@reelout/core 0.13.0 → 0.14.1

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 (66) hide show
  1. package/dist/HookDispatcher-B_TrMRLU.js +236 -0
  2. package/dist/HookDispatcher-B_TrMRLU.js.map +1 -0
  3. package/dist/analyzer.js +12 -3
  4. package/dist/analyzer.js.map +1 -1
  5. package/dist/buildChangelog-CkytKypk.js +187 -0
  6. package/dist/buildChangelog-CkytKypk.js.map +1 -0
  7. package/dist/buildReleaseNotes-Dk4bEclG.js +141 -0
  8. package/dist/buildReleaseNotes-Dk4bEclG.js.map +1 -0
  9. package/dist/builder.js +14 -6
  10. package/dist/builder.js.map +1 -1
  11. package/dist/changelog.js +17 -6
  12. package/dist/changelog.js.map +1 -1
  13. package/dist/index.js +1297 -20
  14. package/dist/index.js.map +1 -1
  15. package/dist/package-la-hLPRR.js +884 -0
  16. package/dist/package-la-hLPRR.js.map +1 -0
  17. package/dist/propagateDependencyUpdates-xcPvP5SP.js +306 -0
  18. package/dist/propagateDependencyUpdates-xcPvP5SP.js.map +1 -0
  19. package/dist/readPackageHistory-6dC72rZk.js +133 -0
  20. package/dist/readPackageHistory-6dC72rZk.js.map +1 -0
  21. package/dist/resolvePackageTag-2ldvH7PC.js +30 -0
  22. package/dist/resolvePackageTag-2ldvH7PC.js.map +1 -0
  23. package/dist/types.js +0 -1
  24. package/package.json +15 -3
  25. package/src/analyzer.ts +7 -2
  26. package/src/builder.ts +12 -3
  27. package/src/changelog.ts +17 -6
  28. package/src/config/resolvePlugin.ts +1 -1
  29. package/src/git/commit/getParsedGitCommit.ts +4 -1
  30. package/src/git/commit/parseGitCommit.ts +27 -2
  31. package/src/git/commit/parseGitPrettyFormat.ts +4 -1
  32. package/src/git/history/expandGitHistory.ts +17 -3
  33. package/src/git/history/readParsedGitHistory.ts +8 -2
  34. package/src/git/repository/isGitShallowRepository.ts +2 -1
  35. package/src/git/tag/ensureGitTag.ts +35 -3
  36. package/src/plugin/createHostReleasePlugin.ts +255 -0
  37. package/src/plugin/index.ts +1 -0
  38. package/src/types.ts +1 -0
  39. package/src/util/captureCommandOutput.ts +140 -0
  40. package/src/util/execCommand.ts +9 -0
  41. package/src/util/formatFile.ts +12 -3
  42. package/src/util/index.ts +1 -0
  43. package/src/util/interpolate.ts +5 -3
  44. package/src/util/isQuietEnvironment.ts +19 -13
  45. package/src/workflow/analysis/propagateDependencyUpdates.ts +1 -0
  46. package/src/workflow/changelog/buildChangelog.ts +27 -4
  47. package/src/workflow/changelog/buildReleaseNotes.ts +1 -1
  48. package/src/workflow/changelog/index.ts +0 -1
  49. package/src/workflow/changelog/prependChangelog.ts +5 -2
  50. package/src/workflow/changelog/writeChangelog.ts +5 -2
  51. package/src/workflow/commit/generateReleaseCommitMessage.ts +1 -1
  52. package/src/workflow/discovery/discoverPackageTag.ts +5 -2
  53. package/src/workflow/discovery/resolvePackageStableTag.ts +12 -7
  54. package/src/workflow/discovery/resolvePackageTag.ts +5 -2
  55. package/src/workflow/discovery/sortPackages.ts +5 -4
  56. package/src/workflow/discovery/verifyPackageTag.ts +6 -3
  57. package/src/workflow/report/printReleaseReport.ts +6 -1
  58. package/src/workflow/version/bumpVersion.ts +0 -1
  59. package/src/workflow/version/index.ts +0 -1
  60. package/dist/formatError-BMsun8Wi.js +0 -22
  61. package/dist/formatError-BMsun8Wi.js.map +0 -1
  62. package/dist/types-la_KkjCS.js +0 -1
  63. package/dist/workflow-Cqg6rLVB.js +0 -2936
  64. package/dist/workflow-Cqg6rLVB.js.map +0 -1
  65. package/src/workflow/changelog/extractPreviousVersion.ts +0 -77
  66. package/src/workflow/version/promotePrereleaseVersions.ts +0 -51
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/util/isCI.ts","../src/util/isQuietEnvironment.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\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\nimport type { ReleaseContext } from '../types'\nimport { isCI } from './isCI'\n\n/**\n * Determine whether the current run should stay quiet about verbose output.\n *\n * A run is quiet when nothing will keep what it prints: no terminal is attached\n * for a human, and no CI provider is recording a job log. A plain pipe outside\n * of CI — an agent sandbox, a script capturing output, a detached daemon — only\n * accumulates noise, so verbose output should be withheld and left to\n * `execCommand` for error reporting instead.\n *\n * CI is deliberately *not* quiet even though its streams are not TTYs: the\n * provider persists the job log, so the output does reach someone. A caller\n * that wants output from a pipe in a non-CI environment can set `CI=1` as an\n * escape hatch.\n *\n * The verdict is per environment, not per stream, so a redirected stdout inside\n * an interactive terminal still counts as quiet.\n *\n * @param context Release context carrying the destination stream and environment\n * @returns `true` when no TTY is attached and the run is not part of CI\n */\nexport function isQuietEnvironment(\n context: Pick<ReleaseContext, 'env' | 'stdout'>\n): boolean {\n if (isCI(context.env)) return false\n\n const stream = context.stdout as NodeJS.WriteStream | undefined\n\n return stream?.isTTY !== true\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":";;;;;;;;;;;;;;;;AAeA,SAAgB,KAAK,KAA2C;CAC9D,OAAO,eAAe,IAAI,EAAE;AAC9B;;;;;;;;;;;;;;;;;;;;;;ACSA,SAAgB,mBACd,SACS;CACT,IAAI,KAAK,QAAQ,GAAG,GAAG,OAAO;CAI9B,OAFe,QAAQ,QAER,UAAU;AAC3B;;;;;;;;;;;;ACnBA,SAAgB,sBACd,YACkB;CAClB,IAAI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,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"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/workflow/version/isStableVersion.ts","../src/util/captureCommandOutput.ts","../src/util/interpolate.ts","../src/util/isTruthyString.ts","../src/util/isCI.ts","../src/util/isClass.ts","../src/util/isGitHubActions.ts","../src/util/isQuietEnvironment.ts","../src/util/readJson.ts","../src/util/writeJson.ts","../src/config/createPlugin.ts","../src/config/findReleaseRule.ts","../src/config/isSemVer.ts","../src/config/isSemVerGitTag.ts","../src/config/normalizeCommitFilter.ts","../src/config/sanitizePrereleaseLabel.ts","../src/config/normalizeReleaseRule.ts","../src/config/normalizeWorkspace.ts","../src/config/resolvePlugin.ts","../src/config/resolveReleaseChannel.ts","../src/config/resolveVersionQualifier.ts","../src/git/branch/getCurrentGitBranch.ts","../src/git/commit/createGitCommit.ts","../src/git/commit/getCurrentGitCommit.ts","../src/git/history/restoreFullGitHistory.ts","../src/git/repository/getGitConfigValue.ts","../src/git/repository/ensureGitUserConfig.ts","../src/git/repository/getGitRemote.ts","../src/git/repository/pushGitChanges.ts","../src/git/repository/resolveGitRepository.ts","../src/git/tag/createGitTag.ts","../src/git/tag/getCurrentGitTag.ts","../src/git/tag/getLatestGitTag.ts","../src/git/tag/isGitTagExact.ts","../src/workflow/discovery/filterPackages.ts","../src/workflow/discovery/sortPackages.ts","../src/workflow/commit/generateReleaseCommitMessage.ts","../src/plugin/createHostReleasePlugin.ts","../src/workflow/report/resolveErrorMessage.ts","../src/workflow/report/appendReleaseReportSummary.ts","../src/workflow/report/generateReleaseReport.ts","../src/workflow/report/printReleaseReport.ts","../src/workflow/report/printReleaseReportAnnotation.ts","../src/workflow/executeReleaseWorkflow.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { colors } from 'consola/utils'\nimport semver from 'semver'\n\n/**\n * Determine whether a version string represents a stable SemVer release.\n *\n * A version is considered stable when:\n * - It is a valid SemVer string.\n * - Its major version is greater than 0 (not 0.x.x).\n * - It contains no prerelease identifiers (no `-alpha`, `-beta`, `-rc`, etc.).\n *\n * Build metadata (the `+` suffix) does not affect stability.\n *\n * @param version Semantic version string to check\n * @returns `true` if `version` is a stable SemVer; otherwise `false`\n * @throws If `version` is not a valid SemVer string\n */\nexport function isStableVersion(version: string): boolean {\n const parsed = semver.parse(version)\n\n if (!parsed) {\n throw new Error(\n `The version \"${colors.bold(version)}\" is not a valid SemVer.`\n )\n }\n\n return parsed.major > 0 && parsed.prerelease.length === 0\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { Writable } from 'node:stream'\nimport type { ReleaseContext } from '../types'\n\n/** Maximum bytes of command output kept per stream for failure diagnostics. */\nconst MAX_TAIL_BYTES = 64 * 1024\n\n/** Wrapping streams that keep a bounded tail of everything written through them. */\nexport interface CommandOutputCapture {\n stdout: NodeJS.WritableStream\n stderr: NodeJS.WritableStream\n readStdout(): string\n readDiagnostics(): string\n}\n\n/** Options controlling where the captured output is streamed. */\nexport interface CaptureCommandOutputOptions {\n pipe: boolean\n}\n\n/**\n * Capture command output at the call site, optionally streaming it live.\n *\n * The returned wrappers keep a tail-bounded capture of everything written\n * through them. When `pipe` is set they also forward the output to the\n * context streams, so it keeps flowing live into the terminal or the CI\n * job log; otherwise the output stays inside the capture.\n *\n * @param context Release context carrying the destination streams\n * @param options Whether the captured output is forwarded to the context\n * streams\n * @returns Wrapping streams plus the captured tail readers\n */\nexport function captureCommandOutput(\n context: Pick<ReleaseContext, 'stdout' | 'stderr'>,\n options: CaptureCommandOutputOptions\n): CommandOutputCapture {\n const stdoutTail = new OutputTail()\n const stderrTail = new OutputTail()\n\n return {\n stdout: createCapturingStream(\n options.pipe ? context.stdout : undefined,\n stdoutTail\n ),\n stderr: createCapturingStream(\n options.pipe ? context.stderr : undefined,\n stderrTail\n ),\n readStdout: () => stdoutTail.read().trim(),\n readDiagnostics: () => stderrTail.read().trim() || stdoutTail.read().trim(),\n }\n}\n\n/**\n * Append captured command output to a failure error message.\n *\n * Command runs that stream through call-site wrappers carry no\n * `execCommand` diagnostics of their own; this appends the captured tail\n * so the publish-rejection classifiers keep reading the command output\n * from the error message.\n *\n * @param cause The error thrown by the command\n * @param capture The capture created for the run\n * @returns The error, with the captured output appended to its message\n */\nexport function appendCapturedDiagnostics(\n cause: unknown,\n capture: CommandOutputCapture\n): unknown {\n const error = cause instanceof Error ? cause : new Error(String(cause))\n const diagnostics = capture.readDiagnostics()\n\n if (diagnostics) {\n error.message = `${error.message}\\n${diagnostics}`\n }\n\n return error\n}\n\nclass OutputTail {\n private chunks: Buffer[] = []\n private size = 0\n\n push(chunk: Buffer): void {\n this.chunks.push(chunk)\n this.size += chunk.length\n\n while (this.size > MAX_TAIL_BYTES && this.chunks.length > 1) {\n const head = this.chunks.shift()\n\n if (!head) break\n\n this.size -= head.length\n }\n }\n\n read(): string {\n let buffer: Buffer = Buffer.concat(this.chunks)\n\n if (buffer.length > MAX_TAIL_BYTES) {\n buffer = trimUtf8Start(buffer.subarray(buffer.length - MAX_TAIL_BYTES))\n }\n\n return buffer.toString('utf-8')\n }\n}\n\nfunction trimUtf8Start(buffer: Buffer): Buffer {\n let start = 0\n\n while (start < 3 && start < buffer.length) {\n const byte = buffer[start]\n\n if (byte === undefined || (byte & 0xc0) !== 0x80) break\n\n start += 1\n }\n\n return start === 0 ? buffer : buffer.subarray(start)\n}\n\nfunction createCapturingStream(\n target: NodeJS.WritableStream | undefined,\n tail: OutputTail\n): Writable {\n return new Writable({\n write(chunk, _encoding, callback) {\n tail.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))\n\n if (target) {\n target.write(chunk, callback)\n } else {\n callback()\n }\n },\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nconst BACKSLASH = '\\\\'\nconst LEFT_BRACE = '{'\nconst RIGHT_BRACE = '}'\nconst DOT = '.'\nconst ESCAPE_CHARS = [BACKSLASH, LEFT_BRACE, RIGHT_BRACE]\nconst BANNED_KEYS = ['__proto__', 'constructor', 'prototype']\n\n/**\n * Interpolate placeholders in `template` using values from `data`.\n *\n * - Placeholders use `{path.to.value}` (dot notation).\n * - Backslash escapes are supported for `{`, `}`, `\\`, and `.` inside tokens.\n * - Tokens that reference banned keys (`__proto__`, `constructor`, `prototype`)\n * are left unexpanded to avoid prototype pollution.\n * - Only own properties are followed when resolving paths; when any step is\n * missing, the token is preserved with its escape sequences already\n * resolved, so an unresolved `{a\\.b}` renders as `{a.b}`.\n * - Resolved non-object, non-null values are stringified and inserted.\n * - Unclosed tokens keep their opening brace and resolved body; a trailing\n * backslash is emitted as-is.\n *\n * @param template Template string containing placeholders like `{user.name}`\n * @param data Object used to resolve placeholder paths\n * @returns The template with placeholders replaced by corresponding values\n */\nexport function interpolate(\n template: string,\n data: Record<string, unknown>\n): string {\n let result = ''\n let i = 0\n let char: string | undefined\n let nextChar: string | undefined\n\n while ((char = template[i])) {\n // Escape handling: if a backslash precedes an escapable char, emit the\n // escaped character; otherwise emit the backslash itself.\n if (char === BACKSLASH) {\n nextChar = template[i + 1]\n\n if (nextChar !== undefined && ESCAPE_CHARS.includes(nextChar)) {\n result += nextChar\n i += 2\n } else {\n result += char\n i += 1\n }\n }\n\n // Placeholder handling: parse a token starting at '{' until a matching '}'.\n else if (char === LEFT_BRACE) {\n const keys: string[] = []\n let key = ''\n let token = ''\n let closed = false\n i += 1\n\n // Parse token body, supporting escaped characters and escaped dots.\n while ((char = template[i])) {\n if (char === RIGHT_BRACE) {\n closed = true\n keys.push(key)\n i += 1\n break\n }\n\n if (char === BACKSLASH) {\n nextChar = template[i + 1]\n\n // Allow escaping of brace, backslash, and dot inside tokens.\n if (\n nextChar !== undefined &&\n [...ESCAPE_CHARS, DOT].includes(nextChar)\n ) {\n key += nextChar\n token += nextChar\n i += 2\n } else {\n // Treat an isolated backslash as a literal within the token.\n key += char\n token += char\n i += 1\n }\n } else if (char === DOT) {\n // Dot separates path segments; record the current segment.\n keys.push(key)\n key = ''\n token += char\n i += 1\n } else {\n key += char\n token += char\n i += 1\n }\n }\n\n // If token closed with '}', attempt to resolve the path against `data`.\n if (closed) {\n let value: unknown = data\n\n for (const key of keys) {\n const isSafeKey = !BANNED_KEYS.includes(key)\n\n // Only follow own properties on objects and skip banned keys.\n if (\n value !== null &&\n typeof value === 'object' &&\n Object.hasOwn(value, key) &&\n isSafeKey\n ) {\n value = (value as Record<string, unknown>)[key]\n } else {\n value = undefined\n break\n }\n }\n\n // If resolution failed or produced an object/null, preserve the token.\n if (value == null || typeof value === 'object') {\n result += LEFT_BRACE + token + RIGHT_BRACE\n } else {\n result += String(value)\n }\n }\n\n // Unclosed token: preserve the raw token text (including the opening brace).\n else {\n result += LEFT_BRACE + token\n }\n }\n\n // Ordinary characters are appended directly.\n else {\n result += char\n i += 1\n }\n }\n\n return result\n}\n","// 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 * Determine whether a given value is a constructible class.\n *\n * Verifies that the input is a function with a non-writable prototype, can\n * be successfully invoked via `Reflect.construct`, and matches ES6 class\n * syntax.\n *\n * @param func The unknown value to inspect\n * @returns True if the value is a class, false otherwise\n */\nexport function isClass(\n func: unknown\n): func is new (...args: readonly unknown[]) => unknown {\n if (typeof func !== 'function') {\n return false\n }\n\n try {\n Reflect.construct(Object, [], func)\n } catch {\n return false\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(func, 'prototype')\n\n if (!descriptor || descriptor.writable) {\n return false\n }\n\n return /^class\\s/.test(Function.prototype.toString.call(func))\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { isTruthyString } from './isTruthyString'\n\n/**\n * Determine whether the current process runs on a GitHub Actions runner.\n *\n * Checks if the `GITHUB_ACTIONS` environment variable is set to a truthy\n * value. Gates GitHub Actions-specific reporting such as job summaries and\n * annotations.\n *\n * @param env Readonly process environment variables object\n * @returns `true` if `env.GITHUB_ACTIONS` normalizes to a truthy string, otherwise `false`\n */\nexport function isGitHubActions(env: Readonly<NodeJS.ProcessEnv>): boolean {\n return isTruthyString(env.GITHUB_ACTIONS)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseContext } from '../types'\nimport { isCI } from './isCI'\n\n/**\n * Determine whether the current run should stay quiet about verbose output.\n *\n * A run is quiet when its verbose output would only accumulate noise: no\n * terminal is attached for a human to read it live, or the run is inside CI\n * where the provider records a job log that publish noise would pollute.\n * The debug flag opts back in: a debug run is never quiet, not even inside\n * CI, so `--debug` keeps the verbose output flowing. Quiet runs still\n * surface command output on failure — `execCommand` attaches it to the\n * failure diagnostics and captured commands attach their recorded output\n * to the thrown error — so failures stay diagnosable.\n *\n * CI runs stay quiet even when the provider attaches a pseudo-terminal: the\n * `isCI` check guarantees it on top of the TTY check, so the job log keeps\n * the publish results without the package manager noise.\n *\n * The verdict is per environment, not per stream, so a redirected stdout inside\n * an interactive terminal still counts as quiet.\n *\n * @param context Release context carrying the debug flag, destination\n * stream, and environment\n * @returns `true` when the run is part of CI or no TTY is attached, unless\n * the debug flag is set\n */\nexport function isQuietEnvironment(\n context: Pick<ReleaseContext, 'debug' | 'env' | 'stdout'>\n): boolean {\n if (context.debug) return false\n\n if (isCI(context.env)) return true\n\n const stream = context.stdout as NodeJS.WriteStream | undefined\n\n return stream?.isTTY !== true\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { colors } from 'consola/utils'\nimport fs from 'node:fs/promises'\n\n/**\n * Read and parse a JSON file.\n *\n * Throws a descriptive error when the file cannot be read or parsed, or when\n * the parsed value is not an object.\n *\n * @param filePath Path to the JSON file\n * @returns Parsed JSON object\n * @throws If the file cannot be read, parsed, or is not an object\n */\nexport async function readJson<T>(filePath: string): Promise<T> {\n let content: string\n\n try {\n content = await fs.readFile(filePath, 'utf-8')\n } catch (err) {\n throw new Error(\n `JSON file at \"${colors.bold(filePath)}\" could not be read.`,\n { cause: err }\n )\n }\n\n let json: T\n\n try {\n json = JSON.parse(content) as T\n } catch (err) {\n throw new Error(\n `JSON file at \"${colors.bold(filePath)}\" could not be parsed.`,\n { cause: err }\n )\n }\n\n if (typeof json !== 'object' || json === null) {\n throw new Error(\n `JSON file at \"${colors.bold(filePath)}\" does not contain a valid object.`\n )\n }\n\n return json\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\nimport { formatFile } from './formatFile'\n\n/**\n * Write a JSON `payload` to `filePath`, formatting the content first.\n *\n * Ensures the directory exists and writes the formatted JSON.\n *\n * @param filePath Path to write the JSON file\n * @param payload JSON-serializable object to write\n * @returns Promise that resolves when the file is written\n */\nexport async function writeJson(\n filePath: string,\n payload: object\n): Promise<void> {\n let content = JSON.stringify(payload, null, 2)\n\n content = await formatFile(filePath, content)\n\n await fs.mkdir(path.dirname(filePath), { recursive: true })\n\n await fs.writeFile(filePath, content)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleasePlugin } from '#types'\nimport { isClass } from '#util'\n\n/**\n * Instantiate or invoke a plugin factory to produce a release plugin instance.\n *\n * Accepts class constructors, factory functions, tuple configurations, or\n * existing plugin objects. Instantiates classes using `new` or invokes factory\n * functions with options, validating that the resulting object satisfies the\n * plugin structure.\n *\n * @param plugin A plugin constructor, factory function, tuple, or object\n * @returns A validated release plugin instance or null\n */\nexport async function createPlugin(\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 === 'function') {\n plugin = isClass(plugin) ? new plugin(options) : await 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\nimport type { GitRef, ResolvedReleaseRule } from '#types'\nimport { isMatch } from '#util'\n\n/**\n * Find the first release rule matching a release reference.\n *\n * Matches rules sequentially against the reference type and pattern.\n *\n * @param ref Release reference object\n * @param rules Array of release rules to match against\n * @returns The first matching release rule or `undefined`\n */\nexport function findReleaseRule(\n ref: GitRef,\n rules: readonly ResolvedReleaseRule[]\n): ResolvedReleaseRule | undefined {\n return rules.find((rule) => {\n return (\n (rule.type == null || rule.type === ref.type) &&\n isMatch(ref.name, rule.pattern)\n )\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport semver from 'semver'\n\n/**\n * Determine whether a value is a valid Semantic Versioning string.\n *\n * Rejects non-string values, leading or trailing whitespace, and leading `v`\n * prefixes. Validates the candidate string using `semver.parse`.\n *\n * @param version Candidate value to evaluate for SemVer compliance\n * @returns `true` if `version` is a valid SemVer string, or `false` otherwise\n */\nexport function isSemVer(\n version: string | null | undefined\n): version is string {\n if (typeof version !== 'string') {\n return false\n }\n\n if (version !== version.trim()) {\n return false\n }\n\n if (version.startsWith('v')) {\n return false\n }\n\n return semver.parse(version) != null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { SEMVER_REGEX } from './const'\n\n/**\n * Determine whether a tag string is a valid SemVer-style Git tag.\n *\n * Anchors `SEMVER_REGEX.source` for full-string matching and applies the\n * repository's Git-tag acceptance rules.\n *\n * @param tag Tag string to validate\n * @returns `true` if `tag` is accepted as a SemVer-style Git tag; otherwise `false`\n */\nexport function isSemVerGitTag(tag: string): boolean {\n const match = new RegExp(`^${SEMVER_REGEX.source}$`).exec(tag)\n\n if (!match) return false\n\n const isScopedPackage = Boolean(match[1])\n\n const hasVersionPrefix = tag.startsWith('v')\n\n return isScopedPackage || hasVersionPrefix\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\n/**\n * Sanitize a string into a safe, SemVer-compliant prerelease label.\n *\n * Replaces sequences of non-alphanumeric characters with a single hyphen and\n * removes leading or trailing hyphens.\n *\n * @param label Raw string to sanitize\n * @returns Safe SemVer prerelease label\n */\nexport function sanitizePrereleaseLabel(label: string): string {\n return label\n .replace(/[^a-zA-Z0-9]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-+|-+$/g, '')\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 { GitRef, ResolvedReleaseRule } from '#types'\nimport { interpolate } from '#util'\nimport { sanitizePrereleaseLabel } from './sanitizePrereleaseLabel'\n\nexport interface ResolveReleaseChannelOptions {\n ref: GitRef\n rule: ResolvedReleaseRule | undefined\n templateParams: Record<string, unknown>\n channel: boolean | string | undefined\n}\n\n/**\n * Resolve the release channel for a release context.\n *\n * Uses the release rule when `channel` is `boolean` or omitted. Sanitizes the\n * reference name when enabling default channel resolution and interpolates\n * `templateParams` into the result.\n *\n * @param options Options for resolving the release channel\n * @returns Resolved release channel string or `undefined`\n */\nexport function resolveReleaseChannel(\n options: ResolveReleaseChannelOptions\n): string | undefined {\n const { ref, rule, templateParams } = options\n let { channel } = options\n let resolved: string | undefined\n\n if (channel === true || channel == null) {\n channel = rule?.releaseChannel ?? channel\n }\n\n if (typeof channel === 'string') {\n resolved = channel\n } else if (channel) {\n resolved = sanitizePrereleaseLabel(ref.name)\n }\n\n if (typeof resolved === 'string') {\n resolved = interpolate(resolved, templateParams)\n }\n\n return resolved\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ResolvedReleaseRule } from '#types'\nimport { interpolate } from '#util'\nimport { isSemVer } from './isSemVer'\n\nexport interface ResolveVersionQualifierOptions {\n rule: ResolvedReleaseRule | undefined\n templateParams: Record<string, unknown>\n qualifier: boolean | string | undefined\n}\n\n/**\n * Resolve the version qualifier for a release context.\n *\n * Uses the release rule when `qualifier` is `boolean` or omitted. Interpolates\n * `templateParams` into `qualifier` and validates that the result forms a\n * valid SemVer prerelease identifier.\n *\n * @param options Options for resolving the version qualifier\n * @returns Resolved version qualifier string or `undefined`\n * @throws If the resolved string is not a valid SemVer prerelease identifier\n */\nexport function resolveVersionQualifier(\n options: ResolveVersionQualifierOptions\n): string | undefined {\n const { rule, templateParams } = options\n let { qualifier } = options\n let resolved: string | undefined\n\n if (qualifier === true || qualifier == null) {\n qualifier = rule?.versionQualifier ?? qualifier\n }\n\n if (typeof qualifier === 'string') {\n resolved = qualifier\n } else if (qualifier) {\n resolved = ''\n }\n\n if (typeof resolved === 'string') {\n resolved = interpolate(resolved, templateParams)\n }\n\n if (resolved && !isSemVer(`1.0.0-${resolved}.1`)) {\n throw new Error(\n `The resolved version qualifier \"${resolved}\" is not a valid SemVer prerelease identifier.`\n )\n }\n\n return resolved\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Get the current Git branch name.\n *\n * Uses `execGit` to run `git symbolic-ref -q --short HEAD` in the provided\n * working directory and trims the result. Returns an empty string when the\n * repository is in a detached HEAD state.\n *\n * @param cwd The working directory to run the Git command in\n * @returns The current branch name as a string\n */\nexport async function getCurrentGitBranch(cwd: string): Promise<string> {\n return (await execGit(cwd, ['symbolic-ref', '-q', '--short', 'HEAD'])).trim()\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Stage all changes and create a git commit with the specified message.\n *\n * Validates the commit message and working directory status before staging\n * all changes and executing the commit command.\n *\n * @param cwd The target directory path for executing git commands\n * @param message The message to associate with the commit\n * @returns A promise that resolves when the operation completes\n */\nexport async function createGitCommit(\n cwd: string,\n message: string | null | undefined\n): Promise<void> {\n if (!message) return\n\n await execGit(cwd, ['add', '.'])\n\n const stdout = (await execGit(cwd, ['status', '--porcelain'])).trim()\n\n if (!stdout) return\n\n await execGit(cwd, ['commit', '--message', message])\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { GitCommit } from '#types'\nimport { getParsedGitCommit } from './getParsedGitCommit'\n\n/**\n * Resolve the current `HEAD` commit in the repository.\n *\n * @param cwd Repository working directory path\n * @param markers Optional array of custom trailer marker strings\n * @returns Parsed commit object for the current `HEAD` commit\n */\nexport function getCurrentGitCommit(\n cwd: string,\n markers: readonly string[] = []\n): Promise<GitCommit> {\n return getParsedGitCommit(cwd, 'HEAD', markers)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Convert a shallow clone into a full clone by fetching additional history.\n *\n * Runs `git fetch --unshallow`. Returns `true` when the operation succeeds\n * and `false` on error.\n *\n * @param cwd Repository working directory\n * @returns `true` when the operation succeeded, otherwise `false`\n */\nexport function restoreFullGitHistory(cwd: string): Promise<boolean> {\n return execGit(cwd, ['fetch', '--unshallow'])\n .then(() => true)\n .catch(() => false)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Get a local git configuration value for `key` in the repository at `cwd`.\n *\n * Returns the config value when present; otherwise `undefined`.\n *\n * @param cwd Repository working directory\n * @param key Git config key to read\n * @returns The config value or `undefined` if not set\n */\nexport async function getGitConfigValue(\n cwd: string,\n key: string\n): Promise<string | undefined> {\n try {\n const stdout = await execGit(cwd, ['config', '--local', '--get', key])\n const value = stdout.trim()\n\n return value ? value : undefined\n } catch {\n return undefined\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { GitAuthor } from '#types'\nimport { execGit } from '#util'\nimport { getGitConfigValue } from './getGitConfigValue'\n\n/**\n * Ensure Git user configuration is set and return a cleanup handle.\n *\n * Checks the existing `user.name` and `user.email` configuration for the given\n * working directory. Updates the configuration if either value is missing and\n * returns an `AsyncDisposable` resource that restores the original state upon\n * disposal.\n *\n * @param cwd Working directory path in which to check and set Git configuration\n * @param user Git author details containing name and email\n * @returns Async disposable cleanup object if updated, or undefined if already set\n */\nexport async function ensureGitUserConfig(\n cwd: string,\n user: GitAuthor\n): Promise<AsyncDisposable | undefined> {\n const initialName = await getGitConfigValue(cwd, 'user.name')\n const initialEmail = await getGitConfigValue(cwd, 'user.email')\n\n if (initialName && initialEmail) {\n return\n }\n\n // https://github.com/actions/checkout?tab=readme-ov-file#push-a-commit-using-the-built-in-token\n await execGit(cwd, ['config', 'user.name', user.name])\n await execGit(cwd, ['config', 'user.email', user.email])\n\n return {\n async [Symbol.asyncDispose]() {\n if (initialName) {\n await execGit(cwd, ['config', 'user.name', initialName])\n } else {\n await execGit(cwd, ['config', '--unset', 'user.name'])\n }\n\n if (initialEmail) {\n await execGit(cwd, ['config', 'user.email', initialEmail])\n } else {\n await execGit(cwd, ['config', '--unset', 'user.email'])\n }\n },\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Get the URL for the named remote (defaults to `origin`).\n *\n * @param cwd Repository working directory\n * @param remoteName Remote name (defaults to `'origin'`)\n * @returns Remote URL string or `null` when unavailable\n */\nexport function getGitRemote(\n cwd: string,\n remoteName = 'origin'\n): Promise<string | null> {\n return execGit(cwd, ['remote', 'get-url', remoteName])\n .then((stdout) => stdout.trim())\n .catch(() => null)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { compact, execGit } from '#util'\n\n/**\n * Push a branch and optional tags to the `origin` remote using an atomic push.\n *\n * @param cwd Repository working directory\n * @param branch Branch name to push\n * @param additionalTags Optional list of tag names to push alongside the branch\n * @returns Promise that resolves when the push completes\n */\nexport async function pushGitChanges(\n cwd: string,\n branch: string | null,\n ...additionalTags: readonly string[]\n): Promise<void> {\n await execGit(cwd, [\n 'push',\n 'origin',\n ...compact([branch, ...additionalTags]),\n '--atomic',\n '--no-verify',\n ])\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { GitRepository } from '#types'\nimport GitHost from 'hosted-git-info'\nimport { getGitRemote } from './getGitRemote'\n\n/**\n * Resolve Git repository host, owner, and project metadata from the `origin` remote URL.\n *\n * @param cwd Repository working directory\n * @returns Promise that resolves to a `GitRepository` object, or `null` when unavailable\n */\nexport async function resolveGitRepository(\n cwd: string\n): Promise<GitRepository | null> {\n const origin = await getGitRemote(cwd)\n\n if (!origin) {\n return null\n }\n\n const info = GitHost.fromUrl(origin)\n\n if (\n info &&\n typeof info.type === 'string' &&\n typeof info.user === 'string' &&\n typeof info.project === 'string'\n ) {\n return {\n host: info.type,\n owner: info.user,\n repo: info.project,\n url: info.browse(),\n }\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Create a git tag in the repository at `cwd`.\n *\n * Creates an annotated tag when `message` is provided.\n *\n * @param cwd Repository working directory\n * @param tag Tag name to create\n * @param message Optional tag message (creates an annotated tag when present)\n * @returns Promise that resolves when the tag is created\n */\nexport async function createGitTag(\n cwd: string,\n tag: string,\n message?: string\n): Promise<void> {\n await execGit(cwd, [\n 'tag',\n ...(message ? ['-a', tag, '-m', message, '--cleanup=whitespace'] : [tag]),\n ])\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Get the tag name that exactly matches the current `HEAD`, if any.\n *\n * @param cwd Repository working directory\n * @returns Tag name or `null` when no exact tag matches HEAD\n */\nexport async function getCurrentGitTag(cwd: string): Promise<string | null> {\n try {\n const stdout = await execGit(cwd, ['describe', '--tags', '--exact-match'])\n\n const tag = stdout.trim()\n\n /* istanbul ignore next */\n return tag ? tag : null\n } catch {\n return null\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Get the most recent tag reachable from `HEAD`.\n *\n * @param cwd Repository working directory\n * @returns Latest tag string or `null` when none is found\n */\nexport async function getLatestGitTag(cwd: string): Promise<string | null> {\n try {\n const stdout = await execGit(cwd, ['describe', '--tags', '--abbrev=0'])\n const tag = stdout.trim()\n\n /* istanbul ignore next */\n return tag ? tag : null\n } catch {\n return null\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Check whether a given tag points to the provided commit.\n *\n * @param cwd Repository working directory\n * @param tag Tag name to resolve\n * @param commit Commit hash to compare against\n * @returns `true` when the tag points at `commit`, otherwise `false`\n */\nexport async function isGitTagExact(\n cwd: string,\n tag: string,\n commit: string\n): Promise<boolean> {\n try {\n await execGit(cwd, [\n 'merge-base',\n '--is-ancestor',\n `refs/tags/${tag}^{commit}`,\n commit,\n ])\n\n await execGit(cwd, [\n 'merge-base',\n '--is-ancestor',\n commit,\n `refs/tags/${tag}^{commit}`,\n ])\n\n return true\n } catch {\n return false\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Package } from '#types'\nimport { isMatch } from '#util'\n\n/**\n * Filter packages by name patterns.\n *\n * Keeps the packages whose names match `patterns`, scoping a release run to\n * a subset of the discovered workspace. Returns a copy of every package when\n * `patterns` is empty.\n *\n * @param packages Workspace packages to filter\n * @param patterns Minimatch patterns to match package names against\n * @returns Packages whose names match the patterns\n */\nexport function filterPackages(\n packages: readonly Package[],\n patterns: readonly string[]\n): Package[] {\n if (patterns.length === 0) {\n return [...packages]\n }\n\n return packages.filter((pkg) => isMatch(pkg.name ?? '', patterns))\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 dependencies are placed first in the resulting array, ensuring that\n * a package always follows its own dependencies. Ties and circular dependencies\n * are resolved deterministically using an alphabetical sort on the package\n * location (`location`).\n *\n * @param packages The workspace packages to sort.\n * @returns A new array of packages sorted by dependency depth and location.\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","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { GIT_TRAILER_RELEASE_AGENT } from '#config'\nimport { mergeGitHistory } from '#git'\nimport type { GitCommit, GitCommitType, ReleasePlan } from '#types'\nimport { version } from '../../../package.json' with { type: 'json' }\n\nconst NOTABLE_TYPES: readonly GitCommitType[] = [\n 'feat',\n 'fix',\n 'perf',\n 'refactor',\n 'revert',\n]\n\n/**\n * Generate a formatted release commit message based on release plans and\n * custom trailers.\n *\n * Compiles package version updates and included commit logs into a standardized\n * conventional commit message body, appending configured release agent and\n * custom trailers. Returns `null` if no valid release subject can be derived.\n *\n * @param cwd The working directory path\n * @param plans Readonly array of release plans containing package changes and commit history\n * @param trailers Optional record of custom git trailers to append to the commit\n * @returns The formatted release commit message string or `null` if the subject is empty\n * @example\n * ```\n * chore: release pkg-a@2.1.0, pkg-b@1.0.4\n *\n * Version Updates:\n * - pkg-a: 2.0.0 → 2.1.0\n * - pkg-b: 1.0.3 → 1.0.4\n *\n * Notable Changes:\n * - feat(pkg-a): support custom plugin entrypoints (#210)\n * - fix(pkg-b): correct minor typography bug in help text (#212)\n *\n * Release-Mode: Deferred\n * ```\n */\nexport async function generateReleaseCommitMessage(\n cwd: string,\n plans: readonly ReleasePlan[],\n trailers: Readonly<Record<string, string | number | null | undefined>> = {}\n): Promise<string | null> {\n const standalone = plans.length === 1\n\n trailers = {\n [GIT_TRAILER_RELEASE_AGENT]: `ReelOut/${import.meta.env.MODE === 'test' ? '0.0.0' : /* istanbul ignore next */ version}`,\n ...trailers,\n }\n\n plans = plans\n .filter((plan) => plan.release?.tag?.name)\n .toSorted((a, b) => {\n if (a.package.entry) return -1\n if (b.package.entry) return 1\n /* istanbul ignore next */\n return (a.package.name ?? '').localeCompare(b.package.name ?? '')\n })\n\n let subject: string | null | undefined\n\n if (plans.length === 1) {\n subject = standalone\n ? plans[0]?.release?.version\n : plans[0]?.release?.tag?.name\n } else if (plans.length >= 2 && plans.length <= 3) {\n subject = plans.map((plan) => plan.release?.tag?.name).join(', ')\n } else if (plans.length > 3) {\n subject = `${plans.length} packages (${plans\n .slice(0, 2)\n .map((plan) => plan.release?.tag?.name)\n .join(', ')}, +${plans.length - 2} more)`\n }\n\n if (!subject) {\n return null\n }\n\n const packages = plans.map((plan) => {\n return `- ${plan.package.name || plan.package.location}: ${plan.package.version} → ${plan.release?.version}`\n })\n\n const commits = (\n await plans.reduce(\n async (acc, plan) => mergeGitHistory(cwd, await acc, plan.history),\n Promise.resolve<GitCommit[]>([])\n )\n )\n .filter((commit) => {\n const isNotableType = commit.type && NOTABLE_TYPES.includes(commit.type)\n const isBreaking = commit.notes.length > 0\n\n return isNotableType || isBreaking\n })\n .toReversed()\n .map(({ header }) => `- ${header}`)\n\n return [\n `chore: release ${subject}`,\n\n packages.length >= 2\n ? ['Version Updates:', ...packages].join('\\n')\n : undefined,\n\n commits.length > 0\n ? ['Notable Changes:', ...commits].join('\\n')\n : undefined,\n\n Object.entries(trailers)\n .map(([key, value]) => (key && value != null ? `${key}: ${value}` : ''))\n .filter(Boolean)\n .join('\\n'),\n ]\n .filter(Boolean)\n .join('\\n\\n')\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n GitRepository,\n ReleaseContext,\n ReleasePlan,\n ReleasePlugin,\n} from '../types'\nimport { formatError } from '../util/formatError'\n\n/**\n * Read the release token from the release environment.\n *\n * Treats unset and whitespace-only values as missing.\n *\n * @param env Release environment variables\n * @param tokenEnvKey Environment variable holding the release token\n * @returns The trimmed token, or undefined when it is not set\n */\nconst readToken = (\n env: ReleaseContext['env'],\n tokenEnvKey: string\n): string | undefined => {\n const token = env[tokenEnvKey]?.trim()\n\n return token ? token : undefined\n}\n\n/**\n * Options for {@link createHostReleasePlugin}.\n */\nexport interface HostReleasePluginOptions {\n /**\n * Plugin name reported to the workflow, such as `'@reelout/github'`.\n */\n name: string\n\n /**\n * Plugin version reported to the workflow.\n */\n version: string\n\n /**\n * Repository host the plugin publishes to, such as `'github'`. Compared\n * against the `host` of the release repository, so custom hosts are\n * supported as long as the repository detection reports them.\n */\n host: string\n\n /**\n * Human-readable host name used in log messages, such as `'GitHub'`.\n */\n displayName: string\n\n /**\n * Environment variable holding the release token, such as\n * `'GITHUB_TOKEN'`.\n */\n tokenEnvKey: string\n\n /**\n * Verify the release token against the target repository.\n *\n * Runs during the `configure` stage so a provided-but-invalid token fails\n * before any mutation, including under dry-run.\n *\n * @param token Release token\n * @param repository Target repository\n */\n verifyToken: (token: string, repository: GitRepository) => Promise<void>\n\n /**\n * Create the host release for a release plan.\n *\n * Runs during the `publish` stage for each finalized plan.\n *\n * @param context Release context\n * @param plan Release plan to publish\n * @param token Release token\n * @param repository Target repository\n * @returns Promise that resolves to a rollback callback for the release,\n * or undefined when creation was skipped\n */\n createRelease: (\n context: ReleaseContext,\n plan: ReleasePlan,\n token: string,\n repository: GitRepository\n ) => Promise<(() => Promise<void>) | void>\n}\n\n/**\n * A rollback callback for a created host release, paired with the tag of\n * the release it removes.\n */\ninterface ReleaseRollback {\n /**\n * Tag of the release the rollback removes.\n */\n tag: string\n\n /**\n * Callback that removes the created release.\n */\n rollback: () => Promise<void>\n}\n\n/**\n * Run the collected release rollbacks, logging individual rollback failures\n * without aborting the remaining rollbacks.\n *\n * @param logger Logger used to report rollback failures\n * @param displayName Human-readable host name used in log messages\n * @param rollbacks Rollbacks collected during publishing\n */\nconst rollbackReleases = async (\n logger: ReleaseContext['logger'],\n displayName: string,\n rollbacks: readonly ReleaseRollback[]\n): Promise<void> => {\n const results = await Promise.allSettled(\n rollbacks.map(({ rollback }) => rollback())\n )\n\n for (const [index, entry] of rollbacks.entries()) {\n const result = results[index]\n\n if (result?.status === 'rejected') {\n logger.error(\n `A ${displayName} release for tag \"${entry.tag}\" could not be rolled back: ${formatError(result.reason)}`\n )\n }\n }\n}\n\n/**\n * Create a built-in plugin that publishes releases to a git host.\n *\n * Produces the shared skeleton behind the host release plugins. The plugin\n * stays inactive unless the release repository is hosted on the given host,\n * and verifies the token during the `configure` stage: a missing token\n * skips the plugin's `publish` step with a debug message — or fails the run in\n * strict mode — and a provided token is verified against the release\n * repository before any mutation. During `publish`, host releases are\n * created in reverse alphabetical package order (ensuring the root package\n * release is created last) and rolled back when subsequent publishing\n * stages fail.\n *\n * @param options Host release plugin options\n * @returns A release plugin configured for the given host\n */\nexport function createHostReleasePlugin(\n options: HostReleasePluginOptions\n): ReleasePlugin {\n return {\n name: options.name,\n version: options.version,\n configure: async (context, next) => {\n const repository = context.repository\n\n if (repository?.host !== options.host) {\n context.logger.debug(\n `${options.displayName} releases will not be created: no ${options.displayName}-hosted repository was detected.`\n )\n\n return next(context)\n }\n\n const token = readToken(context.env, options.tokenEnvKey)\n\n if (!token) {\n if (context.strict) {\n throw new Error(\n `The ${options.tokenEnvKey} environment variable is required in strict mode.`\n )\n }\n\n context.logger.debug(\n `${options.displayName} releases will not be created: ${options.tokenEnvKey} is not set.`\n )\n\n return next(context)\n }\n\n await options.verifyToken(token, repository)\n\n return next(context)\n },\n publish: async (context, next) => {\n if (context.repository?.host !== options.host) {\n context.logger.debug(\n `${options.displayName} publishing was skipped: no ${options.displayName}-hosted repository was detected.`\n )\n\n return next(context)\n }\n\n const token = readToken(context.env, options.tokenEnvKey)\n\n if (!token) {\n return next(context)\n }\n\n if (context.dryRun) {\n context.logger.debug(\n `[DRY RUN] ${options.displayName} releases will not be created.`\n )\n\n return next(context)\n }\n\n const plans = context.plans.toSorted((a, b) =>\n (a.package.name || '').localeCompare(b.package.name || '')\n )\n\n const repository = context.repository\n\n const rollbacks: ReleaseRollback[] = []\n\n try {\n // Create releases in reverse order\n // so that the root package release is created last,\n // as it is often the most important one.\n for (const plan of plans.toReversed()) {\n const rollback = await options.createRelease(\n context,\n plan,\n token,\n repository\n )\n\n if (rollback) {\n rollbacks.push({\n tag: plan.release?.tag?.name ?? 'unknown',\n rollback,\n })\n }\n }\n } catch (err) {\n await rollbackReleases(context.logger, options.displayName, rollbacks)\n\n throw err\n }\n\n try {\n return await next(context)\n } catch (err) {\n await rollbackReleases(context.logger, options.displayName, rollbacks)\n\n throw err\n }\n },\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseOutcome } from '#types'\n\n/**\n * Resolve a displayable message from an unknown error value.\n *\n * Normalizes `Error` instances to their `message` and passes string values\n * through unchanged. Returns `null` for any other shape so callers can fall\n * back to a generic message.\n *\n * @param error Unknown error value carried on a release outcome\n * @returns The resolved error message, or `null` when none can be resolved\n */\nexport function resolveErrorMessage(error: unknown): string | null {\n if (Error.isError(error)) return error.message\n\n return typeof error === 'string' ? error : null\n}\n\nconst FALLBACK_ERROR_MESSAGE =\n 'An unexpected error occurred during the release process.'\n\n/**\n * Resolve a displayable failure message from a release outcome.\n *\n * Normalizes the outcome error to its message and falls back to a generic\n * message when the error carries no displayable content.\n *\n * @param outcome Failure outcome whose error is rendered\n * @returns The resolved error message, or the fallback message\n */\nexport function resolveOutcomeErrorMessage(outcome: ReleaseOutcome): string {\n return resolveErrorMessage(outcome.error) || FALLBACK_ERROR_MESSAGE\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseReport } from '#types'\nimport { isGitHubActions } from '#util'\nimport type { ConsolaInstance } from 'consola/core'\nimport { appendFileSync } from 'node:fs'\nimport { resolveOutcomeErrorMessage } from './resolveErrorMessage'\n\nconst STATUS_LABELS = {\n success: 'Success',\n failure: 'Failure',\n} as const\n\ntype ReportPlan = ReleaseReport['plans'][number]\n\n/**\n * Append a Markdown release report to the GitHub Actions job summary.\n *\n * Detects a GitHub Actions runner through the `GITHUB_ACTIONS` environment\n * variable and appends the rendered `report` to the file referenced by\n * `GITHUB_STEP_SUMMARY`, so GitHub displays it on the run summary page. Dry\n * runs append a `(dry run)` marker to the status line; real releases render\n * the status unmarked. Does nothing outside GitHub Actions or when no summary\n * file is configured, and logs a warning instead of throwing when the summary\n * file cannot be written.\n *\n * @param logger Logger instance for reporting summary write failures\n * @param env Readonly process environment variables object\n * @param report Release report containing outcome and package details\n */\nexport function appendReleaseReportSummary(\n logger: ConsolaInstance,\n env: Readonly<NodeJS.ProcessEnv>,\n report: ReleaseReport\n): void {\n if (!isGitHubActions(env)) return\n\n const filePath = env.GITHUB_STEP_SUMMARY\n\n if (!filePath) return\n\n try {\n appendFileSync(filePath, `\\n${formatReleaseReportSummary(report)}`)\n } catch (error) {\n logger.warn(\n `GitHub Actions job summary could not be written to \"${filePath}\": ${error instanceof Error ? error.message : error}`\n )\n }\n}\n\nconst formatPackageLabel = (plan: ReportPlan): string => {\n if (plan.package.name) return `\\`${plan.package.name}\\``\n\n return `\\`${plan.package.location}\\``\n}\n\nconst formatReleaseReportSummary = (report: ReleaseReport): string => {\n const lines: string[] = ['## ReelOut Release Report', '']\n\n if (report.outcome) {\n const status = STATUS_LABELS[report.outcome.status]\n const label = report.dryRun ? `${status} (dry run)` : status\n\n lines.push(`**Status:** ${label}`, '')\n }\n\n if (report.outcome?.status === 'failure') {\n const message = resolveOutcomeErrorMessage(report.outcome)\n\n lines.push(...message.split('\\n').map((line) => `> ${line}`), '')\n\n return lines.join('\\n')\n }\n\n if (report.plans.length === 0) {\n lines.push('No packages are scheduled for release.', '')\n\n return lines.join('\\n')\n }\n\n const plans = report.plans.toSorted((a, b) =>\n (a.package.name || '').localeCompare(b.package.name || '')\n )\n\n lines.push('| Package | Version | Type | Tag |', '| --- | --- | --- | --- |')\n\n for (const plan of plans) {\n const version = `\\`${plan.release.version}\\` ← \\`${plan.package.version}\\``\n\n lines.push(\n [\n `| ${formatPackageLabel(plan)}`,\n version,\n plan.release.type,\n plan.release.tag ? `\\`${plan.release.tag}\\`` : '',\n ].join(' | ') + ' |'\n )\n }\n\n lines.push('')\n\n for (const plan of plans) {\n const changelog = plan.release.changelog?.trim()\n\n if (!changelog) continue\n\n lines.push(\n '<details>',\n `<summary>${formatPackageLabel(plan)} ${plan.release.version}</summary>`,\n '',\n changelog,\n '',\n '</details>',\n ''\n )\n }\n\n return lines.join('\\n')\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseContext, ReleaseReport } from '#types'\nimport { compact } from '#util'\n\n/**\n * Generate a structured release report from the current workflow state.\n *\n * Extracts state information from `context` and organizes it into a report\n * containing the `dryRun` flag, the terminal release outcome, release plans,\n * and package metadata. Omits unversioned release plans from the finalized\n * output.\n *\n * @param context Release execution context containing workflow state and plans\n * @returns Structured release report object containing workflow results\n */\nexport function generateReleaseReport(context: ReleaseContext): ReleaseReport {\n return {\n dryRun: context.dryRun,\n outcome: context.outcome,\n packages: context.packages.map((pkg) => ({\n location: pkg.location,\n name: pkg.name,\n version: pkg.version,\n })),\n plans: compact(\n context.plans.map((plan) => {\n if (!plan.release?.version) return null\n\n return {\n package: {\n provider: plan.package.provider,\n entry: plan.package.entry,\n location: plan.package.location,\n name: plan.package.name,\n version: plan.package.version,\n private: !!plan.package.private,\n },\n release: {\n type: plan.release.type,\n version: plan.release.version,\n tag: plan.release.tag?.name,\n changelog: plan.release.changelog,\n },\n }\n })\n ),\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseReport } from '#types'\nimport type { ConsolaInstance } from 'consola/core'\nimport { colors } from 'consola/utils'\nimport path from 'node:path'\nimport { resolveOutcomeErrorMessage } from './resolveErrorMessage'\n\n/**\n * Print a formatted release report to the logger.\n *\n * Logs the terminal outcome status and details for planned package releases.\n * Displays package names, directories, and version changes on success, or\n * outputs the error message on failure. Dry runs append a `(dry run)` marker\n * to the status line; real releases print the status unmarked.\n *\n * @param logger Logger instance for outputting messages\n * @param report Release report containing outcome and package details\n */\nexport function printReleaseReport(\n logger: ConsolaInstance,\n report: ReleaseReport\n): void {\n if (report.outcome) {\n const statusLabel = {\n success: colors.green('SUCCESS'),\n failure: colors.red('FAILURE'),\n }[report.outcome.status]\n\n logger.info(\n `Status: ${[statusLabel, report.dryRun && colors.yellow('(dry run)')].filter(Boolean).join(' ')}`\n )\n }\n\n if (report.outcome?.status === 'failure') {\n return logger.error(\n [\n 'Release complete:',\n colors.red(resolveOutcomeErrorMessage(report.outcome)),\n ].join(' ')\n )\n }\n\n if (report.plans.length === 0) {\n return logger.info(\n [\n 'Release complete:',\n colors.yellow('No packages are scheduled for release.'),\n ].join(' ')\n )\n }\n\n const header = [\n 'Release complete:',\n colors.bold(colors.green(`${report.plans.length} released`)),\n colors.gray(`(${report.packages.length})`),\n ].join(' ')\n\n const list = report.plans\n .toSorted((a, b) =>\n (a.package.name || '').localeCompare(b.package.name || '')\n )\n .map((plan) => {\n let dir = path.normalize(path.join(plan.package.location, '.'))\n\n dir = dir === '.' ? dir : `./${dir}`\n\n const name = plan.package.name\n ? colors.bgBlue(` ${plan.package.name} `)\n : !plan.package.entry && colors.gray(` ${dir} `)\n\n let version = [plan.release.version, plan.package.version].join(' ← ')\n\n version = ` ${version} `\n\n // `Release.type` is non-optional on the type level, but report data built\n // by hooks and tests can reach this view without a derived type, so the\n // guard keeps the report readable instead of printing \"undefined\".\n const type = plan.release.type\n ? colors.gray(` ${plan.release.type} `)\n : undefined\n\n const summary = [\n name,\n plan.release.type === 'major'\n ? colors.bgRed(version)\n : colors.bgGreen(version),\n type,\n ]\n .filter(Boolean)\n .join('')\n\n const changelog = plan.release.changelog\n ?.replace(/^(#+ .+)$/gm, (_, header) => colors.cyan(header))\n .trim()\n\n return [summary, changelog].filter(Boolean).join('\\n\\n')\n })\n .join('\\n\\n')\n\n logger.info(`${header}\\n\\n${list}\\n`)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseReport } from '#types'\nimport { isGitHubActions } from '#util'\nimport { resolveOutcomeErrorMessage } from './resolveErrorMessage'\n\n/**\n * Print a GitHub Actions error annotation for a failed release.\n *\n * Detects a GitHub Actions runner through the `GITHUB_ACTIONS` environment\n * variable and writes a `::error` workflow command carrying the failure\n * reason to `stdout`, so GitHub surfaces the failure as an annotation on the\n * run page. Does nothing outside GitHub Actions or when the release did not\n * fail.\n *\n * @param env Readonly process environment variables object\n * @param stdout Writable stream receiving the annotation command\n * @param report Release report containing outcome and failure details\n */\nexport function printReleaseReportAnnotation(\n env: Readonly<NodeJS.ProcessEnv>,\n stdout: NodeJS.WritableStream,\n report: ReleaseReport\n): void {\n if (!isGitHubActions(env) || report.outcome?.status !== 'failure') return\n\n const message = formatAnnotationMessage(\n resolveOutcomeErrorMessage(report.outcome)\n )\n\n stdout.write(`::error title=Release failed::${message}\\n`)\n}\n\nconst formatAnnotationMessage = (message: string): string =>\n message.replaceAll('%', '%25').replaceAll('\\r', '%0D').replaceAll('\\n', '%0A')\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { RELEASE_HOOK_NAMES } from '#config'\nimport { HookDispatcher, type Middleware } from '#plugin'\nimport type {\n ReleaseContext,\n ReleaseHookDefinition,\n ReleaseHookName,\n ReleasePlugin,\n} from '#types'\nimport { colors } from 'consola/utils'\nimport {\n appendReleaseReportSummary,\n generateReleaseReport,\n printReleaseReport,\n printReleaseReportAnnotation,\n} from './report'\n\n/** Failure of a hook middleware, recorded with the owning hook and plugin. */\ninterface MiddlewareFailure {\n hook: ReleaseHookName\n plugin: string\n error: unknown\n}\n\n/**\n * Resolve a plugin's hook entry into a normalized hook definition.\n *\n * Accepts a bare middleware function or a `{ priority, middleware }`\n * definition and extracts its middleware and priority.\n *\n * @param hookName Name of the hook to resolve\n * @param plugin Plugin owning the hook entry\n * @returns Normalized hook definition, or `undefined` when unimplemented\n */\nfunction resolvePluginHook(\n hookName: ReleaseHookName,\n plugin: ReleasePlugin\n): ReleaseHookDefinition | undefined {\n let hook = plugin[hookName]\n\n if (typeof hook === 'function') {\n hook = { middleware: hook }\n }\n\n const middleware = hook?.middleware\n const priority = hook?.priority\n\n if (!middleware) return\n\n return { priority, middleware }\n}\n\n/**\n * Throw a cancellation error when the context abort signal has fired.\n *\n * Wraps the underlying `AbortError` so the workflow reports a readable\n * cancellation instead of a bare DOM exception.\n *\n * @param context Release execution context carrying the optional abort signal\n * @throws If the context abort signal has already fired\n */\nfunction throwIfCancelled(context: ReleaseContext): void {\n const signal = context.signal\n\n if (!signal?.aborted) return\n\n try {\n signal.throwIfAborted()\n } catch (err) {\n throw new Error('Release cancelled.', { cause: err })\n }\n}\n\n/**\n * Format a duration in milliseconds as a seconds string.\n *\n * @param duration Duration in milliseconds\n * @returns Duration formatted as seconds with two decimal places\n */\nfunction formatDuration(duration: number): string {\n return `${(duration / 1000).toFixed(2)}s`\n}\n\n/**\n * Pick the console color for a duration, highlighting slow middleware.\n *\n * @param duration Duration in milliseconds\n * @returns Color function that highlights durations of five seconds or more\n */\nfunction durationColor(duration: number): (text: string) => string {\n return duration >= 5000 ? colors.yellow : colors.cyan\n}\n\n/**\n * Format a hook and its owning plugin as a display label.\n *\n * @param hook Name of the hook\n * @param plugin Name of the plugin owning the hook\n * @returns Gray hook name followed by the plugin name\n */\nfunction hookLabel(hook: ReleaseHookName, plugin: string): string {\n return `${colors.gray(`[${hook}]`)} ${plugin}`\n}\n\n/**\n * Execute the complete release workflow across all configured plugins.\n *\n * Runs each lifecycle phase sequentially, dispatching plugin hooks in onion\n * order based on declared priority, and checks the abort signal before each\n * phase. Each dispatched middleware runs through a single constructor\n * interceptor that also attributes failures to the owning hook and plugin,\n * collects middleware failures, and rescues `finalize` errors so the\n * remaining `finalize` middleware still runs. Outside `test` mode the\n * interceptor logs every middleware's exclusive duration — its wall-clock\n * time minus the time consumed by downstream middleware — on completion.\n * When a phase hook throws, plugin rollbacks run while the error unwinds,\n * then every `finalize` middleware runs with the failure recorded on\n * `context.outcome`. Each `finalize` failure is logged as a warning after\n * the report. A failing `finalize` middleware never changes the workflow\n * outcome and never masks the original workflow error.\n *\n * @param context Release execution context containing runtime options and logger\n * @param plugins List of release plugins to execute\n * @returns Promise that resolves when all phases and `finalize` middleware\n * complete\n * @throws If a lifecycle hook fails or the workflow is cancelled\n */\nexport async function executeReleaseWorkflow(\n context: ReleaseContext,\n plugins: readonly ReleasePlugin[]\n): Promise<void> {\n context.outcome = null\n\n const isSilent = import.meta.env.MODE === 'test'\n\n const middlewareFailures: MiddlewareFailure[] = []\n\n const dispatcher = new HookDispatcher<\n Record<ReleaseHookName, Middleware<ReleaseContext>>,\n ReleasePlugin\n >(async (context, registration, next) => {\n const plugin = registration.meta\n\n /* istanbul ignore next */\n if (!plugin) {\n throw new Error(\n `Registration for hook \"${registration.hook}\" is missing plugin metadata.`\n )\n }\n\n const hook = registration.hook\n const label = hookLabel(hook, plugin.name)\n\n if (!isSilent) {\n context.logger.start(label)\n }\n\n const startedAt = performance.now()\n let downstreamDuration = 0\n\n const runNext = async () => {\n const downstreamStart = performance.now()\n\n try {\n return await next(context)\n } finally {\n downstreamDuration += performance.now() - downstreamStart\n }\n }\n\n const finish = (hasError: boolean): void => {\n if (isSilent) return\n\n const duration = performance.now() - startedAt - downstreamDuration\n const color = durationColor(duration)\n const message = [label, color(formatDuration(duration))].join(' ')\n\n if (hasError) {\n context.logger.error(message)\n } else {\n context.logger.success(message)\n }\n }\n\n try {\n const result = await registration.middleware.call(\n plugin,\n context,\n runNext\n )\n\n finish(false)\n\n return result\n } catch (error) {\n const phase = { hook, plugin: plugin.name }\n\n middlewareFailures.push({ ...phase, error })\n\n context.outcome ??= {\n status: 'failure',\n error,\n phase,\n }\n\n finish(true)\n\n if (hook === 'finalize') return next(context)\n\n throw error\n }\n })\n\n for (const hookName of RELEASE_HOOK_NAMES) {\n for (const plugin of plugins) {\n const definition = resolvePluginHook(hookName, plugin)\n\n if (!definition) continue\n\n dispatcher.on(hookName, definition.middleware, {\n priority: definition.priority,\n meta: plugin,\n })\n }\n }\n\n const dispatch = async (\n index: number,\n context: ReleaseContext\n ): Promise<void> => {\n const hook = RELEASE_HOOK_NAMES[index]\n\n if (!hook) return\n\n if (hook === 'finalize') return await dispatch(index + 1, context)\n\n throwIfCancelled(context)\n\n return await dispatcher.dispatch(hook, context, (context) =>\n dispatch(index + 1, context)\n )\n }\n\n try {\n await dispatch(0, context)\n\n context.outcome = {\n status: 'success',\n error: null,\n phase: null,\n }\n } catch (err) {\n context.outcome ??= {\n status: 'failure',\n error: err,\n phase: null,\n }\n }\n\n await dispatcher.dispatch('finalize', context)\n\n const report = generateReleaseReport(context)\n\n printReleaseReport(context.logger, report)\n appendReleaseReportSummary(context.logger, context.env, report)\n printReleaseReportAnnotation(context.env, context.stdout, report)\n\n for (const failure of middlewareFailures) {\n if (failure.hook !== 'finalize') continue\n if (failure.error === context.outcome.error) continue\n\n context.logger.warn(\n `Plugin \"${failure.plugin}\" could not finalize: ${\n failure.error instanceof Error\n ? failure.error.message\n : String(failure.error)\n }`\n )\n }\n\n if (context.outcome.status === 'failure') {\n throw context.outcome.error\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,gBAAgB,SAA0B;CACxD,MAAM,SAAS,OAAO,MAAM,OAAO;CAEnC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,gBAAgB,OAAO,KAAK,OAAO,EAAE,yBACvC;CAGF,OAAO,OAAO,QAAQ,KAAK,OAAO,WAAW,WAAW;AAC1D;;;ACvBA,IAAM,iBAAiB;;;;;;;;;;;;;;AA4BvB,SAAgB,qBACd,SACA,SACsB;CACtB,MAAM,aAAa,IAAI,WAAW;CAClC,MAAM,aAAa,IAAI,WAAW;CAElC,OAAO;EACL,QAAQ,sBACN,QAAQ,OAAO,QAAQ,SAAS,KAAA,GAChC,UACF;EACA,QAAQ,sBACN,QAAQ,OAAO,QAAQ,SAAS,KAAA,GAChC,UACF;EACA,kBAAkB,WAAW,KAAK,CAAC,CAAC,KAAK;EACzC,uBAAuB,WAAW,KAAK,CAAC,CAAC,KAAK,KAAK,WAAW,KAAK,CAAC,CAAC,KAAK;CAC5E;AACF;;;;;;;;;;;;;AAcA,SAAgB,0BACd,OACA,SACS;CACT,MAAM,QAAQ,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,K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