Skip to content

Commit 42750c9

Browse files
committed
chore: Add script to automate version bumping across project configuration files.
1 parent f43e1ad commit 42750c9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/bump-version.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* - package-lock.json
66
* - src-tauri/tauri.conf.json
77
* - src-tauri/Cargo.toml
8+
* - vscode-extension/package.json
9+
* - vscode-extension/package-lock.json
810
*
911
* Branch rules:
1012
* - If on dev: fail if there are staged changes; otherwise checkout master and merge dev, then continue.
@@ -13,7 +15,7 @@
1315
*
1416
* Defensive rules:
1517
* - Refuses to run if working tree is dirty before starting.
16-
* - After edits, verifies only the four files changed.
18+
* - After edits, verifies only the expected files changed.
1719
* - Aborts (no commit) if any other file changes.
1820
* - Fails if the tag already exists before creating it.
1921
* - Pushes branch and tag after committing.
@@ -32,6 +34,7 @@ const expectedFiles = [
3234
path.join("src-tauri", "tauri.conf.json"),
3335
path.join("src-tauri", "Cargo.toml"),
3436
path.join("vscode-extension", "package.json"),
37+
path.join("vscode-extension", "package-lock.json"),
3538
];
3639

3740
function run(cmd, opts = {}) {
@@ -164,6 +167,16 @@ async function bumpVsCodeExtension(version) {
164167
await writeFile(file, JSON.stringify(pkg, null, 4) + "\n", "utf8");
165168
}
166169

170+
async function bumpVsCodeExtensionLock(version) {
171+
const file = path.join("vscode-extension", "package-lock.json");
172+
const lock = JSON.parse(await readFile(file, "utf8"));
173+
lock.version = version;
174+
if (lock.packages && lock.packages[""]) {
175+
lock.packages[""].version = version;
176+
}
177+
await writeFile(file, JSON.stringify(lock, null, 4) + "\n", "utf8");
178+
}
179+
167180
function verifyOnlyExpectedChanged() {
168181
const diffNames = run("git diff --name-only");
169182
const changed = diffNames ? diffNames.split(/\r?\n/).filter(Boolean) : [];
@@ -231,6 +244,7 @@ async function main() {
231244
await bumpTauriConf(version);
232245
await bumpCargoToml(version);
233246
await bumpVsCodeExtension(version);
247+
await bumpVsCodeExtensionLock(version);
234248

235249
verifyOnlyExpectedChanged();
236250
ensureTagAvailable(version);

0 commit comments

Comments
 (0)