@williamthorsen/release-kit 2.3.1 → 4.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 (43) hide show
  1. package/CHANGELOG.md +61 -37
  2. package/README.md +29 -12
  3. package/cliff.toml.template +16 -13
  4. package/dist/esm/.cache +1 -1
  5. package/dist/esm/bin/release-kit.js +28 -0
  6. package/dist/esm/buildDependencyGraph.d.ts +7 -0
  7. package/dist/esm/buildDependencyGraph.js +59 -0
  8. package/dist/esm/buildReleaseSummary.d.ts +2 -0
  9. package/dist/esm/buildReleaseSummary.js +22 -0
  10. package/dist/esm/commitCommand.d.ts +1 -0
  11. package/dist/esm/commitCommand.js +55 -0
  12. package/dist/esm/createTags.js +12 -1
  13. package/dist/esm/determineBumpFromCommits.d.ts +7 -0
  14. package/dist/esm/determineBumpFromCommits.js +26 -0
  15. package/dist/esm/generateChangelogs.d.ts +2 -0
  16. package/dist/esm/generateChangelogs.js +9 -1
  17. package/dist/esm/index.d.ts +5 -2
  18. package/dist/esm/index.js +10 -2
  19. package/dist/esm/init/initCommand.js +4 -2
  20. package/dist/esm/init/scaffold.js +3 -2
  21. package/dist/esm/init/templates.d.ts +1 -0
  22. package/dist/esm/init/templates.js +24 -2
  23. package/dist/esm/loadConfig.js +6 -6
  24. package/dist/esm/parseCommitMessage.d.ts +2 -1
  25. package/dist/esm/parseCommitMessage.js +19 -7
  26. package/dist/esm/prepareCommand.d.ts +1 -0
  27. package/dist/esm/prepareCommand.js +20 -0
  28. package/dist/esm/propagateBumps.d.ts +8 -0
  29. package/dist/esm/propagateBumps.js +54 -0
  30. package/dist/esm/publish.d.ts +1 -0
  31. package/dist/esm/publish.js +6 -3
  32. package/dist/esm/publishCommand.js +3 -2
  33. package/dist/esm/releasePrepare.js +10 -6
  34. package/dist/esm/releasePrepareMono.js +244 -52
  35. package/dist/esm/reportPrepare.js +46 -3
  36. package/dist/esm/stripScope.d.ts +1 -0
  37. package/dist/esm/stripScope.js +24 -0
  38. package/dist/esm/sync-labels/templates.js +1 -1
  39. package/dist/esm/types.d.ts +12 -4
  40. package/dist/esm/validateConfig.js +6 -6
  41. package/dist/esm/writeSyntheticChangelog.d.ts +9 -0
  42. package/dist/esm/writeSyntheticChangelog.js +27 -0
  43. package/package.json +1 -1
@@ -1,103 +1,295 @@
1
1
  import { execSync } from "node:child_process";
2
+ import { readFileSync } from "node:fs";
3
+ import { buildDependencyGraph } from "./buildDependencyGraph.js";
2
4
  import { bumpAllVersions } from "./bumpAllVersions.js";
3
5
  import { DEFAULT_VERSION_PATTERNS, DEFAULT_WORK_TYPES } from "./defaults.js";
4
- import { determineBumpType } from "./determineBumpType.js";
5
- import { generateChangelog } from "./generateChangelogs.js";
6
+ import { determineBumpFromCommits } from "./determineBumpFromCommits.js";
7
+ import { buildTagPattern, generateChangelog } from "./generateChangelogs.js";
6
8
  import { getCommitsSinceTarget } from "./getCommitsSinceTarget.js";
7
9
  import { hasPrettierConfig } from "./hasPrettierConfig.js";
8
- import { parseCommitMessage } from "./parseCommitMessage.js";
10
+ import { propagateBumps } from "./propagateBumps.js";
11
+ import { writeSyntheticChangelog } from "./writeSyntheticChangelog.js";
9
12
  function releasePrepareMono(config, options) {
10
- const { dryRun, force, bumpOverride } = options;
13
+ const { dryRun } = options;
14
+ const { directBumps, directResults, skippedResults, currentVersions } = determineDirectBumps(config, options);
15
+ const previousTags = /* @__PURE__ */ new Map();
16
+ for (const result of directResults.values()) {
17
+ previousTags.set(result.component.dir, result.tag);
18
+ }
19
+ for (const skipped of skippedResults) {
20
+ previousTags.set(skipped.component.dir, skipped.tag);
21
+ }
22
+ const graph = buildDependencyGraph(config.components);
23
+ const fullReleaseSet = propagateBumps(directBumps, graph, currentVersions);
24
+ const { sorted: sortedDirs, cyclicDirs } = topologicalSort(fullReleaseSet, graph);
25
+ const warnings = [];
26
+ if (cyclicDirs.length > 0) {
27
+ warnings.push(
28
+ `Circular workspace dependencies detected among: ${cyclicDirs.join(", ")}. Propagation metadata may be incomplete for these components.`
29
+ );
30
+ }
31
+ const components = collectSkippedComponents(skippedResults, fullReleaseSet);
32
+ const { tags, modifiedFiles } = executeReleaseSet(
33
+ sortedDirs,
34
+ fullReleaseSet,
35
+ config,
36
+ directResults,
37
+ previousTags,
38
+ dryRun,
39
+ components
40
+ );
41
+ const configOrder = new Map(config.components.map((c, i) => [c.dir, i]));
42
+ components.sort((a, b) => {
43
+ const orderA = configOrder.get(a.name ?? "") ?? 0;
44
+ const orderB = configOrder.get(b.name ?? "") ?? 0;
45
+ return orderA - orderB;
46
+ });
47
+ const formatCommand = runFormatCommand(config, tags, modifiedFiles, dryRun);
48
+ return {
49
+ components,
50
+ tags,
51
+ formatCommand,
52
+ dryRun,
53
+ ...warnings.length > 0 ? { warnings } : {}
54
+ };
55
+ }
56
+ function determineDirectBumps(config, options) {
57
+ const { force, bumpOverride } = options;
11
58
  const workTypes = config.workTypes ?? { ...DEFAULT_WORK_TYPES };
12
59
  const versionPatterns = config.versionPatterns ?? { ...DEFAULT_VERSION_PATTERNS };
13
- const tags = [];
14
- const modifiedFiles = [];
15
- const components = [];
60
+ const directBumps = /* @__PURE__ */ new Map();
61
+ const directResults = /* @__PURE__ */ new Map();
62
+ const skippedResults = [];
63
+ const currentVersions = /* @__PURE__ */ new Map();
16
64
  for (const component of config.components) {
17
65
  const name = component.dir;
18
66
  const { tag, commits } = getCommitsSinceTarget(component.tagPrefix, component.paths);
19
67
  const since = tag === void 0 ? "(no previous release found)" : `since ${tag}`;
68
+ const primaryPackageFile = component.packageFiles[0];
69
+ if (primaryPackageFile !== void 0) {
70
+ const currentVersion = readCurrentVersion(primaryPackageFile);
71
+ if (currentVersion !== void 0) {
72
+ currentVersions.set(component.dir, currentVersion);
73
+ }
74
+ }
20
75
  if (commits.length === 0 && !force) {
21
- components.push({
22
- name,
23
- status: "skipped",
24
- previousTag: tag,
76
+ skippedResults.push({
77
+ component,
78
+ tag,
25
79
  commitCount: 0,
26
- bumpedFiles: [],
27
- changelogFiles: [],
80
+ parsedCommitCount: void 0,
81
+ unparseableCommits: void 0,
28
82
  skipReason: `No changes for ${name} ${since}. Skipping.`
29
83
  });
30
84
  continue;
31
85
  }
32
86
  let releaseType;
33
87
  let parsedCommitCount;
88
+ let unparseableCommits;
34
89
  if (bumpOverride === void 0) {
35
- const parsedCommits = commits.map((c) => parseCommitMessage(c.message, c.hash, workTypes, config.workspaceAliases)).filter((c) => c !== void 0);
36
- parsedCommitCount = parsedCommits.length;
37
- releaseType = determineBumpType(parsedCommits, workTypes, versionPatterns);
90
+ const determination = determineBumpFromCommits(commits, workTypes, versionPatterns, config.scopeAliases);
91
+ parsedCommitCount = determination.parsedCommitCount;
92
+ unparseableCommits = determination.unparseableCommits;
93
+ releaseType = determination.releaseType;
38
94
  } else {
39
95
  releaseType = bumpOverride;
40
96
  }
41
97
  if (releaseType === void 0) {
42
- components.push({
43
- name,
44
- status: "skipped",
45
- previousTag: tag,
98
+ skippedResults.push({
99
+ component,
100
+ tag,
46
101
  commitCount: commits.length,
47
102
  parsedCommitCount,
48
- bumpedFiles: [],
49
- changelogFiles: [],
103
+ unparseableCommits,
50
104
  skipReason: `No release-worthy changes for ${name} ${since}. Skipping.`
51
105
  });
52
106
  continue;
53
107
  }
54
- const bump = bumpAllVersions(component.packageFiles, releaseType, dryRun);
108
+ directBumps.set(component.dir, { releaseType });
109
+ directResults.set(component.dir, {
110
+ component,
111
+ tag,
112
+ commits,
113
+ releaseType,
114
+ parsedCommitCount,
115
+ unparseableCommits
116
+ });
117
+ }
118
+ return { directBumps, directResults, skippedResults, currentVersions };
119
+ }
120
+ function collectSkippedComponents(skippedResults, fullReleaseSet) {
121
+ const components = [];
122
+ for (const skipped of skippedResults) {
123
+ if (fullReleaseSet.has(skipped.component.dir)) {
124
+ continue;
125
+ }
126
+ components.push({
127
+ name: skipped.component.dir,
128
+ status: "skipped",
129
+ previousTag: skipped.tag,
130
+ commitCount: skipped.commitCount,
131
+ parsedCommitCount: skipped.parsedCommitCount,
132
+ unparseableCommits: skipped.unparseableCommits,
133
+ bumpedFiles: [],
134
+ changelogFiles: [],
135
+ skipReason: skipped.skipReason
136
+ });
137
+ }
138
+ return components;
139
+ }
140
+ function executeReleaseSet(sortedDirs, fullReleaseSet, config, directResults, previousTags, dryRun, components) {
141
+ const tags = [];
142
+ const modifiedFiles = [];
143
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
144
+ for (const dir of sortedDirs) {
145
+ const releaseEntry = fullReleaseSet.get(dir);
146
+ if (releaseEntry === void 0) {
147
+ continue;
148
+ }
149
+ const component = findComponent(config.components, dir);
150
+ if (component === void 0) {
151
+ continue;
152
+ }
153
+ const bump = bumpAllVersions(component.packageFiles, releaseEntry.releaseType, dryRun);
55
154
  const newTag = `${component.tagPrefix}${bump.newVersion}`;
56
155
  tags.push(newTag);
57
156
  modifiedFiles.push(...component.packageFiles, ...component.changelogPaths.map((p) => `${p}/CHANGELOG.md`));
58
157
  const changelogFiles = [];
59
- for (const changelogPath of component.changelogPaths) {
60
- changelogFiles.push(
61
- ...generateChangelog(config, changelogPath, newTag, dryRun, { includePaths: component.paths })
62
- );
158
+ const directResult = directResults.get(dir);
159
+ const isPropagationOnly = directResult === void 0;
160
+ if (isPropagationOnly && releaseEntry.propagatedFrom !== void 0) {
161
+ for (const changelogPath of component.changelogPaths) {
162
+ changelogFiles.push(
163
+ writeSyntheticChangelog({
164
+ changelogPath,
165
+ newVersion: bump.newVersion,
166
+ date: today,
167
+ propagatedFrom: releaseEntry.propagatedFrom,
168
+ dryRun
169
+ })
170
+ );
171
+ }
172
+ } else {
173
+ for (const changelogPath of component.changelogPaths) {
174
+ changelogFiles.push(
175
+ ...generateChangelog(config, changelogPath, newTag, dryRun, {
176
+ tagPattern: buildTagPattern(component.tagPrefix),
177
+ includePaths: component.paths
178
+ })
179
+ );
180
+ }
63
181
  }
64
182
  components.push({
65
- name,
183
+ name: dir,
66
184
  status: "released",
67
- previousTag: tag,
68
- commitCount: commits.length,
69
- parsedCommitCount,
70
- releaseType,
185
+ previousTag: directResult?.tag ?? previousTags.get(dir),
186
+ commitCount: directResult?.commits.length ?? 0,
187
+ parsedCommitCount: directResult?.parsedCommitCount,
188
+ releaseType: releaseEntry.releaseType,
71
189
  currentVersion: bump.currentVersion,
72
190
  newVersion: bump.newVersion,
73
191
  tag: newTag,
74
192
  bumpedFiles: bump.files,
75
- changelogFiles
193
+ changelogFiles,
194
+ commits: directResult?.commits,
195
+ unparseableCommits: directResult?.unparseableCommits,
196
+ propagatedFrom: releaseEntry.propagatedFrom
76
197
  });
77
198
  }
199
+ return { tags, modifiedFiles };
200
+ }
201
+ function runFormatCommand(config, tags, modifiedFiles, dryRun) {
78
202
  const formatCommandStr = config.formatCommand ?? (hasPrettierConfig() ? "npx prettier --write" : void 0);
79
- let formatCommand;
80
- if (tags.length > 0 && formatCommandStr !== void 0) {
81
- const fullCommand = `${formatCommandStr} ${modifiedFiles.join(" ")}`;
82
- if (dryRun) {
83
- formatCommand = { command: fullCommand, executed: false, files: modifiedFiles };
84
- } else {
85
- try {
86
- execSync(fullCommand, { stdio: "inherit" });
87
- } catch (error) {
88
- throw new Error(
89
- `Format command failed ('${fullCommand}'): ${error instanceof Error ? error.message : String(error)}`
90
- );
203
+ if (tags.length === 0 || formatCommandStr === void 0) {
204
+ return void 0;
205
+ }
206
+ const fullCommand = `${formatCommandStr} ${modifiedFiles.join(" ")}`;
207
+ if (dryRun) {
208
+ return { command: fullCommand, executed: false, files: modifiedFiles };
209
+ }
210
+ try {
211
+ execSync(fullCommand, { stdio: "inherit" });
212
+ } catch (error) {
213
+ throw new Error(
214
+ `Format command failed ('${fullCommand}'): ${error instanceof Error ? error.message : String(error)}`
215
+ );
216
+ }
217
+ return { command: fullCommand, executed: true, files: modifiedFiles };
218
+ }
219
+ function findComponent(components, dir) {
220
+ return components.find((c) => c.dir === dir);
221
+ }
222
+ function hasVersionField(value) {
223
+ return typeof value === "object" && value !== null && "version" in value && typeof value.version === "string";
224
+ }
225
+ function readCurrentVersion(filePath) {
226
+ try {
227
+ const content = readFileSync(filePath, "utf8");
228
+ const parsed = JSON.parse(content);
229
+ if (hasVersionField(parsed)) {
230
+ return parsed.version;
231
+ }
232
+ } catch {
233
+ }
234
+ return void 0;
235
+ }
236
+ function topologicalSort(releaseSet, graph) {
237
+ const releaseDirs = new Set(releaseSet.keys());
238
+ if (releaseDirs.size === 0) {
239
+ return { sorted: [], cyclicDirs: [] };
240
+ }
241
+ const inDegree = /* @__PURE__ */ new Map();
242
+ const forwardEdges = /* @__PURE__ */ new Map();
243
+ for (const dir of releaseDirs) {
244
+ inDegree.set(dir, 0);
245
+ forwardEdges.set(dir, []);
246
+ }
247
+ for (const [packageName, dependents] of graph.dependentsOf) {
248
+ const depDir = graph.packageNameToDir.get(packageName);
249
+ if (depDir === void 0 || !releaseDirs.has(depDir)) {
250
+ continue;
251
+ }
252
+ for (const dependent of dependents) {
253
+ if (!releaseDirs.has(dependent.dir)) {
254
+ continue;
91
255
  }
92
- formatCommand = { command: fullCommand, executed: true, files: modifiedFiles };
256
+ const edges = forwardEdges.get(depDir);
257
+ if (edges !== void 0) {
258
+ edges.push(dependent.dir);
259
+ }
260
+ inDegree.set(dependent.dir, (inDegree.get(dependent.dir) ?? 0) + 1);
93
261
  }
94
262
  }
95
- return {
96
- components,
97
- tags,
98
- formatCommand,
99
- dryRun
100
- };
263
+ const queue = [];
264
+ for (const [dir, degree] of inDegree) {
265
+ if (degree === 0) {
266
+ queue.push(dir);
267
+ }
268
+ }
269
+ const sorted = [];
270
+ while (queue.length > 0) {
271
+ const dir = queue.shift();
272
+ if (dir === void 0) {
273
+ break;
274
+ }
275
+ sorted.push(dir);
276
+ for (const dependent of forwardEdges.get(dir) ?? []) {
277
+ const newDegree = (inDegree.get(dependent) ?? 1) - 1;
278
+ inDegree.set(dependent, newDegree);
279
+ if (newDegree === 0) {
280
+ queue.push(dependent);
281
+ }
282
+ }
283
+ }
284
+ const sortedSet = new Set(sorted);
285
+ const cyclicDirs = [];
286
+ for (const dir of releaseDirs) {
287
+ if (!sortedSet.has(dir)) {
288
+ sorted.push(dir);
289
+ cyclicDirs.push(dir);
290
+ }
291
+ }
292
+ return { sorted, cyclicDirs };
101
293
  }
102
294
  export {
103
295
  releasePrepareMono
@@ -17,6 +17,7 @@ function formatSingleComponent(result) {
17
17
  if (component.parsedCommitCount !== void 0) {
18
18
  lines.push(dim(` Parsed ${component.parsedCommitCount} typed commits`));
19
19
  }
20
+ formatUnparseableWarning(lines, component);
20
21
  if (component.status === "skipped") {
21
22
  lines.push(`\u23ED\uFE0F ${component.skipReason ?? "Skipped"}`);
22
23
  return lines.join("\n");
@@ -53,17 +54,26 @@ ${sectionHeader(component.name)}`);
53
54
  lines.push(` \u23ED\uFE0F ${component.skipReason ?? "Skipped"}`);
54
55
  continue;
55
56
  }
56
- if (component.parsedCommitCount !== void 0) {
57
+ const { propagatedFrom } = component;
58
+ const isPropagatedOnly = propagatedFrom !== void 0 && component.commitCount === 0;
59
+ if (isPropagatedOnly) {
60
+ const depNames = propagatedFrom.map((p) => p.packageName).join(", ");
61
+ lines.push(dim(` 0 commits (bumped via dependency: ${depNames})`));
62
+ } else if (component.parsedCommitCount !== void 0) {
57
63
  lines.push(dim(` Parsed ${component.parsedCommitCount} typed commits`));
58
64
  }
59
- if (component.parsedCommitCount === void 0 && component.releaseType !== void 0) {
65
+ formatUnparseableWarning(lines, component, " ");
66
+ if (component.parsedCommitCount === void 0 && component.releaseType !== void 0 && !isPropagatedOnly) {
60
67
  lines.push(` Using bump override: ${component.releaseType}`);
61
68
  }
62
69
  if (component.releaseType !== void 0) {
63
70
  lines.push(dim(` Bumping versions (${component.releaseType})...`));
64
71
  }
65
72
  if (component.currentVersion !== void 0 && component.newVersion !== void 0 && component.releaseType !== void 0) {
66
- lines.push(` \u{1F4E6} ${component.currentVersion} \u2192 ${bold(component.newVersion)} (${component.releaseType})`);
73
+ const suffix = isPropagatedOnly ? formatPropagationSuffix(propagatedFrom) : "";
74
+ lines.push(
75
+ ` \u{1F4E6} ${component.currentVersion} \u2192 ${bold(component.newVersion)} (${component.releaseType}${suffix})`
76
+ );
67
77
  }
68
78
  formatBumpFiles(lines, component, result.dryRun, " ");
69
79
  lines.push(dim(" Generating changelogs..."));
@@ -73,6 +83,7 @@ ${sectionHeader(component.name)}`);
73
83
  }
74
84
  }
75
85
  formatFormatCommand(lines, result);
86
+ formatWarnings(lines, result);
76
87
  if (result.tags.length > 0) {
77
88
  lines.push(`
78
89
  \u2705 Release preparation complete.`);
@@ -103,6 +114,38 @@ function formatChangelogFiles(lines, component, dryRun, indent = "") {
103
114
  }
104
115
  }
105
116
  }
117
+ function formatUnparseableWarning(lines, component, indent = "") {
118
+ const unparseable = component.unparseableCommits;
119
+ if (unparseable === void 0 || unparseable.length === 0) {
120
+ return;
121
+ }
122
+ const count = unparseable.length;
123
+ const isPatchFloor = component.parsedCommitCount === 0;
124
+ const suffix = isPatchFloor ? " (defaulting to patch bump)" : "";
125
+ lines.push(`${indent} \u26A0\uFE0F ${count} commit${count === 1 ? "" : "s"} could not be parsed${suffix}`);
126
+ for (const commit of unparseable) {
127
+ const shortHash = commit.hash.slice(0, 7);
128
+ const truncatedMessage = commit.message.length > 72 ? `${commit.message.slice(0, 69)}...` : commit.message;
129
+ lines.push(`${indent} \xB7 ${shortHash} ${truncatedMessage}`);
130
+ }
131
+ }
132
+ function formatPropagationSuffix(propagatedFrom) {
133
+ if (propagatedFrom === void 0 || propagatedFrom.length === 0) {
134
+ return "";
135
+ }
136
+ const names = propagatedFrom.map((p) => p.packageName).join(", ");
137
+ return `, dependency: ${names}`;
138
+ }
139
+ function formatWarnings(lines, result) {
140
+ const { warnings } = result;
141
+ if (warnings === void 0 || warnings.length === 0) {
142
+ return;
143
+ }
144
+ lines.push("");
145
+ for (const warning of warnings) {
146
+ lines.push(`\u26A0\uFE0F ${warning}`);
147
+ }
148
+ }
106
149
  function formatFormatCommand(lines, result) {
107
150
  if (result.formatCommand === void 0) {
108
151
  return;
@@ -0,0 +1 @@
1
+ export declare function stripScope(message: string): string;
@@ -0,0 +1,24 @@
1
+ import { COMMIT_PREPROCESSOR_PATTERNS } from "./parseCommitMessage.js";
2
+ function stripScope(message) {
3
+ let ticketPrefix = "";
4
+ let remainder = message;
5
+ for (const pattern of COMMIT_PREPROCESSOR_PATTERNS) {
6
+ const match = remainder.match(pattern);
7
+ if (match) {
8
+ ticketPrefix += match[0];
9
+ remainder = remainder.slice(match[0].length);
10
+ }
11
+ }
12
+ const pipeMatch = remainder.match(/^[^|]+\|(.*)$/);
13
+ if (pipeMatch) {
14
+ return `${ticketPrefix}${pipeMatch[1]}`;
15
+ }
16
+ const parenMatch = remainder.match(/^(\w+)\([^)]+\)(.*)$/);
17
+ if (parenMatch) {
18
+ return `${ticketPrefix}${parenMatch[1]}${parenMatch[2]}`;
19
+ }
20
+ return message;
21
+ }
22
+ export {
23
+ stripScope
24
+ };
@@ -8,7 +8,7 @@ on:
8
8
 
9
9
  jobs:
10
10
  sync:
11
- uses: williamthorsen/node-monorepo-tools/.github/workflows/sync-labels.yaml@sync-labels-v1
11
+ uses: williamthorsen/node-monorepo-tools/.github/workflows/sync-labels.reusable.yaml@sync-labels-workflow-v1
12
12
  `;
13
13
  }
14
14
  function buildScopeLabels(workspacePaths) {
@@ -1,4 +1,8 @@
1
1
  export type ReleaseType = 'major' | 'minor' | 'patch';
2
+ export interface PropagationSource {
3
+ packageName: string;
4
+ newVersion: string;
5
+ }
2
6
  export interface BumpResult {
3
7
  currentVersion: string;
4
8
  newVersion: string;
@@ -16,6 +20,9 @@ export interface ComponentPrepareResult {
16
20
  tag?: string | undefined;
17
21
  bumpedFiles: string[];
18
22
  changelogFiles: string[];
23
+ commits?: Commit[] | undefined;
24
+ unparseableCommits?: Commit[] | undefined;
25
+ propagatedFrom?: PropagationSource[] | undefined;
19
26
  skipReason?: string | undefined;
20
27
  }
21
28
  export interface PrepareResult {
@@ -27,6 +34,7 @@ export interface PrepareResult {
27
34
  files: string[];
28
35
  } | undefined;
29
36
  dryRun: boolean;
37
+ warnings?: string[] | undefined;
30
38
  }
31
39
  export interface WorkTypeConfig {
32
40
  header: string;
@@ -42,7 +50,7 @@ export interface ReleaseKitConfig {
42
50
  workTypes?: Record<string, WorkTypeConfig>;
43
51
  formatCommand?: string;
44
52
  cliffConfigPath?: string;
45
- workspaceAliases?: Record<string, string>;
53
+ scopeAliases?: Record<string, string>;
46
54
  }
47
55
  export interface ComponentOverride {
48
56
  dir: string;
@@ -57,7 +65,7 @@ export interface ParsedCommit {
57
65
  hash: string;
58
66
  type: string;
59
67
  description: string;
60
- workspace?: string;
68
+ scope?: string;
61
69
  breaking: boolean;
62
70
  }
63
71
  export interface ComponentConfig {
@@ -73,7 +81,7 @@ export interface MonorepoReleaseConfig {
73
81
  versionPatterns?: VersionPatterns;
74
82
  formatCommand?: string;
75
83
  cliffConfigPath?: string;
76
- workspaceAliases?: Record<string, string>;
84
+ scopeAliases?: Record<string, string>;
77
85
  }
78
86
  export interface ReleaseConfig {
79
87
  tagPrefix: string;
@@ -83,5 +91,5 @@ export interface ReleaseConfig {
83
91
  versionPatterns?: VersionPatterns;
84
92
  formatCommand?: string;
85
93
  cliffConfigPath?: string;
86
- workspaceAliases?: Record<string, string>;
94
+ scopeAliases?: Record<string, string>;
87
95
  }
@@ -11,7 +11,7 @@ function validateConfig(raw) {
11
11
  "workTypes",
12
12
  "formatCommand",
13
13
  "cliffConfigPath",
14
- "workspaceAliases"
14
+ "scopeAliases"
15
15
  ]);
16
16
  for (const key of Object.keys(raw)) {
17
17
  if (!knownFields.has(key)) {
@@ -23,7 +23,7 @@ function validateConfig(raw) {
23
23
  validateWorkTypes(raw.workTypes, config, errors);
24
24
  validateStringField("formatCommand", raw.formatCommand, config, errors);
25
25
  validateStringField("cliffConfigPath", raw.cliffConfigPath, config, errors);
26
- validateWorkspaceAliases(raw.workspaceAliases, config, errors);
26
+ validateScopeAliases(raw.scopeAliases, config, errors);
27
27
  return { config, errors };
28
28
  }
29
29
  function isStringArray(value) {
@@ -121,10 +121,10 @@ function validateStringField(fieldName, value, config, errors) {
121
121
  }
122
122
  config[fieldName] = value;
123
123
  }
124
- function validateWorkspaceAliases(value, config, errors) {
124
+ function validateScopeAliases(value, config, errors) {
125
125
  if (value === void 0) return;
126
126
  if (!isRecord(value)) {
127
- errors.push("'workspaceAliases' must be a record (object)");
127
+ errors.push("'scopeAliases' must be a record (object)");
128
128
  return;
129
129
  }
130
130
  const aliases = {};
@@ -133,12 +133,12 @@ function validateWorkspaceAliases(value, config, errors) {
133
133
  if (typeof v === "string") {
134
134
  aliases[key] = v;
135
135
  } else {
136
- errors.push(`workspaceAliases.${key}: value must be a string`);
136
+ errors.push(`scopeAliases.${key}: value must be a string`);
137
137
  valid = false;
138
138
  }
139
139
  }
140
140
  if (valid) {
141
- config.workspaceAliases = aliases;
141
+ config.scopeAliases = aliases;
142
142
  }
143
143
  }
144
144
  export {
@@ -0,0 +1,9 @@
1
+ import type { PropagationSource } from './types.ts';
2
+ export interface WriteSyntheticChangelogParams {
3
+ changelogPath: string;
4
+ newVersion: string;
5
+ date: string;
6
+ propagatedFrom: PropagationSource[];
7
+ dryRun?: boolean;
8
+ }
9
+ export declare function writeSyntheticChangelog(params: WriteSyntheticChangelogParams): string;
@@ -0,0 +1,27 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ function writeSyntheticChangelog(params) {
3
+ const { changelogPath, newVersion, date, propagatedFrom, dryRun } = params;
4
+ const filePath = `${changelogPath}/CHANGELOG.md`;
5
+ const bullets = propagatedFrom.map((dep) => `- Bumped \`${dep.packageName}\` to ${dep.newVersion}`).join("\n");
6
+ const section = `## ${newVersion} \u2014 ${date}
7
+
8
+ ### Dependency updates
9
+
10
+ ${bullets}
11
+ `;
12
+ if (dryRun) {
13
+ return filePath;
14
+ }
15
+ let existingContent = "";
16
+ if (existsSync(filePath)) {
17
+ existingContent = readFileSync(filePath, "utf8");
18
+ }
19
+ const newContent = existingContent.length > 0 ? `${section}
20
+ ${existingContent}` : `${section}
21
+ `;
22
+ writeFileSync(filePath, newContent, "utf8");
23
+ return filePath;
24
+ }
25
+ export {
26
+ writeSyntheticChangelog
27
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@williamthorsen/release-kit",
3
- "version": "2.3.1",
3
+ "version": "4.0.0",
4
4
  "description": "Version-bumping and changelog-generation toolkit for release workflows",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/williamthorsen/node-monorepo-tools/tree/main/packages/release-kit#readme",