mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-22 15:17:23 +01:00
fix: sync package-lock.json version fields during automated version bump (#1345)
* Initial plan * fix: update package-lock.json version fields during version bump Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
This commit is contained in:
parent
2eeb016c9e
commit
7b49802004
1 changed files with 19 additions and 0 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
* Updates:
|
* Updates:
|
||||||
* - public/versioning.js — VERSION constant
|
* - public/versioning.js — VERSION constant
|
||||||
* - package.json — "version" field
|
* - package.json — "version" field
|
||||||
|
* - package-lock.json — top-level "version" and packages[""].version fields
|
||||||
* - src/index.html — ?v= cache-busting hashes for changed public/*.js files
|
* - src/index.html — ?v= cache-busting hashes for changed public/*.js files
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
|
|
@ -28,6 +29,7 @@ const {execSync} = require("child_process");
|
||||||
|
|
||||||
const repoRoot = path.resolve(__dirname, "..");
|
const repoRoot = path.resolve(__dirname, "..");
|
||||||
const packageJsonPath = path.join(repoRoot, "package.json");
|
const packageJsonPath = path.join(repoRoot, "package.json");
|
||||||
|
const packageLockJsonPath = path.join(repoRoot, "package-lock.json");
|
||||||
const versioningPath = path.join(repoRoot, "public", "versioning.js");
|
const versioningPath = path.join(repoRoot, "public", "versioning.js");
|
||||||
const indexHtmlPath = path.join(repoRoot, "src", "index.html");
|
const indexHtmlPath = path.join(repoRoot, "src", "index.html");
|
||||||
|
|
||||||
|
|
@ -138,6 +140,22 @@ function updatePackageJson(newVersion, dry) {
|
||||||
console.log(` package.json ${oldVersion} → ${newVersion}`);
|
console.log(` package.json ${oldVersion} → ${newVersion}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updatePackageLockJson(newVersion, dry) {
|
||||||
|
if (!fs.existsSync(packageLockJsonPath)) {
|
||||||
|
console.log(" package-lock.json (not found, skipping)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const original = readFile(packageLockJsonPath);
|
||||||
|
const lock = JSON.parse(original);
|
||||||
|
const oldVersion = lock.version;
|
||||||
|
lock.version = newVersion;
|
||||||
|
if (lock.packages && lock.packages[""]) {
|
||||||
|
lock.packages[""].version = newVersion;
|
||||||
|
}
|
||||||
|
if (!dry) writeFile(packageLockJsonPath, `${JSON.stringify(lock, null, 2)}\n`);
|
||||||
|
console.log(` package-lock.json ${oldVersion} → ${newVersion}`);
|
||||||
|
}
|
||||||
|
|
||||||
function updateIndexHtmlHashes(newVersion, dry) {
|
function updateIndexHtmlHashes(newVersion, dry) {
|
||||||
const changedFiles = getChangedPublicJsFiles();
|
const changedFiles = getChangedPublicJsFiles();
|
||||||
|
|
||||||
|
|
@ -231,6 +249,7 @@ async function main() {
|
||||||
|
|
||||||
updateVersioningJs(newVersion, dry);
|
updateVersioningJs(newVersion, dry);
|
||||||
updatePackageJson(newVersion, dry);
|
updatePackageJson(newVersion, dry);
|
||||||
|
updatePackageLockJson(newVersion, dry);
|
||||||
updateIndexHtmlHashes(newVersion, dry);
|
updateIndexHtmlHashes(newVersion, dry);
|
||||||
|
|
||||||
console.log(`\n[bump-version] ${dry ? "(dry run) " : ""}done.\n`);
|
console.log(`\n[bump-version] ${dry ? "(dry run) " : ""}done.\n`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue