commit-and-tag-version 13.2.2 → 13.3.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,13 @@
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.3.0](https://github.com/absolute-version/commit-and-tag-version/compare/v13.2.2...v13.3.0) (2026-10-15)
6
+
7
+
8
+ ### Features
9
+
10
+ * **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)
11
+
5
12
  ## [13.2.2](https://github.com/absolute-version/commit-and-tag-version/compare/v13.2.1...v13.2.2) (2026-10-13)
6
13
 
7
14
 
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
@@ -227,6 +227,18 @@ You can override both [parser](https://github.com/conventional-changelog/convent
227
227
 
228
228
  `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
229
 
230
+ 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:
231
+
232
+ ```js
233
+ import { words } from 'commit-and-tag-version/template';
234
+
235
+ function commitPartial(_context, commit) {
236
+ return words(commit.subject || commit.header, commit.shortHash);
237
+ }
238
+
239
+ export default { writerOpts: { commitPartial } };
240
+ ```
241
+
230
242
  ## CLI Usage
231
243
 
232
244
  > **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`.
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.3.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,8 +56,8 @@
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",
59
+ "@conventional-changelog/template": "1.4.0",
60
+ "chalk": "^6.0.1",
52
61
  "conventional-changelog": "8.1.0",
53
62
  "conventional-changelog-config-spec": "2.1.0",
54
63
  "conventional-changelog-conventionalcommits": "10.4.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,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
+ });
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
  },