@reelout/core 0.13.0 → 0.14.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 (62) hide show
  1. package/dist/HookDispatcher-Di79rwtu.js +236 -0
  2. package/dist/HookDispatcher-Di79rwtu.js.map +1 -0
  3. package/dist/analyzer.js +12 -3
  4. package/dist/analyzer.js.map +1 -1
  5. package/dist/buildChangelog-Cxm9_lq2.js +187 -0
  6. package/dist/buildChangelog-Cxm9_lq2.js.map +1 -0
  7. package/dist/buildReleaseNotes-S6HcEQnE.js +141 -0
  8. package/dist/buildReleaseNotes-S6HcEQnE.js.map +1 -0
  9. package/dist/builder.js +14 -6
  10. package/dist/builder.js.map +1 -1
  11. package/dist/changelog.js +17 -6
  12. package/dist/changelog.js.map +1 -1
  13. package/dist/index.js +1201 -8
  14. package/dist/index.js.map +1 -1
  15. package/dist/package-Bczytil1.js +884 -0
  16. package/dist/package-Bczytil1.js.map +1 -0
  17. package/dist/propagateDependencyUpdates-QWn0H1qa.js +306 -0
  18. package/dist/propagateDependencyUpdates-QWn0H1qa.js.map +1 -0
  19. package/dist/readPackageHistory-CN5nqMcE.js +133 -0
  20. package/dist/readPackageHistory-CN5nqMcE.js.map +1 -0
  21. package/dist/resolvePackageTag-cwqG1GGt.js +30 -0
  22. package/dist/resolvePackageTag-cwqG1GGt.js.map +1 -0
  23. package/dist/types.js +0 -1
  24. package/package.json +15 -3
  25. package/src/analyzer.ts +7 -2
  26. package/src/builder.ts +12 -3
  27. package/src/changelog.ts +17 -6
  28. package/src/config/resolvePlugin.ts +1 -1
  29. package/src/git/commit/getParsedGitCommit.ts +4 -1
  30. package/src/git/commit/parseGitCommit.ts +27 -2
  31. package/src/git/commit/parseGitPrettyFormat.ts +4 -1
  32. package/src/git/history/expandGitHistory.ts +17 -3
  33. package/src/git/history/readParsedGitHistory.ts +8 -2
  34. package/src/git/repository/isGitShallowRepository.ts +2 -1
  35. package/src/git/tag/ensureGitTag.ts +35 -3
  36. package/src/plugin/createHostReleasePlugin.ts +255 -0
  37. package/src/plugin/index.ts +1 -0
  38. package/src/util/execCommand.ts +9 -0
  39. package/src/util/formatFile.ts +12 -3
  40. package/src/util/interpolate.ts +5 -3
  41. package/src/workflow/analysis/propagateDependencyUpdates.ts +1 -0
  42. package/src/workflow/changelog/buildChangelog.ts +27 -4
  43. package/src/workflow/changelog/buildReleaseNotes.ts +1 -1
  44. package/src/workflow/changelog/index.ts +0 -1
  45. package/src/workflow/changelog/prependChangelog.ts +5 -2
  46. package/src/workflow/changelog/writeChangelog.ts +5 -2
  47. package/src/workflow/commit/generateReleaseCommitMessage.ts +1 -1
  48. package/src/workflow/discovery/discoverPackageTag.ts +5 -2
  49. package/src/workflow/discovery/resolvePackageStableTag.ts +12 -7
  50. package/src/workflow/discovery/resolvePackageTag.ts +5 -2
  51. package/src/workflow/discovery/sortPackages.ts +5 -4
  52. package/src/workflow/discovery/verifyPackageTag.ts +6 -3
  53. package/src/workflow/report/printReleaseReport.ts +6 -1
  54. package/src/workflow/version/bumpVersion.ts +0 -1
  55. package/src/workflow/version/index.ts +0 -1
  56. package/dist/formatError-BMsun8Wi.js +0 -22
  57. package/dist/formatError-BMsun8Wi.js.map +0 -1
  58. package/dist/types-la_KkjCS.js +0 -1
  59. package/dist/workflow-Cqg6rLVB.js +0 -2936
  60. package/dist/workflow-Cqg6rLVB.js.map +0 -1
  61. package/src/workflow/changelog/extractPreviousVersion.ts +0 -77
  62. package/src/workflow/version/promotePrereleaseVersions.ts +0 -51
@@ -0,0 +1,884 @@
1
+ import { colors } from "consola/utils";
2
+ import { Writable } from "node:stream";
3
+ import { spawn } from "node:child_process";
4
+ import { minimatch } from "minimatch";
5
+ import path from "node:path";
6
+ import { CommitParser } from "conventional-commits-parser";
7
+ import { AsyncLocalStorage } from "node:async_hooks";
8
+ // src/config/const.ts
9
+ var ALL_FILES = "**/*";
10
+ var DEFAULT_CHANGELOG_FILE = "CHANGELOG.md";
11
+ var GIT_TRAILER_RELEASE_AGENT = "Release-Agent";
12
+ /**
13
+ * 1. Primitive Building Blocks
14
+ *
15
+ * Base regular expression patterns for wildcards, alphanumeric strings with hyphens,
16
+ * and standard non-negative integers.
17
+ */
18
+ var WILDCARD = "\\*";
19
+ var ALPHANUM_DASH = "[0-9a-zA-Z-]+";
20
+ var NUMERIC_IDENTIFIER = "0|[1-9]\\d*";
21
+ /**
22
+ * 2. Package Name & Prefix Constructs
23
+ *
24
+ * Matches package name prefixes (unscoped or scoped) or a simple `v` prefix.
25
+ *
26
+ * Capture Groups:
27
+ * - Group 1: Package name (e.g., `my-package` or `@scope/my-package`)
28
+ */
29
+ var PKG_NAME_PART = `(?:${WILDCARD}|${ALPHANUM_DASH})`;
30
+ var OPTIONAL_VERSION_PREFIX = `(?:v|${`(${PKG_NAME_PART}|@${PKG_NAME_PART}\\/${PKG_NAME_PART})`}@)`;
31
+ /**
32
+ * 3. Core SemVer Components
33
+ *
34
+ * Matches standard `MAJOR.MINOR.PATCH` versions or wildcard variants (e.g., `1.0.0`, `*.*.*`).
35
+ *
36
+ * Capture Groups:
37
+ * - Group 3: Major version
38
+ * - Group 4: Minor version
39
+ * - Group 5: Patch version
40
+ */
41
+ var CAPTURED_VERSION_DIGIT = `(${WILDCARD}|${NUMERIC_IDENTIFIER})`;
42
+ var SEMVER_CORE = `${CAPTURED_VERSION_DIGIT}\\.${CAPTURED_VERSION_DIGIT}\\.${CAPTURED_VERSION_DIGIT}`;
43
+ var PRERELEASE_IDENTIFIER = `(?:${WILDCARD}|${NUMERIC_IDENTIFIER}|(\\d*[a-zA-Z-][0-9a-zA-Z-]*))`;
44
+ var FULL_SEMVER_PATTERN = `${OPTIONAL_VERSION_PREFIX}?${`(${SEMVER_CORE}${`(?:-(${PRERELEASE_IDENTIFIER}(?:\\.${PRERELEASE_IDENTIFIER})*))`}?${`(?:\\+(${ALPHANUM_DASH}(?:\\.${ALPHANUM_DASH})*))`}?)`}`;
45
+ /**
46
+ * Regular expression to match and capture Semantic Versioning (SemVer) strings,
47
+ * including optional package prefixes (e.g., `@scope/pkg@`) and `v` prefixes.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * SEMVER_REGEX.test('1.0.0') // true
52
+ * SEMVER_REGEX.test('v1.2.3-beta.1+sha.1234') // true
53
+ * SEMVER_REGEX.test('@scope/package@1.0.0') // true
54
+ * ```
55
+ *
56
+ * @see {@link https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SemVer Specification}
57
+ */
58
+ var SEMVER_REGEX = new RegExp(FULL_SEMVER_PATTERN);
59
+ var DEV_NULL = new Writable({
60
+ /* istanbul ignore next */
61
+ write(_chunk, _encoding, callback) {
62
+ callback();
63
+ } });
64
+ var RELEASE_HOOK_NAMES = [
65
+ "configure",
66
+ "discover",
67
+ "analyze",
68
+ "build",
69
+ "write",
70
+ "publish",
71
+ "finalize"
72
+ ];
73
+ // src/util/buildTrailerPattern.ts
74
+ /**
75
+ * Build a regular expression to match trailer lines using custom markers.
76
+ *
77
+ * Combines the provided marker strings with a standard alphanumeric pattern
78
+ * to construct a regular expression that matches trailer definitions.
79
+ *
80
+ * @param markers Optional array of custom trailer marker strings
81
+ * @returns A regular expression matching trailer lines
82
+ */
83
+ function buildTrailerPattern(markers = []) {
84
+ return new RegExp(`^(${markers.map(RegExp.escape).concat("[A-Za-z0-9_-]+").join("|")})[ \\t]*:[ \\t]*(.*)$`);
85
+ }
86
+ // src/util/execCommand.ts
87
+ /**
88
+ * Execute a system command with arguments as a child process.
89
+ *
90
+ * Spawns the target process, collects output streams, and intercepts mutating
91
+ * `git` operations in test mode to inject deterministic commit timestamps.
92
+ *
93
+ * @param command Executable command name or path to spawn
94
+ * @param args Array of string arguments passed to the command
95
+ * @param options Execution environment, streaming, and signal options
96
+ * @returns Promise attached to the child process resolving to standard output
97
+ * @throws If process execution fails or exits with a non-zero status
98
+ */
99
+ function execCommand(command, args, options) {
100
+ const { cwd, signal } = options;
101
+ const env = {
102
+ HOME: process.env.HOME,
103
+ PATH: process.env.PATH,
104
+ SSH_AUTH_SOCK: process.env.SSH_AUTH_SOCK,
105
+ GIT_SSH: process.env.GIT_SSH,
106
+ GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND,
107
+ http_proxy: process.env.http_proxy,
108
+ https_proxy: process.env.https_proxy,
109
+ no_proxy: process.env.no_proxy,
110
+ HTTP_PROXY: process.env.HTTP_PROXY,
111
+ HTTPS_PROXY: process.env.HTTPS_PROXY,
112
+ NO_PROXY: process.env.NO_PROXY,
113
+ ...options.env
114
+ };
115
+ const child = spawn(command, args, {
116
+ cwd,
117
+ env,
118
+ signal,
119
+ stdio: [
120
+ "ignore",
121
+ "pipe",
122
+ "pipe"
123
+ ]
124
+ });
125
+ const promise = new Promise((resolve, reject) => {
126
+ const stdout = [];
127
+ const stderr = [];
128
+ let settled = false;
129
+ function safeResolve(value) {
130
+ /* istanbul ignore next */
131
+ if (settled) return;
132
+ settled = true;
133
+ cleanup();
134
+ resolve(value);
135
+ }
136
+ function safeReject(err) {
137
+ /* istanbul ignore next */
138
+ if (settled) return;
139
+ settled = true;
140
+ cleanup();
141
+ reject(err);
142
+ }
143
+ function cleanup() {
144
+ child.off("error", onError);
145
+ child.off("close", onClose);
146
+ child.stdout.removeAllListeners("data");
147
+ child.stderr.removeAllListeners("data");
148
+ if (options.stdout) {
149
+ child.stdout.unpipe(options.stdout);
150
+ options.stdout.off("error", onError);
151
+ }
152
+ if (options.stderr) {
153
+ child.stderr.unpipe(options.stderr);
154
+ options.stderr.off("error", onError);
155
+ }
156
+ }
157
+ function onError(err) {
158
+ safeReject(err);
159
+ }
160
+ function onClose(code, signal) {
161
+ /* istanbul ignore next */
162
+ if (settled) return;
163
+ if (code === 0) return safeResolve(bufferArrayToString(stdout));
164
+ const quotedCommand = quoteCommandForMessage([command, ...args].join(" "));
165
+ /* istanbul ignore next */
166
+ const exitStatus = code !== null ? `exit code ${code}` : signal ? `signal ${signal}` : "unknown status";
167
+ const errorDiagnostics = bufferArrayToString(stderr).trim() || bufferArrayToString(stdout).trim();
168
+ const errorMessage = [`Command ${quotedCommand} failed (${exitStatus})`, errorDiagnostics].filter(Boolean).join("\n");
169
+ const err = new Error(errorMessage, { cause: {
170
+ code,
171
+ signal,
172
+ diagnostics: errorDiagnostics
173
+ } });
174
+ /* istanbul ignore else */
175
+ if (code != null) Object.defineProperty(err, "code", { value: code });
176
+ safeReject(err);
177
+ }
178
+ child.on("error", onError);
179
+ child.on("close", onClose);
180
+ if (options.stdout) {
181
+ options.stdout.on("error", onError);
182
+ child.stdout.pipe(options.stdout);
183
+ } else child.stdout.on("data", (chunk) => stdout.push(chunk));
184
+ if (options.stderr) {
185
+ options.stderr.on("error", onError);
186
+ child.stderr.pipe(options.stderr);
187
+ } else child.stderr.on("data", (chunk) => stderr.push(chunk));
188
+ });
189
+ promise.child = child;
190
+ return promise;
191
+ }
192
+ function bufferArrayToString(chunks) {
193
+ return Buffer.concat(chunks).toString("utf-8");
194
+ }
195
+ function quoteCommandForMessage(command) {
196
+ if (!command.includes("'")) return `'${command}'`;
197
+ if (!command.includes("\"")) return `"${command}"`;
198
+ return JSON.stringify(command);
199
+ }
200
+ // src/util/execGit.ts
201
+ /**
202
+ * Execute a Git command inside a target directory.
203
+ *
204
+ * Wraps `execCommand` to invoke the `git` executable using the provided
205
+ * arguments and execution options.
206
+ *
207
+ * @param cwd Working directory path where the Git command runs
208
+ * @param args Command-line arguments passed to Git
209
+ * @param options Additional execution, environment, and stream options
210
+ * @returns Promise attached to the child process resolving to stdout
211
+ */
212
+ function execGit(cwd, args, options) {
213
+ return execCommand("git", args, {
214
+ ...options,
215
+ cwd
216
+ });
217
+ }
218
+ // src/util/formatError.ts
219
+ /**
220
+ * Normalize an unknown thrown value for logging or display.
221
+ *
222
+ * - If `err` is an `Error`, returns its `message` string.
223
+ * - Otherwise returns the original `err` value unchanged (may be a string,
224
+ * object, number, `null`, or `undefined`).
225
+ *
226
+ * This function intentionally does not coerce non-Error values to strings so
227
+ * callers can decide how to render structured values.
228
+ *
229
+ * @param err The thrown value to normalize
230
+ * @returns The error message when `err` is an `Error`, otherwise the original value
231
+ */
232
+ function formatError(err) {
233
+ if (Error.isError(err)) return err.message;
234
+ if (typeof err === "string") return err;
235
+ return err;
236
+ }
237
+ // src/util/isMatch.ts
238
+ /**
239
+ * Determine whether a target string matches glob patterns.
240
+ *
241
+ * Matches positive and negative glob patterns using dotfile support.
242
+ * Negation-only patterns are expanded with a catch-all pattern so they match
243
+ * every named target the patterns do not exclude.
244
+ *
245
+ * @param target Target string to evaluate against glob patterns
246
+ * @param patterns Single glob pattern or list of patterns to evaluate
247
+ * @returns True if target matches positive patterns and satisfies negative patterns
248
+ */
249
+ function isMatch(target, patterns) {
250
+ if (typeof patterns === "string") patterns = [patterns];
251
+ if (patterns.length > 0 && patterns.every((pattern) => pattern.startsWith("!"))) patterns = ["**/*", ...patterns];
252
+ const positives = [];
253
+ const negatives = [];
254
+ for (const pattern of patterns) if (pattern.startsWith("!")) negatives.push(pattern);
255
+ else positives.push(pattern);
256
+ return positives.some((pattern) => minimatch(target, pattern, { dot: true })) && negatives.every((pattern) => minimatch(target, pattern, { dot: true }));
257
+ }
258
+ // src/workflow/analysis/packageContainsCommit.ts
259
+ /**
260
+ * Test whether a commit modifies files in a package.
261
+ *
262
+ * @param pkg Package with an explicit file pattern or base directory
263
+ * @param commit Parsed commit containing changed file paths
264
+ * @returns `true` if any changed file matches the package pattern
265
+ */
266
+ function packageContainsCommit(pkg, commit) {
267
+ return commit.files.some((file) => {
268
+ const { location } = pkg;
269
+ return isMatch(file, pkg.files || path.join(location, "**/*"));
270
+ });
271
+ }
272
+ // src/git/commit/extractMentions.ts
273
+ var ALPHANUMERIC = "[a-zA-Z0-9]";
274
+ var SEPARATOR = "[-_]";
275
+ var USERNAME = `${ALPHANUMERIC}+(?:${SEPARATOR}+${ALPHANUMERIC}+)*`;
276
+ var EMAIL_LOCAL = "[a-zA-Z0-9._%+-]";
277
+ var DOMAIN_SUFFIX = "[a-zA-Z0-9.-]*\\.[a-zA-Z]{2,}";
278
+ var SCOPED_PACKAGE_SPEC_SUFFIX = `/${USERNAME}@[0-9]+\\.[0-9]+\\.[0-9]+`;
279
+ /**
280
+ * Extract unique mention handles from the input text string.
281
+ *
282
+ * Evaluates `text` against boundary rules to isolate valid handles while
283
+ * excluding email addresses, domain names, and scoped package specs, then
284
+ * de-duplicates the resulting handles.
285
+ *
286
+ * @param text The input string to parse for mentions
287
+ * @returns An array of unique mention handles
288
+ */
289
+ function extractMentions(text) {
290
+ if (!text) return [];
291
+ const regex = new RegExp(`(?<!${EMAIL_LOCAL})@(${USERNAME})\\b(?!${SEPARATOR}|${DOMAIN_SUFFIX}|${SCOPED_PACKAGE_SPEC_SUFFIX})`, "g");
292
+ const matches = text.matchAll(regex);
293
+ const mentions = new Set(matches.map((match) => match[1]));
294
+ return Array.from(mentions);
295
+ }
296
+ // src/cache/TTLCache.ts
297
+ /**
298
+ * A simple time-to-live cache that automatically evicts entries after a TTL.
299
+ *
300
+ * - Entries are removed automatically when their TTL expires.
301
+ * - Reading an entry resets its TTL to the original value.
302
+ * - Setting an existing key clears its previous timer and resets the TTL.
303
+ *
304
+ * @template K Type of cache keys
305
+ * @template V Type of cache values
306
+ */
307
+ var TTLCache = class {
308
+ cache = /* @__PURE__ */ new Map();
309
+ /**
310
+ * Store a value under `key` for `ttl` milliseconds.
311
+ *
312
+ * If the key already exists its previous timer is cleared and the TTL is reset.
313
+ *
314
+ * @param key Cache key
315
+ * @param value Value to store
316
+ * @param ttl Time to live in milliseconds (default: 60_000)
317
+ */
318
+ set(key, value, ttl = 6e4) {
319
+ const ref = this.cache.get(key);
320
+ if (ref) clearTimeout(ref.timer);
321
+ const timer = setTimeout(() => {
322
+ this.cache.delete(key);
323
+ }, ttl).unref();
324
+ this.cache.set(key, {
325
+ value,
326
+ timer,
327
+ ttl
328
+ });
329
+ }
330
+ /**
331
+ * Retrieve the value for `key`, or `undefined` if not present.
332
+ *
333
+ * Reading an entry resets its TTL to the original `ttl` provided when it was set.
334
+ *
335
+ * @param key Cache key
336
+ * @returns The stored value or `undefined` if not present
337
+ */
338
+ get(key) {
339
+ const ref = this.cache.get(key);
340
+ if (!ref) return void 0;
341
+ this.set(key, ref.value, ref.ttl);
342
+ return ref.value;
343
+ }
344
+ /**
345
+ * Check whether `key` exists in the cache.
346
+ *
347
+ * @param key Cache key
348
+ * @returns `true` if present; otherwise `false`
349
+ */
350
+ has(key) {
351
+ return this.cache.has(key);
352
+ }
353
+ /**
354
+ * Remove `key` from the cache and clear its eviction timer.
355
+ *
356
+ * @param key Cache key
357
+ * @returns `true` if the key was present and removed; otherwise `false`
358
+ */
359
+ delete(key) {
360
+ const ref = this.cache.get(key);
361
+ if (!ref) return false;
362
+ clearTimeout(ref.timer);
363
+ return this.cache.delete(key);
364
+ }
365
+ /**
366
+ * Clear all entries and their timers.
367
+ */
368
+ clear() {
369
+ for (const { timer } of this.cache.values()) clearTimeout(timer);
370
+ this.cache.clear();
371
+ }
372
+ };
373
+ // src/git/commit/parseGitCommit.ts
374
+ var BREAKING_HEADER_REGEX = /^([\w-]+)(?:\(([^)]+)\))?!: (.*)$/;
375
+ var BREAKING_MARKERS = ["BREAKING CHANGE", "BREAKING-CHANGE"];
376
+ /**
377
+ * Converge the parser's dynamically-shaped result into the typed commit
378
+ * shape used for release analysis.
379
+ *
380
+ * The parser assigns `type`, `scope`, and `subject` at runtime through its
381
+ * default header correspondence, so they exist on the result without being
382
+ * part of its declared return type; `header` is always a string once
383
+ * parsing succeeds because the parser rejects empty input.
384
+ *
385
+ * @param parsed The parser result to converge
386
+ * @returns The typed commit shape
387
+ */
388
+ function toCommit(parsed) {
389
+ return {
390
+ ...parsed,
391
+ type: parsed.type ?? null,
392
+ scope: parsed.scope ?? null,
393
+ subject: parsed.subject ?? "",
394
+ header: parsed.header ?? ""
395
+ };
396
+ }
397
+ /**
398
+ * Parse a git log entry into a structured commit object.
399
+ *
400
+ * Combines the commit subject and body, extracts conventional commit metadata
401
+ * using custom trailer markers and breaking header patterns, and normalizes
402
+ * dates to ISO format strings.
403
+ *
404
+ * @param entry The raw git log entry to parse
405
+ * @param markers Optional array of custom trailer marker strings
406
+ * @returns A structured commit object containing parsed details, notes, and mentions
407
+ */
408
+ async function parseGitCommit(entry, markers = []) {
409
+ const message = [entry.subject, entry.body].filter(Boolean).join("\n\n");
410
+ const commit = toCommit(new CommitParser({
411
+ breakingHeaderPattern: BREAKING_HEADER_REGEX,
412
+ noteKeywords: [],
413
+ notesPattern: () => buildTrailerPattern(BREAKING_MARKERS.concat(markers))
414
+ }).parse(message));
415
+ const notes = [];
416
+ const trailers = [];
417
+ for (const note of commit.notes) {
418
+ if (BREAKING_MARKERS.includes(note.title.toUpperCase())) notes.push(note);
419
+ trailers.push({
420
+ key: note.title,
421
+ value: note.text
422
+ });
423
+ }
424
+ if (notes.length === 0 && BREAKING_HEADER_REGEX.test(commit.header)) {
425
+ const note = {
426
+ title: "BREAKING CHANGE",
427
+ text: commit.subject
428
+ };
429
+ notes.push(note);
430
+ trailers.push({
431
+ key: note.title,
432
+ value: note.text
433
+ });
434
+ }
435
+ const mentions = extractMentions(message);
436
+ return {
437
+ ...commit,
438
+ hash: entry.hash,
439
+ parent: entry.parent,
440
+ authorDate: new Date(entry.authorDate).toISOString(),
441
+ committerDate: new Date(entry.committerDate).toISOString(),
442
+ type: commit.type?.toLowerCase() || null,
443
+ scope: commit.scope || null,
444
+ subject: commit.subject || null,
445
+ header: commit.header,
446
+ body: commit.body,
447
+ footer: commit.footer,
448
+ notes,
449
+ mentions,
450
+ trailers,
451
+ files: entry.files
452
+ };
453
+ }
454
+ // src/git/commit/parseGitPrettyFormat.ts
455
+ /**
456
+ * Field separator used in the git pretty format to produce a single-line
457
+ *, machine-parseable record.
458
+ */
459
+ var GIT_PRETTY_FIELD_SEPARATOR = "";
460
+ /**
461
+ * Pretty format string passed to `git log --pretty=format:`. Produces seven
462
+ * fields separated by `GIT_PRETTY_FIELD_SEPARATOR`:
463
+ * hash, parents, author date, committer date, subject, body, files.
464
+ */
465
+ var GIT_PRETTY_FORMAT = [
466
+ "%H",
467
+ "%P",
468
+ "%aI",
469
+ "%cI",
470
+ "%s",
471
+ "%b",
472
+ ""
473
+ ].join("");
474
+ /**
475
+ * Parse a single line produced by `git log --pretty=format:${GIT_PRETTY_FORMAT}`.
476
+ *
477
+ * The input is expected to contain seven fields separated by
478
+ * `GIT_PRETTY_FIELD_SEPARATOR`:
479
+ * 1. `hash` (commit hash)
480
+ * 2. `parent` (space-separated parent hashes)
481
+ * 3. `authorDate` (ISO 8601)
482
+ * 4. `committerDate` (ISO 8601)
483
+ * 5. `subject`
484
+ * 6. `body`
485
+ * 7. `files` (newline-separated list)
486
+ *
487
+ * The function trims fields, converts parent hashes into an array, normalizes
488
+ * dates to ISO strings, and splits `files` into an array. Missing optional
489
+ * fields are normalized to sensible defaults.
490
+ *
491
+ * @param raw Raw pretty-format string produced by git
492
+ * @returns Parsed `GitLogEntry` with `hash`, `parent`, `authorDate`, `committerDate`, `subject`, `body`, and `files`
493
+ * @throws If required fields (hash, authorDate, committerDate, subject) are missing or malformed
494
+ */
495
+ function parseGitPrettyFormat(raw) {
496
+ let [hash, parentHashes, authorDate, committerDate, subject, body, files] = raw.split("");
497
+ hash = hash?.trim();
498
+ parentHashes = parentHashes?.trim();
499
+ authorDate = authorDate?.trim();
500
+ committerDate = committerDate?.trim();
501
+ subject = subject?.trim();
502
+ body = body?.trim();
503
+ files = files?.trim();
504
+ if (!hash || !authorDate || !committerDate || typeof subject !== "string") throw new Error(`The input "${colors.bold(raw.slice(0, 200))}" is not in the expected pretty format.`, { cause: /* @__PURE__ */ new Error(`Pretty-format payload length: ${raw.length}`) });
505
+ return {
506
+ hash,
507
+ parent: parentHashes ? parentHashes.split(/\s+/) : [],
508
+ authorDate: new Date(authorDate).toISOString(),
509
+ committerDate: new Date(committerDate).toISOString(),
510
+ subject,
511
+ body: body ?? "",
512
+ files: files ? files.split("\n") : []
513
+ };
514
+ }
515
+ // src/git/commit/getParsedGitCommit.ts
516
+ var cache = new TTLCache();
517
+ /**
518
+ * Retrieve and parse a git commit by its reference.
519
+ *
520
+ * Fetches the raw git log entry for the specified `ref`, checking the local cache
521
+ * prior to parsing missing entries.
522
+ *
523
+ * @param cwd Current working directory path
524
+ * @param ref Git reference to fetch
525
+ * @param markers Optional array of custom trailer marker strings
526
+ * @returns Structured commit object
527
+ */
528
+ async function getParsedGitCommit(cwd, ref, markers = []) {
529
+ const entry = parseGitPrettyFormat(await execGit(cwd, [
530
+ "log",
531
+ "-1",
532
+ ref,
533
+ "--name-only",
534
+ `--pretty=format:${GIT_PRETTY_FORMAT}`
535
+ ]));
536
+ const key = JSON.stringify([
537
+ entry.hash,
538
+ entry.parent,
539
+ markers
540
+ ]);
541
+ const cached = cache.get(key);
542
+ if (cached) return cached;
543
+ const parsed = await parseGitCommit(entry, markers);
544
+ cache.set(key, parsed);
545
+ return parsed;
546
+ }
547
+ // src/git/history/countGitHistory.ts
548
+ /**
549
+ * Count mainline commits reachable from a given reference.
550
+ *
551
+ * Uses `git rev-list --count --first-parent` to calculate the length of the
552
+ * primary history trunk, excluding commits introduced by side-branch merges.
553
+ *
554
+ * @param cwd Repository working directory
555
+ * @param ref Commit reference to count from (defaults to `HEAD`)
556
+ * @returns Number of commits along the primary branch line up to `ref`
557
+ */
558
+ async function countGitHistory(cwd, ref = "HEAD") {
559
+ const stdout = await execGit(cwd, [
560
+ "rev-list",
561
+ "--count",
562
+ "--first-parent",
563
+ ref
564
+ ]);
565
+ return Number.parseInt(stdout.trim(), 10);
566
+ }
567
+ // src/git/repository/isGitShallowRepository.ts
568
+ /**
569
+ * Determine whether the repository at `cwd` is a shallow clone.
570
+ *
571
+ * Runs `git rev-parse --is-shallow-repository` to detect shallow clones.
572
+ * Useful before operations that require full history.
573
+ *
574
+ * @param cwd Repository working directory
575
+ * @returns `true` if shallow, `false` if full clone
576
+ * @throws If the underlying Git command fails
577
+ */
578
+ async function isGitShallowRepository(cwd) {
579
+ return (await execGit(cwd, ["rev-parse", "--is-shallow-repository"])).trim() === "true";
580
+ }
581
+ // src/git/repository/withShallowLock.ts
582
+ var lockQueue = /* @__PURE__ */ new Map();
583
+ var context = new AsyncLocalStorage();
584
+ /**
585
+ * Serialize access to a shallow Git repository while running a callback.
586
+ *
587
+ * If `cwd` is a shallow clone, callers from different async contexts are
588
+ * executed one at a time; nested calls within the same async context run
589
+ * immediately without waiting. If the repository becomes non-shallow before
590
+ * a queued turn runs, downstream waiters are released early.
591
+ *
592
+ * @param cwd Repository working directory path string
593
+ * @param callback Function to execute while the lock is held
594
+ * @returns Promise resolving to the result of `callback`
595
+ */
596
+ async function withShallowLock(cwd, callback) {
597
+ if (!await isGitShallowRepository(cwd)) return callback();
598
+ const active = context.getStore();
599
+ if (active?.has(cwd)) return callback();
600
+ const { promise, resolve } = Promise.withResolvers();
601
+ const previous = lockQueue.get(cwd) ?? Promise.resolve();
602
+ const queued = previous.then(() => promise);
603
+ lockQueue.set(cwd, queued);
604
+ await previous;
605
+ if (!await isGitShallowRepository(cwd)) resolve();
606
+ try {
607
+ return await context.run(new Set(active).add(cwd), callback);
608
+ } finally {
609
+ resolve();
610
+ if (lockQueue.get(cwd) === queued) lockQueue.delete(cwd);
611
+ }
612
+ }
613
+ // src/git/revision/isGitAncestor.ts
614
+ /**
615
+ * Determine whether `ancestor` is an ancestor of `descendant`.
616
+ *
617
+ * Runs `git merge-base --is-ancestor <ancestor> <descendant>` in the repository at `cwd`.
618
+ * Resolves to `true` if `ancestor` is an ancestor, `false` if not.
619
+ * Rethrows errors for invalid refs or other failures.
620
+ *
621
+ * @param cwd Repository working directory
622
+ * @param ancestor Candidate ancestor ref
623
+ * @param descendant Candidate descendant ref
624
+ * @returns Resolves to `true` if `ancestor` is an ancestor of `descendant`, `false` otherwise
625
+ * @throws If a ref is invalid or the Git command fails
626
+ */
627
+ function isGitAncestor(cwd, ancestor, descendant) {
628
+ return execGit(cwd, [
629
+ "merge-base",
630
+ "--is-ancestor",
631
+ ancestor,
632
+ descendant
633
+ ]).then(() => true).catch((err) => {
634
+ if (err?.code === 1) return false;
635
+ throw err;
636
+ });
637
+ }
638
+ // src/git/revision/resolveGitRevision.ts
639
+ /**
640
+ * Resolve a Git revision or commit-ish expression to its full commit hash.
641
+ *
642
+ * Runs `git rev-parse --verify <revision>^{commit}` under the hood. Peels annotated
643
+ * tags, branches, short SHAs, and relative expressions down to a verified commit object.
644
+ *
645
+ * @param cwd The repository working directory
646
+ * @param revision The Git revision or expression to resolve
647
+ * @returns A promise that resolves to the full, trimmed commit SHA-1 string
648
+ */
649
+ async function resolveGitRevision(cwd, revision) {
650
+ return (await execGit(cwd, [
651
+ "rev-parse",
652
+ "--verify",
653
+ `${revision}^{commit}`
654
+ ])).trim();
655
+ }
656
+ // src/git/history/expandGitHistory.ts
657
+ /**
658
+ * Deepen a shallow clone so additional commits become available.
659
+ *
660
+ * Attempts a single `--shallow-since` fetch to reach `until` (if provided),
661
+ * otherwise deepens by `pageSize`, accounting for existing depth when `from`
662
+ * is supplied. Operation is serialized to avoid concurrent deepens.
663
+ *
664
+ * @param cwd Repository working directory
665
+ * @param options Options: { pageSize?, from?, until? }
666
+ * @returns true if history was deepened or already sufficient, otherwise false
667
+ */
668
+ async function expandGitHistory(cwd, options = {}) {
669
+ if (!await isGitShallowRepository(cwd)) return false;
670
+ return withShallowLock(cwd, async () => {
671
+ const { until } = options;
672
+ let { from } = options;
673
+ let { pageSize = 50 } = options;
674
+ if (until) {
675
+ if (await isGitAncestor(cwd, until, "HEAD")) return true;
676
+ const commitDate = (await execGit(cwd, [
677
+ "show",
678
+ "-s",
679
+ "--format=%cI",
680
+ `${until}^{commit}`
681
+ ])).trim();
682
+ try {
683
+ await execGit(cwd, [
684
+ "-c",
685
+ "fetch.negotiationAlgorithm=skipping",
686
+ "fetch",
687
+ `--shallow-since=${commitDate}`,
688
+ "--update-shallow",
689
+ "--filter=blob:none"
690
+ ]);
691
+ return true;
692
+ } catch (error) {
693
+ options.logger?.debug(`Shallow fetch to reach "${until}" failed and incremental deepening will be attempted: ${formatError(error)}`);
694
+ }
695
+ }
696
+ if (from) {
697
+ from = await resolveGitRevision(cwd, from);
698
+ const depth = await countGitHistory(cwd, from);
699
+ if (depth > pageSize) return true;
700
+ pageSize -= depth - 1;
701
+ }
702
+ try {
703
+ await execGit(cwd, [
704
+ "-c",
705
+ "fetch.negotiationAlgorithm=skipping",
706
+ "fetch",
707
+ `--deepen=${pageSize}`,
708
+ "--update-shallow",
709
+ "--filter=blob:none",
710
+ ...from && !await isGitAncestor(cwd, from, "HEAD") ? [
711
+ "origin",
712
+ from,
713
+ "HEAD"
714
+ ] : []
715
+ ]);
716
+ return true;
717
+ } catch (error) {
718
+ options.logger?.debug(`Shallow history at "${cwd}" could not be deepened by ${pageSize} commits: ${formatError(error)}`);
719
+ return false;
720
+ }
721
+ });
722
+ }
723
+ // src/git/tag/deleteGitTag.ts
724
+ /**
725
+ * Delete a local git tag in the repository at `cwd`.
726
+ *
727
+ * @param cwd Repository working directory
728
+ * @param tag Tag name to delete
729
+ * @returns `true` when deletion succeeded, otherwise `false`
730
+ */
731
+ function deleteGitTag(cwd, tag) {
732
+ return execGit(cwd, [
733
+ "tag",
734
+ "-d",
735
+ tag
736
+ ]).then(() => true).catch(() => false);
737
+ }
738
+ // src/git/tag/isGitTagPresent.ts
739
+ /**
740
+ * Determine whether a specific git tag exists locally in the repository.
741
+ *
742
+ * @param cwd Working directory for the git command
743
+ * @param tag Name of the tag to evaluate
744
+ * @returns True if the tag reference exists locally, false otherwise
745
+ */
746
+ function isGitTagPresent(cwd, tag) {
747
+ return resolveGitRevision(cwd, `refs/tags/${tag}`).then(() => true).catch(() => false);
748
+ }
749
+ // src/git/tag/ensureGitTag.ts
750
+ var MIN_HISTORY_DEPTH = 2;
751
+ var ORIGIN_NOT_REPO = `fatal: 'origin' does not appear to be a git repository`;
752
+ var REMOTE_REF_NOT_FOUND = `fatal: couldn't find remote ref`;
753
+ /**
754
+ * Ensure a tag exists locally, fetching it shallowly from `origin` if needed.
755
+ *
756
+ * Acquires a shallow-fetch lock, verifies local presence and history depth,
757
+ * attempts a shallow fetch of `refs/tags/<tag>` when required, and removes a
758
+ * local tag if the remote reports the tag is missing — warning before the
759
+ * deletion and skipping it entirely in dry-run mode.
760
+ *
761
+ * @param cwd Working directory
762
+ * @param tag Tag name (for example `v1.2.0`)
763
+ * @param options Dry-run and logging guards for the local tag deletion
764
+ * @returns `true` if the tag is present or was fetched; otherwise `false`
765
+ */
766
+ function ensureGitTag(cwd, tag, options) {
767
+ return withShallowLock(cwd, async () => {
768
+ const tagRef = `refs/tags/${tag}`;
769
+ if (await isGitTagPresent(cwd, tag) && await countGitHistory(cwd, tagRef) >= MIN_HISTORY_DEPTH) return true;
770
+ try {
771
+ await execGit(cwd, [
772
+ "fetch",
773
+ "origin",
774
+ `${tagRef}:${tagRef}`,
775
+ `--depth=${MIN_HISTORY_DEPTH}`,
776
+ "--update-shallow",
777
+ "--force"
778
+ ]);
779
+ return true;
780
+ } catch (err) {
781
+ const errorMessage = err?.message;
782
+ if (errorMessage?.includes(ORIGIN_NOT_REPO)) return await isGitTagPresent(cwd, tag);
783
+ if (errorMessage?.includes(REMOTE_REF_NOT_FOUND)) {
784
+ if (await isGitTagPresent(cwd, tag)) {
785
+ if (options?.dryRun) options.logger?.warn(`[DRY RUN] Local tag "${tag}" would be deleted because the remote no longer reports it.`);
786
+ else {
787
+ options?.logger?.warn(`Local tag "${tag}" is being deleted because the remote no longer reports it.`);
788
+ await deleteGitTag(cwd, tag);
789
+ }
790
+ }
791
+ }
792
+ }
793
+ return false;
794
+ });
795
+ }
796
+ // src/git/tag/generateGitTagName.ts
797
+ function generateGitTagName(entry, name, version) {
798
+ if (!version) return null;
799
+ if (entry) return `v${version}`;
800
+ if (!name) throw new Error("Package name is required to build a tag name.");
801
+ return `${name}@${version}`;
802
+ }
803
+ // src/git/tag/getGitTagMessage.ts
804
+ /**
805
+ * Get the message of an annotated git tag in the repository at `cwd`.
806
+ *
807
+ * @param cwd Repository working directory
808
+ * @param tag Tag name to query
809
+ * @returns The tag message string when found, otherwise `undefined`
810
+ */
811
+ async function getGitTagMessage(cwd, tag) {
812
+ try {
813
+ const [objectType, message] = (await execGit(cwd, [
814
+ "for-each-ref",
815
+ "--format=%(objecttype)%00%(contents)",
816
+ `refs/tags/${tag}`
817
+ ])).split("\0");
818
+ if (objectType?.trim() !== "tag") return;
819
+ return message?.trim() || void 0;
820
+ } catch {
821
+ /* istanbul ignore next */
822
+ return;
823
+ }
824
+ }
825
+ // src/git/tag/isGitTagConnected.ts
826
+ /**
827
+ * Determine whether a specific git tag commit is reachable from the current HEAD.
828
+ *
829
+ * Uses `git merge-base --is-ancestor refs/tags/<tag>^{commit} HEAD` to verify
830
+ * that the tag's commit is an ancestor of the current reference. Any non-zero
831
+ * exit status or execution error is treated as "not reachable".
832
+ *
833
+ * @param cwd Working directory where the git command will run
834
+ * @param tag Tag name to evaluate (for example, "v1.2.0")
835
+ * @returns True if the tag commit is reachable from HEAD, false otherwise
836
+ */
837
+ async function isGitTagConnected(cwd, tag) {
838
+ try {
839
+ await execGit(cwd, [
840
+ "merge-base",
841
+ "--is-ancestor",
842
+ `refs/tags/${tag}^{commit}`,
843
+ "HEAD"
844
+ ]);
845
+ return true;
846
+ } catch {
847
+ return false;
848
+ }
849
+ }
850
+ // src/workflow/discovery/verifyPackageTag.ts
851
+ /**
852
+ * Verify a Git tag against package specifications and repository history.
853
+ *
854
+ * Ensures the target tag exists locally before parsing its commit data. Rejects
855
+ * tags that do not target a commit matching the specified `pkg`. Expands the
856
+ * history graph up to the tag reference before verifying structural connectivity.
857
+ *
858
+ * @param cwd Repository working directory path
859
+ * @param pkg Package descriptor containing version and location context
860
+ * @param tagName Name of the Git tag to verify
861
+ * @param options Dry-run and logging guards for the local tag cleanup
862
+ * @returns True if the tag is valid and connected; otherwise, false
863
+ */
864
+ async function verifyPackageTag(cwd, pkg, tagName, options) {
865
+ await ensureGitTag(cwd, tagName, options);
866
+ const tagRef = `refs/tags/${tagName}`;
867
+ let tagCommit;
868
+ try {
869
+ tagCommit = await getParsedGitCommit(cwd, tagRef);
870
+ } catch {
871
+ return false;
872
+ }
873
+ if (!packageContainsCommit(pkg, tagCommit)) return false;
874
+ await expandGitHistory(cwd, {
875
+ until: tagRef,
876
+ logger: options?.logger
877
+ });
878
+ return isGitTagConnected(cwd, tagName);
879
+ }
880
+ // package.json
881
+ var version = "0.13.0";
882
+ export { DEV_NULL as A, isMatch as C, buildTrailerPattern as D, execCommand as E, RELEASE_HOOK_NAMES as M, SEMVER_REGEX as N, ALL_FILES as O, packageContainsCommit as S, execGit as T, GIT_PRETTY_FORMAT as _, generateGitTagName as a, TTLCache as b, deleteGitTag as c, isGitAncestor as d, withShallowLock as f, GIT_PRETTY_FIELD_SEPARATOR as g, getParsedGitCommit as h, getGitTagMessage as i, GIT_TRAILER_RELEASE_AGENT as j, DEFAULT_CHANGELOG_FILE as k, expandGitHistory as l, countGitHistory as m, verifyPackageTag as n, ensureGitTag as o, isGitShallowRepository as p, isGitTagConnected as r, isGitTagPresent as s, version as t, resolveGitRevision as u, parseGitPrettyFormat as v, formatError as w, extractMentions as x, parseGitCommit as y };
883
+
884
+ //# sourceMappingURL=package-Bczytil1.js.map