Skip to content

Commit 0ba6a79

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

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

scripts/version-bump.js

Lines changed: 17 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,21 @@ 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+
try {
71+
const packageLockData = JSON.parse(fs.readFileSync(CONFIG.PACKAGE_LOCK_PATH, 'utf8'));
72+
packageLockData.version = newVersion;
73+
if (packageLockData.packages && packageLockData.packages['']) {
74+
packageLockData.packages[''].version = newVersion;
75+
}
76+
fs.writeFileSync(CONFIG.PACKAGE_LOCK_PATH, JSON.stringify(packageLockData, null, 2) + '\n', 'utf8');
77+
console.log(chalk.green(`✅ Updated package-lock.json version number`));
78+
} catch (error) {
79+
console.error(chalk.red(`❌ Failed to update package-lock.json: ${error.message}`));
80+
throw error;
81+
}
82+
}
83+
6884
try {
6985
// Check if inside a Git repository before attempting Git operations
7086
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
@@ -74,7 +90,7 @@ async function updateVersion(type) {
7490
console.log(chalk.green(`✅ Generated changelog`));
7591

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

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

0 commit comments

Comments
 (0)