Mirrors testium's src/VERSION: scripts/sync-version.js copies VERSION into package.json#version (enforcing strict semver X.Y.Z, required by the marketplace / Open VSX). Wired into 'npm run package' and vscode:prepublish, so the version is always synced before a build/publish. Bump = edit VERSION. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* Sync package.json "version" from the VERSION file — the single source of
|
|
* truth for the extension version (mirroring testium's src/VERSION).
|
|
*
|
|
* Bump the extension by editing VERSION, then run `npm run package` (or any
|
|
* flow that triggers vscode:prepublish): this script overwrites
|
|
* package.json#version to match. Unlike testium's VERSION (which may be X.Y),
|
|
* the marketplace / Open VSX require strict semver X.Y.Z, so VERSION must be
|
|
* X.Y.Z (optionally with a -prerelease suffix).
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const root = path.resolve(__dirname, "..");
|
|
const versionFile = path.join(root, "VERSION");
|
|
const pkgFile = path.join(root, "package.json");
|
|
|
|
const version = fs.readFileSync(versionFile, "utf8").trim();
|
|
if (!/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(version)) {
|
|
console.error(
|
|
`sync-version: VERSION '${version}' is not strict semver (X.Y.Z) — ` +
|
|
`required by the marketplace / Open VSX.`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
const pkg = JSON.parse(fs.readFileSync(pkgFile, "utf8"));
|
|
if (pkg.version === version) {
|
|
console.log(`sync-version: package.json already at ${version}`);
|
|
} else {
|
|
const previous = pkg.version;
|
|
pkg.version = version;
|
|
fs.writeFileSync(pkgFile, JSON.stringify(pkg, null, 2) + "\n");
|
|
console.log(`sync-version: package.json ${previous} -> ${version}`);
|
|
}
|