feat(build): add update-version.js to auto-increment patch on every build
Script runs before vite build via package.json "build" script. Reads/writes APP_VERSION in frontend/constants.ts (now at V1.0.3). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1 +1 @@
|
|||||||
export const APP_VERSION = 'V1.0.2';
|
export const APP_VERSION = 'V1.0.3';
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "node ../update-version.js && vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// Increments the patch number in frontend/constants.ts before every build.
|
||||||
|
// Called via: node ../update-version.js (from inside frontend/)
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const constantsPath = path.join(__dirname, 'frontend', 'constants.ts');
|
||||||
|
const content = fs.readFileSync(constantsPath, 'utf8');
|
||||||
|
|
||||||
|
const match = content.match(/APP_VERSION\s*=\s*['"]V(\d+)\.(\d+)\.(\d+)['"]/);
|
||||||
|
if (!match) {
|
||||||
|
console.error('[update-version] Could not parse APP_VERSION in constants.ts');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [, major, minor, patch] = match;
|
||||||
|
const next = `V${major}.${minor}.${parseInt(patch, 10) + 1}`;
|
||||||
|
const updated = content.replace(
|
||||||
|
/APP_VERSION\s*=\s*['"]V\d+\.\d+\.\d+['"]/,
|
||||||
|
`APP_VERSION = '${next}'`
|
||||||
|
);
|
||||||
|
|
||||||
|
fs.writeFileSync(constantsPath, updated, 'utf8');
|
||||||
|
console.log(`[update-version] ${match[0].match(/V\d+\.\d+\.\d+/)[0]} → ${next}`);
|
||||||
Reference in New Issue
Block a user