Skip to content

Commit 800c383

Browse files
committed
chore(version): update package-lock.json with new version during release
Signed-off-by: samzong <[email protected]>
1 parent 5aaf352 commit 800c383

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

scripts/version-bump.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const chalk = require('chalk');
1212
const CONFIG = {
1313
PACKAGE_PATH: path.join(__dirname, '../package.json'),
1414
MANIFEST_PATH: path.join(__dirname, '../manifest.json'),
15+
PACKAGE_LOCK_PATH: path.join(__dirname, '../package-lock.json'),
1516
VERSION_TYPES: ['patch', 'minor', 'major', 'prepatch', 'preminor', 'premajor', 'prerelease']
1617
};
1718

@@ -65,6 +66,16 @@ async function updateVersion(type) {
6566
console.log(chalk.green(`✅ Updated manifest.json version number`));
6667
}
6768

69+
if (fs.existsSync(CONFIG.PACKAGE_LOCK_PATH)) {
70+
const packageLockData = JSON.parse(fs.readFileSync(CONFIG.PACKAGE_LOCK_PATH, 'utf8'));
71+
packageLockData.version = newVersion;
72+
if (packageLockData.packages && packageLockData.packages['']) {
73+
packageLockData.packages[''].version = newVersion;
74+
}
75+
fs.writeFileSync(CONFIG.PACKAGE_LOCK_PATH, JSON.stringify(packageLockData, null, 2) + '\n', 'utf8');
76+
console.log(chalk.green(`✅ Updated package-lock.json version number`));
77+
}
78+
6879
try {
6980
// Check if inside a Git repository before attempting Git operations
7081
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
@@ -74,7 +85,7 @@ async function updateVersion(type) {
7485
console.log(chalk.green(`✅ Generated changelog`));
7586

7687
// Stage changed files
77-
runGitCommand(`git add package.json manifest.json CHANGELOG.md`, "Staged version changes");
88+
runGitCommand(`git add package.json manifest.json package-lock.json CHANGELOG.md`, "Staged version changes");
7889

7990
// Commit the changes
8091
runGitCommand(`git commit -m "chore(release): v${newVersion}"`, `Committed version v${newVersion}`);

0 commit comments

Comments
 (0)