Skip to content

Commit

Permalink
Merge pull request #2 from Love-and-Tolerance/zips-change
Browse files Browse the repository at this point in the history
Zips change
  • Loading branch information
keupoz authored Dec 31, 2023
2 parents b4bea6f + 047ef48 commit 97c07c7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
45 changes: 24 additions & 21 deletions assets/java.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"templates": {
"zips_path": "assets/zips/java/{name}.zip",
"zips_path": "java/{name}.zip",
"base_zip_name": "BASE",
"variant_addon_zip_name": "EXCLUSIVE_ADDON_{id_pos}_{variant}_{branch}",
"regular_addon_zip_name": "REGULAR_ADDON_{id}_{branch}",
Expand Down Expand Up @@ -227,26 +227,29 @@
{ "name": "Modrinth", "url": "https://modrinth.com/mod/trinkets" }
]
},
{
"name": "AppleSkin",
"id": "as",
"recommended": false,
"info": ["Fabric"],
"url": "https://github.com/Love-and-Tolerance/AppleSkin-Mod-Support",
"links": [
{ "name": "Modrinth", "url": "https://modrinth.com/mod/appleskin" }
]
},
{
"name": "Eating Animations",
"id": "ea",
"recommended": false,
"info": ["Fabric"],
"url": "https://github.com/Love-and-Tolerance/EatingAnimations-Mod-Support",
"links": [
{ "name": "Modrinth", "url": "https://modrinth.com/mod/eating-animation" }
]
},
{
"name": "AppleSkin",
"id": "as",
"recommended": false,
"info": ["Fabric"],
"url": "https://github.com/Love-and-Tolerance/AppleSkin-Mod-Support",
"links": [
{ "name": "Modrinth", "url": "https://modrinth.com/mod/appleskin" }
]
},
{
"name": "Eating Animations",
"id": "ea",
"recommended": false,
"info": ["Fabric"],
"url": "https://github.com/Love-and-Tolerance/EatingAnimations-Mod-Support",
"links": [
{
"name": "Modrinth",
"url": "https://modrinth.com/mod/eating-animation"
}
]
},
{
"name": "Create",
"id": "crt",
Expand Down
15 changes: 9 additions & 6 deletions scripts/fetchZips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ console.info("Reading json files ...".blue.text_bold);

const JAVA_ASSETS = readJson("assets/java.json", JavaAssetsSchema);

const ZIPS_DIR = JAVA_ASSETS.templates.zips_path.replace("{name}.zip", "");
const ZIPS_DIR = ".temp/zips";
const REPOS_DIR = ".temp/repos";
const JAVA_ZIPS_DIR = JAVA_ASSETS.templates.zips_path.replace("{name}.zip", "");

const zipStack: ZipInfo[] = [];

Expand All @@ -44,7 +45,7 @@ async function prepareRepo(
zipStack.push({ name, files });
}

clean(ZIPS_DIR, REPOS_DIR);
clean(`${ZIPS_DIR}/${JAVA_ZIPS_DIR}`, REPOS_DIR);

console.log("");
console.info("Processing repos ...".blue.text_bold);
Expand Down Expand Up @@ -137,12 +138,14 @@ if (isProduction) {
console.log("");
console.info("Creating zips ...".blue.text_bold);
for (const info of zipStack) {
const dir = `${REPOS_DIR}/${info.name}`;
const name = JAVA_ASSETS.templates.zips_path.replace("{name}", info.name);
const src = `${REPOS_DIR}/${info.name}`;

console.info(`${dir} -> ${name} ...`.black.text_bold);
let dest = JAVA_ASSETS.templates.zips_path.replace("{name}", info.name);
dest = `${ZIPS_DIR}/${dest}`;

await compress(dir, name, info.files);
console.info(`${src} -> ${dest} ...`.black.text_bold);

await compress(src, dest, info.files);
}

console.log("");
Expand Down
8 changes: 4 additions & 4 deletions scripts/utils/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { relative } from "path";
import { run } from "run_simple";

export async function compress(
dir: string,
archiveName: string,
src: string,
dest: string,
files?: string | string[],
): Promise<void> {
if (files === undefined) {
Expand All @@ -12,7 +12,7 @@ export async function compress(
files = [files];
}

await run(["zip", "-r9q", relative(dir, archiveName), ...files], {
cwd: dir,
await run(["zip", "-r9q", relative(src, dest), ...files], {
cwd: src,
});
}

0 comments on commit 97c07c7

Please sign in to comment.