forked from github/cinny
* chore: install deps related to semantic release * chore: add husky config * ci: add a script to update version number on new release * ci: update ci/cd to include semantic release changes * chore: merge dev to semantic-release
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import fs from "fs";
|
|
import path from "path";
|
|
import { execSync } from "child_process";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const version = process.argv[2];
|
|
|
|
if (!version) {
|
|
console.error("Version argument missing");
|
|
process.exit(1);
|
|
}
|
|
|
|
const root = path.resolve(__dirname, "..");
|
|
const newVersionTag = `v${version}`;
|
|
|
|
// Update package.json + package-lock.json safely
|
|
execSync(`npm version ${version} --no-git-tag-version`, {
|
|
cwd: root,
|
|
stdio: "inherit",
|
|
});
|
|
|
|
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",
|
|
];
|
|
|
|
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");
|
|
const updated = content.replace(/v\d+\.\d+\.\d+/g, newVersionTag);
|
|
|
|
fs.writeFileSync(absPath, updated);
|
|
|
|
console.log(`Updated ${filePath} → ${newVersionTag}`);
|
|
}); |