/
command.js
executable file
·125 lines (120 loc) · 3.74 KB
/
command.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const findUp = require('find-up')
const defaults = require('./defaults')
const { readFileSync } = require('fs')
const configPath = findUp.sync(['.versionrc', '.version.json'])
const config = configPath ? JSON.parse(readFileSync(configPath)) : {}
const spec = require('conventional-changelog-config-spec')
const yargs = require('yargs')
.usage('Usage: $0 [options]')
.option('release-as', {
alias: 'r',
describe: 'Specify the release type manually (like npm version <major|minor|patch>)',
requiresArg: true,
string: true
})
.option('prerelease', {
alias: 'p',
describe: 'make a pre-release with optional option value to specify a tag id',
string: true
})
.option('infile', {
alias: 'i',
describe: 'Read the CHANGELOG from this file',
default: defaults.infile
})
.option('message', {
alias: 'm',
describe: 'Commit message, replaces %s with new version',
type: 'string',
default: defaults.message
})
.option('first-release', {
alias: 'f',
describe: 'Is this the first release?',
type: 'boolean',
default: defaults.firstRelease
})
.option('sign', {
alias: 's',
describe: 'Should the git commit and tag be signed?',
type: 'boolean',
default: defaults.sign
})
.option('no-verify', {
alias: 'n',
describe: 'Bypass pre-commit or commit-msg git hooks during the commit phase',
type: 'boolean',
default: defaults.noVerify
})
.option('commit-all', {
alias: 'a',
describe: 'Commit all staged changes, not just files affected by standard-version',
type: 'boolean',
default: defaults.commitAll
})
.option('silent', {
describe: 'Don\'t print logs and errors',
type: 'boolean',
default: defaults.silent
})
.option('tag-prefix', {
alias: 't',
describe: 'Set a custom prefix for the git tag to be created',
type: 'string',
default: defaults.tagPrefix
})
.option('scripts', {
describe: 'Provide scripts to execute for lifecycle events (prebump, precommit, etc.,)',
default: defaults.scripts
})
.option('skip', {
describe: 'Map of steps in the release process that should be skipped',
default: defaults.skip
})
.option('dry-run', {
type: 'boolean',
default: defaults.dryRun,
describe: 'See the commands that running standard-version would run'
})
.option('git-tag-fallback', {
type: 'boolean',
default: defaults.gitTagFallback,
describe: `fallback to git tags for version, if no meta-information file is found (e.g., package.json)`
})
.option('path', {
type: 'string',
describe: 'Only populate commits made under this path'
})
.option('preset', {
type: 'string',
default: defaults.preset,
describe: 'Commit message guideline preset (default: angular)'
})
.check((argv) => {
if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) {
throw Error('scripts must be an object')
} else if (typeof argv.skip !== 'object' || Array.isArray(argv.skip)) {
throw Error('skip must be an object')
} else {
return true
}
})
.alias('version', 'v')
.alias('help', 'h')
.example('$0', 'Update changelog and tag release')
.example('$0 -m "%s: see changelog for details"', 'Update changelog and tag release with custom commit message')
.pkgConf('standard-version')
.config(config)
.wrap(97)
Object.keys(spec.properties).forEach(propertyKey => {
const property = spec.properties[propertyKey]
yargs.option(propertyKey, {
type: property.type,
describe: property.description,
default: property.default,
group: 'Preset Configuration:'
})
})
module.exports = yargs
// TODO: yargs should be populated with keys/descriptions from
// https://github.com/conventional-changelog/conventional-changelog-config-spec