@releasekit/notes 0.41.1 → 0.42.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.
@@ -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";
@@ -9,28 +10,40 @@ import { minimatch } from "minimatch";
9
10
  import * as path3 from "path";
10
11
  function parseGitHubOwnerRepo(repoUrl) {
11
12
  const scpMatch = repoUrl.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
12
- if (scpMatch) return { owner: scpMatch[1], repo: scpMatch[2] };
13
+ if (scpMatch) {
14
+ return { owner: scpMatch[1], repo: scpMatch[2] };
15
+ }
13
16
  try {
14
17
  const url = new URL(repoUrl);
15
- if (url.hostname !== "github.com") return null;
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]) return { owner: parts[0], repo: 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") return "";
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) return "";
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) return `(${prPart})`;
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,25 +65,19 @@ 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) return match;
68
+ if (num === void 0) {
69
+ return match;
70
+ }
56
71
  const ws = lead ?? "";
57
- if (appended.has(Number(num)) || mode === "strip") return "";
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 readPackageVersion(importMetaUrl) {
65
- try {
66
- const dir = path2.dirname(fileURLToPath(importMetaUrl));
67
- const packageJsonPath = path2.resolve(dir, "../package.json");
68
- const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
69
- return packageJson.version ?? "0.0.0";
70
- } catch {
71
- return "0.0.0";
72
- }
73
- }
74
81
  var LOG_LEVELS = {
75
82
  error: 0,
76
83
  warn: 1,
@@ -106,12 +113,18 @@ function setQuietMode(quiet) {
106
113
  quietMode = quiet;
107
114
  }
108
115
  function shouldLog(level) {
109
- if (quietMode && level !== "error") return false;
110
- if (level === "debug" && (process.env.DEBUG === "true" || process.env.DEBUG === "1")) return true;
116
+ if (quietMode && level !== "error") {
117
+ return false;
118
+ }
119
+ if (level === "debug" && (process.env.DEBUG === "true" || process.env.DEBUG === "1")) {
120
+ return true;
121
+ }
111
122
  return LOG_LEVELS[level] <= LOG_LEVELS[currentLevel];
112
123
  }
113
124
  function log(message, level = "info") {
114
- if (!shouldLog(level)) return;
125
+ if (!shouldLog(level)) {
126
+ return;
127
+ }
115
128
  const formatted = COLORS[level](`${PREFIXES[level]} ${message}`);
116
129
  console.error(formatted);
117
130
  }
@@ -125,16 +138,20 @@ function info(message) {
125
138
  log(message, "info");
126
139
  }
127
140
  function success(message) {
128
- if (!shouldLog("info")) return;
141
+ if (!shouldLog("info")) {
142
+ return;
143
+ }
129
144
  console.error(chalk.green(`[SUCCESS] ${message}`));
130
145
  }
131
146
  function debug(message) {
132
147
  log(message, "debug");
133
148
  }
149
+ var RELEASEKIT_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@releasekit/core:ReleaseKitError");
134
150
  var ReleaseKitError = class _ReleaseKitError extends Error {
135
151
  constructor(message) {
136
152
  super(message);
137
153
  this.name = this.constructor.name;
154
+ Object.defineProperty(this, RELEASEKIT_ERROR_BRAND, { value: true });
138
155
  }
139
156
  logError() {
140
157
  log(this.message, "error");
@@ -145,8 +162,12 @@ var ReleaseKitError = class _ReleaseKitError extends Error {
145
162
  }
146
163
  }
147
164
  }
165
+ /** True for an error from any copy of core (see {@link RELEASEKIT_ERROR_BRAND}), not just this one. */
148
166
  static isReleaseKitError(error2) {
149
- return error2 instanceof _ReleaseKitError;
167
+ if (error2 instanceof _ReleaseKitError) {
168
+ return true;
169
+ }
170
+ return typeof error2 === "object" && error2 !== null && error2[RELEASEKIT_ERROR_BRAND] === true;
150
171
  }
151
172
  };
152
173
  var EXIT_CODES = {
@@ -161,6 +182,98 @@ var EXIT_CODES = {
161
182
  VERSION_ERROR: 8,
162
183
  PUBLISH_ERROR: 9
163
184
  };
185
+ var ENVELOPE_SCHEMA_VERSION = 1;
186
+ function isEnvelope(value) {
187
+ return typeof value === "object" && value !== null && "schemaVersion" in value && "status" in value && "data" in value;
188
+ }
189
+ var KNOWN_STATUSES = /* @__PURE__ */ new Set(["success", "error"]);
190
+ function unwrapEnvelope(value) {
191
+ if (!isEnvelope(value)) {
192
+ return value;
193
+ }
194
+ if (typeof value.schemaVersion !== "number" || value.schemaVersion > ENVELOPE_SCHEMA_VERSION) {
195
+ throw new Error(
196
+ `Unsupported releasekit envelope schemaVersion ${String(value.schemaVersion)} (this build understands up to ${ENVELOPE_SCHEMA_VERSION}). Upgrade the consuming releasekit to match the producer.`
197
+ );
198
+ }
199
+ if (!KNOWN_STATUSES.has(value.status)) {
200
+ throw new Error(`Unrecognised releasekit envelope status "${String(value.status)}".`);
201
+ }
202
+ if (value.status === "error") {
203
+ const first = value.errors?.[0];
204
+ throw new Error(
205
+ first ? `Upstream releasekit stage failed (${first.code}): ${first.message}` : "Upstream releasekit stage failed, but reported no error detail."
206
+ );
207
+ }
208
+ if (value.data === null || value.data === void 0) {
209
+ throw new Error("Upstream releasekit stage reported success but produced no data.");
210
+ }
211
+ return value.data;
212
+ }
213
+ var CODE_TO_EXIT = {
214
+ CONFIG_ERROR: EXIT_CODES.CONFIG_ERROR,
215
+ INPUT_ERROR: EXIT_CODES.INPUT_ERROR,
216
+ INPUT_PARSE_ERROR: EXIT_CODES.INPUT_ERROR,
217
+ INPUT_VALIDATION_ERROR: EXIT_CODES.INPUT_ERROR,
218
+ TEMPLATE_ERROR: EXIT_CODES.TEMPLATE_ERROR,
219
+ LLM_ERROR: EXIT_CODES.LLM_ERROR,
220
+ GITHUB_ERROR: EXIT_CODES.GITHUB_ERROR,
221
+ GIT_ERROR: EXIT_CODES.GIT_ERROR,
222
+ VERSION_ERROR: EXIT_CODES.VERSION_ERROR,
223
+ PUBLISH_ERROR: EXIT_CODES.PUBLISH_ERROR,
224
+ // @releasekit/version: discovery failures mean bad `packages` globs, so they're config errors.
225
+ CONFIG_REQUIRED: EXIT_CODES.CONFIG_ERROR,
226
+ INVALID_CONFIG: EXIT_CODES.CONFIG_ERROR,
227
+ UNSAFE_CONFIG_PATH: EXIT_CODES.CONFIG_ERROR,
228
+ PACKAGES_NOT_FOUND: EXIT_CODES.CONFIG_ERROR,
229
+ PACKAGE_NOT_FOUND: EXIT_CODES.CONFIG_ERROR,
230
+ WORKSPACE_ERROR: EXIT_CODES.CONFIG_ERROR,
231
+ NOT_GIT_REPO: EXIT_CODES.GIT_ERROR,
232
+ GIT_PROCESS_ERROR: EXIT_CODES.GIT_ERROR,
233
+ TAG_ALREADY_EXISTS: EXIT_CODES.GIT_ERROR,
234
+ VERSION_CALCULATION_ERROR: EXIT_CODES.VERSION_ERROR,
235
+ STRICT_REACHABLE_UNREACHABLE: EXIT_CODES.VERSION_ERROR,
236
+ NO_COMMIT_MESSAGE: EXIT_CODES.VERSION_ERROR,
237
+ NO_FILES: EXIT_CODES.VERSION_ERROR,
238
+ CARGO_LOCK_SYNC_ERROR: EXIT_CODES.VERSION_ERROR,
239
+ // @releasekit/publish: a malformed manifest is a config error.
240
+ PIPELINE_STAGE_ERROR: EXIT_CODES.PUBLISH_ERROR,
241
+ NPM_AUTH_ERROR: EXIT_CODES.PUBLISH_ERROR,
242
+ NPM_PUBLISH_ERROR: EXIT_CODES.PUBLISH_ERROR,
243
+ CARGO_AUTH_ERROR: EXIT_CODES.PUBLISH_ERROR,
244
+ CARGO_PUBLISH_ERROR: EXIT_CODES.PUBLISH_ERROR,
245
+ PUB_AUTH_ERROR: EXIT_CODES.PUBLISH_ERROR,
246
+ PUB_PUBLISH_ERROR: EXIT_CODES.PUBLISH_ERROR,
247
+ FILE_COPY_ERROR: EXIT_CODES.PUBLISH_ERROR,
248
+ VERIFICATION_FAILED: EXIT_CODES.PUBLISH_ERROR,
249
+ CARGO_TOML_ERROR: EXIT_CODES.CONFIG_ERROR,
250
+ PUBSPEC_YAML_ERROR: EXIT_CODES.CONFIG_ERROR,
251
+ GIT_COMMIT_ERROR: EXIT_CODES.GIT_ERROR,
252
+ GIT_PUSH_ERROR: EXIT_CODES.GIT_ERROR,
253
+ GIT_TAG_ERROR: EXIT_CODES.GIT_ERROR,
254
+ GITHUB_RELEASE_ERROR: EXIT_CODES.GITHUB_ERROR
255
+ };
256
+ var CATEGORY_FOR_EXIT = {
257
+ [EXIT_CODES.GENERAL_ERROR]: "general",
258
+ [EXIT_CODES.CONFIG_ERROR]: "config",
259
+ [EXIT_CODES.INPUT_ERROR]: "input",
260
+ [EXIT_CODES.TEMPLATE_ERROR]: "template",
261
+ [EXIT_CODES.LLM_ERROR]: "llm",
262
+ [EXIT_CODES.GITHUB_ERROR]: "github",
263
+ [EXIT_CODES.GIT_ERROR]: "git",
264
+ [EXIT_CODES.VERSION_ERROR]: "version",
265
+ [EXIT_CODES.PUBLISH_ERROR]: "publish"
266
+ };
267
+ function readPackageVersion(importMetaUrl) {
268
+ try {
269
+ const dir = path2.dirname(fileURLToPath(importMetaUrl));
270
+ const packageJsonPath = path2.resolve(dir, "../package.json");
271
+ const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
272
+ return packageJson.version ?? "0.0.0";
273
+ } catch {
274
+ return "0.0.0";
275
+ }
276
+ }
164
277
  function isPathWithinRoot(root, target) {
165
278
  const resolvedRoot = path3.resolve(root);
166
279
  const resolvedTarget = path3.resolve(target);
@@ -176,7 +289,9 @@ import * as fs3 from "fs";
176
289
  import * as path4 from "path";
177
290
  var DEFAULT_FIRST_RELEASE_TEXT = "_First release of ${packageName}._";
178
291
  function firstReleaseLine(context, config) {
179
- if (!context.isFirstRelease || config === false) return void 0;
292
+ if (!context.isFirstRelease || config === false) {
293
+ return void 0;
294
+ }
180
295
  const template = config?.text ?? DEFAULT_FIRST_RELEASE_TEXT;
181
296
  return template.replaceAll("${packageName}", context.packageName).replaceAll("${version}", context.version);
182
297
  }
@@ -234,11 +349,15 @@ function formatCategorySection(name, entries, refOpts) {
234
349
  lines.push(`### ${name}`);
235
350
  const scopeCounts = /* @__PURE__ */ new Map();
236
351
  for (const entry of entries) {
237
- if (entry.scope) scopeCounts.set(entry.scope, (scopeCounts.get(entry.scope) ?? 0) + 1);
352
+ if (entry.scope) {
353
+ scopeCounts.set(entry.scope, (scopeCounts.get(entry.scope) ?? 0) + 1);
354
+ }
238
355
  }
239
356
  const groupedScopes = /* @__PURE__ */ new Set();
240
357
  for (const [scope, count] of scopeCounts) {
241
- if (count > 1) groupedScopes.add(scope);
358
+ if (count > 1) {
359
+ groupedScopes.add(scope);
360
+ }
242
361
  }
243
362
  if (groupedScopes.size === 0) {
244
363
  for (const entry of entries) {
@@ -273,7 +392,9 @@ function formatCategorySection(name, entries, refOpts) {
273
392
  }
274
393
  function rerouteBreakingEntries(categories) {
275
394
  const hasBreaking = categories.some((c) => c.entries.some((e) => e.breaking));
276
- if (!hasBreaking) return categories;
395
+ if (!hasBreaking) {
396
+ return categories;
397
+ }
277
398
  const breakingEntries = [];
278
399
  const stripped = categories.map((c) => ({
279
400
  ...c,
@@ -292,7 +413,9 @@ function rerouteBreakingEntries(categories) {
292
413
  return [{ name: "Breaking", entries: breakingEntries }, ...stripped.filter((c) => c.entries.length > 0)];
293
414
  }
294
415
  function applyOrder(categories, order) {
295
- if (order.length === 0) return categories;
416
+ if (order.length === 0) {
417
+ return categories;
418
+ }
296
419
  return [...categories].sort((a, b) => {
297
420
  const ai = order.indexOf(a.name);
298
421
  const bi = order.indexOf(b.name);
@@ -304,18 +427,26 @@ function parseMdLink(text) {
304
427
  let search = 0;
305
428
  while (search < text.length) {
306
429
  const bracketOpen = text.indexOf("[", search);
307
- if (bracketOpen === -1) return null;
430
+ if (bracketOpen === -1) {
431
+ return null;
432
+ }
308
433
  const bracketClose = text.indexOf("]", bracketOpen + 1);
309
- if (bracketClose === -1) return null;
434
+ if (bracketClose === -1) {
435
+ return null;
436
+ }
310
437
  if (text[bracketClose + 1] !== "(") {
311
438
  search = bracketClose + 1;
312
439
  continue;
313
440
  }
314
441
  const parenClose = text.indexOf(")", bracketClose + 2);
315
- if (parenClose === -1) return null;
442
+ if (parenClose === -1) {
443
+ return null;
444
+ }
316
445
  const label = text.slice(bracketOpen + 1, bracketClose);
317
446
  const url = text.slice(bracketClose + 2, parenClose);
318
- if (/^https?:\/\//.test(url)) return { label, url };
447
+ if (/^https?:\/\//.test(url)) {
448
+ return { label, url };
449
+ }
319
450
  search = parenClose + 1;
320
451
  }
321
452
  return null;
@@ -327,7 +458,9 @@ function extractLinksFromPRBodies(entries, marker) {
327
458
  for (const pr of entry.context?.prs ?? []) {
328
459
  for (const line of pr.body.split("\n")) {
329
460
  const trimmed = line.trim();
330
- if (!trimmed.startsWith(marker)) continue;
461
+ if (!trimmed.startsWith(marker)) {
462
+ continue;
463
+ }
331
464
  const rest = trimmed.slice(marker.length).trim();
332
465
  const mdLink = parseMdLink(rest);
333
466
  if (mdLink) {
@@ -348,7 +481,9 @@ function extractLinksFromPRBodies(entries, marker) {
348
481
  return links;
349
482
  }
350
483
  function resolveLinks(entries, linksConfig) {
351
- if (!linksConfig) return [];
484
+ if (!linksConfig) {
485
+ return [];
486
+ }
352
487
  const items = linksConfig.items ?? [];
353
488
  const discovered = linksConfig.fromPRBodyMarker ? extractLinksFromPRBodies(entries, linksConfig.fromPRBodyMarker) : [];
354
489
  const seen = new Set(items.map((i) => i.url));
@@ -385,7 +520,9 @@ function formatVersion(context, options) {
385
520
  let categories = rerouteBreakingEntries(context.enhanced.categories);
386
521
  categories = applyOrder(categories, options?.categoryOrder ?? []);
387
522
  for (const category of categories) {
388
- if (category.entries.length === 0) continue;
523
+ if (category.entries.length === 0) {
524
+ continue;
525
+ }
389
526
  lines.push(...formatCategorySection(category.name, category.entries, refOpts));
390
527
  }
391
528
  const links = resolveLinks(context.entries, options?.links);
@@ -399,7 +536,9 @@ function formatVersion(context, options) {
399
536
  } else {
400
537
  const grouped = groupEntriesByType(context.entries);
401
538
  for (const [type, entries] of grouped) {
402
- if (entries.length === 0) continue;
539
+ if (entries.length === 0) {
540
+ continue;
541
+ }
403
542
  lines.push(`### ${TYPE_LABELS[type]}`);
404
543
  for (const entry of entries) {
405
544
  lines.push(formatEntry(entry, refOpts));
@@ -473,7 +612,6 @@ function writeMarkdown(outputPath, contexts, config, dryRun, options) {
473
612
 
474
613
  export {
475
614
  parseGitHubOwnerRepo,
476
- readPackageVersion,
477
615
  setLogLevel,
478
616
  setQuietMode,
479
617
  error,
@@ -483,6 +621,8 @@ export {
483
621
  debug,
484
622
  ReleaseKitError,
485
623
  EXIT_CODES,
624
+ unwrapEnvelope,
625
+ readPackageVersion,
486
626
  isPathWithinRoot,
487
627
  formatVersion,
488
628
  renderMarkdown,
@@ -5,7 +5,7 @@ import {
5
5
  prependVersion,
6
6
  renderMarkdown,
7
7
  success
8
- } from "./chunk-FI3F2ND5.js";
8
+ } from "./chunk-LA3V665B.js";
9
9
 
10
10
  // src/monorepo/aggregator.ts
11
11
  import * as fs from "fs";
@@ -107,7 +107,9 @@ function buildPackageDirMap(rootPath, packagesPath) {
107
107
  return map;
108
108
  }
109
109
  for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {
110
- if (!entry.isDirectory()) continue;
110
+ if (!entry.isDirectory()) {
111
+ continue;
112
+ }
111
113
  const dirPath = path.join(packagesDir, entry.name);
112
114
  map.set(entry.name, dirPath);
113
115
  const packageJsonPath = path.join(dirPath, "package.json");
@@ -158,7 +160,6 @@ function detectMonorepo(cwd) {
158
160
  }
159
161
 
160
162
  export {
161
- splitByPackage,
162
163
  aggregateToRoot,
163
164
  writeMonorepoChangelogs,
164
165
  detectMonorepo
package/dist/cli.d.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  #!/usr/bin/env node
2
- export { createNotesCommand } from './command.ts';
3
- import './core/config.ts';
4
- import './core/pipeline.ts';
5
- import './core/types.ts';
6
- import './errors/index.ts';
7
- import './input/version-output.ts';
8
- import './monorepo/aggregator.ts';
9
- import './output/json.ts';
10
- import './output/markdown.ts';
2
+ import { Command } from 'commander';
3
+
4
+ declare function createNotesCommand(): Command;
5
+
6
+ export { createNotesCommand };
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createNotesCommand
4
- } from "./chunk-ZGFPTVWY.js";
4
+ } from "./chunk-3X4XBORT.js";
5
5
  import {
6
6
  readPackageVersion
7
- } from "./chunk-FI3F2ND5.js";
7
+ } from "./chunk-LA3V665B.js";
8
8
 
9
9
  // src/cli.ts
10
10
  import * as fs from "fs";