-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const { Select } = require('enquirer'); | ||
const { readFileSync, writeFileSync, write } = require('fs'); | ||
const { join } = require('path'); | ||
const { parse, stringify } = require('semver-utils'); | ||
const { execSync } = require('child_process'); | ||
|
||
const prompt = new Select({ | ||
name: 'semver', | ||
message: 'Choose a version change level (semver):', | ||
choices: ['patch', 'minor', 'major'], | ||
}); | ||
|
||
prompt | ||
.run() | ||
.then(async answer => { | ||
const vfile = join(__dirname, '../version'); | ||
const pfile = join(__dirname, '../package.json'); | ||
const current = readFileSync(vfile).toString(); | ||
console.log('Current version:', current); | ||
|
||
const semver = parse(current); | ||
|
||
semver[answer] = parseInt(semver[answer], 10) + 1; | ||
const bumped = stringify(semver); | ||
console.log('New version:', bumped); | ||
|
||
const package = require(pfile); | ||
package.version = bumped; | ||
|
||
writeFileSync(pfile, JSON.stringify(package, null, 2)); | ||
writeFileSync(vfile, bumped); | ||
|
||
console.log('Version updated'); | ||
|
||
execSync( | ||
`git add version package.json && git commit -m "Release ${bumped}"`, | ||
{ | ||
cwd: join(__dirname, '../'), | ||
}, | ||
); | ||
|
||
console.log('Commit made for the automatic release'); | ||
}) | ||
.catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters