@reelout/core 0.1.1 → 0.2.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 (125) hide show
  1. package/dist/analyzer.js +38 -0
  2. package/dist/analyzer.js.map +1 -0
  3. package/dist/builder.js +52 -0
  4. package/dist/builder.js.map +1 -0
  5. package/dist/changelog.js +58 -0
  6. package/dist/changelog.js.map +1 -0
  7. package/dist/formatError-BXNdyRfu.js +23 -0
  8. package/dist/formatError-BXNdyRfu.js.map +1 -0
  9. package/dist/index.js +175 -1
  10. package/dist/index.js.map +1 -0
  11. package/dist/types-la_KkjCS.js +1 -0
  12. package/dist/types.js +2 -0
  13. package/dist/workflow-BoVmbvH6.js +2342 -0
  14. package/dist/workflow-BoVmbvH6.js.map +1 -0
  15. package/package.json +27 -3
  16. package/src/analyzer.ts +63 -0
  17. package/src/builder.ts +104 -0
  18. package/src/cache/TTLCache.ts +100 -0
  19. package/src/cache/index.ts +4 -0
  20. package/src/changelog.ts +97 -0
  21. package/src/config/const.ts +97 -0
  22. package/src/config/index.ts +11 -0
  23. package/src/config/isSemVerGitTag.ts +25 -0
  24. package/src/config/normalizeCommitFilter.ts +37 -0
  25. package/src/config/normalizeReleaseRule.ts +42 -0
  26. package/src/config/normalizeWorkspace.ts +34 -0
  27. package/src/config/resolvePlugin.ts +56 -0
  28. package/src/config/resolveReleaseTarget.ts +71 -0
  29. package/src/config/sanitizePrereleaseLabel.ts +18 -0
  30. package/src/git/branch/getCurrentGitBranch.ts +18 -0
  31. package/src/git/branch/index.ts +4 -0
  32. package/src/git/commit/createGitCommit.ts +29 -0
  33. package/src/git/commit/extractMentions.ts +34 -0
  34. package/src/git/commit/getCurrentGitCommit.ts +14 -0
  35. package/src/git/commit/getParsedCommit.ts +53 -0
  36. package/src/git/commit/index.ts +9 -0
  37. package/src/git/commit/parseCommit.ts +99 -0
  38. package/src/git/commit/parseGitPrettyFormat.ts +76 -0
  39. package/src/git/history/countGitHistory.ts +28 -0
  40. package/src/git/history/expandGitHistory.ts +108 -0
  41. package/src/git/history/index.ts +9 -0
  42. package/src/git/history/mergeGitHistory.ts +76 -0
  43. package/src/git/history/restoreFullGitHistory.ts +19 -0
  44. package/src/git/history/showGitHistory.ts +80 -0
  45. package/src/git/history/showParsedGitHistory.ts +30 -0
  46. package/src/git/index.ts +9 -0
  47. package/src/git/repository/ensureGitUserConfig.ts +31 -0
  48. package/src/git/repository/getGitConfigValue.ts +27 -0
  49. package/src/git/repository/getGitRemote.ts +20 -0
  50. package/src/git/repository/index.ts +10 -0
  51. package/src/git/repository/isGitShallowRepository.ts +21 -0
  52. package/src/git/repository/pushGitChanges.ts +25 -0
  53. package/src/git/repository/resolveGitRepository.ts +40 -0
  54. package/src/git/repository/withShallowLock.ts +62 -0
  55. package/src/git/revision/detectGitRelationship.ts +43 -0
  56. package/src/git/revision/index.ts +7 -0
  57. package/src/git/revision/isGitAncestor.ts +33 -0
  58. package/src/git/revision/readGitFile.ts +29 -0
  59. package/src/git/revision/resolveGitRevision.ts +23 -0
  60. package/src/git/tag/createGitTag.ts +25 -0
  61. package/src/git/tag/deleteGitTag.ts +17 -0
  62. package/src/git/tag/ensureGitTag.ts +63 -0
  63. package/src/git/tag/generateGitTagName.ts +43 -0
  64. package/src/git/tag/getCurrentGitTag.ts +23 -0
  65. package/src/git/tag/getGitTagMessage.ts +35 -0
  66. package/src/git/tag/getLatestGitTag.ts +22 -0
  67. package/src/git/tag/index.ts +13 -0
  68. package/src/git/tag/isGitTagConnected.ts +33 -0
  69. package/src/git/tag/isGitTagPointed.ts +38 -0
  70. package/src/git/tag/isGitTagPresent.ts +17 -0
  71. package/src/index.ts +8 -2
  72. package/src/types.ts +217 -0
  73. package/src/util/buildTrailerPattern.ts +20 -0
  74. package/src/util/compact.ts +14 -0
  75. package/src/util/execCommand.ts +130 -0
  76. package/src/util/execGit.ts +18 -0
  77. package/src/util/formatError.ts +21 -0
  78. package/src/util/formatFile.ts +41 -0
  79. package/src/util/index.ts +16 -0
  80. package/src/util/interpolate.ts +141 -0
  81. package/src/util/isCI.ts +23 -0
  82. package/src/util/isDefined.ts +12 -0
  83. package/src/util/isMatch.ts +43 -0
  84. package/src/util/readJson.ts +47 -0
  85. package/src/util/unique.ts +26 -0
  86. package/src/util/writeJson.ts +28 -0
  87. package/src/workflow/analysis/analyzePackageChanges.ts +54 -0
  88. package/src/workflow/analysis/index.ts +9 -0
  89. package/src/workflow/analysis/isCommitForPackage.ts +23 -0
  90. package/src/workflow/analysis/promotePrereleaseVersions.ts +50 -0
  91. package/src/workflow/analysis/propagateDependencyUpdates.ts +71 -0
  92. package/src/workflow/analysis/sliceUnreleased.ts +36 -0
  93. package/src/workflow/analysis/streamPackageCommits.ts +34 -0
  94. package/src/workflow/changelog/buildChangelog.ts +79 -0
  95. package/src/workflow/changelog/buildReleaseNotes.ts +50 -0
  96. package/src/workflow/changelog/extractLatestVersion.ts +22 -0
  97. package/src/workflow/changelog/extractPlainText.ts +38 -0
  98. package/src/workflow/changelog/extractPreviousVersion.ts +77 -0
  99. package/src/workflow/changelog/extractSemVer.ts +33 -0
  100. package/src/workflow/changelog/index.ts +12 -0
  101. package/src/workflow/changelog/iterateChangelogVersions.ts +70 -0
  102. package/src/workflow/changelog/prependChangelog.ts +59 -0
  103. package/src/workflow/changelog/writeChangelog.ts +27 -0
  104. package/src/workflow/committing/generateReleaseCommitMessage.ts +96 -0
  105. package/src/workflow/committing/index.ts +5 -0
  106. package/src/workflow/committing/isReleaseCommit.ts +52 -0
  107. package/src/workflow/discovery/buildDependencyGraph.ts +43 -0
  108. package/src/workflow/discovery/discoverPackageTag.ts +98 -0
  109. package/src/workflow/discovery/index.ts +9 -0
  110. package/src/workflow/discovery/resolvePackageStableTag.ts +88 -0
  111. package/src/workflow/discovery/resolvePackageTag.ts +45 -0
  112. package/src/workflow/discovery/sortPackages.ts +73 -0
  113. package/src/workflow/discovery/verifyPackageTag.ts +43 -0
  114. package/src/workflow/index.ts +10 -0
  115. package/src/workflow/report/generateReleaseReport.ts +76 -0
  116. package/src/workflow/report/index.ts +5 -0
  117. package/src/workflow/report/printReleaseReport.ts +97 -0
  118. package/src/workflow/runner/index.ts +4 -0
  119. package/src/workflow/runner/runWorkflow.ts +120 -0
  120. package/src/workflow/versioning/bumpVersion.ts +67 -0
  121. package/src/workflow/versioning/deriveReleaseType.ts +33 -0
  122. package/src/workflow/versioning/determineReleaseType.ts +35 -0
  123. package/src/workflow/versioning/index.ts +8 -0
  124. package/src/workflow/versioning/isStableVersion.ts +31 -0
  125. package/src/workflow/versioning/pickPriorityReleaseType.ts +27 -0
@@ -0,0 +1,38 @@
1
+ import { a as version, ct as promotePrereleaseVersions, f as sliceUnreleased, h as resolvePackageTag, lt as analyzePackageChanges, m as propagateDependencyUpdates } from "./workflow-BoVmbvH6.js";
2
+ //#region src/analyzer.ts
3
+ /**
4
+ * Built-in plugin that inspects repository history and produces release plans for packages.
5
+ *
6
+ * Stages:
7
+ * - discover (enforce: post): when promoting, resolve package tags from the repository.
8
+ * - analyze: initialize plans if empty, collect unreleased history, compute package changes,
9
+ * promote prerelease versions when promoting, and propagate dependency updates.
10
+ */
11
+ var analyzer = () => ({
12
+ name: "@reelout/core/analyzer",
13
+ version,
14
+ discover: {
15
+ enforce: "post",
16
+ handler: async (context) => {
17
+ if (context.promote) context.packages = await Promise.all(context.packages.map(async (pkg) => ({
18
+ ...pkg,
19
+ tag: await resolvePackageTag(context.cwd, pkg)
20
+ })));
21
+ }
22
+ },
23
+ analyze: async (context) => {
24
+ if (context.plans.length === 0) context.plans = context.packages.map((pkg) => ({
25
+ package: pkg,
26
+ history: [],
27
+ release: null
28
+ }));
29
+ const history = await sliceUnreleased(context.cwd);
30
+ context.plans = await analyzePackageChanges(context.classifier, context.plans, history);
31
+ if (context.promote) context.plans = await promotePrereleaseVersions(context.plans);
32
+ context.plans = await propagateDependencyUpdates(context.cwd, context.plans);
33
+ }
34
+ });
35
+ //#endregion
36
+ export { analyzer as default };
37
+
38
+ //# 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 { Package, ReleasePlan, ReleasePlugin } from '#types'\nimport {\n analyzePackageChanges,\n promotePrereleaseVersions,\n propagateDependencyUpdates,\n resolvePackageTag,\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 * Stages:\n * - discover (enforce: post): when promoting, resolve package tags from the repository.\n * - analyze: initialize plans if empty, collect unreleased history, compute package changes,\n * promote prerelease versions when promoting, and propagate dependency updates.\n */\nconst analyzer = (): ReleasePlugin => ({\n name: '@reelout/core/analyzer',\n version,\n discover: {\n enforce: 'post',\n handler: async (context) => {\n if (context.promote) {\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 },\n },\n analyze: async (context) => {\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 analyzePackageChanges(\n context.classifier,\n context.plans,\n history\n )\n\n if (context.promote) {\n context.plans = await promotePrereleaseVersions(context.plans)\n }\n\n context.plans = await propagateDependencyUpdates(context.cwd, context.plans)\n },\n})\n\nexport default analyzer\n"],"mappings":";;;;;;;;;;AAqBA,IAAM,kBAAiC;CACrC,MAAM;CACN;CACA,UAAU;EACR,SAAS;EACT,SAAS,OAAO,YAAY;GAC1B,IAAI,QAAQ,SACV,QAAQ,WAAW,MAAM,QAAQ,IAC/B,QAAQ,SAAS,IAAI,OAAO,SAA2B;IACrD,GAAG;IACH,KAAK,MAAM,kBAAkB,QAAQ,KAAK,GAAG;GAC/C,EAAE,CACJ;EAEJ;CACF;CACA,SAAS,OAAO,YAAY;EAC1B,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,sBACpB,QAAQ,YACR,QAAQ,OACR,OACF;EAEA,IAAI,QAAQ,SACV,QAAQ,QAAQ,MAAM,0BAA0B,QAAQ,KAAK;EAG/D,QAAQ,QAAQ,MAAM,2BAA2B,QAAQ,KAAK,QAAQ,KAAK;CAC7E;AACF"}
@@ -0,0 +1,52 @@
1
+ import { Nt as bumpVersion, a as version, d as streamPackageCommits, g as resolvePackageStableTag, k as generateGitTagName, l as buildReleaseNotes } from "./workflow-BoVmbvH6.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 for active plans.
7
+ *
8
+ * Stages:
9
+ * - build: compute new package versions, generate git tag names, build changelogs,
10
+ * and attach tag messages (generate from changelog when available).
11
+ */
12
+ var builder = () => ({
13
+ name: "@reelout/core/builder",
14
+ version,
15
+ build: async (context) => {
16
+ context.plans = await Promise.all(context.plans.map(async (plan) => {
17
+ plan = { ...plan };
18
+ if (!plan.release) return plan;
19
+ plan.release = { ...plan.release };
20
+ let version;
21
+ try {
22
+ version = bumpVersion(plan.package, plan.release.type, context.prereleaseLabel);
23
+ } catch (err) {
24
+ context.logger.warn(colors.yellow(`Version could not be determined for package at "${colors.bold(plan.package.dir)}": ${formatError(err)}`));
25
+ }
26
+ if (version) plan.release.version = version;
27
+ let tagName;
28
+ try {
29
+ tagName = generateGitTagName(plan.package.entry, plan.package.name, plan.release.version);
30
+ } catch (err) {
31
+ context.logger.warn(colors.yellow(`Tag could not be determined for package at "${colors.bold(plan.package.dir)}": ${formatError(err)}`));
32
+ }
33
+ let tagMessage;
34
+ try {
35
+ if (tagName) if (context.promote && plan.history.length === 0) {
36
+ const previousTag = (await resolvePackageStableTag(context.cwd, plan.package))?.name;
37
+ const history = streamPackageCommits(context.cwd, plan.package, { until: previousTag });
38
+ tagMessage = await buildReleaseNotes(context, history);
39
+ } else tagMessage = await buildReleaseNotes(context, plan.history);
40
+ } catch {}
41
+ if (tagName) plan.release.tag = {
42
+ name: tagName,
43
+ message: tagMessage
44
+ };
45
+ return plan;
46
+ }));
47
+ }
48
+ });
49
+ //#endregion
50
+ export { builder as default };
51
+
52
+ //# 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 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 for active plans.\n *\n * Stages:\n * - build: compute new package versions, generate git tag names, build changelogs,\n * and attach tag messages (generate from changelog when available).\n */\nconst builder = (): ReleasePlugin => ({\n name: '@reelout/core/builder',\n version,\n build: async (context) => {\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 plan.package,\n plan.release.type,\n context.prereleaseLabel\n )\n } catch (err) {\n context.logger.warn(\n colors.yellow(\n `Version could not be determined for package at \"${colors.bold(plan.package.dir)}\": ${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.dir)}\": ${formatError(err)}`\n )\n )\n }\n\n let tagMessage: string | undefined\n\n try {\n if (tagName) {\n if (context.promote && plan.history.length === 0) {\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})\n\nexport default builder\n"],"mappings":";;;;;;;;;;;AAsBA,IAAM,iBAAgC;CACpC,MAAM;CACN;CACA,OAAO,OAAO,YAAY;EACxB,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,YACR,KAAK,SACL,KAAK,QAAQ,MACb,QAAQ,eACV;GACF,SAAS,KAAK;IACZ,QAAQ,OAAO,KACb,OAAO,OACL,mDAAmD,OAAO,KAAK,KAAK,QAAQ,GAAG,EAAE,KAAK,YAAY,GAAG,GACvG,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,GAAG,EAAE,KAAK,YAAY,GAAG,GACnG,CACF;GACF;GAEA,IAAI;GAEJ,IAAI;IACF,IAAI,SACF,IAAI,QAAQ,WAAW,KAAK,QAAQ,WAAW,GAAG;KAChD,MAAM,eACJ,MAAM,wBAAwB,QAAQ,KAAK,KAAK,OAAO,EAAA,EACtD;KAEH,MAAM,UAAU,qBAAqB,QAAQ,KAAK,KAAK,SAAS,EAC9D,OAAO,YACT,CAAC;KAED,aAAa,MAAM,kBAAkB,SAAS,OAAO;IACvD,OACE,aAAa,MAAM,kBAAkB,SAAS,KAAK,OAAO;GAGhE,QAAQ,CAAC;GAET,IAAI,SACF,KAAK,QAAQ,MAAM;IACjB,MAAM;IACN,SAAS;GACX;GAGF,OAAO;EACT,CAAC,CACH;CACF;AACF"}
@@ -0,0 +1,58 @@
1
+ import { _ as discoverPackageTag, a as version, h as resolvePackageTag, o as writeChangelog, u as buildChangelog } from "./workflow-BoVmbvH6.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 changelogs, and writes changelog files.
7
+ *
8
+ * Stages:
9
+ * - discover (enforce: post): resolve missing package tags from the repository.
10
+ * - build: generate changelogs for planned releases (optionally using the previous tag)
11
+ * and attach tag messages derived from changelogs.
12
+ * - write: persist changelog files for each plan (skipped in dry-run).
13
+ */
14
+ var changelog = () => ({
15
+ name: "@reelout/core/changelog",
16
+ version,
17
+ discover: {
18
+ enforce: "post",
19
+ handler: async (context) => {
20
+ context.packages = await Promise.all(context.packages.map(async (pkg) => ({
21
+ ...pkg,
22
+ tag: await resolvePackageTag(context.cwd, pkg)
23
+ })));
24
+ }
25
+ },
26
+ build: async (context) => {
27
+ context.plans = await Promise.all(context.plans.map(async (plan) => {
28
+ plan = { ...plan };
29
+ if (!plan.release) return plan;
30
+ if (!plan.release.version) return plan;
31
+ plan.release = { ...plan.release };
32
+ let changelog;
33
+ let previousTag = plan.package.tag?.name;
34
+ if (!previousTag) previousTag = (await discoverPackageTag(context.cwd, plan.package))?.name;
35
+ try {
36
+ changelog = await buildChangelog(context, plan.history, {
37
+ packageDir: plan.package.dir,
38
+ changelogFile: plan.package.changelogFile,
39
+ version: plan.release.version,
40
+ previousTag,
41
+ currentTag: plan.release.tag?.name
42
+ });
43
+ } catch (err) {
44
+ context.logger.warn(colors.yellow(`Changelog could not be generated for package at "${colors.bold(plan.package.dir)}": ${formatError(err)}`));
45
+ }
46
+ if (changelog) plan.release.changelog = changelog;
47
+ return plan;
48
+ }));
49
+ },
50
+ write: async (context) => {
51
+ if (context.dryRun) return;
52
+ for (const plan of context.plans) await writeChangelog(context.cwd, plan);
53
+ }
54
+ });
55
+ //#endregion
56
+ export { changelog as default };
57
+
58
+ //# 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 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 changelogs, and writes changelog files.\n *\n * Stages:\n * - discover (enforce: post): resolve missing package tags from the repository.\n * - build: generate changelogs for planned releases (optionally using the previous tag)\n * and attach tag messages derived from changelogs.\n * - write: persist changelog files for each plan (skipped in dry-run).\n */\nconst changelog = (): ReleasePlugin => ({\n name: '@reelout/core/changelog',\n version,\n discover: {\n enforce: 'post',\n handler: async (context) => {\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 },\n build: async (context) => {\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 = plan.package.tag?.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.dir,\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.dir)}\": ${formatError(err)}`\n )\n )\n }\n\n if (changelog) {\n plan.release.changelog = changelog\n }\n\n return plan\n })\n )\n },\n write: async (context) => {\n if (context.dryRun) {\n return\n }\n\n for (const plan of context.plans) {\n await writeChangelog(context.cwd, plan)\n }\n },\n})\n\nexport default changelog\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAM,mBAAkC;CACtC,MAAM;CACN;CACA,UAAU;EACR,SAAS;EACT,SAAS,OAAO,YAAY;GAC1B,QAAQ,WAAW,MAAM,QAAQ,IAC/B,QAAQ,SAAS,IAAI,OAAO,SAA2B;IACrD,GAAG;IACH,KAAK,MAAM,kBAAkB,QAAQ,KAAK,GAAG;GAC/C,EAAE,CACJ;EACF;CACF;CACA,OAAO,OAAO,YAAY;EACxB,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,cAAc,KAAK,QAAQ,KAAK;GAEpC,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,GAAG,EAAE,KAAK,YAAY,GAAG,GACxG,CACF;GACF;GAEA,IAAI,WACF,KAAK,QAAQ,YAAY;GAG3B,OAAO;EACT,CAAC,CACH;CACF;CACA,OAAO,OAAO,YAAY;EACxB,IAAI,QAAQ,QACV;EAGF,KAAK,MAAM,QAAQ,QAAQ,OACzB,MAAM,eAAe,QAAQ,KAAK,IAAI;CAE1C;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,175 @@
1
- export {};
1
+ import { $ as GIT_PRETTY_FORMAT, A as ensureGitTag, At as deriveReleaseType, B as showParsedGitHistory, C as buildDependencyGraph, Ct as isSemVerGitTag, D as getGitTagMessage, Dt as RELEASE_LIFECYCLE_HOOK_LIST, E as getLatestGitTag, Et as GIT_TRAILER_RELEASE_AGENT, F as resolveGitRepository, G as detectGitRelationship, H as restoreFullGitHistory, I as pushGitChanges, J as withShallowLock, K as expandGitHistory, L as getGitRemote, M as deleteGitTag, Mt as determineReleaseType, N as createGitTag, Nt as bumpVersion, O as getCurrentGitTag, Ot as SEMVER_REGEX, P as readGitFile, Q as GIT_PRETTY_FIELD_SEPARATOR, R as ensureGitUserConfig, S as extractPlainText, St as buildTrailerPattern, T as isGitTagConnected, Tt as DEFAULT_CHANGELOG_FILE, U as mergeGitHistory, V as showGitHistory, W as GIT_REL_FLAGS, X as countGitHistory, Y as isGitShallowRepository, Z as getParsedCommit, _ as discoverPackageTag, _t as formatFile, at as extractMentions, b as iterateChangelogVersions, bt as compact, c as extractPreviousVersion, ct as promotePrereleaseVersions, d as streamPackageCommits, dt as resolveReleaseTarget, et as parseGitPrettyFormat, f as sliceUnreleased, ft as sanitizePrereleaseLabel, g as resolvePackageStableTag, gt as interpolate, h as resolvePackageTag, ht as isMatch, i as generateReleaseCommitMessage, it as resolveGitRevision, j as isGitTagPresent, jt as pickPriorityReleaseType, k as generateGitTagName, kt as isStableVersion, l as buildReleaseNotes, lt as analyzePackageChanges, m as propagateDependencyUpdates, mt as readJson, n as printReleaseReport, nt as TTLCache, o as writeChangelog, ot as createGitCommit, p as isReleaseCommit, pt as writeJson, q as isGitAncestor, r as generateReleaseReport, rt as getCurrentGitCommit, s as prependChangelog, st as getCurrentGitBranch, t as runWorkflow, tt as parseCommit, u as buildChangelog, ut as isCommitForPackage, v as verifyPackageTag, vt as execGit, w as isGitTagPointed, wt as ALL_FILES, x as extractSemVer, xt as isDefined, y as extractLatestVersion, yt as execCommand, z as getGitConfigValue } from "./workflow-BoVmbvH6.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/config/normalizeCommitFilter.ts
7
+ /**
8
+ * Normalize a commit classifier into a consistent function.
9
+ *
10
+ * Accepts `null`/`undefined` (returns no-op classifier), a function classifier,
11
+ * or a config object mapping commit types to release types. Returns a classifier
12
+ * function that maps commits to their corresponding release types.
13
+ *
14
+ * @param classifier Commit classifier config, function, or falsy value
15
+ * @returns Normalized classifier function
16
+ */
17
+ function normalizeCommitFilter(classifier) {
18
+ if (classifier == null) return () => null;
19
+ if (typeof classifier === "function") return classifier;
20
+ const map = new Map(Object.entries(classifier).flatMap(([releaseType, commitTypes]) => {
21
+ return commitTypes.map((commitType) => [commitType, releaseType]);
22
+ }));
23
+ return (commit) => commit.type ? map.get(commit.type) : null;
24
+ }
25
+ //#endregion
26
+ //#region src/config/normalizeReleaseRule.ts
27
+ /**
28
+ * Normalize a release rule for the given ref.
29
+ *
30
+ * If `rule` is `true`, derive the rule from the ref (branch or tag).
31
+ * Falsy inputs return an empty rule.
32
+ *
33
+ * @param ref Current repository ref (branch or tag)
34
+ * @param rule Rule input to normalize
35
+ * @returns Normalized `ReleaseRule` object
36
+ */
37
+ function normalizeReleaseRule(ref, rule) {
38
+ if (rule === true) switch (ref.type) {
39
+ case "branch": rule = ref.name.split("/").at(0);
40
+ }
41
+ if (!rule) rule = {};
42
+ if (typeof rule === "string") rule = {
43
+ prereleaseLabel: rule,
44
+ releaseChannel: rule
45
+ };
46
+ return {
47
+ type: rule.type || ref.type,
48
+ pattern: rule.pattern || ref.name,
49
+ prereleaseLabel: rule.prereleaseLabel,
50
+ releaseChannel: rule.releaseChannel
51
+ };
52
+ }
53
+ //#endregion
54
+ //#region src/config/normalizeWorkspace.ts
55
+ /**
56
+ * Normalize and validate workspace configuration for a repository.
57
+ *
58
+ * Resolves the workspace entry directory relative to `cwd` and normalizes
59
+ * the path representation. Returns a workspace object with normalized `entry`
60
+ * and optional workspace members.
61
+ *
62
+ * @param cwd Repository working directory
63
+ * @param workspace Partial workspace configuration (optional)
64
+ * @returns Normalized workspace object
65
+ */
66
+ function normalizeWorkspace(cwd, workspace) {
67
+ let entry = workspace?.entry || ".";
68
+ const members = workspace?.members ?? null;
69
+ entry = path.normalize(path.relative(cwd, path.resolve(cwd, entry)));
70
+ return {
71
+ entry,
72
+ members
73
+ };
74
+ }
75
+ //#endregion
76
+ //#region src/config/resolvePlugin.ts
77
+ /**
78
+ * Resolve a plugin reference to a `ReleasePlugin` instance.
79
+ *
80
+ * Accepts a module specifier, a loaded plugin object, or an initializer
81
+ * function (optionally with options) and normalizes it to a `ReleasePlugin`,
82
+ * or `null` when resolution fails.
83
+ *
84
+ * @param cwd Base directory used to resolve module specifiers
85
+ * @param plugin Plugin reference (module path, function, object, or [path, opts])
86
+ * @returns Resolved `ReleasePlugin` or `null` when not resolvable
87
+ */
88
+ async function resolvePlugin(cwd, plugin) {
89
+ let options;
90
+ if (Array.isArray(plugin)) [plugin, options] = plugin;
91
+ if (typeof plugin === "string") plugin = await import(createRequire(pathToFileURL(cwd)).resolve(plugin));
92
+ if (plugin != null && typeof plugin === "object" && Object.hasOwn(plugin, "default")) plugin = plugin.default;
93
+ if (typeof plugin === "function") plugin = plugin(options);
94
+ if (plugin != null && typeof plugin === "object" && Object.hasOwn(plugin, "name") && typeof plugin.name === "string") return plugin;
95
+ return null;
96
+ }
97
+ //#endregion
98
+ //#region src/util/isCI.ts
99
+ /**
100
+ * Detect whether the current process is running in a CI environment.
101
+ *
102
+ * Returns true when the standard `CI` environment variable is set to a
103
+ * truthy value. Explicit string values `"false"` and `"0"` are treated as
104
+ * false to accommodate CI systems that expose `CI` but allow disabling it.
105
+ *
106
+ * This check is intentionally minimal and does not inspect provider-specific
107
+ * environment variables (e.g., `GITHUB_ACTIONS`, `GITLAB_CI`). Callers that
108
+ * need provider-level detail should check those variables separately.
109
+ *
110
+ * @returns `true` if running in CI; otherwise `false`
111
+ */
112
+ function isCI() {
113
+ return !!(process.env.CI && process.env.CI !== "false" && process.env.CI !== "0");
114
+ }
115
+ //#endregion
116
+ //#region src/util/unique.ts
117
+ /**
118
+ * Return a new array containing only the first-seen occurrence of each item.
119
+ *
120
+ * This preserves the original iteration order and performs equality checks
121
+ * using JavaScript's `Set` semantics (i.e., primitives by value, objects by
122
+ * reference). The input array is not mutated.
123
+ *
124
+ * @param array The array of items to deduplicate
125
+ * @returns A new array with duplicates removed, preserving first-seen order
126
+ */
127
+ function unique(array) {
128
+ const seen = /* @__PURE__ */ new Set();
129
+ const result = [];
130
+ for (const item of array) if (!seen.has(item)) {
131
+ seen.add(item);
132
+ result.push(item);
133
+ }
134
+ return result;
135
+ }
136
+ //#endregion
137
+ //#region src/workflow/discovery/sortPackages.ts
138
+ /**
139
+ * Sort workspace packages topologically based on their dependency graphs.
140
+ *
141
+ * Deepest dependents are placed first in the resulting array, ensuring that
142
+ * a package always precedes its own dependencies. Ties and circular dependencies
143
+ * are resolved deterministically using an alphabetical sort on the package directory (`dir`).
144
+ *
145
+ * @param packages The workspace packages to sort.
146
+ * @returns A new array of packages sorted by dependency depth and directory path.
147
+ */
148
+ function sortPackages(packages) {
149
+ const packageNodes = [];
150
+ const packageMap = /* @__PURE__ */ new Map();
151
+ for (const pkg of packages.toSorted((a, b) => a.dir.localeCompare(b.dir))) {
152
+ const node = {
153
+ package: pkg,
154
+ level: -1
155
+ };
156
+ packageNodes.push(node);
157
+ if (pkg.name) packageMap.set(pkg.name, node);
158
+ }
159
+ for (const node of packageNodes) visit(node);
160
+ function visit(node, level = 0, visited = /* @__PURE__ */ new Set()) {
161
+ if (node.level >= level) return;
162
+ if (visited.has(node)) return;
163
+ visited.add(node);
164
+ for (const depName of node.package.dependencies) {
165
+ const depNode = packageMap.get(depName);
166
+ if (depNode && depNode !== node) visit(depNode, level + 1, visited);
167
+ }
168
+ node.level = level;
169
+ }
170
+ return packageNodes.toSorted((a, b) => b.level - a.level).map((node) => node.package);
171
+ }
172
+ //#endregion
173
+ export { ALL_FILES, DEFAULT_CHANGELOG_FILE, GIT_PRETTY_FIELD_SEPARATOR, GIT_PRETTY_FORMAT, GIT_REL_FLAGS, GIT_TRAILER_RELEASE_AGENT, RELEASE_LIFECYCLE_HOOK_LIST, SEMVER_REGEX, TTLCache, analyzePackageChanges, buildChangelog, buildDependencyGraph, buildReleaseNotes, buildTrailerPattern, bumpVersion, compact, countGitHistory, createGitCommit, createGitTag, deleteGitTag, deriveReleaseType, detectGitRelationship, determineReleaseType, discoverPackageTag, ensureGitTag, ensureGitUserConfig, execCommand, execGit, expandGitHistory, extractLatestVersion, extractMentions, extractPlainText, extractPreviousVersion, extractSemVer, formatError, formatFile, generateGitTagName, generateReleaseCommitMessage, generateReleaseReport, getCurrentGitBranch, getCurrentGitCommit, getCurrentGitTag, getGitConfigValue, getGitRemote, getGitTagMessage, getLatestGitTag, getParsedCommit, interpolate, isCI, isCommitForPackage, isDefined, isGitAncestor, isGitShallowRepository, isGitTagConnected, isGitTagPointed, isGitTagPresent, isMatch, isReleaseCommit, isSemVerGitTag, isStableVersion, iterateChangelogVersions, mergeGitHistory, normalizeCommitFilter, normalizeReleaseRule, normalizeWorkspace, parseCommit, parseGitPrettyFormat, pickPriorityReleaseType, prependChangelog, printReleaseReport, promotePrereleaseVersions, propagateDependencyUpdates, pushGitChanges, readGitFile, readJson, resolveGitRepository, resolveGitRevision, resolvePackageStableTag, resolvePackageTag, resolvePlugin, resolveReleaseTarget, restoreFullGitHistory, runWorkflow, sanitizePrereleaseLabel, showGitHistory, showParsedGitHistory, sliceUnreleased, sortPackages, streamPackageCommits, unique, verifyPackageTag, withShallowLock, writeChangelog, writeJson };
174
+
175
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/config/normalizeCommitFilter.ts","../src/config/normalizeReleaseRule.ts","../src/config/normalizeWorkspace.ts","../src/config/resolvePlugin.ts","../src/util/isCI.ts","../src/util/unique.ts","../src/workflow/discovery/sortPackages.ts"],"sourcesContent":["// 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 { ReleaseContext, ReleaseRule } from '#types'\n\n/**\n * Normalize a release rule for the given ref.\n *\n * If `rule` is `true`, derive the rule from the ref (branch or tag).\n * Falsy inputs return an empty rule.\n *\n * @param ref Current repository ref (branch or tag)\n * @param rule Rule input to normalize\n * @returns Normalized `ReleaseRule` object\n */\nexport function normalizeReleaseRule(\n ref: ReleaseContext['ref'],\n rule: boolean | string | Partial<ReleaseRule> | null | undefined\n): ReleaseRule {\n if (rule === true) {\n switch (ref.type) {\n case 'branch':\n rule = ref.name.split('/').at(0)\n break\n }\n }\n\n if (!rule) {\n rule = {}\n }\n\n if (typeof rule === 'string') {\n rule = { prereleaseLabel: rule, releaseChannel: rule }\n }\n\n return {\n type: rule.type || ref.type,\n pattern: rule.pattern || ref.name,\n prereleaseLabel: rule.prereleaseLabel,\n releaseChannel: rule.releaseChannel,\n }\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 { ReleasePlugin } from '#types'\nimport { createRequire } from 'node:module'\nimport { pathToFileURL } from 'node:url'\n\n/**\n * Resolve a plugin reference to a `ReleasePlugin` instance.\n *\n * Accepts a module specifier, a loaded plugin object, or an initializer\n * function (optionally with options) and normalizes it to a `ReleasePlugin`,\n * or `null` when resolution fails.\n *\n * @param cwd Base directory used to resolve module specifiers\n * @param plugin Plugin reference (module path, function, object, or [path, opts])\n * @returns Resolved `ReleasePlugin` or `null` when not resolvable\n */\nexport async function resolvePlugin(\n cwd: string,\n plugin: unknown\n): Promise<ReleasePlugin | 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 (\n plugin != null &&\n typeof plugin === 'object' &&\n Object.hasOwn(plugin, 'default')\n ) {\n plugin = (plugin as { default: unknown }).default\n }\n\n if (typeof plugin === 'function') {\n plugin = plugin(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\n/**\n * Detect whether the current process is running in a CI environment.\n *\n * Returns true when the standard `CI` environment variable is set to a\n * truthy value. Explicit string values `\"false\"` and `\"0\"` are treated as\n * false to accommodate CI systems that expose `CI` but allow disabling it.\n *\n * This check is intentionally minimal and does not inspect provider-specific\n * environment variables (e.g., `GITHUB_ACTIONS`, `GITLAB_CI`). Callers that\n * need provider-level detail should check those variables separately.\n *\n * @returns `true` if running in CI; otherwise `false`\n */\nexport function isCI(): boolean {\n return !!(\n process.env.CI &&\n process.env.CI !== 'false' &&\n process.env.CI !== '0'\n )\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 { 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) => a.dir.localeCompare(b.dir))) {\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":";;;;;;;;;;;;;;;;AAeA,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;;;;;;;;;;;;;ACrBA,SAAgB,qBACd,KACA,MACa;CACb,IAAI,SAAS,MACX,QAAQ,IAAI,MAAZ;EACE,KAAK,UACH,OAAO,IAAI,KAAK,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC;CAEnC;CAGF,IAAI,CAAC,MACH,OAAO,CAAC;CAGV,IAAI,OAAO,SAAS,UAClB,OAAO;EAAE,iBAAiB;EAAM,gBAAgB;CAAK;CAGvD,OAAO;EACL,MAAM,KAAK,QAAQ,IAAI;EACvB,SAAS,KAAK,WAAW,IAAI;EAC7B,iBAAiB,KAAK;EACtB,gBAAgB,KAAK;CACvB;AACF;;;;;;;;;;;;;;ACxBA,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;;;;;;;;;;;;;;ACfA,eAAsB,cACpB,KACA,QAC+B;CAC/B,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,IACE,UAAU,QACV,OAAO,WAAW,YAClB,OAAO,OAAO,QAAQ,SAAS,GAE/B,SAAU,OAAgC;CAG5C,IAAI,OAAO,WAAW,YACpB,SAAS,OAAO,OAAO;CAGzB,IACE,UAAU,QACV,OAAO,WAAW,YAClB,OAAO,OAAO,QAAQ,MAAM,KAC5B,OAAQ,OAAyB,SAAS,UAE1C,OAAO;CAGT,OAAO;AACT;;;;;;;;;;;;;;;;ACvCA,SAAgB,OAAgB;CAC9B,OAAO,CAAC,EACN,QAAQ,IAAI,MACZ,QAAQ,IAAI,OAAO,WACnB,QAAQ,IAAI,OAAO;AAEvB;;;;;;;;;;;;;ACTA,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;;;;;;;;;;;;;ACLA,SAAgB,aAAa,UAAyC;CACpE,MAAM,eAA8B,CAAC;CACrC,MAAM,6BAAa,IAAI,IAAyB;CAEhD,KAAK,MAAM,OAAO,SAAS,UAAU,GAAG,MAAM,EAAE,IAAI,cAAc,EAAE,GAAG,CAAC,GAAG;EACzE,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 {};