Files
cinny/scripts/update-version.js
T

49 lines
1.2 KiB
JavaScript
Raw Normal View History

import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
import { fileURLToPath } from 'url';
2026-03-19 16:26:25 +11:00
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const version = process.argv[2];
if (!version) {
console.error('Version argument missing');
2026-03-19 16:26:25 +11:00
process.exit(1);
}
const root = path.resolve(__dirname, '..');
2026-03-19 16:26:25 +11:00
const newVersionTag = `v${version}`;
// Update package.json + package-lock.json safely
execSync(`npm version ${version} --no-git-tag-version`, {
cwd: root,
stdio: 'inherit',
2026-03-19 16:26:25 +11:00
});
console.log(`Updated package.json and package-lock.json → ${version}`);
// Update UI version references
const files = [
'src/app/features/settings/about/About.tsx',
'src/app/pages/auth/AuthFooter.tsx',
'src/app/pages/client/WelcomePage.tsx',
2026-03-19 16:26:25 +11:00
];
files.forEach((filePath) => {
const absPath = path.join(root, filePath);
if (!fs.existsSync(absPath)) {
console.warn(`File not found: ${filePath}`);
return;
}
const content = fs.readFileSync(absPath, 'utf8');
2026-03-19 16:26:25 +11:00
const updated = content.replace(/v\d+\.\d+\.\d+/g, newVersionTag);
fs.writeFileSync(absPath, updated);
console.log(`Updated ${filePath}${newVersionTag}`);
});