@williamthorsen/release-kit 14.2.2 → 14.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.meta/changelog.json +50 -0
  2. package/.readyup/kits/default.js +135 -145
  3. package/.readyup/kits/npm-auto-publish.js +179 -180
  4. package/.readyup/manifest.json +31 -17
  5. package/CHANGELOG.md +16 -0
  6. package/README.md +7 -1
  7. package/dist/esm/applyChangelogOverrides.d.ts +50 -0
  8. package/dist/esm/applyChangelogOverrides.js +162 -0
  9. package/dist/esm/attachChangelogDiagnostics.d.ts +1 -1
  10. package/dist/esm/bin/release-kit.js +6 -238
  11. package/dist/esm/buildChangelogEntries.d.ts +20 -31
  12. package/dist/esm/buildChangelogEntries.js +71 -188
  13. package/dist/esm/buildChangelogItem.d.ts +56 -0
  14. package/dist/esm/buildChangelogItem.js +119 -0
  15. package/dist/esm/buildReleasedResult.d.ts +20 -0
  16. package/dist/esm/buildReleasedResult.js +78 -0
  17. package/dist/esm/changelogJsonUtils.d.ts +1 -1
  18. package/dist/esm/changelogOverrides.d.ts +29 -143
  19. package/dist/esm/changelogOverrides.js +35 -467
  20. package/dist/esm/configSchema.d.ts +225 -0
  21. package/dist/esm/configSchema.js +103 -0
  22. package/dist/esm/decideDirectReleases.d.ts +30 -0
  23. package/dist/esm/decideDirectReleases.js +66 -0
  24. package/dist/esm/defineConfig.d.ts +2 -2
  25. package/dist/esm/deriveReleaseNotesConfig.d.ts +2 -1
  26. package/dist/esm/deriveReleaseNotesConfig.js +1 -1
  27. package/dist/esm/formatPrepareFiles.d.ts +11 -0
  28. package/dist/esm/formatPrepareFiles.js +55 -0
  29. package/dist/esm/formatPrepareWarnings.d.ts +26 -0
  30. package/dist/esm/formatPrepareWarnings.js +72 -0
  31. package/dist/esm/help/initHelp.d.ts +4 -0
  32. package/dist/esm/help/initHelp.js +31 -0
  33. package/dist/esm/help/overridesHelp.d.ts +4 -0
  34. package/dist/esm/help/overridesHelp.js +32 -0
  35. package/dist/esm/help/releaseStepsHelp.d.ts +12 -0
  36. package/dist/esm/help/releaseStepsHelp.js +91 -0
  37. package/dist/esm/help/syncLabelsHelp.d.ts +8 -0
  38. package/dist/esm/help/syncLabelsHelp.js +55 -0
  39. package/dist/esm/help/usage.d.ts +2 -0
  40. package/dist/esm/help/usage.js +29 -0
  41. package/dist/esm/index.d.ts +1 -1
  42. package/dist/esm/index.js +1 -1
  43. package/dist/esm/loadChangelogOverrides.d.ts +31 -0
  44. package/dist/esm/loadChangelogOverrides.js +138 -0
  45. package/dist/esm/loadConfig.d.ts +0 -40
  46. package/dist/esm/loadConfig.js +0 -240
  47. package/dist/esm/loadValidatedConfig.d.ts +1 -1
  48. package/dist/esm/mergeConfig.d.ts +41 -0
  49. package/dist/esm/mergeConfig.js +118 -0
  50. package/dist/esm/monorepoConfigAssertions.d.ts +49 -0
  51. package/dist/esm/monorepoConfigAssertions.js +126 -0
  52. package/dist/esm/planChangelogFiles.d.ts +16 -0
  53. package/dist/esm/planChangelogFiles.js +41 -0
  54. package/dist/esm/prepareArgs.d.ts +55 -0
  55. package/dist/esm/prepareArgs.js +69 -0
  56. package/dist/esm/prepareCommand.d.ts +0 -48
  57. package/dist/esm/prepareCommand.js +6 -73
  58. package/dist/esm/prepareComposite.d.ts +16 -0
  59. package/dist/esm/prepareComposite.js +39 -0
  60. package/dist/esm/prepareRunContext.d.ts +38 -0
  61. package/dist/esm/prepareRunContext.js +39 -0
  62. package/dist/esm/prepareTarget.d.ts +2 -7
  63. package/dist/esm/prepareTarget.js +2 -118
  64. package/dist/esm/previewTagPrefixes.d.ts +1 -1
  65. package/dist/esm/releasePrepareTargets.js +13 -205
  66. package/dist/esm/reportPrepare.js +3 -125
  67. package/dist/esm/resolveCommandTags.d.ts +1 -1
  68. package/dist/esm/resolveCommandTags.js +2 -1
  69. package/dist/esm/resolveReleaseDeclaration.d.ts +2 -1
  70. package/dist/esm/resolveReleaseTargets.d.ts +2 -1
  71. package/dist/esm/resolveReleaseTargets.js +2 -1
  72. package/dist/esm/sync-labels/generateCommand.d.ts +1 -1
  73. package/dist/esm/sync-labels/resolveLabels.d.ts +1 -1
  74. package/dist/esm/topologicalSort.d.ts +12 -0
  75. package/dist/esm/topologicalSort.js +60 -0
  76. package/dist/esm/types.d.ts +1 -225
  77. package/dist/esm/types.js +1 -103
  78. package/dist/esm/validateAllChangelogOverrides.d.ts +56 -0
  79. package/dist/esm/validateAllChangelogOverrides.js +138 -0
  80. package/dist/esm/validateConfig.d.ts +1 -1
  81. package/dist/esm/validateConfig.js +7 -9
  82. package/dist/esm/validateOverridesCommand.d.ts +1 -1
  83. package/dist/esm/validateOverridesCommand.js +2 -1
  84. package/package.json +2 -2
@@ -1,68 +1,39 @@
1
+ import { applyChangelogOverrides } from './applyChangelogOverrides.js';
1
2
  import type { ChangelogEntry, ChangelogOverride } from './types.js';
2
- /** Known fields on a single override entry; presence of any other field is a validation error. */
3
- export declare const KNOWN_OVERRIDE_FIELDS: Set<string>;
4
- /** Form of an override key: a lowercase hex commit hash or prefix, optionally followed by `:<n>`, a 1-based entry position. */
5
- export declare const OVERRIDE_KEY_PATTERN: RegExp;
6
- /** Result of loading an override file: either parsed overrides or a list of structured errors. */
7
- export type LoadChangelogOverridesResult = {
8
- overrides: Map<string, ChangelogOverride>;
9
- } | {
10
- errors: string[];
11
- };
12
3
  /**
13
- * Loads and validates the editorial overrides file at `path`. A missing file yields an empty map; an unreadable file,
14
- * malformed JSON, a wrong top-level shape, or any per-entry validation failure yields errors.
4
+ * Applies the composed root and workspace override map to a target's changelog entries, and records stale keys by
5
+ * tier. A target without a workspace override file, such as the project, passes `undefined` for `workspacePath` and
6
+ * applies the root tier alone.
7
+ *
8
+ * A workspace key that matched nothing, whether or not the root map has the same key, is stale, and it is warned about
9
+ * at once. The function adds each root key that matched without being shadowed to `globalMatchedRootKeys`, from which
10
+ * the caller warns, at the end of the run, about the root keys that matched nowhere. Throws if applying reports any
11
+ * error, such as an ambiguous prefix.
15
12
  */
16
- export declare function loadChangelogOverrides(path: string): LoadChangelogOverridesResult;
13
+ export declare function applyWorkspaceOverrides(newEntries: ChangelogEntry[], workspacePath: string | undefined, overrideContext: OverrideContext): ReturnType<typeof applyChangelogOverrides>;
17
14
  /**
18
- * Validates a parsed override record, returning the valid overrides and an error message for each problem.
15
+ * Composes root and workspace override maps into the effective map for one workspace, without mutating either.
19
16
  *
20
- * Each error names the offending key (e.g. `overrides['abc']: 'audience' must be one of …`) so that the user can find
21
- * it in the override file.
17
+ * A workspace key identical to a root key replaces the root entry entirely, without a field-level merge. Distinct keys
18
+ * that resolve to the same item do not shadow each other here: {@link applyChangelogOverrides} reports them as
19
+ * overlapping.
22
20
  */
23
- export declare function validateChangelogOverrides(raw: unknown): {
24
- overrides: Map<string, ChangelogOverride>;
25
- errors: string[];
26
- };
27
- /** Splits a valid override key into its hash prefix and, for an ordinal key, its 1-based entry position. */
28
- export declare function parseOverrideKey(key: string): {
29
- hashPrefix: string;
30
- entry?: number;
31
- };
32
- /** Formats the warning for an override key that did not match any item in the changelog. */
33
- export declare function formatStaleOverrideKeyWarning(key: string): string;
21
+ export declare function composeOverrides(rootEntries: Map<string, ChangelogOverride>, workspaceEntries: Map<string, ChangelogOverride> | undefined): Map<string, ChangelogOverride>;
34
22
  /**
35
- * Applies overrides to changelog entries, returning new entries without mutating the input.
36
- *
37
- * Each key's hash prefix is matched against the distinct `ChangelogItem.hash` values:
38
- * - No match: The key is unmatched in this batch, and this function doesn't emit a warning.
39
- * - One match: A bare key resolves to every item of that commit, and an ordinal key `<hash>:<n>` to the items whose
40
- * `entry` is `n`. A key that doesn't resolve to any item is unmatched, so an ordinal key on a title-derived item
41
- * goes stale.
42
- * - Several matches: an error (ambiguous prefix).
43
- *
44
- * Two more conditions are errors, and the keys involved apply nowhere: a bare key that sets `description` or `body` on a
45
- * commit with several items, and two keys that resolve to the same item.
46
- *
47
- * `matchedKeys` lists the keys that resolved to at least one item without error. The caller computes stale-key
48
- * warnings, because in a monorepo a key may target a commit in another workspace: A key unmatched in one batch is not
49
- * necessarily stale.
50
- *
51
- * An override whose audience is `'skip'` removes its item, and a section left empty is dropped; an entry left without
52
- * sections is kept. An item without a `hash`, such as a synthetic propagation item, passes through unmatched. Errors
53
- * are returned rather than thrown, and the caller decides whether to abort.
23
+ * Loads and validates the override files of the root and of every workspace at the given repo-relative paths, and
24
+ * bundles them with empty warning aggregators. Throws if any file fails to load, so that a malformed checked-in
25
+ * override file stops `prepare` before any workspace writes.
54
26
  */
55
- export declare function applyChangelogOverrides(entries: ChangelogEntry[], overrides: Map<string, ChangelogOverride>): {
56
- entries: ChangelogEntry[];
57
- warnings: string[];
58
- errors: string[];
59
- matchedKeys: string[];
60
- };
27
+ export declare function createOverrideContext(workspacePaths: readonly string[]): OverrideContext;
61
28
  /**
62
- * Resolves the conventional override-file path for a scope root: the directory in which a scope's other artifacts live
63
- * (e.g., `'.'` for the project, `'packages/foo'` for a workspace). The returned path is repo-relative.
29
+ * Loads and validates the override file of every requested scope, collecting the errors of all files rather than
30
+ * stopping at the first, so that a user who edits several files sees every problem in one report. A missing file
31
+ * yields an empty map.
64
32
  */
65
- export declare function resolveOverridePath(scopeRoot: string): string;
33
+ export declare function loadOverridesForScopes(scopes: {
34
+ project?: string;
35
+ workspaces?: string[];
36
+ }): LoadOverridesForScopesResult;
66
37
  /** Result of {@link loadOverridesForScopes}: per-scope maps plus accumulated load/validation errors. */
67
38
  export interface LoadOverridesForScopesResult {
68
39
  /** Project-tier (root) overrides. Empty map when the project file is absent. */
@@ -72,23 +43,6 @@ export interface LoadOverridesForScopesResult {
72
43
  /** All load and validation errors across every requested scope, prefixed with the offending file path. */
73
44
  errors: string[];
74
45
  }
75
- /**
76
- * Loads and validates the override file of every requested scope, collecting the errors of all files rather than
77
- * stopping at the first, so that a user who edits several files sees every problem in one report. A missing file
78
- * yields an empty map.
79
- */
80
- export declare function loadOverridesForScopes(scopes: {
81
- project?: string;
82
- workspaces?: string[];
83
- }): LoadOverridesForScopesResult;
84
- /**
85
- * Composes root and workspace override maps into the effective map for one workspace, without mutating either.
86
- *
87
- * A workspace key identical to a root key replaces the root entry entirely, without a field-level merge. Distinct keys
88
- * that resolve to the same item do not shadow each other here: {@link applyChangelogOverrides} reports them as
89
- * overlapping.
90
- */
91
- export declare function composeOverrides(rootEntries: Map<string, ChangelogOverride>, workspaceEntries: Map<string, ChangelogOverride> | undefined): Map<string, ChangelogOverride>;
92
46
  /**
93
47
  * The loaded per-scope override maps and the run's warning aggregators, shared by every apply of a prepare run.
94
48
  *
@@ -102,75 +56,7 @@ export interface OverrideContext {
102
56
  globalMatchedRootKeys: Set<string>;
103
57
  }
104
58
  /**
105
- * Loads and validates the override files of the root and of every workspace at the given repo-relative paths, and
106
- * bundles them with empty warning aggregators. Throws if any file fails to load, so that a malformed checked-in
107
- * override file stops `prepare` before any workspace writes.
108
- */
109
- export declare function createOverrideContext(workspacePaths: readonly string[]): OverrideContext;
110
- /** A changelog item as override matching sees it. `entry` is absent for a title-derived item. */
111
- export interface OverrideTargetItem {
112
- hash: string;
113
- entry?: number;
114
- }
115
- /** Per-scope input to {@link validateAllChangelogOverrides}. */
116
- export interface ChangelogOverrideScope {
117
- /**
118
- * Path to the override file, used to load the file and to attribute findings. A relative path resolves against the
119
- * process working directory.
120
- */
121
- filePath: string;
122
- /** Items in this scope's history window. Each override key is matched against these. */
123
- items: readonly OverrideTargetItem[];
124
- }
125
- /** Inputs to {@link validateAllChangelogOverrides}. */
126
- export interface ValidateAllChangelogOverridesInputs {
127
- /**
128
- * Project-tier scope (the override file at the repo root).
129
- *
130
- * The file at `filePath` is loaded once and used in two ways:
131
- * - Its overrides are composed into every workspace's apply (root-tier overrides apply globally).
132
- * - When `items` is provided, the project map is also applied directly to those items
133
- * (project release in monorepo mode, or the package's history in single-package mode).
134
- *
135
- * Omit when the project file doesn't exist.
136
- */
137
- project?: {
138
- filePath: string;
139
- items?: readonly OverrideTargetItem[];
140
- };
141
- /** Per-workspace scopes. Each workspace's file applies only to its own items. */
142
- workspaces?: readonly ChangelogOverrideScope[];
143
- }
144
- /**
145
- * Result of {@link validateAllChangelogOverrides}: aggregated errors and warnings, each prefixed with the path of the
146
- * file to which it pertains.
147
- */
148
- export interface ValidateAllChangelogOverridesResult {
149
- errors: string[];
150
- warnings: string[];
151
- }
152
- /**
153
- * Validates every override file against the items of its scopes and returns the aggregated findings. It reads the
154
- * override files but doesn't collect any items: The caller supplies each scope's items.
155
- *
156
- * Items built by `buildChangelogEntries`, as `release-kit prepare` builds them, yield the matches that `prepare`
157
- * computes, tier asymmetry included: A workspace-tier key is stale when it matches nothing in its own workspace, and a
158
- * root-tier key only when it matches nothing in any scope, the project release window included.
159
- *
160
- * Every returned string is prefixed with the path of the override file to which it pertains.
161
- *
162
- * A relative `filePath`, in any scope, resolves against the process working directory, not against the repo root.
163
- * A caller running from elsewhere passes absolute paths or changes directory first.
164
- */
165
- export declare function validateAllChangelogOverrides(inputs: ValidateAllChangelogOverridesInputs): ValidateAllChangelogOverridesResult;
166
- /**
167
- * Applies the composed root and workspace override map to a target's changelog entries, and records stale keys by
168
- * tier. A target without a workspace override file, such as the project, passes `undefined` for `workspacePath` and
169
- * applies the root tier alone.
170
- *
171
- * A workspace key that matched nothing, whether or not the root map has the same key, is stale, and it is warned about
172
- * at once. The function adds each root key that matched without being shadowed to `globalMatchedRootKeys`, from which
173
- * the caller warns, at the end of the run, about the root keys that matched nowhere. Throws if applying reports any
174
- * error, such as an ambiguous prefix.
59
+ * Resolves the conventional override-file path for a scope root: the directory in which a scope's other artifacts live
60
+ * (e.g., `'.'` for the project, `'packages/foo'` for a workspace). The returned path is repo-relative.
175
61
  */
176
- export declare function applyWorkspaceOverrides(newEntries: ChangelogEntry[], workspacePath: string | undefined, overrideContext: OverrideContext): ReturnType<typeof applyChangelogOverrides>;
62
+ export declare function resolveOverridePath(scopeRoot: string): string;