@releasekit/notes 0.41.2 → 0.42.1
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.
- package/dist/{aggregator-NMUD72J2.js → aggregator-DYYIWNIK.js} +2 -4
- package/dist/{chunk-FI3F2ND5.js → chunk-CBMVDKDR.js} +211 -64
- package/dist/{chunk-YO6KWOCB.js → chunk-KQQPQQSS.js} +7 -22
- package/dist/{chunk-2PRVRNSI.js → chunk-OTH3XXI4.js} +496 -269
- package/dist/cli.d.ts +5 -9
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +400 -9
- package/dist/index.js +3 -3
- package/docs/configuration.md +1 -1
- package/package.json +22 -22
- package/templates/angular/entry.hbs +1 -1
- package/templates/github-release/release.md.ejs +1 -1
- package/templates/keep-a-changelog/entry.liquid +1 -1
- package/templates/keep-a-changelog/version.liquid +6 -6
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
aggregateToRoot,
|
|
3
3
|
detectMonorepo,
|
|
4
|
-
splitByPackage,
|
|
5
4
|
writeMonorepoChangelogs
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-KQQPQQSS.js";
|
|
6
|
+
import "./chunk-CBMVDKDR.js";
|
|
8
7
|
export {
|
|
9
8
|
aggregateToRoot,
|
|
10
9
|
detectMonorepo,
|
|
11
|
-
splitByPackage,
|
|
12
10
|
writeMonorepoChangelogs
|
|
13
11
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// ../core/dist/index.js
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import * as TOML from "smol-toml";
|
|
4
5
|
import * as fs2 from "fs";
|
|
5
6
|
import * as path2 from "path";
|
|
6
7
|
import { fileURLToPath } from "url";
|
|
@@ -8,29 +9,41 @@ import chalk from "chalk";
|
|
|
8
9
|
import { minimatch } from "minimatch";
|
|
9
10
|
import * as path3 from "path";
|
|
10
11
|
function parseGitHubOwnerRepo(repoUrl) {
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
12
|
+
const [, scpOwner, scpRepo] = repoUrl.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/) ?? [];
|
|
13
|
+
if (scpOwner && scpRepo) {
|
|
14
|
+
return { owner: scpOwner, repo: scpRepo };
|
|
15
|
+
}
|
|
13
16
|
try {
|
|
14
17
|
const url = new URL(repoUrl);
|
|
15
|
-
if (url.hostname !== "github.com")
|
|
18
|
+
if (url.hostname !== "github.com") {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
16
21
|
const parts = url.pathname.replace(/^\//, "").replace(/\.git$/, "").split("/");
|
|
17
|
-
if (parts.length >= 2 && parts[0] && parts[1])
|
|
22
|
+
if (parts.length >= 2 && parts[0] && parts[1]) {
|
|
23
|
+
return { owner: parts[0], repo: parts[1] };
|
|
24
|
+
}
|
|
18
25
|
} catch {
|
|
19
26
|
}
|
|
20
27
|
return null;
|
|
21
28
|
}
|
|
22
29
|
function renderIssueRefs(issueIds, mode, repoUrl, prNumber) {
|
|
23
|
-
if (mode === "strip")
|
|
30
|
+
if (mode === "strip") {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
24
33
|
const ids = issueIds ?? [];
|
|
25
34
|
const allIds = prNumber && !ids.some((id) => Number(id.replace(/^#/, "")) === Number(prNumber.replace(/^#/, ""))) ? [prNumber, ...ids] : ids;
|
|
26
|
-
if (allIds.length === 0)
|
|
35
|
+
if (allIds.length === 0) {
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
27
38
|
const ownerRepo = mode === "link" && repoUrl ? parseGitHubOwnerRepo(repoUrl) : null;
|
|
28
39
|
if (ownerRepo && prNumber) {
|
|
29
40
|
const { owner, repo } = ownerRepo;
|
|
30
41
|
const pr = prNumber.replace(/^#/, "");
|
|
31
42
|
const prPart = `PR [#${pr}](https://github.com/${owner}/${repo}/pull/${pr})`;
|
|
32
43
|
const closes = allIds.map((raw) => raw.replace(/^#/, "")).filter((num) => Number(num) !== Number(pr));
|
|
33
|
-
if (closes.length === 0)
|
|
44
|
+
if (closes.length === 0) {
|
|
45
|
+
return `(${prPart})`;
|
|
46
|
+
}
|
|
34
47
|
const closesPart = closes.map((num) => `[#${num}](https://github.com/${owner}/${repo}/issues/${num})`).join(", ");
|
|
35
48
|
return `(${prPart} \xB7 closes ${closesPart})`;
|
|
36
49
|
}
|
|
@@ -52,24 +65,25 @@ function neutralizeDescriptionRefs(text, appendedRefs, mode, repoUrl) {
|
|
|
52
65
|
CODE_SPAN_OR_DESC_REF,
|
|
53
66
|
(match, lead, parenNum, bareNum) => {
|
|
54
67
|
const num = parenNum ?? bareNum;
|
|
55
|
-
if (num === void 0)
|
|
68
|
+
if (num === void 0) {
|
|
69
|
+
return match;
|
|
70
|
+
}
|
|
56
71
|
const ws = lead ?? "";
|
|
57
|
-
if (appended.has(Number(num)) || mode === "strip")
|
|
72
|
+
if (appended.has(Number(num)) || mode === "strip") {
|
|
73
|
+
return "";
|
|
74
|
+
}
|
|
58
75
|
const inner = ownerRepo ? `[#${num}](https://github.com/${ownerRepo.owner}/${ownerRepo.repo}/issues/${num})` : `\\#${num}`;
|
|
59
76
|
return parenNum !== void 0 ? `${ws}(${inner})` : `${ws}${inner}`;
|
|
60
77
|
}
|
|
61
78
|
);
|
|
62
79
|
return out.trim();
|
|
63
80
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} catch {
|
|
71
|
-
return "0.0.0";
|
|
72
|
-
}
|
|
81
|
+
function removeDescriptionRefs(text, refs) {
|
|
82
|
+
const remove = new Set(refs.filter((r) => !!r).map((r) => Number(r.replace(/^#/, ""))));
|
|
83
|
+
return text.replace(CODE_SPAN_OR_DESC_REF, (match, _lead, parenNum, bareNum) => {
|
|
84
|
+
const num = parenNum ?? bareNum;
|
|
85
|
+
return num !== void 0 && remove.has(Number(num)) ? "" : match;
|
|
86
|
+
}).trim();
|
|
73
87
|
}
|
|
74
88
|
var LOG_LEVELS = {
|
|
75
89
|
error: 0,
|
|
@@ -106,12 +120,18 @@ function setQuietMode(quiet) {
|
|
|
106
120
|
quietMode = quiet;
|
|
107
121
|
}
|
|
108
122
|
function shouldLog(level) {
|
|
109
|
-
if (quietMode && level !== "error")
|
|
110
|
-
|
|
123
|
+
if (quietMode && level !== "error") {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (level === "debug" && (process.env.DEBUG === "true" || process.env.DEBUG === "1")) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
111
129
|
return LOG_LEVELS[level] <= LOG_LEVELS[currentLevel];
|
|
112
130
|
}
|
|
113
131
|
function log(message, level = "info") {
|
|
114
|
-
if (!shouldLog(level))
|
|
132
|
+
if (!shouldLog(level)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
115
135
|
const formatted = COLORS[level](`${PREFIXES[level]} ${message}`);
|
|
116
136
|
console.error(formatted);
|
|
117
137
|
}
|
|
@@ -125,16 +145,20 @@ function info(message) {
|
|
|
125
145
|
log(message, "info");
|
|
126
146
|
}
|
|
127
147
|
function success(message) {
|
|
128
|
-
if (!shouldLog("info"))
|
|
148
|
+
if (!shouldLog("info")) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
129
151
|
console.error(chalk.green(`[SUCCESS] ${message}`));
|
|
130
152
|
}
|
|
131
153
|
function debug(message) {
|
|
132
154
|
log(message, "debug");
|
|
133
155
|
}
|
|
156
|
+
var RELEASEKIT_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@releasekit/core:ReleaseKitError");
|
|
134
157
|
var ReleaseKitError = class _ReleaseKitError extends Error {
|
|
135
158
|
constructor(message) {
|
|
136
159
|
super(message);
|
|
137
160
|
this.name = this.constructor.name;
|
|
161
|
+
Object.defineProperty(this, RELEASEKIT_ERROR_BRAND, { value: true });
|
|
138
162
|
}
|
|
139
163
|
logError() {
|
|
140
164
|
log(this.message, "error");
|
|
@@ -145,8 +169,12 @@ var ReleaseKitError = class _ReleaseKitError extends Error {
|
|
|
145
169
|
}
|
|
146
170
|
}
|
|
147
171
|
}
|
|
172
|
+
/** True for an error from any copy of core (see {@link RELEASEKIT_ERROR_BRAND}), not just this one. */
|
|
148
173
|
static isReleaseKitError(error2) {
|
|
149
|
-
|
|
174
|
+
if (error2 instanceof _ReleaseKitError) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
return typeof error2 === "object" && error2 !== null && error2[RELEASEKIT_ERROR_BRAND] === true;
|
|
150
178
|
}
|
|
151
179
|
};
|
|
152
180
|
var EXIT_CODES = {
|
|
@@ -161,6 +189,99 @@ var EXIT_CODES = {
|
|
|
161
189
|
VERSION_ERROR: 8,
|
|
162
190
|
PUBLISH_ERROR: 9
|
|
163
191
|
};
|
|
192
|
+
var ENVELOPE_SCHEMA_VERSION = 1;
|
|
193
|
+
function isEnvelope(value) {
|
|
194
|
+
return typeof value === "object" && value !== null && "schemaVersion" in value && "status" in value && "data" in value;
|
|
195
|
+
}
|
|
196
|
+
var KNOWN_STATUSES = /* @__PURE__ */ new Set(["success", "error"]);
|
|
197
|
+
function unwrapEnvelope(value) {
|
|
198
|
+
if (!isEnvelope(value)) {
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
if (typeof value.schemaVersion !== "number" || value.schemaVersion > ENVELOPE_SCHEMA_VERSION) {
|
|
202
|
+
throw new Error(
|
|
203
|
+
`Unsupported releasekit envelope schemaVersion ${String(value.schemaVersion)} (this build understands up to ${ENVELOPE_SCHEMA_VERSION}). Upgrade the consuming releasekit to match the producer.`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
if (!KNOWN_STATUSES.has(value.status)) {
|
|
207
|
+
throw new Error(`Unrecognised releasekit envelope status "${String(value.status)}".`);
|
|
208
|
+
}
|
|
209
|
+
if (value.status === "error") {
|
|
210
|
+
const first = value.errors?.[0];
|
|
211
|
+
throw new Error(
|
|
212
|
+
first ? `Upstream releasekit stage failed (${first.code}): ${first.message}` : "Upstream releasekit stage failed, but reported no error detail."
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
if (value.data === null || value.data === void 0) {
|
|
216
|
+
throw new Error("Upstream releasekit stage reported success but produced no data.");
|
|
217
|
+
}
|
|
218
|
+
return value.data;
|
|
219
|
+
}
|
|
220
|
+
var CODE_TO_EXIT = {
|
|
221
|
+
CONFIG_ERROR: EXIT_CODES.CONFIG_ERROR,
|
|
222
|
+
INPUT_ERROR: EXIT_CODES.INPUT_ERROR,
|
|
223
|
+
INPUT_PARSE_ERROR: EXIT_CODES.INPUT_ERROR,
|
|
224
|
+
INPUT_VALIDATION_ERROR: EXIT_CODES.INPUT_ERROR,
|
|
225
|
+
TEMPLATE_ERROR: EXIT_CODES.TEMPLATE_ERROR,
|
|
226
|
+
LLM_ERROR: EXIT_CODES.LLM_ERROR,
|
|
227
|
+
GITHUB_ERROR: EXIT_CODES.GITHUB_ERROR,
|
|
228
|
+
GIT_ERROR: EXIT_CODES.GIT_ERROR,
|
|
229
|
+
VERSION_ERROR: EXIT_CODES.VERSION_ERROR,
|
|
230
|
+
PUBLISH_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
231
|
+
// @releasekit/version: discovery failures mean bad `packages` globs, so they're config errors.
|
|
232
|
+
CONFIG_REQUIRED: EXIT_CODES.CONFIG_ERROR,
|
|
233
|
+
INVALID_CONFIG: EXIT_CODES.CONFIG_ERROR,
|
|
234
|
+
UNSAFE_CONFIG_PATH: EXIT_CODES.CONFIG_ERROR,
|
|
235
|
+
PACKAGES_NOT_FOUND: EXIT_CODES.CONFIG_ERROR,
|
|
236
|
+
PACKAGE_NOT_FOUND: EXIT_CODES.CONFIG_ERROR,
|
|
237
|
+
WORKSPACE_ERROR: EXIT_CODES.CONFIG_ERROR,
|
|
238
|
+
NOT_GIT_REPO: EXIT_CODES.GIT_ERROR,
|
|
239
|
+
GIT_PROCESS_ERROR: EXIT_CODES.GIT_ERROR,
|
|
240
|
+
TAG_ALREADY_EXISTS: EXIT_CODES.GIT_ERROR,
|
|
241
|
+
VERSION_CALCULATION_ERROR: EXIT_CODES.VERSION_ERROR,
|
|
242
|
+
STRICT_REACHABLE_UNREACHABLE: EXIT_CODES.VERSION_ERROR,
|
|
243
|
+
NO_COMMIT_MESSAGE: EXIT_CODES.VERSION_ERROR,
|
|
244
|
+
NO_FILES: EXIT_CODES.VERSION_ERROR,
|
|
245
|
+
CARGO_LOCK_SYNC_ERROR: EXIT_CODES.VERSION_ERROR,
|
|
246
|
+
// @releasekit/publish
|
|
247
|
+
PIPELINE_STAGE_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
248
|
+
NPM_AUTH_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
249
|
+
NPM_PUBLISH_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
250
|
+
CARGO_AUTH_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
251
|
+
CARGO_PUBLISH_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
252
|
+
PUB_AUTH_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
253
|
+
PUB_PUBLISH_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
254
|
+
FILE_COPY_ERROR: EXIT_CODES.PUBLISH_ERROR,
|
|
255
|
+
VERIFICATION_FAILED: EXIT_CODES.PUBLISH_ERROR,
|
|
256
|
+
// A malformed manifest is a config error.
|
|
257
|
+
CARGO_TOML_ERROR: EXIT_CODES.CONFIG_ERROR,
|
|
258
|
+
PUBSPEC_YAML_ERROR: EXIT_CODES.CONFIG_ERROR,
|
|
259
|
+
GIT_COMMIT_ERROR: EXIT_CODES.GIT_ERROR,
|
|
260
|
+
GIT_PUSH_ERROR: EXIT_CODES.GIT_ERROR,
|
|
261
|
+
GIT_TAG_ERROR: EXIT_CODES.GIT_ERROR,
|
|
262
|
+
GITHUB_RELEASE_ERROR: EXIT_CODES.GITHUB_ERROR
|
|
263
|
+
};
|
|
264
|
+
var CATEGORY_FOR_EXIT = {
|
|
265
|
+
[EXIT_CODES.GENERAL_ERROR]: "general",
|
|
266
|
+
[EXIT_CODES.CONFIG_ERROR]: "config",
|
|
267
|
+
[EXIT_CODES.INPUT_ERROR]: "input",
|
|
268
|
+
[EXIT_CODES.TEMPLATE_ERROR]: "template",
|
|
269
|
+
[EXIT_CODES.LLM_ERROR]: "llm",
|
|
270
|
+
[EXIT_CODES.GITHUB_ERROR]: "github",
|
|
271
|
+
[EXIT_CODES.GIT_ERROR]: "git",
|
|
272
|
+
[EXIT_CODES.VERSION_ERROR]: "version",
|
|
273
|
+
[EXIT_CODES.PUBLISH_ERROR]: "publish"
|
|
274
|
+
};
|
|
275
|
+
function readPackageVersion(importMetaUrl) {
|
|
276
|
+
try {
|
|
277
|
+
const dir = path2.dirname(fileURLToPath(importMetaUrl));
|
|
278
|
+
const packageJsonPath = path2.resolve(dir, "../package.json");
|
|
279
|
+
const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
|
|
280
|
+
return packageJson.version ?? "0.0.0";
|
|
281
|
+
} catch {
|
|
282
|
+
return "0.0.0";
|
|
283
|
+
}
|
|
284
|
+
}
|
|
164
285
|
function isPathWithinRoot(root, target) {
|
|
165
286
|
const resolvedRoot = path3.resolve(root);
|
|
166
287
|
const resolvedTarget = path3.resolve(target);
|
|
@@ -176,7 +297,9 @@ import * as fs3 from "fs";
|
|
|
176
297
|
import * as path4 from "path";
|
|
177
298
|
var DEFAULT_FIRST_RELEASE_TEXT = "_First release of ${packageName}._";
|
|
178
299
|
function firstReleaseLine(context, config) {
|
|
179
|
-
if (!context.isFirstRelease || config === false)
|
|
300
|
+
if (!context.isFirstRelease || config === false) {
|
|
301
|
+
return void 0;
|
|
302
|
+
}
|
|
180
303
|
const template = config?.text ?? DEFAULT_FIRST_RELEASE_TEXT;
|
|
181
304
|
return template.replaceAll("${packageName}", context.packageName).replaceAll("${version}", context.version);
|
|
182
305
|
}
|
|
@@ -234,11 +357,15 @@ function formatCategorySection(name, entries, refOpts) {
|
|
|
234
357
|
lines.push(`### ${name}`);
|
|
235
358
|
const scopeCounts = /* @__PURE__ */ new Map();
|
|
236
359
|
for (const entry of entries) {
|
|
237
|
-
if (entry.scope)
|
|
360
|
+
if (entry.scope) {
|
|
361
|
+
scopeCounts.set(entry.scope, (scopeCounts.get(entry.scope) ?? 0) + 1);
|
|
362
|
+
}
|
|
238
363
|
}
|
|
239
364
|
const groupedScopes = /* @__PURE__ */ new Set();
|
|
240
365
|
for (const [scope, count] of scopeCounts) {
|
|
241
|
-
if (count > 1)
|
|
366
|
+
if (count > 1) {
|
|
367
|
+
groupedScopes.add(scope);
|
|
368
|
+
}
|
|
242
369
|
}
|
|
243
370
|
if (groupedScopes.size === 0) {
|
|
244
371
|
for (const entry of entries) {
|
|
@@ -273,7 +400,9 @@ function formatCategorySection(name, entries, refOpts) {
|
|
|
273
400
|
}
|
|
274
401
|
function rerouteBreakingEntries(categories) {
|
|
275
402
|
const hasBreaking = categories.some((c) => c.entries.some((e) => e.breaking));
|
|
276
|
-
if (!hasBreaking)
|
|
403
|
+
if (!hasBreaking) {
|
|
404
|
+
return categories;
|
|
405
|
+
}
|
|
277
406
|
const breakingEntries = [];
|
|
278
407
|
const stripped = categories.map((c) => ({
|
|
279
408
|
...c,
|
|
@@ -292,7 +421,9 @@ function rerouteBreakingEntries(categories) {
|
|
|
292
421
|
return [{ name: "Breaking", entries: breakingEntries }, ...stripped.filter((c) => c.entries.length > 0)];
|
|
293
422
|
}
|
|
294
423
|
function applyOrder(categories, order) {
|
|
295
|
-
if (order.length === 0)
|
|
424
|
+
if (order.length === 0) {
|
|
425
|
+
return categories;
|
|
426
|
+
}
|
|
296
427
|
return [...categories].sort((a, b) => {
|
|
297
428
|
const ai = order.indexOf(a.name);
|
|
298
429
|
const bi = order.indexOf(b.name);
|
|
@@ -304,18 +435,26 @@ function parseMdLink(text) {
|
|
|
304
435
|
let search = 0;
|
|
305
436
|
while (search < text.length) {
|
|
306
437
|
const bracketOpen = text.indexOf("[", search);
|
|
307
|
-
if (bracketOpen === -1)
|
|
438
|
+
if (bracketOpen === -1) {
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
308
441
|
const bracketClose = text.indexOf("]", bracketOpen + 1);
|
|
309
|
-
if (bracketClose === -1)
|
|
442
|
+
if (bracketClose === -1) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
310
445
|
if (text[bracketClose + 1] !== "(") {
|
|
311
446
|
search = bracketClose + 1;
|
|
312
447
|
continue;
|
|
313
448
|
}
|
|
314
449
|
const parenClose = text.indexOf(")", bracketClose + 2);
|
|
315
|
-
if (parenClose === -1)
|
|
450
|
+
if (parenClose === -1) {
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
316
453
|
const label = text.slice(bracketOpen + 1, bracketClose);
|
|
317
454
|
const url = text.slice(bracketClose + 2, parenClose);
|
|
318
|
-
if (/^https?:\/\//.test(url))
|
|
455
|
+
if (/^https?:\/\//.test(url)) {
|
|
456
|
+
return { label, url };
|
|
457
|
+
}
|
|
319
458
|
search = parenClose + 1;
|
|
320
459
|
}
|
|
321
460
|
return null;
|
|
@@ -327,7 +466,9 @@ function extractLinksFromPRBodies(entries, marker) {
|
|
|
327
466
|
for (const pr of entry.context?.prs ?? []) {
|
|
328
467
|
for (const line of pr.body.split("\n")) {
|
|
329
468
|
const trimmed = line.trim();
|
|
330
|
-
if (!trimmed.startsWith(marker))
|
|
469
|
+
if (!trimmed.startsWith(marker)) {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
331
472
|
const rest = trimmed.slice(marker.length).trim();
|
|
332
473
|
const mdLink = parseMdLink(rest);
|
|
333
474
|
if (mdLink) {
|
|
@@ -335,9 +476,9 @@ function extractLinksFromPRBodies(entries, marker) {
|
|
|
335
476
|
seen.add(mdLink.url);
|
|
336
477
|
links.push(mdLink);
|
|
337
478
|
}
|
|
338
|
-
} else
|
|
339
|
-
const url = rest
|
|
340
|
-
if (!seen.has(url)) {
|
|
479
|
+
} else {
|
|
480
|
+
const url = /^https?:\/\/\S*/.exec(rest)?.[0];
|
|
481
|
+
if (url && !seen.has(url)) {
|
|
341
482
|
seen.add(url);
|
|
342
483
|
links.push({ label: marker.replace(/:$/, ""), url });
|
|
343
484
|
}
|
|
@@ -348,7 +489,9 @@ function extractLinksFromPRBodies(entries, marker) {
|
|
|
348
489
|
return links;
|
|
349
490
|
}
|
|
350
491
|
function resolveLinks(entries, linksConfig) {
|
|
351
|
-
if (!linksConfig)
|
|
492
|
+
if (!linksConfig) {
|
|
493
|
+
return [];
|
|
494
|
+
}
|
|
352
495
|
const items = linksConfig.items ?? [];
|
|
353
496
|
const discovered = linksConfig.fromPRBodyMarker ? extractLinksFromPRBodies(entries, linksConfig.fromPRBodyMarker) : [];
|
|
354
497
|
const seen = new Set(items.map((i) => i.url));
|
|
@@ -385,7 +528,9 @@ function formatVersion(context, options) {
|
|
|
385
528
|
let categories = rerouteBreakingEntries(context.enhanced.categories);
|
|
386
529
|
categories = applyOrder(categories, options?.categoryOrder ?? []);
|
|
387
530
|
for (const category of categories) {
|
|
388
|
-
if (category.entries.length === 0)
|
|
531
|
+
if (category.entries.length === 0) {
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
389
534
|
lines.push(...formatCategorySection(category.name, category.entries, refOpts));
|
|
390
535
|
}
|
|
391
536
|
const links = resolveLinks(context.entries, options?.links);
|
|
@@ -399,7 +544,9 @@ function formatVersion(context, options) {
|
|
|
399
544
|
} else {
|
|
400
545
|
const grouped = groupEntriesByType(context.entries);
|
|
401
546
|
for (const [type, entries] of grouped) {
|
|
402
|
-
if (entries.length === 0)
|
|
547
|
+
if (entries.length === 0) {
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
403
550
|
lines.push(`### ${TYPE_LABELS[type]}`);
|
|
404
551
|
for (const entry of entries) {
|
|
405
552
|
lines.push(formatEntry(entry, refOpts));
|
|
@@ -426,22 +573,27 @@ function renderMarkdown(contexts, options) {
|
|
|
426
573
|
}
|
|
427
574
|
return sections.join("\n");
|
|
428
575
|
}
|
|
429
|
-
function
|
|
430
|
-
|
|
431
|
-
if (
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
576
|
+
function prependVersions(existingPath, contexts, options) {
|
|
577
|
+
const existing = fs3.existsSync(existingPath) ? fs3.readFileSync(existingPath, "utf-8") : "";
|
|
578
|
+
if (existing.trim() === "") {
|
|
579
|
+
return renderMarkdown(contexts, options);
|
|
580
|
+
}
|
|
581
|
+
const sections = contexts.map((context) => formatVersion(context, options)).join("\n");
|
|
582
|
+
if (existing.startsWith("## ")) {
|
|
583
|
+
return `${sections}
|
|
584
|
+
${existing}`;
|
|
585
|
+
}
|
|
586
|
+
const headerEnd = existing.indexOf("\n## ");
|
|
587
|
+
if (headerEnd === -1) {
|
|
588
|
+
return `${existing.trimEnd()}
|
|
439
589
|
|
|
440
|
-
|
|
441
|
-
${
|
|
442
|
-
}
|
|
590
|
+
|
|
591
|
+
${sections}`;
|
|
443
592
|
}
|
|
444
|
-
return
|
|
593
|
+
return `${existing.slice(0, headerEnd)}
|
|
594
|
+
|
|
595
|
+
${sections}
|
|
596
|
+
${existing.slice(headerEnd + 1)}`;
|
|
445
597
|
}
|
|
446
598
|
function writeMarkdown(outputPath, contexts, config, dryRun, options) {
|
|
447
599
|
const content = renderMarkdown(contexts, options);
|
|
@@ -459,21 +611,14 @@ function writeMarkdown(outputPath, contexts, config, dryRun, options) {
|
|
|
459
611
|
process.stdout.write(content);
|
|
460
612
|
return;
|
|
461
613
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
if (firstContext) {
|
|
465
|
-
const updated = prependVersion(outputPath, firstContext, options);
|
|
466
|
-
fs3.writeFileSync(outputPath, updated, "utf-8");
|
|
467
|
-
}
|
|
468
|
-
} else {
|
|
469
|
-
fs3.writeFileSync(outputPath, content, "utf-8");
|
|
470
|
-
}
|
|
614
|
+
const updated = config.updateStrategy === "regenerate" ? content : prependVersions(outputPath, contexts, options);
|
|
615
|
+
fs3.writeFileSync(outputPath, updated, "utf-8");
|
|
471
616
|
success(`${label} written to ${outputPath}`);
|
|
472
617
|
}
|
|
473
618
|
|
|
474
619
|
export {
|
|
475
620
|
parseGitHubOwnerRepo,
|
|
476
|
-
|
|
621
|
+
removeDescriptionRefs,
|
|
477
622
|
setLogLevel,
|
|
478
623
|
setQuietMode,
|
|
479
624
|
error,
|
|
@@ -483,9 +628,11 @@ export {
|
|
|
483
628
|
debug,
|
|
484
629
|
ReleaseKitError,
|
|
485
630
|
EXIT_CODES,
|
|
631
|
+
unwrapEnvelope,
|
|
632
|
+
readPackageVersion,
|
|
486
633
|
isPathWithinRoot,
|
|
487
634
|
formatVersion,
|
|
488
635
|
renderMarkdown,
|
|
489
|
-
|
|
636
|
+
prependVersions,
|
|
490
637
|
writeMarkdown
|
|
491
638
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
debug,
|
|
3
|
-
formatVersion,
|
|
4
3
|
info,
|
|
5
|
-
|
|
4
|
+
prependVersions,
|
|
6
5
|
renderMarkdown,
|
|
7
6
|
success
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CBMVDKDR.js";
|
|
9
8
|
|
|
10
9
|
// src/monorepo/aggregator.ts
|
|
11
10
|
import * as fs from "fs";
|
|
@@ -60,22 +59,7 @@ function writeMonorepoChangelogs(contexts, options, config, dryRun, refs = "link
|
|
|
60
59
|
const rootPath = path.join(options.rootPath, options.fileName ?? "CHANGELOG.md");
|
|
61
60
|
const fmtOpts = { includePackageName: true, refs };
|
|
62
61
|
info(`Writing root changelog to ${rootPath}`);
|
|
63
|
-
|
|
64
|
-
if (config.updateStrategy !== "regenerate" && fs.existsSync(rootPath)) {
|
|
65
|
-
const newSections = contexts.map((ctx) => formatVersion(ctx, fmtOpts)).join("\n");
|
|
66
|
-
const existing = fs.readFileSync(rootPath, "utf-8");
|
|
67
|
-
const headerEnd = existing.indexOf("\n## ");
|
|
68
|
-
if (headerEnd >= 0) {
|
|
69
|
-
rootContent = `${existing.slice(0, headerEnd)}
|
|
70
|
-
|
|
71
|
-
${newSections}
|
|
72
|
-
${existing.slice(headerEnd + 1)}`;
|
|
73
|
-
} else {
|
|
74
|
-
rootContent = renderMarkdown(contexts, fmtOpts);
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
rootContent = renderMarkdown(contexts, fmtOpts);
|
|
78
|
-
}
|
|
62
|
+
const rootContent = config.updateStrategy === "regenerate" ? renderMarkdown(contexts, fmtOpts) : prependVersions(rootPath, contexts, fmtOpts);
|
|
79
63
|
if (writeFile(rootPath, rootContent, dryRun)) {
|
|
80
64
|
files.push(rootPath);
|
|
81
65
|
}
|
|
@@ -89,7 +73,7 @@ ${existing.slice(headerEnd + 1)}`;
|
|
|
89
73
|
if (packageDir) {
|
|
90
74
|
const changelogPath = path.join(packageDir, options.fileName ?? "CHANGELOG.md");
|
|
91
75
|
info(`Writing changelog for ${packageName} to ${changelogPath}`);
|
|
92
|
-
const pkgContent = config.updateStrategy
|
|
76
|
+
const pkgContent = config.updateStrategy === "regenerate" ? renderMarkdown([ctx], { refs }) : prependVersions(changelogPath, [ctx], { refs });
|
|
93
77
|
if (writeFile(changelogPath, pkgContent, dryRun)) {
|
|
94
78
|
files.push(changelogPath);
|
|
95
79
|
}
|
|
@@ -107,7 +91,9 @@ function buildPackageDirMap(rootPath, packagesPath) {
|
|
|
107
91
|
return map;
|
|
108
92
|
}
|
|
109
93
|
for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {
|
|
110
|
-
if (!entry.isDirectory())
|
|
94
|
+
if (!entry.isDirectory()) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
111
97
|
const dirPath = path.join(packagesDir, entry.name);
|
|
112
98
|
map.set(entry.name, dirPath);
|
|
113
99
|
const packageJsonPath = path.join(dirPath, "package.json");
|
|
@@ -158,7 +144,6 @@ function detectMonorepo(cwd) {
|
|
|
158
144
|
}
|
|
159
145
|
|
|
160
146
|
export {
|
|
161
|
-
splitByPackage,
|
|
162
147
|
aggregateToRoot,
|
|
163
148
|
writeMonorepoChangelogs,
|
|
164
149
|
detectMonorepo
|