calver-bump 0.1.2 → 0.1.3
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/README.md +3 -3
- package/package.json +1 -1
- package/src/index.js +6 -9
- package/test/release.test.js +25 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Example:
|
|
|
18
18
|
|
|
19
19
|
1. Bumps `package.json` to the next CalVer version.
|
|
20
20
|
2. Updates `package-lock.json` or `npm-shrinkwrap.json` when present.
|
|
21
|
-
3. Creates or prepends a `CHANGELOG.md` entry from conventional commits since the
|
|
21
|
+
3. Creates or prepends a `CHANGELOG.md` entry from conventional commits since the nearest reachable tag.
|
|
22
22
|
4. Creates a release commit.
|
|
23
23
|
5. Creates an annotated git tag.
|
|
24
24
|
|
|
@@ -95,11 +95,11 @@ Project defaults can be stored in `.calverbumprc.json`:
|
|
|
95
95
|
- The optional `compact` format is `YYMMDD` for the first release of the day, then `YYMMDD.1`, `YYMMDD.2`, etc.
|
|
96
96
|
- The optional `long` format is `YYYY.MM.DD` for the first release of the day, then `YYYY.MM.DD.1`, `YYYY.MM.DD.2`, etc.
|
|
97
97
|
- Existing `v`-prefixed tags are considered when calculating the next sequence number.
|
|
98
|
-
- Changelog ranges start from the
|
|
98
|
+
- Changelog ranges start from the nearest reachable tag, even when it is not a CalVer tag.
|
|
99
99
|
- Changelog entries include conventional commit subjects only, such as `feat:`, `fix(scope):`, or `chore!:`.
|
|
100
100
|
- Changelog entries are grouped into `Features`, `Fixes`, and `Other Changes`.
|
|
101
101
|
- Changelog entries link to their commit hash for GitHub and GitLab-style `origin` remotes.
|
|
102
|
-
- Later releases prepend only commits since the previous reachable tag.
|
|
102
|
+
- Later releases prepend only commits since the previous nearest reachable tag.
|
|
103
103
|
- Release tags are annotated so `git push --follow-tags <remote> <branch>` pushes them.
|
|
104
104
|
- The working tree must be clean before creating a real release.
|
|
105
105
|
- If tag creation fails after the release commit, the CLI rolls back its own release commit.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -237,15 +237,12 @@ function parseGitRemote(remote) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
async function latestReachableTag(cwd) {
|
|
240
|
-
|
|
241
|
-
'
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
'refs/tags',
|
|
247
|
-
]);
|
|
248
|
-
return tags[0] ?? null;
|
|
240
|
+
try {
|
|
241
|
+
const { stdout } = await git(cwd, ['describe', '--tags', '--abbrev=0']);
|
|
242
|
+
return stdout.trim() || null;
|
|
243
|
+
} catch {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
249
246
|
}
|
|
250
247
|
|
|
251
248
|
async function currentBranch(cwd) {
|
package/test/release.test.js
CHANGED
|
@@ -104,7 +104,7 @@ test('runRelease updates package-lock.json when it exists', async () => {
|
|
|
104
104
|
assert.equal(lock.packages[''].version, '26.0529');
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
test('runRelease uses the
|
|
107
|
+
test('runRelease uses the nearest reachable tag as the changelog base', async () => {
|
|
108
108
|
const repo = await makeRepo();
|
|
109
109
|
execFileSync('git', ['tag', '26.0528.1'], { cwd: repo });
|
|
110
110
|
await writeFile(path.join(repo, 'feature-a.txt'), 'a\n');
|
|
@@ -122,7 +122,7 @@ test('runRelease uses the latest reachable tag as the changelog base', async ()
|
|
|
122
122
|
|
|
123
123
|
const changelog = await readFile(path.join(repo, 'CHANGELOG.md'), 'utf8');
|
|
124
124
|
assert.match(changelog, /- fix: after non-release tag/);
|
|
125
|
-
assert.
|
|
125
|
+
assert.doesNotMatch(changelog, /- feat: after calver tag/);
|
|
126
126
|
assert.doesNotMatch(changelog, /- feat: initial app/);
|
|
127
127
|
});
|
|
128
128
|
|
|
@@ -265,6 +265,29 @@ test('runRelease uses the latest reachable tag as the changelog base even when i
|
|
|
265
265
|
assert.doesNotMatch(changelog, /- feat: initial app/);
|
|
266
266
|
});
|
|
267
267
|
|
|
268
|
+
test('runRelease uses the nearest history tag, not the newest-created reachable tag, as the changelog base', async () => {
|
|
269
|
+
const repo = await makeRepo();
|
|
270
|
+
execFileSync('git', ['tag', 'old-tag'], { cwd: repo });
|
|
271
|
+
await writeFile(path.join(repo, 'first.txt'), 'first\n');
|
|
272
|
+
execFileSync('git', ['add', 'first.txt'], { cwd: repo });
|
|
273
|
+
execFileSync('git', ['commit', '-m', 'feat: already released'], { cwd: repo });
|
|
274
|
+
execFileSync('git', ['tag', 'v1.35.0'], { cwd: repo });
|
|
275
|
+
execFileSync('git', ['tag', '-f', 'newer-created-old-tag', 'old-tag'], { cwd: repo });
|
|
276
|
+
await writeFile(path.join(repo, 'second.txt'), 'second\n');
|
|
277
|
+
execFileSync('git', ['add', 'second.txt'], { cwd: repo });
|
|
278
|
+
execFileSync('git', ['commit', '-m', 'fix: unreleased change'], { cwd: repo });
|
|
279
|
+
|
|
280
|
+
await runRelease({
|
|
281
|
+
cwd: repo,
|
|
282
|
+
date: new Date('2026-05-29T12:00:00-07:00'),
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
const changelog = await readFile(path.join(repo, 'CHANGELOG.md'), 'utf8');
|
|
286
|
+
assert.match(changelog, /- fix: unreleased change/);
|
|
287
|
+
assert.doesNotMatch(changelog, /feat: already released/);
|
|
288
|
+
assert.doesNotMatch(changelog, /feat: initial app/);
|
|
289
|
+
});
|
|
290
|
+
|
|
268
291
|
test('runRelease rolls back its release commit when tag creation fails', async () => {
|
|
269
292
|
const repo = await makeRepo();
|
|
270
293
|
execFileSync('git', ['tag', '26.0529'], { cwd: repo });
|