@reelout/core 0.1.1 → 0.4.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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/dist/analyzer.js +33 -0
  3. package/dist/analyzer.js.map +1 -0
  4. package/dist/builder.js +64 -0
  5. package/dist/builder.js.map +1 -0
  6. package/dist/changelog.js +63 -0
  7. package/dist/changelog.js.map +1 -0
  8. package/dist/formatError-BXNdyRfu.js +23 -0
  9. package/dist/formatError-BXNdyRfu.js.map +1 -0
  10. package/dist/index.js +199 -1
  11. package/dist/index.js.map +1 -0
  12. package/dist/types-la_KkjCS.js +1 -0
  13. package/dist/types.js +2 -0
  14. package/dist/workflow-BRMp4uB6.js +2736 -0
  15. package/dist/workflow-BRMp4uB6.js.map +1 -0
  16. package/package.json +35 -6
  17. package/src/analyzer.ts +59 -0
  18. package/src/builder.ts +116 -0
  19. package/src/cache/TTLCache.ts +100 -0
  20. package/src/cache/index.ts +4 -0
  21. package/src/changelog.ts +107 -0
  22. package/src/config/const.ts +104 -0
  23. package/src/config/createPlugin.ts +41 -0
  24. package/src/config/findReleaseRule.ts +26 -0
  25. package/src/config/index.ts +15 -0
  26. package/src/config/isSemVer.ts +31 -0
  27. package/src/config/isSemVerGitTag.ts +25 -0
  28. package/src/config/normalizeCommitFilter.ts +37 -0
  29. package/src/config/normalizeReleaseRule.ts +66 -0
  30. package/src/config/normalizeWorkspace.ts +34 -0
  31. package/src/config/resolvePlugin.ts +57 -0
  32. package/src/config/resolveReleaseChannel.ts +47 -0
  33. package/src/config/resolveVersionQualifier.ts +53 -0
  34. package/src/config/sanitizePrereleaseLabel.ts +18 -0
  35. package/src/git/branch/getCurrentGitBranch.ts +18 -0
  36. package/src/git/branch/index.ts +4 -0
  37. package/src/git/commit/createGitCommit.ts +29 -0
  38. package/src/git/commit/extractMentions.ts +34 -0
  39. package/src/git/commit/getCurrentGitCommit.ts +19 -0
  40. package/src/git/commit/getParsedGitCommit.ts +49 -0
  41. package/src/git/commit/index.ts +9 -0
  42. package/src/git/commit/parseGitCommit.ts +114 -0
  43. package/src/git/commit/parseGitPrettyFormat.ts +76 -0
  44. package/src/git/history/countGitHistory.ts +28 -0
  45. package/src/git/history/expandGitHistory.ts +112 -0
  46. package/src/git/history/index.ts +9 -0
  47. package/src/git/history/mergeGitHistory.ts +76 -0
  48. package/src/git/history/restoreFullGitHistory.ts +19 -0
  49. package/src/git/history/showGitHistory.ts +80 -0
  50. package/src/git/history/showParsedGitHistory.ts +28 -0
  51. package/src/git/index.ts +9 -0
  52. package/src/git/repository/ensureGitUserConfig.ts +50 -0
  53. package/src/git/repository/getGitConfigValue.ts +27 -0
  54. package/src/git/repository/getGitRemote.ts +20 -0
  55. package/src/git/repository/index.ts +10 -0
  56. package/src/git/repository/isGitShallowRepository.ts +21 -0
  57. package/src/git/repository/pushGitChanges.ts +26 -0
  58. package/src/git/repository/resolveGitRepository.ts +40 -0
  59. package/src/git/repository/withShallowLock.ts +62 -0
  60. package/src/git/revision/detectGitRelationship.ts +43 -0
  61. package/src/git/revision/index.ts +7 -0
  62. package/src/git/revision/isGitAncestor.ts +33 -0
  63. package/src/git/revision/readGitFile.ts +29 -0
  64. package/src/git/revision/resolveGitRevision.ts +23 -0
  65. package/src/git/tag/createGitTag.ts +25 -0
  66. package/src/git/tag/deleteGitTag.ts +17 -0
  67. package/src/git/tag/ensureGitTag.ts +63 -0
  68. package/src/git/tag/generateGitTagName.ts +43 -0
  69. package/src/git/tag/getCurrentGitTag.ts +23 -0
  70. package/src/git/tag/getGitTagMessage.ts +35 -0
  71. package/src/git/tag/getLatestGitTag.ts +22 -0
  72. package/src/git/tag/index.ts +13 -0
  73. package/src/git/tag/isGitTagConnected.ts +33 -0
  74. package/src/git/tag/isGitTagPointed.ts +38 -0
  75. package/src/git/tag/isGitTagPresent.ts +17 -0
  76. package/src/index.ts +9 -2
  77. package/src/plugin/HookManager.ts +128 -0
  78. package/src/plugin/index.ts +4 -0
  79. package/src/types.ts +259 -0
  80. package/src/util/buildTrailerPattern.ts +20 -0
  81. package/src/util/compact.ts +14 -0
  82. package/src/util/execCommand.ts +196 -0
  83. package/src/util/execGit.ts +27 -0
  84. package/src/util/formatError.ts +21 -0
  85. package/src/util/formatFile.ts +41 -0
  86. package/src/util/index.ts +18 -0
  87. package/src/util/interpolate.ts +141 -0
  88. package/src/util/isCI.ts +18 -0
  89. package/src/util/isClass.ts +34 -0
  90. package/src/util/isDefined.ts +12 -0
  91. package/src/util/isMatch.ts +43 -0
  92. package/src/util/isTruthyString.ts +19 -0
  93. package/src/util/readJson.ts +47 -0
  94. package/src/util/unique.ts +26 -0
  95. package/src/util/writeJson.ts +28 -0
  96. package/src/workflow/analysis/deriveChangeReleases.ts +76 -0
  97. package/src/workflow/analysis/deriveTransitionReleases.ts +134 -0
  98. package/src/workflow/analysis/index.ts +10 -0
  99. package/src/workflow/analysis/isCommitForPackage.ts +23 -0
  100. package/src/workflow/analysis/promotePrereleaseVersions.ts +51 -0
  101. package/src/workflow/analysis/propagateDependencyUpdates.ts +71 -0
  102. package/src/workflow/analysis/sliceUnreleased.ts +36 -0
  103. package/src/workflow/analysis/streamPackageCommits.ts +34 -0
  104. package/src/workflow/changelog/buildChangelog.ts +79 -0
  105. package/src/workflow/changelog/buildReleaseNotes.ts +50 -0
  106. package/src/workflow/changelog/conventional-changelog-conventionalcommits.d.ts +7 -0
  107. package/src/workflow/changelog/extractLatestVersion.ts +22 -0
  108. package/src/workflow/changelog/extractPlainText.ts +38 -0
  109. package/src/workflow/changelog/extractPreviousVersion.ts +77 -0
  110. package/src/workflow/changelog/extractSemVer.ts +33 -0
  111. package/src/workflow/changelog/index.ts +12 -0
  112. package/src/workflow/changelog/iterateChangelogVersions.ts +70 -0
  113. package/src/workflow/changelog/prependChangelog.ts +59 -0
  114. package/src/workflow/changelog/writeChangelog.ts +27 -0
  115. package/src/workflow/committing/generateReleaseCommitMessage.ts +121 -0
  116. package/src/workflow/committing/index.ts +5 -0
  117. package/src/workflow/committing/isReleaseCommit.ts +56 -0
  118. package/src/workflow/discovery/buildDependencyGraph.ts +43 -0
  119. package/src/workflow/discovery/discoverPackageTag.ts +98 -0
  120. package/src/workflow/discovery/index.ts +9 -0
  121. package/src/workflow/discovery/resolvePackageStableTag.ts +88 -0
  122. package/src/workflow/discovery/resolvePackageTag.ts +45 -0
  123. package/src/workflow/discovery/sortPackages.ts +75 -0
  124. package/src/workflow/discovery/verifyPackageTag.ts +49 -0
  125. package/src/workflow/executeReleaseWorkflow.ts +130 -0
  126. package/src/workflow/index.ts +10 -0
  127. package/src/workflow/report/generateReleaseReport.ts +54 -0
  128. package/src/workflow/report/index.ts +5 -0
  129. package/src/workflow/report/printReleaseReport.ts +97 -0
  130. package/src/workflow/versioning/bumpVersion.ts +76 -0
  131. package/src/workflow/versioning/deriveReleaseType.ts +33 -0
  132. package/src/workflow/versioning/determineReleaseType.ts +35 -0
  133. package/src/workflow/versioning/extractVersionQualifier.ts +29 -0
  134. package/src/workflow/versioning/index.ts +10 -0
  135. package/src/workflow/versioning/isSameReleaseCycle.ts +36 -0
  136. package/src/workflow/versioning/isStableVersion.ts +31 -0
  137. package/src/workflow/versioning/pickPriorityReleaseType.ts +27 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,33 @@
1
+ import { dt as deriveTransitionReleases, ft as deriveChangeReleases, g as propagateDependencyUpdates, m as sliceUnreleased, s as version } from "./workflow-BRMp4uB6.js";
2
+ //#region src/analyzer.ts
3
+ /**
4
+ * Built-in plugin that inspects repository history and produces release plans for packages.
5
+ *
6
+ * @remarks
7
+ * **Lifecycle Stages:**
8
+ * - `analyze`: Initializes release plans if empty, extracts unreleased Git commit history,
9
+ * calculates package version bumps based on commit classifications, handles transition releases
10
+ * for empty changesets (if enabled), and propagates dependency updates across internal packages.
11
+ *
12
+ * @returns A release plugin configured for package change analysis.
13
+ */
14
+ var analyzer = () => ({
15
+ name: "@reelout/core/analyzer",
16
+ version,
17
+ analyze: async (context, next) => {
18
+ if (context.plans.length === 0) context.plans = context.packages.map((pkg) => ({
19
+ package: pkg,
20
+ history: [],
21
+ release: null
22
+ }));
23
+ const history = await sliceUnreleased(context.cwd);
24
+ context.plans = await deriveChangeReleases(context.type, context.classifier, context.plans, history);
25
+ if (context.allowEmpty) context.plans = deriveTransitionReleases(context.type, context.versionQualifier, context.plans);
26
+ context.plans = await propagateDependencyUpdates(context.cwd, context.plans);
27
+ return next(context);
28
+ }
29
+ });
30
+ //#endregion
31
+ export { analyzer as default };
32
+
33
+ //# sourceMappingURL=analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzer.js","names":[],"sources":["../src/analyzer.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleasePlan, ReleasePlugin } from '#types'\nimport {\n deriveChangeReleases,\n deriveTransitionReleases,\n propagateDependencyUpdates,\n sliceUnreleased,\n} from '#workflow'\nimport { version } from '../package.json'\n\n/**\n * Built-in plugin that inspects repository history and produces release plans for packages.\n *\n * @remarks\n * **Lifecycle Stages:**\n * - `analyze`: Initializes release plans if empty, extracts unreleased Git commit history,\n * calculates package version bumps based on commit classifications, handles transition releases\n * for empty changesets (if enabled), and propagates dependency updates across internal packages.\n *\n * @returns A release plugin configured for package change analysis.\n */\nconst analyzer = (): ReleasePlugin => ({\n name: '@reelout/core/analyzer',\n version,\n analyze: async (context, next) => {\n if (context.plans.length === 0) {\n context.plans = context.packages.map((pkg): ReleasePlan => ({\n package: pkg,\n history: [],\n release: null,\n }))\n }\n\n const history = await sliceUnreleased(context.cwd)\n\n context.plans = await deriveChangeReleases(\n context.type,\n context.classifier,\n context.plans,\n history\n )\n\n if (context.allowEmpty) {\n context.plans = deriveTransitionReleases(\n context.type,\n context.versionQualifier,\n context.plans\n )\n }\n\n context.plans = await propagateDependencyUpdates(context.cwd, context.plans)\n\n return next(context)\n },\n})\n\nexport default analyzer\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAM,kBAAiC;CACrC,MAAM;CACN;CACA,SAAS,OAAO,SAAS,SAAS;EAChC,IAAI,QAAQ,MAAM,WAAW,GAC3B,QAAQ,QAAQ,QAAQ,SAAS,KAAK,SAAsB;GAC1D,SAAS;GACT,SAAS,CAAC;GACV,SAAS;EACX,EAAE;EAGJ,MAAM,UAAU,MAAM,gBAAgB,QAAQ,GAAG;EAEjD,QAAQ,QAAQ,MAAM,qBACpB,QAAQ,MACR,QAAQ,YACR,QAAQ,OACR,OACF;EAEA,IAAI,QAAQ,YACV,QAAQ,QAAQ,yBACd,QAAQ,MACR,QAAQ,kBACR,QAAQ,KACV;EAGF,QAAQ,QAAQ,MAAM,2BAA2B,QAAQ,KAAK,QAAQ,KAAK;EAE3E,OAAO,KAAK,OAAO;CACrB;AACF"}
@@ -0,0 +1,64 @@
1
+ import { Ut as bumpVersion, d as buildReleaseNotes, j as generateGitTagName, p as streamPackageCommits, s as version, v as resolvePackageStableTag, zt as isSameReleaseCycle } from "./workflow-BRMp4uB6.js";
2
+ import { t as formatError } from "./formatError-BXNdyRfu.js";
3
+ import { colors } from "consola/utils";
4
+ //#region src/builder.ts
5
+ /**
6
+ * Built-in plugin that prepares release metadata and artifacts for active plans.
7
+ *
8
+ * @remarks
9
+ * **Lifecycle Stages:**
10
+ * - `build`: Computes bumped package versions, derives standardized Git tag names,
11
+ * and generates release notes/tag messages from unreleased commit history.
12
+ *
13
+ * @returns A release plugin configured for release metadata preparation.
14
+ */
15
+ var builder = () => ({
16
+ name: "@reelout/core/builder",
17
+ version,
18
+ build: async (context, next) => {
19
+ context.plans = await Promise.all(context.plans.map(async (plan) => {
20
+ plan = { ...plan };
21
+ if (!plan.release) return plan;
22
+ plan.release = { ...plan.release };
23
+ let version;
24
+ try {
25
+ version = bumpVersion({
26
+ version: plan.package.version,
27
+ private: plan.package.private,
28
+ release: plan.release.type,
29
+ identifier: context.versionQualifier,
30
+ transition: plan.release.transition
31
+ });
32
+ } catch (err) {
33
+ context.logger.warn(colors.yellow(`Version could not be determined for package at "${colors.bold(plan.package.location)}": ${formatError(err)}`));
34
+ }
35
+ if (version) plan.release.version = version;
36
+ let tagName;
37
+ try {
38
+ tagName = generateGitTagName(plan.package.entry, plan.package.name, plan.release.version);
39
+ } catch (err) {
40
+ context.logger.warn(colors.yellow(`Tag could not be determined for package at "${colors.bold(plan.package.location)}": ${formatError(err)}`));
41
+ }
42
+ let tagMessage;
43
+ try {
44
+ if (tagName) {
45
+ if (context.allowEmpty && plan.history.length === 0 && isSameReleaseCycle(plan.package.version, plan.release.version)) {
46
+ const previousTag = (await resolvePackageStableTag(context.cwd, plan.package))?.name;
47
+ const history = streamPackageCommits(context.cwd, plan.package, { until: previousTag });
48
+ tagMessage = await buildReleaseNotes(context, history);
49
+ } else tagMessage = await buildReleaseNotes(context, plan.history);
50
+ }
51
+ } catch {}
52
+ if (tagName) plan.release.tag = {
53
+ name: tagName,
54
+ message: tagMessage
55
+ };
56
+ return plan;
57
+ }));
58
+ return next(context);
59
+ }
60
+ });
61
+ //#endregion
62
+ export { builder as default };
63
+
64
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","names":[],"sources":["../src/builder.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { generateGitTagName } from '#git'\nimport type { ReleasePlan, ReleasePlugin } from '#types'\nimport { formatError } from '#util'\nimport {\n buildReleaseNotes,\n bumpVersion,\n isSameReleaseCycle,\n resolvePackageStableTag,\n streamPackageCommits,\n} from '#workflow'\nimport { colors } from 'consola/utils'\nimport { version } from '../package.json'\n\n/**\n * Built-in plugin that prepares release metadata and artifacts for active plans.\n *\n * @remarks\n * **Lifecycle Stages:**\n * - `build`: Computes bumped package versions, derives standardized Git tag names,\n * and generates release notes/tag messages from unreleased commit history.\n *\n * @returns A release plugin configured for release metadata preparation.\n */\nconst builder = (): ReleasePlugin => ({\n name: '@reelout/core/builder',\n version,\n build: async (context, next) => {\n context.plans = await Promise.all(\n context.plans.map(async (plan): Promise<ReleasePlan> => {\n plan = { ...plan }\n\n if (!plan.release) return plan\n\n plan.release = { ...plan.release }\n\n let version: string | null | undefined\n\n try {\n version = bumpVersion({\n version: plan.package.version,\n private: plan.package.private,\n release: plan.release.type,\n identifier: context.versionQualifier,\n transition: plan.release.transition,\n })\n } catch (err) {\n context.logger.warn(\n colors.yellow(\n `Version could not be determined for package at \"${colors.bold(plan.package.location)}\": ${formatError(err)}`\n )\n )\n }\n\n if (version) {\n plan.release.version = version\n }\n\n let tagName: string | null | undefined\n\n try {\n tagName = generateGitTagName(\n plan.package.entry,\n plan.package.name,\n plan.release.version\n )\n } catch (err) {\n context.logger.warn(\n colors.yellow(\n `Tag could not be determined for package at \"${colors.bold(plan.package.location)}\": ${formatError(err)}`\n )\n )\n }\n\n let tagMessage: string | undefined\n\n try {\n if (tagName) {\n if (\n context.allowEmpty &&\n plan.history.length === 0 &&\n isSameReleaseCycle(plan.package.version, plan.release.version)\n ) {\n const previousTag = (\n await resolvePackageStableTag(context.cwd, plan.package)\n )?.name\n\n const history = streamPackageCommits(context.cwd, plan.package, {\n until: previousTag,\n })\n\n tagMessage = await buildReleaseNotes(context, history)\n } else {\n tagMessage = await buildReleaseNotes(context, plan.history)\n }\n }\n } catch {}\n\n if (tagName) {\n plan.release.tag = {\n name: tagName,\n message: tagMessage,\n }\n }\n\n return plan\n })\n )\n\n return next(context)\n },\n})\n\nexport default builder\n"],"mappings":";;;;;;;;;;;;;;AA0BA,IAAM,iBAAgC;CACpC,MAAM;CACN;CACA,OAAO,OAAO,SAAS,SAAS;EAC9B,QAAQ,QAAQ,MAAM,QAAQ,IAC5B,QAAQ,MAAM,IAAI,OAAO,SAA+B;GACtD,OAAO,EAAE,GAAG,KAAK;GAEjB,IAAI,CAAC,KAAK,SAAS,OAAO;GAE1B,KAAK,UAAU,EAAE,GAAG,KAAK,QAAQ;GAEjC,IAAI;GAEJ,IAAI;IACF,UAAU,YAAY;KACpB,SAAS,KAAK,QAAQ;KACtB,SAAS,KAAK,QAAQ;KACtB,SAAS,KAAK,QAAQ;KACtB,YAAY,QAAQ;KACpB,YAAY,KAAK,QAAQ;IAC3B,CAAC;GACH,SAAS,KAAK;IACZ,QAAQ,OAAO,KACb,OAAO,OACL,mDAAmD,OAAO,KAAK,KAAK,QAAQ,QAAQ,EAAE,KAAK,YAAY,GAAG,GAC5G,CACF;GACF;GAEA,IAAI,SACF,KAAK,QAAQ,UAAU;GAGzB,IAAI;GAEJ,IAAI;IACF,UAAU,mBACR,KAAK,QAAQ,OACb,KAAK,QAAQ,MACb,KAAK,QAAQ,OACf;GACF,SAAS,KAAK;IACZ,QAAQ,OAAO,KACb,OAAO,OACL,+CAA+C,OAAO,KAAK,KAAK,QAAQ,QAAQ,EAAE,KAAK,YAAY,GAAG,GACxG,CACF;GACF;GAEA,IAAI;GAEJ,IAAI;IACF,IAAI,SAAS;KACX,IACE,QAAQ,cACR,KAAK,QAAQ,WAAW,KACxB,mBAAmB,KAAK,QAAQ,SAAS,KAAK,QAAQ,OAAO,GAC7D;MACA,MAAM,eACJ,MAAM,wBAAwB,QAAQ,KAAK,KAAK,OAAO,EAAA,EACtD;MAEH,MAAM,UAAU,qBAAqB,QAAQ,KAAK,KAAK,SAAS,EAC9D,OAAO,YACT,CAAC;MAED,aAAa,MAAM,kBAAkB,SAAS,OAAO;KACvD,OACE,aAAa,MAAM,kBAAkB,SAAS,KAAK,OAAO;IAE9D;GACF,QAAQ,CAAC;GAET,IAAI,SACF,KAAK,QAAQ,MAAM;IACjB,MAAM;IACN,SAAS;GACX;GAGF,OAAO;EACT,CAAC,CACH;EAEA,OAAO,KAAK,OAAO;CACrB;AACF"}
@@ -0,0 +1,63 @@
1
+ import { _ as resolvePackageTag, a as HookPriority, c as writeChangelog, f as buildChangelog, s as version, y as discoverPackageTag } from "./workflow-BRMp4uB6.js";
2
+ import { t as formatError } from "./formatError-BXNdyRfu.js";
3
+ import { colors } from "consola/utils";
4
+ //#region src/changelog.ts
5
+ /**
6
+ * Built-in plugin that resolves package tags, generates release changelogs, and persists changelog files.
7
+ *
8
+ * @remarks
9
+ * **Lifecycle Stages:**
10
+ * - `discover`: Resolves missing Git tags for workspace packages (low priority execution).
11
+ * - `build`: Generates Markdown changelogs for planned releases based on historical commits.
12
+ * - `write`: Writes generated changelog files to disk (skipped during dry-run mode).
13
+ *
14
+ * @returns A release plugin configured for changelog generation and file persistence.
15
+ */
16
+ var changelog = () => ({
17
+ name: "@reelout/core/changelog",
18
+ version,
19
+ discover: {
20
+ priority: HookPriority.Low,
21
+ handler: async (context, next) => {
22
+ context.packages = await Promise.all(context.packages.map(async (pkg) => ({
23
+ ...pkg,
24
+ tag: await resolvePackageTag(context.cwd, pkg)
25
+ })));
26
+ await next(context);
27
+ }
28
+ },
29
+ build: async (context, next) => {
30
+ context.plans = await Promise.all(context.plans.map(async (plan) => {
31
+ plan = { ...plan };
32
+ if (!plan.release) return plan;
33
+ if (!plan.release.version) return plan;
34
+ plan.release = { ...plan.release };
35
+ let changelog;
36
+ let previousTag = (await resolvePackageTag(context.cwd, plan.package))?.name;
37
+ if (!previousTag) previousTag = (await discoverPackageTag(context.cwd, plan.package))?.name;
38
+ try {
39
+ changelog = await buildChangelog(context, plan.history, {
40
+ packageDir: plan.package.location,
41
+ changelogFile: plan.package.changelogFile,
42
+ version: plan.release.version,
43
+ previousTag,
44
+ currentTag: plan.release.tag?.name
45
+ });
46
+ } catch (err) {
47
+ context.logger.warn(colors.yellow(`Changelog could not be generated for package at "${colors.bold(plan.package.location)}": ${formatError(err)}`));
48
+ }
49
+ if (changelog) plan.release.changelog = changelog;
50
+ return plan;
51
+ }));
52
+ return next(context);
53
+ },
54
+ write: async (context, next) => {
55
+ if (context.dryRun) context.logger.debug("[DRY RUN] Changelog files will not be written.");
56
+ else for (const plan of context.plans) await writeChangelog(context.cwd, plan);
57
+ return next(context);
58
+ }
59
+ });
60
+ //#endregion
61
+ export { changelog as default };
62
+
63
+ //# sourceMappingURL=changelog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changelog.js","names":[],"sources":["../src/changelog.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { HookPriority } from '#plugin'\nimport type { Package, ReleasePlugin } from '#types'\nimport { formatError } from '#util'\nimport {\n buildChangelog,\n discoverPackageTag,\n resolvePackageTag,\n writeChangelog,\n} from '#workflow'\nimport { colors } from 'consola/utils'\nimport { version } from '../package.json'\n\n/**\n * Built-in plugin that resolves package tags, generates release changelogs, and persists changelog files.\n *\n * @remarks\n * **Lifecycle Stages:**\n * - `discover`: Resolves missing Git tags for workspace packages (low priority execution).\n * - `build`: Generates Markdown changelogs for planned releases based on historical commits.\n * - `write`: Writes generated changelog files to disk (skipped during dry-run mode).\n *\n * @returns A release plugin configured for changelog generation and file persistence.\n */\nconst changelog = (): ReleasePlugin => ({\n name: '@reelout/core/changelog',\n version,\n discover: {\n priority: HookPriority.Low,\n handler: async (context, next) => {\n context.packages = await Promise.all(\n context.packages.map(async (pkg): Promise<Package> => ({\n ...pkg,\n tag: await resolvePackageTag(context.cwd, pkg),\n }))\n )\n\n await next(context)\n },\n },\n build: async (context, next) => {\n context.plans = await Promise.all(\n context.plans.map(async (plan) => {\n plan = { ...plan }\n\n if (!plan.release) {\n return plan\n }\n\n if (!plan.release.version) {\n return plan\n }\n\n plan.release = { ...plan.release }\n\n let changelog: string | null | undefined\n\n let previousTag = (await resolvePackageTag(context.cwd, plan.package))\n ?.name\n\n if (!previousTag) {\n previousTag = (await discoverPackageTag(context.cwd, plan.package))\n ?.name\n }\n\n try {\n changelog = await buildChangelog(context, plan.history, {\n packageDir: plan.package.location,\n changelogFile: plan.package.changelogFile,\n version: plan.release.version,\n previousTag,\n currentTag: plan.release.tag?.name,\n })\n } catch (err) {\n context.logger.warn(\n colors.yellow(\n `Changelog could not be generated for package at \"${colors.bold(plan.package.location)}\": ${formatError(err)}`\n )\n )\n }\n\n if (changelog) {\n plan.release.changelog = changelog\n }\n\n return plan\n })\n )\n\n return next(context)\n },\n write: async (context, next) => {\n if (context.dryRun) {\n context.logger.debug('[DRY RUN] Changelog files will not be written.')\n } else {\n for (const plan of context.plans) {\n await writeChangelog(context.cwd, plan)\n }\n }\n\n return next(context)\n },\n})\n\nexport default changelog\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAM,mBAAkC;CACtC,MAAM;CACN;CACA,UAAU;EACR,UAAU,aAAa;EACvB,SAAS,OAAO,SAAS,SAAS;GAChC,QAAQ,WAAW,MAAM,QAAQ,IAC/B,QAAQ,SAAS,IAAI,OAAO,SAA2B;IACrD,GAAG;IACH,KAAK,MAAM,kBAAkB,QAAQ,KAAK,GAAG;GAC/C,EAAE,CACJ;GAEA,MAAM,KAAK,OAAO;EACpB;CACF;CACA,OAAO,OAAO,SAAS,SAAS;EAC9B,QAAQ,QAAQ,MAAM,QAAQ,IAC5B,QAAQ,MAAM,IAAI,OAAO,SAAS;GAChC,OAAO,EAAE,GAAG,KAAK;GAEjB,IAAI,CAAC,KAAK,SACR,OAAO;GAGT,IAAI,CAAC,KAAK,QAAQ,SAChB,OAAO;GAGT,KAAK,UAAU,EAAE,GAAG,KAAK,QAAQ;GAEjC,IAAI;GAEJ,IAAI,eAAe,MAAM,kBAAkB,QAAQ,KAAK,KAAK,OAAO,EAAA,EAChE;GAEJ,IAAI,CAAC,aACH,eAAe,MAAM,mBAAmB,QAAQ,KAAK,KAAK,OAAO,EAAA,EAC7D;GAGN,IAAI;IACF,YAAY,MAAM,eAAe,SAAS,KAAK,SAAS;KACtD,YAAY,KAAK,QAAQ;KACzB,eAAe,KAAK,QAAQ;KAC5B,SAAS,KAAK,QAAQ;KACtB;KACA,YAAY,KAAK,QAAQ,KAAK;IAChC,CAAC;GACH,SAAS,KAAK;IACZ,QAAQ,OAAO,KACb,OAAO,OACL,oDAAoD,OAAO,KAAK,KAAK,QAAQ,QAAQ,EAAE,KAAK,YAAY,GAAG,GAC7G,CACF;GACF;GAEA,IAAI,WACF,KAAK,QAAQ,YAAY;GAG3B,OAAO;EACT,CAAC,CACH;EAEA,OAAO,KAAK,OAAO;CACrB;CACA,OAAO,OAAO,SAAS,SAAS;EAC9B,IAAI,QAAQ,QACV,QAAQ,OAAO,MAAM,gDAAgD;OAErE,KAAK,MAAM,QAAQ,QAAQ,OACzB,MAAM,eAAe,QAAQ,KAAK,IAAI;EAI1C,OAAO,KAAK,OAAO;CACrB;AACF"}
@@ -0,0 +1,23 @@
1
+ //#region src/util/formatError.ts
2
+ /**
3
+ * Normalize an unknown thrown value for logging or display.
4
+ *
5
+ * - If `err` is an `Error`, returns its `message` string.
6
+ * - Otherwise returns the original `err` value unchanged (may be a string,
7
+ * object, number, `null`, or `undefined`).
8
+ *
9
+ * This function intentionally does not coerce non-Error values to strings so
10
+ * callers can decide how to render structured values.
11
+ *
12
+ * @param err The thrown value to normalize
13
+ * @returns The error message when `err` is an `Error`, otherwise the original value
14
+ */
15
+ function formatError(err) {
16
+ if (Error.isError(err)) return err.message;
17
+ if (typeof err === "string") return err;
18
+ return err;
19
+ }
20
+ //#endregion
21
+ export { formatError as t };
22
+
23
+ //# sourceMappingURL=formatError-BXNdyRfu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatError-BXNdyRfu.js","names":[],"sources":["../src/util/formatError.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Normalize an unknown thrown value for logging or display.\n *\n * - If `err` is an `Error`, returns its `message` string.\n * - Otherwise returns the original `err` value unchanged (may be a string,\n * object, number, `null`, or `undefined`).\n *\n * This function intentionally does not coerce non-Error values to strings so\n * callers can decide how to render structured values.\n *\n * @param err The thrown value to normalize\n * @returns The error message when `err` is an `Error`, otherwise the original value\n */\nexport function formatError<T>(err: T): T | string {\n if (Error.isError(err)) return err.message\n if (typeof err === 'string') return err\n return err\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,SAAgB,YAAe,KAAoB;CACjD,IAAI,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI;CACnC,IAAI,OAAO,QAAQ,UAAU,OAAO;CACpC,OAAO;AACT"}
package/dist/index.js CHANGED
@@ -1 +1,199 @@
1
- export {};
1
+ import { $ as countGitHistory, A as getCurrentGitTag, At as isDefined, B as ensureGitUserConfig, Bt as deriveReleaseType, C as extractSemVer, Ct as isMatch, D as isGitTagConnected, Dt as execGit, E as isGitTagPointed, Et as formatFile, F as createGitTag, Ft as GIT_TRAILER_RELEASE_AGENT, G as mergeGitHistory, H as showParsedGitHistory, Ht as determineReleaseType, I as readGitFile, It as RELEASE_HOOK_NAMES, J as expandGitHistory, K as GIT_REL_FLAGS, L as resolveGitRepository, Lt as SEMVER_REGEX, M as ensureGitTag, Mt as ALL_FILES, N as isGitTagPresent, Nt as DEFAULT_CHANGELOG_FILE, O as getLatestGitTag, Ot as execCommand, P as deleteGitTag, Pt as DEV_NULL, Q as isGitShallowRepository, R as pushGitChanges, Rt as isStableVersion, S as iterateChangelogVersions, St as readJson, T as buildDependencyGraph, Tt as interpolate, U as showGitHistory, Ut as bumpVersion, V as getGitConfigValue, Vt as pickPriorityReleaseType, W as restoreFullGitHistory, Wt as extractVersionQualifier, X as isGitAncestor, Y as resolveGitRevision, Z as withShallowLock, _ as resolvePackageTag, _t as isSemVerGitTag, a as HookPriority, at as parseGitCommit, b as verifyPackageTag, bt as createPlugin, c as writeChangelog, ct as createGitCommit, d as buildReleaseNotes, dt as deriveTransitionReleases, et as getCurrentGitCommit, f as buildChangelog, ft as deriveChangeReleases, g as propagateDependencyUpdates, gt as sanitizePrereleaseLabel, h as isReleaseCommit, ht as resolveReleaseChannel, i as HookManager, it as parseGitPrettyFormat, j as generateGitTagName, jt as buildTrailerPattern, k as getGitTagMessage, kt as compact, l as prependChangelog, lt as getCurrentGitBranch, m as sliceUnreleased, mt as resolveVersionQualifier, n as printReleaseReport, nt as GIT_PRETTY_FIELD_SEPARATOR, o as generateReleaseCommitMessage, ot as TTLCache, p as streamPackageCommits, pt as isCommitForPackage, q as detectGitRelationship, r as generateReleaseReport, rt as GIT_PRETTY_FORMAT, st as extractMentions, t as executeReleaseWorkflow, tt as getParsedGitCommit, u as extractPreviousVersion, ut as promotePrereleaseVersions, v as resolvePackageStableTag, vt as isSemVer, w as extractPlainText, wt as isClass, x as extractLatestVersion, xt as writeJson, y as discoverPackageTag, yt as findReleaseRule, z as getGitRemote, zt as isSameReleaseCycle } from "./workflow-BRMp4uB6.js";
2
+ import { t as formatError } from "./formatError-BXNdyRfu.js";
3
+ import { createRequire } from "node:module";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ //#region src/util/isTruthyString.ts
7
+ /**
8
+ * Determine whether a string value represents a truthy boolean.
9
+ *
10
+ * Trims leading and trailing whitespace and coerces the target string to
11
+ * lowercase. Evaluates the string as truthy if it equals `'true'` or `'1'`.
12
+ *
13
+ * @param value The raw string to evaluate
14
+ * @returns `true` if `value` normalizes to `'true'` or `'1'`, otherwise `false`
15
+ */
16
+ function isTruthyString(value) {
17
+ if (!value) return false;
18
+ const normalized = value.toLowerCase().trim();
19
+ return normalized === "true" || normalized === "1";
20
+ }
21
+ //#endregion
22
+ //#region src/util/isCI.ts
23
+ /**
24
+ * Determine whether the current process is running in a CI environment.
25
+ *
26
+ * Checks if the `CI` environment variable is set to a truthy value. Ignores
27
+ * provider-specific variables such as `GITHUB_ACTIONS` to keep detection
28
+ * generic.
29
+ *
30
+ * @param env Readonly process environment variables object
31
+ * @returns `true` if `env.CI` normalizes to a truthy string, otherwise `false`
32
+ */
33
+ function isCI(env) {
34
+ return isTruthyString(env.CI);
35
+ }
36
+ //#endregion
37
+ //#region src/util/unique.ts
38
+ /**
39
+ * Return a new array containing only the first-seen occurrence of each item.
40
+ *
41
+ * This preserves the original iteration order and performs equality checks
42
+ * using JavaScript's `Set` semantics (i.e., primitives by value, objects by
43
+ * reference). The input array is not mutated.
44
+ *
45
+ * @param array The array of items to deduplicate
46
+ * @returns A new array with duplicates removed, preserving first-seen order
47
+ */
48
+ function unique(array) {
49
+ const seen = /* @__PURE__ */ new Set();
50
+ const result = [];
51
+ for (const item of array) if (!seen.has(item)) {
52
+ seen.add(item);
53
+ result.push(item);
54
+ }
55
+ return result;
56
+ }
57
+ //#endregion
58
+ //#region src/config/normalizeCommitFilter.ts
59
+ /**
60
+ * Normalize a commit classifier into a consistent function.
61
+ *
62
+ * Accepts `null`/`undefined` (returns no-op classifier), a function classifier,
63
+ * or a config object mapping commit types to release types. Returns a classifier
64
+ * function that maps commits to their corresponding release types.
65
+ *
66
+ * @param classifier Commit classifier config, function, or falsy value
67
+ * @returns Normalized classifier function
68
+ */
69
+ function normalizeCommitFilter(classifier) {
70
+ if (classifier == null) return () => null;
71
+ if (typeof classifier === "function") return classifier;
72
+ const map = new Map(Object.entries(classifier).flatMap(([releaseType, commitTypes]) => {
73
+ return commitTypes.map((commitType) => [commitType, releaseType]);
74
+ }));
75
+ return (commit) => commit.type ? map.get(commit.type) : null;
76
+ }
77
+ //#endregion
78
+ //#region src/config/normalizeReleaseRule.ts
79
+ /**
80
+ * Normalize a release rule input into a resolved release rule object.
81
+ *
82
+ * Converts `string` shorthand inputs into structured rule objects with sanitized
83
+ * labels. Resolves `versionQualifier` and `releaseChannel` against `pattern`.
84
+ * Returns `null` if `rule` is invalid, falsy, or missing `pattern`.
85
+ *
86
+ * @param rule Raw release rule input, `string` shorthand, or falsy value
87
+ * @returns Resolved `ResolvedReleaseRule` object, or `null` if `rule` is invalid
88
+ */
89
+ function normalizeReleaseRule(rule) {
90
+ if (typeof rule === "string") rule = {
91
+ pattern: rule,
92
+ qualifier: sanitizePrereleaseLabel(rule),
93
+ channel: sanitizePrereleaseLabel(rule)
94
+ };
95
+ if (typeof rule !== "object" || rule == null) return null;
96
+ const { pattern } = rule;
97
+ if (pattern == null) return null;
98
+ return {
99
+ type: rule.type,
100
+ pattern,
101
+ versionQualifier: resolveRuleValue(rule.qualifier, pattern),
102
+ releaseChannel: resolveRuleValue(rule.channel, pattern)
103
+ };
104
+ }
105
+ /**
106
+ * Resolve a rule property value from an explicit `string` or pattern fallback.
107
+ *
108
+ * @param value Explicit `string` value, `boolean` flag, or `undefined`
109
+ * @param pattern Fallback pattern string used when `value` is `true`
110
+ * @returns Resolved `string` value or `undefined`
111
+ */
112
+ function resolveRuleValue(value, pattern) {
113
+ if (typeof value === "string") return value;
114
+ if (value) return sanitizePrereleaseLabel(pattern);
115
+ }
116
+ //#endregion
117
+ //#region src/config/normalizeWorkspace.ts
118
+ /**
119
+ * Normalize and validate workspace configuration for a repository.
120
+ *
121
+ * Resolves the workspace entry directory relative to `cwd` and normalizes
122
+ * the path representation. Returns a workspace object with normalized `entry`
123
+ * and optional workspace members.
124
+ *
125
+ * @param cwd Repository working directory
126
+ * @param workspace Partial workspace configuration (optional)
127
+ * @returns Normalized workspace object
128
+ */
129
+ function normalizeWorkspace(cwd, workspace) {
130
+ let entry = workspace?.entry || ".";
131
+ const members = workspace?.members ?? null;
132
+ entry = path.normalize(path.relative(cwd, path.resolve(cwd, entry)));
133
+ return {
134
+ entry,
135
+ members
136
+ };
137
+ }
138
+ //#endregion
139
+ //#region src/config/resolvePlugin.ts
140
+ /**
141
+ * Resolve a release plugin definition into a factory tuple or plugin object.
142
+ *
143
+ * Handles string module specifiers by dynamically importing the package relative
144
+ * to `cwd`. Unwraps ES module default exports, array configurations containing
145
+ * options, function factories, and direct plugin objects.
146
+ *
147
+ * @param cwd The working directory path used to resolve string specifiers
148
+ * @param plugin The plugin name, path, tuple configuration, or plugin object
149
+ * @returns A factory tuple, plugin object, or null if resolution fails
150
+ */
151
+ async function resolvePlugin(cwd, plugin) {
152
+ let options;
153
+ if (Array.isArray(plugin)) [plugin, options] = plugin;
154
+ if (typeof plugin === "string") plugin = await import(createRequire(pathToFileURL(cwd)).resolve(plugin));
155
+ if (plugin != null && typeof plugin === "object" && "default" in plugin) plugin = plugin.default;
156
+ if (typeof plugin === "function") return [plugin, options];
157
+ if (plugin != null && typeof plugin === "object" && Object.hasOwn(plugin, "name") && typeof plugin.name === "string") return plugin;
158
+ return null;
159
+ }
160
+ //#endregion
161
+ //#region src/workflow/discovery/sortPackages.ts
162
+ /**
163
+ * Sort workspace packages topologically based on their dependency graphs.
164
+ *
165
+ * Deepest dependents are placed first in the resulting array, ensuring that
166
+ * a package always precedes its own dependencies. Ties and circular dependencies
167
+ * are resolved deterministically using an alphabetical sort on the package directory (`dir`).
168
+ *
169
+ * @param packages The workspace packages to sort.
170
+ * @returns A new array of packages sorted by dependency depth and directory path.
171
+ */
172
+ function sortPackages(packages) {
173
+ const packageNodes = [];
174
+ const packageMap = /* @__PURE__ */ new Map();
175
+ for (const pkg of packages.toSorted((a, b) => a.location.localeCompare(b.location))) {
176
+ const node = {
177
+ package: pkg,
178
+ level: -1
179
+ };
180
+ packageNodes.push(node);
181
+ if (pkg.name) packageMap.set(pkg.name, node);
182
+ }
183
+ for (const node of packageNodes) visit(node);
184
+ function visit(node, level = 0, visited = /* @__PURE__ */ new Set()) {
185
+ if (node.level >= level) return;
186
+ if (visited.has(node)) return;
187
+ visited.add(node);
188
+ for (const depName of node.package.dependencies) {
189
+ const depNode = packageMap.get(depName);
190
+ if (depNode && depNode !== node) visit(depNode, level + 1, visited);
191
+ }
192
+ node.level = level;
193
+ }
194
+ return packageNodes.toSorted((a, b) => b.level - a.level).map((node) => node.package);
195
+ }
196
+ //#endregion
197
+ export { ALL_FILES, DEFAULT_CHANGELOG_FILE, DEV_NULL, GIT_PRETTY_FIELD_SEPARATOR, GIT_PRETTY_FORMAT, GIT_REL_FLAGS, GIT_TRAILER_RELEASE_AGENT, HookManager, HookPriority, RELEASE_HOOK_NAMES, SEMVER_REGEX, TTLCache, buildChangelog, buildDependencyGraph, buildReleaseNotes, buildTrailerPattern, bumpVersion, compact, countGitHistory, createGitCommit, createGitTag, createPlugin, deleteGitTag, deriveChangeReleases, deriveReleaseType, deriveTransitionReleases, detectGitRelationship, determineReleaseType, discoverPackageTag, ensureGitTag, ensureGitUserConfig, execCommand, execGit, executeReleaseWorkflow, expandGitHistory, extractLatestVersion, extractMentions, extractPlainText, extractPreviousVersion, extractSemVer, extractVersionQualifier, findReleaseRule, formatError, formatFile, generateGitTagName, generateReleaseCommitMessage, generateReleaseReport, getCurrentGitBranch, getCurrentGitCommit, getCurrentGitTag, getGitConfigValue, getGitRemote, getGitTagMessage, getLatestGitTag, getParsedGitCommit, interpolate, isCI, isClass, isCommitForPackage, isDefined, isGitAncestor, isGitShallowRepository, isGitTagConnected, isGitTagPointed, isGitTagPresent, isMatch, isReleaseCommit, isSameReleaseCycle, isSemVer, isSemVerGitTag, isStableVersion, isTruthyString, iterateChangelogVersions, mergeGitHistory, normalizeCommitFilter, normalizeReleaseRule, normalizeWorkspace, parseGitCommit, parseGitPrettyFormat, pickPriorityReleaseType, prependChangelog, printReleaseReport, promotePrereleaseVersions, propagateDependencyUpdates, pushGitChanges, readGitFile, readJson, resolveGitRepository, resolveGitRevision, resolvePackageStableTag, resolvePackageTag, resolvePlugin, resolveReleaseChannel, resolveVersionQualifier, restoreFullGitHistory, sanitizePrereleaseLabel, showGitHistory, showParsedGitHistory, sliceUnreleased, sortPackages, streamPackageCommits, unique, verifyPackageTag, withShallowLock, writeChangelog, writeJson };
198
+
199
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/util/isTruthyString.ts","../src/util/isCI.ts","../src/util/unique.ts","../src/config/normalizeCommitFilter.ts","../src/config/normalizeReleaseRule.ts","../src/config/normalizeWorkspace.ts","../src/config/resolvePlugin.ts","../src/workflow/discovery/sortPackages.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Determine whether a string value represents a truthy boolean.\n *\n * Trims leading and trailing whitespace and coerces the target string to\n * lowercase. Evaluates the string as truthy if it equals `'true'` or `'1'`.\n *\n * @param value The raw string to evaluate\n * @returns `true` if `value` normalizes to `'true'` or `'1'`, otherwise `false`\n */\nexport function isTruthyString(value: string | undefined): boolean {\n if (!value) return false\n\n const normalized = value.toLowerCase().trim()\n\n return normalized === 'true' || normalized === '1'\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { isTruthyString } from './isTruthyString'\n\n/**\n * Determine whether the current process is running in a CI environment.\n *\n * Checks if the `CI` environment variable is set to a truthy value. Ignores\n * provider-specific variables such as `GITHUB_ACTIONS` to keep detection\n * generic.\n *\n * @param env Readonly process environment variables object\n * @returns `true` if `env.CI` normalizes to a truthy string, otherwise `false`\n */\nexport function isCI(env: Readonly<NodeJS.ProcessEnv>): boolean {\n return isTruthyString(env.CI)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Return a new array containing only the first-seen occurrence of each item.\n *\n * This preserves the original iteration order and performs equality checks\n * using JavaScript's `Set` semantics (i.e., primitives by value, objects by\n * reference). The input array is not mutated.\n *\n * @param array The array of items to deduplicate\n * @returns A new array with duplicates removed, preserving first-seen order\n */\nexport function unique<T>(array: readonly T[]): T[] {\n const seen = new Set<T>()\n const result: T[] = []\n\n for (const item of array) {\n if (!seen.has(item)) {\n seen.add(item)\n result.push(item)\n }\n }\n\n return result\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { CommitClassifier, ReleaseConfig, ReleaseType } from '#types'\n\n/**\n * Normalize a commit classifier into a consistent function.\n *\n * Accepts `null`/`undefined` (returns no-op classifier), a function classifier,\n * or a config object mapping commit types to release types. Returns a classifier\n * function that maps commits to their corresponding release types.\n *\n * @param classifier Commit classifier config, function, or falsy value\n * @returns Normalized classifier function\n */\nexport function normalizeCommitFilter(\n classifier: ReleaseConfig['classifier'] | null | undefined\n): CommitClassifier {\n if (classifier == null) {\n return () => null\n }\n\n if (typeof classifier === 'function') {\n return classifier\n }\n\n const map = new Map(\n Object.entries(classifier).flatMap(([releaseType, commitTypes]) => {\n return commitTypes.map((commitType) => [\n commitType,\n releaseType as ReleaseType,\n ])\n })\n )\n\n return (commit) => (commit.type ? map.get(commit.type) : null)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseRule, ResolvedReleaseRule } from '#types'\nimport { sanitizePrereleaseLabel } from './sanitizePrereleaseLabel'\n\n/**\n * Normalize a release rule input into a resolved release rule object.\n *\n * Converts `string` shorthand inputs into structured rule objects with sanitized\n * labels. Resolves `versionQualifier` and `releaseChannel` against `pattern`.\n * Returns `null` if `rule` is invalid, falsy, or missing `pattern`.\n *\n * @param rule Raw release rule input, `string` shorthand, or falsy value\n * @returns Resolved `ResolvedReleaseRule` object, or `null` if `rule` is invalid\n */\nexport function normalizeReleaseRule(\n rule: ReleaseRule | string | false | null | undefined\n): ResolvedReleaseRule | null {\n if (typeof rule === 'string') {\n rule = {\n pattern: rule,\n qualifier: sanitizePrereleaseLabel(rule),\n channel: sanitizePrereleaseLabel(rule),\n }\n }\n\n if (typeof rule !== 'object' || rule == null) {\n return null\n }\n\n const { pattern } = rule\n\n if (pattern == null) {\n return null\n }\n\n return {\n type: rule.type,\n pattern,\n versionQualifier: resolveRuleValue(rule.qualifier, pattern),\n releaseChannel: resolveRuleValue(rule.channel, pattern),\n }\n}\n\n/**\n * Resolve a rule property value from an explicit `string` or pattern fallback.\n *\n * @param value Explicit `string` value, `boolean` flag, or `undefined`\n * @param pattern Fallback pattern string used when `value` is `true`\n * @returns Resolved `string` value or `undefined`\n */\nfunction resolveRuleValue(\n value: string | boolean | undefined,\n pattern: string\n): string | undefined {\n if (typeof value === 'string') {\n return value\n }\n\n if (value) {\n return sanitizePrereleaseLabel(pattern)\n }\n\n return undefined\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Workspace } from '#types'\nimport path from 'node:path'\n\n/**\n * Normalize and validate workspace configuration for a repository.\n *\n * Resolves the workspace entry directory relative to `cwd` and normalizes\n * the path representation. Returns a workspace object with normalized `entry`\n * and optional workspace members.\n *\n * @param cwd Repository working directory\n * @param workspace Partial workspace configuration (optional)\n * @returns Normalized workspace object\n */\nexport function normalizeWorkspace(\n cwd: string,\n workspace?: {\n entry?: string | null | undefined\n members?: readonly string[] | null | undefined\n }\n): Workspace {\n let entry = workspace?.entry || '.'\n const members = workspace?.members ?? null\n\n entry = path.normalize(path.relative(cwd, path.resolve(cwd, entry)))\n\n return {\n entry,\n members,\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n ReleasePlugin,\n ReleasePluginDefinition,\n ReleasePluginFactory,\n ReleasePluginTuple,\n} from '#types'\nimport { createRequire } from 'node:module'\nimport { pathToFileURL } from 'node:url'\n\n/**\n * Resolve a release plugin definition into a factory tuple or plugin object.\n *\n * Handles string module specifiers by dynamically importing the package relative\n * to `cwd`. Unwraps ES module default exports, array configurations containing\n * options, function factories, and direct plugin objects.\n *\n * @param cwd The working directory path used to resolve string specifiers\n * @param plugin The plugin name, path, tuple configuration, or plugin object\n * @returns A factory tuple, plugin object, or null if resolution fails\n */\nexport async function resolvePlugin(\n cwd: string,\n plugin: unknown\n): Promise<ReleasePluginDefinition | ReleasePluginTuple | null> {\n let options: unknown\n\n if (Array.isArray(plugin)) {\n ;[plugin, options] = plugin\n }\n\n if (typeof plugin === 'string') {\n const require = createRequire(pathToFileURL(cwd))\n plugin = await import(require.resolve(plugin))\n }\n\n if (plugin != null && typeof plugin === 'object' && 'default' in plugin) {\n plugin = plugin.default\n }\n\n if (typeof plugin === 'function') {\n return [plugin as ReleasePluginFactory, options]\n }\n\n if (\n plugin != null &&\n typeof plugin === 'object' &&\n Object.hasOwn(plugin, 'name') &&\n typeof (plugin as ReleasePlugin).name === 'string'\n ) {\n return plugin as ReleasePlugin\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Package } from '#types'\n\ninterface PackageNode {\n package: Package\n level: number\n}\n\n/**\n * Sort workspace packages topologically based on their dependency graphs.\n *\n * Deepest dependents are placed first in the resulting array, ensuring that\n * a package always precedes its own dependencies. Ties and circular dependencies\n * are resolved deterministically using an alphabetical sort on the package directory (`dir`).\n *\n * @param packages The workspace packages to sort.\n * @returns A new array of packages sorted by dependency depth and directory path.\n */\nexport function sortPackages(packages: readonly Package[]): Package[] {\n const packageNodes: PackageNode[] = []\n const packageMap = new Map<string, PackageNode>()\n\n for (const pkg of packages.toSorted((a, b) =>\n a.location.localeCompare(b.location)\n )) {\n const node: PackageNode = {\n package: pkg,\n level: -1,\n }\n\n packageNodes.push(node)\n\n if (pkg.name) {\n packageMap.set(pkg.name, node)\n }\n }\n\n for (const node of packageNodes) {\n visit(node)\n }\n\n function visit(\n node: PackageNode,\n level = 0,\n visited = new Set<PackageNode>()\n ): void {\n if (node.level >= level) {\n return\n }\n\n if (visited.has(node)) {\n return\n }\n\n visited.add(node)\n\n for (const depName of node.package.dependencies) {\n const depNode = packageMap.get(depName)\n\n if (depNode && depNode !== node) {\n visit(depNode, level + 1, visited)\n }\n }\n\n node.level = level\n }\n\n const sorted = packageNodes\n .toSorted((a, b) => b.level - a.level)\n .map((node) => node.package)\n\n return sorted\n}\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAgB,eAAe,OAAoC;CACjE,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,aAAa,MAAM,YAAY,CAAC,CAAC,KAAK;CAE5C,OAAO,eAAe,UAAU,eAAe;AACjD;;;;;;;;;;;;;ACHA,SAAgB,KAAK,KAA2C;CAC9D,OAAO,eAAe,IAAI,EAAE;AAC9B;;;;;;;;;;;;;ACJA,SAAgB,OAAU,OAA0B;CAClD,MAAM,uBAAO,IAAI,IAAO;CACxB,MAAM,SAAc,CAAC;CAErB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG;EACnB,KAAK,IAAI,IAAI;EACb,OAAO,KAAK,IAAI;CAClB;CAGF,OAAO;AACT;;;;;;;;;;;;;ACVA,SAAgB,sBACd,YACkB;CAClB,IAAI,cAAc,MAChB,aAAa;CAGf,IAAI,OAAO,eAAe,YACxB,OAAO;CAGT,MAAM,MAAM,IAAI,IACd,OAAO,QAAQ,UAAU,CAAC,CAAC,SAAS,CAAC,aAAa,iBAAiB;EACjE,OAAO,YAAY,KAAK,eAAe,CACrC,YACA,WACF,CAAC;CACH,CAAC,CACH;CAEA,QAAQ,WAAY,OAAO,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI;AAC3D;;;;;;;;;;;;;ACpBA,SAAgB,qBACd,MAC4B;CAC5B,IAAI,OAAO,SAAS,UAClB,OAAO;EACL,SAAS;EACT,WAAW,wBAAwB,IAAI;EACvC,SAAS,wBAAwB,IAAI;CACvC;CAGF,IAAI,OAAO,SAAS,YAAY,QAAQ,MACtC,OAAO;CAGT,MAAM,EAAE,YAAY;CAEpB,IAAI,WAAW,MACb,OAAO;CAGT,OAAO;EACL,MAAM,KAAK;EACX;EACA,kBAAkB,iBAAiB,KAAK,WAAW,OAAO;EAC1D,gBAAgB,iBAAiB,KAAK,SAAS,OAAO;CACxD;AACF;;;;;;;;AASA,SAAS,iBACP,OACA,SACoB;CACpB,IAAI,OAAO,UAAU,UACnB,OAAO;CAGT,IAAI,OACF,OAAO,wBAAwB,OAAO;AAI1C;;;;;;;;;;;;;;AChDA,SAAgB,mBACd,KACA,WAIW;CACX,IAAI,QAAQ,WAAW,SAAS;CAChC,MAAM,UAAU,WAAW,WAAW;CAEtC,QAAQ,KAAK,UAAU,KAAK,SAAS,KAAK,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC;CAEnE,OAAO;EACL;EACA;CACF;AACF;;;;;;;;;;;;;;ACVA,eAAsB,cACpB,KACA,QAC8D;CAC9D,IAAI;CAEJ,IAAI,MAAM,QAAQ,MAAM,GACrB,CAAC,QAAQ,WAAW;CAGvB,IAAI,OAAO,WAAW,UAEpB,SAAS,MAAM,OADC,cAAc,cAAc,GAAG,CACzB,CAAA,CAAQ,QAAQ,MAAM;CAG9C,IAAI,UAAU,QAAQ,OAAO,WAAW,YAAY,aAAa,QAC/D,SAAS,OAAO;CAGlB,IAAI,OAAO,WAAW,YACpB,OAAO,CAAC,QAAgC,OAAO;CAGjD,IACE,UAAU,QACV,OAAO,WAAW,YAClB,OAAO,OAAO,QAAQ,MAAM,KAC5B,OAAQ,OAAyB,SAAS,UAE1C,OAAO;CAGT,OAAO;AACT;;;;;;;;;;;;;ACpCA,SAAgB,aAAa,UAAyC;CACpE,MAAM,eAA8B,CAAC;CACrC,MAAM,6BAAa,IAAI,IAAyB;CAEhD,KAAK,MAAM,OAAO,SAAS,UAAU,GAAG,MACtC,EAAE,SAAS,cAAc,EAAE,QAAQ,CACrC,GAAG;EACD,MAAM,OAAoB;GACxB,SAAS;GACT,OAAO;EACT;EAEA,aAAa,KAAK,IAAI;EAEtB,IAAI,IAAI,MACN,WAAW,IAAI,IAAI,MAAM,IAAI;CAEjC;CAEA,KAAK,MAAM,QAAQ,cACjB,MAAM,IAAI;CAGZ,SAAS,MACP,MACA,QAAQ,GACR,0BAAU,IAAI,IAAiB,GACzB;EACN,IAAI,KAAK,SAAS,OAChB;EAGF,IAAI,QAAQ,IAAI,IAAI,GAClB;EAGF,QAAQ,IAAI,IAAI;EAEhB,KAAK,MAAM,WAAW,KAAK,QAAQ,cAAc;GAC/C,MAAM,UAAU,WAAW,IAAI,OAAO;GAEtC,IAAI,WAAW,YAAY,MACzB,MAAM,SAAS,QAAQ,GAAG,OAAO;EAErC;EAEA,KAAK,QAAQ;CACf;CAMA,OAJe,aACZ,UAAU,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CACrC,KAAK,SAAS,KAAK,OAEf;AACT"}
@@ -0,0 +1 @@
1
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ import "./types-la_KkjCS.js";
2
+ export {};