commit-and-tag-version 13.1.1 → 13.2.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 +19 -0
- package/MIGRATION.md +43 -1
- package/README.md +39 -8
- package/lib/updaters/types/maven.js +37 -1
- package/lib/updaters/types/openapi.js +1 -1
- package/lib/updaters/types/yaml.js +1 -1
- package/package.json +10 -11
- package/test/core.spec.js +96 -0
- 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/test/yaml-updaters.spec.js +20 -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.0](https://github.com/absolute-version/commit-and-tag-version/compare/v13.1.2...v13.2.0) (2026-09-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **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))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* 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))
|
|
16
|
+
|
|
17
|
+
## [13.1.2](https://github.com/absolute-version/commit-and-tag-version/compare/v13.1.1...v13.1.2) (2026-07-28)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **yaml:** preserve long scalar lines ([#313](https://github.com/absolute-version/commit-and-tag-version/issues/313)) ([8b968bc](https://github.com/absolute-version/commit-and-tag-version/commit/8b968bc1d98d85134c91efe66727bc2e1823a997))
|
|
23
|
+
|
|
5
24
|
## [13.1.1](https://github.com/absolute-version/commit-and-tag-version/compare/v13.1.0...v13.1.1) (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
|
@@ -299,6 +299,28 @@ commit-and-tag-version --prerelease xyz # Creates v1.4.3-xyz.1 (auto-incremente
|
|
|
299
299
|
|
|
300
300
|
This behavior applies to both named prereleases (e.g., `-alpha.0`, `-beta.1`) and unnamed prereleases (e.g., `-0`, `-1`), ensuring that you can safely cut multiple prerelease versions without encountering git tag conflicts.
|
|
301
301
|
|
|
302
|
+
#### Keeping Prereleases out of a Final Changelog
|
|
303
|
+
|
|
304
|
+
`commit-and-tag-version` does not currently provide a general-purpose option to
|
|
305
|
+
ignore every intermediary prerelease tag when generating a final release
|
|
306
|
+
changelog. The `releaseCount` option controls how many release sections are
|
|
307
|
+
generated; it does not exclude prerelease tags.
|
|
308
|
+
|
|
309
|
+
To keep a final changelog based on the previous stable release, maintain a
|
|
310
|
+
dedicated prerelease branch and merge the stable branch into it as product
|
|
311
|
+
changes land. Cut prereleases only from that branch, keeping their tagged
|
|
312
|
+
release commits unreachable from the stable branch. When the code is ready, cut
|
|
313
|
+
the stable release from the stable branch without merging the prerelease branch
|
|
314
|
+
back. If product changes exist only on the prerelease branch, transfer those
|
|
315
|
+
changes selectively instead of bringing its generated prerelease versions,
|
|
316
|
+
changelog entries, or release commits into stable history.
|
|
317
|
+
|
|
318
|
+
Avoid deleting prerelease tags locally, cutting the stable release, and then
|
|
319
|
+
fetching the tags again. That workaround makes changelog generation depend on
|
|
320
|
+
an incomplete local tag set, can affect tag-derived version calculations, and
|
|
321
|
+
temporarily puts local and remote tag state out of sync. Keeping the tags intact
|
|
322
|
+
and using separate branch histories makes the release inputs reproducible.
|
|
323
|
+
|
|
302
324
|
### Release as a Target Type Imperatively (`npm version`-like)
|
|
303
325
|
|
|
304
326
|
To forgo the automated version bump use `--release-as` with the argument `major`, `minor` or `patch`.
|
|
@@ -410,6 +432,8 @@ by adding the following to your package.json:
|
|
|
410
432
|
}
|
|
411
433
|
```
|
|
412
434
|
|
|
435
|
+
To set these options via the command line, use `commit-and-tag-version --skip.changelog`
|
|
436
|
+
|
|
413
437
|
### Committing Generated Artifacts in the Release Commit
|
|
414
438
|
|
|
415
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:
|
|
@@ -639,26 +663,33 @@ module.exports.writeVersion = function (contents, version) {
|
|
|
639
663
|
### Why do breaking changes before 1.0.0 not trigger a 1.0.0 release?
|
|
640
664
|
|
|
641
665
|
Below 1.0.0, the semver specification doesn't give any guarantees about the
|
|
642
|
-
meaning of version numbers.
|
|
666
|
+
meaning of version numbers.
|
|
667
|
+
|
|
668
|
+
However, with npm there is a community convention,
|
|
643
669
|
and implementation-defined behaviour: If your version is between 0.1.0 and
|
|
644
|
-
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
|
|
645
671
|
^0.1.0 will match 0.1.2 but not 0.2.0. Rust's cargo package manager also behaves
|
|
646
672
|
the same way.
|
|
647
673
|
|
|
648
|
-
|
|
649
|
-
changes below v1.0.0 are treated as a minor version bump
|
|
650
|
-
|
|
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:
|
|
651
678
|
|
|
652
679
|
```
|
|
653
680
|
1017b00 chore: initial commit
|
|
654
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
|
|
655
686
|
3598012 fix!: Example breaking change
|
|
656
687
|
1a4994a (tag: v0.1.0) chore(release): 0.1.0
|
|
657
688
|
```
|
|
658
689
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
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).
|
|
662
693
|
|
|
663
694
|
When you are ready to release v1.0.0, add `--release-as 1.0.0` to the options.
|
|
664
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.
|
|
3
|
+
"version": "13.2.0",
|
|
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
|
@@ -1491,6 +1491,102 @@ describe('cli', function () {
|
|
|
1491
1491
|
expect(calledWithContentStr).toEqual(expected);
|
|
1492
1492
|
});
|
|
1493
1493
|
|
|
1494
|
+
describe('multi-module maven pom.xml files', function () {
|
|
1495
|
+
it('bumps version in multi-module Maven `pom.xml` file while preserving revisions', async function () {
|
|
1496
|
+
const expected = fs.readFileSync(
|
|
1497
|
+
'./test/mocks/pom-6.4.0-mm.xml',
|
|
1498
|
+
'utf-8',
|
|
1499
|
+
);
|
|
1500
|
+
const filename = 'pom.xml';
|
|
1501
|
+
mock({
|
|
1502
|
+
bump: 'minor',
|
|
1503
|
+
realTestFiles: [
|
|
1504
|
+
{
|
|
1505
|
+
filename,
|
|
1506
|
+
path: './test/mocks/pom-6.3.1-mm.xml',
|
|
1507
|
+
},
|
|
1508
|
+
],
|
|
1509
|
+
});
|
|
1510
|
+
await exec({
|
|
1511
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1512
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1513
|
+
});
|
|
1514
|
+
|
|
1515
|
+
// filePath is the first arg passed to writeFileSync
|
|
1516
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1517
|
+
writeFileSyncSpy,
|
|
1518
|
+
filename,
|
|
1519
|
+
});
|
|
1520
|
+
|
|
1521
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1522
|
+
throw new Error(`writeFileSynch not invoked with path ${filename}`);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1526
|
+
expect(calledWithContentStr).toEqual(expected);
|
|
1527
|
+
});
|
|
1528
|
+
|
|
1529
|
+
it('throws error in multi-module Maven `pom.xml` file when version is invalid syntax', async function () {
|
|
1530
|
+
const filename = 'pom.xml';
|
|
1531
|
+
mock({
|
|
1532
|
+
bump: 'minor',
|
|
1533
|
+
realTestFiles: [
|
|
1534
|
+
{
|
|
1535
|
+
filename,
|
|
1536
|
+
path: './test/mocks/pom-6.3.1-mm-invalid-syntax.xml',
|
|
1537
|
+
},
|
|
1538
|
+
],
|
|
1539
|
+
});
|
|
1540
|
+
await exec({
|
|
1541
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1542
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1543
|
+
});
|
|
1544
|
+
const expectedLog =
|
|
1545
|
+
'Failed to read the version field in your pom file - unexpected invalid property reference';
|
|
1546
|
+
verifyLogPrinted({ consoleInfoSpy: consoleErrorSpy, expectedLog });
|
|
1547
|
+
});
|
|
1548
|
+
|
|
1549
|
+
it('throws error in multi-module Maven `pom.xml` file when no properties are discovered', async function () {
|
|
1550
|
+
const filename = 'pom.xml';
|
|
1551
|
+
mock({
|
|
1552
|
+
bump: 'minor',
|
|
1553
|
+
realTestFiles: [
|
|
1554
|
+
{
|
|
1555
|
+
filename,
|
|
1556
|
+
path: './test/mocks/pom-6.3.1-mm-no-properties.xml',
|
|
1557
|
+
},
|
|
1558
|
+
],
|
|
1559
|
+
});
|
|
1560
|
+
await exec({
|
|
1561
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1562
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1563
|
+
});
|
|
1564
|
+
const expectedLog =
|
|
1565
|
+
'Failed to read the revision field in your pom file properties - is it present?';
|
|
1566
|
+
verifyLogPrinted({ consoleInfoSpy: consoleErrorSpy, expectedLog });
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1569
|
+
it('throws error in multi-module Maven `pom.xml` file when associated property is missing', async function () {
|
|
1570
|
+
const filename = 'pom.xml';
|
|
1571
|
+
mock({
|
|
1572
|
+
bump: 'minor',
|
|
1573
|
+
realTestFiles: [
|
|
1574
|
+
{
|
|
1575
|
+
filename,
|
|
1576
|
+
path: './test/mocks/pom-6.3.1-mm-missing-revision.xml',
|
|
1577
|
+
},
|
|
1578
|
+
],
|
|
1579
|
+
});
|
|
1580
|
+
await exec({
|
|
1581
|
+
packageFiles: [{ filename, type: 'maven' }],
|
|
1582
|
+
bumpFiles: [{ filename, type: 'maven' }],
|
|
1583
|
+
});
|
|
1584
|
+
const expectedLog =
|
|
1585
|
+
'Failed to read the revision field in your pom file properties - is it present?';
|
|
1586
|
+
verifyLogPrinted({ consoleInfoSpy: consoleErrorSpy, expectedLog });
|
|
1587
|
+
});
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1494
1590
|
it('bumps version in Gradle `build.gradle.kts` file', async function () {
|
|
1495
1591
|
const expected = fs.readFileSync(
|
|
1496
1592
|
'./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
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { writeVersion as writeOpenApiVersion } from '../lib/updaters/types/openapi.js';
|
|
2
|
+
import { writeVersion as writeYamlVersion } from '../lib/updaters/types/yaml.js';
|
|
3
|
+
|
|
4
|
+
const description = 'word '.repeat(30).trim();
|
|
5
|
+
|
|
6
|
+
describe('YAML updaters', function () {
|
|
7
|
+
it('does not wrap long lines in YAML files', function () {
|
|
8
|
+
const contents = `version: 1.2.3\ndescription: ${description}\n`;
|
|
9
|
+
const expected = `version: 1.3.0\ndescription: ${description}\n`;
|
|
10
|
+
|
|
11
|
+
expect(writeYamlVersion(contents, '1.3.0')).toEqual(expected);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('does not wrap long lines in OpenAPI files', function () {
|
|
15
|
+
const contents = `openapi: 3.0.3\ninfo:\n title: Example\n version: 1.2.3\n description: ${description}\npaths: {}\n`;
|
|
16
|
+
const expected = `openapi: 3.0.3\ninfo:\n title: Example\n version: 1.3.0\n description: ${description}\npaths: {}\n`;
|
|
17
|
+
|
|
18
|
+
expect(writeOpenApiVersion(contents, '1.3.0')).toEqual(expected);
|
|
19
|
+
});
|
|
20
|
+
});
|