diff --git a/package.json b/package.json index 555f6e26..3acf52a1 100644 --- a/package.json +++ b/package.json @@ -205,10 +205,9 @@ "lint:grammar": "cspell ./src", "postinstall": "npx grunt exec:fixCryptoApiImports && npx grunt exec:fixSnackbarMarkup", "newop": "node src/core/config/scripts/newOperation.mjs", - "minor": "node src/core/config/scripts/newMinorVersion.mjs && npm version minor --git-tag-version=false && echo \"Updated to version v$(npm pkg get version | xargs), please create a pull request and once merged use 'npm run tag'\"", - "tag": "git tag -s \"v$(npm pkg get version | xargs)\" -m \"$(npm pkg get version | xargs)\" && echo \"Created v$(npm pkg get version | xargs), now check and push the tag\"", - "getheapsize": "node -e 'console.log(`node heap limit = ${require(\"v8\").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'", - "setheapsize": "export NODE_OPTIONS=--max_old_space_size=2048" + "minor": "node src/core/config/scripts/bumpMinor.mjs", + "tag": "node src/core/config/scripts/tagRelease.mjs", + "getheapsize": "node --no-warnings src/core/config/scripts/getHeapSize.mjs" }, "engines": { "node": ">=24 <25" diff --git a/plan-buildsystem-agnostic.md b/plan-buildsystem-agnostic.md index b5ae7b1a..9e23dbb8 100644 --- a/plan-buildsystem-agnostic.md +++ b/plan-buildsystem-agnostic.md @@ -16,9 +16,9 @@ Stages are executed by Leon, not the agent. Tick each box once the stage is done - [x] 1g. Webpack output path uses `path.join` _(2026-05-19)_ ### Section 2 — [package.json](package.json) -- [ ] 2a. `setheapsize` deleted -- [ ] 2b. `getheapsize` switched to `getHeapSize.mjs` -- [ ] 2c. `minor` / `tag` switched to `.mjs` orchestrators +- [x] 2a. `setheapsize` deleted _(2026-05-19)_ +- [x] 2b. `getheapsize` switched to `getHeapSize.mjs` _(2026-05-19)_ +- [x] 2c. `minor` / `tag` switched to `.mjs` orchestrators _(2026-05-19)_ ### Verification - [ ] macOS: 7-step verification pass (see "Verification" section below) diff --git a/src/core/config/scripts/bumpMinor.mjs b/src/core/config/scripts/bumpMinor.mjs new file mode 100644 index 00000000..01e1dcad --- /dev/null +++ b/src/core/config/scripts/bumpMinor.mjs @@ -0,0 +1,27 @@ +/** + * Orchestrates a minor version bump: regenerates the CHANGELOG via + * newMinorVersion.mjs, runs `npm version minor` (without a git tag), + * then prints a follow-up message that includes the new version. + * + * Replaces the previous shell-substitution npm script so it works on + * Windows cmd.exe as well as POSIX shells. + * + * @author n1474335 [n1474335@gmail.com] + * @copyright Crown Copyright 2026 + * @license Apache-2.0 + */ + +/* eslint no-console: ["off"] */ + +import { execSync } from "child_process"; +import { readFileSync } from "fs"; +import { dirname, join } from "path"; +import { fileURLToPath } from "url"; + +const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..", "package.json"); + +execSync("node src/core/config/scripts/newMinorVersion.mjs", { stdio: "inherit" }); +execSync("npm version minor --git-tag-version=false", { stdio: "inherit" }); + +const version = JSON.parse(readFileSync(pkgPath, "utf8")).version; +console.log(`Updated to version v${version}, please create a pull request and once merged use 'npm run tag'`); diff --git a/src/core/config/scripts/getHeapSize.mjs b/src/core/config/scripts/getHeapSize.mjs new file mode 100644 index 00000000..0cdde0b7 --- /dev/null +++ b/src/core/config/scripts/getHeapSize.mjs @@ -0,0 +1,13 @@ +/** + * Prints the Node V8 heap size limit in MB. + * + * @author n1474335 [n1474335@gmail.com] + * @copyright Crown Copyright 2026 + * @license Apache-2.0 + */ + +/* eslint no-console: ["off"] */ + +import v8 from "v8"; + +console.log(`node heap limit = ${v8.getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`); diff --git a/src/core/config/scripts/tagRelease.mjs b/src/core/config/scripts/tagRelease.mjs new file mode 100644 index 00000000..3be8624f --- /dev/null +++ b/src/core/config/scripts/tagRelease.mjs @@ -0,0 +1,24 @@ +/** + * Creates a signed git tag matching the version in package.json, + * then prints a follow-up message. + * + * Replaces the previous shell-substitution npm script so it works on + * Windows cmd.exe as well as POSIX shells. + * + * @author n1474335 [n1474335@gmail.com] + * @copyright Crown Copyright 2026 + * @license Apache-2.0 + */ + +/* eslint no-console: ["off"] */ + +import { execSync } from "child_process"; +import { readFileSync } from "fs"; +import { dirname, join } from "path"; +import { fileURLToPath } from "url"; + +const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..", "package.json"); +const version = JSON.parse(readFileSync(pkgPath, "utf8")).version; + +execSync(`git tag -s "v${version}" -m "${version}"`, { stdio: "inherit" }); +console.log(`Created v${version}, now check and push the tag`);