commit-and-tag-version 12.0.0 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +43 -8
- package/.gitattributes +2 -0
- package/.github/workflows/ci.yaml +10 -3
- package/.prettierrc +3 -0
- package/CHANGELOG.md +7 -0
- package/README.md +4 -0
- package/bin/cli.js +6 -6
- package/command.js +43 -37
- package/defaults.js +12 -11
- package/index.js +44 -42
- package/jest.config.js +28 -0
- package/lib/checkpoint.js +19 -8
- package/lib/configuration.js +17 -17
- package/lib/detect-package-manager.js +20 -20
- package/lib/format-commit-message.js +3 -3
- package/lib/latest-semver-tag.js +13 -11
- package/lib/lifecycles/bump.js +136 -105
- package/lib/lifecycles/changelog.js +70 -51
- package/lib/lifecycles/commit.js +41 -42
- package/lib/lifecycles/tag.js +41 -31
- package/lib/preset-loader.js +12 -10
- package/lib/print-error.js +10 -7
- package/lib/run-exec.js +10 -10
- package/lib/run-execFile.js +10 -10
- package/lib/run-lifecycle-script.js +16 -11
- package/lib/stringify-package.js +10 -10
- package/lib/updaters/index.js +40 -33
- package/lib/updaters/types/csproj.js +9 -7
- package/lib/updaters/types/gradle.js +10 -8
- package/lib/updaters/types/json.js +14 -14
- package/lib/updaters/types/plain-text.js +4 -4
- package/lib/write-file.js +4 -4
- package/package.json +14 -21
- package/test/commit-message-config.integration-test.js +106 -0
- package/test/config-files.integration-test.js +114 -0
- package/test/config-keys.integration-test.js +83 -0
- package/test/core.spec.js +1369 -704
- package/test/git.integration-test.js +363 -0
- package/test/invalid-config.integration-test.js +73 -0
- package/test/mocks/jest-mocks.js +48 -0
- package/test/mocks/updater/customer-updater.js +5 -8
- package/test/mocks/updater/increment-updater.js +5 -5
- package/test/pre-commit-hook.integration-test.js +192 -0
- package/test/preset.integration-test.js +56 -0
- package/test/stringify-package.spec.js +18 -22
- package/test/utils.spec.js +25 -41
- package/test/config-files.spec.js +0 -176
- package/test/git.spec.js +0 -480
- package/test/preset.spec.js +0 -52
package/.eslintrc
CHANGED
|
@@ -1,14 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": [
|
|
2
|
+
"extends": [
|
|
3
|
+
"prettier",
|
|
4
|
+
"eslint:recommended"
|
|
5
|
+
],
|
|
6
|
+
"env": {
|
|
7
|
+
"node": true,
|
|
8
|
+
"es6": true
|
|
9
|
+
},
|
|
10
|
+
"overrides": [
|
|
11
|
+
{
|
|
12
|
+
"env": {
|
|
13
|
+
"node": true,
|
|
14
|
+
"es6": true,
|
|
15
|
+
"jest/globals": true
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"test/**"
|
|
19
|
+
],
|
|
20
|
+
"plugins": [
|
|
21
|
+
"jest"
|
|
22
|
+
],
|
|
23
|
+
"extends": [
|
|
24
|
+
"prettier",
|
|
25
|
+
"eslint:recommended",
|
|
26
|
+
"plugin:jest/recommended"
|
|
27
|
+
],
|
|
28
|
+
"rules": {
|
|
29
|
+
"jest/prefer-expect-assertions": "off",
|
|
30
|
+
"jest/expect-expect": "off"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"parserOptions": {
|
|
35
|
+
"ecmaVersion": 2023
|
|
36
|
+
},
|
|
3
37
|
"plugins": [
|
|
4
|
-
"
|
|
5
|
-
"@fintechstudios/eslint-plugin-chai-as-promised",
|
|
38
|
+
"jest"
|
|
6
39
|
],
|
|
7
40
|
"rules": {
|
|
8
41
|
"no-var": "error",
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
42
|
+
"no-unused-vars": [
|
|
43
|
+
"error",
|
|
44
|
+
{
|
|
45
|
+
"argsIgnorePattern": "_.*"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
13
48
|
}
|
|
14
|
-
}
|
|
49
|
+
}
|
package/.gitattributes
ADDED
|
@@ -10,8 +10,16 @@ jobs:
|
|
|
10
10
|
runs-on: ${{ matrix.os }}
|
|
11
11
|
strategy:
|
|
12
12
|
matrix:
|
|
13
|
-
node: [
|
|
14
|
-
|
|
13
|
+
node: [
|
|
14
|
+
18,
|
|
15
|
+
20.4, # Known good version of 20 which ran the previous Mocha and mock-fs based tests. If you go back to re-run those, tests Node 20.4 is the last version mock-fs worked with
|
|
16
|
+
20,
|
|
17
|
+
lts/*
|
|
18
|
+
]
|
|
19
|
+
os: [
|
|
20
|
+
ubuntu-latest,
|
|
21
|
+
windows-latest
|
|
22
|
+
]
|
|
15
23
|
env:
|
|
16
24
|
OS: ${{ matrix.os }}
|
|
17
25
|
NODE_VERSION: ${{ matrix.node }}
|
|
@@ -26,7 +34,6 @@ jobs:
|
|
|
26
34
|
- run: node --version
|
|
27
35
|
- run: npm install --engine-strict
|
|
28
36
|
- run: npm test
|
|
29
|
-
- run: npm run coverage
|
|
30
37
|
- name: Codecov
|
|
31
38
|
uses: codecov/codecov-action@v3
|
|
32
39
|
with:
|
package/.prettierrc
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [12.1.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.0.0...v12.1.0) (2024-01-06)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Add signoff option ([#120](https://github.com/absolute-version/commit-and-tag-version/issues/120)) ([d107e38](https://github.com/absolute-version/commit-and-tag-version/commit/d107e38eb906dfb21658d12803b7308f2e3dda7d))
|
|
11
|
+
|
|
5
12
|
## [12.0.0](https://github.com/absolute-version/commit-and-tag-version/compare/v11.3.0...v12.0.0) (2023-10-31)
|
|
6
13
|
|
|
7
14
|
|
package/README.md
CHANGED
|
@@ -279,6 +279,10 @@ commit-and-tag-version --no-verify
|
|
|
279
279
|
|
|
280
280
|
If you have your GPG key set up, add the `--sign` or `-s` flag to your `commit-and-tag-version` command.
|
|
281
281
|
|
|
282
|
+
### Signed-off-by trailer
|
|
283
|
+
|
|
284
|
+
To add the "Signed-off-by" trailer to the commit message add the `--signoff` flag to your `commit-and-tag-version` command.
|
|
285
|
+
|
|
282
286
|
### Lifecycle Scripts
|
|
283
287
|
|
|
284
288
|
`commit-and-tag-version` supports lifecycle scripts. These allow you to execute your
|
package/bin/cli.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
/* istanbul ignore if */
|
|
4
4
|
if (process.version.match(/v(\d+)\./)[1] < 6) {
|
|
5
5
|
console.error(
|
|
6
|
-
'commit-and-tag-version: Node v6 or greater is required. `commit-and-tag-version` did not run.'
|
|
7
|
-
)
|
|
6
|
+
'commit-and-tag-version: Node v6 or greater is required. `commit-and-tag-version` did not run.',
|
|
7
|
+
);
|
|
8
8
|
} else {
|
|
9
|
-
const standardVersion = require('../index')
|
|
10
|
-
const cmdParser = require('../command')
|
|
9
|
+
const standardVersion = require('../index');
|
|
10
|
+
const cmdParser = require('../command');
|
|
11
11
|
standardVersion(cmdParser.argv).catch(() => {
|
|
12
|
-
process.exit(1)
|
|
13
|
-
})
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
|
14
14
|
}
|
package/command.js
CHANGED
|
@@ -1,138 +1,144 @@
|
|
|
1
|
-
const spec = require('conventional-changelog-config-spec')
|
|
2
|
-
const { getConfiguration } = require('./lib/configuration')
|
|
3
|
-
const defaults = require('./defaults')
|
|
1
|
+
const spec = require('conventional-changelog-config-spec');
|
|
2
|
+
const { getConfiguration } = require('./lib/configuration');
|
|
3
|
+
const defaults = require('./defaults');
|
|
4
4
|
|
|
5
5
|
const yargs = require('yargs')
|
|
6
6
|
.usage('Usage: $0 [options]')
|
|
7
7
|
.option('packageFiles', {
|
|
8
8
|
default: defaults.packageFiles,
|
|
9
|
-
array: true
|
|
9
|
+
array: true,
|
|
10
10
|
})
|
|
11
11
|
.option('bumpFiles', {
|
|
12
12
|
default: defaults.bumpFiles,
|
|
13
|
-
array: true
|
|
13
|
+
array: true,
|
|
14
14
|
})
|
|
15
15
|
.option('release-as', {
|
|
16
16
|
alias: 'r',
|
|
17
17
|
describe:
|
|
18
18
|
'Specify the release type manually (like npm version <major|minor|patch>)',
|
|
19
19
|
requiresArg: true,
|
|
20
|
-
string: true
|
|
20
|
+
string: true,
|
|
21
21
|
})
|
|
22
22
|
.option('prerelease', {
|
|
23
23
|
alias: 'p',
|
|
24
24
|
describe:
|
|
25
25
|
'make a pre-release with optional option value to specify a tag id',
|
|
26
|
-
string: true
|
|
26
|
+
string: true,
|
|
27
27
|
})
|
|
28
28
|
.option('infile', {
|
|
29
29
|
alias: 'i',
|
|
30
30
|
describe: 'Read the CHANGELOG from this file',
|
|
31
|
-
default: defaults.infile
|
|
31
|
+
default: defaults.infile,
|
|
32
32
|
})
|
|
33
33
|
.option('message', {
|
|
34
34
|
alias: ['m'],
|
|
35
35
|
describe:
|
|
36
36
|
'[DEPRECATED] Commit message, replaces %s with new version.\nThis option will be removed in the next major version, please use --releaseCommitMessageFormat.',
|
|
37
|
-
type: 'string'
|
|
37
|
+
type: 'string',
|
|
38
38
|
})
|
|
39
39
|
.option('first-release', {
|
|
40
40
|
alias: 'f',
|
|
41
41
|
describe: 'Is this the first release?',
|
|
42
42
|
type: 'boolean',
|
|
43
|
-
default: defaults.firstRelease
|
|
43
|
+
default: defaults.firstRelease,
|
|
44
44
|
})
|
|
45
45
|
.option('sign', {
|
|
46
46
|
alias: 's',
|
|
47
47
|
describe: 'Should the git commit and tag be signed?',
|
|
48
48
|
type: 'boolean',
|
|
49
|
-
default: defaults.sign
|
|
49
|
+
default: defaults.sign,
|
|
50
|
+
})
|
|
51
|
+
.option('signoff', {
|
|
52
|
+
describe: 'Should the git commit have a "Signed-off-by" trailer',
|
|
53
|
+
type: 'boolean',
|
|
54
|
+
default: defaults.signoff,
|
|
50
55
|
})
|
|
51
56
|
.option('no-verify', {
|
|
52
57
|
alias: 'n',
|
|
53
58
|
describe:
|
|
54
59
|
'Bypass pre-commit or commit-msg git hooks during the commit phase',
|
|
55
60
|
type: 'boolean',
|
|
56
|
-
default: defaults.noVerify
|
|
61
|
+
default: defaults.noVerify,
|
|
57
62
|
})
|
|
58
63
|
.option('commit-all', {
|
|
59
64
|
alias: 'a',
|
|
60
65
|
describe:
|
|
61
66
|
'Commit all staged changes, not just files affected by commit-and-tag-version',
|
|
62
67
|
type: 'boolean',
|
|
63
|
-
default: defaults.commitAll
|
|
68
|
+
default: defaults.commitAll,
|
|
64
69
|
})
|
|
65
70
|
.option('silent', {
|
|
66
71
|
describe: "Don't print logs and errors",
|
|
67
72
|
type: 'boolean',
|
|
68
|
-
default: defaults.silent
|
|
73
|
+
default: defaults.silent,
|
|
69
74
|
})
|
|
70
75
|
.option('tag-prefix', {
|
|
71
76
|
alias: 't',
|
|
72
77
|
describe: 'Set a custom prefix for the git tag to be created',
|
|
73
78
|
type: 'string',
|
|
74
|
-
default: defaults.tagPrefix
|
|
79
|
+
default: defaults.tagPrefix,
|
|
75
80
|
})
|
|
76
81
|
.option('release-count', {
|
|
77
|
-
describe:
|
|
82
|
+
describe:
|
|
83
|
+
'How many releases of changelog you want to generate. It counts from the upcoming release. Useful when you forgot to generate any previous changelog. Set to 0 to regenerate all.',
|
|
78
84
|
type: 'number',
|
|
79
|
-
default: defaults.releaseCount
|
|
85
|
+
default: defaults.releaseCount,
|
|
80
86
|
})
|
|
81
87
|
.option('tag-force', {
|
|
82
88
|
describe: 'Allow tag replacement',
|
|
83
89
|
type: 'boolean',
|
|
84
|
-
default: defaults.tagForce
|
|
90
|
+
default: defaults.tagForce,
|
|
85
91
|
})
|
|
86
92
|
.option('scripts', {
|
|
87
93
|
describe:
|
|
88
94
|
'Provide scripts to execute for lifecycle events (prebump, precommit, etc.,)',
|
|
89
|
-
default: defaults.scripts
|
|
95
|
+
default: defaults.scripts,
|
|
90
96
|
})
|
|
91
97
|
.option('skip', {
|
|
92
98
|
describe: 'Map of steps in the release process that should be skipped',
|
|
93
|
-
default: defaults.skip
|
|
99
|
+
default: defaults.skip,
|
|
94
100
|
})
|
|
95
101
|
.option('dry-run', {
|
|
96
102
|
type: 'boolean',
|
|
97
103
|
default: defaults.dryRun,
|
|
98
|
-
describe: 'See the commands that running commit-and-tag-version would run'
|
|
104
|
+
describe: 'See the commands that running commit-and-tag-version would run',
|
|
99
105
|
})
|
|
100
106
|
.option('git-tag-fallback', {
|
|
101
107
|
type: 'boolean',
|
|
102
108
|
default: defaults.gitTagFallback,
|
|
103
109
|
describe:
|
|
104
|
-
'fallback to git tags for version, if no meta-information file is found (e.g., package.json)'
|
|
110
|
+
'fallback to git tags for version, if no meta-information file is found (e.g., package.json)',
|
|
105
111
|
})
|
|
106
112
|
.option('path', {
|
|
107
113
|
type: 'string',
|
|
108
|
-
describe: 'Only populate commits made under this path'
|
|
114
|
+
describe: 'Only populate commits made under this path',
|
|
109
115
|
})
|
|
110
116
|
.option('changelogHeader', {
|
|
111
117
|
type: 'string',
|
|
112
118
|
describe:
|
|
113
|
-
'[DEPRECATED] Use a custom header when generating and updating changelog.\nThis option will be removed in the next major version, please use --header.'
|
|
119
|
+
'[DEPRECATED] Use a custom header when generating and updating changelog.\nThis option will be removed in the next major version, please use --header.',
|
|
114
120
|
})
|
|
115
121
|
.option('preset', {
|
|
116
122
|
type: 'string',
|
|
117
123
|
default: defaults.preset,
|
|
118
|
-
describe: 'Commit message guideline preset'
|
|
124
|
+
describe: 'Commit message guideline preset',
|
|
119
125
|
})
|
|
120
126
|
.option('lerna-package', {
|
|
121
127
|
type: 'string',
|
|
122
|
-
describe: 'Name of the package from which the tags will be extracted'
|
|
128
|
+
describe: 'Name of the package from which the tags will be extracted',
|
|
123
129
|
})
|
|
124
130
|
.option('npmPublishHint', {
|
|
125
131
|
type: 'string',
|
|
126
132
|
default: defaults.npmPublishHint,
|
|
127
|
-
describe: 'Customized publishing hint'
|
|
133
|
+
describe: 'Customized publishing hint',
|
|
128
134
|
})
|
|
129
135
|
.check((argv) => {
|
|
130
136
|
if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) {
|
|
131
|
-
throw Error('scripts must be an object')
|
|
137
|
+
throw Error('scripts must be an object');
|
|
132
138
|
} else if (typeof argv.skip !== 'object' || Array.isArray(argv.skip)) {
|
|
133
|
-
throw Error('skip must be an object')
|
|
139
|
+
throw Error('skip must be an object');
|
|
134
140
|
} else {
|
|
135
|
-
return true
|
|
141
|
+
return true;
|
|
136
142
|
}
|
|
137
143
|
})
|
|
138
144
|
.alias('version', 'v')
|
|
@@ -140,21 +146,21 @@ const yargs = require('yargs')
|
|
|
140
146
|
.example('$0', 'Update changelog and tag release')
|
|
141
147
|
.example(
|
|
142
148
|
'$0 -m "%s: see changelog for details"',
|
|
143
|
-
'Update changelog and tag release with custom commit message'
|
|
149
|
+
'Update changelog and tag release with custom commit message',
|
|
144
150
|
)
|
|
145
151
|
.pkgConf('standard-version')
|
|
146
152
|
.pkgConf('commit-and-tag-version')
|
|
147
153
|
.config(getConfiguration())
|
|
148
|
-
.wrap(97)
|
|
154
|
+
.wrap(97);
|
|
149
155
|
|
|
150
156
|
Object.keys(spec.properties).forEach((propertyKey) => {
|
|
151
|
-
const property = spec.properties[propertyKey]
|
|
157
|
+
const property = spec.properties[propertyKey];
|
|
152
158
|
yargs.option(propertyKey, {
|
|
153
159
|
type: property.type,
|
|
154
160
|
describe: property.description,
|
|
155
161
|
default: defaults[propertyKey] ? defaults[propertyKey] : property.default,
|
|
156
|
-
group: 'Preset Configuration:'
|
|
157
|
-
})
|
|
158
|
-
})
|
|
162
|
+
group: 'Preset Configuration:',
|
|
163
|
+
});
|
|
164
|
+
});
|
|
159
165
|
|
|
160
|
-
module.exports = yargs
|
|
166
|
+
module.exports = yargs;
|
package/defaults.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
const spec = require('conventional-changelog-config-spec')
|
|
1
|
+
const spec = require('conventional-changelog-config-spec');
|
|
2
2
|
|
|
3
3
|
const defaults = {
|
|
4
4
|
infile: 'CHANGELOG.md',
|
|
5
5
|
firstRelease: false,
|
|
6
6
|
sign: false,
|
|
7
|
+
signoff: false,
|
|
7
8
|
noVerify: false,
|
|
8
9
|
commitAll: false,
|
|
9
10
|
silent: false,
|
|
@@ -15,29 +16,29 @@ const defaults = {
|
|
|
15
16
|
tagForce: false,
|
|
16
17
|
gitTagFallback: true,
|
|
17
18
|
preset: require.resolve('conventional-changelog-conventionalcommits'),
|
|
18
|
-
npmPublishHint: undefined
|
|
19
|
-
}
|
|
19
|
+
npmPublishHint: undefined,
|
|
20
|
+
};
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Merge in defaults provided by the spec
|
|
23
24
|
*/
|
|
24
25
|
Object.keys(spec.properties).forEach((propertyKey) => {
|
|
25
|
-
const property = spec.properties[propertyKey]
|
|
26
|
-
defaults[propertyKey] = property.default
|
|
27
|
-
})
|
|
26
|
+
const property = spec.properties[propertyKey];
|
|
27
|
+
defaults[propertyKey] = property.default;
|
|
28
|
+
});
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Sets the default for `header` (provided by the spec) for backwards
|
|
31
32
|
* compatibility. This should be removed in the next major version.
|
|
32
33
|
*/
|
|
33
34
|
defaults.header =
|
|
34
|
-
'# Changelog\n\nAll notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.\n'
|
|
35
|
+
'# Changelog\n\nAll notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.\n';
|
|
35
36
|
|
|
36
|
-
defaults.packageFiles = ['package.json', 'bower.json', 'manifest.json']
|
|
37
|
+
defaults.packageFiles = ['package.json', 'bower.json', 'manifest.json'];
|
|
37
38
|
|
|
38
39
|
defaults.bumpFiles = defaults.packageFiles.concat([
|
|
39
40
|
'package-lock.json',
|
|
40
|
-
'npm-shrinkwrap.json'
|
|
41
|
-
])
|
|
41
|
+
'npm-shrinkwrap.json',
|
|
42
|
+
]);
|
|
42
43
|
|
|
43
|
-
module.exports = defaults
|
|
44
|
+
module.exports = defaults;
|
package/index.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
const bump = require('./lib/lifecycles/bump')
|
|
2
|
-
const changelog = require('./lib/lifecycles/changelog')
|
|
3
|
-
const commit = require('./lib/lifecycles/commit')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
const latestSemverTag = require('./lib/latest-semver-tag')
|
|
6
|
-
const path = require('path')
|
|
7
|
-
const printError = require('./lib/print-error')
|
|
8
|
-
const tag = require('./lib/lifecycles/tag')
|
|
9
|
-
const { resolveUpdaterObjectFromArgument } = require('./lib/updaters')
|
|
1
|
+
const bump = require('./lib/lifecycles/bump');
|
|
2
|
+
const changelog = require('./lib/lifecycles/changelog');
|
|
3
|
+
const commit = require('./lib/lifecycles/commit');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const latestSemverTag = require('./lib/latest-semver-tag');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const printError = require('./lib/print-error');
|
|
8
|
+
const tag = require('./lib/lifecycles/tag');
|
|
9
|
+
const { resolveUpdaterObjectFromArgument } = require('./lib/updaters');
|
|
10
10
|
|
|
11
|
-
module.exports = async function standardVersion
|
|
12
|
-
const defaults = require('./defaults')
|
|
11
|
+
module.exports = async function standardVersion(argv) {
|
|
12
|
+
const defaults = require('./defaults');
|
|
13
13
|
/**
|
|
14
14
|
* `--message` (`-m`) support will be removed in the next major version.
|
|
15
15
|
*/
|
|
16
|
-
const message = argv.m || argv.message
|
|
16
|
+
const message = argv.m || argv.message;
|
|
17
17
|
if (message) {
|
|
18
18
|
/**
|
|
19
19
|
* The `--message` flag uses `%s` for version substitutions, we swap this
|
|
20
20
|
* for the substitution defined in the config-spec for future-proofing upstream
|
|
21
21
|
* handling.
|
|
22
22
|
*/
|
|
23
|
-
argv.releaseCommitMessageFormat = message.replace(/%s/g, '{{currentTag}}')
|
|
23
|
+
argv.releaseCommitMessageFormat = message.replace(/%s/g, '{{currentTag}}');
|
|
24
24
|
if (!argv.silent) {
|
|
25
25
|
console.warn(
|
|
26
|
-
'[commit-and-tag-version]: --message (-m) will be removed in the next major release. Use --releaseCommitMessageFormat.'
|
|
27
|
-
)
|
|
26
|
+
'[commit-and-tag-version]: --message (-m) will be removed in the next major release. Use --releaseCommitMessageFormat.',
|
|
27
|
+
);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (argv.changelogHeader) {
|
|
32
|
-
argv.header = argv.changelogHeader
|
|
32
|
+
argv.header = argv.changelogHeader;
|
|
33
33
|
if (!argv.silent) {
|
|
34
34
|
console.warn(
|
|
35
|
-
'[commit-and-tag-version]: --changelogHeader will be removed in the next major release. Use --header.'
|
|
36
|
-
)
|
|
35
|
+
'[commit-and-tag-version]: --changelogHeader will be removed in the next major release. Use --header.',
|
|
36
|
+
);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -42,51 +42,53 @@ module.exports = async function standardVersion (argv) {
|
|
|
42
42
|
argv.header.search(changelog.START_OF_LAST_RELEASE_PATTERN) !== -1
|
|
43
43
|
) {
|
|
44
44
|
throw Error(
|
|
45
|
-
`custom changelog header must not match ${changelog.START_OF_LAST_RELEASE_PATTERN}
|
|
46
|
-
)
|
|
45
|
+
`custom changelog header must not match ${changelog.START_OF_LAST_RELEASE_PATTERN}`,
|
|
46
|
+
);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* If an argument for `packageFiles` provided, we include it as a "default" `bumpFile`.
|
|
51
51
|
*/
|
|
52
52
|
if (argv.packageFiles) {
|
|
53
|
-
defaults.bumpFiles = defaults.bumpFiles.concat(argv.packageFiles)
|
|
53
|
+
defaults.bumpFiles = defaults.bumpFiles.concat(argv.packageFiles);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const args = Object.assign({}, defaults, argv)
|
|
57
|
-
let pkg
|
|
56
|
+
const args = Object.assign({}, defaults, argv);
|
|
57
|
+
let pkg;
|
|
58
58
|
for (const packageFile of args.packageFiles) {
|
|
59
|
-
const updater = resolveUpdaterObjectFromArgument(packageFile)
|
|
60
|
-
if (!updater) return
|
|
61
|
-
const pkgPath = path.resolve(process.cwd(), updater.filename)
|
|
59
|
+
const updater = resolveUpdaterObjectFromArgument(packageFile);
|
|
60
|
+
if (!updater) return;
|
|
61
|
+
const pkgPath = path.resolve(process.cwd(), updater.filename);
|
|
62
62
|
try {
|
|
63
|
-
const contents = fs.readFileSync(pkgPath, 'utf8')
|
|
63
|
+
const contents = fs.readFileSync(pkgPath, 'utf8');
|
|
64
64
|
pkg = {
|
|
65
65
|
version: updater.updater.readVersion(contents),
|
|
66
66
|
private:
|
|
67
67
|
typeof updater.updater.isPrivate === 'function'
|
|
68
68
|
? updater.updater.isPrivate(contents)
|
|
69
|
-
: false
|
|
70
|
-
}
|
|
71
|
-
break
|
|
72
|
-
} catch (err) {
|
|
69
|
+
: false,
|
|
70
|
+
};
|
|
71
|
+
break;
|
|
72
|
+
} catch (err) {
|
|
73
|
+
/* This probably shouldn't be empty? */
|
|
74
|
+
}
|
|
73
75
|
}
|
|
74
76
|
try {
|
|
75
|
-
let version
|
|
77
|
+
let version;
|
|
76
78
|
if (pkg && pkg.version) {
|
|
77
|
-
version = pkg.version
|
|
79
|
+
version = pkg.version;
|
|
78
80
|
} else if (args.gitTagFallback) {
|
|
79
|
-
version = await latestSemverTag(args.tagPrefix)
|
|
81
|
+
version = await latestSemverTag(args.tagPrefix);
|
|
80
82
|
} else {
|
|
81
|
-
throw new Error('no package file found')
|
|
83
|
+
throw new Error('no package file found');
|
|
82
84
|
}
|
|
83
85
|
|
|
84
|
-
const newVersion = await bump(args, version)
|
|
85
|
-
await changelog(args, newVersion)
|
|
86
|
-
await commit(args, newVersion)
|
|
87
|
-
await tag(newVersion, pkg ? pkg.private : false, args)
|
|
86
|
+
const newVersion = await bump(args, version);
|
|
87
|
+
await changelog(args, newVersion);
|
|
88
|
+
await commit(args, newVersion);
|
|
89
|
+
await tag(newVersion, pkg ? pkg.private : false, args);
|
|
88
90
|
} catch (err) {
|
|
89
|
-
printError(args, err.message)
|
|
90
|
-
throw err
|
|
91
|
+
printError(args, err.message);
|
|
92
|
+
throw err;
|
|
91
93
|
}
|
|
92
|
-
}
|
|
94
|
+
};
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
collectCoverage: true,
|
|
3
|
+
collectCoverageFrom: [
|
|
4
|
+
'**/*.{js,jsx,ts}',
|
|
5
|
+
'!**/node_modules/**',
|
|
6
|
+
'!**/tmp/**',
|
|
7
|
+
'!**/test/**',
|
|
8
|
+
'!**/coverage/**',
|
|
9
|
+
'!**/bin/**',
|
|
10
|
+
],
|
|
11
|
+
coverageReporters: ['lcov', 'text'],
|
|
12
|
+
projects: [
|
|
13
|
+
{
|
|
14
|
+
displayName: 'Unit Test',
|
|
15
|
+
testMatch: ['**/test/*.spec.js'],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Integration Test',
|
|
19
|
+
runner: 'jest-serial-runner',
|
|
20
|
+
testMatch: ['**/test/*.integration-test.js'],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
silent: true, // Suppresses runtime console logs during test runs
|
|
24
|
+
testTimeout: 30000,
|
|
25
|
+
verbose: true, // Prints test describe/it names into console during test runs
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = config;
|
package/lib/checkpoint.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
const figures = require('figures')
|
|
3
|
-
const util = require('util')
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const figures = require('figures');
|
|
3
|
+
const util = require('util');
|
|
4
4
|
|
|
5
5
|
module.exports = function (argv, msg, args, figure) {
|
|
6
|
-
const defaultFigure = argv.dryRun
|
|
6
|
+
const defaultFigure = argv.dryRun
|
|
7
|
+
? chalk.yellow(figures.tick)
|
|
8
|
+
: chalk.green(figures.tick);
|
|
7
9
|
if (!argv.silent) {
|
|
8
|
-
console.info(
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
console.info(
|
|
11
|
+
(figure || defaultFigure) +
|
|
12
|
+
' ' +
|
|
13
|
+
util.format.apply(
|
|
14
|
+
util,
|
|
15
|
+
[msg].concat(
|
|
16
|
+
args.map(function (arg) {
|
|
17
|
+
return chalk.bold(arg);
|
|
18
|
+
}),
|
|
19
|
+
),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
11
22
|
}
|
|
12
|
-
}
|
|
23
|
+
};
|
package/lib/configuration.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const findUp = require('find-up')
|
|
3
|
-
const { readFileSync } = require('fs')
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const findUp = require('find-up');
|
|
3
|
+
const { readFileSync } = require('fs');
|
|
4
4
|
|
|
5
5
|
const CONFIGURATION_FILES = [
|
|
6
6
|
'.versionrc',
|
|
7
7
|
'.versionrc.cjs',
|
|
8
8
|
'.versionrc.json',
|
|
9
|
-
'.versionrc.js'
|
|
10
|
-
]
|
|
9
|
+
'.versionrc.js',
|
|
10
|
+
];
|
|
11
11
|
|
|
12
12
|
module.exports.getConfiguration = function () {
|
|
13
|
-
let config = {}
|
|
14
|
-
const configPath = findUp.sync(CONFIGURATION_FILES)
|
|
13
|
+
let config = {};
|
|
14
|
+
const configPath = findUp.sync(CONFIGURATION_FILES);
|
|
15
15
|
if (!configPath) {
|
|
16
|
-
return config
|
|
16
|
+
return config;
|
|
17
17
|
}
|
|
18
|
-
const ext = path.extname(configPath)
|
|
18
|
+
const ext = path.extname(configPath);
|
|
19
19
|
if (ext === '.js' || ext === '.cjs') {
|
|
20
|
-
const jsConfiguration = require(configPath)
|
|
20
|
+
const jsConfiguration = require(configPath);
|
|
21
21
|
if (typeof jsConfiguration === 'function') {
|
|
22
|
-
config = jsConfiguration()
|
|
22
|
+
config = jsConfiguration();
|
|
23
23
|
} else {
|
|
24
|
-
config = jsConfiguration
|
|
24
|
+
config = jsConfiguration;
|
|
25
25
|
}
|
|
26
26
|
} else {
|
|
27
|
-
config = JSON.parse(readFileSync(configPath))
|
|
27
|
+
config = JSON.parse(readFileSync(configPath));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -33,9 +33,9 @@ module.exports.getConfiguration = function () {
|
|
|
33
33
|
*/
|
|
34
34
|
if (typeof config !== 'object') {
|
|
35
35
|
throw Error(
|
|
36
|
-
`[commit-and-tag-version] Invalid configuration in ${configPath} provided. Expected an object but found ${typeof config}
|
|
37
|
-
)
|
|
36
|
+
`[commit-and-tag-version] Invalid configuration in ${configPath} provided. Expected an object but found ${typeof config}.`,
|
|
37
|
+
);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return config
|
|
41
|
-
}
|
|
40
|
+
return config;
|
|
41
|
+
};
|