Skip to content
Snippets Groups Projects
Commit 64677c70 authored by Ali Asaria's avatar Ali Asaria
Browse files

bump version asks for confirmation first

parent 43bc22af
No related branches found
No related tags found
No related merge requests found
const fs = require('fs'); const fs = require('fs');
const { execSync } = require('child_process'); const { execSync } = require('child_process');
const { version } = require('os'); const { version } = require('os');
const readline = require('node:readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const files = [ const files = [
'package.json', 'package.json',
...@@ -47,15 +53,23 @@ if (versionPart === 'patch') versionParts[2] = parseInt(versionParts[2]) + 1; // ...@@ -47,15 +53,23 @@ if (versionPart === 'patch') versionParts[2] = parseInt(versionParts[2]) + 1; //
const newVersion = versionParts.join('.'); const newVersion = versionParts.join('.');
console.log(`Bumping version from ${currentVersion} to ${newVersion}`); console.log(`Bumping version from ${currentVersion} to ${newVersion}`);
files.forEach((file) => { rl.question(`Do you want to continue? (y/n) `, (answer) => {
bumpVersion(file, newVersion); rl.close();
}); if (answer.toLowerCase() !== 'y' && answer.toLowerCase() !== 'yes') {
console.log('Exiting process...');
process.exit(1);
} else {
files.forEach((file) => {
bumpVersion(file, newVersion);
});
// Add the updated files to git, commit the changes, and tag the new commit // Add the updated files to git, commit the changes, and tag the new commit
execSync(`git add ${files.join(' ')}`); execSync(`git add ${files.join(' ')}`);
execSync(`git commit -m "Bump version to ${newVersion}"`); execSync(`git commit -m "Bump version to ${newVersion}"`);
execSync(`git tag v${newVersion}`); execSync(`git tag v${newVersion}`);
console.log( console.log(
'A new commit and tag have been created. Please push the changes to the remote repository to trigger a new build.' 'A new commit and tag have been created. Please push the changes to the remote repository to trigger a new build.'
); );
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment