@hugojosefson/cli 0.11.0 → 0.12.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.
Files changed (207) hide show
  1. package/esm/deno.js +16 -8
  2. package/esm/node_modules/@conventional-changelog/template/LICENSE.md +21 -0
  3. package/esm/node_modules/@conventional-changelog/template/README.md +66 -0
  4. package/esm/node_modules/@conventional-changelog/template/dist/elements.d.ts +78 -0
  5. package/esm/node_modules/@conventional-changelog/template/dist/elements.d.ts.map +1 -0
  6. package/esm/node_modules/@conventional-changelog/template/dist/elements.js +132 -0
  7. package/esm/node_modules/@conventional-changelog/template/dist/index.d.ts +6 -0
  8. package/esm/node_modules/@conventional-changelog/template/dist/index.d.ts.map +1 -0
  9. package/esm/node_modules/@conventional-changelog/template/dist/index.js +5 -0
  10. package/esm/node_modules/@conventional-changelog/template/dist/legacy.d.ts +20 -0
  11. package/esm/node_modules/@conventional-changelog/template/dist/legacy.d.ts.map +1 -0
  12. package/esm/node_modules/@conventional-changelog/template/dist/legacy.js +22 -0
  13. package/esm/node_modules/@conventional-changelog/template/dist/references.d.ts +43 -0
  14. package/esm/node_modules/@conventional-changelog/template/dist/references.d.ts.map +1 -0
  15. package/esm/node_modules/@conventional-changelog/template/dist/references.js +82 -0
  16. package/esm/node_modules/@conventional-changelog/template/dist/templates.d.ts +74 -0
  17. package/esm/node_modules/@conventional-changelog/template/dist/templates.d.ts.map +1 -0
  18. package/esm/node_modules/@conventional-changelog/template/dist/templates.js +125 -0
  19. package/esm/node_modules/@conventional-changelog/template/dist/types/commit.d.ts +37 -0
  20. package/esm/node_modules/@conventional-changelog/template/dist/types/commit.d.ts.map +1 -0
  21. package/esm/node_modules/@conventional-changelog/template/dist/types/commit.js +2 -0
  22. package/esm/node_modules/@conventional-changelog/template/dist/types/context.d.ts +113 -0
  23. package/esm/node_modules/@conventional-changelog/template/dist/types/context.d.ts.map +1 -0
  24. package/esm/node_modules/@conventional-changelog/template/dist/types/context.js +2 -0
  25. package/esm/node_modules/@conventional-changelog/template/dist/types/index.d.ts +4 -0
  26. package/esm/node_modules/@conventional-changelog/template/dist/types/index.d.ts.map +1 -0
  27. package/esm/node_modules/@conventional-changelog/template/dist/types/index.js +2 -0
  28. package/esm/node_modules/@conventional-changelog/template/dist/types/utils.d.ts +2 -0
  29. package/esm/node_modules/@conventional-changelog/template/dist/types/utils.d.ts.map +1 -0
  30. package/esm/node_modules/@conventional-changelog/template/dist/types/utils.js +2 -0
  31. package/esm/node_modules/@conventional-changelog/template/package.json +38 -0
  32. package/esm/node_modules/@simple-libs/stream-utils/LICENSE +21 -0
  33. package/esm/node_modules/@simple-libs/stream-utils/README.md +79 -0
  34. package/esm/node_modules/@simple-libs/stream-utils/dist/index.d.ts +51 -0
  35. package/esm/node_modules/@simple-libs/stream-utils/dist/index.d.ts.map +1 -0
  36. package/esm/node_modules/@simple-libs/stream-utils/dist/index.js +116 -0
  37. package/esm/node_modules/@simple-libs/stream-utils/package.json +38 -0
  38. package/esm/node_modules/argue-cli/LICENSE +21 -0
  39. package/esm/node_modules/argue-cli/README.md +239 -0
  40. package/esm/node_modules/argue-cli/dist/args.d.ts +30 -0
  41. package/esm/node_modules/argue-cli/dist/args.d.ts.map +1 -0
  42. package/esm/node_modules/argue-cli/dist/argv.d.ts +14 -0
  43. package/esm/node_modules/argue-cli/dist/argv.d.ts.map +1 -0
  44. package/esm/node_modules/argue-cli/dist/core.d.ts +24 -0
  45. package/esm/node_modules/argue-cli/dist/core.d.ts.map +1 -0
  46. package/esm/node_modules/argue-cli/dist/index.d.ts +6 -0
  47. package/esm/node_modules/argue-cli/dist/index.d.ts.map +1 -0
  48. package/esm/node_modules/argue-cli/dist/index.js +254 -0
  49. package/esm/node_modules/argue-cli/dist/index.js.map +1 -0
  50. package/esm/node_modules/argue-cli/dist/options.d.ts +9 -0
  51. package/esm/node_modules/argue-cli/dist/options.d.ts.map +1 -0
  52. package/esm/node_modules/argue-cli/dist/types.d.ts +16 -0
  53. package/esm/node_modules/argue-cli/dist/types.d.ts.map +1 -0
  54. package/esm/node_modules/argue-cli/dist/utils.d.ts +24 -0
  55. package/esm/node_modules/argue-cli/dist/utils.d.ts.map +1 -0
  56. package/esm/node_modules/argue-cli/package.json +34 -0
  57. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-changelog-writer/LICENSE.md +21 -0
  58. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-changelog-writer/README.md +369 -0
  59. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-changelog-writer/package.json +53 -0
  60. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-filter/LICENSE +21 -0
  61. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-filter/README.md +184 -0
  62. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-filter/package.json +31 -0
  63. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-parser/LICENSE.md +21 -0
  64. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-parser/README.md +383 -0
  65. package/esm/node_modules/conventional-changelog-core/node_modules/conventional-commits-parser/package.json +47 -0
  66. package/esm/node_modules/conventional-changelog-writer/README.md +49 -342
  67. package/esm/node_modules/conventional-changelog-writer/dist/cli/index.d.ts +3 -0
  68. package/esm/node_modules/conventional-changelog-writer/dist/cli/index.d.ts.map +1 -0
  69. package/esm/node_modules/conventional-changelog-writer/dist/cli/index.js +68 -0
  70. package/esm/node_modules/conventional-changelog-writer/dist/cli/utils.d.ts +4 -0
  71. package/esm/node_modules/conventional-changelog-writer/dist/cli/utils.d.ts.map +1 -0
  72. package/esm/node_modules/conventional-changelog-writer/dist/cli/utils.js +39 -0
  73. package/esm/node_modules/conventional-changelog-writer/dist/commit.d.ts +10 -0
  74. package/esm/node_modules/conventional-changelog-writer/dist/commit.d.ts.map +1 -0
  75. package/esm/node_modules/conventional-changelog-writer/dist/commit.js +43 -0
  76. package/esm/node_modules/conventional-changelog-writer/dist/context.d.ts +27 -0
  77. package/esm/node_modules/conventional-changelog-writer/dist/context.d.ts.map +1 -0
  78. package/esm/node_modules/conventional-changelog-writer/dist/context.js +134 -0
  79. package/esm/node_modules/conventional-changelog-writer/dist/index.d.ts +7 -0
  80. package/esm/node_modules/conventional-changelog-writer/dist/index.d.ts.map +1 -0
  81. package/esm/node_modules/conventional-changelog-writer/dist/index.js +6 -0
  82. package/esm/node_modules/conventional-changelog-writer/dist/options.d.ts +25 -0
  83. package/esm/node_modules/conventional-changelog-writer/dist/options.d.ts.map +1 -0
  84. package/esm/node_modules/conventional-changelog-writer/dist/options.js +79 -0
  85. package/esm/node_modules/conventional-changelog-writer/dist/template.d.ts +10 -0
  86. package/esm/node_modules/conventional-changelog-writer/dist/template.d.ts.map +1 -0
  87. package/esm/node_modules/conventional-changelog-writer/dist/template.js +18 -0
  88. package/esm/node_modules/conventional-changelog-writer/dist/types/index.d.ts +8 -0
  89. package/esm/node_modules/conventional-changelog-writer/dist/types/index.d.ts.map +1 -0
  90. package/esm/node_modules/conventional-changelog-writer/dist/types/index.js +2 -0
  91. package/esm/node_modules/conventional-changelog-writer/dist/types/options.d.ts +122 -0
  92. package/esm/node_modules/conventional-changelog-writer/dist/types/options.d.ts.map +1 -0
  93. package/esm/node_modules/conventional-changelog-writer/dist/types/options.js +2 -0
  94. package/esm/node_modules/conventional-changelog-writer/dist/types/utils.d.ts +9 -0
  95. package/esm/node_modules/conventional-changelog-writer/dist/types/utils.d.ts.map +1 -0
  96. package/esm/node_modules/conventional-changelog-writer/dist/types/utils.js +2 -0
  97. package/esm/node_modules/conventional-changelog-writer/dist/utils.d.ts +20 -0
  98. package/esm/node_modules/conventional-changelog-writer/dist/utils.d.ts.map +1 -0
  99. package/esm/node_modules/conventional-changelog-writer/dist/utils.js +70 -0
  100. package/esm/node_modules/conventional-changelog-writer/dist/writers.d.ts +29 -0
  101. package/esm/node_modules/conventional-changelog-writer/dist/writers.d.ts.map +1 -0
  102. package/esm/node_modules/conventional-changelog-writer/dist/writers.js +94 -0
  103. package/esm/node_modules/conventional-changelog-writer/package.json +24 -26
  104. package/esm/node_modules/conventional-commits-filter/README.md +51 -170
  105. package/esm/node_modules/conventional-commits-filter/dist/RevertedCommitsFilter.d.ts +17 -0
  106. package/esm/node_modules/conventional-commits-filter/dist/RevertedCommitsFilter.d.ts.map +1 -0
  107. package/esm/node_modules/conventional-commits-filter/dist/RevertedCommitsFilter.js +46 -0
  108. package/esm/node_modules/conventional-commits-filter/dist/filters.d.ts +19 -0
  109. package/esm/node_modules/conventional-commits-filter/dist/filters.d.ts.map +1 -0
  110. package/esm/node_modules/conventional-commits-filter/dist/filters.js +34 -0
  111. package/esm/node_modules/conventional-commits-filter/dist/index.d.ts +4 -0
  112. package/esm/node_modules/conventional-commits-filter/dist/index.d.ts.map +1 -0
  113. package/esm/node_modules/conventional-commits-filter/dist/index.js +3 -0
  114. package/esm/node_modules/conventional-commits-filter/dist/types.d.ts +6 -0
  115. package/esm/node_modules/conventional-commits-filter/dist/types.d.ts.map +1 -0
  116. package/esm/node_modules/conventional-commits-filter/dist/types.js +2 -0
  117. package/esm/node_modules/conventional-commits-filter/dist/utils.d.ts +16 -0
  118. package/esm/node_modules/conventional-commits-filter/dist/utils.d.ts.map +1 -0
  119. package/esm/node_modules/conventional-commits-filter/dist/utils.js +43 -0
  120. package/esm/node_modules/conventional-commits-filter/package.json +22 -16
  121. package/esm/node_modules/conventional-commits-parser/README.md +49 -353
  122. package/esm/node_modules/conventional-commits-parser/dist/CommitParser.d.ts +40 -0
  123. package/esm/node_modules/conventional-commits-parser/dist/CommitParser.d.ts.map +1 -0
  124. package/esm/node_modules/conventional-commits-parser/dist/CommitParser.js +319 -0
  125. package/esm/node_modules/conventional-commits-parser/dist/cli/index.d.ts +3 -0
  126. package/esm/node_modules/conventional-commits-parser/dist/cli/index.d.ts.map +1 -0
  127. package/esm/node_modules/conventional-commits-parser/dist/cli/index.js +67 -0
  128. package/esm/node_modules/conventional-commits-parser/dist/cli/options.d.ts +3 -0
  129. package/esm/node_modules/conventional-commits-parser/dist/cli/options.d.ts.map +1 -0
  130. package/esm/node_modules/conventional-commits-parser/dist/cli/options.js +40 -0
  131. package/esm/node_modules/conventional-commits-parser/dist/cli/utils.d.ts +5 -0
  132. package/esm/node_modules/conventional-commits-parser/dist/cli/utils.d.ts.map +1 -0
  133. package/esm/node_modules/conventional-commits-parser/dist/cli/utils.js +49 -0
  134. package/esm/node_modules/conventional-commits-parser/dist/index.d.ts +4 -0
  135. package/esm/node_modules/conventional-commits-parser/dist/index.d.ts.map +1 -0
  136. package/esm/node_modules/conventional-commits-parser/dist/index.js +3 -0
  137. package/esm/node_modules/conventional-commits-parser/dist/options.d.ts +3 -0
  138. package/esm/node_modules/conventional-commits-parser/dist/options.d.ts.map +1 -0
  139. package/esm/node_modules/conventional-commits-parser/dist/options.js +27 -0
  140. package/esm/node_modules/conventional-commits-parser/dist/regex.d.ts +8 -0
  141. package/esm/node_modules/conventional-commits-parser/dist/regex.d.ts.map +1 -0
  142. package/esm/node_modules/conventional-commits-parser/dist/regex.js +63 -0
  143. package/esm/node_modules/conventional-commits-parser/dist/stream.d.ts +14 -0
  144. package/esm/node_modules/conventional-commits-parser/dist/stream.d.ts.map +1 -0
  145. package/esm/node_modules/conventional-commits-parser/dist/stream.js +38 -0
  146. package/esm/node_modules/conventional-commits-parser/dist/types.d.ts +100 -0
  147. package/esm/node_modules/conventional-commits-parser/dist/types.d.ts.map +1 -0
  148. package/esm/node_modules/conventional-commits-parser/dist/types.js +2 -0
  149. package/esm/node_modules/conventional-commits-parser/dist/utils.d.ts +41 -0
  150. package/esm/node_modules/conventional-commits-parser/dist/utils.d.ts.map +1 -0
  151. package/esm/node_modules/conventional-commits-parser/dist/utils.js +75 -0
  152. package/esm/node_modules/conventional-commits-parser/package.json +22 -23
  153. package/esm/src/cli/command-help.js +15 -0
  154. package/esm/src/cli/repair-configuration-description.js +98 -0
  155. package/esm/src/cli/run-changelog.js +51 -0
  156. package/esm/src/cli/run-cli.js +8 -0
  157. package/esm/src/features/built-in-feature-registry.js +2 -0
  158. package/esm/src/features/changelog-feature.js +155 -0
  159. package/esm/src/features/github-ci-artifacts.js +17 -3
  160. package/esm/src/features/github-ci-runtime-matrix.js +50 -0
  161. package/esm/src/features/github-release-publish-artifacts.js +5 -4
  162. package/esm/src/features/github-release-publish-feature.js +4 -0
  163. package/esm/src/features/github-workflow-cache.js +18 -0
  164. package/esm/src/features/workflow-deno.js +1 -1
  165. package/esm/src/release/changelog-markdown.js +41 -0
  166. package/esm/src/release/changelog.js +155 -7
  167. package/esm/src/release/format-changelog.js +15 -0
  168. package/esm/src/release/migrate-changelog.js +92 -0
  169. package/esm/src/release/publish-github.js +7 -3
  170. package/esm/src/release/publish-tag-prepare.js +63 -78
  171. package/esm/src/release/release-history.js +53 -0
  172. package/npm-dependencies.lock.json +115 -48
  173. package/package.json +5 -3
  174. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/dependencies.js +0 -11036
  175. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/index.d.ts +0 -1416
  176. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/index.js +0 -100
  177. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/licenses.md +0 -1767
  178. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/options.js +0 -92
  179. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/parser.js +0 -84
  180. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/utils.js +0 -7
  181. package/esm/node_modules/conventional-commits-parser/node_modules/meow/build/validate.js +0 -122
  182. package/esm/node_modules/conventional-commits-parser/node_modules/meow/license +0 -9
  183. package/esm/node_modules/conventional-commits-parser/node_modules/meow/package.json +0 -107
  184. package/esm/node_modules/conventional-commits-parser/node_modules/meow/readme.md +0 -314
  185. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/cli.mjs +0 -0
  186. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/index.js +0 -0
  187. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/lib/util.js +0 -0
  188. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/templates/commit.hbs +0 -0
  189. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/templates/footer.hbs +0 -0
  190. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/templates/header.hbs +0 -0
  191. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core/node_modules/conventional-changelog-writer}/templates/template.hbs +0 -0
  192. /package/esm/node_modules/{conventional-commits-filter → conventional-changelog-core/node_modules/conventional-commits-filter}/index.js +0 -0
  193. /package/esm/node_modules/{conventional-commits-parser → conventional-changelog-core/node_modules/conventional-commits-parser}/cli.mjs +0 -0
  194. /package/esm/node_modules/{conventional-commits-parser → conventional-changelog-core/node_modules/conventional-commits-parser}/index.js +0 -0
  195. /package/esm/node_modules/{conventional-commits-parser → conventional-changelog-core/node_modules/conventional-commits-parser}/lib/parser.js +0 -0
  196. /package/esm/node_modules/{conventional-commits-parser → conventional-changelog-core/node_modules/conventional-commits-parser}/lib/regex.js +0 -0
  197. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/dependencies.js +0 -0
  198. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/index.d.ts +0 -0
  199. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/index.js +0 -0
  200. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/licenses.md +0 -0
  201. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/options.js +0 -0
  202. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/parser.js +0 -0
  203. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/utils.js +0 -0
  204. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/build/validate.js +0 -0
  205. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/license +0 -0
  206. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/package.json +0 -0
  207. /package/esm/node_modules/{conventional-changelog-writer → conventional-changelog-core}/node_modules/meow/readme.md +0 -0
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "@hugojosefson/cli",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "license": "MIT",
5
5
  "hj": {
6
6
  "commandName": "hj"
@@ -33,6 +33,8 @@ export default {
33
33
  "imports": {
34
34
  "@std/assert": "jsr:@std/assert@^1.0.19",
35
35
  "@std/path": "jsr:@std/path@^1.1.6",
36
+ "conventional-changelog-writer": "npm:conventional-changelog-writer@9.2.1",
37
+ "conventional-commits-parser": "npm:conventional-commits-parser@7.1.2",
36
38
  "fork-version": "npm:fork-version@5.2.0",
37
39
  "jsonc-parser": "npm:jsonc-parser@3.3.1",
38
40
  "yaml": "npm:yaml@2.8.3",
@@ -106,13 +108,7 @@ export default {
106
108
  "ci": {
107
109
  "description": "Run validation and coverage once",
108
110
  "dependencies": [
109
- "format",
110
- "lint",
111
- "typecheck",
112
- "coverage",
113
- "diff-check",
114
- "publish-check",
115
- "readme-check",
111
+ "ci-deno",
116
112
  "native-tests"
117
113
  ]
118
114
  },
@@ -162,6 +158,18 @@ export default {
162
158
  "test-matrix": {
163
159
  "description": "Run every test in Deno, Node 24/26 and Bun",
164
160
  "command": "deno run --allow-all scripts/run-test-matrix.ts"
161
+ },
162
+ "ci-deno": {
163
+ "description": "Run Deno coverage and all non-native checks for the parallel CI job",
164
+ "dependencies": [
165
+ "format",
166
+ "lint",
167
+ "typecheck",
168
+ "coverage",
169
+ "diff-check",
170
+ "publish-check",
171
+ "readme-check"
172
+ ]
165
173
  }
166
174
  },
167
175
  "coverage": {
@@ -0,0 +1,21 @@
1
+ ### MIT License
2
+
3
+ Copyright © [conventional-changelog team](https://github.com/conventional-changelog)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,66 @@
1
+ # @conventional-changelog/template
2
+
3
+ [![ESM-only package][package]][package-url]
4
+ [![NPM version][npm]][npm-url]
5
+ [![Node version][node]][node-url]
6
+ [![Dependencies status][deps]][deps-url]
7
+ [![Install size][size]][size-url]
8
+ [![Build status][build]][build-url]
9
+ [![Coverage status][coverage]][coverage-url]
10
+
11
+ [package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
12
+ [package-url]: https://nodejs.org/api/esm.html
13
+
14
+ [npm]: https://img.shields.io/npm/v/@conventional-changelog/template.svg
15
+ [npm-url]: https://npmjs.com/package/@conventional-changelog/template
16
+
17
+ [node]: https://img.shields.io/node/v/@conventional-changelog/template.svg
18
+ [node-url]: https://nodejs.org
19
+
20
+ [deps]: https://img.shields.io/librariesio/release/npm/@conventional-changelog/template
21
+ [deps-url]: https://libraries.io/npm/@conventional-changelog%2Ftemplate
22
+
23
+ [size]: https://packagephobia.com/badge?p=@conventional-changelog/template
24
+ [size-url]: https://packagephobia.com/result?p=@conventional-changelog/template
25
+
26
+ [build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/tests.yaml?branch=master
27
+ [build-url]: https://github.com/conventional-changelog/conventional-changelog/actions
28
+
29
+ [coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
30
+ [coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
31
+
32
+ Template utilities for conventional changelog generation.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ # pnpm
38
+ pnpm add @conventional-changelog/template
39
+ # yarn
40
+ yarn add @conventional-changelog/template
41
+ # npm
42
+ npm i @conventional-changelog/template
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ ```js
48
+ import {
49
+ heading,
50
+ link,
51
+ list,
52
+ url
53
+ } from '@conventional-changelog/template'
54
+
55
+ console.log(heading(2, 'Features')) // ## Features
56
+ console.log(link('commit', url('https://github.com/example/repo', 'commit', 'abc123')))
57
+ console.log(list(['a', 'b'], item => item))
58
+ ```
59
+
60
+ ## Documentation
61
+
62
+ For the API reference, visit the [documentation website](https://conventional-changelog.js.org/template/).
63
+
64
+ ## License
65
+
66
+ MIT © [Dan Onoshko](https://github.com/dangreen)
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Renders an array into newline-separated non-empty strings.
3
+ * @param array - Items to render.
4
+ * @param callback - Item renderer.
5
+ * @param separator - Separator inserted between rendered items.
6
+ * @returns Rendered string.
7
+ */
8
+ export declare function each<T>(array: T[] | null | undefined | false, callback: (item: T) => string | number | null | undefined | false, separator?: string): string;
9
+ /**
10
+ * Renders a Markdown heading.
11
+ * @param level - Markdown heading level.
12
+ * @param text - Heading text.
13
+ * @returns Markdown heading.
14
+ */
15
+ export declare function heading(level: number, text: string): string;
16
+ /**
17
+ * Renders a Markdown link.
18
+ * @param text - Link text.
19
+ * @param url - Link URL.
20
+ * @returns Markdown link.
21
+ */
22
+ export declare function link(text: string, url: string): string;
23
+ /**
24
+ * Renders an array into a Markdown unordered list.
25
+ * @param array - Items to render.
26
+ * @param callback - Item renderer.
27
+ * @returns Markdown unordered list.
28
+ */
29
+ export declare function list<T>(array: T[] | null | undefined | false, callback: (item: T) => string | null | undefined | false): string;
30
+ /**
31
+ * Renders bold Markdown text.
32
+ * @param text - Text to render.
33
+ * @returns Bold Markdown text.
34
+ */
35
+ export declare function bold(text: string): string;
36
+ /**
37
+ * Renders italic Markdown text.
38
+ * @param text - Text to render.
39
+ * @returns Italic Markdown text.
40
+ */
41
+ export declare function italic(text: string): string;
42
+ /**
43
+ * Renders text inside an HTML small element.
44
+ * @param text - Text to render.
45
+ * @returns HTML small element.
46
+ */
47
+ export declare function small(text: string): string;
48
+ /**
49
+ * Creates one or more newline characters.
50
+ * @param times - Number of newline characters to render.
51
+ * @returns Newline characters.
52
+ */
53
+ export declare function newline(times?: number): string;
54
+ /**
55
+ * Renders values without separators.
56
+ * @param values - Values to render.
57
+ * @returns Concatenated non-empty values.
58
+ */
59
+ export declare function strings(...values: (string | number | null | undefined | false)[]): string;
60
+ /**
61
+ * Renders values as Markdown blocks separated by blank lines.
62
+ * @param values - Values to render.
63
+ * @returns Rendered non-empty block segments.
64
+ */
65
+ export declare function segments(...values: (string | number | null | undefined | false)[]): string;
66
+ /**
67
+ * Renders values as space-separated words.
68
+ * @param values - Values to render.
69
+ * @returns Rendered non-empty words.
70
+ */
71
+ export declare function words(...values: (string | number | null | undefined | false)[]): string;
72
+ /**
73
+ * Joins URL path segments and trims extra slashes around each segment.
74
+ * @param parts - URL path segments.
75
+ * @returns Joined URL.
76
+ */
77
+ export declare function url(...parts: (string | number | null | undefined)[]): string;
78
+ //# sourceMappingURL=elements.d.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,CAAC,EAAE,UAG1D;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CACnB,GAAG,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,EAAE,UAG1D;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,UAYnE"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Converts a renderable value to a string.
3
+ * @param value - Value to render.
4
+ * @returns String value, or an empty string for empty values.
5
+ */
6
+ function toString(value) {
7
+ return typeof value === 'number' || value ? String(value) : '';
8
+ }
9
+ /**
10
+ * Renders an array into newline-separated non-empty strings.
11
+ * @param array - Items to render.
12
+ * @param callback - Item renderer.
13
+ * @param separator - Separator inserted between rendered items.
14
+ * @returns Rendered string.
15
+ */
16
+ export function each(array, callback, separator = newline()) {
17
+ return array
18
+ ? array.reduce((acc, item) => {
19
+ const rendered = toString(callback(item)).trim();
20
+ return `${acc}${acc && rendered ? separator : ''}${rendered}`;
21
+ }, '')
22
+ : '';
23
+ }
24
+ /**
25
+ * Renders a Markdown heading.
26
+ * @param level - Markdown heading level.
27
+ * @param text - Heading text.
28
+ * @returns Markdown heading.
29
+ */
30
+ export function heading(level, text) {
31
+ return `${'#'.repeat(level)} ${text}`;
32
+ }
33
+ /**
34
+ * Renders a Markdown link.
35
+ * @param text - Link text.
36
+ * @param url - Link URL.
37
+ * @returns Markdown link.
38
+ */
39
+ export function link(text, url) {
40
+ return `[${text}](${url})`;
41
+ }
42
+ /**
43
+ * Renders an array into a Markdown unordered list.
44
+ * @param array - Items to render.
45
+ * @param callback - Item renderer.
46
+ * @returns Markdown unordered list.
47
+ */
48
+ export function list(array, callback) {
49
+ return each(array, (item) => {
50
+ const rendered = toString(callback(item)).trim();
51
+ const itemText = rendered
52
+ .split(/\r?\n/)
53
+ .map((line, index) => (index > 0 && line
54
+ ? ` ${line}`
55
+ : line))
56
+ .join('\n');
57
+ return rendered ? `* ${itemText}` : '';
58
+ });
59
+ }
60
+ /**
61
+ * Renders bold Markdown text.
62
+ * @param text - Text to render.
63
+ * @returns Bold Markdown text.
64
+ */
65
+ export function bold(text) {
66
+ return `**${text}**`;
67
+ }
68
+ /**
69
+ * Renders italic Markdown text.
70
+ * @param text - Text to render.
71
+ * @returns Italic Markdown text.
72
+ */
73
+ export function italic(text) {
74
+ return `_${text}_`;
75
+ }
76
+ /**
77
+ * Renders text inside an HTML small element.
78
+ * @param text - Text to render.
79
+ * @returns HTML small element.
80
+ */
81
+ export function small(text) {
82
+ return `<small>${text}</small>`;
83
+ }
84
+ /**
85
+ * Creates one or more newline characters.
86
+ * @param times - Number of newline characters to render.
87
+ * @returns Newline characters.
88
+ */
89
+ export function newline(times = 1) {
90
+ return '\n'.repeat(times);
91
+ }
92
+ /**
93
+ * Renders values without separators.
94
+ * @param values - Values to render.
95
+ * @returns Concatenated non-empty values.
96
+ */
97
+ export function strings(...values) {
98
+ return each(values, value => value, '');
99
+ }
100
+ /**
101
+ * Renders values as Markdown blocks separated by blank lines.
102
+ * @param values - Values to render.
103
+ * @returns Rendered non-empty block segments.
104
+ */
105
+ export function segments(...values) {
106
+ return each(values, value => value, newline(2));
107
+ }
108
+ /**
109
+ * Renders values as space-separated words.
110
+ * @param values - Values to render.
111
+ * @returns Rendered non-empty words.
112
+ */
113
+ export function words(...values) {
114
+ return each(values, value => value, ' ');
115
+ }
116
+ /**
117
+ * Joins URL path segments and trims extra slashes around each segment.
118
+ * @param parts - URL path segments.
119
+ * @returns Joined URL.
120
+ */
121
+ export function url(...parts) {
122
+ return parts.reduce((acc, part) => {
123
+ if (typeof part !== 'number' && !part) {
124
+ return acc;
125
+ }
126
+ const segment = String(part).replace(/^\/+|\/+$/g, '');
127
+ return acc
128
+ ? `${acc}/${segment}`
129
+ : segment;
130
+ }, '');
131
+ }
132
+ //# sourceMappingURL=data:application/json;base64,eyJ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RLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztZQUN0QyxPQUFPLEdBQUcsQ0FBQTtRQUNaLENBQUM7UUFFRCxNQUFNLE9BQU8sR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUMsT0FBTyxDQUFDLFlBQVksRUFBRSxFQUFFLENBQUMsQ0FBQTtRQUV0RCxPQUFPLEdBQUc7WUFDUixDQUFDLENBQUMsR0FBRyxHQUFHLElBQUksT0FBTyxFQUFFO1lBQ3JCLENBQUMsQ0FBQyxPQUFPLENBQUE7SUFDYixDQUFDLEVBQUUsRUFBRSxDQUFDLENBQUE7QUFDUixDQUFDIn0=
@@ -0,0 +1,6 @@
1
+ export type * from './types/index.js';
2
+ export * from './elements.js';
3
+ export * from './references.js';
4
+ export * from './templates.js';
5
+ export * from './legacy.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,kBAAkB,CAAA;AACrC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from './elements.js';
2
+ export * from './references.js';
3
+ export * from './templates.js';
4
+ export * from './legacy.js';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsY0FBYyxlQUFlLENBQUE7QUFDN0IsY0FBYyxpQkFBaUIsQ0FBQTtBQUMvQixjQUFjLGdCQUFnQixDQUFBO0FBQzlCLGNBQWMsYUFBYSxDQUFBIn0=
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Creates writer options which make legacy handlebars-based writers
3
+ * (`conventional-changelog-writer@8` and older) fail loudly instead of
4
+ * silently rendering an empty changelog when a mixed-versions install
5
+ * resolves a modern preset against them.
6
+ * Legacy writers compile the `mainTemplate` option with handlebars,
7
+ * where rendering the planted template triggers the `helperMissing` hook,
8
+ * which throws an error with the message from the template.
9
+ * Modern writers have no `mainTemplate` option and ignore the value,
10
+ * and a string survives the option merges of downstream tooling,
11
+ * so the guard reaches legacy writers even through cloned options.
12
+ * The message must not contain `]` characters to stay a valid
13
+ * handlebars segment literal.
14
+ * @param preset - Preset package name to mention in the error message.
15
+ * @returns Writer options to spread into preset writer options.
16
+ */
17
+ export declare function createLegacyWriterGuard(preset: string): {
18
+ mainTemplate: string;
19
+ };
20
+ //# sourceMappingURL=legacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM;IAElD,YAAY;EAEf"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates writer options which make legacy handlebars-based writers
3
+ * (`conventional-changelog-writer@8` and older) fail loudly instead of
4
+ * silently rendering an empty changelog when a mixed-versions install
5
+ * resolves a modern preset against them.
6
+ * Legacy writers compile the `mainTemplate` option with handlebars,
7
+ * where rendering the planted template triggers the `helperMissing` hook,
8
+ * which throws an error with the message from the template.
9
+ * Modern writers have no `mainTemplate` option and ignore the value,
10
+ * and a string survives the option merges of downstream tooling,
11
+ * so the guard reaches legacy writers even through cloned options.
12
+ * The message must not contain `]` characters to stay a valid
13
+ * handlebars segment literal.
14
+ * @param preset - Preset package name to mention in the error message.
15
+ * @returns Writer options to spread into preset writer options.
16
+ */
17
+ export function createLegacyWriterGuard(preset) {
18
+ return {
19
+ mainTemplate: `{{[${preset} requires conventional-changelog-writer@9 or newer (conventional-changelog@8 or newer). Your changelog tooling loaded an older writer which cannot render this preset. Update the tooling or use an older major version of the preset.] true}}`
20
+ };
21
+ }
22
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGVnYWN5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2xlZ2FjeS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7QUFDSCxNQUFNLFVBQVUsdUJBQXVCLENBQUMsTUFBYztJQUNwRCxPQUFPO1FBQ0wsWUFBWSxFQUFFLE1BQU0sTUFBTSxnUEFBZ1A7S0FDM1EsQ0FBQTtBQUNILENBQUMifQ==
@@ -0,0 +1,43 @@
1
+ import type { CommitKnownProps, FinalTemplateContext } from './types/index.js';
2
+ export interface IssueReference {
3
+ /**
4
+ * Issue prefix. EG: In `gh-123` `gh-` is the prefix.
5
+ */
6
+ prefix: string;
7
+ /**
8
+ * Issue id. EG: In `gh-123` `123` is the id.
9
+ */
10
+ issue: string;
11
+ }
12
+ export interface ReferencesFormatterOptions<Commit extends CommitKnownProps = CommitKnownProps> {
13
+ /**
14
+ * The prefixes of an issue. EG: In `gh-123` `gh-` is the prefix.
15
+ * Prefixes are matched in the given order, so a prefix which starts
16
+ * with another one should be placed first.
17
+ */
18
+ issuePrefixes?: (string | RegExp)[];
19
+ /**
20
+ * Pattern of an issue id. EG: In `gh-123` `123` is the id.
21
+ */
22
+ issuePattern?: RegExp;
23
+ /**
24
+ * Builds an issue URL. Empty result leaves the reference as is.
25
+ */
26
+ formatIssueUrl(context: FinalTemplateContext<Commit>, reference: IssueReference): string;
27
+ /**
28
+ * Builds a user URL. Empty result leaves the mention as is.
29
+ */
30
+ formatUserUrl(context: FinalTemplateContext<Commit>, user: string): string;
31
+ }
32
+ export type ReferencesFormatter<Commit extends CommitKnownProps = CommitKnownProps> = (text: string, context: FinalTemplateContext<Commit>, references?: string[]) => string;
33
+ /**
34
+ * Creates a text formatter for the given options.
35
+ *
36
+ * Regexes from the options are inlined into a single multiline regex,
37
+ * so their flags are ignored, `^` and `$` match line boundaries,
38
+ * and they should not contain capturing groups, backreferences or named groups.
39
+ * @param options - Formatter options.
40
+ * @returns Formatter which replaces issue and user references in a text with links.
41
+ */
42
+ export declare function createReferencesFormatter<Commit extends CommitKnownProps = CommitKnownProps>(options: ReferencesFormatterOptions<Commit>): ReferencesFormatter<Commit>;
43
+ //# sourceMappingURL=references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,kBAAkB,CAAA;AAmBzB,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,0BAA0B,CAAC,MAAM,SAAS,gBAAgB,GAAG,gBAAgB;IAC5F;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACnC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,cAAc,GAAG,MAAM,CAAA;IACxF;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAC3E;AAED,MAAM,MAAM,mBAAmB,CAAC,MAAM,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,CACpF,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,EACrC,UAAU,CAAC,EAAE,MAAM,EAAE,KAClB,MAAM,CAAA;AAmCX;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,SAAS,gBAAgB,GAAG,gBAAgB,EAC1F,OAAO,EAAE,0BAA0B,CAAC,MAAM,CAAC,GAC1C,mBAAmB,CAAC,MAAM,CAAC,CA0C7B"}
@@ -0,0 +1,82 @@
1
+ import { link } from './elements.js';
2
+ /**
3
+ * Markdown segments to keep as is: replacing references inside them
4
+ * would break already formatted links, code samples and urls.
5
+ */
6
+ const protectedSegments = [
7
+ /\[(?:[^[\]]|\[[^[\]]*])*]\((?:[^()\n]|\([^()\n]*\))*\)/, // [text](url)
8
+ /\[[^\]]*]\[[^\]]*]/, // [text][ref]
9
+ // the lookahead makes the delimiter length atomic, without it a long run
10
+ // of backticks makes the regex engine retry every possible delimiter length
11
+ /^[ \t]*(?=(?<fence>`{3,}|~{3,}))\k<fence>[\s\S]*?^[ \t]*\k<fence>[ \t]*\r?$/, // ```code block```
12
+ /(?=(?<code>`+))\k<code>[^\n]*?\k<code>/, // `code span`
13
+ /https?:\/\/(?:[^\s()]|\([^\s()]*\))+/ // https://url
14
+ ];
15
+ const userMention = /\B@(?<user>[a-z0-9](?:-?[a-z0-9/]){0,38})/;
16
+ const defaultIssuePattern = /[a-z0-9]+/;
17
+ /**
18
+ * Escapes a string to use it as a part of a regex.
19
+ * @param string
20
+ * @returns Escaped string.
21
+ */
22
+ function escapeRegExp(string) {
23
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
24
+ }
25
+ /**
26
+ * Builds a regex which matches issue and user references
27
+ * outside of the protected Markdown segments.
28
+ * @param issuePrefixes
29
+ * @param issuePattern
30
+ * @returns Regex with `prefix`, `issue` and `user` groups.
31
+ */
32
+ function referencesRegex(issuePrefixes = [], issuePattern = defaultIssuePattern) {
33
+ const prefixes = issuePrefixes
34
+ .map(prefix => (typeof prefix === 'string' ? escapeRegExp(prefix) : prefix.source))
35
+ .join('|');
36
+ const patterns = [
37
+ ...protectedSegments.map(segment => segment.source),
38
+ // without prefixes every word would be matched as an issue reference
39
+ prefixes && `(?<prefix>${prefixes})(?<issue>${issuePattern.source})`,
40
+ userMention.source
41
+ ];
42
+ return new RegExp(patterns.filter(Boolean).join('|'), 'gm');
43
+ }
44
+ /**
45
+ * Creates a text formatter for the given options.
46
+ *
47
+ * Regexes from the options are inlined into a single multiline regex,
48
+ * so their flags are ignored, `^` and `$` match line boundaries,
49
+ * and they should not contain capturing groups, backreferences or named groups.
50
+ * @param options - Formatter options.
51
+ * @returns Formatter which replaces issue and user references in a text with links.
52
+ */
53
+ export function createReferencesFormatter(options) {
54
+ const regex = referencesRegex(options.issuePrefixes, options.issuePattern);
55
+ return (text, context, references) => text.replace(regex, (match, ...args) => {
56
+ const { prefix, issue, user } = args.at(-1);
57
+ if (issue) {
58
+ const issueUrl = options.formatIssueUrl(context, {
59
+ prefix: prefix,
60
+ issue
61
+ });
62
+ if (!issueUrl) {
63
+ return match;
64
+ }
65
+ references?.push(match);
66
+ return link(match, issueUrl);
67
+ }
68
+ if (user) {
69
+ // TODO: investigate why this code exists.
70
+ if (user.includes('/')) {
71
+ return match;
72
+ }
73
+ const userUrl = options.formatUserUrl(context, user);
74
+ if (!userUrl) {
75
+ return match;
76
+ }
77
+ return link(match, userUrl);
78
+ }
79
+ return match;
80
+ });
81
+ }
82
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVmZXJlbmNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9yZWZlcmVuY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sRUFBRSxJQUFJLEVBQUUsTUFBTSxlQUFlLENBQUE7QUFFcEM7OztHQUdHO0FBQ0gsTUFBTSxpQkFBaUIsR0FBRztJQUN4Qix3REFBd0QsRUFBRSxjQUFjO0lBQ3hFLG9CQUFvQixFQUFFLGNBQWM7SUFDcEMseUVBQXlFO0lBQ3pFLDRFQUE0RTtJQUM1RSw2RUFBNkUsRUFBRSxtQkFBbUI7SUFDbEcsd0NBQXdDL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FPLENBQUMsYUFBYSxDQUFDLE9BQU8sRUFBRSxJQUFJLENBQUMsQ0FBQTtZQUVwRCxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7Z0JBQ2IsT0FBTyxLQUFLLENBQUE7WUFDZCxDQUFDO1lBRUQsT0FBTyxJQUFJLENBQUMsS0FBSyxFQUFFLE9BQU8sQ0FBQyxDQUFBO1FBQzdCLENBQUM7UUFFRCxPQUFPLEtBQUssQ0FBQTtJQUNkLENBQUMsQ0FBQyxDQUFBO0FBQ0osQ0FBQyJ9
@@ -0,0 +1,74 @@
1
+ import type { FinalTemplateContext, CommitKnownProps, CommitNote, CommitReference, TransformedCommit } from './types/index.js';
2
+ /**
3
+ * Builds a repository URL from template context fields.
4
+ * @param context - Template context.
5
+ * @returns Repository URL.
6
+ */
7
+ export declare function repositoryUrl<Commit extends CommitKnownProps = CommitKnownProps>(context: FinalTemplateContext<Commit>): string;
8
+ /**
9
+ * Builds a repository URL for a commit reference.
10
+ * @param context - Template context.
11
+ * @param reference - Commit reference.
12
+ * @returns Reference repository URL.
13
+ */
14
+ export declare function referenceRepositoryUrl<Commit extends CommitKnownProps = CommitKnownProps>(context: FinalTemplateContext<Commit>, reference: CommitReference): string;
15
+ /**
16
+ * Builds a release comparison URL and encodes tag names as URL path segments.
17
+ * @param context - Template context.
18
+ * @returns Release comparison URL.
19
+ */
20
+ export declare function compareUrl<Commit extends CommitKnownProps = CommitKnownProps>(context: FinalTemplateContext<Commit>): string;
21
+ export declare const BREAKING_CHANGE_KEYWORDS: string[];
22
+ export declare const BREAKING_CHANGES_TITLE = "BREAKING CHANGES";
23
+ /**
24
+ * Renders a note group title.
25
+ * Breaking change keywords are merged into a single title,
26
+ * every other keyword is uppercased to group its spellings together.
27
+ * @param title - Note title as it was written in a commit.
28
+ * @returns Note group title.
29
+ */
30
+ export declare function noteTitle(title: string): string;
31
+ /**
32
+ * Checks if a note is a breaking change note.
33
+ * @param note - Commit note.
34
+ * @returns Is it a breaking change note.
35
+ */
36
+ export declare function isBreakingNote(note: CommitNote): boolean;
37
+ /**
38
+ * Renders a commit reference label.
39
+ * @param reference - Commit reference.
40
+ * @returns Commit reference label.
41
+ */
42
+ export declare function reference(reference: CommitReference): string;
43
+ /**
44
+ * Renders the default changelog header.
45
+ * @param context - Template context.
46
+ * @returns Changelog header.
47
+ */
48
+ export declare function headerPartial<Commit extends CommitKnownProps = CommitKnownProps>({ isPatch, title, version, date }: FinalTemplateContext<Commit>): string;
49
+ /**
50
+ * Renders the default changelog preamble.
51
+ * @param context - Template context.
52
+ * @returns Changelog preamble.
53
+ */
54
+ export declare function preamblePartial<Commit extends CommitKnownProps = CommitKnownProps>({ preamble }: FinalTemplateContext<Commit>): string;
55
+ /**
56
+ * Renders the default changelog footer.
57
+ * @param context - Template context.
58
+ * @returns Changelog footer.
59
+ */
60
+ export declare function footerPartial<Commit extends CommitKnownProps = CommitKnownProps>({ noteGroups }: FinalTemplateContext<Commit>): string;
61
+ /**
62
+ * Renders the default changelog commit line.
63
+ * @param context - Template context.
64
+ * @param commit - Transformed commit.
65
+ * @returns Changelog commit line.
66
+ */
67
+ export declare function commitPartial<Commit extends CommitKnownProps = CommitKnownProps>(context: FinalTemplateContext<Commit>, commit: TransformedCommit<Commit>): string;
68
+ /**
69
+ * Renders the default changelog template.
70
+ * @param context - Template context.
71
+ * @returns Changelog text.
72
+ */
73
+ export declare function template<Commit extends CommitKnownProps = CommitKnownProps>(context: FinalTemplateContext<Commit>): string;
74
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AAczB;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,SAAS,gBAAgB,GAAG,gBAAgB,EAC9E,OAAO,EAAE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