build: update version bump script; fix minAppVersion in version.json

This commit is contained in:
aidenlx 2022-01-22 18:01:48 +08:00
parent 772be85e67
commit e015abefd9
3 changed files with 12 additions and 23 deletions

View File

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"dev": "node esbuild.config.mjs", "dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs" "version": "node version-bump.mjs && git add manifest.json versions.json"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",

View File

@ -1,25 +1,14 @@
import { readFile as readFile0, writeFile as writeFile0 } from "fs"; import { readFileSync, writeFileSync } from "fs";
import { exec as exec0 } from "child_process";
import { promisify } from "util";
const exec = promisify(exec0),
readFile = promisify(readFile0),
writeFile = promisify(writeFile0);
const targetVersion = process.env.npm_package_version; const targetVersion = process.env.npm_package_version;
(async () => {
// read minAppVersion from manifest.json and bump version to target version // read minAppVersion from manifest.json and bump version to target version
let menifest = JSON.parse((await readFile("manifest.json")).toString()); let menifest = JSON.parse(readFileSync("manifest.json").toString());
const { minAppVersion } = menifest; const { minAppVersion } = menifest;
menifest.version = targetVersion; menifest.version = targetVersion;
await writeFile("manifest.json", JSON.stringify(menifest, null, "\t")); writeFileSync("manifest.json", JSON.stringify(menifest, null, "\t"));
// update versions.json with target version and minAppVersion from manifest.json // update versions.json with target version and minAppVersion from manifest.json
let versions = JSON.parse((await readFile("versions.json")).toString()); let versions = JSON.parse(readFileSync("versions.json").toString());
versions[targetVersion] = minAppVersion; versions[targetVersion] = minAppVersion;
await writeFile("versions.json", JSON.stringify(versions, null, "\t")); writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
// save changes in git
await exec("git add manifest.json versions.json");
})().catch(() => process.exit(1));

View File

@ -1,4 +1,4 @@
{ {
"1.0.0": "0.9.7", "1.0.0": "0.9.7",
"1.0.1": "0.9.12" "1.0.1": "0.12.0"
} }