Allow compiling singular version
This commit is contained in:
parent
7121f46fe6
commit
848a1ae3d6
@ -12,6 +12,7 @@ build-packs
|
||||
* `-d` or `--data` - The data directory containing the data files. Defailts to data.
|
||||
* `-r` or `--revision` - The revision/version. Defaults to `git rev-parse --short HEAD` if .git exists, else required.
|
||||
* `-i` or `--info` - The info file. Defaults to info.json.
|
||||
* `-v` or `--version` - Only compile this version.
|
||||
|
||||
### Info File
|
||||
An `info.json` file should be present in the input directory. This file should contain the following fields:
|
||||
|
15
index.ts
15
index.ts
@ -30,7 +30,7 @@ interface Info {
|
||||
}
|
||||
|
||||
|
||||
const { values: { indir: inDir, data: dataDir, revision: rev, outdir: outDir, info: infoPath } } = parseArgs({
|
||||
const { values: { indir: inDir, data: dataDir, revision: rev, outdir: outDir, info: infoPath, version: onlyVersion } } = parseArgs({
|
||||
args: Bun.argv,
|
||||
options: {
|
||||
indir: {
|
||||
@ -56,6 +56,10 @@ const { values: { indir: inDir, data: dataDir, revision: rev, outdir: outDir, in
|
||||
type: "string",
|
||||
default: "info.json"
|
||||
},
|
||||
version: {
|
||||
type: "string",
|
||||
short: "v"
|
||||
}
|
||||
},
|
||||
strict: true,
|
||||
allowPositionals: true
|
||||
@ -100,6 +104,10 @@ const tempDir = await mkdtemp(`${tmpdir()}/${info.name.toLowerCase().replaceAll(
|
||||
console.log("Temporary Directory:", tempDir);
|
||||
let totalSize = 0;
|
||||
async function createVersion(mcVersion: string, packFormat: number) {
|
||||
if (onlyVersion && mcVersion !== onlyVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
let dataDir = data;
|
||||
if (info.overrides) {
|
||||
const override = info.overrides[mcVersion];
|
||||
@ -147,7 +155,9 @@ for (const [mcVersion, packFormat] of info.versions) {
|
||||
await rm(tempDir, { recursive: true, force: true });
|
||||
|
||||
console.log("Total size: %s", prettyBytes(totalSize));
|
||||
|
||||
if (onlyVersion) {
|
||||
console.log("Skipping exports due to version filter");
|
||||
} else {
|
||||
for (const ex of info.exports) {
|
||||
const name = (ex[0] === "all" ? info.name : `${info.name}-${ex.join("-")}`).replaceAll(" ", "");
|
||||
console.log("Exporting %s", name);
|
||||
@ -160,5 +170,6 @@ for (const ex of info.exports) {
|
||||
const { size } = await stat(`${dist}/${name}.zip`);
|
||||
console.log("%s exported, size: %s", name, prettyBytes(size));
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Done");
|
||||
|
Loading…
Reference in New Issue
Block a user