77 * Updates:
88 * - public/versioning.js — VERSION constant
99 * - package.json — "version" field
10+ * - package-lock.json — top-level "version" and packages[""].version fields
1011 * - src/index.html — ?v= cache-busting hashes for changed public/*.js files
1112 *
1213 * Usage:
@@ -28,6 +29,7 @@ const {execSync} = require("child_process");
2829
2930const repoRoot = path . resolve ( __dirname , ".." ) ;
3031const packageJsonPath = path . join ( repoRoot , "package.json" ) ;
32+ const packageLockJsonPath = path . join ( repoRoot , "package-lock.json" ) ;
3133const versioningPath = path . join ( repoRoot , "public" , "versioning.js" ) ;
3234const indexHtmlPath = path . join ( repoRoot , "src" , "index.html" ) ;
3335
@@ -138,6 +140,22 @@ function updatePackageJson(newVersion, dry) {
138140 console . log ( ` package.json ${ oldVersion } → ${ newVersion } ` ) ;
139141}
140142
143+ function updatePackageLockJson ( newVersion , dry ) {
144+ if ( ! fs . existsSync ( packageLockJsonPath ) ) {
145+ console . log ( " package-lock.json (not found, skipping)" ) ;
146+ return ;
147+ }
148+ const original = readFile ( packageLockJsonPath ) ;
149+ const lock = JSON . parse ( original ) ;
150+ const oldVersion = lock . version ;
151+ lock . version = newVersion ;
152+ if ( lock . packages && lock . packages [ "" ] ) {
153+ lock . packages [ "" ] . version = newVersion ;
154+ }
155+ if ( ! dry ) writeFile ( packageLockJsonPath , `${ JSON . stringify ( lock , null , 2 ) } \n` ) ;
156+ console . log ( ` package-lock.json ${ oldVersion } → ${ newVersion } ` ) ;
157+ }
158+
141159function updateIndexHtmlHashes ( newVersion , dry ) {
142160 const changedFiles = getChangedPublicJsFiles ( ) ;
143161
@@ -231,6 +249,7 @@ async function main() {
231249
232250 updateVersioningJs ( newVersion , dry ) ;
233251 updatePackageJson ( newVersion , dry ) ;
252+ updatePackageLockJson ( newVersion , dry ) ;
234253 updateIndexHtmlHashes ( newVersion , dry ) ;
235254
236255 console . log ( `\n[bump-version] ${ dry ? "(dry run) " : "" } done.\n` ) ;
0 commit comments