commit-and-tag-version 13.1.2 → 13.2.1
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 +19 -0
- package/MIGRATION.md +43 -1
- package/README.md +17 -8
- package/lib/lifecycles/changelog.js +1 -1
- package/lib/updaters/types/maven.js +37 -1
- package/package.json +10 -11
- package/test/core.spec.js +111 -3
- package/test/esm-config.integration-test.js +29 -1
- package/test/mocks/pom-6.3.1-mm-invalid-syntax.xml +36 -0
- package/test/mocks/pom-6.3.1-mm-missing-revision.xml +35 -0
- package/test/mocks/pom-6.3.1-mm-no-properties.xml +31 -0
- package/test/mocks/pom-6.3.1-mm.xml +36 -0
- package/test/mocks/pom-6.4.0-mm.xml +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
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.2.1](https://github.com/absolute-version/commit-and-tag-version/compare/v13.2.0...v13.2.1) (2026-09-14)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* bring back the blank line between release notes sections ([#341](https://github.com/absolute-version/commit-and-tag-version/issues/341)) ([4248f1a](https://github.com/absolute-version/commit-and-tag-version/commit/4248f1ab142784e84b4dc3fb19d02a25b92705a3))
|
|
11
|
+
|
|
12
|
+
## [13.2.0](https://github.com/absolute-version/commit-and-tag-version/compare/v13.1.2...v13.2.0) (2026-09-08)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **maven:** add support for multi-module pom version resolution ([#340](https://github.com/absolute-version/commit-and-tag-version/issues/340)) ([72f9a02](https://github.com/absolute-version/commit-and-tag-version/commit/72f9a02d7a8e00c8a98dca5720055830e1976e71))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* document and support custom writer render functions ([#324](https://github.com/absolute-version/commit-and-tag-version/issues/324)) ([c81ad2f](https://github.com/absolute-version/commit-and-tag-version/commit/c81ad2f214e44f5cfdfde7e9b80f7a82714453d5))
|
|
23
|
+
|
|
5
24
|
## [13.1.2](https://github.com/absolute-version/commit-and-tag-version/compare/v13.1.1...v13.1.2) (2026-07-28)
|
|
6
25
|
|
|
7
26
|
|
package/MIGRATION.md
CHANGED
|
@@ -42,10 +42,52 @@ The content of the changelog is otherwise unchanged. This only affects newly gen
|
|
|
42
42
|
|
|
43
43
|
The new conventional-changelog packages require Node.js >= 22, so `commit-and-tag-version` now does too. Node 20 reached end-of-life in April 2026, so I expect this won't affect most users.
|
|
44
44
|
|
|
45
|
+
### Custom writer templates use render functions
|
|
46
|
+
|
|
47
|
+
[conventional-changelog v8.0.0](https://github.com/conventional-changelog/conventional-changelog/releases/tag/conventional-changelog-v8.0.0) replaced Handlebars template strings and partial files with JavaScript render functions ([#1477](https://github.com/conventional-changelog/conventional-changelog/issues/1477)). The following `writerOpts` options must now be functions:
|
|
48
|
+
|
|
49
|
+
- `template`
|
|
50
|
+
- `headerPartial`
|
|
51
|
+
- `commitPartial`
|
|
52
|
+
- `footerPartial`
|
|
53
|
+
|
|
54
|
+
The old `mainTemplate` option must be migrated to `template(context)`. The official [`@conventional-changelog/template` helpers](https://conventional-changelog.js.org/template/) provide Markdown, URL, repository and composition helpers for building these render functions.
|
|
55
|
+
|
|
56
|
+
Before:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
module.exports = {
|
|
60
|
+
writerOpts: {
|
|
61
|
+
mainTemplate: '...',
|
|
62
|
+
commitPartial: '- {{subject}}',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
After:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import { words } from '@conventional-changelog/template';
|
|
71
|
+
|
|
72
|
+
function commitPartial(_context, commit) {
|
|
73
|
+
return words(commit.subject || commit.header, commit.shortHash);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default {
|
|
77
|
+
writerOpts: {
|
|
78
|
+
commitPartial,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If you customized the main template, implement `template(context)` as well instead of continuing to use `mainTemplate`.
|
|
84
|
+
|
|
85
|
+
ESM `.versionrc.js` and `.versionrc.mjs` configurations require [`commit-and-tag-version` 13.1.0](https://github.com/absolute-version/commit-and-tag-version/releases/tag/v13.1.0) or newer. Although `@conventional-changelog/template` is a direct dependency of `commit-and-tag-version`, a configuration file that imports it directly should also declare it as a direct dependency of the user project. This is required by strict dependency managers such as pnpm.
|
|
86
|
+
|
|
45
87
|
### Behaviour that is intentionally preserved
|
|
46
88
|
|
|
47
89
|
The upstream packages made some breaking changes that `commit-and-tag-version` shields you from, so no action is needed for these — they're listed here for the record:
|
|
48
90
|
|
|
49
91
|
- **`types[].hidden` and the URL format options still work.** conventional-changelog-conventionalcommits 10 replaced `types[].hidden` with `types[].effect`, and replaced the `commitUrlFormat`, `compareUrlFormat`, `issueUrlFormat` and `userUrlFormat` template strings with callback functions. `commit-and-tag-version` translates the [config-spec](https://github.com/conventional-changelog/conventional-changelog-config-spec) options for you, so existing configuration keeps working. (If you supply the new-style `effect` / `format*Url` options, they're passed through untouched.)
|
|
50
92
|
- **Version bump recommendations are unchanged.** The new preset only recommends a release when there's at least one `feat`, `fix`, `perf`, `revert` or breaking change; `commit-and-tag-version` keeps its historical behaviour of always recommending at least a patch. Use `--noBumpWhenEmptyChanges` if you don't want a release when there are no relevant commits, as before. In a future major release, we might change this default, depending on feedback.
|
|
51
|
-
- **`parserOpts` and `writerOpts` overrides work as before**, merged over the preset's options.
|
|
93
|
+
- **`parserOpts` and non-template `writerOpts` overrides work as before**, merged over the preset's options. Custom writer templates are the exception and must use the render functions described above.
|
package/README.md
CHANGED
|
@@ -432,6 +432,8 @@ by adding the following to your package.json:
|
|
|
432
432
|
}
|
|
433
433
|
```
|
|
434
434
|
|
|
435
|
+
To set these options via the command line, use `commit-and-tag-version --skip.changelog`
|
|
436
|
+
|
|
435
437
|
### Committing Generated Artifacts in the Release Commit
|
|
436
438
|
|
|
437
439
|
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:
|
|
@@ -661,26 +663,33 @@ module.exports.writeVersion = function (contents, version) {
|
|
|
661
663
|
### Why do breaking changes before 1.0.0 not trigger a 1.0.0 release?
|
|
662
664
|
|
|
663
665
|
Below 1.0.0, the semver specification doesn't give any guarantees about the
|
|
664
|
-
meaning of version numbers.
|
|
666
|
+
meaning of version numbers.
|
|
667
|
+
|
|
668
|
+
However, with npm there is a community convention,
|
|
665
669
|
and implementation-defined behaviour: If your version is between 0.1.0 and
|
|
666
|
-
1.0.0, npm treats an update to the
|
|
670
|
+
1.0.0, npm treats an update to the _minor_ version as a breaking change - that is
|
|
667
671
|
^0.1.0 will match 0.1.2 but not 0.2.0. Rust's cargo package manager also behaves
|
|
668
672
|
the same way.
|
|
669
673
|
|
|
670
|
-
|
|
671
|
-
changes below v1.0.0 are treated as a minor version bump
|
|
672
|
-
|
|
674
|
+
Via conventional-commits, we also follow that convention - breaking
|
|
675
|
+
changes below v1.0.0 are treated as a minor version bump, with all other changes being a patch version bump.
|
|
676
|
+
|
|
677
|
+
Here's an example series of commits to illustrate the behaviour, where only breaking changes will advance the minor version:
|
|
673
678
|
|
|
674
679
|
```
|
|
675
680
|
1017b00 chore: initial commit
|
|
676
681
|
9e2ba95 (tag: v0.0.2) chore(release): 0.0.2
|
|
682
|
+
ab1826f feat: Some new feature
|
|
683
|
+
497bc01 (tag: v0.0.3) chore(release): 0.0.3
|
|
684
|
+
f82b518 fix: Some bug fix
|
|
685
|
+
b6382bd (tag: v0.0.3) chore(release): 0.0.4
|
|
677
686
|
3598012 fix!: Example breaking change
|
|
678
687
|
1a4994a (tag: v0.1.0) chore(release): 0.1.0
|
|
679
688
|
```
|
|
680
689
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
with other package managers for other ecosystems).
|
|
690
|
+
Although semver makes no guarantee about the meaning of pre-major releases, npm _has_ made a choice about
|
|
691
|
+
the meaning. For this reason, `commit-and-tag-version` follows the same convention (along
|
|
692
|
+
with other package managers for other ecosystems, like Cargo).
|
|
684
693
|
|
|
685
694
|
When you are ready to release v1.0.0, add `--release-as 1.0.0` to the options.
|
|
686
695
|
|
|
@@ -26,6 +26,23 @@ function pomVersion(document) {
|
|
|
26
26
|
'Failed to read the version field in your pom file - is it present?',
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
|
+
if (version.startsWith('${')) {
|
|
30
|
+
const revisionMatcher = /^\${(?<property>[^}]+)}$/.exec(version);
|
|
31
|
+
if (!revisionMatcher) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
'Failed to read the version field in your pom file - unexpected invalid property reference',
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const revisionVersion = document.project.properties
|
|
37
|
+
? document.project.properties[revisionMatcher.groups.property]
|
|
38
|
+
: null;
|
|
39
|
+
if (!revisionVersion) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Failed to read the ${revisionMatcher.groups.property} field in your pom file properties - is it present?`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return revisionVersion;
|
|
45
|
+
}
|
|
29
46
|
|
|
30
47
|
return version;
|
|
31
48
|
}
|
|
@@ -38,8 +55,27 @@ export function readVersion(contents) {
|
|
|
38
55
|
export function writeVersion(contents, version) {
|
|
39
56
|
const newline = detectNewline(contents);
|
|
40
57
|
const document = pomDocument(contents);
|
|
58
|
+
const pomVersion = document.project.version;
|
|
41
59
|
|
|
42
|
-
|
|
60
|
+
if (pomVersion.startsWith('${')) {
|
|
61
|
+
const revisionMatcher = /^\${(?<property>[^}]+)}$/.exec(pomVersion);
|
|
62
|
+
if (!revisionMatcher) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
'Failed to read the version field in your pom file - unexpected invalid property reference',
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const revisionVersion = document.project.properties
|
|
68
|
+
? document.project.properties[revisionMatcher.groups.property]
|
|
69
|
+
: null;
|
|
70
|
+
if (!revisionVersion) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Failed to read the ${revisionMatcher.groups.property} field in your pom file properties - is it present?`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
document.project.properties[revisionMatcher.groups.property] = version;
|
|
76
|
+
} else {
|
|
77
|
+
document.project.version = version;
|
|
78
|
+
}
|
|
43
79
|
|
|
44
80
|
const builder = new XMLBuilder({
|
|
45
81
|
// Preserve attributes on XML elements (fast-xml-parser strips them by default)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-and-tag-version",
|
|
3
|
-
"version": "13.1
|
|
3
|
+
"version": "13.2.1",
|
|
4
4
|
"description": "replacement for `npm version` with automatic CHANGELOG generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"homepage": "https://github.com/absolute-version/commit-and-tag-version#readme",
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@conventional-changelog/git-client": "3.1.0",
|
|
50
|
-
"
|
|
50
|
+
"@conventional-changelog/template": "1.2.1",
|
|
51
|
+
"chalk": "^6.0.0",
|
|
51
52
|
"conventional-changelog": "8.1.0",
|
|
52
53
|
"conventional-changelog-config-spec": "2.1.0",
|
|
53
54
|
"conventional-changelog-conventionalcommits": "10.2.1",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"detect-indent": "^7.0.2",
|
|
56
57
|
"detect-newline": "^3.1.0",
|
|
57
58
|
"dotgitignore": "^2.1.0",
|
|
58
|
-
"fast-xml-parser": "^5.
|
|
59
|
+
"fast-xml-parser": "^5.10.1",
|
|
59
60
|
"figures": "^3.2.0",
|
|
60
61
|
"find-up": "^5.0.0",
|
|
61
62
|
"semver": "^7.7.2",
|
|
@@ -63,18 +64,16 @@
|
|
|
63
64
|
"yargs": "^17.7.2"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"@eslint/js": "^
|
|
67
|
-
"@vitest/coverage-istanbul": "^4.1.
|
|
68
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
67
|
+
"@eslint/js": "^10.0.1",
|
|
68
|
+
"@vitest/coverage-istanbul": "^4.1.11",
|
|
69
|
+
"@vitest/eslint-plugin": "^1.6.26",
|
|
69
70
|
"conventional-changelog-angular": "^9.2.1",
|
|
70
|
-
"eslint": "^
|
|
71
|
+
"eslint": "^10.8.1",
|
|
71
72
|
"eslint-config-prettier": "^10.1.8",
|
|
72
|
-
"
|
|
73
|
-
"eslint-plugin-n": "^18.2.2",
|
|
74
|
-
"eslint-plugin-promise": "^7.2.1",
|
|
73
|
+
"globals": "^17.11.0",
|
|
75
74
|
"istanbul-lib-instrument": "^6.0.3",
|
|
76
75
|
"pirates": "^4.0.7",
|
|
77
|
-
"prettier": "^3.
|
|
76
|
+
"prettier": "^3.9.6",
|
|
78
77
|
"shelljs": "^0.10.0",
|
|
79
78
|
"strip-ansi": "^7.2.0",
|
|
80
79
|
"vitest": "^4.1.0"
|
package/test/core.spec.js
CHANGED
|
@@ -389,7 +389,13 @@ describe('cli', function () {
|
|
|
389
389
|
verifyNewChangelogContentEquals({
|
|
390
390
|
writeFileSyncSpy,
|
|
391
391
|
expectedContent:
|
|
392
|
-
frontMatter +
|
|
392
|
+
frontMatter +
|
|
393
|
+
'\n' +
|
|
394
|
+
header +
|
|
395
|
+
'\n' +
|
|
396
|
+
changelog101 +
|
|
397
|
+
'\n' +
|
|
398
|
+
changelog100,
|
|
393
399
|
});
|
|
394
400
|
});
|
|
395
401
|
|
|
@@ -417,7 +423,13 @@ describe('cli', function () {
|
|
|
417
423
|
verifyNewChangelogContentEquals({
|
|
418
424
|
writeFileSyncSpy,
|
|
419
425
|
expectedContent:
|
|
420
|
-
frontMatter +
|
|
426
|
+
frontMatter +
|
|
427
|
+
'\n' +
|
|
428
|
+
header +
|
|
429
|
+
'\n' +
|
|
430
|
+
changelog101 +
|
|
431
|
+
'\n' +
|
|
432
|
+
changelog100,
|
|
421
433
|
});
|
|
422
434
|
});
|
|
423
435
|
|
|
@@ -446,7 +458,7 @@ describe('cli', function () {
|
|
|
446
458
|
await exec();
|
|
447
459
|
verifyNewChangelogContentEquals({
|
|
448
460
|
writeFileSyncSpy,
|
|
449
|
-
expectedContent: header + '\n' + changelog2 + changelog1,
|
|
461
|
+
expectedContent: header + '\n' + changelog2 + '\n' + changelog1,
|
|
450
462
|
});
|
|
451
463
|
});
|
|
452
464
|
|
|
@@ -1491,6 +1503,102 @@ describe('cli', function () {
|
|
|
1491
1503
|
expect(calledWithContentStr).toEqual(expected);
|
|
1492
1504
|
});
|
|
1493
1505
|
|
|
1506
|
+
describe('multi-module maven pom.xml files', function () {
|
|
1507
|
+
it('bumps version in multi-module Maven `pom.xml` file while preserving revisions', async function () {
|
|
1508
|
+
const expected = fs.readFileSync(
|
|
1509
|
+
'./test/mocks/pom-6.4.0-mm.xml',
|
|
1510
|
+
'utf-8',
|
|
1511
|
+
);
|
|
1512
|
+
const filename = 'pom.xml';
|
|
1513
|
+
mock({
|
|
1514
|
+
bump: 'minor',
|
|
1515
|
+
realTestFiles: [
|
|
1516
|
+
{
|
|
1517
|
+
filename,
|
|
1518
|
+
path: './test/mocks/pom-6.3.1-mm.xml',
|
|
1519
|
+
},
|
|
1520
|
+
],
|
|
1521
|
+
});
|
|
1522
|
+
await exec({
|
|
1523
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1524
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1525
|
+
});
|
|
1526
|
+
|
|
1527
|
+
// filePath is the first arg passed to writeFileSync
|
|
1528
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1529
|
+
writeFileSyncSpy,
|
|
1530
|
+
filename,
|
|
1531
|
+
});
|
|
1532
|
+
|
|
1533
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1534
|
+
throw new Error(`writeFileSynch not invoked with path ${filename}`);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1538
|
+
expect(calledWithContentStr).toEqual(expected);
|
|
1539
|
+
});
|
|
1540
|
+
|
|
1541
|
+
it('throws error in multi-module Maven `pom.xml` file when version is invalid syntax', async function () {
|
|
1542
|
+
const filename = 'pom.xml';
|
|
1543
|
+
mock({
|
|
1544
|
+
bump: 'minor',
|
|
1545
|
+
realTestFiles: [
|
|
1546
|
+
{
|
|
1547
|
+
filename,
|
|
1548
|
+
path: './test/mocks/pom-6.3.1-mm-invalid-syntax.xml',
|
|
1549
|
+
},
|
|
1550
|
+
],
|
|
1551
|
+
});
|
|
1552
|
+
await exec({
|
|
1553
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1554
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1555
|
+
});
|
|
1556
|
+
const expectedLog =
|
|
1557
|
+
'Failed to read the version field in your pom file - unexpected invalid property reference';
|
|
1558
|
+
verifyLogPrinted({ consoleInfoSpy: consoleErrorSpy, expectedLog });
|
|
1559
|
+
});
|
|
1560
|
+
|
|
1561
|
+
it('throws error in multi-module Maven `pom.xml` file when no properties are discovered', async function () {
|
|
1562
|
+
const filename = 'pom.xml';
|
|
1563
|
+
mock({
|
|
1564
|
+
bump: 'minor',
|
|
1565
|
+
realTestFiles: [
|
|
1566
|
+
{
|
|
1567
|
+
filename,
|
|
1568
|
+
path: './test/mocks/pom-6.3.1-mm-no-properties.xml',
|
|
1569
|
+
},
|
|
1570
|
+
],
|
|
1571
|
+
});
|
|
1572
|
+
await exec({
|
|
1573
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1574
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1575
|
+
});
|
|
1576
|
+
const expectedLog =
|
|
1577
|
+
'Failed to read the revision field in your pom file properties - is it present?';
|
|
1578
|
+
verifyLogPrinted({ consoleInfoSpy: consoleErrorSpy, expectedLog });
|
|
1579
|
+
});
|
|
1580
|
+
|
|
1581
|
+
it('throws error in multi-module Maven `pom.xml` file when associated property is missing', async function () {
|
|
1582
|
+
const filename = 'pom.xml';
|
|
1583
|
+
mock({
|
|
1584
|
+
bump: 'minor',
|
|
1585
|
+
realTestFiles: [
|
|
1586
|
+
{
|
|
1587
|
+
filename,
|
|
1588
|
+
path: './test/mocks/pom-6.3.1-mm-missing-revision.xml',
|
|
1589
|
+
},
|
|
1590
|
+
],
|
|
1591
|
+
});
|
|
1592
|
+
await exec({
|
|
1593
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1594
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1595
|
+
});
|
|
1596
|
+
const expectedLog =
|
|
1597
|
+
'Failed to read the revision field in your pom file properties - is it present?';
|
|
1598
|
+
verifyLogPrinted({ consoleInfoSpy: consoleErrorSpy, expectedLog });
|
|
1599
|
+
});
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1494
1602
|
it('bumps version in Gradle `build.gradle.kts` file', async function () {
|
|
1495
1603
|
const expected = fs.readFileSync(
|
|
1496
1604
|
'./test/mocks/build-6.4.0.gradle.kts',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import shell from 'shelljs';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { execFileSync } from 'child_process';
|
|
3
|
+
import { execFileSync, spawnSync } from 'child_process';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
|
|
6
6
|
const CLI = fileURLToPath(new URL('../bin/cli.js', import.meta.url));
|
|
@@ -62,6 +62,34 @@ describe('ESM config files', function () {
|
|
|
62
62
|
expect(output).toContain('tagging release custom-1.0.1');
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
it('renders a custom writer function imported by an ES module config', function () {
|
|
66
|
+
fs.writeFileSync(
|
|
67
|
+
'.versionrc.js',
|
|
68
|
+
`import { words } from '@conventional-changelog/template'
|
|
69
|
+
|
|
70
|
+
function commitPartial(_context, commit) {
|
|
71
|
+
return words(commit.subject || commit.header, commit.shortHash)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default {
|
|
75
|
+
writerOpts: {
|
|
76
|
+
commitPartial,
|
|
77
|
+
},
|
|
78
|
+
}`,
|
|
79
|
+
'utf-8',
|
|
80
|
+
);
|
|
81
|
+
shell.exec('git commit --allow-empty -m"fix: render custom writer"');
|
|
82
|
+
|
|
83
|
+
const result = spawnSync(process.execPath, [CLI, '--dry-run'], {
|
|
84
|
+
encoding: 'utf-8',
|
|
85
|
+
});
|
|
86
|
+
const output = `${result.stdout}${result.stderr}`;
|
|
87
|
+
|
|
88
|
+
expect(result.status).toBe(0);
|
|
89
|
+
expect(output).toContain('render custom writer');
|
|
90
|
+
expect(output).not.toContain('commitPartial is not a function');
|
|
91
|
+
});
|
|
92
|
+
|
|
65
93
|
it('reads an ES module config from .versionrc.mjs', function () {
|
|
66
94
|
fs.writeFileSync(
|
|
67
95
|
'.versionrc.mjs',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
|
|
4
|
+
<parent>
|
|
5
|
+
<groupId>com.mycompany.app</groupId>
|
|
6
|
+
<artifactId>my-app</artifactId>
|
|
7
|
+
<version>3.0.0</version>
|
|
8
|
+
</parent>
|
|
9
|
+
|
|
10
|
+
<groupId>com.mycompany.app</groupId>
|
|
11
|
+
<artifactId>my-multi-module-project</artifactId>
|
|
12
|
+
<version>${revision</version>
|
|
13
|
+
<packaging>pom</packaging>
|
|
14
|
+
|
|
15
|
+
<properties>
|
|
16
|
+
<revision>6.3.1</revision>
|
|
17
|
+
<some.version>2.0.0</some.version>
|
|
18
|
+
</properties>
|
|
19
|
+
|
|
20
|
+
<modules>
|
|
21
|
+
<module>my-module</module>
|
|
22
|
+
</modules>
|
|
23
|
+
|
|
24
|
+
<dependencies>
|
|
25
|
+
<dependency>
|
|
26
|
+
<groupId>org.some.dependency</groupId>
|
|
27
|
+
<artifactId>some-artifact</artifactId>
|
|
28
|
+
<version>${some.version}</version>
|
|
29
|
+
</dependency>
|
|
30
|
+
<dependency>
|
|
31
|
+
<groupId>org.another.dependency</groupId>
|
|
32
|
+
<artifactId>another-artifact</artifactId>
|
|
33
|
+
<version>1.0.0</version>
|
|
34
|
+
</dependency>
|
|
35
|
+
</dependencies>
|
|
36
|
+
</project>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
|
|
4
|
+
<parent>
|
|
5
|
+
<groupId>com.mycompany.app</groupId>
|
|
6
|
+
<artifactId>my-app</artifactId>
|
|
7
|
+
<version>3.0.0</version>
|
|
8
|
+
</parent>
|
|
9
|
+
|
|
10
|
+
<groupId>com.mycompany.app</groupId>
|
|
11
|
+
<artifactId>my-multi-module-project</artifactId>
|
|
12
|
+
<version>${revision}</version>
|
|
13
|
+
<packaging>pom</packaging>
|
|
14
|
+
|
|
15
|
+
<properties>
|
|
16
|
+
<some.version>2.0.0</some.version>
|
|
17
|
+
</properties>
|
|
18
|
+
|
|
19
|
+
<modules>
|
|
20
|
+
<module>my-module</module>
|
|
21
|
+
</modules>
|
|
22
|
+
|
|
23
|
+
<dependencies>
|
|
24
|
+
<dependency>
|
|
25
|
+
<groupId>org.some.dependency</groupId>
|
|
26
|
+
<artifactId>some-artifact</artifactId>
|
|
27
|
+
<version>${some.version}</version>
|
|
28
|
+
</dependency>
|
|
29
|
+
<dependency>
|
|
30
|
+
<groupId>org.another.dependency</groupId>
|
|
31
|
+
<artifactId>another-artifact</artifactId>
|
|
32
|
+
<version>1.0.0</version>
|
|
33
|
+
</dependency>
|
|
34
|
+
</dependencies>
|
|
35
|
+
</project>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
|
|
4
|
+
<parent>
|
|
5
|
+
<groupId>com.mycompany.app</groupId>
|
|
6
|
+
<artifactId>my-app</artifactId>
|
|
7
|
+
<version>3.0.0</version>
|
|
8
|
+
</parent>
|
|
9
|
+
|
|
10
|
+
<groupId>com.mycompany.app</groupId>
|
|
11
|
+
<artifactId>my-multi-module-project</artifactId>
|
|
12
|
+
<version>${revision}</version>
|
|
13
|
+
<packaging>pom</packaging>
|
|
14
|
+
|
|
15
|
+
<modules>
|
|
16
|
+
<module>my-module</module>
|
|
17
|
+
</modules>
|
|
18
|
+
|
|
19
|
+
<dependencies>
|
|
20
|
+
<dependency>
|
|
21
|
+
<groupId>org.some.dependency</groupId>
|
|
22
|
+
<artifactId>some-artifact</artifactId>
|
|
23
|
+
<version>${some.version}</version>
|
|
24
|
+
</dependency>
|
|
25
|
+
<dependency>
|
|
26
|
+
<groupId>org.another.dependency</groupId>
|
|
27
|
+
<artifactId>another-artifact</artifactId>
|
|
28
|
+
<version>1.0.0</version>
|
|
29
|
+
</dependency>
|
|
30
|
+
</dependencies>
|
|
31
|
+
</project>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
|
|
4
|
+
<parent>
|
|
5
|
+
<groupId>com.mycompany.app</groupId>
|
|
6
|
+
<artifactId>my-app</artifactId>
|
|
7
|
+
<version>3.0.0</version>
|
|
8
|
+
</parent>
|
|
9
|
+
|
|
10
|
+
<groupId>com.mycompany.app</groupId>
|
|
11
|
+
<artifactId>my-multi-module-project</artifactId>
|
|
12
|
+
<version>${revision}</version>
|
|
13
|
+
<packaging>pom</packaging>
|
|
14
|
+
|
|
15
|
+
<properties>
|
|
16
|
+
<revision>6.3.1</revision>
|
|
17
|
+
<some.version>2.0.0</some.version>
|
|
18
|
+
</properties>
|
|
19
|
+
|
|
20
|
+
<modules>
|
|
21
|
+
<module>my-module</module>
|
|
22
|
+
</modules>
|
|
23
|
+
|
|
24
|
+
<dependencies>
|
|
25
|
+
<dependency>
|
|
26
|
+
<groupId>org.some.dependency</groupId>
|
|
27
|
+
<artifactId>some-artifact</artifactId>
|
|
28
|
+
<version>${some.version}</version>
|
|
29
|
+
</dependency>
|
|
30
|
+
<dependency>
|
|
31
|
+
<groupId>org.another.dependency</groupId>
|
|
32
|
+
<artifactId>another-artifact</artifactId>
|
|
33
|
+
<version>1.0.0</version>
|
|
34
|
+
</dependency>
|
|
35
|
+
</dependencies>
|
|
36
|
+
</project>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<project>
|
|
2
|
+
<modelVersion>4.0.0</modelVersion>
|
|
3
|
+
<parent>
|
|
4
|
+
<groupId>com.mycompany.app</groupId>
|
|
5
|
+
<artifactId>my-app</artifactId>
|
|
6
|
+
<version>3.0.0</version>
|
|
7
|
+
</parent>
|
|
8
|
+
<groupId>com.mycompany.app</groupId>
|
|
9
|
+
<artifactId>my-multi-module-project</artifactId>
|
|
10
|
+
<version>${revision}</version>
|
|
11
|
+
<packaging>pom</packaging>
|
|
12
|
+
<properties>
|
|
13
|
+
<revision>6.4.0</revision>
|
|
14
|
+
<some.version>2.0.0</some.version>
|
|
15
|
+
</properties>
|
|
16
|
+
<modules>
|
|
17
|
+
<module>my-module</module>
|
|
18
|
+
</modules>
|
|
19
|
+
<dependencies>
|
|
20
|
+
<dependency>
|
|
21
|
+
<groupId>org.some.dependency</groupId>
|
|
22
|
+
<artifactId>some-artifact</artifactId>
|
|
23
|
+
<version>${some.version}</version>
|
|
24
|
+
</dependency>
|
|
25
|
+
<dependency>
|
|
26
|
+
<groupId>org.another.dependency</groupId>
|
|
27
|
+
<artifactId>another-artifact</artifactId>
|
|
28
|
+
<version>1.0.0</version>
|
|
29
|
+
</dependency>
|
|
30
|
+
</dependencies>
|
|
31
|
+
</project>
|
|
32
|
+
|