mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-09 01:03:54 +01:00
078a62cb0d
Replaces the `npm run allbuild` script with the `npm version` command. It creates a new commit with a standardized message & includes the built app. Usage: `npm version [patch | minor | version | 10.0.0 | etc]` Will update the package.json & perform a bunch of steps in a row: - Runs `npm install` in: - The root directory - The ./electron/ directory - The ./tools/bump-version/ directory - Runs `npm run test` - Update the version string in: - ./electron/package.json (version) - ./src/Constants.ts (VersionString) - ./doc/source/conf.py (version & release) - Runs `npm run doc` (build the markdown documentation) - Runs `npm run build` (production build) - Runs `npm run electron` (electron build) - Runs `git add --all` - Runs `git push -u origin dev && git push --tags`
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
import commandLineArgs from "command-line-args";
|
|
|
|
import fs from "fs/promises";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
// https://github.com/75lb/command-line-args
|
|
const optionDefinitions = [
|
|
{
|
|
name: "version",
|
|
alias: "v",
|
|
type: String,
|
|
required: true,
|
|
},
|
|
];
|
|
|
|
const cliArgs = commandLineArgs(optionDefinitions);
|
|
|
|
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const appPaths = {
|
|
root,
|
|
electronPackage: path.join(root, "./electron/package.json"),
|
|
constants: path.join(root, "./src/Constants.ts"),
|
|
sphinxConf: path.join(root, "./doc/source/conf.py"),
|
|
};
|
|
|
|
async function main(version) {
|
|
console.log(`Updating app files to match v${version}`);
|
|
|
|
const [major, minor] = version.split(".");
|
|
const shortVersion = `${major}.${minor}`;
|
|
|
|
const modifiedElectronPackage = (await fs.readFile(appPaths.electronPackage, "utf8")).replace(
|
|
/(^\s*"version":\s)"(.*)",$/m,
|
|
`$1"${version}",`,
|
|
);
|
|
await fs.writeFile(appPaths.electronPackage, modifiedElectronPackage);
|
|
console.log(`> Modified ${appPaths.electronPackage}`);
|
|
|
|
let modifiedConstants = (await fs.readFile(appPaths.constants, "utf8")).replace(
|
|
/(^\s*?VersionString:\s)"(.*)",/m,
|
|
`$1"${version}",`,
|
|
);
|
|
|
|
await fs.writeFile(appPaths.constants, modifiedConstants);
|
|
console.log(`> Modified ${appPaths.constants}`);
|
|
|
|
let modifiedSphinxConfig = (await fs.readFile(appPaths.sphinxConf, "utf8")).replace(
|
|
/(^version = ')(.*)'$/m,
|
|
`$1${shortVersion}'`,
|
|
);
|
|
modifiedSphinxConfig = modifiedSphinxConfig.replace(/(^release = ')(.*)'$/m, `$1${version}'`);
|
|
await fs.writeFile(appPaths.sphinxConf, modifiedSphinxConfig);
|
|
console.log(`> Modified ${appPaths.sphinxConf}`);
|
|
}
|
|
|
|
main(cliArgs.version).then(() => console.log("Done"));
|