commit-and-tag-version 13.2.2 → 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 CHANGED
@@ -2,6 +2,26 @@
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
+
18
+ ## [13.3.0](https://github.com/absolute-version/commit-and-tag-version/compare/v13.2.2...v13.3.0) (2026-10-15)
19
+
20
+
21
+ ### Features
22
+
23
+ * **template:** expose the template helpers as a subpath export ([#357](https://github.com/absolute-version/commit-and-tag-version/issues/357)) ([0990f12](https://github.com/absolute-version/commit-and-tag-version/commit/0990f126f8dd3b6fa2a08b0feabc53a44dda12a3)), closes [#323](https://github.com/absolute-version/commit-and-tag-version/issues/323)
24
+
5
25
  ## [13.2.2](https://github.com/absolute-version/commit-and-tag-version/compare/v13.2.1...v13.2.2) (2026-10-13)
6
26
 
7
27
 
package/MIGRATION.md CHANGED
@@ -82,7 +82,13 @@ export default {
82
82
 
83
83
  If you customized the main template, implement `template(context)` as well instead of continuing to use `mainTemplate`.
84
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.
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. From 13.3.0 the same helpers are re-exported as `commit-and-tag-version/template`, so a configuration file can import them without adding another dependency:
86
+
87
+ ```js
88
+ import { words } from 'commit-and-tag-version/template';
89
+ ```
90
+
91
+ If you import `@conventional-changelog/template` directly instead, declare it as a direct dependency of the user project. Strict dependency managers such as pnpm require it.
86
92
 
87
93
  ### Behaviour that is intentionally preserved
88
94
 
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,34 @@ 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
+
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:
268
+
269
+ ```js
270
+ import { words } from 'commit-and-tag-version/template';
271
+
272
+ function commitPartial(_context, commit) {
273
+ return words(commit.subject || commit.header, commit.shortHash);
274
+ }
275
+
276
+ export default { writerOpts: { commitPartial } };
277
+ ```
278
+
230
279
  ## CLI Usage
231
280
 
232
281
  > **NOTE:** To pass nested configurations to the CLI without defining them in the `package.json` use dot notation as the parameters `e.g. --skip.changelog`.
@@ -459,6 +508,8 @@ by adding the following to your package.json:
459
508
 
460
509
  To set these options via the command line, use `commit-and-tag-version --skip.changelog`
461
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
+
462
513
  ### Committing Generated Artifacts in the Release Commit
463
514
 
464
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
@@ -18,6 +18,7 @@ const defaults = {
18
18
  preset: 'conventional-changelog-conventionalcommits',
19
19
  npmPublishHint: undefined,
20
20
  config: undefined,
21
+ context: {},
21
22
  };
22
23
 
23
24
  /**
@@ -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, { getParserOpts } from '../preset-loader.js';
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) return version;
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
- const releaseAs = new semver.SemVer(args.releaseAs);
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({ path: args.path }, getParserOpts(args));
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({ merges: null, path: args.path }, getParserOpts(args))
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
@@ -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,9 +1,18 @@
1
1
  {
2
2
  "name": "commit-and-tag-version",
3
- "version": "13.2.2",
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",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./template": {
10
+ "types": "./template.d.ts",
11
+ "default": "./template.js"
12
+ },
13
+ "./package.json": "./package.json",
14
+ "./*": "./*"
15
+ },
7
16
  "bin": {
8
17
  "commit-and-tag-version": "bin/cli.js"
9
18
  },
@@ -47,16 +56,16 @@
47
56
  "homepage": "https://github.com/absolute-version/commit-and-tag-version#readme",
48
57
  "dependencies": {
49
58
  "@conventional-changelog/git-client": "3.1.0",
50
- "@conventional-changelog/template": "1.2.1",
51
- "chalk": "^6.0.0",
52
- "conventional-changelog": "8.1.0",
59
+ "@conventional-changelog/template": "1.4.0",
60
+ "chalk": "^6.0.1",
61
+ "conventional-changelog": "8.1.3",
53
62
  "conventional-changelog-config-spec": "2.1.0",
54
63
  "conventional-changelog-conventionalcommits": "10.4.0",
55
64
  "conventional-recommended-bump": "12.1.0",
56
65
  "detect-indent": "^7.0.2",
57
66
  "detect-newline": "^3.1.0",
58
67
  "dotgitignore": "^2.1.0",
59
- "fast-xml-parser": "^5.10.1",
68
+ "fast-xml-parser": "^5.11.2",
60
69
  "figures": "^6.1.0",
61
70
  "find-up": "^5.0.0",
62
71
  "semver": "^7.7.2",
@@ -73,7 +82,7 @@
73
82
  "globals": "^17.12.0",
74
83
  "istanbul-lib-instrument": "^6.0.3",
75
84
  "pirates": "^4.0.7",
76
- "prettier": "^3.9.6",
85
+ "prettier": "^3.9.10",
77
86
  "shelljs": "^0.10.0",
78
87
  "strip-ansi": "^7.2.0",
79
88
  "vitest": "^4.1.0"
package/template.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Types for the template helpers re-exported by `template.js`.
3
+ *
4
+ * @see https://conventional-changelog.js.org/template/
5
+ */
6
+ export * from '@conventional-changelog/template';
package/template.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Public re-export of the conventional-changelog template helpers, so custom
3
+ * writer render functions can import them without having to resolve
4
+ * `@conventional-changelog/template` from their own project, which strict
5
+ * package managers such as pnpm refuse to do.
6
+ *
7
+ * @see https://conventional-changelog.js.org/template/
8
+ */
9
+ export * from '@conventional-changelog/template';
@@ -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');
@@ -0,0 +1,51 @@
1
+ import path from 'path';
2
+ import { execFileSync } from 'child_process';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const PACKAGE_ROOT = path.resolve(
6
+ fileURLToPath(new URL('..', import.meta.url)),
7
+ );
8
+
9
+ /**
10
+ * These tests use a child process rather than the in-process harness: `exports`
11
+ * subpath resolution and package self-referencing are Node resolver behaviour,
12
+ * which the vitest module runner does not reproduce.
13
+ */
14
+
15
+ function resolveEntryPoints() {
16
+ const script = `
17
+ const template = await import('commit-and-tag-version/template')
18
+ const main = await import('commit-and-tag-version')
19
+ const legacy = await import('commit-and-tag-version/defaults.js')
20
+ console.log(JSON.stringify({
21
+ words: typeof template.words,
22
+ template: typeof template.template,
23
+ main: typeof main.default,
24
+ legacy: typeof legacy.default,
25
+ }))
26
+ `;
27
+
28
+ const output = execFileSync(
29
+ process.execPath,
30
+ ['--input-type=module', '-e', script],
31
+ { cwd: PACKAGE_ROOT, encoding: 'utf-8' },
32
+ );
33
+
34
+ return JSON.parse(output.trim());
35
+ }
36
+
37
+ describe('package exports', function () {
38
+ it('exposes the template helpers as a subpath export', function () {
39
+ expect(resolveEntryPoints()).toMatchObject({
40
+ words: 'function',
41
+ template: 'function',
42
+ });
43
+ });
44
+
45
+ it('keeps the entry points that existed before `exports`', function () {
46
+ expect(resolveEntryPoints()).toMatchObject({
47
+ main: 'function',
48
+ legacy: 'object',
49
+ });
50
+ });
51
+ });
@@ -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
+ });
package/vitest.config.js CHANGED
@@ -14,6 +14,7 @@ export default defineConfig({
14
14
  'test/**',
15
15
  'coverage/**',
16
16
  'bin/**',
17
+ '**/*.d.ts',
17
18
  ],
18
19
  reporter: ['lcov', 'text'],
19
20
  },