- Allow `publish` plugins to return an `Object` with information related to the releases - Add the `success` plugin hook, called when all `publish` are successful, receiving a list of release - Add the `fail` plugin hook, called when an error happens at any point, receiving a list of errors - Add detailed message for each error
65 lines
2.5 KiB
JavaScript
Executable File
65 lines
2.5 KiB
JavaScript
Executable File
const program = require('commander');
|
|
const {pickBy, isUndefined} = require('lodash');
|
|
|
|
function list(values) {
|
|
return values
|
|
.split(',')
|
|
.map(value => value.trim())
|
|
.filter(value => value && value !== 'false');
|
|
}
|
|
|
|
module.exports = async () => {
|
|
program
|
|
.name('semantic-release')
|
|
.description('Run automated package publishing')
|
|
.option('-b, --branch <branch>', 'Branch to release from')
|
|
.option('-r, --repository-url <repositoryUrl>', 'Git repository URL')
|
|
.option('-t, --tag-format <tagFormat>', `Git tag format`)
|
|
.option('-e, --extends <paths>', 'Comma separated list of shareable config paths or packages name', list)
|
|
.option(
|
|
'--verify-conditions <paths>',
|
|
'Comma separated list of paths or packages name for the verifyConditions plugin(s)',
|
|
list
|
|
)
|
|
.option('--analyze-commits <path>', 'Path or package name for the analyzeCommits plugin')
|
|
.option(
|
|
'--verify-release <paths>',
|
|
'Comma separated list of paths or packages name for the verifyRelease plugin(s)',
|
|
list
|
|
)
|
|
.option('--generate-notes <path>', 'Path or package name for the generateNotes plugin')
|
|
.option('--publish <paths>', 'Comma separated list of paths or packages name for the publish plugin(s)', list)
|
|
.option('--success <paths>', 'Comma separated list of paths or packages name for the success plugin(s)', list)
|
|
.option('--fail <paths>', 'Comma separated list of paths or packages name for the fail plugin(s)', list)
|
|
.option(
|
|
'--no-ci',
|
|
'Skip Continuous Integration environment verifications, allowing to make releases from a local machine'
|
|
)
|
|
.option('--debug', 'Output debugging information')
|
|
.option(
|
|
'-d, --dry-run',
|
|
'Dry-run mode, skipping verifyConditions, publishing and release, printing next version and release notes'
|
|
)
|
|
.parse(process.argv);
|
|
|
|
if (program.debug) {
|
|
// Debug must be enabled before other requires in order to work
|
|
require('debug').enable('semantic-release:*');
|
|
}
|
|
|
|
try {
|
|
if (program.args.length > 0) {
|
|
program.outputHelp();
|
|
process.exitCode = 1;
|
|
} else {
|
|
const opts = program.opts();
|
|
// Set the `noCi` options as commander.js sets the `ci` options instead (because args starts with `--no`)
|
|
opts.noCi = opts.ci === false ? true : undefined;
|
|
// Remove option with undefined values, as commander.js sets non defined options as `undefined`
|
|
await require('.')(pickBy(opts, value => !isUndefined(value)));
|
|
}
|
|
} catch (err) {
|
|
process.exitCode = 1;
|
|
}
|
|
};
|