commit-and-tag-version 13.1.0 → 13.1.2
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 +14 -0
- package/README.md +22 -0
- package/lib/lifecycles/bump.js +4 -0
- package/lib/lifecycles/changelog.js +15 -2
- package/lib/updaters/types/openapi.js +1 -1
- package/lib/updaters/types/yaml.js +1 -1
- package/package.json +3 -3
- package/test/prerelease-window.integration-test.js +137 -0
- package/test/yaml-updaters.spec.js +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.1.2](https://github.com/absolute-version/commit-and-tag-version/compare/v13.1.1...v13.1.2) (2026-07-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **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))
|
|
11
|
+
|
|
12
|
+
## [13.1.1](https://github.com/absolute-version/commit-and-tag-version/compare/v13.1.0...v13.1.1) (2026-07-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* Fix issue where prereleases were calculated from the wrong base (fixes [#310](https://github.com/absolute-version/commit-and-tag-version/issues/310)) ([1261803](https://github.com/absolute-version/commit-and-tag-version/commit/12618033a5b1a6c8bf3fd2aa65ceb062b6180c3a))
|
|
18
|
+
|
|
5
19
|
## [13.1.0](https://github.com/absolute-version/commit-and-tag-version/compare/v13.0.0...v13.1.0) (2026-07-21)
|
|
6
20
|
|
|
7
21
|
|
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`.
|
package/lib/lifecycles/bump.js
CHANGED
|
@@ -291,6 +291,10 @@ async function bumpVersion(releaseAs, currentVersion, args) {
|
|
|
291
291
|
prefix: args.lernaPackage
|
|
292
292
|
? packagePrefix(args.lernaPackage)
|
|
293
293
|
: args.tagPrefix,
|
|
294
|
+
// Measure the recommendation from the last stable release rather than
|
|
295
|
+
// the most recent tag: commits released only in prereleases still count
|
|
296
|
+
// towards the next version (#310).
|
|
297
|
+
skipUnstable: true,
|
|
294
298
|
})
|
|
295
299
|
.commits({ path: args.path }, args.parserOpts);
|
|
296
300
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { ConventionalChangelog } from 'conventional-changelog';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
+
import semver from 'semver';
|
|
4
5
|
import checkpoint from '../checkpoint.js';
|
|
5
6
|
import presetLoader from '../preset-loader.js';
|
|
6
7
|
import runLifecycleScript from '../run-lifecycle-script.js';
|
|
@@ -57,7 +58,10 @@ async function outputChangelog(args, newVersion) {
|
|
|
57
58
|
const generator = new ConventionalChangelog()
|
|
58
59
|
.readPackage()
|
|
59
60
|
.loadPreset(presetLoader(args))
|
|
60
|
-
|
|
61
|
+
// skipUnstable keeps the changelog window aligned with the bump logic:
|
|
62
|
+
// both cover all commits since the last stable release, so changes that
|
|
63
|
+
// only appeared in prereleases are not dropped from the release (#310).
|
|
64
|
+
.tags({ prefix: args.tagPrefix, skipUnstable: true })
|
|
61
65
|
.options({
|
|
62
66
|
releaseCount: args.releaseCount,
|
|
63
67
|
...(args.verbose
|
|
@@ -68,7 +72,16 @@ async function outputChangelog(args, newVersion) {
|
|
|
68
72
|
})
|
|
69
73
|
.context({ version: newVersion })
|
|
70
74
|
.commits({ merges: null, path: args.path }, args.parserOpts)
|
|
71
|
-
.writer(
|
|
75
|
+
.writer({
|
|
76
|
+
// Split sections at stable release tags only, so commits already
|
|
77
|
+
// released in intermediate prereleases stay in this release's section
|
|
78
|
+
// rather than being regenerated under the prerelease's heading (#310).
|
|
79
|
+
generateOn: (commit) =>
|
|
80
|
+
Boolean(
|
|
81
|
+
semver.valid(commit.version) && !semver.prerelease(commit.version),
|
|
82
|
+
),
|
|
83
|
+
...(args.writerOpts || {}),
|
|
84
|
+
});
|
|
72
85
|
|
|
73
86
|
let content = '';
|
|
74
87
|
for await (const chunk of generator.write()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-and-tag-version",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.2",
|
|
4
4
|
"description": "replacement for `npm version` with automatic CHANGELOG generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"figures": "^3.2.0",
|
|
60
60
|
"find-up": "^5.0.0",
|
|
61
61
|
"semver": "^7.7.2",
|
|
62
|
-
"yaml": "^2.
|
|
62
|
+
"yaml": "^2.9.0",
|
|
63
63
|
"yargs": "^17.7.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"eslint": "^9.13.0",
|
|
71
71
|
"eslint-config-prettier": "^10.1.8",
|
|
72
72
|
"eslint-plugin-import": "^2.31.0",
|
|
73
|
-
"eslint-plugin-n": "^
|
|
73
|
+
"eslint-plugin-n": "^18.2.2",
|
|
74
74
|
"eslint-plugin-promise": "^7.2.1",
|
|
75
75
|
"istanbul-lib-instrument": "^6.0.3",
|
|
76
76
|
"pirates": "^4.0.7",
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import shell from 'shelljs';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { execFileSync } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const CLI = fileURLToPath(new URL('../bin/cli.js', import.meta.url));
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Regression tests for #310: the bump recommendation and the changelog were
|
|
10
|
+
* generated from commits since the most recent tag of any kind, while the
|
|
11
|
+
* "current version" resolution ignores prereleases with other identifiers.
|
|
12
|
+
* Commits released only in a prerelease fell between the two windows and were
|
|
13
|
+
* counted by neither. These tests spawn the real CLI in a real git repository
|
|
14
|
+
* because the in-process harness mocks the git client's raw commit stream
|
|
15
|
+
* without honouring the `from` range, so it cannot observe the bug.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function setupTestDirectory() {
|
|
19
|
+
shell.rm('-rf', 'prerelease-window-temp');
|
|
20
|
+
shell.config.silent = true;
|
|
21
|
+
shell.mkdir('prerelease-window-temp');
|
|
22
|
+
shell.cd('prerelease-window-temp');
|
|
23
|
+
shell.exec('git init');
|
|
24
|
+
shell.exec('git config commit.gpgSign false');
|
|
25
|
+
shell.exec('git config core.autocrlf false');
|
|
26
|
+
shell.exec('git config user.email "test@example.com"');
|
|
27
|
+
shell.exec('git config user.name "Test"');
|
|
28
|
+
shell.exec('git commit --allow-empty -m"root-commit"');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function resetShell() {
|
|
32
|
+
shell.cd('../');
|
|
33
|
+
shell.rm('-rf', 'prerelease-window-temp');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function runCli(...args) {
|
|
37
|
+
return execFileSync(process.execPath, [CLI, ...args], {
|
|
38
|
+
encoding: 'utf-8',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function commit(message) {
|
|
43
|
+
shell.exec(`git commit --allow-empty -m"${message}"`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function tags() {
|
|
47
|
+
return shell.exec('git tag').stdout.split('\n').filter(Boolean);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Extract one release's section from CHANGELOG.md. Version headings look like
|
|
52
|
+
* `## 1.1.0 (2026-01-01)` or `# [1.1.0](compare-url) (2026-01-01)` depending
|
|
53
|
+
* on whether a repository URL is known, so match both forms and cut at the
|
|
54
|
+
* next version heading.
|
|
55
|
+
*/
|
|
56
|
+
function changelogSection(version) {
|
|
57
|
+
const changelog = fs.readFileSync('CHANGELOG.md', 'utf-8');
|
|
58
|
+
const escaped = version.replace(/[.[\]]/g, '\\$&');
|
|
59
|
+
const start = changelog.search(new RegExp(`^#+ \\[?${escaped}[\\] ]`, 'm'));
|
|
60
|
+
expect(start, `no changelog section for ${version}`).toBeGreaterThan(-1);
|
|
61
|
+
const rest = changelog.slice(start);
|
|
62
|
+
const headingEnd = rest.indexOf('\n') + 1;
|
|
63
|
+
const next = rest.slice(headingEnd).search(/^#+ \[?[0-9]/m);
|
|
64
|
+
return next === -1 ? rest : rest.slice(0, headingEnd + next);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
describe('prerelease bump and changelog windows (#310)', function () {
|
|
68
|
+
beforeEach(function () {
|
|
69
|
+
setupTestDirectory();
|
|
70
|
+
runCli('--first-release');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
afterEach(function () {
|
|
74
|
+
resetShell();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('bumps from the last stable release when switching prerelease identifiers', function () {
|
|
78
|
+
commit('feat: add feat');
|
|
79
|
+
runCli('--prerelease', 'dev');
|
|
80
|
+
expect(tags()).toContain('v1.1.0-dev.0');
|
|
81
|
+
|
|
82
|
+
commit('fix: add fix');
|
|
83
|
+
runCli('--prerelease', 'rc');
|
|
84
|
+
|
|
85
|
+
// Before the fix the feat was invisible: only the fix commit (since the
|
|
86
|
+
// dev tag) was considered, recommending a prepatch from v1.0.0.
|
|
87
|
+
expect(tags()).toContain('v1.1.0-rc.0');
|
|
88
|
+
expect(tags()).not.toContain('v1.0.1-rc.0');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('includes changes from earlier prereleases in a new prerelease changelog', function () {
|
|
92
|
+
commit('feat: add feat');
|
|
93
|
+
runCli('--prerelease', 'dev');
|
|
94
|
+
commit('fix: add fix');
|
|
95
|
+
runCli('--prerelease', 'rc');
|
|
96
|
+
|
|
97
|
+
const rcSection = changelogSection('1.1.0-rc.0');
|
|
98
|
+
expect(rcSection).toContain('add feat');
|
|
99
|
+
expect(rcSection).toContain('add fix');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('graduates a prerelease with --noBumpWhenEmptyChanges', function () {
|
|
103
|
+
commit('feat: add feat');
|
|
104
|
+
runCli('--prerelease', 'rc');
|
|
105
|
+
expect(tags()).toContain('v1.1.0-rc.0');
|
|
106
|
+
|
|
107
|
+
// Before the fix no commits were found since the rc tag, so the CLI
|
|
108
|
+
// refused to bump at all.
|
|
109
|
+
runCli('--noBumpWhenEmptyChanges');
|
|
110
|
+
expect(tags()).toContain('v1.1.0');
|
|
111
|
+
expect(changelogSection('1.1.0')).toContain('add feat');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('continues a prerelease with the same identifier', function () {
|
|
115
|
+
commit('feat: add feat');
|
|
116
|
+
runCli('--prerelease', 'dev');
|
|
117
|
+
commit('fix: add fix');
|
|
118
|
+
runCli('--prerelease', 'dev');
|
|
119
|
+
expect(tags()).toContain('v1.1.0-dev.1');
|
|
120
|
+
|
|
121
|
+
// Prerelease sections are cumulative: each one covers everything since
|
|
122
|
+
// the last stable release.
|
|
123
|
+
const devSection = changelogSection('1.1.0-dev.1');
|
|
124
|
+
expect(devSection).toContain('add feat');
|
|
125
|
+
expect(devSection).toContain('add fix');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('escalates a continued prerelease when a bigger change lands', function () {
|
|
129
|
+
commit('fix: add fix');
|
|
130
|
+
runCli('--prerelease', 'rc');
|
|
131
|
+
expect(tags()).toContain('v1.0.1-rc.0');
|
|
132
|
+
|
|
133
|
+
commit('feat: add feat');
|
|
134
|
+
runCli('--prerelease', 'rc');
|
|
135
|
+
expect(tags()).toContain('v1.1.0-rc.0');
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -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
|
+
});
|