diff --git a/.vscodeignore b/.vscodeignore index a3c4f5a..972d070 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -11,3 +11,5 @@ node_modules/.cache/** .github/** .editorconfig icon.svg +scripts/** +VERSION diff --git a/README.md b/README.md index d823419..6355569 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,19 @@ loaded. Open any `.tum` file; the **Testium LSP** output channel shows the language-server traffic when `testium.trace.server` is set to `messages` or `verbose`. +## Versioning + +The extension version lives in the `VERSION` file (single source of truth, like +testium's `src/VERSION`). It must be strict semver `X.Y.Z` — the marketplace and +Open VSX reject `X.Y`. `npm run sync-version` (run automatically by +`npm run package` and `vscode:prepublish`) copies it into `package.json`. To +release, bump `VERSION` and package. + ## Packaging ```sh +npm run package # sync VERSION -> package.json, then vsce package +# or, when already in sync: npx vsce package # produces testium-assist-.vsix ``` diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/package.json b/package.json index 9903966..bdd052d 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,11 @@ }, "testium.trace.server": { "type": "string", - "enum": ["off", "messages", "verbose"], + "enum": [ + "off", + "messages", + "verbose" + ], "default": "off", "description": "Trace the LSP communication between VSCode and the testium server in the Output panel." } @@ -59,9 +63,11 @@ } }, "scripts": { + "sync-version": "node scripts/sync-version.js", "compile": "tsc -p .", "watch": "tsc -p . --watch", - "vscode:prepublish": "npm run compile" + "package": "npm run sync-version && npx --yes @vscode/vsce package", + "vscode:prepublish": "npm run sync-version && npm run compile" }, "dependencies": { "vscode-languageclient": "^9.0.0" diff --git a/scripts/sync-version.js b/scripts/sync-version.js new file mode 100644 index 0000000..f91a783 --- /dev/null +++ b/scripts/sync-version.js @@ -0,0 +1,36 @@ +#!/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}`); +}