mirror of
https://github.com/fancive/obsidian-parallel-reader.git
synced 2026-07-22 06:53:43 +00:00
build: add version bump script
npm run version <x.y.z> atomically updates manifest.json and versions.json. Replaces the manual three-file version dance. Change-Id: Ib894147f654b284d8f4c1df95bd8ff5da80d5dcc
This commit is contained in:
parent
e5f5af43ca
commit
e10cbbbe9c
2 changed files with 35 additions and 0 deletions
|
|
@ -9,6 +9,7 @@
|
|||
"typecheck": "tsc --noEmit",
|
||||
"lint": "biome check main.ts src/",
|
||||
"lint:fix": "biome check --write main.ts src/",
|
||||
"version": "node scripts/bump-version.mjs",
|
||||
"test": "npm run build && npm run typecheck && node scripts/run-tests.mjs",
|
||||
"test:only": "node scripts/run-tests.mjs"
|
||||
},
|
||||
|
|
|
|||
34
scripts/bump-version.mjs
Normal file
34
scripts/bump-version.mjs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Bump plugin version in manifest.json and versions.json atomically.
|
||||
* Usage: node scripts/bump-version.mjs <version>
|
||||
* Example: node scripts/bump-version.mjs 1.0.8
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
const version = process.argv[2];
|
||||
|
||||
if (!version || !/^\d+\.\d+\.\d+$/.test(version)) {
|
||||
console.error('Usage: node scripts/bump-version.mjs <version>');
|
||||
console.error('Example: node scripts/bump-version.mjs 1.0.8');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const manifestPath = path.join(root, 'manifest.json');
|
||||
const versionsPath = path.join(root, 'versions.json');
|
||||
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||
const versions = JSON.parse(fs.readFileSync(versionsPath, 'utf8'));
|
||||
|
||||
const oldVersion = manifest.version;
|
||||
manifest.version = version;
|
||||
versions[version] = manifest.minAppVersion;
|
||||
|
||||
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, '\t') + '\n');
|
||||
fs.writeFileSync(versionsPath, JSON.stringify(versions, null, '\t') + '\n');
|
||||
|
||||
console.log(`Bumped version: ${oldVersion} → ${version}`);
|
||||
console.log(`Updated: manifest.json, versions.json`);
|
||||
Loading…
Reference in a new issue