@reelout/core 0.6.0 → 0.8.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 (49) hide show
  1. package/dist/analyzer.js +14 -10
  2. package/dist/analyzer.js.map +1 -1
  3. package/dist/builder.js +1 -1
  4. package/dist/changelog.js +1 -1
  5. package/dist/index.js +2 -51
  6. package/dist/index.js.map +1 -1
  7. package/dist/{workflow-c9uKSARL.js → workflow-MQRNVoZo.js} +765 -732
  8. package/dist/workflow-MQRNVoZo.js.map +1 -0
  9. package/package.json +1 -1
  10. package/src/analyzer.ts +27 -17
  11. package/src/config/const.ts +0 -2
  12. package/src/git/history/index.ts +2 -2
  13. package/src/git/history/{showGitHistory.ts → readGitHistory.ts} +3 -3
  14. package/src/git/history/{showParsedGitHistory.ts → readParsedGitHistory.ts} +6 -6
  15. package/src/git/tag/generateGitTagName.ts +1 -0
  16. package/src/git/tag/index.ts +1 -1
  17. package/src/git/tag/{isGitTagPointed.ts → isGitTagExact.ts} +1 -1
  18. package/src/util/index.ts +1 -0
  19. package/src/util/isGitHubActions.ts +18 -0
  20. package/src/workflow/analysis/deriveChangeReleases.ts +3 -3
  21. package/src/workflow/analysis/deriveTransitionReleases.ts +1 -1
  22. package/src/workflow/analysis/index.ts +1 -5
  23. package/src/workflow/analysis/{isCommitForPackage.ts → packageContainsCommit.ts} +4 -1
  24. package/src/workflow/analysis/readPackageHistory.ts +28 -9
  25. package/src/workflow/commit/index.ts +4 -0
  26. package/src/workflow/discovery/verifyPackageTag.ts +2 -2
  27. package/src/workflow/executeReleaseWorkflow.ts +11 -2
  28. package/src/workflow/index.ts +2 -2
  29. package/src/workflow/report/appendReleaseReportSummary.ts +115 -0
  30. package/src/workflow/report/index.ts +2 -0
  31. package/src/workflow/report/printReleaseReportAnnotation.ts +35 -0
  32. package/src/workflow/{versioning/determineReleaseType.ts → version/deriveCommitReleaseType.ts} +2 -2
  33. package/src/workflow/{versioning → version}/deriveReleaseType.ts +2 -2
  34. package/src/workflow/{versioning → version}/index.ts +2 -1
  35. package/dist/workflow-c9uKSARL.js.map +0 -1
  36. package/src/workflow/analysis/collectUnreleased.ts +0 -44
  37. package/src/workflow/analysis/sliceUnreleased.ts +0 -24
  38. package/src/workflow/analysis/sliceUnreleasedForPackage.ts +0 -41
  39. package/src/workflow/committing/formatReleaseFilterPatterns.ts +0 -18
  40. package/src/workflow/committing/index.ts +0 -7
  41. package/src/workflow/committing/isReleaseCommit.ts +0 -56
  42. package/src/workflow/committing/readReleaseFilterPatterns.ts +0 -38
  43. /package/src/workflow/{committing → commit}/generateReleaseCommitMessage.ts +0 -0
  44. /package/src/workflow/{versioning → version}/bumpVersion.ts +0 -0
  45. /package/src/workflow/{versioning → version}/extractVersionQualifier.ts +0 -0
  46. /package/src/workflow/{versioning → version}/isSameReleaseCycle.ts +0 -0
  47. /package/src/workflow/{versioning → version}/isStableVersion.ts +0 -0
  48. /package/src/workflow/{versioning → version}/pickPriorityReleaseType.ts +0 -0
  49. /package/src/workflow/{analysis → version}/promotePrereleaseVersions.ts +0 -0
@@ -1,19 +1,275 @@
1
+ import semver from "semver";
2
+ import { colors } from "consola/utils";
3
+ import { Writable } from "node:stream";
1
4
  import { spawn } from "node:child_process";
2
5
  import prettier from "prettier";
3
6
  import { minimatch } from "minimatch";
4
- import { colors } from "consola/utils";
5
7
  import fs, { readFile } from "node:fs/promises";
6
8
  import path from "node:path";
7
9
  import { CommitParser } from "conventional-commits-parser";
8
10
  import { AsyncLocalStorage } from "node:async_hooks";
9
11
  import GitHost from "hosted-git-info";
10
- import { Writable } from "node:stream";
11
- import semver from "semver";
12
12
  import { fromMarkdown } from "mdast-util-from-markdown";
13
13
  import assert from "node:assert";
14
14
  import createPreset from "conventional-changelog-conventionalcommits";
15
15
  import { writeChangelogString } from "conventional-changelog-writer";
16
16
  import { toMarkdown } from "mdast-util-to-markdown";
17
+ import { appendFileSync } from "node:fs";
18
+ // src/workflow/version/extractVersionQualifier.ts
19
+ /**
20
+ * Extract the version qualifier string from a parsed `SemVer` instance.
21
+ *
22
+ * Strips the trailing numeric counter from the `prerelease` components if
23
+ * present. Joins any remaining prerelease identifiers with a dot separator.
24
+ *
25
+ * @param version Parsed `SemVer` instance or nullish value to inspect
26
+ * @returns The extracted qualifier string or `undefined` if no prerelease exists
27
+ */
28
+ function extractVersionQualifier(version) {
29
+ if (version != null && version.prerelease.length > 0) {
30
+ const prerelease = [...version.prerelease];
31
+ if (typeof prerelease.at(-1) === "number") prerelease.pop();
32
+ return prerelease.join(".");
33
+ } else return;
34
+ }
35
+ // src/workflow/version/bumpVersion.ts
36
+ /**
37
+ * Bump a semantic version string based on release and transition rules.
38
+ *
39
+ * Parses the target version and determines the next version string using the
40
+ * specified release type, prerelease identifier, and transition mode. Adjusts
41
+ * prerelease types when continuing an existing qualifier and returns `null` when
42
+ * `options.release` is omitted or if transition conditions fail.
43
+ *
44
+ * @param options Version bump configuration including release type, identifier, and transition rules
45
+ * @returns The bumped semantic version string, or `null` if no bump occurs
46
+ * @throws If `options.version` is not a valid semantic version
47
+ */
48
+ function bumpVersion(options) {
49
+ const { version } = options;
50
+ const parsed = semver.parse(version);
51
+ if (!parsed) throw new Error(`Version "${version}" is not a valid semantic version.`);
52
+ if (!options.release) return null;
53
+ if (parsed.prerelease.length > 0) {
54
+ if (options.transition === "advance" && options.identifier == null) return null;
55
+ } else if (options.transition === "continue") return null;
56
+ let release = options.release;
57
+ let identifier;
58
+ if (typeof options.identifier === "string") {
59
+ release = `pre${options.release}`;
60
+ identifier = options.identifier;
61
+ const parsedIdentifier = extractVersionQualifier(parsed);
62
+ const transition = options.transition ?? (parsedIdentifier && identifier === "" ? "advance" : "continue");
63
+ if (typeof parsedIdentifier === "string" && transition === "continue") {
64
+ if (release === "premajor" && parsed.minor === 0 && parsed.patch === 0 || release === "preminor" && parsed.patch === 0 || release === "prepatch") release = "prerelease";
65
+ }
66
+ }
67
+ return semver.inc(parsed, release, { loose: false }, identifier, "0");
68
+ }
69
+ // src/workflow/version/deriveCommitReleaseType.ts
70
+ /**
71
+ * Derive the release type for a single commit.
72
+ *
73
+ * Returns `'minor'` for a commit marked as a breaking change while the
74
+ * supplied `version` is zero-major (`0.y.z`), and `'major'` otherwise, since
75
+ * SemVer treats `0.y.z` as initial development where breaking changes do not
76
+ * require a new major version. Otherwise, routes the commit through the
77
+ * custom `classifier` and ensures the resolved value is a valid semantic
78
+ * versioning release type.
79
+ *
80
+ * @param classifier Function mapping commits to release types
81
+ * @param commit Parsed commit to evaluate
82
+ * @param version Current package version used to adjust zero-major breaking releases
83
+ * @returns `ReleaseType` string, or `null` when no matching rule applies
84
+ */
85
+ function deriveCommitReleaseType(classifier, commit, version) {
86
+ if (commit.notes.length > 0) return semver.parse(version)?.major === 0 ? "minor" : "major";
87
+ const type = classifier(commit);
88
+ switch (type) {
89
+ case "major":
90
+ case "minor":
91
+ case "patch": return type;
92
+ }
93
+ return null;
94
+ }
95
+ // src/workflow/version/pickPriorityReleaseType.ts
96
+ /**
97
+ * Determine the highest-priority release type between two candidates.
98
+ *
99
+ * Compares release types by precedence order: `major` > `minor` > `patch`.
100
+ * Returns the higher-precedence type, or `null` if neither applies.
101
+ *
102
+ * @param curr Current accumulated release type
103
+ * @param next Candidate release type to consider
104
+ * @returns Highest-precedence `ReleaseType`, or `null` if neither applies
105
+ */
106
+ function pickPriorityReleaseType(curr, next) {
107
+ for (const type of [
108
+ "major",
109
+ "minor",
110
+ "patch"
111
+ ]) if (curr === type || next === type) return type;
112
+ return null;
113
+ }
114
+ // src/workflow/version/deriveReleaseType.ts
115
+ /**
116
+ * Derive the combined release type from a release plan.
117
+ *
118
+ * Processes the plan's commits sequentially, accumulating the
119
+ * highest-precedence release type found by evaluating each individual commit
120
+ * and comparing it against the current maximum via `pickPriorityReleaseType`.
121
+ * Breaking commits resolve to `minor` while the plan's package version is
122
+ * zero-major (`0.y.z`).
123
+ *
124
+ * @param classifier Function mapping commits to release types
125
+ * @param plan Release plan carrying the commit history and package version
126
+ * @returns `ReleaseType` string, or `null` when no matching rule applies
127
+ */
128
+ function deriveReleaseType(classifier, plan) {
129
+ let releaseType = null;
130
+ for (const commit of plan.history) releaseType = pickPriorityReleaseType(releaseType, deriveCommitReleaseType(classifier, commit, plan.package.version));
131
+ return releaseType;
132
+ }
133
+ // src/workflow/version/isSameReleaseCycle.ts
134
+ /**
135
+ * Determine whether two semantic version strings or objects belong to the same release cycle.
136
+ *
137
+ * Compares the main version components of `currentVersion` and `nextVersion` to
138
+ * determine equality. Treats a transition from a non-zero `0.x` version to
139
+ * `1.0.0` as part of the same release cycle. Returns `false` if either input
140
+ * cannot be parsed.
141
+ *
142
+ * @param currentVersion Starting version string, `semver.SemVer` instance, or nullish value
143
+ * @param nextVersion Target version string, `semver.SemVer` instance, or nullish value
144
+ * @returns `true` if both versions belong to the same release cycle, `false` otherwise
145
+ */
146
+ function isSameReleaseCycle(currentVersion, nextVersion) {
147
+ const current = semver.parse(currentVersion);
148
+ const next = semver.parse(nextVersion);
149
+ if (!current || !next) return false;
150
+ if (current.compareMain(next) === 0) return true;
151
+ return current.major === 0 && (current.minor > 0 || current.patch > 0) && next.major === 1 && next.minor === 0 && next.patch === 0;
152
+ }
153
+ // src/workflow/version/isStableVersion.ts
154
+ /**
155
+ * Determine whether a version string represents a stable SemVer release.
156
+ *
157
+ * A version is considered stable when:
158
+ * - It is a valid SemVer string.
159
+ * - Its major version is greater than 0 (not 0.x.x).
160
+ * - It contains no prerelease identifiers (no `-alpha`, `-beta`, `-rc`, etc.).
161
+ *
162
+ * Build metadata (the `+` suffix) does not affect stability.
163
+ *
164
+ * @param version Semantic version string to check
165
+ * @returns `true` if `version` is a stable SemVer; otherwise `false`
166
+ * @throws If `version` is not a valid SemVer string
167
+ */
168
+ function isStableVersion(version) {
169
+ const parsed = semver.parse(version);
170
+ if (!parsed) throw new Error(`The version "${colors.bold(version)}" is not a valid SemVer.`);
171
+ return parsed.major > 0 && parsed.prerelease.length === 0;
172
+ }
173
+ // src/workflow/version/promotePrereleaseVersions.ts
174
+ /**
175
+ * Promote prerelease versions when they have no explicit release type.
176
+ *
177
+ * Analyzes prerelease and zero-major versions to determine an appropriate
178
+ * release type for graduation:
179
+ * - Prerelease versions are promoted based on their highest incremented component
180
+ * (patch, minor, or major)
181
+ * - Zero-major versions (0.y.z) are promoted to major
182
+ * - Stable versions (1.0.0+) remain unchanged
183
+ * - Plans with explicit releases are preserved as-is
184
+ *
185
+ * @param plans Release plans to analyze
186
+ * @returns Plans with inferred release types for prerelease versions
187
+ */
188
+ async function promotePrereleaseVersions(plans) {
189
+ return plans.map((plan) => {
190
+ if (plan.release) return plan;
191
+ if (!plan.package.tag) return plan;
192
+ const parsed = semver.parse(plan.package.version);
193
+ if (!parsed) return plan;
194
+ let type;
195
+ if (parsed.prerelease.length) {
196
+ if (parsed.patch !== 0) type = "patch";
197
+ else if (parsed.minor !== 0) type = "minor";
198
+ else if (parsed.major !== 0) type = "major";
199
+ else type = "major";
200
+ } else if (parsed.major === 0) type = "major";
201
+ if (type) return {
202
+ ...plan,
203
+ release: { type }
204
+ };
205
+ return plan;
206
+ });
207
+ }
208
+ // src/config/const.ts
209
+ var ALL_FILES = "**/*";
210
+ var DEFAULT_CHANGELOG_FILE = "CHANGELOG.md";
211
+ var GIT_TRAILER_RELEASE_AGENT = "Release-Agent";
212
+ /**
213
+ * 1. Primitive Building Blocks
214
+ *
215
+ * Base regular expression patterns for wildcards, alphanumeric strings with hyphens,
216
+ * and standard non-negative integers.
217
+ */
218
+ var WILDCARD = "\\*";
219
+ var ALPHANUM_DASH = "[0-9a-zA-Z-]+";
220
+ var NUMERIC_IDENTIFIER = "0|[1-9]\\d*";
221
+ /**
222
+ * 2. Package Name & Prefix Constructs
223
+ *
224
+ * Matches package name prefixes (unscoped or scoped) or a simple `v` prefix.
225
+ *
226
+ * Capture Groups:
227
+ * - Group 1: Package name (e.g., `my-package` or `@scope/my-package`)
228
+ */
229
+ var PKG_NAME_PART = `(?:${WILDCARD}|${ALPHANUM_DASH})`;
230
+ var OPTIONAL_VERSION_PREFIX = `(?:v|${`(${PKG_NAME_PART}|@${PKG_NAME_PART}\\/${PKG_NAME_PART})`}@)`;
231
+ /**
232
+ * 3. Core SemVer Components
233
+ *
234
+ * Matches standard `MAJOR.MINOR.PATCH` versions or wildcard variants (e.g., `1.0.0`, `*.*.*`).
235
+ *
236
+ * Capture Groups:
237
+ * - Group 3: Major version
238
+ * - Group 4: Minor version
239
+ * - Group 5: Patch version
240
+ */
241
+ var CAPTURED_VERSION_DIGIT = `(${WILDCARD}|${NUMERIC_IDENTIFIER})`;
242
+ var SEMVER_CORE = `${CAPTURED_VERSION_DIGIT}\\.${CAPTURED_VERSION_DIGIT}\\.${CAPTURED_VERSION_DIGIT}`;
243
+ var PRERELEASE_IDENTIFIER = `(?:${WILDCARD}|${NUMERIC_IDENTIFIER}|(\\d*[a-zA-Z-][0-9a-zA-Z-]*))`;
244
+ var FULL_SEMVER_PATTERN = `${OPTIONAL_VERSION_PREFIX}?${`(${SEMVER_CORE}${`(?:-(${PRERELEASE_IDENTIFIER}(?:\\.${PRERELEASE_IDENTIFIER})*))`}?${`(?:\\+(${ALPHANUM_DASH}(?:\\.${ALPHANUM_DASH})*))`}?)`}`;
245
+ /**
246
+ * Regular expression to match and capture Semantic Versioning (SemVer) strings,
247
+ * including optional package prefixes (e.g., `@scope/pkg@`) and `v` prefixes.
248
+ *
249
+ * @example
250
+ * ```ts
251
+ * SEMVER_REGEX.test('1.0.0') // true
252
+ * SEMVER_REGEX.test('v1.2.3-beta.1+sha.1234') // true
253
+ * SEMVER_REGEX.test('@scope/package@1.0.0') // true
254
+ * ```
255
+ *
256
+ * @see {@link https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SemVer Specification}
257
+ */
258
+ var SEMVER_REGEX = new RegExp(FULL_SEMVER_PATTERN);
259
+ var DEV_NULL = new Writable({
260
+ /* istanbul ignore next */
261
+ write(_chunk, _encoding, callback) {
262
+ callback();
263
+ } });
264
+ var RELEASE_HOOK_NAMES = [
265
+ "configure",
266
+ "discover",
267
+ "analyze",
268
+ "build",
269
+ "write",
270
+ "publish",
271
+ "finalize"
272
+ ];
17
273
  // src/util/buildTrailerPattern.ts
18
274
  /**
19
275
  * Build a regular expression to match trailer lines using custom markers.
@@ -294,6 +550,21 @@ function interpolate(template, data) {
294
550
  }
295
551
  return result;
296
552
  }
553
+ // src/util/isTruthyString.ts
554
+ /**
555
+ * Determine whether a string value represents a truthy boolean.
556
+ *
557
+ * Trims leading and trailing whitespace and coerces the target string to
558
+ * lowercase. Evaluates the string as truthy if it equals `'true'` or `'1'`.
559
+ *
560
+ * @param value The raw string to evaluate
561
+ * @returns `true` if `value` normalizes to `'true'` or `'1'`, otherwise `false`
562
+ */
563
+ function isTruthyString(value) {
564
+ if (!value) return false;
565
+ const normalized = value.toLowerCase().trim();
566
+ return normalized === "true" || normalized === "1";
567
+ }
297
568
  // src/util/isClass.ts
298
569
  /**
299
570
  * Determine whether a given value is a constructible class.
@@ -316,7 +587,21 @@ function isClass(func) {
316
587
  if (!descriptor || descriptor.writable) return false;
317
588
  return /^class\s/.test(Function.prototype.toString.call(func));
318
589
  }
319
- // src/util/isMatch.ts
590
+ // src/util/isGitHubActions.ts
591
+ /**
592
+ * Determine whether the current process runs on a GitHub Actions runner.
593
+ *
594
+ * Checks if the `GITHUB_ACTIONS` environment variable is set to a truthy
595
+ * value. Gates GitHub Actions-specific reporting such as job summaries and
596
+ * annotations.
597
+ *
598
+ * @param env Readonly process environment variables object
599
+ * @returns `true` if `env.GITHUB_ACTIONS` normalizes to a truthy string, otherwise `false`
600
+ */
601
+ function isGitHubActions(env) {
602
+ return isTruthyString(env.GITHUB_ACTIONS);
603
+ }
604
+ // src/util/isMatch.ts
320
605
  /**
321
606
  * Determine whether a target string matches glob patterns.
322
607
  *
@@ -364,6 +649,26 @@ async function readJson(filePath) {
364
649
  if (typeof json !== "object" || json === null) throw new Error(`JSON file at "${colors.bold(filePath)}" does not contain a valid object.`);
365
650
  return json;
366
651
  }
652
+ // src/util/unique.ts
653
+ /**
654
+ * Return a new array containing only the first-seen occurrence of each item.
655
+ *
656
+ * This preserves the original iteration order and performs equality checks
657
+ * using JavaScript's `Set` semantics (i.e., primitives by value, objects by
658
+ * reference). The input array is not mutated.
659
+ *
660
+ * @param array The array of items to deduplicate
661
+ * @returns A new array with duplicates removed, preserving first-seen order
662
+ */
663
+ function unique(array) {
664
+ const seen = /* @__PURE__ */ new Set();
665
+ const result = [];
666
+ for (const item of array) if (!seen.has(item)) {
667
+ seen.add(item);
668
+ result.push(item);
669
+ }
670
+ return result;
671
+ }
367
672
  // src/util/writeJson.ts
368
673
  /**
369
674
  * Write a JSON `payload` to `filePath`, formatting the content first.
@@ -380,6 +685,251 @@ async function writeJson(filePath, payload) {
380
685
  await fs.mkdir(path.dirname(filePath), { recursive: true });
381
686
  await fs.writeFile(filePath, content);
382
687
  }
688
+ // src/config/createPlugin.ts
689
+ /**
690
+ * Instantiate or invoke a plugin factory to produce a release plugin instance.
691
+ *
692
+ * Accepts class constructors, factory functions, tuple configurations, or
693
+ * existing plugin objects. Instantiates classes using `new` or invokes factory
694
+ * functions with options, validating that the resulting object satisfies the
695
+ * plugin structure.
696
+ *
697
+ * @param plugin A plugin constructor, factory function, tuple, or object
698
+ * @returns A validated release plugin instance or null
699
+ */
700
+ async function createPlugin(plugin) {
701
+ let options;
702
+ if (Array.isArray(plugin)) [plugin, options] = plugin;
703
+ if (typeof plugin === "function") plugin = isClass(plugin) ? new plugin(options) : await plugin(options);
704
+ if (plugin != null && typeof plugin === "object" && Object.hasOwn(plugin, "name") && typeof plugin.name === "string") return plugin;
705
+ return null;
706
+ }
707
+ // src/config/findReleaseRule.ts
708
+ /**
709
+ * Find the first release rule matching a release reference.
710
+ *
711
+ * Matches rules sequentially against the reference type and pattern.
712
+ *
713
+ * @param ref Release reference object
714
+ * @param rules Array of release rules to match against
715
+ * @returns The first matching release rule or `undefined`
716
+ */
717
+ function findReleaseRule(ref, rules) {
718
+ return rules.find((rule) => {
719
+ return (rule.type == null || rule.type === ref.type) && isMatch(ref.name, rule.pattern);
720
+ });
721
+ }
722
+ // src/config/isSemVer.ts
723
+ /**
724
+ * Determine whether a value is a valid Semantic Versioning string.
725
+ *
726
+ * Rejects non-string values, leading or trailing whitespace, and leading `v`
727
+ * prefixes. Validates the candidate string using `semver.parse`.
728
+ *
729
+ * @param version Candidate value to evaluate for SemVer compliance
730
+ * @returns `true` if `version` is a valid SemVer string, or `false` otherwise
731
+ */
732
+ function isSemVer(version) {
733
+ if (typeof version !== "string") return false;
734
+ if (version !== version.trim()) return false;
735
+ if (version.startsWith("v")) return false;
736
+ return semver.parse(version) != null;
737
+ }
738
+ // src/config/isSemVerGitTag.ts
739
+ /**
740
+ * Determine whether a tag string is a valid SemVer-style Git tag.
741
+ *
742
+ * Anchors `SEMVER_REGEX.source` for full-string matching and applies the
743
+ * repository's Git-tag acceptance rules.
744
+ *
745
+ * @param tag Tag string to validate
746
+ * @returns `true` if `tag` is accepted as a SemVer-style Git tag; otherwise `false`
747
+ */
748
+ function isSemVerGitTag(tag) {
749
+ const match = new RegExp(`^${SEMVER_REGEX.source}$`).exec(tag);
750
+ if (!match) return false;
751
+ const isScopedPackage = Boolean(match[1]);
752
+ const hasVersionPrefix = tag.startsWith("v");
753
+ return isScopedPackage || hasVersionPrefix;
754
+ }
755
+ // src/config/sanitizePrereleaseLabel.ts
756
+ /**
757
+ * Sanitize a string into a safe, SemVer-compliant prerelease label.
758
+ *
759
+ * Replaces sequences of non-alphanumeric characters with a single hyphen and
760
+ * removes leading or trailing hyphens.
761
+ *
762
+ * @param label Raw string to sanitize
763
+ * @returns Safe SemVer prerelease label
764
+ */
765
+ function sanitizePrereleaseLabel(label) {
766
+ return label.replace(/[^a-zA-Z0-9]+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
767
+ }
768
+ // src/config/resolveReleaseChannel.ts
769
+ /**
770
+ * Resolve the release channel for a release context.
771
+ *
772
+ * Uses the release rule when `channel` is `boolean` or omitted. Sanitizes the
773
+ * reference name when enabling default channel resolution and interpolates
774
+ * `templateParams` into the result.
775
+ *
776
+ * @param options Options for resolving the release channel
777
+ * @returns Resolved release channel string or `undefined`
778
+ */
779
+ function resolveReleaseChannel(options) {
780
+ const { ref, rule, templateParams } = options;
781
+ let { channel } = options;
782
+ let resolved;
783
+ if (channel === true || channel == null) channel = rule?.releaseChannel ?? channel;
784
+ if (typeof channel === "string") resolved = channel;
785
+ else if (channel) resolved = sanitizePrereleaseLabel(ref.name);
786
+ if (typeof resolved === "string") resolved = interpolate(resolved, templateParams);
787
+ return resolved;
788
+ }
789
+ // src/config/resolveVersionQualifier.ts
790
+ /**
791
+ * Resolve the version qualifier for a release context.
792
+ *
793
+ * Uses the release rule when `qualifier` is `boolean` or omitted. Interpolates
794
+ * `templateParams` into `qualifier` and validates that the result forms a
795
+ * valid SemVer prerelease identifier.
796
+ *
797
+ * @param options Options for resolving the version qualifier
798
+ * @returns Resolved version qualifier string or `undefined`
799
+ * @throws If the resolved string is not a valid SemVer prerelease identifier
800
+ */
801
+ function resolveVersionQualifier(options) {
802
+ const { rule, templateParams } = options;
803
+ let { qualifier } = options;
804
+ let resolved;
805
+ if (qualifier === true || qualifier == null) qualifier = rule?.versionQualifier ?? qualifier;
806
+ if (typeof qualifier === "string") resolved = qualifier;
807
+ else if (qualifier) resolved = "";
808
+ if (typeof resolved === "string") resolved = interpolate(resolved, templateParams);
809
+ if (resolved && !isSemVer(`1.0.0-${resolved}.1`)) throw new Error(`The resolved version qualifier "${resolved}" is not a valid SemVer prerelease identifier.`);
810
+ return resolved;
811
+ }
812
+ // src/workflow/analysis/packageContainsCommit.ts
813
+ /**
814
+ * Test whether a commit modifies files in a package.
815
+ *
816
+ * @param pkg Package with an explicit file pattern or base directory
817
+ * @param commit Parsed commit containing changed file paths
818
+ * @returns `true` if any changed file matches the package pattern
819
+ */
820
+ function packageContainsCommit(pkg, commit) {
821
+ return commit.files.some((file) => {
822
+ const { location } = pkg;
823
+ return isMatch(file, pkg.files || path.join(location, "**/*"));
824
+ });
825
+ }
826
+ // src/workflow/analysis/deriveChangeReleases.ts
827
+ /**
828
+ * Analyze commit history to update release plans for packages.
829
+ *
830
+ * Maps commit `history` across package release `plans` to associate matching
831
+ * commits with their target packages. Calculates the release type for each
832
+ * plan based on classified `history` and applies overrides according to the
833
+ * provided `hint` or existing release priority. Downgrades breaking-change
834
+ * `major` release types to `minor` while the package version is zero-major
835
+ * (`0.y.z`).
836
+ *
837
+ * @param hint Release type override hint or default preference
838
+ * @param classifier Classifier function to determine commit release types
839
+ * @param plans List of release plans to analyze and update
840
+ * @param history Stream or iterable of git commits to process
841
+ * @returns Updated release plans with updated commit histories and release types
842
+ */
843
+ async function deriveChangeReleases(hint, classifier, plans, history) {
844
+ for await (const commit of history) plans = plans.map((plan) => {
845
+ if (!packageContainsCommit(plan.package, commit)) return plan;
846
+ return {
847
+ ...plan,
848
+ history: plan.history.concat(commit)
849
+ };
850
+ });
851
+ return plans.map((plan) => {
852
+ let { release } = plan;
853
+ let releaseType = deriveReleaseType(classifier, plan);
854
+ if (releaseType) switch (hint) {
855
+ case "major":
856
+ case "minor":
857
+ case "patch":
858
+ releaseType = hint;
859
+ break;
860
+ default: releaseType = pickPriorityReleaseType(release?.type, releaseType);
861
+ }
862
+ if (releaseType) release = {
863
+ ...release,
864
+ type: releaseType
865
+ };
866
+ return {
867
+ ...plan,
868
+ release
869
+ };
870
+ });
871
+ }
872
+ // src/workflow/analysis/deriveTransitionReleases.ts
873
+ /**
874
+ * Derive transition release types for release plans based on version qualifiers.
875
+ *
876
+ * Evaluates unreleased `plans` by parsing package `semver` strings and checking
877
+ * prerelease tags. Compares parsed version qualifiers against
878
+ * `versionQualifier` and assigns `major`, `minor`, or `patch` release types
879
+ * according to `hint`. When `hint` is `patch`, every package receives an
880
+ * update: stable packages are assigned a patch release even without a
881
+ * `versionQualifier`, and prerelease packages (pre-major, pre-minor, and
882
+ * pre-patch cycles) continue their cycle with an incremented counter,
883
+ * redirect to `versionQualifier` when it differs, or release their stable
884
+ * base when no `versionQualifier` is set.
885
+ *
886
+ * @param hint Release type override hint to guide release classification
887
+ * @param versionQualifier Optional qualifier string to compare against prerelease tags
888
+ * @param plans List of release plans to analyze and update
889
+ * @returns Updated release plans with derived transition release types
890
+ */
891
+ function deriveTransitionReleases(hint, versionQualifier, plans) {
892
+ return plans.map((plan) => {
893
+ if (plan.release) return plan;
894
+ const parsed = semver.parse(plan.package.version);
895
+ if (!parsed) return plan;
896
+ const { major, minor, patch } = parsed;
897
+ const parsedVersionQualifier = extractVersionQualifier(parsed);
898
+ let releaseType;
899
+ let versionTransition;
900
+ switch (hint) {
901
+ case "major":
902
+ if (parsed.prerelease.length === 0) {
903
+ if (typeof versionQualifier === "string") releaseType = "major";
904
+ else if (major === 0 && (minor > 0 || patch > 0)) releaseType = "major";
905
+ } else if (minor === 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "major";
906
+ break;
907
+ case "minor":
908
+ if (parsed.prerelease.length === 0) {
909
+ if (typeof versionQualifier === "string") releaseType = "minor";
910
+ } else if (minor > 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "minor";
911
+ break;
912
+ case "patch":
913
+ releaseType = "patch";
914
+ break;
915
+ default: if (parsed.prerelease.length === 0) {
916
+ if (major === 0 && (minor > 0 || patch > 0)) releaseType = "major";
917
+ } else if (minor === 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "major";
918
+ else if (minor > 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "minor";
919
+ else if (patch > 0 && parsedVersionQualifier !== versionQualifier) releaseType = "patch";
920
+ }
921
+ if (parsedVersionQualifier == null || parsedVersionQualifier !== "" && versionQualifier === "") versionTransition = "advance";
922
+ else versionTransition = "continue";
923
+ if (!releaseType) return plan;
924
+ return {
925
+ ...plan,
926
+ release: {
927
+ type: releaseType,
928
+ transition: versionTransition
929
+ }
930
+ };
931
+ });
932
+ }
383
933
  // src/git/branch/getCurrentGitBranch.ts
384
934
  /**
385
935
  * Get the current Git branch name.
@@ -925,20 +1475,7 @@ async function mergeGitHistory(cwd, a, b) {
925
1475
  if (j) merged.push(j);
926
1476
  return merged.concat(a2).concat(b2);
927
1477
  }
928
- // src/git/history/restoreFullGitHistory.ts
929
- /**
930
- * Convert a shallow clone into a full clone by fetching additional history.
931
- *
932
- * Runs `git fetch --unshallow`. Returns `true` when the operation succeeds
933
- * and `false` on error.
934
- *
935
- * @param cwd Repository working directory
936
- * @returns `true` when the operation succeeded, otherwise `false`
937
- */
938
- function restoreFullGitHistory(cwd) {
939
- return execGit(cwd, ["fetch", "--unshallow"]).then(() => true).catch(() => false);
940
- }
941
- // src/git/history/showGitHistory.ts
1478
+ // src/git/history/readGitHistory.ts
942
1479
  /**
943
1480
  * Yield commit SHAs from repository history in paginated order.
944
1481
  *
@@ -950,7 +1487,7 @@ function restoreFullGitHistory(cwd) {
950
1487
  * @param options Supports `from`, `until`, `pageSize`, and `filePath`
951
1488
  * @yields Commit SHA strings in paginated order
952
1489
  */
953
- async function* showGitHistory(cwd, options = {}) {
1490
+ async function* readGitHistory(cwd, options = {}) {
954
1491
  try {
955
1492
  const { filePath, pageSize = 50 } = options;
956
1493
  let from = options.from || "HEAD";
@@ -981,23 +1518,36 @@ async function* showGitHistory(cwd, options = {}) {
981
1518
  }
982
1519
  } catch {}
983
1520
  }
984
- // src/git/history/showParsedGitHistory.ts
1521
+ // src/git/history/readParsedGitHistory.ts
985
1522
  /**
986
1523
  * Yield parsed commits sequentially from repository history.
987
1524
  *
988
- * Fetches commits using `showGitHistory` and parses each commit with
1525
+ * Fetches commits using `readGitHistory` and parses each commit with
989
1526
  * `getParsedGitCommit`. Yields successfully parsed `GitCommit` objects on demand
990
1527
  * and skips unparsable commits.
991
1528
  *
992
1529
  * @param cwd Repository working directory path
993
- * @param options Filter and pagination options passed to `showGitHistory`
1530
+ * @param options Filter and pagination options passed to `readGitHistory`
994
1531
  * @yields Parsed `GitCommit` objects in historical order
995
1532
  */
996
- async function* showParsedGitHistory(cwd, options) {
997
- for await (const commit of showGitHistory(cwd, options)) try {
1533
+ async function* readParsedGitHistory(cwd, options) {
1534
+ for await (const commit of readGitHistory(cwd, options)) try {
998
1535
  yield await getParsedGitCommit(cwd, commit);
999
1536
  } catch {}
1000
1537
  }
1538
+ // src/git/history/restoreFullGitHistory.ts
1539
+ /**
1540
+ * Convert a shallow clone into a full clone by fetching additional history.
1541
+ *
1542
+ * Runs `git fetch --unshallow`. Returns `true` when the operation succeeds
1543
+ * and `false` on error.
1544
+ *
1545
+ * @param cwd Repository working directory
1546
+ * @returns `true` when the operation succeeded, otherwise `false`
1547
+ */
1548
+ function restoreFullGitHistory(cwd) {
1549
+ return execGit(cwd, ["fetch", "--unshallow"]).then(() => true).catch(() => false);
1550
+ }
1001
1551
  // src/git/repository/getGitConfigValue.ts
1002
1552
  /**
1003
1553
  * Get a local git configuration value for `key` in the repository at `cwd`.
@@ -1249,663 +1799,107 @@ async function getCurrentGitTag(cwd) {
1249
1799
  "describe",
1250
1800
  "--tags",
1251
1801
  "--exact-match"
1252
- ])).trim();
1253
- /* istanbul ignore next */
1254
- return tag ? tag : null;
1255
- } catch {
1256
- return null;
1257
- }
1258
- }
1259
- // src/git/tag/getGitTagMessage.ts
1260
- /**
1261
- * Get the message of an annotated git tag in the repository at `cwd`.
1262
- *
1263
- * @param cwd Repository working directory
1264
- * @param tag Tag name to query
1265
- * @returns The tag message string when found, otherwise `undefined`
1266
- */
1267
- async function getGitTagMessage(cwd, tag) {
1268
- try {
1269
- const [objectType, message] = (await execGit(cwd, [
1270
- "for-each-ref",
1271
- "--format=%(objecttype)%00%(contents)",
1272
- `refs/tags/${tag}`
1273
- ])).split("\0");
1274
- if (objectType?.trim() !== "tag") return;
1275
- return message?.trim() || void 0;
1276
- } catch {
1277
- /* istanbul ignore next */
1278
- return;
1279
- }
1280
- }
1281
- // src/git/tag/getLatestGitTag.ts
1282
- /**
1283
- * Get the most recent tag reachable from `HEAD`.
1284
- *
1285
- * @param cwd Repository working directory
1286
- * @returns Latest tag string or `null` when none is found
1287
- */
1288
- async function getLatestGitTag(cwd) {
1289
- try {
1290
- const tag = (await execGit(cwd, [
1291
- "describe",
1292
- "--tags",
1293
- "--abbrev=0"
1294
- ])).trim();
1295
- /* istanbul ignore next */
1296
- return tag ? tag : null;
1297
- } catch {
1298
- return null;
1299
- }
1300
- }
1301
- // src/git/tag/isGitTagConnected.ts
1302
- /**
1303
- * Determine whether a specific git tag commit is reachable from the current HEAD.
1304
- *
1305
- * Uses `git merge-base --is-ancestor refs/tags/<tag>^{commit} HEAD` to verify
1306
- * that the tag's commit is an ancestor of the current reference. Any non-zero
1307
- * exit status or execution error is treated as "not reachable".
1308
- *
1309
- * @param cwd Working directory where the git command will run
1310
- * @param tag Tag name to evaluate (for example, "v1.2.0")
1311
- * @returns True if the tag commit is reachable from HEAD, false otherwise
1312
- */
1313
- async function isGitTagConnected(cwd, tag) {
1314
- try {
1315
- await execGit(cwd, [
1316
- "merge-base",
1317
- "--is-ancestor",
1318
- `refs/tags/${tag}^{commit}`,
1319
- "HEAD"
1320
- ]);
1321
- return true;
1322
- } catch {
1323
- return false;
1324
- }
1325
- }
1326
- // src/git/tag/isGitTagPointed.ts
1327
- /**
1328
- * Check whether a given tag points to the provided commit.
1329
- *
1330
- * @param cwd Repository working directory
1331
- * @param tag Tag name to resolve
1332
- * @param commit Commit hash to compare against
1333
- * @returns `true` when the tag points at `commit`, otherwise `false`
1334
- */
1335
- async function isGitTagPointed(cwd, tag, commit) {
1336
- try {
1337
- await execGit(cwd, [
1338
- "merge-base",
1339
- "--is-ancestor",
1340
- `refs/tags/${tag}^{commit}`,
1341
- commit
1342
- ]);
1343
- await execGit(cwd, [
1344
- "merge-base",
1345
- "--is-ancestor",
1346
- commit,
1347
- `refs/tags/${tag}^{commit}`
1348
- ]);
1349
- return true;
1350
- } catch {
1351
- return false;
1352
- }
1353
- }
1354
- // src/config/const.ts
1355
- var ALL_FILES = "**/*";
1356
- var DEFAULT_CHANGELOG_FILE = "CHANGELOG.md";
1357
- var GIT_TRAILER_RELEASE_AGENT = "Release-Agent";
1358
- var GIT_TRAILER_RELEASE_FILTER = "Release-Filter";
1359
- /**
1360
- * 1. Primitive Building Blocks
1361
- *
1362
- * Base regular expression patterns for wildcards, alphanumeric strings with hyphens,
1363
- * and standard non-negative integers.
1364
- */
1365
- var WILDCARD = "\\*";
1366
- var ALPHANUM_DASH = "[0-9a-zA-Z-]+";
1367
- var NUMERIC_IDENTIFIER = "0|[1-9]\\d*";
1368
- /**
1369
- * 2. Package Name & Prefix Constructs
1370
- *
1371
- * Matches package name prefixes (unscoped or scoped) or a simple `v` prefix.
1372
- *
1373
- * Capture Groups:
1374
- * - Group 1: Package name (e.g., `my-package` or `@scope/my-package`)
1375
- */
1376
- var PKG_NAME_PART = `(?:${WILDCARD}|${ALPHANUM_DASH})`;
1377
- var OPTIONAL_VERSION_PREFIX = `(?:v|${`(${PKG_NAME_PART}|@${PKG_NAME_PART}\\/${PKG_NAME_PART})`}@)`;
1378
- /**
1379
- * 3. Core SemVer Components
1380
- *
1381
- * Matches standard `MAJOR.MINOR.PATCH` versions or wildcard variants (e.g., `1.0.0`, `*.*.*`).
1382
- *
1383
- * Capture Groups:
1384
- * - Group 3: Major version
1385
- * - Group 4: Minor version
1386
- * - Group 5: Patch version
1387
- */
1388
- var CAPTURED_VERSION_DIGIT = `(${WILDCARD}|${NUMERIC_IDENTIFIER})`;
1389
- var SEMVER_CORE = `${CAPTURED_VERSION_DIGIT}\\.${CAPTURED_VERSION_DIGIT}\\.${CAPTURED_VERSION_DIGIT}`;
1390
- var PRERELEASE_IDENTIFIER = `(?:${WILDCARD}|${NUMERIC_IDENTIFIER}|(\\d*[a-zA-Z-][0-9a-zA-Z-]*))`;
1391
- var FULL_SEMVER_PATTERN = `${OPTIONAL_VERSION_PREFIX}?${`(${SEMVER_CORE}${`(?:-(${PRERELEASE_IDENTIFIER}(?:\\.${PRERELEASE_IDENTIFIER})*))`}?${`(?:\\+(${ALPHANUM_DASH}(?:\\.${ALPHANUM_DASH})*))`}?)`}`;
1392
- /**
1393
- * Regular expression to match and capture Semantic Versioning (SemVer) strings,
1394
- * including optional package prefixes (e.g., `@scope/pkg@`) and `v` prefixes.
1395
- *
1396
- * @example
1397
- * ```ts
1398
- * SEMVER_REGEX.test('1.0.0') // true
1399
- * SEMVER_REGEX.test('v1.2.3-beta.1+sha.1234') // true
1400
- * SEMVER_REGEX.test('@scope/package@1.0.0') // true
1401
- * ```
1402
- *
1403
- * @see {@link https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SemVer Specification}
1404
- */
1405
- var SEMVER_REGEX = new RegExp(FULL_SEMVER_PATTERN);
1406
- var DEV_NULL = new Writable({
1407
- /* istanbul ignore next */
1408
- write(_chunk, _encoding, callback) {
1409
- callback();
1410
- } });
1411
- var RELEASE_HOOK_NAMES = [
1412
- "configure",
1413
- "discover",
1414
- "analyze",
1415
- "build",
1416
- "write",
1417
- "publish",
1418
- "finalize"
1419
- ];
1420
- // src/config/createPlugin.ts
1421
- /**
1422
- * Instantiate or invoke a plugin factory to produce a release plugin instance.
1423
- *
1424
- * Accepts class constructors, factory functions, tuple configurations, or
1425
- * existing plugin objects. Instantiates classes using `new` or invokes factory
1426
- * functions with options, validating that the resulting object satisfies the
1427
- * plugin structure.
1428
- *
1429
- * @param plugin A plugin constructor, factory function, tuple, or object
1430
- * @returns A validated release plugin instance or null
1431
- */
1432
- async function createPlugin(plugin) {
1433
- let options;
1434
- if (Array.isArray(plugin)) [plugin, options] = plugin;
1435
- if (typeof plugin === "function") plugin = isClass(plugin) ? new plugin(options) : await plugin(options);
1436
- if (plugin != null && typeof plugin === "object" && Object.hasOwn(plugin, "name") && typeof plugin.name === "string") return plugin;
1437
- return null;
1438
- }
1439
- // src/config/findReleaseRule.ts
1440
- /**
1441
- * Find the first release rule matching a release reference.
1442
- *
1443
- * Matches rules sequentially against the reference type and pattern.
1444
- *
1445
- * @param ref Release reference object
1446
- * @param rules Array of release rules to match against
1447
- * @returns The first matching release rule or `undefined`
1448
- */
1449
- function findReleaseRule(ref, rules) {
1450
- return rules.find((rule) => {
1451
- return (rule.type == null || rule.type === ref.type) && isMatch(ref.name, rule.pattern);
1452
- });
1453
- }
1454
- // src/config/isSemVer.ts
1455
- /**
1456
- * Determine whether a value is a valid Semantic Versioning string.
1457
- *
1458
- * Rejects non-string values, leading or trailing whitespace, and leading `v`
1459
- * prefixes. Validates the candidate string using `semver.parse`.
1460
- *
1461
- * @param version Candidate value to evaluate for SemVer compliance
1462
- * @returns `true` if `version` is a valid SemVer string, or `false` otherwise
1463
- */
1464
- function isSemVer(version) {
1465
- if (typeof version !== "string") return false;
1466
- if (version !== version.trim()) return false;
1467
- if (version.startsWith("v")) return false;
1468
- return semver.parse(version) != null;
1469
- }
1470
- // src/config/isSemVerGitTag.ts
1471
- /**
1472
- * Determine whether a tag string is a valid SemVer-style Git tag.
1473
- *
1474
- * Anchors `SEMVER_REGEX.source` for full-string matching and applies the
1475
- * repository's Git-tag acceptance rules.
1476
- *
1477
- * @param tag Tag string to validate
1478
- * @returns `true` if `tag` is accepted as a SemVer-style Git tag; otherwise `false`
1479
- */
1480
- function isSemVerGitTag(tag) {
1481
- const match = new RegExp(`^${SEMVER_REGEX.source}$`).exec(tag);
1482
- if (!match) return false;
1483
- const isScopedPackage = Boolean(match[1]);
1484
- const hasVersionPrefix = tag.startsWith("v");
1485
- return isScopedPackage || hasVersionPrefix;
1486
- }
1487
- // src/config/sanitizePrereleaseLabel.ts
1488
- /**
1489
- * Sanitize a string into a safe, SemVer-compliant prerelease label.
1490
- *
1491
- * Replaces sequences of non-alphanumeric characters with a single hyphen and
1492
- * removes leading or trailing hyphens.
1493
- *
1494
- * @param label Raw string to sanitize
1495
- * @returns Safe SemVer prerelease label
1496
- */
1497
- function sanitizePrereleaseLabel(label) {
1498
- return label.replace(/[^a-zA-Z0-9]+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
1499
- }
1500
- // src/config/resolveReleaseChannel.ts
1501
- /**
1502
- * Resolve the release channel for a release context.
1503
- *
1504
- * Uses the release rule when `channel` is `boolean` or omitted. Sanitizes the
1505
- * reference name when enabling default channel resolution and interpolates
1506
- * `templateParams` into the result.
1507
- *
1508
- * @param options Options for resolving the release channel
1509
- * @returns Resolved release channel string or `undefined`
1510
- */
1511
- function resolveReleaseChannel(options) {
1512
- const { ref, rule, templateParams } = options;
1513
- let { channel } = options;
1514
- let resolved;
1515
- if (channel === true || channel == null) channel = rule?.releaseChannel ?? channel;
1516
- if (typeof channel === "string") resolved = channel;
1517
- else if (channel) resolved = sanitizePrereleaseLabel(ref.name);
1518
- if (typeof resolved === "string") resolved = interpolate(resolved, templateParams);
1519
- return resolved;
1520
- }
1521
- // src/config/resolveVersionQualifier.ts
1522
- /**
1523
- * Resolve the version qualifier for a release context.
1524
- *
1525
- * Uses the release rule when `qualifier` is `boolean` or omitted. Interpolates
1526
- * `templateParams` into `qualifier` and validates that the result forms a
1527
- * valid SemVer prerelease identifier.
1528
- *
1529
- * @param options Options for resolving the version qualifier
1530
- * @returns Resolved version qualifier string or `undefined`
1531
- * @throws If the resolved string is not a valid SemVer prerelease identifier
1532
- */
1533
- function resolveVersionQualifier(options) {
1534
- const { rule, templateParams } = options;
1535
- let { qualifier } = options;
1536
- let resolved;
1537
- if (qualifier === true || qualifier == null) qualifier = rule?.versionQualifier ?? qualifier;
1538
- if (typeof qualifier === "string") resolved = qualifier;
1539
- else if (qualifier) resolved = "";
1540
- if (typeof resolved === "string") resolved = interpolate(resolved, templateParams);
1541
- if (resolved && !isSemVer(`1.0.0-${resolved}.1`)) throw new Error(`The resolved version qualifier "${resolved}" is not a valid SemVer prerelease identifier.`);
1542
- return resolved;
1543
- }
1544
- // src/workflow/committing/isReleaseCommit.ts
1545
- /**
1546
- * Determine whether a commit represents a release or matches a release marker.
1547
- *
1548
- * Resolves string commit identifiers to parsed commit objects, checks if any
1549
- * associated trailer matches the `marker` predicate, and falls back to
1550
- * verifying exact tag matches for the `commit` hash.
1551
- *
1552
- * @param cwd Working directory path for Git commands
1553
- * @param commit Commit object, hash string, or nullish value
1554
- * @param marker Trailer key string or predicate function to evaluate
1555
- * @returns `true` if the commit is a release commit, otherwise `false`
1556
- */
1557
- async function isReleaseCommit(cwd, commit, marker = GIT_TRAILER_RELEASE_AGENT) {
1558
- if (typeof commit === "string") try {
1559
- commit = await getParsedGitCommit(cwd, commit, typeof marker === "string" ? [marker] : []);
1560
- } catch {
1561
- commit = null;
1562
- }
1563
- if (!commit) return false;
1564
- const predicate = typeof marker === "string" ? (trailer) => trailer.key === marker && !!trailer.value : marker;
1565
- if (commit.trailers.some(predicate)) return true;
1566
- return execGit(cwd, [
1567
- "describe",
1568
- "--tags",
1569
- "--exact-match",
1570
- commit.hash
1571
- ]).then(() => true).catch(() => false);
1572
- }
1573
- // src/workflow/analysis/collectUnreleased.ts
1574
- /**
1575
- * Collect unreleased commits from repository history.
1576
- *
1577
- * Walks parsed commit history in order and gathers every commit preceding the
1578
- * first release commit. Exposes the release commit that ended the walk so
1579
- * callers can inspect it, for example to read its release filter trailer.
1580
- *
1581
- * @param cwd Path to the working directory for git commands
1582
- * @param options Options for configuring Git history retrieval
1583
- * @returns The unreleased commits and the release commit that stopped the walk
1584
- */
1585
- async function collectUnreleased(cwd, options = {}) {
1586
- const history = [];
1587
- for await (const commit of showParsedGitHistory(cwd, options)) {
1588
- if (await isReleaseCommit(cwd, commit, options.marker)) return {
1589
- history,
1590
- stop: commit
1591
- };
1592
- history.push(commit);
1593
- }
1594
- return {
1595
- history,
1596
- stop: null
1597
- };
1598
- }
1599
- // src/workflow/versioning/extractVersionQualifier.ts
1600
- /**
1601
- * Extract the version qualifier string from a parsed `SemVer` instance.
1602
- *
1603
- * Strips the trailing numeric counter from the `prerelease` components if
1604
- * present. Joins any remaining prerelease identifiers with a dot separator.
1605
- *
1606
- * @param version Parsed `SemVer` instance or nullish value to inspect
1607
- * @returns The extracted qualifier string or `undefined` if no prerelease exists
1608
- */
1609
- function extractVersionQualifier(version) {
1610
- if (version != null && version.prerelease.length > 0) {
1611
- const prerelease = [...version.prerelease];
1612
- if (typeof prerelease.at(-1) === "number") prerelease.pop();
1613
- return prerelease.join(".");
1614
- } else return;
1615
- }
1616
- // src/workflow/versioning/bumpVersion.ts
1617
- /**
1618
- * Bump a semantic version string based on release and transition rules.
1619
- *
1620
- * Parses the target version and determines the next version string using the
1621
- * specified release type, prerelease identifier, and transition mode. Adjusts
1622
- * prerelease types when continuing an existing qualifier and returns `null` when
1623
- * `options.release` is omitted or if transition conditions fail.
1624
- *
1625
- * @param options Version bump configuration including release type, identifier, and transition rules
1626
- * @returns The bumped semantic version string, or `null` if no bump occurs
1627
- * @throws If `options.version` is not a valid semantic version
1628
- */
1629
- function bumpVersion(options) {
1630
- const { version } = options;
1631
- const parsed = semver.parse(version);
1632
- if (!parsed) throw new Error(`Version "${version}" is not a valid semantic version.`);
1633
- if (!options.release) return null;
1634
- if (parsed.prerelease.length > 0) {
1635
- if (options.transition === "advance" && options.identifier == null) return null;
1636
- } else if (options.transition === "continue") return null;
1637
- let release = options.release;
1638
- let identifier;
1639
- if (typeof options.identifier === "string") {
1640
- release = `pre${options.release}`;
1641
- identifier = options.identifier;
1642
- const parsedIdentifier = extractVersionQualifier(parsed);
1643
- const transition = options.transition ?? (parsedIdentifier && identifier === "" ? "advance" : "continue");
1644
- if (typeof parsedIdentifier === "string" && transition === "continue") {
1645
- if (release === "premajor" && parsed.minor === 0 && parsed.patch === 0 || release === "preminor" && parsed.patch === 0 || release === "prepatch") release = "prerelease";
1646
- }
1647
- }
1648
- return semver.inc(parsed, release, { loose: false }, identifier, "0");
1649
- }
1650
- // src/workflow/versioning/determineReleaseType.ts
1651
- /**
1652
- * Determine the release type for a single commit.
1653
- *
1654
- * Returns `'minor'` for a commit marked as a breaking change while the
1655
- * supplied `version` is zero-major (`0.y.z`), and `'major'` otherwise, since
1656
- * SemVer treats `0.y.z` as initial development where breaking changes do not
1657
- * require a new major version. Otherwise, routes the commit through the
1658
- * custom `classifier` and ensures the resolved value is a valid semantic
1659
- * versioning release type.
1660
- *
1661
- * @param classifier Function mapping commits to release types
1662
- * @param commit Parsed commit to evaluate
1663
- * @param version Current package version used to adjust zero-major breaking releases
1664
- * @returns `ReleaseType` string, or `null` when no matching rule applies
1665
- */
1666
- function determineReleaseType(classifier, commit, version) {
1667
- if (commit.notes.length > 0) return semver.parse(version)?.major === 0 ? "minor" : "major";
1668
- const type = classifier(commit);
1669
- switch (type) {
1670
- case "major":
1671
- case "minor":
1672
- case "patch": return type;
1673
- }
1674
- return null;
1675
- }
1676
- // src/workflow/versioning/pickPriorityReleaseType.ts
1677
- /**
1678
- * Determine the highest-priority release type between two candidates.
1679
- *
1680
- * Compares release types by precedence order: `major` > `minor` > `patch`.
1681
- * Returns the higher-precedence type, or `null` if neither applies.
1682
- *
1683
- * @param curr Current accumulated release type
1684
- * @param next Candidate release type to consider
1685
- * @returns Highest-precedence `ReleaseType`, or `null` if neither applies
1686
- */
1687
- function pickPriorityReleaseType(curr, next) {
1688
- for (const type of [
1689
- "major",
1690
- "minor",
1691
- "patch"
1692
- ]) if (curr === type || next === type) return type;
1693
- return null;
1694
- }
1695
- // src/workflow/versioning/deriveReleaseType.ts
1696
- /**
1697
- * Derive the combined release type from a release plan.
1698
- *
1699
- * Processes the plan's commits sequentially, accumulating the
1700
- * highest-precedence release type found by evaluating each individual commit
1701
- * and comparing it against the current maximum via `pickPriorityReleaseType`.
1702
- * Breaking commits resolve to `minor` while the plan's package version is
1703
- * zero-major (`0.y.z`).
1704
- *
1705
- * @param classifier Function mapping commits to release types
1706
- * @param plan Release plan carrying the commit history and package version
1707
- * @returns `ReleaseType` string, or `null` when no matching rule applies
1708
- */
1709
- function deriveReleaseType(classifier, plan) {
1710
- let releaseType = null;
1711
- for (const commit of plan.history) releaseType = pickPriorityReleaseType(releaseType, determineReleaseType(classifier, commit, plan.package.version));
1712
- return releaseType;
1713
- }
1714
- // src/workflow/versioning/isSameReleaseCycle.ts
1715
- /**
1716
- * Determine whether two semantic version strings or objects belong to the same release cycle.
1717
- *
1718
- * Compares the main version components of `currentVersion` and `nextVersion` to
1719
- * determine equality. Treats a transition from a non-zero `0.x` version to
1720
- * `1.0.0` as part of the same release cycle. Returns `false` if either input
1721
- * cannot be parsed.
1722
- *
1723
- * @param currentVersion Starting version string, `semver.SemVer` instance, or nullish value
1724
- * @param nextVersion Target version string, `semver.SemVer` instance, or nullish value
1725
- * @returns `true` if both versions belong to the same release cycle, `false` otherwise
1726
- */
1727
- function isSameReleaseCycle(currentVersion, nextVersion) {
1728
- const current = semver.parse(currentVersion);
1729
- const next = semver.parse(nextVersion);
1730
- if (!current || !next) return false;
1731
- if (current.compareMain(next) === 0) return true;
1732
- return current.major === 0 && (current.minor > 0 || current.patch > 0) && next.major === 1 && next.minor === 0 && next.patch === 0;
1733
- }
1734
- // src/workflow/versioning/isStableVersion.ts
1735
- /**
1736
- * Determine whether a version string represents a stable SemVer release.
1737
- *
1738
- * A version is considered stable when:
1739
- * - It is a valid SemVer string.
1740
- * - Its major version is greater than 0 (not 0.x.x).
1741
- * - It contains no prerelease identifiers (no `-alpha`, `-beta`, `-rc`, etc.).
1742
- *
1743
- * Build metadata (the `+` suffix) does not affect stability.
1744
- *
1745
- * @param version Semantic version string to check
1746
- * @returns `true` if `version` is a stable SemVer; otherwise `false`
1747
- * @throws If `version` is not a valid SemVer string
1748
- */
1749
- function isStableVersion(version) {
1750
- const parsed = semver.parse(version);
1751
- if (!parsed) throw new Error(`The version "${colors.bold(version)}" is not a valid SemVer.`);
1752
- return parsed.major > 0 && parsed.prerelease.length === 0;
1802
+ ])).trim();
1803
+ /* istanbul ignore next */
1804
+ return tag ? tag : null;
1805
+ } catch {
1806
+ return null;
1807
+ }
1753
1808
  }
1754
- // src/workflow/analysis/isCommitForPackage.ts
1809
+ // src/git/tag/getGitTagMessage.ts
1755
1810
  /**
1756
- * Test whether a commit modifies files in a package.
1811
+ * Get the message of an annotated git tag in the repository at `cwd`.
1757
1812
  *
1758
- * @param pkg Package with an explicit file pattern or base directory
1759
- * @param commit Parsed commit containing changed file paths
1760
- * @returns `true` if any changed file matches the package pattern
1813
+ * @param cwd Repository working directory
1814
+ * @param tag Tag name to query
1815
+ * @returns The tag message string when found, otherwise `undefined`
1761
1816
  */
1762
- function isCommitForPackage(pkg, commit) {
1763
- return commit.files.some((file) => {
1764
- const { location } = pkg;
1765
- return isMatch(file, pkg.files || path.join(location, "**/*"));
1766
- });
1817
+ async function getGitTagMessage(cwd, tag) {
1818
+ try {
1819
+ const [objectType, message] = (await execGit(cwd, [
1820
+ "for-each-ref",
1821
+ "--format=%(objecttype)%00%(contents)",
1822
+ `refs/tags/${tag}`
1823
+ ])).split("\0");
1824
+ if (objectType?.trim() !== "tag") return;
1825
+ return message?.trim() || void 0;
1826
+ } catch {
1827
+ /* istanbul ignore next */
1828
+ return;
1829
+ }
1767
1830
  }
1768
- // src/workflow/analysis/deriveChangeReleases.ts
1831
+ // src/git/tag/getLatestGitTag.ts
1769
1832
  /**
1770
- * Analyze commit history to update release plans for packages.
1771
- *
1772
- * Maps commit `history` across package release `plans` to associate matching
1773
- * commits with their target packages. Calculates the release type for each
1774
- * plan based on classified `history` and applies overrides according to the
1775
- * provided `hint` or existing release priority. Downgrades breaking-change
1776
- * `major` release types to `minor` while the package version is zero-major
1777
- * (`0.y.z`).
1833
+ * Get the most recent tag reachable from `HEAD`.
1778
1834
  *
1779
- * @param hint Release type override hint or default preference
1780
- * @param classifier Classifier function to determine commit release types
1781
- * @param plans List of release plans to analyze and update
1782
- * @param history Stream or iterable of git commits to process
1783
- * @returns Updated release plans with updated commit histories and release types
1835
+ * @param cwd Repository working directory
1836
+ * @returns Latest tag string or `null` when none is found
1784
1837
  */
1785
- async function deriveChangeReleases(hint, classifier, plans, history) {
1786
- for await (const commit of history) plans = plans.map((plan) => {
1787
- if (!isCommitForPackage(plan.package, commit)) return plan;
1788
- return {
1789
- ...plan,
1790
- history: plan.history.concat(commit)
1791
- };
1792
- });
1793
- return plans.map((plan) => {
1794
- let { release } = plan;
1795
- let releaseType = deriveReleaseType(classifier, plan);
1796
- if (releaseType) switch (hint) {
1797
- case "major":
1798
- case "minor":
1799
- case "patch":
1800
- releaseType = hint;
1801
- break;
1802
- default: releaseType = pickPriorityReleaseType(release?.type, releaseType);
1803
- }
1804
- if (releaseType) release = {
1805
- ...release,
1806
- type: releaseType
1807
- };
1808
- return {
1809
- ...plan,
1810
- release
1811
- };
1812
- });
1838
+ async function getLatestGitTag(cwd) {
1839
+ try {
1840
+ const tag = (await execGit(cwd, [
1841
+ "describe",
1842
+ "--tags",
1843
+ "--abbrev=0"
1844
+ ])).trim();
1845
+ /* istanbul ignore next */
1846
+ return tag ? tag : null;
1847
+ } catch {
1848
+ return null;
1849
+ }
1813
1850
  }
1814
- // src/workflow/analysis/deriveTransitionReleases.ts
1851
+ // src/git/tag/isGitTagConnected.ts
1815
1852
  /**
1816
- * Derive transition release types for release plans based on version qualifiers.
1853
+ * Determine whether a specific git tag commit is reachable from the current HEAD.
1817
1854
  *
1818
- * Evaluates unreleased `plans` by parsing package `semver` strings and checking
1819
- * prerelease tags. Compares parsed version qualifiers against
1820
- * `versionQualifier` and assigns `major`, `minor`, or `patch` release types
1821
- * according to `hint`. When `hint` is `patch`, every package receives an
1822
- * update: stable packages are assigned a patch release even without a
1823
- * `versionQualifier`, and prerelease packages (pre-major, pre-minor, and
1824
- * pre-patch cycles) continue their cycle with an incremented counter,
1825
- * redirect to `versionQualifier` when it differs, or release their stable
1826
- * base when no `versionQualifier` is set.
1855
+ * Uses `git merge-base --is-ancestor refs/tags/<tag>^{commit} HEAD` to verify
1856
+ * that the tag's commit is an ancestor of the current reference. Any non-zero
1857
+ * exit status or execution error is treated as "not reachable".
1827
1858
  *
1828
- * @param hint Release type override hint to guide release classification
1829
- * @param versionQualifier Optional qualifier string to compare against prerelease tags
1830
- * @param plans List of release plans to analyze and update
1831
- * @returns Updated release plans with derived transition release types
1859
+ * @param cwd Working directory where the git command will run
1860
+ * @param tag Tag name to evaluate (for example, "v1.2.0")
1861
+ * @returns True if the tag commit is reachable from HEAD, false otherwise
1832
1862
  */
1833
- function deriveTransitionReleases(hint, versionQualifier, plans) {
1834
- return plans.map((plan) => {
1835
- if (plan.release) return plan;
1836
- const parsed = semver.parse(plan.package.version);
1837
- if (!parsed) return plan;
1838
- const { major, minor, patch } = parsed;
1839
- const parsedVersionQualifier = extractVersionQualifier(parsed);
1840
- let releaseType;
1841
- let versionTransition;
1842
- switch (hint) {
1843
- case "major":
1844
- if (parsed.prerelease.length === 0) {
1845
- if (typeof versionQualifier === "string") releaseType = "major";
1846
- else if (major === 0 && (minor > 0 || patch > 0)) releaseType = "major";
1847
- } else if (minor === 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "major";
1848
- break;
1849
- case "minor":
1850
- if (parsed.prerelease.length === 0) {
1851
- if (typeof versionQualifier === "string") releaseType = "minor";
1852
- } else if (minor > 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "minor";
1853
- break;
1854
- case "patch":
1855
- releaseType = "patch";
1856
- break;
1857
- default: if (parsed.prerelease.length === 0) {
1858
- if (major === 0 && (minor > 0 || patch > 0)) releaseType = "major";
1859
- } else if (minor === 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "major";
1860
- else if (minor > 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "minor";
1861
- else if (patch > 0 && parsedVersionQualifier !== versionQualifier) releaseType = "patch";
1862
- }
1863
- if (parsedVersionQualifier == null || parsedVersionQualifier !== "" && versionQualifier === "") versionTransition = "advance";
1864
- else versionTransition = "continue";
1865
- if (!releaseType) return plan;
1866
- return {
1867
- ...plan,
1868
- release: {
1869
- type: releaseType,
1870
- transition: versionTransition
1871
- }
1872
- };
1873
- });
1863
+ async function isGitTagConnected(cwd, tag) {
1864
+ try {
1865
+ await execGit(cwd, [
1866
+ "merge-base",
1867
+ "--is-ancestor",
1868
+ `refs/tags/${tag}^{commit}`,
1869
+ "HEAD"
1870
+ ]);
1871
+ return true;
1872
+ } catch {
1873
+ return false;
1874
+ }
1874
1875
  }
1875
- // src/workflow/analysis/promotePrereleaseVersions.ts
1876
+ // src/git/tag/isGitTagExact.ts
1876
1877
  /**
1877
- * Promote prerelease versions when they have no explicit release type.
1878
- *
1879
- * Analyzes prerelease and zero-major versions to determine an appropriate
1880
- * release type for graduation:
1881
- * - Prerelease versions are promoted based on their highest incremented component
1882
- * (patch, minor, or major)
1883
- * - Zero-major versions (0.y.z) are promoted to major
1884
- * - Stable versions (1.0.0+) remain unchanged
1885
- * - Plans with explicit releases are preserved as-is
1878
+ * Check whether a given tag points to the provided commit.
1886
1879
  *
1887
- * @param plans Release plans to analyze
1888
- * @returns Plans with inferred release types for prerelease versions
1880
+ * @param cwd Repository working directory
1881
+ * @param tag Tag name to resolve
1882
+ * @param commit Commit hash to compare against
1883
+ * @returns `true` when the tag points at `commit`, otherwise `false`
1889
1884
  */
1890
- async function promotePrereleaseVersions(plans) {
1891
- return plans.map((plan) => {
1892
- if (plan.release) return plan;
1893
- if (!plan.package.tag) return plan;
1894
- const parsed = semver.parse(plan.package.version);
1895
- if (!parsed) return plan;
1896
- let type;
1897
- if (parsed.prerelease.length) {
1898
- if (parsed.patch !== 0) type = "patch";
1899
- else if (parsed.minor !== 0) type = "minor";
1900
- else if (parsed.major !== 0) type = "major";
1901
- else type = "major";
1902
- } else if (parsed.major === 0) type = "major";
1903
- if (type) return {
1904
- ...plan,
1905
- release: { type }
1906
- };
1907
- return plan;
1908
- });
1885
+ async function isGitTagExact(cwd, tag, commit) {
1886
+ try {
1887
+ await execGit(cwd, [
1888
+ "merge-base",
1889
+ "--is-ancestor",
1890
+ `refs/tags/${tag}^{commit}`,
1891
+ commit
1892
+ ]);
1893
+ await execGit(cwd, [
1894
+ "merge-base",
1895
+ "--is-ancestor",
1896
+ commit,
1897
+ `refs/tags/${tag}^{commit}`
1898
+ ]);
1899
+ return true;
1900
+ } catch {
1901
+ return false;
1902
+ }
1909
1903
  }
1910
1904
  // src/workflow/discovery/buildDependencyGraph.ts
1911
1905
  /**
@@ -2042,7 +2036,7 @@ async function verifyPackageTag(cwd, pkg, tagName) {
2042
2036
  } catch {
2043
2037
  return false;
2044
2038
  }
2045
- if (!isCommitForPackage(pkg, tagCommit)) return false;
2039
+ if (!packageContainsCommit(pkg, tagCommit)) return false;
2046
2040
  await expandGitHistory(cwd, { until: tagRef });
2047
2041
  return isGitTagConnected(cwd, tagName);
2048
2042
  }
@@ -2208,11 +2202,20 @@ async function propagateDependencyUpdates(cwd, plans) {
2208
2202
  });
2209
2203
  }
2210
2204
  // src/workflow/analysis/readPackageHistory.ts
2205
+ var LITERAL_PATH = /^[^*?[\]{}!+@]*$/;
2211
2206
  /**
2212
2207
  * Yield commits from git history associated with a package.
2213
2208
  *
2214
2209
  * Filters git commit history to yield only entries relevant to the target
2215
- * `pkg` directory.
2210
+ * `pkg` directory. When the package file pattern is a list, plain file
2211
+ * entries are added to the git path filter alongside the package directory
2212
+ * (duplicates removed), so commits touching extra package files (for example
2213
+ * the pnpm workspace manifest) are included. Only entries without glob or
2214
+ * pattern metacharacters (wildcards, braces, and the extglob or negation
2215
+ * characters used by package file patterns) are passed to git, because git
2216
+ * pathspecs would interpret those characters differently. Pattern-like
2217
+ * entries are left to `packageContainsCommit`, which matches them with the
2218
+ * package's own file-pattern semantics.
2216
2219
  *
2217
2220
  * @param cwd Path to the working directory for git commands
2218
2221
  * @param pkg Package configuration containing the target directory
@@ -2220,68 +2223,12 @@ async function propagateDependencyUpdates(cwd, plans) {
2220
2223
  * @yields Commits belonging to the specified package
2221
2224
  */
2222
2225
  async function* readPackageHistory(cwd, pkg, options = {}) {
2223
- options = {
2224
- ...options,
2225
- filePath: options.filePath || pkg.location
2226
- };
2227
- for await (const commit of showParsedGitHistory(cwd, options)) if (isCommitForPackage(pkg, commit)) yield commit;
2228
- }
2229
- // src/workflow/analysis/sliceUnreleased.ts
2230
- /**
2231
- * Yield parsed commits from the workspace until a release commit is found.
2232
- *
2233
- * Collects unreleased commits ahead of the most recent release commit and
2234
- * yields them in order.
2235
- *
2236
- * @param cwd Path to the working directory
2237
- * @param options Options for configuring Git history retrieval
2238
- * @yields Parsed `Commit` objects up to the most recent release commit
2239
- */
2240
- async function* sliceUnreleased(cwd, options) {
2241
- const { history } = await collectUnreleased(cwd, options);
2242
- yield* history;
2243
- }
2244
- // src/workflow/committing/readReleaseFilterPatterns.ts
2245
- /**
2246
- * Read release filter patterns from a parsed commit.
2247
- *
2248
- * Collects the release filter trailer values and splits them into individual
2249
- * comma-separated filter patterns, unescaping the commas within patterns.
2250
- * Returns `null` when the commit carries no release filter trailer, so
2251
- * callers can treat it as a release of every package.
2252
- *
2253
- * @param commit Parsed commit object or nullish value
2254
- * @returns Filter patterns carried by the trailer, or `null` when absent
2255
- */
2256
- function readReleaseFilterPatterns(commit) {
2257
- if (!commit) return null;
2258
- const values = commit.trailers.filter((trailer) => trailer.key === GIT_TRAILER_RELEASE_FILTER).map((trailer) => trailer.value);
2259
- if (values.length === 0) return null;
2260
- return values.flatMap((value) => value.split(/(?<!\\),/)).map((pattern) => pattern.trim()).map((pattern) => pattern.replaceAll("\\,", ",")).filter((pattern) => pattern.length > 0);
2261
- }
2262
- // src/workflow/analysis/sliceUnreleasedForPackage.ts
2263
- /**
2264
- * Yield unreleased commits from the history of a single package.
2265
- *
2266
- * Streams commits that touch the package files in historical order and stops
2267
- * at the first release commit that released the package. Release commits
2268
- * created by filtered runs that excluded the package are themselves yielded
2269
- * as unreleased changes, so every package keeps its own release boundary
2270
- * instead of sharing the latest repository-wide release commit.
2271
- *
2272
- * @param cwd Path to the working directory for git commands
2273
- * @param pkg Package whose files scope the commit history
2274
- * @param options Options for configuring Git history retrieval
2275
- * @yields Parsed commits up to the package's most recent release commit
2276
- */
2277
- async function* sliceUnreleasedForPackage(cwd, pkg, options = {}) {
2278
- for await (const commit of readPackageHistory(cwd, pkg, options)) {
2279
- if (await isReleaseCommit(cwd, commit, options.marker)) {
2280
- const patterns = readReleaseFilterPatterns(commit);
2281
- if (patterns === null || isMatch(pkg.name ?? "", patterns)) break;
2282
- }
2283
- yield commit;
2226
+ options = { ...options };
2227
+ if (!options.filePath) {
2228
+ if (Array.isArray(pkg.files)) options.filePath = unique([pkg.location, ...pkg.files.filter((file) => LITERAL_PATH.test(file))]);
2229
+ else options.filePath = pkg.location;
2284
2230
  }
2231
+ for await (const commit of readParsedGitHistory(cwd, options)) if (packageContainsCommit(pkg, commit)) yield commit;
2285
2232
  }
2286
2233
  // src/workflow/changelog/buildChangelog.ts
2287
2234
  var preset = await createPreset();
@@ -2437,8 +2384,8 @@ async function writeChangelog(cwd, plan) {
2437
2384
  }
2438
2385
  }
2439
2386
  // package.json
2440
- var version = "0.5.3";
2441
- // src/workflow/committing/generateReleaseCommitMessage.ts
2387
+ var version = "0.7.0";
2388
+ // src/workflow/commit/generateReleaseCommitMessage.ts
2442
2389
  var NOTABLE_TYPES = [
2443
2390
  "feat",
2444
2391
  "fix",
@@ -2580,6 +2527,69 @@ var HookManager = class {
2580
2527
  return await dispatch(0, context);
2581
2528
  }
2582
2529
  };
2530
+ // src/workflow/report/appendReleaseReportSummary.ts
2531
+ var STATUS_LABELS = {
2532
+ success: "Success",
2533
+ failure: "Failure"
2534
+ };
2535
+ /**
2536
+ * Append a Markdown release report to the GitHub Actions job summary.
2537
+ *
2538
+ * Detects a GitHub Actions runner through the `GITHUB_ACTIONS` environment
2539
+ * variable and appends the rendered `report` to the file referenced by
2540
+ * `GITHUB_STEP_SUMMARY`, so GitHub displays it on the run summary page. Does
2541
+ * nothing outside GitHub Actions or when no summary file is configured, and
2542
+ * logs a warning instead of throwing when the summary file cannot be written.
2543
+ *
2544
+ * @param logger Logger instance for reporting summary write failures
2545
+ * @param env Readonly process environment variables object
2546
+ * @param report Release report containing status and package details
2547
+ */
2548
+ function appendReleaseReportSummary(logger, env, report) {
2549
+ if (!isGitHubActions(env)) return;
2550
+ const filePath = env.GITHUB_STEP_SUMMARY;
2551
+ if (!filePath) return;
2552
+ try {
2553
+ appendFileSync(filePath, `\n${formatReleaseReportSummary(report)}`);
2554
+ } catch (error) {
2555
+ logger.warn(`GitHub Actions job summary could not be written to "${filePath}": ${error instanceof Error ? error.message : error}`);
2556
+ }
2557
+ }
2558
+ var formatPackageLabel = (plan) => {
2559
+ if (plan.package.name) return `\`${plan.package.name}\``;
2560
+ return `\`${plan.package.location}\``;
2561
+ };
2562
+ var formatReleaseReportSummary = (report) => {
2563
+ const lines = ["## ReelOut Release Report", ""];
2564
+ if (report.status) lines.push(`**Status:** ${STATUS_LABELS[report.status]}`, "");
2565
+ if (report.status === "failure") {
2566
+ const message = report.error || "An unexpected error occurred during the release process.";
2567
+ lines.push(...message.split("\n").map((line) => `> ${line}`), "");
2568
+ return lines.join("\n");
2569
+ }
2570
+ if (report.plans.length === 0) {
2571
+ lines.push("No packages are scheduled for release.", "");
2572
+ return lines.join("\n");
2573
+ }
2574
+ const plans = report.plans.toSorted((a, b) => (a.package.name || "").localeCompare(b.package.name || ""));
2575
+ lines.push("| Package | Version | Type | Tag |", "| --- | --- | --- | --- |");
2576
+ for (const plan of plans) {
2577
+ const version = `\`${plan.release.version}\` ← \`${plan.package.version}\``;
2578
+ lines.push([
2579
+ `| ${formatPackageLabel(plan)}`,
2580
+ version,
2581
+ plan.release.type,
2582
+ plan.release.tag ? `\`${plan.release.tag}\`` : ""
2583
+ ].join(" | ") + " |");
2584
+ }
2585
+ lines.push("");
2586
+ for (const plan of plans) {
2587
+ const changelog = plan.release.changelog?.trim();
2588
+ if (!changelog) continue;
2589
+ lines.push("<details>", `<summary>${formatPackageLabel(plan)} ${plan.release.version}</summary>`, "", changelog, "", "</details>", "");
2590
+ }
2591
+ return lines.join("\n");
2592
+ };
2583
2593
  // src/workflow/report/generateReleaseReport.ts
2584
2594
  /**
2585
2595
  * Generate a structured release report from the current workflow state.
@@ -2663,6 +2673,26 @@ function printReleaseReport(logger, report) {
2663
2673
  }).join("\n\n");
2664
2674
  logger.info(`${header}\n\n${list}\n`);
2665
2675
  }
2676
+ // src/workflow/report/printReleaseReportAnnotation.ts
2677
+ /**
2678
+ * Print a GitHub Actions error annotation for a failed release.
2679
+ *
2680
+ * Detects a GitHub Actions runner through the `GITHUB_ACTIONS` environment
2681
+ * variable and writes a `::error` workflow command carrying the failure
2682
+ * reason to `stdout`, so GitHub surfaces the failure as an annotation on the
2683
+ * run page. Does nothing outside GitHub Actions or when the release did not
2684
+ * fail.
2685
+ *
2686
+ * @param env Readonly process environment variables object
2687
+ * @param stdout Writable stream receiving the annotation command
2688
+ * @param report Release report containing status and failure details
2689
+ */
2690
+ function printReleaseReportAnnotation(env, stdout, report) {
2691
+ if (!isGitHubActions(env) || report.status !== "failure") return;
2692
+ const message = formatAnnotationMessage(report.error || "An unexpected error occurred during the release process.");
2693
+ stdout.write(`::error title=Release failed::${message}\n`);
2694
+ }
2695
+ var formatAnnotationMessage = (message) => message.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
2666
2696
  // src/workflow/executeReleaseWorkflow.ts
2667
2697
  /**
2668
2698
  * Execute the complete release workflow across all configured plugins.
@@ -2732,9 +2762,12 @@ async function executeReleaseWorkflow(context, plugins) {
2732
2762
  context.error = err;
2733
2763
  throw err;
2734
2764
  } finally {
2735
- printReleaseReport(context.logger, generateReleaseReport(context));
2765
+ const report = generateReleaseReport(context);
2766
+ printReleaseReport(context.logger, report);
2767
+ appendReleaseReportSummary(context.logger, context.env, report);
2768
+ printReleaseReportAnnotation(context.env, context.stdout, report);
2736
2769
  }
2737
2770
  }
2738
- export { RELEASE_HOOK_NAMES as $, deriveChangeReleases as A, getParsedGitCommit as At, isReleaseCommit as B, readJson as Bt, extractLatestVersion as C, expandGitHistory as Ct, buildDependencyGraph as D, isGitShallowRepository as Dt, extractPlainText as E, withShallowLock as Et, pickPriorityReleaseType as F, TTLCache as Ft, isSemVer as G, execGit as Gt, resolveReleaseChannel as H, isClass as Ht, determineReleaseType as I, extractMentions as It, ALL_FILES as J, isDefined as Jt, findReleaseRule as K, execCommand as Kt, bumpVersion as L, createGitCommit as Lt, isStableVersion as M, GIT_PRETTY_FORMAT as Mt, isSameReleaseCycle as N, parseGitPrettyFormat as Nt, promotePrereleaseVersions as O, countGitHistory as Ot, deriveReleaseType as P, parseGitCommit as Pt, GIT_TRAILER_RELEASE_FILTER as Q, extractVersionQualifier as R, getCurrentGitBranch as Rt, verifyPackageTag as S, detectGitRelationship as St, extractSemVer as T, isGitAncestor as Tt, sanitizePrereleaseLabel as U, interpolate as Ut, resolveVersionQualifier as V, isMatch as Vt, isSemVerGitTag as W, formatFile as Wt, DEV_NULL as X, DEFAULT_CHANGELOG_FILE as Y, buildTrailerPattern as Yt, GIT_TRAILER_RELEASE_AGENT as Z, propagateDependencyUpdates as _, showParsedGitHistory as _t, HookPriority as a, getCurrentGitTag as at, filterPackages as b, mergeGitHistory as bt, writeChangelog as c, isGitTagPresent as ct, buildReleaseNotes as d, readGitFile as dt, SEMVER_REGEX as et, buildChangelog as f, resolveGitRepository as ft, readPackageHistory as g, getGitConfigValue as gt, sliceUnreleased as h, ensureGitUserConfig as ht, HookManager as i, getGitTagMessage as it, isCommitForPackage as j, GIT_PRETTY_FIELD_SEPARATOR as jt, deriveTransitionReleases as k, getCurrentGitCommit as kt, prependChangelog as l, deleteGitTag as lt, readReleaseFilterPatterns as m, getGitRemote as mt, printReleaseReport as n, isGitTagConnected as nt, generateReleaseCommitMessage as o, generateGitTagName as ot, sliceUnreleasedForPackage as p, pushGitChanges as pt, createPlugin as q, compact as qt, generateReleaseReport as r, getLatestGitTag as rt, version as s, ensureGitTag as st, executeReleaseWorkflow as t, isGitTagPointed as tt, extractPreviousVersion as u, createGitTag as ut, resolvePackageTag as v, showGitHistory as vt, iterateChangelogVersions as w, resolveGitRevision as wt, discoverPackageTag as x, GIT_REL_FLAGS as xt, resolvePackageStableTag as y, restoreFullGitHistory as yt, collectUnreleased as z, writeJson as zt };
2771
+ export { isGitShallowRepository as $, getGitTagMessage as A, execGit as At, getGitRemote as B, SEMVER_REGEX as Bt, iterateChangelogVersions as C, readJson as Ct, isGitTagExact as D, isTruthyString as Dt, buildDependencyGraph as E, isClass as Et, deleteGitTag as F, ALL_FILES as Ft, readGitHistory as G, pickPriorityReleaseType as Gt, getGitConfigValue as H, isStableVersion as Ht, createGitTag as I, DEFAULT_CHANGELOG_FILE as It, detectGitRelationship as J, extractVersionQualifier as Jt, mergeGitHistory as K, deriveCommitReleaseType as Kt, readGitFile as L, DEV_NULL as Lt, generateGitTagName as M, compact as Mt, ensureGitTag as N, isDefined as Nt, isGitTagConnected as O, interpolate as Ot, isGitTagPresent as P, buildTrailerPattern as Pt, withShallowLock as Q, resolveGitRepository as R, GIT_TRAILER_RELEASE_AGENT as Rt, extractLatestVersion as S, unique as St, extractPlainText as T, isGitHubActions as Tt, restoreFullGitHistory as U, isSameReleaseCycle as Ut, ensureGitUserConfig as V, promotePrereleaseVersions as Vt, readParsedGitHistory as W, deriveReleaseType as Wt, resolveGitRevision as X, expandGitHistory as Y, isGitAncestor as Z, resolvePackageTag as _, isSemVerGitTag as _t, appendReleaseReportSummary as a, parseGitPrettyFormat as at, discoverPackageTag as b, createPlugin as bt, generateReleaseCommitMessage as c, extractMentions as ct, prependChangelog as d, deriveTransitionReleases as dt, countGitHistory as et, extractPreviousVersion as f, deriveChangeReleases as ft, propagateDependencyUpdates as g, sanitizePrereleaseLabel as gt, readPackageHistory as h, resolveReleaseChannel as ht, generateReleaseReport as i, GIT_PRETTY_FORMAT as it, getCurrentGitTag as j, execCommand as jt, getLatestGitTag as k, formatFile as kt, version as l, createGitCommit as lt, buildChangelog as m, resolveVersionQualifier as mt, printReleaseReportAnnotation as n, getParsedGitCommit as nt, HookManager as o, parseGitCommit as ot, buildReleaseNotes as p, packageContainsCommit as pt, GIT_REL_FLAGS as q, bumpVersion as qt, printReleaseReport as r, GIT_PRETTY_FIELD_SEPARATOR as rt, HookPriority as s, TTLCache as st, executeReleaseWorkflow as t, getCurrentGitCommit as tt, writeChangelog as u, getCurrentGitBranch as ut, resolvePackageStableTag as v, isSemVer as vt, extractSemVer as w, isMatch as wt, verifyPackageTag as x, writeJson as xt, filterPackages as y, findReleaseRule as yt, pushGitChanges as z, RELEASE_HOOK_NAMES as zt };
2739
2772
 
2740
- //# sourceMappingURL=workflow-c9uKSARL.js.map
2773
+ //# sourceMappingURL=workflow-MQRNVoZo.js.map