Skip to content

Commit

Permalink
Change zips output dir
Browse files Browse the repository at this point in the history
  • Loading branch information
keupoz committed Dec 31, 2023
1 parent 16057da commit 047ef48
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion 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
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 047ef48

Please sign in to comment.