-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbump-version.js
29 lines (21 loc) · 1.02 KB
/
bump-version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const fs = require('fs');
const { execSync } = require('child_process');
// Script for automatic version bumping of Phone-island component
// Path to package.json
const packageJsonPath = './package.json';
// Read package.json content
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
// Increment version number
// Split version into major.minor.patch and convert to numbers
const currentVersion = packageJson.version;
const [major, minor, patch] = currentVersion.split('.').map(Number);
const newVersion = `${major}.${minor}.${patch + 1}`;
// Update version in package.json object
packageJson.version = newVersion;
// Write the new version back to package.json
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log(`Version updated: ${currentVersion} -> ${newVersion}`);
// Regenerate package-lock.json to ensure dependency consistency
console.log('Updating package-lock.json...');
execSync('npm install --package-lock-only', { stdio: 'inherit' });
console.log('Process completed.');