@reelout/core 0.6.0 → 0.7.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 (43) 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 -36
  6. package/dist/index.js.map +1 -1
  7. package/dist/{workflow-c9uKSARL.js → workflow-BolfadM0.js} +690 -773
  8. package/dist/workflow-BolfadM0.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/workflow/analysis/deriveChangeReleases.ts +3 -3
  19. package/src/workflow/analysis/deriveTransitionReleases.ts +1 -1
  20. package/src/workflow/analysis/index.ts +1 -5
  21. package/src/workflow/analysis/{isCommitForPackage.ts → packageContainsCommit.ts} +4 -1
  22. package/src/workflow/analysis/readPackageHistory.ts +28 -9
  23. package/src/workflow/commit/index.ts +4 -0
  24. package/src/workflow/discovery/verifyPackageTag.ts +2 -2
  25. package/src/workflow/index.ts +2 -2
  26. package/src/workflow/{versioning/determineReleaseType.ts → version/deriveCommitReleaseType.ts} +2 -2
  27. package/src/workflow/{versioning → version}/deriveReleaseType.ts +2 -2
  28. package/src/workflow/{versioning → version}/index.ts +2 -1
  29. package/dist/workflow-c9uKSARL.js.map +0 -1
  30. package/src/workflow/analysis/collectUnreleased.ts +0 -44
  31. package/src/workflow/analysis/sliceUnreleased.ts +0 -24
  32. package/src/workflow/analysis/sliceUnreleasedForPackage.ts +0 -41
  33. package/src/workflow/committing/formatReleaseFilterPatterns.ts +0 -18
  34. package/src/workflow/committing/index.ts +0 -7
  35. package/src/workflow/committing/isReleaseCommit.ts +0 -56
  36. package/src/workflow/committing/readReleaseFilterPatterns.ts +0 -38
  37. /package/src/workflow/{committing → commit}/generateReleaseCommitMessage.ts +0 -0
  38. /package/src/workflow/{versioning → version}/bumpVersion.ts +0 -0
  39. /package/src/workflow/{versioning → version}/extractVersionQualifier.ts +0 -0
  40. /package/src/workflow/{versioning → version}/isSameReleaseCycle.ts +0 -0
  41. /package/src/workflow/{versioning → version}/isStableVersion.ts +0 -0
  42. /package/src/workflow/{versioning → version}/pickPriorityReleaseType.ts +0 -0
  43. /package/src/workflow/{analysis → version}/promotePrereleaseVersions.ts +0 -0
@@ -1,19 +1,274 @@
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
+ // src/workflow/version/extractVersionQualifier.ts
18
+ /**
19
+ * Extract the version qualifier string from a parsed `SemVer` instance.
20
+ *
21
+ * Strips the trailing numeric counter from the `prerelease` components if
22
+ * present. Joins any remaining prerelease identifiers with a dot separator.
23
+ *
24
+ * @param version Parsed `SemVer` instance or nullish value to inspect
25
+ * @returns The extracted qualifier string or `undefined` if no prerelease exists
26
+ */
27
+ function extractVersionQualifier(version) {
28
+ if (version != null && version.prerelease.length > 0) {
29
+ const prerelease = [...version.prerelease];
30
+ if (typeof prerelease.at(-1) === "number") prerelease.pop();
31
+ return prerelease.join(".");
32
+ } else return;
33
+ }
34
+ // src/workflow/version/bumpVersion.ts
35
+ /**
36
+ * Bump a semantic version string based on release and transition rules.
37
+ *
38
+ * Parses the target version and determines the next version string using the
39
+ * specified release type, prerelease identifier, and transition mode. Adjusts
40
+ * prerelease types when continuing an existing qualifier and returns `null` when
41
+ * `options.release` is omitted or if transition conditions fail.
42
+ *
43
+ * @param options Version bump configuration including release type, identifier, and transition rules
44
+ * @returns The bumped semantic version string, or `null` if no bump occurs
45
+ * @throws If `options.version` is not a valid semantic version
46
+ */
47
+ function bumpVersion(options) {
48
+ const { version } = options;
49
+ const parsed = semver.parse(version);
50
+ if (!parsed) throw new Error(`Version "${version}" is not a valid semantic version.`);
51
+ if (!options.release) return null;
52
+ if (parsed.prerelease.length > 0) {
53
+ if (options.transition === "advance" && options.identifier == null) return null;
54
+ } else if (options.transition === "continue") return null;
55
+ let release = options.release;
56
+ let identifier;
57
+ if (typeof options.identifier === "string") {
58
+ release = `pre${options.release}`;
59
+ identifier = options.identifier;
60
+ const parsedIdentifier = extractVersionQualifier(parsed);
61
+ const transition = options.transition ?? (parsedIdentifier && identifier === "" ? "advance" : "continue");
62
+ if (typeof parsedIdentifier === "string" && transition === "continue") {
63
+ if (release === "premajor" && parsed.minor === 0 && parsed.patch === 0 || release === "preminor" && parsed.patch === 0 || release === "prepatch") release = "prerelease";
64
+ }
65
+ }
66
+ return semver.inc(parsed, release, { loose: false }, identifier, "0");
67
+ }
68
+ // src/workflow/version/deriveCommitReleaseType.ts
69
+ /**
70
+ * Derive the release type for a single commit.
71
+ *
72
+ * Returns `'minor'` for a commit marked as a breaking change while the
73
+ * supplied `version` is zero-major (`0.y.z`), and `'major'` otherwise, since
74
+ * SemVer treats `0.y.z` as initial development where breaking changes do not
75
+ * require a new major version. Otherwise, routes the commit through the
76
+ * custom `classifier` and ensures the resolved value is a valid semantic
77
+ * versioning release type.
78
+ *
79
+ * @param classifier Function mapping commits to release types
80
+ * @param commit Parsed commit to evaluate
81
+ * @param version Current package version used to adjust zero-major breaking releases
82
+ * @returns `ReleaseType` string, or `null` when no matching rule applies
83
+ */
84
+ function deriveCommitReleaseType(classifier, commit, version) {
85
+ if (commit.notes.length > 0) return semver.parse(version)?.major === 0 ? "minor" : "major";
86
+ const type = classifier(commit);
87
+ switch (type) {
88
+ case "major":
89
+ case "minor":
90
+ case "patch": return type;
91
+ }
92
+ return null;
93
+ }
94
+ // src/workflow/version/pickPriorityReleaseType.ts
95
+ /**
96
+ * Determine the highest-priority release type between two candidates.
97
+ *
98
+ * Compares release types by precedence order: `major` > `minor` > `patch`.
99
+ * Returns the higher-precedence type, or `null` if neither applies.
100
+ *
101
+ * @param curr Current accumulated release type
102
+ * @param next Candidate release type to consider
103
+ * @returns Highest-precedence `ReleaseType`, or `null` if neither applies
104
+ */
105
+ function pickPriorityReleaseType(curr, next) {
106
+ for (const type of [
107
+ "major",
108
+ "minor",
109
+ "patch"
110
+ ]) if (curr === type || next === type) return type;
111
+ return null;
112
+ }
113
+ // src/workflow/version/deriveReleaseType.ts
114
+ /**
115
+ * Derive the combined release type from a release plan.
116
+ *
117
+ * Processes the plan's commits sequentially, accumulating the
118
+ * highest-precedence release type found by evaluating each individual commit
119
+ * and comparing it against the current maximum via `pickPriorityReleaseType`.
120
+ * Breaking commits resolve to `minor` while the plan's package version is
121
+ * zero-major (`0.y.z`).
122
+ *
123
+ * @param classifier Function mapping commits to release types
124
+ * @param plan Release plan carrying the commit history and package version
125
+ * @returns `ReleaseType` string, or `null` when no matching rule applies
126
+ */
127
+ function deriveReleaseType(classifier, plan) {
128
+ let releaseType = null;
129
+ for (const commit of plan.history) releaseType = pickPriorityReleaseType(releaseType, deriveCommitReleaseType(classifier, commit, plan.package.version));
130
+ return releaseType;
131
+ }
132
+ // src/workflow/version/isSameReleaseCycle.ts
133
+ /**
134
+ * Determine whether two semantic version strings or objects belong to the same release cycle.
135
+ *
136
+ * Compares the main version components of `currentVersion` and `nextVersion` to
137
+ * determine equality. Treats a transition from a non-zero `0.x` version to
138
+ * `1.0.0` as part of the same release cycle. Returns `false` if either input
139
+ * cannot be parsed.
140
+ *
141
+ * @param currentVersion Starting version string, `semver.SemVer` instance, or nullish value
142
+ * @param nextVersion Target version string, `semver.SemVer` instance, or nullish value
143
+ * @returns `true` if both versions belong to the same release cycle, `false` otherwise
144
+ */
145
+ function isSameReleaseCycle(currentVersion, nextVersion) {
146
+ const current = semver.parse(currentVersion);
147
+ const next = semver.parse(nextVersion);
148
+ if (!current || !next) return false;
149
+ if (current.compareMain(next) === 0) return true;
150
+ return current.major === 0 && (current.minor > 0 || current.patch > 0) && next.major === 1 && next.minor === 0 && next.patch === 0;
151
+ }
152
+ // src/workflow/version/isStableVersion.ts
153
+ /**
154
+ * Determine whether a version string represents a stable SemVer release.
155
+ *
156
+ * A version is considered stable when:
157
+ * - It is a valid SemVer string.
158
+ * - Its major version is greater than 0 (not 0.x.x).
159
+ * - It contains no prerelease identifiers (no `-alpha`, `-beta`, `-rc`, etc.).
160
+ *
161
+ * Build metadata (the `+` suffix) does not affect stability.
162
+ *
163
+ * @param version Semantic version string to check
164
+ * @returns `true` if `version` is a stable SemVer; otherwise `false`
165
+ * @throws If `version` is not a valid SemVer string
166
+ */
167
+ function isStableVersion(version) {
168
+ const parsed = semver.parse(version);
169
+ if (!parsed) throw new Error(`The version "${colors.bold(version)}" is not a valid SemVer.`);
170
+ return parsed.major > 0 && parsed.prerelease.length === 0;
171
+ }
172
+ // src/workflow/version/promotePrereleaseVersions.ts
173
+ /**
174
+ * Promote prerelease versions when they have no explicit release type.
175
+ *
176
+ * Analyzes prerelease and zero-major versions to determine an appropriate
177
+ * release type for graduation:
178
+ * - Prerelease versions are promoted based on their highest incremented component
179
+ * (patch, minor, or major)
180
+ * - Zero-major versions (0.y.z) are promoted to major
181
+ * - Stable versions (1.0.0+) remain unchanged
182
+ * - Plans with explicit releases are preserved as-is
183
+ *
184
+ * @param plans Release plans to analyze
185
+ * @returns Plans with inferred release types for prerelease versions
186
+ */
187
+ async function promotePrereleaseVersions(plans) {
188
+ return plans.map((plan) => {
189
+ if (plan.release) return plan;
190
+ if (!plan.package.tag) return plan;
191
+ const parsed = semver.parse(plan.package.version);
192
+ if (!parsed) return plan;
193
+ let type;
194
+ if (parsed.prerelease.length) {
195
+ if (parsed.patch !== 0) type = "patch";
196
+ else if (parsed.minor !== 0) type = "minor";
197
+ else if (parsed.major !== 0) type = "major";
198
+ else type = "major";
199
+ } else if (parsed.major === 0) type = "major";
200
+ if (type) return {
201
+ ...plan,
202
+ release: { type }
203
+ };
204
+ return plan;
205
+ });
206
+ }
207
+ // src/config/const.ts
208
+ var ALL_FILES = "**/*";
209
+ var DEFAULT_CHANGELOG_FILE = "CHANGELOG.md";
210
+ var GIT_TRAILER_RELEASE_AGENT = "Release-Agent";
211
+ /**
212
+ * 1. Primitive Building Blocks
213
+ *
214
+ * Base regular expression patterns for wildcards, alphanumeric strings with hyphens,
215
+ * and standard non-negative integers.
216
+ */
217
+ var WILDCARD = "\\*";
218
+ var ALPHANUM_DASH = "[0-9a-zA-Z-]+";
219
+ var NUMERIC_IDENTIFIER = "0|[1-9]\\d*";
220
+ /**
221
+ * 2. Package Name & Prefix Constructs
222
+ *
223
+ * Matches package name prefixes (unscoped or scoped) or a simple `v` prefix.
224
+ *
225
+ * Capture Groups:
226
+ * - Group 1: Package name (e.g., `my-package` or `@scope/my-package`)
227
+ */
228
+ var PKG_NAME_PART = `(?:${WILDCARD}|${ALPHANUM_DASH})`;
229
+ var OPTIONAL_VERSION_PREFIX = `(?:v|${`(${PKG_NAME_PART}|@${PKG_NAME_PART}\\/${PKG_NAME_PART})`}@)`;
230
+ /**
231
+ * 3. Core SemVer Components
232
+ *
233
+ * Matches standard `MAJOR.MINOR.PATCH` versions or wildcard variants (e.g., `1.0.0`, `*.*.*`).
234
+ *
235
+ * Capture Groups:
236
+ * - Group 3: Major version
237
+ * - Group 4: Minor version
238
+ * - Group 5: Patch version
239
+ */
240
+ var CAPTURED_VERSION_DIGIT = `(${WILDCARD}|${NUMERIC_IDENTIFIER})`;
241
+ var SEMVER_CORE = `${CAPTURED_VERSION_DIGIT}\\.${CAPTURED_VERSION_DIGIT}\\.${CAPTURED_VERSION_DIGIT}`;
242
+ var PRERELEASE_IDENTIFIER = `(?:${WILDCARD}|${NUMERIC_IDENTIFIER}|(\\d*[a-zA-Z-][0-9a-zA-Z-]*))`;
243
+ var FULL_SEMVER_PATTERN = `${OPTIONAL_VERSION_PREFIX}?${`(${SEMVER_CORE}${`(?:-(${PRERELEASE_IDENTIFIER}(?:\\.${PRERELEASE_IDENTIFIER})*))`}?${`(?:\\+(${ALPHANUM_DASH}(?:\\.${ALPHANUM_DASH})*))`}?)`}`;
244
+ /**
245
+ * Regular expression to match and capture Semantic Versioning (SemVer) strings,
246
+ * including optional package prefixes (e.g., `@scope/pkg@`) and `v` prefixes.
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * SEMVER_REGEX.test('1.0.0') // true
251
+ * SEMVER_REGEX.test('v1.2.3-beta.1+sha.1234') // true
252
+ * SEMVER_REGEX.test('@scope/package@1.0.0') // true
253
+ * ```
254
+ *
255
+ * @see {@link https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SemVer Specification}
256
+ */
257
+ var SEMVER_REGEX = new RegExp(FULL_SEMVER_PATTERN);
258
+ var DEV_NULL = new Writable({
259
+ /* istanbul ignore next */
260
+ write(_chunk, _encoding, callback) {
261
+ callback();
262
+ } });
263
+ var RELEASE_HOOK_NAMES = [
264
+ "configure",
265
+ "discover",
266
+ "analyze",
267
+ "build",
268
+ "write",
269
+ "publish",
270
+ "finalize"
271
+ ];
17
272
  // src/util/buildTrailerPattern.ts
18
273
  /**
19
274
  * Build a regular expression to match trailer lines using custom markers.
@@ -364,15 +619,35 @@ async function readJson(filePath) {
364
619
  if (typeof json !== "object" || json === null) throw new Error(`JSON file at "${colors.bold(filePath)}" does not contain a valid object.`);
365
620
  return json;
366
621
  }
367
- // src/util/writeJson.ts
622
+ // src/util/unique.ts
368
623
  /**
369
- * Write a JSON `payload` to `filePath`, formatting the content first.
624
+ * Return a new array containing only the first-seen occurrence of each item.
370
625
  *
371
- * Ensures the directory exists and writes the formatted JSON.
626
+ * This preserves the original iteration order and performs equality checks
627
+ * using JavaScript's `Set` semantics (i.e., primitives by value, objects by
628
+ * reference). The input array is not mutated.
372
629
  *
373
- * @param filePath Path to write the JSON file
374
- * @param payload JSON-serializable object to write
375
- * @returns Promise that resolves when the file is written
630
+ * @param array The array of items to deduplicate
631
+ * @returns A new array with duplicates removed, preserving first-seen order
632
+ */
633
+ function unique(array) {
634
+ const seen = /* @__PURE__ */ new Set();
635
+ const result = [];
636
+ for (const item of array) if (!seen.has(item)) {
637
+ seen.add(item);
638
+ result.push(item);
639
+ }
640
+ return result;
641
+ }
642
+ // src/util/writeJson.ts
643
+ /**
644
+ * Write a JSON `payload` to `filePath`, formatting the content first.
645
+ *
646
+ * Ensures the directory exists and writes the formatted JSON.
647
+ *
648
+ * @param filePath Path to write the JSON file
649
+ * @param payload JSON-serializable object to write
650
+ * @returns Promise that resolves when the file is written
376
651
  */
377
652
  async function writeJson(filePath, payload) {
378
653
  let content = JSON.stringify(payload, null, 2);
@@ -380,6 +655,251 @@ async function writeJson(filePath, payload) {
380
655
  await fs.mkdir(path.dirname(filePath), { recursive: true });
381
656
  await fs.writeFile(filePath, content);
382
657
  }
658
+ // src/config/createPlugin.ts
659
+ /**
660
+ * Instantiate or invoke a plugin factory to produce a release plugin instance.
661
+ *
662
+ * Accepts class constructors, factory functions, tuple configurations, or
663
+ * existing plugin objects. Instantiates classes using `new` or invokes factory
664
+ * functions with options, validating that the resulting object satisfies the
665
+ * plugin structure.
666
+ *
667
+ * @param plugin A plugin constructor, factory function, tuple, or object
668
+ * @returns A validated release plugin instance or null
669
+ */
670
+ async function createPlugin(plugin) {
671
+ let options;
672
+ if (Array.isArray(plugin)) [plugin, options] = plugin;
673
+ if (typeof plugin === "function") plugin = isClass(plugin) ? new plugin(options) : await plugin(options);
674
+ if (plugin != null && typeof plugin === "object" && Object.hasOwn(plugin, "name") && typeof plugin.name === "string") return plugin;
675
+ return null;
676
+ }
677
+ // src/config/findReleaseRule.ts
678
+ /**
679
+ * Find the first release rule matching a release reference.
680
+ *
681
+ * Matches rules sequentially against the reference type and pattern.
682
+ *
683
+ * @param ref Release reference object
684
+ * @param rules Array of release rules to match against
685
+ * @returns The first matching release rule or `undefined`
686
+ */
687
+ function findReleaseRule(ref, rules) {
688
+ return rules.find((rule) => {
689
+ return (rule.type == null || rule.type === ref.type) && isMatch(ref.name, rule.pattern);
690
+ });
691
+ }
692
+ // src/config/isSemVer.ts
693
+ /**
694
+ * Determine whether a value is a valid Semantic Versioning string.
695
+ *
696
+ * Rejects non-string values, leading or trailing whitespace, and leading `v`
697
+ * prefixes. Validates the candidate string using `semver.parse`.
698
+ *
699
+ * @param version Candidate value to evaluate for SemVer compliance
700
+ * @returns `true` if `version` is a valid SemVer string, or `false` otherwise
701
+ */
702
+ function isSemVer(version) {
703
+ if (typeof version !== "string") return false;
704
+ if (version !== version.trim()) return false;
705
+ if (version.startsWith("v")) return false;
706
+ return semver.parse(version) != null;
707
+ }
708
+ // src/config/isSemVerGitTag.ts
709
+ /**
710
+ * Determine whether a tag string is a valid SemVer-style Git tag.
711
+ *
712
+ * Anchors `SEMVER_REGEX.source` for full-string matching and applies the
713
+ * repository's Git-tag acceptance rules.
714
+ *
715
+ * @param tag Tag string to validate
716
+ * @returns `true` if `tag` is accepted as a SemVer-style Git tag; otherwise `false`
717
+ */
718
+ function isSemVerGitTag(tag) {
719
+ const match = new RegExp(`^${SEMVER_REGEX.source}$`).exec(tag);
720
+ if (!match) return false;
721
+ const isScopedPackage = Boolean(match[1]);
722
+ const hasVersionPrefix = tag.startsWith("v");
723
+ return isScopedPackage || hasVersionPrefix;
724
+ }
725
+ // src/config/sanitizePrereleaseLabel.ts
726
+ /**
727
+ * Sanitize a string into a safe, SemVer-compliant prerelease label.
728
+ *
729
+ * Replaces sequences of non-alphanumeric characters with a single hyphen and
730
+ * removes leading or trailing hyphens.
731
+ *
732
+ * @param label Raw string to sanitize
733
+ * @returns Safe SemVer prerelease label
734
+ */
735
+ function sanitizePrereleaseLabel(label) {
736
+ return label.replace(/[^a-zA-Z0-9]+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
737
+ }
738
+ // src/config/resolveReleaseChannel.ts
739
+ /**
740
+ * Resolve the release channel for a release context.
741
+ *
742
+ * Uses the release rule when `channel` is `boolean` or omitted. Sanitizes the
743
+ * reference name when enabling default channel resolution and interpolates
744
+ * `templateParams` into the result.
745
+ *
746
+ * @param options Options for resolving the release channel
747
+ * @returns Resolved release channel string or `undefined`
748
+ */
749
+ function resolveReleaseChannel(options) {
750
+ const { ref, rule, templateParams } = options;
751
+ let { channel } = options;
752
+ let resolved;
753
+ if (channel === true || channel == null) channel = rule?.releaseChannel ?? channel;
754
+ if (typeof channel === "string") resolved = channel;
755
+ else if (channel) resolved = sanitizePrereleaseLabel(ref.name);
756
+ if (typeof resolved === "string") resolved = interpolate(resolved, templateParams);
757
+ return resolved;
758
+ }
759
+ // src/config/resolveVersionQualifier.ts
760
+ /**
761
+ * Resolve the version qualifier for a release context.
762
+ *
763
+ * Uses the release rule when `qualifier` is `boolean` or omitted. Interpolates
764
+ * `templateParams` into `qualifier` and validates that the result forms a
765
+ * valid SemVer prerelease identifier.
766
+ *
767
+ * @param options Options for resolving the version qualifier
768
+ * @returns Resolved version qualifier string or `undefined`
769
+ * @throws If the resolved string is not a valid SemVer prerelease identifier
770
+ */
771
+ function resolveVersionQualifier(options) {
772
+ const { rule, templateParams } = options;
773
+ let { qualifier } = options;
774
+ let resolved;
775
+ if (qualifier === true || qualifier == null) qualifier = rule?.versionQualifier ?? qualifier;
776
+ if (typeof qualifier === "string") resolved = qualifier;
777
+ else if (qualifier) resolved = "";
778
+ if (typeof resolved === "string") resolved = interpolate(resolved, templateParams);
779
+ if (resolved && !isSemVer(`1.0.0-${resolved}.1`)) throw new Error(`The resolved version qualifier "${resolved}" is not a valid SemVer prerelease identifier.`);
780
+ return resolved;
781
+ }
782
+ // src/workflow/analysis/packageContainsCommit.ts
783
+ /**
784
+ * Test whether a commit modifies files in a package.
785
+ *
786
+ * @param pkg Package with an explicit file pattern or base directory
787
+ * @param commit Parsed commit containing changed file paths
788
+ * @returns `true` if any changed file matches the package pattern
789
+ */
790
+ function packageContainsCommit(pkg, commit) {
791
+ return commit.files.some((file) => {
792
+ const { location } = pkg;
793
+ return isMatch(file, pkg.files || path.join(location, "**/*"));
794
+ });
795
+ }
796
+ // src/workflow/analysis/deriveChangeReleases.ts
797
+ /**
798
+ * Analyze commit history to update release plans for packages.
799
+ *
800
+ * Maps commit `history` across package release `plans` to associate matching
801
+ * commits with their target packages. Calculates the release type for each
802
+ * plan based on classified `history` and applies overrides according to the
803
+ * provided `hint` or existing release priority. Downgrades breaking-change
804
+ * `major` release types to `minor` while the package version is zero-major
805
+ * (`0.y.z`).
806
+ *
807
+ * @param hint Release type override hint or default preference
808
+ * @param classifier Classifier function to determine commit release types
809
+ * @param plans List of release plans to analyze and update
810
+ * @param history Stream or iterable of git commits to process
811
+ * @returns Updated release plans with updated commit histories and release types
812
+ */
813
+ async function deriveChangeReleases(hint, classifier, plans, history) {
814
+ for await (const commit of history) plans = plans.map((plan) => {
815
+ if (!packageContainsCommit(plan.package, commit)) return plan;
816
+ return {
817
+ ...plan,
818
+ history: plan.history.concat(commit)
819
+ };
820
+ });
821
+ return plans.map((plan) => {
822
+ let { release } = plan;
823
+ let releaseType = deriveReleaseType(classifier, plan);
824
+ if (releaseType) switch (hint) {
825
+ case "major":
826
+ case "minor":
827
+ case "patch":
828
+ releaseType = hint;
829
+ break;
830
+ default: releaseType = pickPriorityReleaseType(release?.type, releaseType);
831
+ }
832
+ if (releaseType) release = {
833
+ ...release,
834
+ type: releaseType
835
+ };
836
+ return {
837
+ ...plan,
838
+ release
839
+ };
840
+ });
841
+ }
842
+ // src/workflow/analysis/deriveTransitionReleases.ts
843
+ /**
844
+ * Derive transition release types for release plans based on version qualifiers.
845
+ *
846
+ * Evaluates unreleased `plans` by parsing package `semver` strings and checking
847
+ * prerelease tags. Compares parsed version qualifiers against
848
+ * `versionQualifier` and assigns `major`, `minor`, or `patch` release types
849
+ * according to `hint`. When `hint` is `patch`, every package receives an
850
+ * update: stable packages are assigned a patch release even without a
851
+ * `versionQualifier`, and prerelease packages (pre-major, pre-minor, and
852
+ * pre-patch cycles) continue their cycle with an incremented counter,
853
+ * redirect to `versionQualifier` when it differs, or release their stable
854
+ * base when no `versionQualifier` is set.
855
+ *
856
+ * @param hint Release type override hint to guide release classification
857
+ * @param versionQualifier Optional qualifier string to compare against prerelease tags
858
+ * @param plans List of release plans to analyze and update
859
+ * @returns Updated release plans with derived transition release types
860
+ */
861
+ function deriveTransitionReleases(hint, versionQualifier, plans) {
862
+ return plans.map((plan) => {
863
+ if (plan.release) return plan;
864
+ const parsed = semver.parse(plan.package.version);
865
+ if (!parsed) return plan;
866
+ const { major, minor, patch } = parsed;
867
+ const parsedVersionQualifier = extractVersionQualifier(parsed);
868
+ let releaseType;
869
+ let versionTransition;
870
+ switch (hint) {
871
+ case "major":
872
+ if (parsed.prerelease.length === 0) {
873
+ if (typeof versionQualifier === "string") releaseType = "major";
874
+ else if (major === 0 && (minor > 0 || patch > 0)) releaseType = "major";
875
+ } else if (minor === 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "major";
876
+ break;
877
+ case "minor":
878
+ if (parsed.prerelease.length === 0) {
879
+ if (typeof versionQualifier === "string") releaseType = "minor";
880
+ } else if (minor > 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "minor";
881
+ break;
882
+ case "patch":
883
+ releaseType = "patch";
884
+ break;
885
+ default: if (parsed.prerelease.length === 0) {
886
+ if (major === 0 && (minor > 0 || patch > 0)) releaseType = "major";
887
+ } else if (minor === 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "major";
888
+ else if (minor > 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "minor";
889
+ else if (patch > 0 && parsedVersionQualifier !== versionQualifier) releaseType = "patch";
890
+ }
891
+ if (parsedVersionQualifier == null || parsedVersionQualifier !== "" && versionQualifier === "") versionTransition = "advance";
892
+ else versionTransition = "continue";
893
+ if (!releaseType) return plan;
894
+ return {
895
+ ...plan,
896
+ release: {
897
+ type: releaseType,
898
+ transition: versionTransition
899
+ }
900
+ };
901
+ });
902
+ }
383
903
  // src/git/branch/getCurrentGitBranch.ts
384
904
  /**
385
905
  * Get the current Git branch name.
@@ -925,20 +1445,7 @@ async function mergeGitHistory(cwd, a, b) {
925
1445
  if (j) merged.push(j);
926
1446
  return merged.concat(a2).concat(b2);
927
1447
  }
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
1448
+ // src/git/history/readGitHistory.ts
942
1449
  /**
943
1450
  * Yield commit SHAs from repository history in paginated order.
944
1451
  *
@@ -950,7 +1457,7 @@ function restoreFullGitHistory(cwd) {
950
1457
  * @param options Supports `from`, `until`, `pageSize`, and `filePath`
951
1458
  * @yields Commit SHA strings in paginated order
952
1459
  */
953
- async function* showGitHistory(cwd, options = {}) {
1460
+ async function* readGitHistory(cwd, options = {}) {
954
1461
  try {
955
1462
  const { filePath, pageSize = 50 } = options;
956
1463
  let from = options.from || "HEAD";
@@ -981,23 +1488,36 @@ async function* showGitHistory(cwd, options = {}) {
981
1488
  }
982
1489
  } catch {}
983
1490
  }
984
- // src/git/history/showParsedGitHistory.ts
1491
+ // src/git/history/readParsedGitHistory.ts
985
1492
  /**
986
1493
  * Yield parsed commits sequentially from repository history.
987
1494
  *
988
- * Fetches commits using `showGitHistory` and parses each commit with
1495
+ * Fetches commits using `readGitHistory` and parses each commit with
989
1496
  * `getParsedGitCommit`. Yields successfully parsed `GitCommit` objects on demand
990
1497
  * and skips unparsable commits.
991
1498
  *
992
1499
  * @param cwd Repository working directory path
993
- * @param options Filter and pagination options passed to `showGitHistory`
1500
+ * @param options Filter and pagination options passed to `readGitHistory`
994
1501
  * @yields Parsed `GitCommit` objects in historical order
995
1502
  */
996
- async function* showParsedGitHistory(cwd, options) {
997
- for await (const commit of showGitHistory(cwd, options)) try {
1503
+ async function* readParsedGitHistory(cwd, options) {
1504
+ for await (const commit of readGitHistory(cwd, options)) try {
998
1505
  yield await getParsedGitCommit(cwd, commit);
999
1506
  } catch {}
1000
1507
  }
1508
+ // src/git/history/restoreFullGitHistory.ts
1509
+ /**
1510
+ * Convert a shallow clone into a full clone by fetching additional history.
1511
+ *
1512
+ * Runs `git fetch --unshallow`. Returns `true` when the operation succeeds
1513
+ * and `false` on error.
1514
+ *
1515
+ * @param cwd Repository working directory
1516
+ * @returns `true` when the operation succeeded, otherwise `false`
1517
+ */
1518
+ function restoreFullGitHistory(cwd) {
1519
+ return execGit(cwd, ["fetch", "--unshallow"]).then(() => true).catch(() => false);
1520
+ }
1001
1521
  // src/git/repository/getGitConfigValue.ts
1002
1522
  /**
1003
1523
  * Get a local git configuration value for `key` in the repository at `cwd`.
@@ -1323,7 +1843,7 @@ async function isGitTagConnected(cwd, tag) {
1323
1843
  return false;
1324
1844
  }
1325
1845
  }
1326
- // src/git/tag/isGitTagPointed.ts
1846
+ // src/git/tag/isGitTagExact.ts
1327
1847
  /**
1328
1848
  * Check whether a given tag points to the provided commit.
1329
1849
  *
@@ -1332,7 +1852,7 @@ async function isGitTagConnected(cwd, tag) {
1332
1852
  * @param commit Commit hash to compare against
1333
1853
  * @returns `true` when the tag points at `commit`, otherwise `false`
1334
1854
  */
1335
- async function isGitTagPointed(cwd, tag, commit) {
1855
+ async function isGitTagExact(cwd, tag, commit) {
1336
1856
  try {
1337
1857
  await execGit(cwd, [
1338
1858
  "merge-base",
@@ -1351,713 +1871,157 @@ async function isGitTagPointed(cwd, tag, commit) {
1351
1871
  return false;
1352
1872
  }
1353
1873
  }
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})`}@)`;
1874
+ // src/workflow/discovery/buildDependencyGraph.ts
1378
1875
  /**
1379
- * 3. Core SemVer Components
1876
+ * Build a dependency graph mapping package names to dependent release plans.
1380
1877
  *
1381
- * Matches standard `MAJOR.MINOR.PATCH` versions or wildcard variants (e.g., `1.0.0`, `*.*.*`).
1878
+ * Each key is a package name and the value is a set of `ReleasePlan`s that
1879
+ * list that package as a dependency.
1382
1880
  *
1383
- * Capture Groups:
1384
- * - Group 3: Major version
1385
- * - Group 4: Minor version
1386
- * - Group 5: Patch version
1881
+ * @param plans Array of release plans to analyze
1882
+ * @returns Dependency graph mapping package name -> set of dependent plans
1387
1883
  */
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})*))`}?)`}`;
1884
+ function buildDependencyGraph(plans) {
1885
+ const graph = /* @__PURE__ */ new Map();
1886
+ const packageNames = new Set(plans.map((plan) => plan.package.name).filter((name) => !!name));
1887
+ for (const plan of plans) for (const depName of plan.package.dependencies) {
1888
+ let set = graph.get(depName);
1889
+ if (!set && packageNames.has(depName)) graph.set(depName, set = /* @__PURE__ */ new Set());
1890
+ if (set) set.add(plan);
1891
+ }
1892
+ return graph;
1893
+ }
1894
+ // src/workflow/changelog/extractPlainText.ts
1392
1895
  /**
1393
- * Regular expression to match and capture Semantic Versioning (SemVer) strings,
1394
- * including optional package prefixes (e.g., `@scope/pkg@`) and `v` prefixes.
1896
+ * Extract trimmed plain text from a Heading, Paragraph, or PhrasingContent node.
1395
1897
  *
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
- * ```
1898
+ * Performs a depth-first traversal, concatenating string `value` tokens in
1899
+ * document order. Non-string values are ignored. Returns `null` for empty or
1900
+ * missing input.
1402
1901
  *
1403
- * @see {@link https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SemVer Specification}
1902
+ * @param node Node to extract text from
1903
+ * @returns The trimmed plain-text string, or null if empty
1404
1904
  */
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
1905
+ function extractPlainText(node) {
1906
+ if (!node) return null;
1907
+ const queue = [node];
1908
+ let result = "";
1909
+ while (node = queue.shift()) {
1910
+ if ("value" in node && typeof node.value === "string") result += node.value;
1911
+ /* istanbul ignore else */
1912
+ if ("children" in node && Array.isArray(node.children)) queue.unshift(...node.children);
1913
+ }
1914
+ return result.trim() || null;
1915
+ }
1916
+ // src/workflow/changelog/extractSemVer.ts
1917
+ var ANCHORED_SEMVER_REGEX = new RegExp(`^${SEMVER_REGEX.source}$`);
1918
+ var BRACKETED_SEMVER_REGEX = new RegExp(`\\[${SEMVER_REGEX.source}\\]`);
1421
1919
  /**
1422
- * Instantiate or invoke a plugin factory to produce a release plugin instance.
1920
+ * Extract SemVer core strings from a line.
1423
1921
  *
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.
1922
+ * Splits the line on runs of spaces or tabs and on `..`/`...`. For each token,
1923
+ * first attempts an anchored SemVer match (must match the whole token), then
1924
+ * a bracketed match that finds a SemVer inside `[...]`. Returns the captured
1925
+ * SemVer core (capture group 2) for each successful match; falsy results are
1926
+ * filtered out.
1428
1927
  *
1429
- * @param plugin A plugin constructor, factory function, tuple, or object
1430
- * @returns A validated release plugin instance or null
1928
+ * @param line Line to scan for SemVer cores
1929
+ * @returns Array of extracted SemVer core strings; empty if none
1431
1930
  */
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;
1931
+ function extractSemVer(line) {
1932
+ return compact(line.split(/[ \t]+|\.{2,3}/).map((token) => {
1933
+ return (ANCHORED_SEMVER_REGEX.exec(token) ?? BRACKETED_SEMVER_REGEX.exec(token))?.at(2);
1934
+ }));
1438
1935
  }
1439
- // src/config/findReleaseRule.ts
1936
+ // src/workflow/changelog/iterateChangelogVersions.ts
1937
+ var SENTENCE_TERMINAL_REGEX = /\p{Sentence_Terminal}$/u;
1440
1938
  /**
1441
- * Find the first release rule matching a release reference.
1939
+ * Iterate over Semantic Version strings extracted from a Markdown changelog.
1442
1940
  *
1443
- * Matches rules sequentially against the reference type and pattern.
1941
+ * Parses `changelogContent` into an AST and evaluates nodes sequentially using
1942
+ * custom extractors. Evaluates heading nodes first before checking short
1943
+ * paragraph nodes. Stops execution after the first strategy yields valid
1944
+ * versions.
1444
1945
  *
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`
1946
+ * @param changelogContent Raw Markdown text of the changelog
1947
+ * @yields Valid SemVer strings found in headings or candidate paragraphs
1448
1948
  */
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
- });
1949
+ function* iterateChangelogVersions(changelogContent) {
1950
+ const root = fromMarkdown(changelogContent);
1951
+ const nodeExtractors = [(node) => {
1952
+ return node.type === "heading" ? extractPlainText(node) : null;
1953
+ }, (node) => {
1954
+ if (node.type !== "paragraph") return null;
1955
+ const paragraphText = extractPlainText(node);
1956
+ if (!paragraphText || paragraphText.length > 48 || SENTENCE_TERMINAL_REGEX.test(paragraphText)) return null;
1957
+ return paragraphText;
1958
+ }];
1959
+ for (const extractText of nodeExtractors) {
1960
+ let isVersionFound = false;
1961
+ for (const node of root.children) {
1962
+ const extractedText = extractText(node);
1963
+ const candidateVersion = extractedText ? semver.sort(extractSemVer(extractedText)).pop() : null;
1964
+ if (candidateVersion && semver.valid(candidateVersion)) {
1965
+ isVersionFound = true;
1966
+ yield candidateVersion;
1967
+ }
1968
+ }
1969
+ if (isVersionFound) return;
1970
+ }
1453
1971
  }
1454
- // src/config/isSemVer.ts
1972
+ // src/workflow/changelog/extractLatestVersion.ts
1455
1973
  /**
1456
- * Determine whether a value is a valid Semantic Versioning string.
1974
+ * Find the highest semantic version from the first version-bearing element.
1457
1975
  *
1458
- * Rejects non-string values, leading or trailing whitespace, and leading `v`
1459
- * prefixes. Validates the candidate string using `semver.parse`.
1976
+ * Pulls the first available version string from the parsed markdown iterator.
1977
+ * Short-circuits execution immediately upon locating a match to avoid passing
1978
+ * through the remaining document structure.
1460
1979
  *
1461
- * @param version Candidate value to evaluate for SemVer compliance
1462
- * @returns `true` if `version` is a valid SemVer string, or `false` otherwise
1980
+ * @param changelogContent The raw markdown string representing the changelog
1981
+ * @returns The highest valid semantic version string found or null
1463
1982
  */
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;
1983
+ function extractLatestVersion(changelogContent) {
1984
+ for (const version of iterateChangelogVersions(changelogContent)) return version;
1985
+ return null;
1469
1986
  }
1470
- // src/config/isSemVerGitTag.ts
1987
+ // src/workflow/discovery/verifyPackageTag.ts
1471
1988
  /**
1472
- * Determine whether a tag string is a valid SemVer-style Git tag.
1989
+ * Verify a Git tag against package specifications and repository history.
1473
1990
  *
1474
- * Anchors `SEMVER_REGEX.source` for full-string matching and applies the
1475
- * repository's Git-tag acceptance rules.
1991
+ * Ensures the target tag exists locally before parsing its commit data. Rejects
1992
+ * tags that do not target a commit matching the specified `pkg`. Expands the
1993
+ * history graph up to the tag reference before verifying structural connectivity.
1476
1994
  *
1477
- * @param tag Tag string to validate
1478
- * @returns `true` if `tag` is accepted as a SemVer-style Git tag; otherwise `false`
1995
+ * @param cwd Repository working directory path
1996
+ * @param pkg Package descriptor containing version and location context
1997
+ * @param tagName Name of the Git tag to verify
1998
+ * @returns True if the tag is valid and connected; otherwise, false
1479
1999
  */
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;
2000
+ async function verifyPackageTag(cwd, pkg, tagName) {
2001
+ await ensureGitTag(cwd, tagName);
2002
+ const tagRef = `refs/tags/${tagName}`;
2003
+ let tagCommit;
2004
+ try {
2005
+ tagCommit = await getParsedGitCommit(cwd, tagRef);
2006
+ } catch {
2007
+ return false;
2008
+ }
2009
+ if (!packageContainsCommit(pkg, tagCommit)) return false;
2010
+ await expandGitHistory(cwd, { until: tagRef });
2011
+ return isGitTagConnected(cwd, tagName);
1486
2012
  }
1487
- // src/config/sanitizePrereleaseLabel.ts
2013
+ // src/workflow/discovery/discoverPackageTag.ts
1488
2014
  /**
1489
- * Sanitize a string into a safe, SemVer-compliant prerelease label.
2015
+ * Discover and validate the Git tag for a package.
1490
2016
  *
1491
- * Replaces sequences of non-alphanumeric characters with a single hyphen and
1492
- * removes leading or trailing hyphens.
2017
+ * Returns the existing tag if already present on the `pkg` object. Resolves
2018
+ * the local changelog file path, extracts the current version, and generates
2019
+ * the expected Git tag name. Verifies the tag against the repository and
2020
+ * ensures its historical changelog version matches the current local version.
1493
2021
  *
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;
1753
- }
1754
- // src/workflow/analysis/isCommitForPackage.ts
1755
- /**
1756
- * Test whether a commit modifies files in a package.
1757
- *
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
1761
- */
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
- });
1767
- }
1768
- // src/workflow/analysis/deriveChangeReleases.ts
1769
- /**
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`).
1778
- *
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
1784
- */
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
- });
1813
- }
1814
- // src/workflow/analysis/deriveTransitionReleases.ts
1815
- /**
1816
- * Derive transition release types for release plans based on version qualifiers.
1817
- *
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.
1827
- *
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
1832
- */
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
- });
1874
- }
1875
- // src/workflow/analysis/promotePrereleaseVersions.ts
1876
- /**
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
1886
- *
1887
- * @param plans Release plans to analyze
1888
- * @returns Plans with inferred release types for prerelease versions
1889
- */
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
- });
1909
- }
1910
- // src/workflow/discovery/buildDependencyGraph.ts
1911
- /**
1912
- * Build a dependency graph mapping package names to dependent release plans.
1913
- *
1914
- * Each key is a package name and the value is a set of `ReleasePlan`s that
1915
- * list that package as a dependency.
1916
- *
1917
- * @param plans Array of release plans to analyze
1918
- * @returns Dependency graph mapping package name -> set of dependent plans
1919
- */
1920
- function buildDependencyGraph(plans) {
1921
- const graph = /* @__PURE__ */ new Map();
1922
- const packageNames = new Set(plans.map((plan) => plan.package.name).filter((name) => !!name));
1923
- for (const plan of plans) for (const depName of plan.package.dependencies) {
1924
- let set = graph.get(depName);
1925
- if (!set && packageNames.has(depName)) graph.set(depName, set = /* @__PURE__ */ new Set());
1926
- if (set) set.add(plan);
1927
- }
1928
- return graph;
1929
- }
1930
- // src/workflow/changelog/extractPlainText.ts
1931
- /**
1932
- * Extract trimmed plain text from a Heading, Paragraph, or PhrasingContent node.
1933
- *
1934
- * Performs a depth-first traversal, concatenating string `value` tokens in
1935
- * document order. Non-string values are ignored. Returns `null` for empty or
1936
- * missing input.
1937
- *
1938
- * @param node Node to extract text from
1939
- * @returns The trimmed plain-text string, or null if empty
1940
- */
1941
- function extractPlainText(node) {
1942
- if (!node) return null;
1943
- const queue = [node];
1944
- let result = "";
1945
- while (node = queue.shift()) {
1946
- if ("value" in node && typeof node.value === "string") result += node.value;
1947
- /* istanbul ignore else */
1948
- if ("children" in node && Array.isArray(node.children)) queue.unshift(...node.children);
1949
- }
1950
- return result.trim() || null;
1951
- }
1952
- // src/workflow/changelog/extractSemVer.ts
1953
- var ANCHORED_SEMVER_REGEX = new RegExp(`^${SEMVER_REGEX.source}$`);
1954
- var BRACKETED_SEMVER_REGEX = new RegExp(`\\[${SEMVER_REGEX.source}\\]`);
1955
- /**
1956
- * Extract SemVer core strings from a line.
1957
- *
1958
- * Splits the line on runs of spaces or tabs and on `..`/`...`. For each token,
1959
- * first attempts an anchored SemVer match (must match the whole token), then
1960
- * a bracketed match that finds a SemVer inside `[...]`. Returns the captured
1961
- * SemVer core (capture group 2) for each successful match; falsy results are
1962
- * filtered out.
1963
- *
1964
- * @param line Line to scan for SemVer cores
1965
- * @returns Array of extracted SemVer core strings; empty if none
1966
- */
1967
- function extractSemVer(line) {
1968
- return compact(line.split(/[ \t]+|\.{2,3}/).map((token) => {
1969
- return (ANCHORED_SEMVER_REGEX.exec(token) ?? BRACKETED_SEMVER_REGEX.exec(token))?.at(2);
1970
- }));
1971
- }
1972
- // src/workflow/changelog/iterateChangelogVersions.ts
1973
- var SENTENCE_TERMINAL_REGEX = /\p{Sentence_Terminal}$/u;
1974
- /**
1975
- * Iterate over Semantic Version strings extracted from a Markdown changelog.
1976
- *
1977
- * Parses `changelogContent` into an AST and evaluates nodes sequentially using
1978
- * custom extractors. Evaluates heading nodes first before checking short
1979
- * paragraph nodes. Stops execution after the first strategy yields valid
1980
- * versions.
1981
- *
1982
- * @param changelogContent Raw Markdown text of the changelog
1983
- * @yields Valid SemVer strings found in headings or candidate paragraphs
1984
- */
1985
- function* iterateChangelogVersions(changelogContent) {
1986
- const root = fromMarkdown(changelogContent);
1987
- const nodeExtractors = [(node) => {
1988
- return node.type === "heading" ? extractPlainText(node) : null;
1989
- }, (node) => {
1990
- if (node.type !== "paragraph") return null;
1991
- const paragraphText = extractPlainText(node);
1992
- if (!paragraphText || paragraphText.length > 48 || SENTENCE_TERMINAL_REGEX.test(paragraphText)) return null;
1993
- return paragraphText;
1994
- }];
1995
- for (const extractText of nodeExtractors) {
1996
- let isVersionFound = false;
1997
- for (const node of root.children) {
1998
- const extractedText = extractText(node);
1999
- const candidateVersion = extractedText ? semver.sort(extractSemVer(extractedText)).pop() : null;
2000
- if (candidateVersion && semver.valid(candidateVersion)) {
2001
- isVersionFound = true;
2002
- yield candidateVersion;
2003
- }
2004
- }
2005
- if (isVersionFound) return;
2006
- }
2007
- }
2008
- // src/workflow/changelog/extractLatestVersion.ts
2009
- /**
2010
- * Find the highest semantic version from the first version-bearing element.
2011
- *
2012
- * Pulls the first available version string from the parsed markdown iterator.
2013
- * Short-circuits execution immediately upon locating a match to avoid passing
2014
- * through the remaining document structure.
2015
- *
2016
- * @param changelogContent The raw markdown string representing the changelog
2017
- * @returns The highest valid semantic version string found or null
2018
- */
2019
- function extractLatestVersion(changelogContent) {
2020
- for (const version of iterateChangelogVersions(changelogContent)) return version;
2021
- return null;
2022
- }
2023
- // src/workflow/discovery/verifyPackageTag.ts
2024
- /**
2025
- * Verify a Git tag against package specifications and repository history.
2026
- *
2027
- * Ensures the target tag exists locally before parsing its commit data. Rejects
2028
- * tags that do not target a commit matching the specified `pkg`. Expands the
2029
- * history graph up to the tag reference before verifying structural connectivity.
2030
- *
2031
- * @param cwd Repository working directory path
2032
- * @param pkg Package descriptor containing version and location context
2033
- * @param tagName Name of the Git tag to verify
2034
- * @returns True if the tag is valid and connected; otherwise, false
2035
- */
2036
- async function verifyPackageTag(cwd, pkg, tagName) {
2037
- await ensureGitTag(cwd, tagName);
2038
- const tagRef = `refs/tags/${tagName}`;
2039
- let tagCommit;
2040
- try {
2041
- tagCommit = await getParsedGitCommit(cwd, tagRef);
2042
- } catch {
2043
- return false;
2044
- }
2045
- if (!isCommitForPackage(pkg, tagCommit)) return false;
2046
- await expandGitHistory(cwd, { until: tagRef });
2047
- return isGitTagConnected(cwd, tagName);
2048
- }
2049
- // src/workflow/discovery/discoverPackageTag.ts
2050
- /**
2051
- * Discover and validate the Git tag for a package.
2052
- *
2053
- * Returns the existing tag if already present on the `pkg` object. Resolves
2054
- * the local changelog file path, extracts the current version, and generates
2055
- * the expected Git tag name. Verifies the tag against the repository and
2056
- * ensures its historical changelog version matches the current local version.
2057
- *
2058
- * @param cwd The current working directory
2059
- * @param pkg The package configuration object
2060
- * @returns The validated `Tag` object or null if validation fails
2022
+ * @param cwd The current working directory
2023
+ * @param pkg The package configuration object
2024
+ * @returns The validated `Tag` object or null if validation fails
2061
2025
  */
2062
2026
  async function discoverPackageTag(cwd, pkg) {
2063
2027
  if (pkg.tag) return pkg.tag;
@@ -2208,11 +2172,20 @@ async function propagateDependencyUpdates(cwd, plans) {
2208
2172
  });
2209
2173
  }
2210
2174
  // src/workflow/analysis/readPackageHistory.ts
2175
+ var LITERAL_PATH = /^[^*?[\]{}!+@]*$/;
2211
2176
  /**
2212
2177
  * Yield commits from git history associated with a package.
2213
2178
  *
2214
2179
  * Filters git commit history to yield only entries relevant to the target
2215
- * `pkg` directory.
2180
+ * `pkg` directory. When the package file pattern is a list, plain file
2181
+ * entries are added to the git path filter alongside the package directory
2182
+ * (duplicates removed), so commits touching extra package files (for example
2183
+ * the pnpm workspace manifest) are included. Only entries without glob or
2184
+ * pattern metacharacters (wildcards, braces, and the extglob or negation
2185
+ * characters used by package file patterns) are passed to git, because git
2186
+ * pathspecs would interpret those characters differently. Pattern-like
2187
+ * entries are left to `packageContainsCommit`, which matches them with the
2188
+ * package's own file-pattern semantics.
2216
2189
  *
2217
2190
  * @param cwd Path to the working directory for git commands
2218
2191
  * @param pkg Package configuration containing the target directory
@@ -2220,68 +2193,12 @@ async function propagateDependencyUpdates(cwd, plans) {
2220
2193
  * @yields Commits belonging to the specified package
2221
2194
  */
2222
2195
  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;
2196
+ options = { ...options };
2197
+ if (!options.filePath) {
2198
+ if (Array.isArray(pkg.files)) options.filePath = unique([pkg.location, ...pkg.files.filter((file) => LITERAL_PATH.test(file))]);
2199
+ else options.filePath = pkg.location;
2284
2200
  }
2201
+ for await (const commit of readParsedGitHistory(cwd, options)) if (packageContainsCommit(pkg, commit)) yield commit;
2285
2202
  }
2286
2203
  // src/workflow/changelog/buildChangelog.ts
2287
2204
  var preset = await createPreset();
@@ -2437,8 +2354,8 @@ async function writeChangelog(cwd, plan) {
2437
2354
  }
2438
2355
  }
2439
2356
  // package.json
2440
- var version = "0.5.3";
2441
- // src/workflow/committing/generateReleaseCommitMessage.ts
2357
+ var version = "0.6.0";
2358
+ // src/workflow/commit/generateReleaseCommitMessage.ts
2442
2359
  var NOTABLE_TYPES = [
2443
2360
  "feat",
2444
2361
  "fix",
@@ -2735,6 +2652,6 @@ async function executeReleaseWorkflow(context, plugins) {
2735
2652
  printReleaseReport(context.logger, generateReleaseReport(context));
2736
2653
  }
2737
2654
  }
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 };
2655
+ export { getCurrentGitCommit as $, generateGitTagName as A, buildTrailerPattern as At, getGitConfigValue as B, deriveReleaseType as Bt, extractPlainText as C, isClass as Ct, getLatestGitTag as D, execCommand as Dt, isGitTagConnected as E, execGit as Et, readGitFile as F, RELEASE_HOOK_NAMES as Ft, GIT_REL_FLAGS as G, readParsedGitHistory as H, deriveCommitReleaseType as Ht, resolveGitRepository as I, SEMVER_REGEX as It, resolveGitRevision as J, detectGitRelationship as K, pushGitChanges as L, promotePrereleaseVersions as Lt, isGitTagPresent as M, DEFAULT_CHANGELOG_FILE as Mt, deleteGitTag as N, DEV_NULL as Nt, getGitTagMessage as O, compact as Ot, createGitTag as P, GIT_TRAILER_RELEASE_AGENT as Pt, countGitHistory as Q, getGitRemote as R, isStableVersion as Rt, extractSemVer as S, isMatch as St, isGitTagExact as T, formatFile as Tt, readGitHistory as U, bumpVersion as Ut, restoreFullGitHistory as V, pickPriorityReleaseType as Vt, mergeGitHistory as W, extractVersionQualifier as Wt, withShallowLock as X, isGitAncestor as Y, isGitShallowRepository as Z, filterPackages as _, findReleaseRule as _t, HookPriority as a, TTLCache as at, extractLatestVersion as b, unique as bt, writeChangelog as c, getCurrentGitBranch as ct, buildReleaseNotes as d, packageContainsCommit as dt, getParsedGitCommit as et, buildChangelog as f, resolveVersionQualifier as ft, resolvePackageStableTag as g, isSemVer as gt, resolvePackageTag as h, isSemVerGitTag as ht, HookManager as i, parseGitCommit as it, ensureGitTag as j, ALL_FILES as jt, getCurrentGitTag as k, isDefined as kt, prependChangelog as l, deriveTransitionReleases as lt, propagateDependencyUpdates as m, sanitizePrereleaseLabel as mt, printReleaseReport as n, GIT_PRETTY_FORMAT as nt, generateReleaseCommitMessage as o, extractMentions as ot, readPackageHistory as p, resolveReleaseChannel as pt, expandGitHistory as q, generateReleaseReport as r, parseGitPrettyFormat as rt, version as s, createGitCommit as st, executeReleaseWorkflow as t, GIT_PRETTY_FIELD_SEPARATOR as tt, extractPreviousVersion as u, deriveChangeReleases as ut, discoverPackageTag as v, createPlugin as vt, buildDependencyGraph as w, interpolate as wt, iterateChangelogVersions as x, readJson as xt, verifyPackageTag as y, writeJson as yt, ensureGitUserConfig as z, isSameReleaseCycle as zt };
2739
2656
 
2740
- //# sourceMappingURL=workflow-c9uKSARL.js.map
2657
+ //# sourceMappingURL=workflow-BolfadM0.js.map