@williamthorsen/release-kit 11.0.0 → 13.0.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 (189) hide show
  1. package/.meta/changelog.json +274 -2
  2. package/.readyup/kits/default.js +18 -33
  3. package/.readyup/kits/npm-auto-publish.js +24 -23
  4. package/.readyup/manifest.json +16 -11
  5. package/CHANGELOG.md +98 -0
  6. package/README.md +57 -69
  7. package/bin/release-kit.js +1 -1
  8. package/dist/esm/assertCleanWorkingTree.d.ts +1 -5
  9. package/dist/esm/assertTaggedBaseline.d.ts +29 -0
  10. package/dist/esm/assertTaggedBaseline.js +41 -0
  11. package/dist/esm/attachChangelogDiagnostics.d.ts +4 -0
  12. package/dist/esm/attachChangelogDiagnostics.js +14 -0
  13. package/dist/esm/bin/release-kit.js +88 -24
  14. package/dist/esm/buildChangelogEntries.d.ts +69 -17
  15. package/dist/esm/buildChangelogEntries.js +222 -120
  16. package/dist/esm/buildDependencyGraph.d.ts +6 -6
  17. package/dist/esm/buildEmptyReleaseEntry.d.ts +1 -8
  18. package/dist/esm/buildReleaseSummary.d.ts +2 -8
  19. package/dist/esm/buildReleaseSummary.js +2 -2
  20. package/dist/esm/buildSyntheticChangelogEntry.d.ts +3 -5
  21. package/dist/esm/buildSyntheticChangelogEntry.js +2 -2
  22. package/dist/esm/bumpVersion.d.ts +1 -8
  23. package/dist/esm/changelogJsonFile.d.ts +5 -7
  24. package/dist/esm/changelogJsonFile.js +2 -17
  25. package/dist/esm/changelogJsonUtils.d.ts +7 -10
  26. package/dist/esm/changelogOverrides.d.ts +79 -100
  27. package/dist/esm/changelogOverrides.js +138 -58
  28. package/dist/esm/classifyChangelogCommit.d.ts +36 -0
  29. package/dist/esm/classifyChangelogCommit.js +34 -0
  30. package/dist/esm/commitCommand.d.ts +2 -4
  31. package/dist/esm/compareVersions.d.ts +10 -4
  32. package/dist/esm/compareVersions.js +16 -0
  33. package/dist/esm/configFlagSchema.d.ts +1 -1
  34. package/dist/esm/createGithubRelease.d.ts +7 -19
  35. package/dist/esm/createGithubReleaseCommand.d.ts +5 -5
  36. package/dist/esm/createGithubReleaseCommand.js +9 -9
  37. package/dist/esm/createTags.d.ts +2 -3
  38. package/dist/esm/decideRelease.d.ts +11 -41
  39. package/dist/esm/decideRelease.js +5 -27
  40. package/dist/esm/defaults.d.ts +5 -24
  41. package/dist/esm/defaults.js +7 -5
  42. package/dist/esm/defineConfig.d.ts +1 -1
  43. package/dist/esm/deleteFileIfExists.d.ts +1 -1
  44. package/dist/esm/deriveReleaseNotesConfig.d.ts +20 -0
  45. package/dist/esm/deriveReleaseNotesConfig.js +21 -0
  46. package/dist/esm/deriveWorkspaceConfig.d.ts +3 -5
  47. package/dist/esm/detectPackageManager.d.ts +2 -4
  48. package/dist/esm/detectUndeclaredTagPrefixes.d.ts +4 -6
  49. package/dist/esm/detectUndeclaredTagPrefixes.js +1 -1
  50. package/dist/esm/determineBumpType.d.ts +11 -11
  51. package/dist/esm/determineBumpType.js +6 -7
  52. package/dist/esm/discoverWorkspaces.d.ts +14 -15
  53. package/dist/esm/discoverWorkspaces.js +12 -12
  54. package/dist/esm/enterRepoRoot.d.ts +12 -0
  55. package/dist/esm/enterRepoRoot.js +16 -0
  56. package/dist/esm/enumerateReleaseWindows.d.ts +50 -0
  57. package/dist/esm/enumerateReleaseWindows.js +124 -0
  58. package/dist/esm/extractMigration.d.ts +6 -8
  59. package/dist/esm/findUnroutedEntryScopes.d.ts +16 -0
  60. package/dist/esm/findUnroutedEntryScopes.js +57 -0
  61. package/dist/esm/formatExcludedSkip.d.ts +3 -0
  62. package/dist/esm/formatExcludedSkip.js +3 -0
  63. package/dist/esm/formatPrivateSkip.d.ts +1 -6
  64. package/dist/esm/generateChangelogs.d.ts +13 -26
  65. package/dist/esm/generateChangelogs.js +0 -14
  66. package/dist/esm/glyphs.d.ts +2 -2
  67. package/dist/esm/help/prepareHelp.d.ts +3 -4
  68. package/dist/esm/help/prepareHelp.js +7 -8
  69. package/dist/esm/index.d.ts +1 -1
  70. package/dist/esm/init/checks.d.ts +3 -3
  71. package/dist/esm/init/checks.js +4 -1
  72. package/dist/esm/init/detectRepoType.d.ts +2 -3
  73. package/dist/esm/init/hasProvenance.d.ts +2 -0
  74. package/dist/esm/init/hasProvenance.js +3 -0
  75. package/dist/esm/init/initCommand.d.ts +3 -6
  76. package/dist/esm/init/initCommand.js +11 -11
  77. package/dist/esm/init/parseJsonRecord.d.ts +1 -4
  78. package/dist/esm/init/scaffold.d.ts +1 -3
  79. package/dist/esm/init/scaffold.js +2 -30
  80. package/dist/esm/init/templates.d.ts +9 -11
  81. package/dist/esm/init/templates.js +12 -11
  82. package/dist/esm/init/updateTemplatesCommand.d.ts +13 -0
  83. package/dist/esm/init/updateTemplatesCommand.js +64 -0
  84. package/dist/esm/injectReleaseNotesIntoReadme.d.ts +12 -17
  85. package/dist/esm/injectSection.d.ts +3 -3
  86. package/dist/esm/loadConfig.d.ts +16 -14
  87. package/dist/esm/loadConfig.js +2 -5
  88. package/dist/esm/loadValidatedConfig.d.ts +16 -19
  89. package/dist/esm/loadValidatedConfig.js +6 -1
  90. package/dist/esm/packsPath.d.ts +9 -9
  91. package/dist/esm/parseChangeRecordBlock.d.ts +37 -0
  92. package/dist/esm/parseChangeRecordBlock.js +134 -0
  93. package/dist/esm/parseCommitMessage.d.ts +42 -32
  94. package/dist/esm/parseCommitMessage.js +33 -41
  95. package/dist/esm/parseRequestedTags.d.ts +3 -3
  96. package/dist/esm/planReleaseNotesPreviews.d.ts +6 -6
  97. package/dist/esm/planVersionBump.d.ts +5 -3
  98. package/dist/esm/planVersionBump.js +3 -0
  99. package/dist/esm/prepareCommand.d.ts +4 -7
  100. package/dist/esm/prepareCommand.js +17 -18
  101. package/dist/esm/previewTagPrefixes.d.ts +8 -10
  102. package/dist/esm/propagateBumps.d.ts +6 -7
  103. package/dist/esm/publish.d.ts +1 -1
  104. package/dist/esm/publishCommand.d.ts +4 -3
  105. package/dist/esm/publishCommand.js +8 -8
  106. package/dist/esm/pushCommand.d.ts +4 -3
  107. package/dist/esm/pushCommand.js +8 -2
  108. package/dist/esm/pushRelease.d.ts +2 -2
  109. package/dist/esm/readChangelogSections.d.ts +33 -0
  110. package/dist/esm/readChangelogSections.js +80 -0
  111. package/dist/esm/releaseFiles.d.ts +5 -7
  112. package/dist/esm/releasePlan.d.ts +11 -13
  113. package/dist/esm/releasePrepare.d.ts +25 -25
  114. package/dist/esm/releasePrepare.js +80 -80
  115. package/dist/esm/releasePrepareMono.d.ts +9 -7
  116. package/dist/esm/releasePrepareMono.js +114 -99
  117. package/dist/esm/releasePrepareProject.d.ts +19 -29
  118. package/dist/esm/releasePrepareProject.js +46 -45
  119. package/dist/esm/renderChangelogMarkdown.d.ts +10 -4
  120. package/dist/esm/renderChangelogMarkdown.js +27 -2
  121. package/dist/esm/renderReleaseNotes.d.ts +3 -11
  122. package/dist/esm/renderReleaseNotes.js +2 -6
  123. package/dist/esm/reportPrepare.d.ts +4 -5
  124. package/dist/esm/reportPrepare.js +67 -42
  125. package/dist/esm/resolveCommandTags.d.ts +15 -11
  126. package/dist/esm/resolveCommandTags.js +35 -5
  127. package/dist/esm/resolveConfigFlag.d.ts +7 -0
  128. package/dist/esm/resolveConfigFlag.js +4 -0
  129. package/dist/esm/resolveReleaseTags.d.ts +6 -8
  130. package/dist/esm/resolveReleaseTags.js +1 -1
  131. package/dist/esm/resolveStylesOrExit.d.ts +2 -2
  132. package/dist/esm/showTagPrefixesCommand.d.ts +7 -10
  133. package/dist/esm/showTagPrefixesCommand.js +4 -4
  134. package/dist/esm/stripEmojiPrefix.d.ts +1 -0
  135. package/dist/esm/stripScope.d.ts +2 -2
  136. package/dist/esm/stripScope.js +3 -3
  137. package/dist/esm/sync-labels/generateCommand.d.ts +11 -10
  138. package/dist/esm/sync-labels/generateCommand.js +11 -8
  139. package/dist/esm/sync-labels/initCommand.d.ts +6 -7
  140. package/dist/esm/sync-labels/initCommand.js +2 -2
  141. package/dist/esm/sync-labels/presets.d.ts +5 -4
  142. package/dist/esm/sync-labels/presets.js +9 -9
  143. package/dist/esm/sync-labels/resolveLabels.d.ts +7 -7
  144. package/dist/esm/sync-labels/resolveLabels.js +1 -1
  145. package/dist/esm/sync-labels/retiredConfig.d.ts +4 -5
  146. package/dist/esm/sync-labels/syncCommand.d.ts +1 -4
  147. package/dist/esm/sync-labels/templates.d.ts +3 -3
  148. package/dist/esm/sync-labels/templates.js +3 -3
  149. package/dist/esm/sync-labels/typeLabels.d.ts +14 -0
  150. package/dist/esm/sync-labels/typeLabels.js +38 -0
  151. package/dist/esm/sync-labels/types.d.ts +1 -1
  152. package/dist/esm/tagCommand.d.ts +1 -1
  153. package/dist/esm/typeGuards.d.ts +2 -2
  154. package/dist/esm/types.d.ts +185 -116
  155. package/dist/esm/types.js +2 -2
  156. package/dist/esm/validateConfig.d.ts +2 -11
  157. package/dist/esm/validateConfig.js +5 -1
  158. package/dist/esm/validateOnlyExcludesStrandedDependents.d.ts +14 -12
  159. package/dist/esm/validateOverridesCommand.d.ts +19 -21
  160. package/dist/esm/validateOverridesCommand.js +16 -23
  161. package/docs/api.md +6 -6
  162. package/docs/changelogs.md +90 -28
  163. package/docs/configuration.md +30 -29
  164. package/docs/editorial-overrides.md +90 -31
  165. package/docs/labels.md +21 -19
  166. package/docs/project-releases.md +14 -14
  167. package/docs/publishing.md +5 -5
  168. package/docs/readiness-checks.md +3 -3
  169. package/docs/releasing.md +54 -24
  170. package/docs/work-types.md +46 -58
  171. package/package.json +7 -7
  172. package/presets/labels/common.yaml +1 -41
  173. package/schemas/changelog-overrides.json +39 -0
  174. package/cliff.toml.template +0 -65
  175. package/dist/esm/collectPolicyViolations.d.ts +0 -15
  176. package/dist/esm/collectPolicyViolations.js +0 -12
  177. package/dist/esm/determineBumpFromCommits.d.ts +0 -17
  178. package/dist/esm/determineBumpFromCommits.js +0 -28
  179. package/dist/esm/getCommitsSinceTarget.d.ts +0 -21
  180. package/dist/esm/getCommitsSinceTarget.js +0 -66
  181. package/dist/esm/resolveCliffConfigPath.d.ts +0 -11
  182. package/dist/esm/resolveCliffConfigPath.js +0 -20
  183. package/dist/esm/resolveReleaseNotesConfig.d.ts +0 -26
  184. package/dist/esm/resolveReleaseNotesConfig.js +0 -29
  185. package/dist/esm/runGitCliff.d.ts +0 -38
  186. package/dist/esm/runGitCliff.js +0 -25
  187. package/dist/esm/workTypesData.d.ts +0 -50
  188. package/dist/esm/workTypesData.js +0 -145
  189. package/schemas/label-map.json +0 -24
@@ -4,11 +4,14 @@ import { describeError } from '@williamthorsen/toolbelt.errors';
4
4
  import { commitCommand } from "../commitCommand.js";
5
5
  import { configFlagSchema } from "../configFlagSchema.js";
6
6
  import { createGithubReleaseCommand } from "../createGithubReleaseCommand.js";
7
+ import { enterRepoRoot } from "../enterRepoRoot.js";
7
8
  import { showPrepareHelp } from "../help/prepareHelp.js";
8
9
  import { initCommand } from "../init/initCommand.js";
10
+ import { updateTemplatesCommand } from "../init/updateTemplatesCommand.js";
9
11
  import { prepareCommand } from "../prepareCommand.js";
10
12
  import { publishCommand } from "../publishCommand.js";
11
13
  import { pushCommand } from "../pushCommand.js";
14
+ import { resolveConfigFlag } from "../resolveConfigFlag.js";
12
15
  import { OUTPUT_STYLE_ENV_VAR, resolveStylesOrExit } from "../resolveStylesOrExit.js";
13
16
  import { showTagPrefixesCommand } from "../showTagPrefixesCommand.js";
14
17
  import { generateCommand } from "../sync-labels/generateCommand.js";
@@ -30,6 +33,7 @@ Commands:
30
33
  create-github-release Create GitHub Releases from changelog.json for tags on HEAD
31
34
  show-tag-prefixes Show derived and declared legacy tag prefixes per workspace
32
35
  init Initialize release-kit in the current repository
36
+ update-templates Update the scaffolded workflows to the current templates
33
37
  overrides Manage editorial changelog overrides
34
38
  sync-labels Manage GitHub label synchronization
35
39
 
@@ -69,7 +73,8 @@ retired packages, then generate .github/labels.yaml. When the config file alread
69
73
  exists, print the block for manual paste instead of rewriting the file.
70
74
 
71
75
  Options:
72
- --config <path> Path to config file (default: .config/release-kit.config.ts)
76
+ --config <path> Config file, relative to the current directory
77
+ (default: .config/release-kit.config.ts at the repo root)
73
78
  --dry-run Preview changes without writing files
74
79
  --force Overwrite existing files instead of skipping them
75
80
  --help, -h Show this help message
@@ -83,7 +88,8 @@ Regenerate .github/labels.yaml from the repoLabels block of .config/release-kit.
83
88
 
84
89
  Options:
85
90
  --check Report whether .github/labels.yaml is stale instead of writing it
86
- --config <path> Path to config file (default: .config/release-kit.config.ts)
91
+ --config <path> Config file, relative to the current directory
92
+ (default: .config/release-kit.config.ts at the repo root)
87
93
  --help, -h Show this help message
88
94
  `);
89
95
  }
@@ -105,12 +111,26 @@ Initialize release-kit in the current repository.
105
111
  By default, scaffolds only the GitHub Actions workflow files.
106
112
 
107
113
  Options:
108
- --with-config Also scaffold .config/release-kit.config.ts and .config/git-cliff.toml
114
+ --with-config Also scaffold .config/release-kit.config.ts
109
115
  --force Overwrite existing files instead of skipping them
110
116
  --dry-run Preview changes without writing files
111
117
  --help, -h Show this help message
112
118
  `);
113
119
  }
120
+ function showUpdateTemplatesHelp() {
121
+ console.info(`
122
+ Usage: release-kit update-templates [options]
123
+
124
+ Update the GitHub Actions workflows that release-kit scaffolds to the templates
125
+ of the installed version, showing what changed in each file. Creates a missing
126
+ workflow that \`init\` would create, and refreshes sync-labels.yaml only when it
127
+ exists. Keeps publish.yaml's provenance setting. Never touches config files.
128
+
129
+ Options:
130
+ --dry-run Preview changes without writing files
131
+ --help, -h Show this help message
132
+ `);
133
+ }
114
134
  function showCommitHelp() {
115
135
  console.info(`
116
136
  Usage: release-kit commit [options]
@@ -139,10 +159,12 @@ function showPushHelp() {
139
159
  console.info(`
140
160
  Usage: release-kit push [options]
141
161
 
142
- Push the release commit and each tag individually, ensuring GitHub Actions
143
- fires a separate workflow run per tag.
162
+ Push the release commit and each tag individually, so that GitHub Actions
163
+ starts a separate workflow run for each tag.
144
164
 
145
165
  Options:
166
+ --config <path> Config file, relative to the current directory
167
+ (default: .config/release-kit.config.ts at the repo root)
146
168
  --dry-run Preview without pushing
147
169
  --tags=tag1,tag2 Only push the named tags (comma-separated, full tag names)
148
170
  --tags-only Skip the branch push (push tags only)
@@ -154,10 +176,12 @@ function showCreateGithubReleaseHelp() {
154
176
  Usage: release-kit create-github-release [options]
155
177
 
156
178
  Create GitHub Releases from changelog.json for tags on HEAD. Private
157
- (package.json#private) workspaces are skipped with a warning and get no Release.
179
+ (package.json#private) workspaces are skipped with a warning, and the command
180
+ doesn't create a Release for them.
158
181
 
159
182
  Options:
160
- --config <path> Path to config file (default: .config/release-kit.config.ts)
183
+ --config <path> Config file, relative to the current directory
184
+ (default: .config/release-kit.config.ts at the repo root)
161
185
  --dry-run Preview without creating releases
162
186
  --tags=tag1,tag2 Only create releases for the named tags (comma-separated, full tag names)
163
187
  --help, -h Show this help message
@@ -168,12 +192,13 @@ function showShowTagPrefixesHelp() {
168
192
  Usage: release-kit show-tag-prefixes [options]
169
193
 
170
194
  Print a per-workspace table of derived tag prefixes, tag counts, and declared
171
- legacy tag prefixes. Surfaces any release-shaped tags whose prefix is neither a
195
+ legacy tag prefixes. Reports any release-shaped tags whose prefix is neither a
172
196
  derived prefix nor declared in \`legacyIdentities\`, with a copy-pasteable
173
197
  config snippet.
174
198
 
175
199
  Options:
176
- --config <path> Path to config file (default: .config/release-kit.config.ts)
200
+ --config <path> Config file, relative to the current directory
201
+ (default: .config/release-kit.config.ts at the repo root)
177
202
  --help, -h Show this help message
178
203
  `);
179
204
  }
@@ -195,15 +220,17 @@ function showOverridesValidateHelp() {
195
220
  Usage: release-kit overrides validate
196
221
 
197
222
  Validate every \`.meta/changelog-overrides.json\` file across the project and per-workspace
198
- scopes. Reports schema/parse errors, ambiguous-prefix errors, and stale-key warnings.
223
+ scopes. Reports schema/parse errors, ambiguous-prefix errors, conflicting-key errors, and
224
+ stale-key warnings.
199
225
 
200
226
  Exit codes:
201
- 0 Clean — no errors, no stale keys
227
+ 0 Clean: no errors, no stale keys
202
228
  1 Stale-key warnings only (no errors)
203
- 2 Schema/parse or ambiguous-prefix errors (errors dominate)
229
+ 2 Schema/parse, ambiguous-prefix, or conflicting-key errors (errors take precedence)
204
230
 
205
231
  Options:
206
- --config <path> Path to config file (default: .config/release-kit.config.ts)
232
+ --config <path> Config file, relative to the current directory
233
+ (default: .config/release-kit.config.ts at the repo root)
207
234
  --help, -h Show this help message
208
235
  `);
209
236
  }
@@ -211,13 +238,14 @@ function showPublishHelp() {
211
238
  console.info(`
212
239
  Usage: release-kit publish [options]
213
240
 
214
- Publish packages that have release tags on HEAD. Operates only on workspaces where
241
+ Publish packages that have release tags on HEAD. Operates only on workspaces whose
215
242
  package.json#private is absent or false. Without --tags, unpublishable workspaces are
216
243
  silently filtered out. With --tags, an unpublishable tag is skipped with a warning while
217
- any publishable tags still publish.
244
+ any publishable tags are still published.
218
245
 
219
246
  Options:
220
- --config <path> Path to config file (default: .config/release-kit.config.ts)
247
+ --config <path> Config file, relative to the current directory
248
+ (default: .config/release-kit.config.ts at the repo root)
221
249
  --dry-run Preview without publishing
222
250
  --no-git-checks Skip the clean-working-tree check
223
251
  --tags=tag1,tag2 Only publish the named tags (comma-separated, full tag names)
@@ -225,6 +253,15 @@ Options:
225
253
  --help, -h Show this help message
226
254
  `);
227
255
  }
256
+ function enterRepoRootOrExit() {
257
+ try {
258
+ return enterRepoRoot();
259
+ }
260
+ catch (error) {
261
+ reportError(describeError(error));
262
+ process.exit(1);
263
+ }
264
+ }
228
265
  const args = process.argv.slice(2);
229
266
  const command = args[0];
230
267
  if (command === '--version' || command === '-V') {
@@ -246,7 +283,8 @@ if (command === 'prepare') {
246
283
  showPrepareHelp();
247
284
  process.exit(0);
248
285
  }
249
- await prepareCommand(flags, styles);
286
+ const { invocationDir } = enterRepoRootOrExit();
287
+ await prepareCommand(flags, styles, invocationDir);
250
288
  process.exit(0);
251
289
  }
252
290
  if (command === 'commit') {
@@ -254,6 +292,7 @@ if (command === 'commit') {
254
292
  showCommitHelp();
255
293
  process.exit(0);
256
294
  }
295
+ enterRepoRootOrExit();
257
296
  try {
258
297
  commitCommand(flags);
259
298
  }
@@ -268,6 +307,7 @@ if (command === 'tag') {
268
307
  showTagHelp();
269
308
  process.exit(0);
270
309
  }
310
+ enterRepoRootOrExit();
271
311
  tagCommand(flags, styles);
272
312
  process.exit(0);
273
313
  }
@@ -276,7 +316,8 @@ if (command === 'push') {
276
316
  showPushHelp();
277
317
  process.exit(0);
278
318
  }
279
- pushCommand(flags);
319
+ const { invocationDir } = enterRepoRootOrExit();
320
+ await pushCommand(flags, styles, invocationDir);
280
321
  process.exit(0);
281
322
  }
282
323
  if (command === 'create-github-release') {
@@ -284,7 +325,8 @@ if (command === 'create-github-release') {
284
325
  showCreateGithubReleaseHelp();
285
326
  process.exit(0);
286
327
  }
287
- await createGithubReleaseCommand(flags, styles);
328
+ const { invocationDir } = enterRepoRootOrExit();
329
+ await createGithubReleaseCommand(flags, styles, invocationDir);
288
330
  process.exit(0);
289
331
  }
290
332
  if (command === 'publish') {
@@ -292,7 +334,8 @@ if (command === 'publish') {
292
334
  showPublishHelp();
293
335
  process.exit(0);
294
336
  }
295
- await publishCommand(flags, styles);
337
+ const { invocationDir } = enterRepoRootOrExit();
338
+ await publishCommand(flags, styles, invocationDir);
296
339
  process.exit(0);
297
340
  }
298
341
  if (command === 'show-tag-prefixes') {
@@ -300,8 +343,9 @@ if (command === 'show-tag-prefixes') {
300
343
  showShowTagPrefixesHelp();
301
344
  process.exit(0);
302
345
  }
346
+ const { invocationDir } = enterRepoRootOrExit();
303
347
  const { config } = parseArgsOrExit(flags, configFlagSchema).flags;
304
- const exitCode = await showTagPrefixesCommand(styles, config);
348
+ const exitCode = await showTagPrefixesCommand(styles, resolveConfigFlag(config, invocationDir));
305
349
  process.exit(exitCode);
306
350
  }
307
351
  if (command === 'init') {
@@ -309,6 +353,7 @@ if (command === 'init') {
309
353
  showInitHelp();
310
354
  process.exit(0);
311
355
  }
356
+ enterRepoRootOrExit();
312
357
  const initFlagSchema = {
313
358
  dryRun: { long: '--dry-run', type: 'boolean' },
314
359
  force: { long: '--force', type: 'boolean' },
@@ -318,6 +363,19 @@ if (command === 'init') {
318
363
  const exitCode = initCommand({ dryRun, force, styles, withConfig });
319
364
  process.exit(exitCode);
320
365
  }
366
+ if (command === 'update-templates') {
367
+ if (flags.some((f) => f === '--help' || f === '-h')) {
368
+ showUpdateTemplatesHelp();
369
+ process.exit(0);
370
+ }
371
+ enterRepoRootOrExit();
372
+ const updateTemplatesFlagSchema = {
373
+ dryRun: { long: '--dry-run', type: 'boolean' },
374
+ };
375
+ const { dryRun } = parseArgsOrExit(flags, updateTemplatesFlagSchema).flags;
376
+ const exitCode = updateTemplatesCommand({ dryRun, styles });
377
+ process.exit(exitCode);
378
+ }
321
379
  if (command === 'sync-labels') {
322
380
  const subcommand = flags[0];
323
381
  if (subcommand === undefined || ['--help', '-h'].includes(subcommand)) {
@@ -330,14 +388,16 @@ if (command === 'sync-labels') {
330
388
  showSyncLabelsInitHelp();
331
389
  process.exit(0);
332
390
  }
391
+ const { invocationDir } = enterRepoRootOrExit();
333
392
  const syncLabelsInitFlagSchema = {
334
393
  ...configFlagSchema,
335
394
  dryRun: { long: '--dry-run', type: 'boolean' },
336
395
  force: { long: '--force', type: 'boolean' },
337
396
  };
338
397
  const { config, dryRun, force } = parseArgsOrExit(subflags, syncLabelsInitFlagSchema).flags;
398
+ const configPath = resolveConfigFlag(config, invocationDir);
339
399
  const exitCode = await syncLabelsInitCommand({
340
- ...(config !== undefined && { configPath: config }),
400
+ ...(configPath !== undefined && { configPath }),
341
401
  dryRun,
342
402
  force,
343
403
  styles,
@@ -349,12 +409,14 @@ if (command === 'sync-labels') {
349
409
  showSyncLabelsGenerateHelp();
350
410
  process.exit(0);
351
411
  }
412
+ const { invocationDir } = enterRepoRootOrExit();
352
413
  const generateFlagSchema = {
353
414
  ...configFlagSchema,
354
415
  check: { long: '--check', type: 'boolean' },
355
416
  };
356
417
  const { check, config } = parseArgsOrExit(subflags, generateFlagSchema).flags;
357
- const exitCode = await generateCommand({ check, ...(config !== undefined && { configPath: config }), styles });
418
+ const configPath = resolveConfigFlag(config, invocationDir);
419
+ const exitCode = await generateCommand({ check, ...(configPath !== undefined && { configPath }), styles });
358
420
  process.exit(exitCode);
359
421
  }
360
422
  if (subcommand === 'sync') {
@@ -366,6 +428,7 @@ if (command === 'sync-labels') {
366
428
  reportError(`Unknown option: ${subflags[0]}`);
367
429
  process.exit(1);
368
430
  }
431
+ enterRepoRootOrExit();
369
432
  const exitCode = syncLabelsCommand();
370
433
  process.exit(exitCode);
371
434
  }
@@ -385,8 +448,9 @@ if (command === 'overrides') {
385
448
  showOverridesValidateHelp();
386
449
  process.exit(0);
387
450
  }
451
+ const { invocationDir } = enterRepoRootOrExit();
388
452
  const { config } = parseArgsOrExit(subflags, configFlagSchema).flags;
389
- const result = await validateOverridesCommand(styles, config);
453
+ const result = await validateOverridesCommand(styles, resolveConfigFlag(config, invocationDir));
390
454
  if (result.exitCode === 0) {
391
455
  console.info(result.message);
392
456
  }
@@ -1,26 +1,78 @@
1
+ import { type RawCommit } from './enumerateReleaseWindows.js';
1
2
  import type { GenerateChangelogOptions } from './generateChangelogs.js';
2
- import type { ChangelogEntry, ReleaseConfig } from './types.js';
3
+ import type { ChangelogEntry, ChangelogSection, MalformedChangeRecordBlock, PolicyViolation, ReleaseConfig, ReleaseType, UndeclaredEntryType, UnroutedEntryScope } from './types.js';
3
4
  /**
4
- * Strip cliff-template decorations from a group string, returning the bare section name.
5
+ * Strips a section title down to its bare name.
5
6
  *
6
- * The bundled `cliff.toml.template` encodes canonical row order as a hidden HTML comment
7
- * (e.g. `"<!-- 04 -->🐛 Bug fixes"`) so tera's `group_by` filter sorts groups predictably.
8
- * The body template's `striptags` filter erases the comment from the rendered heading,
9
- * but downstream consumers that read the raw `group` value (changelog.json titles, the
10
- * dev-vs-public classifier, the drift test) see the prefix and must strip it. The trailing
11
- * `stripEmojiPrefix` keeps the helper backward-compatible with consumer overrides written
12
- * as bare names.
7
+ * A default title has a leading emoji (e.g. `"🐛 Bug fixes"`), while a consumer's
8
+ * `devOnlySections` or `workTypes` override may be written as a bare name. Comparing both sides
9
+ * through this helper lets the two forms match.
13
10
  */
14
11
  export declare function stripGroupDecorations(group: string): string;
15
12
  /**
16
- * Build structured changelog entries from git history using git-cliff `--context`.
13
+ * Builds structured changelog entries from the release windows of git history, naming the unreleased window `tag`.
17
14
  *
18
- * Pure data: invokes git-cliff, parses its `--context` output, and returns the transformed
19
- * `ChangelogEntry[]`. Performs no `changelog.json` I/O — callers persist the entries via
20
- * `renderChangelogJson`.
15
+ * Composes `readReleaseHistory` and `toChangelogEntries` for a caller that knows the tag before it reads.
16
+ */
17
+ export declare function buildChangelogEntries(config: ReleaseHistoryConfig, tag: string, options: GenerateChangelogOptions): {
18
+ entries: ChangelogEntry[];
19
+ diagnostics: ChangelogDiagnostics;
20
+ };
21
+ /** What reading the unreleased window reports beyond its items. */
22
+ export interface ChangelogDiagnostics {
23
+ malformedBlocks: MalformedChangeRecordBlock[];
24
+ /** Breaking-policy violations of the window's titles and change-record entries. */
25
+ policyViolations: PolicyViolation[];
26
+ undeclaredEntryTypes: UndeclaredEntryType[];
27
+ /**
28
+ * Entry scopes that don't route to any workspace. A read leaves it empty: Only a pass over every workspace can fill
29
+ * it.
30
+ */
31
+ unroutedEntryScopes: UnroutedEntryScope[];
32
+ }
33
+ /**
34
+ * Reads a scope's release windows once and returns the changelog items of every window, with what the unreleased
35
+ * window decides: its commits, its bump, and its diagnostics.
21
36
  *
22
- * Always invokes git-cliff: dry-run is the caller's concern (it governs whether the file write happens,
23
- * not whether git-cliff runs). This means dry-run exercises the full git-cliff toolchain and surfaces missing-binary,
24
- * malformed-config, and template-resolution failures earlier than before.
37
+ * A commit whose last `change-record` block records entries yields one item per entry routed to
38
+ * `options.workspaceDir`; any other commit is classified by its title through `classifyChangelogCommit`. A `release:`
39
+ * or merge subject yields nothing either way. The read records diagnostics only for the unreleased window, since the
40
+ * released windows were reported when they were prepared.
41
+ */
42
+ export declare function readReleaseHistory(config: ReleaseHistoryConfig, options: GenerateChangelogOptions): ReleaseHistory;
43
+ /** The configuration that `readReleaseHistory` reads. */
44
+ export type ReleaseHistoryConfig = Pick<ReleaseConfig, 'breakingPolicies' | 'changelogJson' | 'scopeAliases' | 'versionPatterns' | 'workTypes'>;
45
+ /** One read of a scope's release windows. */
46
+ export interface ReleaseHistory {
47
+ /** The newest matching tag that HEAD reaches; undefined when none does. */
48
+ previousTag: string | undefined;
49
+ /** Entries of the released windows, newest first; a window that doesn't yield any item contributes none. */
50
+ releasedEntries: ChangelogEntry[];
51
+ unreleased: UnreleasedWindowReading;
52
+ }
53
+ /** The unreleased window: its changelog sections and commits, and the bump and diagnostics that they determine. */
54
+ export interface UnreleasedWindowReading {
55
+ /** The highest bump that the window's items call for; undefined when the window doesn't yield any item. */
56
+ bump: ReleaseType | undefined;
57
+ /** The window's commits, newest first, without release commits. */
58
+ commits: RawCommit[];
59
+ /** The date of the window's entry, from the time of the read. */
60
+ date: string;
61
+ diagnostics: ChangelogDiagnostics;
62
+ /** The number of commits that yield at least one item. */
63
+ parsedCommitCount: number;
64
+ sections: ChangelogSection[];
65
+ /**
66
+ * Commits that don't yield any item and that neither an exclusion nor a diagnostic accounts for, newest first;
67
+ * undefined when none.
68
+ */
69
+ unparseableCommits: RawCommit[] | undefined;
70
+ }
71
+ /** Labels the unreleased window of `history` with `tag` and returns the entries of every window, newest first. */
72
+ export declare function toChangelogEntries(history: ReleaseHistory, tag: string): ChangelogEntry[];
73
+ /**
74
+ * Returns the entries that a direct release tagged `tag` records: those of `toChangelogEntries`, or, when the
75
+ * unreleased window doesn't yield any item, the synthetic "Forced version bump." entry dated `today` ahead of the
76
+ * released entries.
25
77
  */
26
- export declare function buildChangelogEntries(config: Pick<ReleaseConfig, 'breakingPolicies' | 'changelogJson' | 'cliffConfigPath' | 'workTypes'>, tag: string, options?: GenerateChangelogOptions): ChangelogEntry[];
78
+ export declare function toReleaseEntries(history: ReleaseHistory, tag: string, today: string): ChangelogEntry[];