-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- new: dry-run option, only logs the commands without changing anything
- some cleanup
- Loading branch information
Showing
7 changed files
with
76 additions
and
49 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
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,25 @@ | ||
const readJsonSync = require('read-json-sync'); | ||
const args = require('args'); | ||
const log = require('./log'); | ||
|
||
args.option('message', 'enter a custom tag message'); | ||
args.option('dry-run', 'only show the commands that would be executed without changing anything', false); | ||
args.option('bump-files', 'a list of .json files where the version field should be bumped', ['package.json']); | ||
args.option('skip-build', `skip build before finishing release`); | ||
|
||
const flags = args.parse(process.argv); | ||
const pkgConfig = readJsonSync('./package.json').releaseConfig || {}; | ||
const configDefault = { | ||
versionFiles: ['package.json'], | ||
productionBranchName: 'master', | ||
developBranchName: 'develop', | ||
buildCommand: false, | ||
historyFile: false | ||
}; | ||
const config = Object.assign({}, configDefault, pkgConfig); | ||
|
||
flags.d && console.log('\nflags:', flags, '\n\nConfig: \n', config, '\n'); | ||
|
||
module.exports.config = config; | ||
|
||
module.exports.flags = flags; |
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 |
---|---|---|
@@ -1,22 +1,21 @@ | ||
const shellEx = require('../lib/ex').shellEx; | ||
const dateFormat = require('dateformat'); | ||
const shellEx = require('./ex').shellEx; | ||
const handleError = require('./handle-error'); | ||
|
||
const getDate = () => { | ||
const d = new Date(); | ||
const getHistoryString = (currentVersion, newVersion) => { | ||
const logCommand = shellEx(`git log ${currentVersion}..HEAD --pretty=format:" * %s"`); | ||
const date = dateFormat(new Date(), 'longDate'); | ||
|
||
const months = ['January', 'February', 'March', 'April', 'May', 'June', | ||
'July', 'August', 'September', 'October', 'November', 'December']; | ||
if (logCommand.code !== 0) { | ||
handleError(logCommand.stderr); | ||
} | ||
|
||
return `${months[d.getMonth()]} ${d.getDate()}, ${d.getFullYear()}`; | ||
}; | ||
|
||
module.exports = (currentVersion, newVersion) => { | ||
const logCommand = shellEx(`git log ${currentVersion}..HEAD --pretty=format:" * %s"`); | ||
const date = getDate(); | ||
return `###${newVersion} — *${date}*\n\n${logCommand.stdout}\n`; | ||
}; | ||
|
||
if (logCommand.code !== 0) { | ||
handleError(logCommand.stderr); | ||
} | ||
|
||
return `###${newVersion} — *${date}*\n\n${logCommand.stdout}\n`; | ||
const writeHistoryFile = (currentVersion, newVersion, file) => { | ||
const historyText = getHistoryString(currentVersion, newVersion); | ||
shellEx(`echo "${historyText}\n$(cat ${file})" > ${file}`); | ||
}; | ||
|
||
module.exports.writeHistoryFile = writeHistoryFile; |
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