@williamthorsen/release-kit 6.0.0 → 7.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 (134) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -3
  3. package/dist/esm/.cache +1 -1
  4. package/dist/esm/assertCleanWorkingTree.js +9 -14
  5. package/dist/esm/bin/release-kit.js +200 -199
  6. package/dist/esm/buildChangelogEntries.d.ts +2 -2
  7. package/dist/esm/buildChangelogEntries.js +142 -149
  8. package/dist/esm/buildDependencyGraph.d.ts +1 -1
  9. package/dist/esm/buildDependencyGraph.js +60 -59
  10. package/dist/esm/buildEmptyReleaseEntry.d.ts +1 -1
  11. package/dist/esm/buildEmptyReleaseEntry.js +12 -15
  12. package/dist/esm/buildReleaseSummary.d.ts +1 -1
  13. package/dist/esm/buildReleaseSummary.js +23 -26
  14. package/dist/esm/buildSyntheticChangelogEntry.d.ts +1 -1
  15. package/dist/esm/buildSyntheticChangelogEntry.js +9 -12
  16. package/dist/esm/bumpAllVersions.d.ts +1 -1
  17. package/dist/esm/bumpAllVersions.js +51 -52
  18. package/dist/esm/bumpVersion.d.ts +1 -1
  19. package/dist/esm/bumpVersion.js +25 -28
  20. package/dist/esm/changelogJsonFile.d.ts +1 -1
  21. package/dist/esm/changelogJsonFile.js +59 -62
  22. package/dist/esm/changelogJsonUtils.d.ts +1 -1
  23. package/dist/esm/changelogJsonUtils.js +35 -32
  24. package/dist/esm/changelogOverrides.d.ts +1 -1
  25. package/dist/esm/changelogOverrides.js +374 -377
  26. package/dist/esm/checkWorkTypesDrift.js +104 -102
  27. package/dist/esm/collectPolicyViolations.d.ts +2 -2
  28. package/dist/esm/collectPolicyViolations.js +11 -14
  29. package/dist/esm/commitCommand.js +48 -46
  30. package/dist/esm/compareVersions.js +20 -23
  31. package/dist/esm/createGithubRelease.js +56 -59
  32. package/dist/esm/createGithubReleaseCommand.js +21 -23
  33. package/dist/esm/createTags.js +57 -56
  34. package/dist/esm/decideRelease.d.ts +2 -2
  35. package/dist/esm/decideRelease.js +27 -41
  36. package/dist/esm/defaults.d.ts +3 -3
  37. package/dist/esm/defaults.js +36 -48
  38. package/dist/esm/deleteFileIfExists.js +10 -12
  39. package/dist/esm/deriveWorkspaceConfig.d.ts +1 -1
  40. package/dist/esm/deriveWorkspaceConfig.js +34 -36
  41. package/dist/esm/detectPackageManager.js +35 -37
  42. package/dist/esm/detectUndeclaredTagPrefixes.js +41 -40
  43. package/dist/esm/determineBumpFromCommits.d.ts +2 -2
  44. package/dist/esm/determineBumpFromCommits.js +25 -29
  45. package/dist/esm/determineBumpType.d.ts +1 -1
  46. package/dist/esm/determineBumpType.js +31 -32
  47. package/dist/esm/discoverWorkspaces.js +38 -40
  48. package/dist/esm/format.js +6 -11
  49. package/dist/esm/generateChangelogs.d.ts +1 -1
  50. package/dist/esm/generateChangelogs.js +13 -17
  51. package/dist/esm/getCommitsSinceTarget.d.ts +1 -1
  52. package/dist/esm/getCommitsSinceTarget.js +54 -55
  53. package/dist/esm/hasPrettierConfig.js +33 -35
  54. package/dist/esm/help/prepareHelp.js +4 -8
  55. package/dist/esm/index.d.ts +4 -4
  56. package/dist/esm/index.js +2 -8
  57. package/dist/esm/init/checks.js +28 -32
  58. package/dist/esm/init/detectRepoType.js +12 -15
  59. package/dist/esm/init/initCommand.js +60 -54
  60. package/dist/esm/init/parseJsonRecord.js +9 -11
  61. package/dist/esm/init/scaffold.d.ts +1 -1
  62. package/dist/esm/init/scaffold.js +32 -38
  63. package/dist/esm/init/templates.d.ts +1 -1
  64. package/dist/esm/init/templates.js +16 -22
  65. package/dist/esm/injectReleaseNotesIntoReadme.js +42 -49
  66. package/dist/esm/injectSection.js +17 -27
  67. package/dist/esm/loadConfig.d.ts +1 -1
  68. package/dist/esm/loadConfig.js +206 -225
  69. package/dist/esm/parseCommitMessage.d.ts +1 -1
  70. package/dist/esm/parseCommitMessage.js +72 -76
  71. package/dist/esm/parseRequestedTags.js +6 -9
  72. package/dist/esm/prepareCommand.d.ts +1 -1
  73. package/dist/esm/prepareCommand.js +225 -235
  74. package/dist/esm/previewTagPrefixes.d.ts +1 -1
  75. package/dist/esm/previewTagPrefixes.js +101 -96
  76. package/dist/esm/propagateBumps.d.ts +2 -2
  77. package/dist/esm/propagateBumps.js +48 -50
  78. package/dist/esm/publish.d.ts +2 -2
  79. package/dist/esm/publish.js +22 -28
  80. package/dist/esm/publishCommand.js +75 -80
  81. package/dist/esm/pushCommand.js +33 -34
  82. package/dist/esm/pushRelease.d.ts +1 -1
  83. package/dist/esm/pushRelease.js +21 -24
  84. package/dist/esm/readCurrentVersion.js +13 -17
  85. package/dist/esm/releasePrepare.d.ts +1 -1
  86. package/dist/esm/releasePrepare.js +213 -231
  87. package/dist/esm/releasePrepareMono.d.ts +2 -2
  88. package/dist/esm/releasePrepareMono.js +434 -494
  89. package/dist/esm/releasePrepareProject.d.ts +2 -2
  90. package/dist/esm/releasePrepareProject.js +143 -153
  91. package/dist/esm/renderChangelogMarkdown.d.ts +1 -1
  92. package/dist/esm/renderChangelogMarkdown.js +20 -24
  93. package/dist/esm/renderReleaseNotes.d.ts +1 -1
  94. package/dist/esm/renderReleaseNotes.js +50 -55
  95. package/dist/esm/reportPrepare.d.ts +1 -1
  96. package/dist/esm/reportPrepare.js +230 -231
  97. package/dist/esm/resolveCliffConfigPath.js +18 -23
  98. package/dist/esm/resolveCommandTags.d.ts +1 -1
  99. package/dist/esm/resolveCommandTags.js +47 -45
  100. package/dist/esm/resolveReleaseNotesConfig.d.ts +1 -1
  101. package/dist/esm/resolveReleaseNotesConfig.js +39 -43
  102. package/dist/esm/resolveReleaseTags.d.ts +1 -1
  103. package/dist/esm/resolveReleaseTags.js +39 -40
  104. package/dist/esm/runGitCliff.js +27 -30
  105. package/dist/esm/showTagPrefixesCommand.js +48 -70
  106. package/dist/esm/stripEmojiPrefix.js +2 -5
  107. package/dist/esm/stripScope.js +18 -21
  108. package/dist/esm/sync-labels/generateCommand.d.ts +1 -1
  109. package/dist/esm/sync-labels/generateCommand.js +51 -53
  110. package/dist/esm/sync-labels/initCommand.js +46 -48
  111. package/dist/esm/sync-labels/loadSyncLabelsConfig.d.ts +1 -1
  112. package/dist/esm/sync-labels/loadSyncLabelsConfig.js +46 -52
  113. package/dist/esm/sync-labels/presets.d.ts +1 -1
  114. package/dist/esm/sync-labels/presets.js +40 -43
  115. package/dist/esm/sync-labels/resolveLabels.d.ts +1 -1
  116. package/dist/esm/sync-labels/resolveLabels.js +28 -35
  117. package/dist/esm/sync-labels/syncCommand.js +30 -31
  118. package/dist/esm/sync-labels/templates.d.ts +1 -1
  119. package/dist/esm/sync-labels/templates.js +23 -26
  120. package/dist/esm/sync-labels/types.js +1 -0
  121. package/dist/esm/syncWorkTypes.js +83 -84
  122. package/dist/esm/tagCommand.js +12 -14
  123. package/dist/esm/typeGuards.js +4 -8
  124. package/dist/esm/types.js +66 -60
  125. package/dist/esm/validateConfig.d.ts +1 -1
  126. package/dist/esm/validateConfig.js +109 -115
  127. package/dist/esm/validateOnlyExcludesStrandedDependents.d.ts +2 -2
  128. package/dist/esm/validateOnlyExcludesStrandedDependents.js +97 -91
  129. package/dist/esm/validateOverridesCommand.d.ts +2 -2
  130. package/dist/esm/validateOverridesCommand.js +110 -111
  131. package/dist/esm/workTypesData.js +57 -60
  132. package/dist/esm/workTypesUtils.js +16 -21
  133. package/dist/esm/writeReleaseNotesPreviews.js +55 -57
  134. package/package.json +2 -2
@@ -6,174 +6,167 @@ import { runGitCliff } from "./runGitCliff.js";
6
6
  import { stripEmojiPrefix } from "./stripEmojiPrefix.js";
7
7
  import { isRecord, isUnknownArray } from "./typeGuards.js";
8
8
  const HTML_COMMENT_PREFIX_PATTERN = /^<!--[^>]*-->/;
9
- const CANONICAL_SECTION_ORDER = new Map(
10
- Object.values(DEFAULT_WORK_TYPES).map((config, index) => [stripGroupDecorations(config.header), index])
11
- );
9
+ const CANONICAL_SECTION_ORDER = new Map(Object.values(DEFAULT_WORK_TYPES).map((config, index) => [stripGroupDecorations(config.header), index]));
12
10
  function canonicalSectionPriority(title) {
13
- const index = CANONICAL_SECTION_ORDER.get(stripGroupDecorations(title));
14
- return index ?? Number.POSITIVE_INFINITY;
11
+ const index = CANONICAL_SECTION_ORDER.get(stripGroupDecorations(title));
12
+ return index ?? Number.POSITIVE_INFINITY;
15
13
  }
16
- function stripGroupDecorations(group) {
17
- return stripEmojiPrefix(group.replace(HTML_COMMENT_PREFIX_PATTERN, ""));
14
+ export function stripGroupDecorations(group) {
15
+ return stripEmojiPrefix(group.replace(HTML_COMMENT_PREFIX_PATTERN, ''));
18
16
  }
19
- function buildChangelogEntries(config, tag, options) {
20
- const resolvedConfigPath = resolveCliffConfigPath(config.cliffConfigPath, import.meta.url);
21
- const cliffArgs = ["--context", "--tag", tag];
22
- if (options?.tagPattern !== void 0) {
23
- cliffArgs.push("--tag-pattern", options.tagPattern);
24
- }
25
- for (const includePath of options?.includePaths ?? []) {
26
- cliffArgs.push("--include-path", includePath);
27
- }
28
- try {
29
- const contextJson = runGitCliff(resolvedConfigPath, cliffArgs, ["pipe", "pipe", "inherit"]);
30
- const releases = parseCliffContext(contextJson);
31
- const devOnlySections = new Set(config.changelogJson.devOnlySections);
32
- return transformReleases(releases, devOnlySections);
33
- } catch (error) {
34
- throw new Error(
35
- `Failed to build changelog entries for tag ${tag}: ${error instanceof Error ? error.message : String(error)}`
36
- );
37
- }
17
+ export function buildChangelogEntries(config, tag, options) {
18
+ const resolvedConfigPath = resolveCliffConfigPath(config.cliffConfigPath, import.meta.url);
19
+ const cliffArgs = ['--context', '--tag', tag];
20
+ if (options?.tagPattern !== undefined) {
21
+ cliffArgs.push('--tag-pattern', options.tagPattern);
22
+ }
23
+ for (const includePath of options?.includePaths ?? []) {
24
+ cliffArgs.push('--include-path', includePath);
25
+ }
26
+ try {
27
+ const contextJson = runGitCliff(resolvedConfigPath, cliffArgs, ['pipe', 'pipe', 'inherit']);
28
+ const releases = parseCliffContext(contextJson);
29
+ const devOnlySections = new Set(config.changelogJson.devOnlySections);
30
+ return transformReleases(releases, devOnlySections);
31
+ }
32
+ catch (error) {
33
+ throw new Error(`Failed to build changelog entries for tag ${tag}: ${error instanceof Error ? error.message : String(error)}`);
34
+ }
38
35
  }
39
36
  function parseCliffContext(json) {
40
- const parsed = JSON.parse(json);
41
- if (!isUnknownArray(parsed)) {
42
- throw new TypeError("Expected git-cliff --context output to be an array");
43
- }
44
- return parsed.map(toCliffContextRelease);
37
+ const parsed = JSON.parse(json);
38
+ if (!isUnknownArray(parsed)) {
39
+ throw new TypeError('Expected git-cliff --context output to be an array');
40
+ }
41
+ return parsed.map(toCliffContextRelease);
45
42
  }
46
43
  function toCliffContextRelease(value) {
47
- if (!isRecord(value)) {
48
- return {};
49
- }
50
- const release = {};
51
- if (typeof value.version === "string") {
52
- release.version = value.version;
53
- }
54
- if (typeof value.timestamp === "number") {
55
- release.timestamp = value.timestamp;
56
- }
57
- if (isUnknownArray(value.commits)) {
58
- release.commits = value.commits.map(toCliffContextCommit);
59
- }
60
- return release;
44
+ if (!isRecord(value)) {
45
+ return {};
46
+ }
47
+ const release = {};
48
+ if (typeof value.version === 'string') {
49
+ release.version = value.version;
50
+ }
51
+ if (typeof value.timestamp === 'number') {
52
+ release.timestamp = value.timestamp;
53
+ }
54
+ if (isUnknownArray(value.commits)) {
55
+ release.commits = value.commits.map(toCliffContextCommit);
56
+ }
57
+ return release;
61
58
  }
62
59
  function toCliffContextCommit(value) {
63
- if (!isRecord(value)) {
64
- return { message: "" };
65
- }
66
- const commit = {
67
- message: typeof value.message === "string" ? value.message : ""
68
- };
69
- if (typeof value.group === "string") {
70
- commit.group = value.group;
71
- }
72
- if (typeof value.id === "string") {
73
- commit.id = value.id;
74
- }
75
- return commit;
60
+ if (!isRecord(value)) {
61
+ return { message: '' };
62
+ }
63
+ const commit = {
64
+ message: typeof value.message === 'string' ? value.message : '',
65
+ };
66
+ if (typeof value.group === 'string') {
67
+ commit.group = value.group;
68
+ }
69
+ if (typeof value.id === 'string') {
70
+ commit.id = value.id;
71
+ }
72
+ return commit;
76
73
  }
77
74
  function transformReleases(releases, devOnlySections) {
78
- const entries = [];
79
- const devOnlyNormalised = new Set([...devOnlySections].map(stripGroupDecorations));
80
- for (const release of releases) {
81
- if (release.version === void 0) {
82
- continue;
83
- }
84
- const version = extractVersion(release.version);
85
- const date = release.timestamp !== void 0 ? new Date(release.timestamp * 1e3).toISOString().slice(0, 10) : "unreleased";
86
- const sectionMap = /* @__PURE__ */ new Map();
87
- for (const commit of release.commits ?? []) {
88
- const group = stripCommentPrefix(commit.group ?? "Other");
89
- const description = extractDescription(commit.message);
90
- const body = extractBody(commit.message);
91
- const breaking = subjectHasBreakingMarker(commit.message);
92
- let items = sectionMap.get(group);
93
- if (items === void 0) {
94
- items = [];
95
- sectionMap.set(group, items);
96
- }
97
- const item = { description };
98
- if (body !== void 0) {
99
- item.body = body;
100
- }
101
- if (breaking) {
102
- item.breaking = true;
103
- }
104
- if (commit.id !== void 0 && commit.id !== "") {
105
- item.hash = commit.id;
106
- }
107
- items.push(item);
108
- }
109
- const sections = [];
110
- for (const [title, items] of sectionMap) {
111
- if (items.length === 0) {
112
- continue;
113
- }
114
- sections.push({
115
- title,
116
- audience: devOnlyNormalised.has(stripGroupDecorations(title)) ? "dev" : "all",
117
- items
118
- });
119
- }
120
- sections.sort((a, b) => canonicalSectionPriority(a.title) - canonicalSectionPriority(b.title));
121
- if (sections.length > 0) {
122
- entries.push({ version, date, sections });
123
- }
124
- }
125
- return entries;
75
+ const entries = [];
76
+ const devOnlyNormalised = new Set([...devOnlySections].map(stripGroupDecorations));
77
+ for (const release of releases) {
78
+ if (release.version === undefined) {
79
+ continue;
80
+ }
81
+ const version = extractVersion(release.version);
82
+ const date = release.timestamp !== undefined ? new Date(release.timestamp * 1000).toISOString().slice(0, 10) : 'unreleased';
83
+ const sectionMap = new Map();
84
+ for (const commit of release.commits ?? []) {
85
+ const group = stripCommentPrefix(commit.group ?? 'Other');
86
+ const description = extractDescription(commit.message);
87
+ const body = extractBody(commit.message);
88
+ const breaking = subjectHasBreakingMarker(commit.message);
89
+ let items = sectionMap.get(group);
90
+ if (items === undefined) {
91
+ items = [];
92
+ sectionMap.set(group, items);
93
+ }
94
+ const item = { description };
95
+ if (body !== undefined) {
96
+ item.body = body;
97
+ }
98
+ if (breaking) {
99
+ item.breaking = true;
100
+ }
101
+ if (commit.id !== undefined && commit.id !== '') {
102
+ item.hash = commit.id;
103
+ }
104
+ items.push(item);
105
+ }
106
+ const sections = [];
107
+ for (const [title, items] of sectionMap) {
108
+ if (items.length === 0) {
109
+ continue;
110
+ }
111
+ sections.push({
112
+ title,
113
+ audience: devOnlyNormalised.has(stripGroupDecorations(title)) ? 'dev' : 'all',
114
+ items,
115
+ });
116
+ }
117
+ sections.sort((a, b) => canonicalSectionPriority(a.title) - canonicalSectionPriority(b.title));
118
+ if (sections.length > 0) {
119
+ entries.push({ version, date, sections });
120
+ }
121
+ }
122
+ return entries;
126
123
  }
127
124
  function stripCommentPrefix(group) {
128
- return group.replace(HTML_COMMENT_PREFIX_PATTERN, "");
125
+ return group.replace(HTML_COMMENT_PREFIX_PATTERN, '');
129
126
  }
130
127
  function subjectHasBreakingMarker(message) {
131
- let subject = message.split("\n", 1)[0] ?? "";
132
- for (const pattern of COMMIT_PREPROCESSOR_PATTERNS) {
133
- subject = subject.replace(pattern, "");
134
- }
135
- return /^(?:[^|]+\|)?\w+(?:\([^)]+\))?!:/.test(subject);
128
+ let subject = message.split('\n', 1)[0] ?? '';
129
+ for (const pattern of COMMIT_PREPROCESSOR_PATTERNS) {
130
+ subject = subject.replace(pattern, '');
131
+ }
132
+ return /^(?:[^|]+\|)?\w+(?:\([^)]+\))?!:/.test(subject);
136
133
  }
137
134
  function extractDescription(message) {
138
- const firstLine = message.split("\n")[0] ?? message;
139
- const afterColon = firstLine.split(": ").slice(1).join(": ");
140
- if (afterColon.length > 0) {
141
- return afterColon.charAt(0).toUpperCase() + afterColon.slice(1);
142
- }
143
- return firstLine;
135
+ const firstLine = message.split('\n')[0] ?? message;
136
+ const afterColon = firstLine.split(': ').slice(1).join(': ');
137
+ if (afterColon.length > 0) {
138
+ return afterColon.charAt(0).toUpperCase() + afterColon.slice(1);
139
+ }
140
+ return firstLine;
144
141
  }
145
142
  const TRAILER_PATTERNS = [
146
- /^Signed-off-by:/i,
147
- /^Co-authored-by:/i,
148
- /^(Closes|Fixes|Resolves)\s+#\d+\s*$/i,
149
- /^https?:\/\/\S+\/pull\/\d+\/?\s*$/
143
+ /^Signed-off-by:/i,
144
+ /^Co-authored-by:/i,
145
+ /^(Closes|Fixes|Resolves)\s+#\d+\s*$/i,
146
+ /^https?:\/\/\S+\/pull\/\d+\/?\s*$/,
150
147
  ];
151
148
  function extractBody(message) {
152
- const lines = message.split("\n").slice(1);
153
- let start = 0;
154
- while (start < lines.length && (lines[start] ?? "").trim() === "") {
155
- start += 1;
156
- }
157
- let end = lines.length;
158
- while (end > start) {
159
- const line = lines[end - 1] ?? "";
160
- const trimmed = line.trim();
161
- if (trimmed === "") {
162
- end -= 1;
163
- continue;
164
- }
165
- if (TRAILER_PATTERNS.some((pattern) => pattern.test(trimmed))) {
166
- end -= 1;
167
- continue;
168
- }
169
- break;
170
- }
171
- if (end <= start) {
172
- return void 0;
173
- }
174
- return lines.slice(start, end).join("\n").trim();
149
+ const lines = message.split('\n').slice(1);
150
+ let start = 0;
151
+ while (start < lines.length && (lines[start] ?? '').trim() === '') {
152
+ start += 1;
153
+ }
154
+ let end = lines.length;
155
+ while (end > start) {
156
+ const line = lines[end - 1] ?? '';
157
+ const trimmed = line.trim();
158
+ if (trimmed === '') {
159
+ end -= 1;
160
+ continue;
161
+ }
162
+ if (TRAILER_PATTERNS.some((pattern) => pattern.test(trimmed))) {
163
+ end -= 1;
164
+ continue;
165
+ }
166
+ break;
167
+ }
168
+ if (end <= start) {
169
+ return undefined;
170
+ }
171
+ return lines.slice(start, end).join('\n').trim();
175
172
  }
176
- export {
177
- buildChangelogEntries,
178
- stripGroupDecorations
179
- };
@@ -1,4 +1,4 @@
1
- import type { WorkspaceConfig } from './types.ts';
1
+ import type { WorkspaceConfig } from './types.js';
2
2
  export interface DependencyGraph {
3
3
  packageNameToDir: Map<string, string>;
4
4
  dirToPackageName: Map<string, string>;
@@ -1,66 +1,67 @@
1
- import { readFileSync } from "node:fs";
1
+ import { readFileSync } from 'node:fs';
2
2
  function isPackageJsonSubset(value) {
3
- return typeof value === "object" && value !== null;
3
+ return typeof value === 'object' && value !== null;
4
4
  }
5
- function buildDependencyGraph(workspaces) {
6
- const packageNameToDir = /* @__PURE__ */ new Map();
7
- const dirToPackageName = /* @__PURE__ */ new Map();
8
- const dependentsOf = /* @__PURE__ */ new Map();
9
- const dependenciesOf = /* @__PURE__ */ new Map();
10
- const workspacePackages = /* @__PURE__ */ new Map();
11
- for (const workspace of workspaces) {
12
- const primaryPackageFile = workspace.packageFiles[0];
13
- if (primaryPackageFile === void 0) {
14
- continue;
5
+ export function buildDependencyGraph(workspaces) {
6
+ const packageNameToDir = new Map();
7
+ const dirToPackageName = new Map();
8
+ const dependentsOf = new Map();
9
+ const dependenciesOf = new Map();
10
+ const workspacePackages = new Map();
11
+ for (const workspace of workspaces) {
12
+ const primaryPackageFile = workspace.packageFiles[0];
13
+ if (primaryPackageFile === undefined) {
14
+ continue;
15
+ }
16
+ const pkg = readPackageJsonSubset(primaryPackageFile);
17
+ workspacePackages.set(workspace, pkg);
18
+ if (pkg.name === undefined) {
19
+ continue;
20
+ }
21
+ packageNameToDir.set(pkg.name, workspace.dir);
22
+ dirToPackageName.set(workspace.dir, pkg.name);
15
23
  }
16
- const pkg = readPackageJsonSubset(primaryPackageFile);
17
- workspacePackages.set(workspace, pkg);
18
- if (pkg.name === void 0) {
19
- continue;
24
+ for (const [workspace, pkg] of workspacePackages) {
25
+ const allDeps = { ...pkg.dependencies, ...pkg.peerDependencies };
26
+ for (const [depName, depVersion] of Object.entries(allDeps)) {
27
+ if (typeof depVersion !== 'string' || !depVersion.startsWith('workspace:')) {
28
+ continue;
29
+ }
30
+ const existing = dependentsOf.get(depName);
31
+ if (existing === undefined) {
32
+ dependentsOf.set(depName, [workspace]);
33
+ }
34
+ else {
35
+ existing.push(workspace);
36
+ }
37
+ const forward = dependenciesOf.get(workspace.dir);
38
+ if (forward === undefined) {
39
+ dependenciesOf.set(workspace.dir, new Set([depName]));
40
+ }
41
+ else {
42
+ forward.add(depName);
43
+ }
44
+ }
20
45
  }
21
- packageNameToDir.set(pkg.name, workspace.dir);
22
- dirToPackageName.set(workspace.dir, pkg.name);
23
- }
24
- for (const [workspace, pkg] of workspacePackages) {
25
- const allDeps = { ...pkg.dependencies, ...pkg.peerDependencies };
26
- for (const [depName, depVersion] of Object.entries(allDeps)) {
27
- if (typeof depVersion !== "string" || !depVersion.startsWith("workspace:")) {
28
- continue;
29
- }
30
- const existing = dependentsOf.get(depName);
31
- if (existing === void 0) {
32
- dependentsOf.set(depName, [workspace]);
33
- } else {
34
- existing.push(workspace);
35
- }
36
- const forward = dependenciesOf.get(workspace.dir);
37
- if (forward === void 0) {
38
- dependenciesOf.set(workspace.dir, /* @__PURE__ */ new Set([depName]));
39
- } else {
40
- forward.add(depName);
41
- }
42
- }
43
- }
44
- return { packageNameToDir, dirToPackageName, dependentsOf, dependenciesOf };
46
+ return { packageNameToDir, dirToPackageName, dependentsOf, dependenciesOf };
45
47
  }
46
48
  function readPackageJsonSubset(filePath) {
47
- let content;
48
- try {
49
- content = readFileSync(filePath, "utf8");
50
- } catch (error) {
51
- throw new Error(`Failed to read ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
52
- }
53
- let parsed;
54
- try {
55
- parsed = JSON.parse(content);
56
- } catch (error) {
57
- throw new Error(`Failed to parse JSON in ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
58
- }
59
- if (!isPackageJsonSubset(parsed)) {
60
- throw new Error(`Invalid package.json at ${filePath}`);
61
- }
62
- return parsed;
49
+ let content;
50
+ try {
51
+ content = readFileSync(filePath, 'utf8');
52
+ }
53
+ catch (error) {
54
+ throw new Error(`Failed to read ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
55
+ }
56
+ let parsed;
57
+ try {
58
+ parsed = JSON.parse(content);
59
+ }
60
+ catch (error) {
61
+ throw new Error(`Failed to parse JSON in ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
62
+ }
63
+ if (!isPackageJsonSubset(parsed)) {
64
+ throw new Error(`Invalid package.json at ${filePath}`);
65
+ }
66
+ return parsed;
63
67
  }
64
- export {
65
- buildDependencyGraph
66
- };
@@ -1,2 +1,2 @@
1
- import type { ChangelogEntry } from './types.ts';
1
+ import type { ChangelogEntry } from './types.js';
2
2
  export declare function buildEmptyReleaseEntry(version: string, date: string): ChangelogEntry;
@@ -1,16 +1,13 @@
1
- function buildEmptyReleaseEntry(version, date) {
2
- return {
3
- version,
4
- date,
5
- sections: [
6
- {
7
- title: "Notes",
8
- audience: "dev",
9
- items: [{ description: "Forced version bump." }]
10
- }
11
- ]
12
- };
1
+ export function buildEmptyReleaseEntry(version, date) {
2
+ return {
3
+ version,
4
+ date,
5
+ sections: [
6
+ {
7
+ title: 'Notes',
8
+ audience: 'dev',
9
+ items: [{ description: 'Forced version bump.' }],
10
+ },
11
+ ],
12
+ };
13
13
  }
14
- export {
15
- buildEmptyReleaseEntry
16
- };
@@ -1,2 +1,2 @@
1
- import type { PrepareResult } from './types.ts';
1
+ import type { PrepareResult } from './types.js';
2
2
  export declare function buildReleaseSummary(result: PrepareResult): string;
@@ -1,30 +1,27 @@
1
1
  import { stripScope } from "./stripScope.js";
2
- function buildReleaseSummary(result) {
3
- const sections = [];
4
- for (const workspace of result.workspaces) {
5
- if (workspace.status !== "released") {
6
- continue;
2
+ export function buildReleaseSummary(result) {
3
+ const sections = [];
4
+ for (const workspace of result.workspaces) {
5
+ if (workspace.status !== 'released') {
6
+ continue;
7
+ }
8
+ const commits = workspace.commits;
9
+ if (commits === undefined || commits.length === 0) {
10
+ continue;
11
+ }
12
+ const lines = [workspace.tag];
13
+ for (const commit of commits) {
14
+ lines.push(`- ${stripScope(commit.message)}`);
15
+ }
16
+ sections.push(lines.join('\n'));
7
17
  }
8
- const commits = workspace.commits;
9
- if (commits === void 0 || commits.length === 0) {
10
- continue;
18
+ const project = result.project;
19
+ if (project !== undefined && project.status === 'released' && project.commits.length > 0) {
20
+ const lines = [project.tag];
21
+ for (const commit of project.commits) {
22
+ lines.push(`- ${stripScope(commit.message)}`);
23
+ }
24
+ sections.push(lines.join('\n'));
11
25
  }
12
- const lines = [workspace.tag];
13
- for (const commit of commits) {
14
- lines.push(`- ${stripScope(commit.message)}`);
15
- }
16
- sections.push(lines.join("\n"));
17
- }
18
- const project = result.project;
19
- if (project !== void 0 && project.status === "released" && project.commits.length > 0) {
20
- const lines = [project.tag];
21
- for (const commit of project.commits) {
22
- lines.push(`- ${stripScope(commit.message)}`);
23
- }
24
- sections.push(lines.join("\n"));
25
- }
26
- return sections.join("\n\n");
26
+ return sections.join('\n\n');
27
27
  }
28
- export {
29
- buildReleaseSummary
30
- };
@@ -1,4 +1,4 @@
1
- import type { ChangelogEntry } from './types.ts';
1
+ import type { ChangelogEntry } from './types.js';
2
2
  export declare function buildSyntheticChangelogEntry(propagatedFrom: ReadonlyArray<{
3
3
  packageName: string;
4
4
  newVersion: string;
@@ -1,13 +1,10 @@
1
- function buildSyntheticChangelogEntry(propagatedFrom, version, date) {
2
- const items = propagatedFrom.map((dep) => ({
3
- description: `Bumped \`${dep.packageName}\` to ${dep.newVersion}`
4
- }));
5
- return {
6
- version,
7
- date,
8
- sections: [{ title: "Dependency updates", audience: "dev", items }]
9
- };
1
+ export function buildSyntheticChangelogEntry(propagatedFrom, version, date) {
2
+ const items = propagatedFrom.map((dep) => ({
3
+ description: `Bumped \`${dep.packageName}\` to ${dep.newVersion}`,
4
+ }));
5
+ return {
6
+ version,
7
+ date,
8
+ sections: [{ title: 'Dependency updates', audience: 'dev', items }],
9
+ };
10
10
  }
11
- export {
12
- buildSyntheticChangelogEntry
13
- };
@@ -1,3 +1,3 @@
1
- import type { BumpResult, ReleaseType } from './types.ts';
1
+ import type { BumpResult, ReleaseType } from './types.js';
2
2
  export declare function bumpAllVersions(packageFiles: readonly string[], releaseType: ReleaseType, dryRun: boolean): BumpResult;
3
3
  export declare function setAllVersions(packageFiles: readonly string[], newVersion: string, dryRun: boolean): BumpResult;