commit-and-tag-version 13.3.0 → 13.4.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/CHANGELOG.md +13 -0
- package/README.md +39 -0
- package/defaults.js +1 -0
- package/lib/lifecycles/bump.js +60 -33
- package/lib/lifecycles/changelog.js +10 -2
- package/lib/preset-loader.js +11 -0
- package/package.json +4 -4
- package/test/changelog-context.integration-test.js +75 -0
- package/test/config-files.integration-test.js +23 -0
- package/test/git.integration-test.js +10 -0
- package/test/utils.spec.js +40 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
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
|
+
## [13.4.0](https://github.com/absolute-version/commit-and-tag-version/compare/v13.3.0...v13.4.0) (2026-11-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **changelog:** allow overriding the changelog context ([#370](https://github.com/absolute-version/commit-and-tag-version/issues/370)) ([f4be71f](https://github.com/absolute-version/commit-and-tag-version/commit/f4be71ff0d05b44bceae1fea78523f67d1986e3c))
|
|
11
|
+
* pass gitRawCommitsOpts through to changelog and bump ([#367](https://github.com/absolute-version/commit-and-tag-version/issues/367)) ([2d37feb](https://github.com/absolute-version/commit-and-tag-version/commit/2d37feb551160c4dbbd9b07e790557cac16f9bb6)), closes [#197](https://github.com/absolute-version/commit-and-tag-version/issues/197)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* use an explicit releaseAs version when the bump step is skipped ([#368](https://github.com/absolute-version/commit-and-tag-version/issues/368)) ([66b20aa](https://github.com/absolute-version/commit-and-tag-version/commit/66b20aa5181f6ee89346bd9249cdcc8915c3b7a3))
|
|
17
|
+
|
|
5
18
|
## [13.3.0](https://github.com/absolute-version/commit-and-tag-version/compare/v13.2.2...v13.3.0) (2026-10-15)
|
|
6
19
|
|
|
7
20
|
|
package/README.md
CHANGED
|
@@ -211,6 +211,27 @@ Suppose you're using GitLab, rather than GitHub, you might modify the following
|
|
|
211
211
|
|
|
212
212
|
Making these URLs match GitLab's format, rather than GitHub's.
|
|
213
213
|
|
|
214
|
+
### Overriding the changelog context
|
|
215
|
+
|
|
216
|
+
The values the changelog template renders from can be overridden with the
|
|
217
|
+
`context` option. For example, to generate a changelog without link markup:
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{
|
|
221
|
+
"commit-and-tag-version": {
|
|
222
|
+
"context": {
|
|
223
|
+
"linkCompare": false,
|
|
224
|
+
"linkReferences": false
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
`linkCompare` controls the link on the version heading, and `linkReferences`
|
|
231
|
+
controls the commit hash and `closes #123` links. The `version` key is overwritten by commit-and-tag-version, any other key is passed to the
|
|
232
|
+
[conventional-changelog writer context](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer)
|
|
233
|
+
unchanged.
|
|
234
|
+
|
|
214
235
|
### Deeper customization
|
|
215
236
|
|
|
216
237
|
You can override both [parser](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser) and [writer](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer) options (they will be merged into the preset we just mentioned). As an example, to list commits in the order that they were committed:
|
|
@@ -227,6 +248,22 @@ You can override both [parser](https://github.com/conventional-changelog/convent
|
|
|
227
248
|
|
|
228
249
|
`parser` and `writer` are accepted as aliases of `parserOpts` and `writerOpts`, matching the shape of presets built on conventional-changelog 7+, so such a preset can be used directly as the configuration (e.g. `commit-and-tag-version --config ./my-preset.js`). If both are set, `parserOpts`/`writerOpts` take precedence.
|
|
229
250
|
|
|
251
|
+
You can also pass commit-fetch options through to conventional-changelog via `gitRawCommitsOpts` (or the modern `commits` alias). This is useful for including extra git fields such as author name/email so a custom writer template can render them (#197):
|
|
252
|
+
|
|
253
|
+
```js
|
|
254
|
+
export default {
|
|
255
|
+
gitRawCommitsOpts: {
|
|
256
|
+
format:
|
|
257
|
+
'%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae',
|
|
258
|
+
},
|
|
259
|
+
writerOpts: {
|
|
260
|
+
// commit.authorName / commit.authorEmail are then available
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
`commits` is accepted as an alias of `gitRawCommitsOpts`. If both are set, `gitRawCommitsOpts` takes precedence. Lifecycle-owned fields (`path`, and `merges` for changelog generation) always win over user overrides.
|
|
266
|
+
|
|
230
267
|
Custom writer templates must be render functions rather than Handlebars strings; see the [v13 migration guide](MIGRATION.md#custom-writer-templates-use-render-functions). The official [`@conventional-changelog/template`](https://conventional-changelog.js.org/template/) helpers are re-exported from this package, so they can be imported without installing anything else — including under strict package managers such as pnpm:
|
|
231
268
|
|
|
232
269
|
```js
|
|
@@ -471,6 +508,8 @@ by adding the following to your package.json:
|
|
|
471
508
|
|
|
472
509
|
To set these options via the command line, use `commit-and-tag-version --skip.changelog`
|
|
473
510
|
|
|
511
|
+
When the `bump` step is skipped, no files are updated and the remaining steps use the current version. If you also pass an explicit version with `--release-as` (e.g. `--skip.bump --release-as 1.5.0`), the changelog, commit and tag use that version instead.
|
|
512
|
+
|
|
474
513
|
### Committing Generated Artifacts in the Release Commit
|
|
475
514
|
|
|
476
515
|
If you want to commit generated artifacts in the release commit, you can use the `--commit-all` or `-a` flag. You will need to stage the artifacts you want to commit, so your `release` command could look like this:
|
package/defaults.js
CHANGED
package/lib/lifecycles/bump.js
CHANGED
|
@@ -7,7 +7,10 @@ import path from 'path';
|
|
|
7
7
|
import semver from 'semver';
|
|
8
8
|
import { ConventionalGitClient } from '@conventional-changelog/git-client';
|
|
9
9
|
import checkpoint from '../checkpoint.js';
|
|
10
|
-
import presetLoader, {
|
|
10
|
+
import presetLoader, {
|
|
11
|
+
getParserOpts,
|
|
12
|
+
getGitRawCommitsOpts,
|
|
13
|
+
} from '../preset-loader.js';
|
|
11
14
|
import runLifecycleScript from '../run-lifecycle-script.js';
|
|
12
15
|
import writeFile from '../write-file.js';
|
|
13
16
|
import { resolveUpdaterObjectFromArgument } from '../updaters/index.js';
|
|
@@ -93,7 +96,13 @@ async function Bump(args, version) {
|
|
|
93
96
|
// time we perform the version bump step.
|
|
94
97
|
configsToUpdate = {};
|
|
95
98
|
|
|
96
|
-
if (args.skip.bump)
|
|
99
|
+
if (args.skip.bump) {
|
|
100
|
+
// No files are bumped, but an explicit releaseAs version is still the
|
|
101
|
+
// version used by the changelog, commit and tag steps.
|
|
102
|
+
return semver.valid(args.releaseAs)
|
|
103
|
+
? versionFromReleaseAs(args, version)
|
|
104
|
+
: version;
|
|
105
|
+
}
|
|
97
106
|
|
|
98
107
|
if (
|
|
99
108
|
args.releaseAs &&
|
|
@@ -117,36 +126,7 @@ async function Bump(args, version) {
|
|
|
117
126
|
|
|
118
127
|
if (!args.firstRelease) {
|
|
119
128
|
if (semver.valid(args.releaseAs)) {
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
isString(args.prerelease) &&
|
|
123
|
-
releaseAs.prerelease.length &&
|
|
124
|
-
releaseAs.prerelease.slice(0, -1).join('.') !== args.prerelease
|
|
125
|
-
) {
|
|
126
|
-
// If both releaseAs and the prerelease identifier are supplied, they must match. The behavior
|
|
127
|
-
// for a mismatch is undefined, so error out instead.
|
|
128
|
-
throw new Error(
|
|
129
|
-
'releaseAs and prerelease have conflicting prerelease identifiers',
|
|
130
|
-
);
|
|
131
|
-
} else if (isString(args.prerelease) && releaseAs.prerelease.length) {
|
|
132
|
-
newVersion = releaseAs.version;
|
|
133
|
-
} else if (isString(args.prerelease)) {
|
|
134
|
-
newVersion = `${releaseAs.major}.${releaseAs.minor}.${releaseAs.patch}-${args.prerelease}.0`;
|
|
135
|
-
} else {
|
|
136
|
-
newVersion = releaseAs.version;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Check if the previous version is the same version and prerelease, and increment if so
|
|
140
|
-
if (
|
|
141
|
-
isString(args.prerelease) &&
|
|
142
|
-
['prerelease', null].includes(semver.diff(version, newVersion)) &&
|
|
143
|
-
semver.lte(newVersion, version)
|
|
144
|
-
) {
|
|
145
|
-
newVersion = semver.inc(version, 'prerelease', args.prerelease);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Append any build info from releaseAs
|
|
149
|
-
newVersion = semvarToVersionStr(newVersion, releaseAs.build);
|
|
129
|
+
newVersion = versionFromReleaseAs(args, version);
|
|
150
130
|
} else {
|
|
151
131
|
const release = await bumpVersion(args.releaseAs, version, args);
|
|
152
132
|
|
|
@@ -184,6 +164,47 @@ async function Bump(args, version) {
|
|
|
184
164
|
return newVersion;
|
|
185
165
|
}
|
|
186
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Compute the new version from an explicit `releaseAs` version, taking the
|
|
169
|
+
* `prerelease` option into account.
|
|
170
|
+
* @param args config object
|
|
171
|
+
* @param {string} version the current version
|
|
172
|
+
* @return {string}
|
|
173
|
+
*/
|
|
174
|
+
function versionFromReleaseAs(args, version) {
|
|
175
|
+
let newVersion;
|
|
176
|
+
const releaseAs = new semver.SemVer(args.releaseAs);
|
|
177
|
+
if (
|
|
178
|
+
isString(args.prerelease) &&
|
|
179
|
+
releaseAs.prerelease.length &&
|
|
180
|
+
releaseAs.prerelease.slice(0, -1).join('.') !== args.prerelease
|
|
181
|
+
) {
|
|
182
|
+
// If both releaseAs and the prerelease identifier are supplied, they must match. The behavior
|
|
183
|
+
// for a mismatch is undefined, so error out instead.
|
|
184
|
+
throw new Error(
|
|
185
|
+
'releaseAs and prerelease have conflicting prerelease identifiers',
|
|
186
|
+
);
|
|
187
|
+
} else if (isString(args.prerelease) && releaseAs.prerelease.length) {
|
|
188
|
+
newVersion = releaseAs.version;
|
|
189
|
+
} else if (isString(args.prerelease)) {
|
|
190
|
+
newVersion = `${releaseAs.major}.${releaseAs.minor}.${releaseAs.patch}-${args.prerelease}.0`;
|
|
191
|
+
} else {
|
|
192
|
+
newVersion = releaseAs.version;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Check if the previous version is the same version and prerelease, and increment if so
|
|
196
|
+
if (
|
|
197
|
+
isString(args.prerelease) &&
|
|
198
|
+
['prerelease', null].includes(semver.diff(version, newVersion)) &&
|
|
199
|
+
semver.lte(newVersion, version)
|
|
200
|
+
) {
|
|
201
|
+
newVersion = semver.inc(version, 'prerelease', args.prerelease);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Append any build info from releaseAs
|
|
205
|
+
return semvarToVersionStr(newVersion, releaseAs.build);
|
|
206
|
+
}
|
|
207
|
+
|
|
187
208
|
Bump.getUpdatedConfigs = function () {
|
|
188
209
|
return configsToUpdate;
|
|
189
210
|
};
|
|
@@ -296,7 +317,13 @@ async function bumpVersion(releaseAs, currentVersion, args) {
|
|
|
296
317
|
// towards the next version (#310).
|
|
297
318
|
skipUnstable: true,
|
|
298
319
|
})
|
|
299
|
-
.commits(
|
|
320
|
+
.commits(
|
|
321
|
+
{
|
|
322
|
+
...(getGitRawCommitsOpts(args) || {}),
|
|
323
|
+
path: args.path,
|
|
324
|
+
},
|
|
325
|
+
getParserOpts(args),
|
|
326
|
+
);
|
|
300
327
|
|
|
301
328
|
if (args.verbose) {
|
|
302
329
|
bumper.options({
|
|
@@ -7,6 +7,7 @@ import checkpoint from '../checkpoint.js';
|
|
|
7
7
|
import presetLoader, {
|
|
8
8
|
getParserOpts,
|
|
9
9
|
getWriterOpts,
|
|
10
|
+
getGitRawCommitsOpts,
|
|
10
11
|
} from '../preset-loader.js';
|
|
11
12
|
import runLifecycleScript from '../run-lifecycle-script.js';
|
|
12
13
|
import writeFile from '../write-file.js';
|
|
@@ -119,8 +120,15 @@ async function outputChangelog(args, newVersion) {
|
|
|
119
120
|
}
|
|
120
121
|
: {}),
|
|
121
122
|
})
|
|
122
|
-
.context({ version: newVersion })
|
|
123
|
-
.commits(
|
|
123
|
+
.context({ ...args.context, version: newVersion })
|
|
124
|
+
.commits(
|
|
125
|
+
{
|
|
126
|
+
...(getGitRawCommitsOpts(args) || {}),
|
|
127
|
+
merges: null,
|
|
128
|
+
path: args.path,
|
|
129
|
+
},
|
|
130
|
+
getParserOpts(args),
|
|
131
|
+
)
|
|
124
132
|
.writer({
|
|
125
133
|
// Split sections at the same tags the commit range is built from, so
|
|
126
134
|
// commits released in other prereleases stay in this release's section
|
package/lib/preset-loader.js
CHANGED
|
@@ -87,6 +87,17 @@ export function getWriterOpts(args) {
|
|
|
87
87
|
return mergeOptions(args.writer, args.writerOpts);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Commit-fetch options passed to ConventionalChangelog.commits() /
|
|
92
|
+
* Bumper.commits() (GetCommitsParams). Accept the legacy
|
|
93
|
+
* `gitRawCommitsOpts` name (from older conventional-changelog) and the
|
|
94
|
+
* modern `commits` alias. When both are present, `gitRawCommitsOpts`
|
|
95
|
+
* takes precedence.
|
|
96
|
+
*/
|
|
97
|
+
export function getGitRawCommitsOpts(args) {
|
|
98
|
+
return mergeOptions(args.commits, args.gitRawCommitsOpts);
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
export default (args) => {
|
|
91
102
|
let preset = args.preset || DEFAULT_PRESET;
|
|
92
103
|
if (preset === DEFAULT_PRESET) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-and-tag-version",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.4.0",
|
|
4
4
|
"description": "replacement for `npm version` with automatic CHANGELOG generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"@conventional-changelog/git-client": "3.1.0",
|
|
59
59
|
"@conventional-changelog/template": "1.4.0",
|
|
60
60
|
"chalk": "^6.0.1",
|
|
61
|
-
"conventional-changelog": "8.1.
|
|
61
|
+
"conventional-changelog": "8.1.3",
|
|
62
62
|
"conventional-changelog-config-spec": "2.1.0",
|
|
63
63
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
64
64
|
"conventional-recommended-bump": "12.1.0",
|
|
65
65
|
"detect-indent": "^7.0.2",
|
|
66
66
|
"detect-newline": "^3.1.0",
|
|
67
67
|
"dotgitignore": "^2.1.0",
|
|
68
|
-
"fast-xml-parser": "^5.
|
|
68
|
+
"fast-xml-parser": "^5.11.2",
|
|
69
69
|
"figures": "^6.1.0",
|
|
70
70
|
"find-up": "^5.0.0",
|
|
71
71
|
"semver": "^7.7.2",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"globals": "^17.12.0",
|
|
83
83
|
"istanbul-lib-instrument": "^6.0.3",
|
|
84
84
|
"pirates": "^4.0.7",
|
|
85
|
-
"prettier": "^3.9.
|
|
85
|
+
"prettier": "^3.9.10",
|
|
86
86
|
"shelljs": "^0.10.0",
|
|
87
87
|
"strip-ansi": "^7.2.0",
|
|
88
88
|
"vitest": "^4.1.0"
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import shell from 'shelljs';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
const repoUrl = 'https://github.com/example/changelog-context';
|
|
5
|
+
|
|
6
|
+
async function exec(opt) {
|
|
7
|
+
vi.resetModules();
|
|
8
|
+
const { default: cli } = await import('../command');
|
|
9
|
+
opt = cli.parse(`commit-and-tag-version ${opt} --silent`);
|
|
10
|
+
opt.skip = { commit: true, tag: true };
|
|
11
|
+
const { default: standardVersion } = await import('../index');
|
|
12
|
+
return standardVersion(opt);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function setupTempGitRepo(versionrc) {
|
|
16
|
+
shell.rm('-rf', 'changelog-context-temp');
|
|
17
|
+
shell.config.silent = true;
|
|
18
|
+
shell.mkdir('changelog-context-temp');
|
|
19
|
+
shell.cd('changelog-context-temp');
|
|
20
|
+
shell.exec('git init');
|
|
21
|
+
shell.exec('git config commit.gpgSign false');
|
|
22
|
+
shell.exec('git config core.autocrlf false');
|
|
23
|
+
fs.writeFileSync(
|
|
24
|
+
'package.json',
|
|
25
|
+
JSON.stringify({
|
|
26
|
+
name: 'changelog-context',
|
|
27
|
+
version: '1.0.0',
|
|
28
|
+
repository: { type: 'git', url: `${repoUrl}.git` },
|
|
29
|
+
}),
|
|
30
|
+
'utf-8',
|
|
31
|
+
);
|
|
32
|
+
if (versionrc) {
|
|
33
|
+
fs.writeFileSync('.versionrc', JSON.stringify(versionrc), 'utf-8');
|
|
34
|
+
}
|
|
35
|
+
shell.exec('git add -A');
|
|
36
|
+
shell.exec('git commit -m "chore: initial commit"');
|
|
37
|
+
shell.exec('git tag v1.0.0');
|
|
38
|
+
shell.exec('git commit --allow-empty -m "feat: A feature commit."');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function resetShell() {
|
|
42
|
+
shell.cd('../');
|
|
43
|
+
shell.rm('-rf', 'changelog-context-temp');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('changelog context', function () {
|
|
47
|
+
afterEach(function () {
|
|
48
|
+
resetShell();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('links the compare range and commit hashes by default', async function () {
|
|
52
|
+
setupTempGitRepo();
|
|
53
|
+
|
|
54
|
+
await exec();
|
|
55
|
+
|
|
56
|
+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8');
|
|
57
|
+
expect(content).toContain(`${repoUrl}/compare/v1.0.0...v1.1.0`);
|
|
58
|
+
expect(content).toMatch(new RegExp(`${repoUrl}/commit/[0-9a-f]{40}`));
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('applies the configured context to the changelog', async function () {
|
|
62
|
+
setupTempGitRepo({
|
|
63
|
+
context: { linkCompare: false, linkReferences: false },
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await exec();
|
|
67
|
+
|
|
68
|
+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8');
|
|
69
|
+
expect(content).toContain('## 1.1.0');
|
|
70
|
+
expect(content).toContain('### Features');
|
|
71
|
+
expect(content).toContain('A feature commit.');
|
|
72
|
+
expect(content).not.toContain(`${repoUrl}/compare/`);
|
|
73
|
+
expect(content).not.toContain(`${repoUrl}/commit/`);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -150,4 +150,27 @@ describe('config files', function () {
|
|
|
150
150
|
const content = fs.readFileSync('CHANGELOG.md', 'utf-8');
|
|
151
151
|
expect(content).toContain(issueUrlFormat);
|
|
152
152
|
});
|
|
153
|
+
|
|
154
|
+
it('passes gitRawCommitsOpts through to ConventionalChangelog.commits (#197)', async function () {
|
|
155
|
+
const format =
|
|
156
|
+
'%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae';
|
|
157
|
+
let seenCommits;
|
|
158
|
+
mock({
|
|
159
|
+
bump: 'minor',
|
|
160
|
+
changelog: ({ commits }) => {
|
|
161
|
+
seenCommits = commits;
|
|
162
|
+
return '## changelog\n';
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
// Use `.versionrc` (not `.versionrc.js`) so findUp picks this file before
|
|
166
|
+
// the repo-root `.versionrc` when walking from the temp directory.
|
|
167
|
+
fs.writeFileSync(
|
|
168
|
+
'.versionrc',
|
|
169
|
+
JSON.stringify({ gitRawCommitsOpts: { format } }),
|
|
170
|
+
'utf-8',
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
await exec();
|
|
174
|
+
expect(seenCommits).toMatchObject({ format, merges: null });
|
|
175
|
+
});
|
|
153
176
|
});
|
|
@@ -216,6 +216,16 @@ describe('git', function () {
|
|
|
216
216
|
expect(shell.exec('git describe').stdout).toMatch(/v1\.1\.0/);
|
|
217
217
|
});
|
|
218
218
|
|
|
219
|
+
it('uses an explicit releaseAs version when the bump is skipped', async function () {
|
|
220
|
+
mock({ bump: 'minor' });
|
|
221
|
+
await exec('--skip.bump --release-as 1.5.0');
|
|
222
|
+
expect(getPackageVersion()).toEqual('1.0.0');
|
|
223
|
+
expect(shell.exec('git describe').stdout).toMatch(/v1\.5\.0/);
|
|
224
|
+
expect(shell.exec('git log --oneline -n1').stdout).toMatch(
|
|
225
|
+
/chore\(release\): 1\.5\.0/,
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
|
|
219
229
|
it('allows the commit phase to be skipped', async function () {
|
|
220
230
|
const changelogContent = 'legacy header format<a name="1.0.0">\n';
|
|
221
231
|
writePackageJson('1.0.0');
|
package/test/utils.spec.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { promises as fsp } from 'fs';
|
|
2
2
|
import { detectPMByLockFile } from '../lib/detect-package-manager';
|
|
3
|
+
import {
|
|
4
|
+
getParserOpts,
|
|
5
|
+
getWriterOpts,
|
|
6
|
+
getGitRawCommitsOpts,
|
|
7
|
+
} from '../lib/preset-loader.js';
|
|
3
8
|
|
|
4
9
|
let mockFs;
|
|
5
10
|
|
|
@@ -33,3 +38,38 @@ describe('utils', function () {
|
|
|
33
38
|
expect(pm).toEqual('pnpm');
|
|
34
39
|
});
|
|
35
40
|
});
|
|
41
|
+
|
|
42
|
+
describe('preset-loader option aliases', function () {
|
|
43
|
+
it('getGitRawCommitsOpts merges commits and prefers gitRawCommitsOpts', function () {
|
|
44
|
+
expect(getGitRawCommitsOpts({})).toBeUndefined();
|
|
45
|
+
expect(
|
|
46
|
+
getGitRawCommitsOpts({ commits: { format: 'from-commits' } }),
|
|
47
|
+
).toEqual({ format: 'from-commits' });
|
|
48
|
+
expect(
|
|
49
|
+
getGitRawCommitsOpts({
|
|
50
|
+
gitRawCommitsOpts: { format: 'legacy' },
|
|
51
|
+
}),
|
|
52
|
+
).toEqual({ format: 'legacy' });
|
|
53
|
+
expect(
|
|
54
|
+
getGitRawCommitsOpts({
|
|
55
|
+
commits: { format: 'new', reverse: true },
|
|
56
|
+
gitRawCommitsOpts: { format: 'legacy' },
|
|
57
|
+
}),
|
|
58
|
+
).toEqual({ format: 'legacy', reverse: true });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('getParserOpts / getWriterOpts prefer *Opts over modern aliases', function () {
|
|
62
|
+
expect(
|
|
63
|
+
getParserOpts({
|
|
64
|
+
parser: { noteKeywords: ['A'] },
|
|
65
|
+
parserOpts: { noteKeywords: ['B'] },
|
|
66
|
+
}),
|
|
67
|
+
).toEqual({ noteKeywords: ['B'] });
|
|
68
|
+
expect(
|
|
69
|
+
getWriterOpts({
|
|
70
|
+
writer: { commitsSort: false },
|
|
71
|
+
writerOpts: { commitsSort: true },
|
|
72
|
+
}),
|
|
73
|
+
).toEqual({ commitsSort: true });
|
|
74
|
+
});
|
|
75
|
+
});
|