@reelout/core 0.14.1 → 0.14.2
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.
- package/dist/{HookDispatcher-B_TrMRLU.js → HookDispatcher-BhDq-Kju.js} +3 -3
- package/dist/{HookDispatcher-B_TrMRLU.js.map → HookDispatcher-BhDq-Kju.js.map} +1 -1
- package/dist/analyzer.js +4 -4
- package/dist/{buildChangelog-CkytKypk.js → buildChangelog-KqS15vOE.js} +2 -2
- package/dist/{buildChangelog-CkytKypk.js.map → buildChangelog-KqS15vOE.js.map} +1 -1
- package/dist/{buildReleaseNotes-Dk4bEclG.js → buildReleaseNotes-D12vnood.js} +4 -4
- package/dist/{buildReleaseNotes-Dk4bEclG.js.map → buildReleaseNotes-D12vnood.js.map} +1 -1
- package/dist/builder.js +3 -3
- package/dist/changelog.js +4 -4
- package/dist/index.js +7 -7
- package/dist/{package-la-hLPRR.js → package-ZT0zvko1.js} +11 -2
- package/dist/package-ZT0zvko1.js.map +1 -0
- package/dist/{propagateDependencyUpdates-xcPvP5SP.js → propagateDependencyUpdates-uFNP3wOj.js} +3 -3
- package/dist/{propagateDependencyUpdates-xcPvP5SP.js.map → propagateDependencyUpdates-uFNP3wOj.js.map} +1 -1
- package/dist/{readPackageHistory-6dC72rZk.js → readPackageHistory-CpX-1QuK.js} +2 -2
- package/dist/{readPackageHistory-6dC72rZk.js.map → readPackageHistory-CpX-1QuK.js.map} +1 -1
- package/dist/{resolvePackageTag-2ldvH7PC.js → resolvePackageTag-pPUPCCmI.js} +2 -2
- package/dist/{resolvePackageTag-2ldvH7PC.js.map → resolvePackageTag-pPUPCCmI.js.map} +1 -1
- package/package.json +1 -1
- package/src/types.ts +5 -0
- package/src/util/execCommand.ts +9 -0
- package/dist/package-la-hLPRR.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as execGit, a as generateGitTagName, i as getGitTagMessage, n as verifyPackageTag, u as resolveGitRevision } from "./package-
|
|
2
|
-
import { a as formatFile, n as iterateChangelogVersions } from "./buildChangelog-
|
|
1
|
+
import { T as execGit, a as generateGitTagName, i as getGitTagMessage, n as verifyPackageTag, u as resolveGitRevision } from "./package-ZT0zvko1.js";
|
|
2
|
+
import { a as formatFile, n as iterateChangelogVersions } from "./buildChangelog-KqS15vOE.js";
|
|
3
3
|
import fs, { readFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
@@ -233,4 +233,4 @@ var HookDispatcher = class {
|
|
|
233
233
|
};
|
|
234
234
|
export { discoverPackageTag as a, prependChangelog as i, Priority as n, extractLatestVersion as o, writeChangelog as r, readGitFile as s, HookDispatcher as t };
|
|
235
235
|
|
|
236
|
-
//# sourceMappingURL=HookDispatcher-
|
|
236
|
+
//# sourceMappingURL=HookDispatcher-BhDq-Kju.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HookDispatcher-B_TrMRLU.js","names":[],"sources":["../src/git/revision/readGitFile.ts","../src/workflow/changelog/extractLatestVersion.ts","../src/workflow/discovery/discoverPackageTag.ts","../src/workflow/changelog/prependChangelog.ts","../src/workflow/changelog/writeChangelog.ts","../src/plugin/HookDispatcher.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Read a file's contents from a specific Git revision.\n *\n * Runs `git show <ref>:<filePath>` and returns the command output as a\n * string. If the file does not exist at the given revision or the Git\n * command fails for any reason, the function returns `null`.\n *\n * The returned string is the raw file contents as emitted by Git; callers\n * that need binary-safe handling should decode or process the bytes\n * accordingly. This function intentionally swallows Git errors and signals\n * absence via a `null` result rather than throwing.\n *\n * @param cwd Repository working directory\n * @param ref Commit-ish reference (commit SHA, tag, or branch) to read from\n * @param filePath Path to the file relative to the repository root\n * @returns File contents as a string, or `null` if the file is unavailable at the ref\n */\nexport function readGitFile(\n cwd: string,\n ref: string,\n filePath: string\n): Promise<string | null> {\n return execGit(cwd, ['show', `${ref}:${filePath}`]).catch(() => null)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { iterateChangelogVersions } from './iterateChangelogVersions'\n\n/**\n * Find the highest semantic version from the first version-bearing element.\n *\n * Pulls the first available version string from the parsed markdown iterator.\n * Short-circuits execution immediately upon locating a match to avoid passing\n * through the remaining document structure.\n *\n * @param changelogContent The raw markdown string representing the changelog\n * @returns The highest valid semantic version string found or null\n */\nexport function extractLatestVersion(changelogContent: string): string | null {\n for (const version of iterateChangelogVersions(changelogContent)) {\n return version\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport {\n generateGitTagName,\n getGitTagMessage,\n readGitFile,\n resolveGitRevision,\n} from '#git'\nimport type { EnsureGitTagOptions } from '#git'\nimport type { Package, Tag } from '#types'\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { extractLatestVersion } from '../changelog/extractLatestVersion'\nimport { verifyPackageTag } from './verifyPackageTag'\n\n/**\n * Discover and validate the Git tag for a package.\n *\n * Returns the existing tag if already present on the `pkg` object. Resolves\n * the local changelog file path, extracts the current version, and generates\n * the expected Git tag name. Verifies the tag against the repository and\n * ensures its historical changelog version matches the current local version.\n *\n * @param cwd The current working directory\n * @param pkg The package configuration object\n * @param options Dry-run and logging guards for the local tag cleanup\n * @returns The validated `Tag` object or null if validation fails\n */\nexport async function discoverPackageTag(\n cwd: string,\n pkg: Package,\n options?: EnsureGitTagOptions\n): Promise<Tag | null> {\n if (pkg.tag) {\n return pkg.tag\n }\n\n const changelogFile = pkg.changelogFile || DEFAULT_CHANGELOG_FILE\n\n const changelogFilePath = path.resolve(cwd, pkg.location, changelogFile)\n\n let localChangelogContent: string | null | undefined\n\n try {\n localChangelogContent = await readFile(changelogFilePath, 'utf-8')\n } catch {}\n\n if (!localChangelogContent) {\n return null\n }\n\n const currentVersion = extractLatestVersion(localChangelogContent)\n\n if (!currentVersion) {\n return null\n }\n\n let expectedTagName: string | null | undefined\n\n try {\n expectedTagName = generateGitTagName(pkg.entry, pkg.name, currentVersion)\n } catch {}\n\n if (!expectedTagName) {\n return null\n }\n\n if (!(await verifyPackageTag(cwd, pkg, expectedTagName, options))) {\n return null\n }\n\n const tagRef = `refs/tags/${expectedTagName}`\n\n const historicalChangelogContent = await readGitFile(\n cwd,\n await resolveGitRevision(cwd, tagRef),\n path.relative(cwd, changelogFilePath)\n )\n\n if (!historicalChangelogContent) {\n return null\n }\n\n const historicalChangelogVersion = extractLatestVersion(\n historicalChangelogContent\n )\n\n if (\n !historicalChangelogVersion ||\n historicalChangelogVersion !== currentVersion\n ) {\n return null\n }\n\n return {\n name: expectedTagName,\n message: await getGitTagMessage(cwd, expectedTagName),\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { formatFile } from '#util'\nimport type { ConsolaInstance } from 'consola/core'\nimport { fromMarkdown } from 'mdast-util-from-markdown'\nimport { toMarkdown } from 'mdast-util-to-markdown'\nimport fs from 'node:fs/promises'\n\nconst defaultChangelogTitle = 'Changelog'\n\n/**\n * Prepend changelog content to a markdown file, creating it if necessary.\n *\n * Reads the existing file if present, prepends the new content before the main heading,\n * formats and writes the result back.\n *\n * @param filePath Path to the changelog file\n * @param revision Changelog content to prepend\n * @param logger Optional logger that receives formatting failures\n * @returns Promise that resolves when the changelog is written\n */\nexport async function prependChangelog(\n filePath: string,\n revision: string,\n logger?: ConsolaInstance\n): Promise<void> {\n let content = ''\n\n try {\n content = await fs.readFile(filePath, 'utf-8')\n } catch (err) {\n /* istanbul ignore next */\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw err\n }\n }\n\n const root = fromMarkdown(content)\n\n let index = root.children.findIndex(\n (node) => node.type === 'heading' && node.depth === 1\n )\n\n if (index === -1) {\n index = 0\n\n root.children.unshift({\n type: 'heading',\n depth: 1,\n children: [{ type: 'text', value: defaultChangelogTitle }],\n })\n }\n\n root.children.splice(index + 1, 0, ...fromMarkdown(revision).children)\n\n content = toMarkdown(root)\n\n content = await formatFile(filePath, content, logger)\n\n await fs.writeFile(filePath, content)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport type { ReleasePlan } from '#types'\nimport type { ConsolaInstance } from 'consola/core'\nimport path from 'node:path'\nimport { prependChangelog } from './prependChangelog'\n\n/**\n * Write changelog content to the file system based on the release plan.\n *\n * @param cwd Repository working directory\n * @param plan Release plan containing package and changelog content\n * @param logger Optional logger that receives formatting failures\n * @returns Promise that resolves when the changelog file has been written\n */\nexport async function writeChangelog(\n cwd: string,\n plan: ReleasePlan,\n logger?: ConsolaInstance\n): Promise<void> {\n if (plan.release?.changelog) {\n const changelogFile = plan.package.changelogFile || DEFAULT_CHANGELOG_FILE\n\n const filePath = path.join(cwd, plan.package.location, changelogFile)\n\n await prependChangelog(filePath, plan.release.changelog, logger)\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Continuation that resumes the chain with the following middleware.\n */\nexport type Next<Context> = (context: Context) => Promise<void>\n\n/**\n * Function executed as a single link in a hook dispatch chain.\n */\nexport type Middleware<Context> = {\n bivariant(context: Context, next: Next<Context>): void | Promise<void>\n}['bivariant']\n\n/**\n * Priority ranks that order middleware within a hook.\n */\nexport const Priority = {\n High: 50,\n Normal: 0,\n Low: -50,\n} as const\n\n/**\n * Registration options accepted by `on`.\n */\nexport interface RegistrationOptions<Meta> {\n priority?: number | undefined\n meta?: Meta | undefined\n}\n\n/**\n * A registration entry captured by `on`.\n *\n * Carries the `middleware`, its `priority` sort rank, and the `meta` exposed\n * to the constructor interceptor.\n */\nexport interface Registration<HookName, Context, Meta = undefined> {\n hook: HookName\n priority: number\n middleware: Middleware<Context>\n meta: Meta | undefined\n}\n\n/**\n * Intercept a registered middleware during dispatch.\n *\n * Runs in place of every registered middleware, receiving the shared\n * `context`, the `registration` being dispatched — including its `priority`\n * and `meta` — and the `next` function that continues with the following\n * middleware.\n */\nexport type Interceptor<HookName, Context, Meta = undefined> = (\n context: Context,\n registration: Registration<HookName, Context, Meta>,\n next: Next<Context>\n) => void | Promise<void>\n\ntype InferContext<M extends Middleware<unknown>> =\n M extends Middleware<infer Context> ? Context : never\n\n/**\n * Dispatch registered hooks through asynchronous execution chains.\n *\n * Stores middleware in a prioritized registry and executes them sequentially\n * in priority order.\n */\nexport class HookDispatcher<\n HookMap extends Record<keyof HookMap, Middleware<unknown>>,\n Meta = undefined,\n> {\n readonly #registry = new Map<\n keyof HookMap,\n Registration<keyof HookMap, InferContext<HookMap[keyof HookMap]>, Meta>[]\n >()\n\n readonly #interceptor:\n | Interceptor<keyof HookMap, InferContext<HookMap[keyof HookMap]>, Meta>\n | undefined\n\n /**\n * Create a hook dispatcher.\n *\n * @param interceptor Wrapper invoked in place of every registered\n * middleware during dispatch\n */\n constructor(\n interceptor?: Interceptor<\n keyof HookMap,\n InferContext<HookMap[keyof HookMap]>,\n Meta\n >\n ) {\n this.#interceptor = interceptor\n }\n\n /**\n * Register middleware for a specific hook.\n *\n * Adds the `middleware` to the internal registry for `hook` and sorts the\n * list so higher-priority middleware runs first. An omitted or `undefined`\n * `options.priority` defaults to `Priority.Normal`; `options.meta` is\n * carried on the registration for the constructor interceptor.\n *\n * @param hook Name of the hook to register\n * @param middleware Function executed when the hook dispatches\n * @param options Registration options carrying the execution order rank and\n * the metadata exposed to the constructor interceptor\n */\n on<HookName extends keyof HookMap>(\n hook: HookName,\n middleware: Middleware<InferContext<HookMap[HookName]>>,\n options?: RegistrationOptions<Meta>\n ): void {\n const registrations = this.#registry.get(hook) ?? []\n\n registrations.push({\n hook,\n middleware,\n priority: options?.priority ?? Priority.Normal,\n meta: options?.meta,\n })\n\n registrations.sort((a, b) => b.priority - a.priority)\n\n this.#registry.set(hook, registrations)\n }\n\n /**\n * Unregister middleware from a specific hook.\n *\n * Removes matching `middleware` references from the internal registry for\n * `hook`. Takes no action if `hook` has no registered middleware.\n *\n * @param hook Name of the hook to unregister from\n * @param middleware Reference of the middleware function to remove\n */\n off<HookName extends keyof HookMap>(\n hook: HookName,\n middleware: Middleware<InferContext<HookMap[HookName]>>\n ): void {\n const registrations = this.#registry.get(hook)\n\n if (!registrations) return\n\n this.#registry.set(\n hook,\n registrations.filter(\n (registration) => registration.middleware !== middleware\n )\n )\n }\n\n /**\n * Dispatch all middleware registered to a hook.\n *\n * Passes `context` through the middleware pipeline in descending priority\n * order and dispatches each registration through the constructor\n * interceptor when one is provided. Enables middleware to control\n * execution flow using `next` and executes `done` after the last\n * middleware completes.\n *\n * @param hook Name of the hook to dispatch\n * @param context Shared payload passed into each middleware\n * @param done Optional final callback run after the pipeline completes\n * @returns Promise that resolves when execution completes\n */\n async dispatch<HookName extends keyof HookMap>(\n hook: HookName,\n context: InferContext<HookMap[HookName]>,\n done?: Next<InferContext<HookMap[HookName]>>\n ): Promise<void> {\n type Context = InferContext<HookMap[HookName]>\n\n const registrations = this.#registry.get(hook) ?? []\n\n const interceptor = this.#interceptor\n\n const run = async (index: number, context: Context): Promise<void> => {\n const registration = registrations[index]\n\n if (!registration) {\n return done ? await done(context) : undefined\n }\n\n let isNextCalled = false\n\n const next: Next<Context> = async (context) => {\n if (isNextCalled) return\n isNextCalled = true\n return await run(index + 1, context)\n }\n\n const middleware: Middleware<Context> = interceptor\n ? (context, next) => interceptor(context, registration, next)\n : registration.middleware\n\n return await middleware(context, next)\n }\n\n return await run(0, context)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,YACd,KACA,KACA,UACwB;CACxB,OAAO,QAAQ,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,YAAY,IAAI;AACtE;;;;;;;;;;;;ACbA,SAAgB,qBAAqB,kBAAyC;CAC5E,KAAK,MAA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;;;CAgBA,MAAM,SACJ,MACA,SACA,MACe;EAGf,MAAM,gBAAgB,KAAK,UAAU,IAAI,IAAI,KAAK,CAAC;EAEnD,MAAM,cAAc,KAAK;EAEzB,MAAM,MAAM,OAAO,OAAe,YAAoC;GACpE,MAAM,eAAe,cAAc;GAEnC,IAAI,CAAC,cACH,OAAO,OAAO,MAAM,KAAK,OAAO,IAAI,KAAA;GAGtC,IAAI,eAAe;GAEnB,MAAM,OAAsB,OAAO,YAAY;IAC7C,IAAI,cAAc;IAClB,eAAe;IACf,OAAO,MAAM,IAAI,QAAQ,GAAG,OAAO;GACrC;GAMA,OAAO,OAJiC,eACnC,SAAS,SAAS,YAAY,SAAS,cAAc,IAAI,IAC1D,aAAa,WAAA,CAEO,SAAS,IAAI;EACvC;EAEA,OAAO,MAAM,IAAI,GAAG,OAAO;CAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"HookDispatcher-BhDq-Kju.js","names":[],"sources":["../src/git/revision/readGitFile.ts","../src/workflow/changelog/extractLatestVersion.ts","../src/workflow/discovery/discoverPackageTag.ts","../src/workflow/changelog/prependChangelog.ts","../src/workflow/changelog/writeChangelog.ts","../src/plugin/HookDispatcher.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Read a file's contents from a specific Git revision.\n *\n * Runs `git show <ref>:<filePath>` and returns the command output as a\n * string. If the file does not exist at the given revision or the Git\n * command fails for any reason, the function returns `null`.\n *\n * The returned string is the raw file contents as emitted by Git; callers\n * that need binary-safe handling should decode or process the bytes\n * accordingly. This function intentionally swallows Git errors and signals\n * absence via a `null` result rather than throwing.\n *\n * @param cwd Repository working directory\n * @param ref Commit-ish reference (commit SHA, tag, or branch) to read from\n * @param filePath Path to the file relative to the repository root\n * @returns File contents as a string, or `null` if the file is unavailable at the ref\n */\nexport function readGitFile(\n cwd: string,\n ref: string,\n filePath: string\n): Promise<string | null> {\n return execGit(cwd, ['show', `${ref}:${filePath}`]).catch(() => null)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { iterateChangelogVersions } from './iterateChangelogVersions'\n\n/**\n * Find the highest semantic version from the first version-bearing element.\n *\n * Pulls the first available version string from the parsed markdown iterator.\n * Short-circuits execution immediately upon locating a match to avoid passing\n * through the remaining document structure.\n *\n * @param changelogContent The raw markdown string representing the changelog\n * @returns The highest valid semantic version string found or null\n */\nexport function extractLatestVersion(changelogContent: string): string | null {\n for (const version of iterateChangelogVersions(changelogContent)) {\n return version\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport {\n generateGitTagName,\n getGitTagMessage,\n readGitFile,\n resolveGitRevision,\n} from '#git'\nimport type { EnsureGitTagOptions } from '#git'\nimport type { Package, Tag } from '#types'\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { extractLatestVersion } from '../changelog/extractLatestVersion'\nimport { verifyPackageTag } from './verifyPackageTag'\n\n/**\n * Discover and validate the Git tag for a package.\n *\n * Returns the existing tag if already present on the `pkg` object. Resolves\n * the local changelog file path, extracts the current version, and generates\n * the expected Git tag name. Verifies the tag against the repository and\n * ensures its historical changelog version matches the current local version.\n *\n * @param cwd The current working directory\n * @param pkg The package configuration object\n * @param options Dry-run and logging guards for the local tag cleanup\n * @returns The validated `Tag` object or null if validation fails\n */\nexport async function discoverPackageTag(\n cwd: string,\n pkg: Package,\n options?: EnsureGitTagOptions\n): Promise<Tag | null> {\n if (pkg.tag) {\n return pkg.tag\n }\n\n const changelogFile = pkg.changelogFile || DEFAULT_CHANGELOG_FILE\n\n const changelogFilePath = path.resolve(cwd, pkg.location, changelogFile)\n\n let localChangelogContent: string | null | undefined\n\n try {\n localChangelogContent = await readFile(changelogFilePath, 'utf-8')\n } catch {}\n\n if (!localChangelogContent) {\n return null\n }\n\n const currentVersion = extractLatestVersion(localChangelogContent)\n\n if (!currentVersion) {\n return null\n }\n\n let expectedTagName: string | null | undefined\n\n try {\n expectedTagName = generateGitTagName(pkg.entry, pkg.name, currentVersion)\n } catch {}\n\n if (!expectedTagName) {\n return null\n }\n\n if (!(await verifyPackageTag(cwd, pkg, expectedTagName, options))) {\n return null\n }\n\n const tagRef = `refs/tags/${expectedTagName}`\n\n const historicalChangelogContent = await readGitFile(\n cwd,\n await resolveGitRevision(cwd, tagRef),\n path.relative(cwd, changelogFilePath)\n )\n\n if (!historicalChangelogContent) {\n return null\n }\n\n const historicalChangelogVersion = extractLatestVersion(\n historicalChangelogContent\n )\n\n if (\n !historicalChangelogVersion ||\n historicalChangelogVersion !== currentVersion\n ) {\n return null\n }\n\n return {\n name: expectedTagName,\n message: await getGitTagMessage(cwd, expectedTagName),\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { formatFile } from '#util'\nimport type { ConsolaInstance } from 'consola/core'\nimport { fromMarkdown } from 'mdast-util-from-markdown'\nimport { toMarkdown } from 'mdast-util-to-markdown'\nimport fs from 'node:fs/promises'\n\nconst defaultChangelogTitle = 'Changelog'\n\n/**\n * Prepend changelog content to a markdown file, creating it if necessary.\n *\n * Reads the existing file if present, prepends the new content before the main heading,\n * formats and writes the result back.\n *\n * @param filePath Path to the changelog file\n * @param revision Changelog content to prepend\n * @param logger Optional logger that receives formatting failures\n * @returns Promise that resolves when the changelog is written\n */\nexport async function prependChangelog(\n filePath: string,\n revision: string,\n logger?: ConsolaInstance\n): Promise<void> {\n let content = ''\n\n try {\n content = await fs.readFile(filePath, 'utf-8')\n } catch (err) {\n /* istanbul ignore next */\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw err\n }\n }\n\n const root = fromMarkdown(content)\n\n let index = root.children.findIndex(\n (node) => node.type === 'heading' && node.depth === 1\n )\n\n if (index === -1) {\n index = 0\n\n root.children.unshift({\n type: 'heading',\n depth: 1,\n children: [{ type: 'text', value: defaultChangelogTitle }],\n })\n }\n\n root.children.splice(index + 1, 0, ...fromMarkdown(revision).children)\n\n content = toMarkdown(root)\n\n content = await formatFile(filePath, content, logger)\n\n await fs.writeFile(filePath, content)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport type { ReleasePlan } from '#types'\nimport type { ConsolaInstance } from 'consola/core'\nimport path from 'node:path'\nimport { prependChangelog } from './prependChangelog'\n\n/**\n * Write changelog content to the file system based on the release plan.\n *\n * @param cwd Repository working directory\n * @param plan Release plan containing package and changelog content\n * @param logger Optional logger that receives formatting failures\n * @returns Promise that resolves when the changelog file has been written\n */\nexport async function writeChangelog(\n cwd: string,\n plan: ReleasePlan,\n logger?: ConsolaInstance\n): Promise<void> {\n if (plan.release?.changelog) {\n const changelogFile = plan.package.changelogFile || DEFAULT_CHANGELOG_FILE\n\n const filePath = path.join(cwd, plan.package.location, changelogFile)\n\n await prependChangelog(filePath, plan.release.changelog, logger)\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Continuation that resumes the chain with the following middleware.\n */\nexport type Next<Context> = (context: Context) => Promise<void>\n\n/**\n * Function executed as a single link in a hook dispatch chain.\n */\nexport type Middleware<Context> = {\n bivariant(context: Context, next: Next<Context>): void | Promise<void>\n}['bivariant']\n\n/**\n * Priority ranks that order middleware within a hook.\n */\nexport const Priority = {\n High: 50,\n Normal: 0,\n Low: -50,\n} as const\n\n/**\n * Registration options accepted by `on`.\n */\nexport interface RegistrationOptions<Meta> {\n priority?: number | undefined\n meta?: Meta | undefined\n}\n\n/**\n * A registration entry captured by `on`.\n *\n * Carries the `middleware`, its `priority` sort rank, and the `meta` exposed\n * to the constructor interceptor.\n */\nexport interface Registration<HookName, Context, Meta = undefined> {\n hook: HookName\n priority: number\n middleware: Middleware<Context>\n meta: Meta | undefined\n}\n\n/**\n * Intercept a registered middleware during dispatch.\n *\n * Runs in place of every registered middleware, receiving the shared\n * `context`, the `registration` being dispatched — including its `priority`\n * and `meta` — and the `next` function that continues with the following\n * middleware.\n */\nexport type Interceptor<HookName, Context, Meta = undefined> = (\n context: Context,\n registration: Registration<HookName, Context, Meta>,\n next: Next<Context>\n) => void | Promise<void>\n\ntype InferContext<M extends Middleware<unknown>> =\n M extends Middleware<infer Context> ? Context : never\n\n/**\n * Dispatch registered hooks through asynchronous execution chains.\n *\n * Stores middleware in a prioritized registry and executes them sequentially\n * in priority order.\n */\nexport class HookDispatcher<\n HookMap extends Record<keyof HookMap, Middleware<unknown>>,\n Meta = undefined,\n> {\n readonly #registry = new Map<\n keyof HookMap,\n Registration<keyof HookMap, InferContext<HookMap[keyof HookMap]>, Meta>[]\n >()\n\n readonly #interceptor:\n | Interceptor<keyof HookMap, InferContext<HookMap[keyof HookMap]>, Meta>\n | undefined\n\n /**\n * Create a hook dispatcher.\n *\n * @param interceptor Wrapper invoked in place of every registered\n * middleware during dispatch\n */\n constructor(\n interceptor?: Interceptor<\n keyof HookMap,\n InferContext<HookMap[keyof HookMap]>,\n Meta\n >\n ) {\n this.#interceptor = interceptor\n }\n\n /**\n * Register middleware for a specific hook.\n *\n * Adds the `middleware` to the internal registry for `hook` and sorts the\n * list so higher-priority middleware runs first. An omitted or `undefined`\n * `options.priority` defaults to `Priority.Normal`; `options.meta` is\n * carried on the registration for the constructor interceptor.\n *\n * @param hook Name of the hook to register\n * @param middleware Function executed when the hook dispatches\n * @param options Registration options carrying the execution order rank and\n * the metadata exposed to the constructor interceptor\n */\n on<HookName extends keyof HookMap>(\n hook: HookName,\n middleware: Middleware<InferContext<HookMap[HookName]>>,\n options?: RegistrationOptions<Meta>\n ): void {\n const registrations = this.#registry.get(hook) ?? []\n\n registrations.push({\n hook,\n middleware,\n priority: options?.priority ?? Priority.Normal,\n meta: options?.meta,\n })\n\n registrations.sort((a, b) => b.priority - a.priority)\n\n this.#registry.set(hook, registrations)\n }\n\n /**\n * Unregister middleware from a specific hook.\n *\n * Removes matching `middleware` references from the internal registry for\n * `hook`. Takes no action if `hook` has no registered middleware.\n *\n * @param hook Name of the hook to unregister from\n * @param middleware Reference of the middleware function to remove\n */\n off<HookName extends keyof HookMap>(\n hook: HookName,\n middleware: Middleware<InferContext<HookMap[HookName]>>\n ): void {\n const registrations = this.#registry.get(hook)\n\n if (!registrations) return\n\n this.#registry.set(\n hook,\n registrations.filter(\n (registration) => registration.middleware !== middleware\n )\n )\n }\n\n /**\n * Dispatch all middleware registered to a hook.\n *\n * Passes `context` through the middleware pipeline in descending priority\n * order and dispatches each registration through the constructor\n * interceptor when one is provided. Enables middleware to control\n * execution flow using `next` and executes `done` after the last\n * middleware completes.\n *\n * @param hook Name of the hook to dispatch\n * @param context Shared payload passed into each middleware\n * @param done Optional final callback run after the pipeline completes\n * @returns Promise that resolves when execution completes\n */\n async dispatch<HookName extends keyof HookMap>(\n hook: HookName,\n context: InferContext<HookMap[HookName]>,\n done?: Next<InferContext<HookMap[HookName]>>\n ): Promise<void> {\n type Context = InferContext<HookMap[HookName]>\n\n const registrations = this.#registry.get(hook) ?? []\n\n const interceptor = this.#interceptor\n\n const run = async (index: number, context: Context): Promise<void> => {\n const registration = registrations[index]\n\n if (!registration) {\n return done ? await done(context) : undefined\n }\n\n let isNextCalled = false\n\n const next: Next<Context> = async (context) => {\n if (isNextCalled) return\n isNextCalled = true\n return await run(index + 1, context)\n }\n\n const middleware: Middleware<Context> = interceptor\n ? (context, next) => interceptor(context, registration, next)\n : registration.middleware\n\n return await middleware(context, next)\n }\n\n return await run(0, context)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,YACd,KACA,KACA,UACwB;CACxB,OAAO,QAAQ,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,YAAY,IAAI;AACtE;;;;;;;;;;;;ACbA,SAAgB,qBAAqB,kBAAyC;CAC5E,KAAK,MAAM,WAAW,yBAAyB,gBAAgB,GAC7D,OAAO;CAGT,O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AM,gBAAgB,KAAK,UAAU,IAAI,IAAI,KAAK,CAAC;EAEnD,MAAM,cAAc,KAAK;EAEzB,MAAM,MAAM,OAAO,OAAe,YAAoC;GACpE,MAAM,eAAe,cAAc;GAEnC,IAAI,CAAC,cACH,OAAO,OAAO,MAAM,KAAK,OAAO,IAAI,KAAA;GAGtC,IAAI,eAAe;GAEnB,MAAM,OAAsB,OAAO,YAAY;IAC7C,IAAI,cAAc;IAClB,eAAe;IACf,OAAO,MAAM,IAAI,QAAQ,GAAG,OAAO;GACrC;GAMA,OAAO,OAJiC,eACnC,SAAS,SAAS,YAAY,SAAS,cAAc,IAAI,IAC1D,aAAa,WAAA,CAEO,SAAS,IAAI;EACvC;EAEA,OAAO,MAAM,IAAI,GAAG,OAAO;CAC7B;AACF"}
|
package/dist/analyzer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { o as deriveTransitionReleases, s as deriveChangeReleases, t as propagateDependencyUpdates } from "./propagateDependencyUpdates-
|
|
2
|
-
import { t as readPackageHistory } from "./readPackageHistory-
|
|
3
|
-
import { t as resolvePackageTag } from "./resolvePackageTag-
|
|
4
|
-
import { t as version } from "./package-
|
|
1
|
+
import { o as deriveTransitionReleases, s as deriveChangeReleases, t as propagateDependencyUpdates } from "./propagateDependencyUpdates-uFNP3wOj.js";
|
|
2
|
+
import { t as readPackageHistory } from "./readPackageHistory-CpX-1QuK.js";
|
|
3
|
+
import { t as resolvePackageTag } from "./resolvePackageTag-pPUPCCmI.js";
|
|
4
|
+
import { t as version } from "./package-ZT0zvko1.js";
|
|
5
5
|
// src/analyzer.ts
|
|
6
6
|
/**
|
|
7
7
|
* Built-in plugin that inspects repository history and produces release plans for packages.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as SEMVER_REGEX, w as formatError } from "./package-
|
|
1
|
+
import { N as SEMVER_REGEX, w as formatError } from "./package-ZT0zvko1.js";
|
|
2
2
|
import semver from "semver";
|
|
3
3
|
import prettier from "prettier";
|
|
4
4
|
import path from "node:path";
|
|
@@ -184,4 +184,4 @@ async function buildChangelog(context, history, options = {}) {
|
|
|
184
184
|
}
|
|
185
185
|
export { formatFile as a, extractPlainText as i, iterateChangelogVersions as n, compact as o, extractSemVer as r, isDefined as s, buildChangelog as t };
|
|
186
186
|
|
|
187
|
-
//# sourceMappingURL=buildChangelog-
|
|
187
|
+
//# sourceMappingURL=buildChangelog-KqS15vOE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildChangelog-CkytKypk.js","names":[],"sources":["../src/util/isDefined.ts","../src/util/compact.ts","../src/util/formatFile.ts","../src/workflow/changelog/extractPlainText.ts","../src/workflow/changelog/extractSemVer.ts","../src/workflow/changelog/iterateChangelogVersions.ts","../src/workflow/changelog/buildChangelog.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Type guard that asserts a value is neither `null` nor `undefined`.\n *\n * @param value Value to test\n * @returns `true` when `value` is not `null` or `undefined`\n */\nexport function isDefined<T>(value: T): value is NonNullable<T> {\n return value != null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { isDefined } from './isDefined'\n\n/**\n * Remove `null` and `undefined` values from an array.\n *\n * @param array The array to compact\n * @returns A new array that does not contain `null` or `undefined` values\n */\nexport function compact<T>(array: readonly (T | null | undefined)[]): T[] {\n return array.filter(isDefined)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ConsolaInstance } from 'consola/core'\nimport prettier from 'prettier'\nimport { formatError } from './formatError'\n\n/**\n * Format `content` for `filePath` using Prettier when possible.\n *\n * Resolves project/editorconfig settings and formats the provided content.\n * Returns the original content on error or when no parser is inferred, and\n * reports the failure through `logger` at debug level when one is provided.\n *\n * @param filePath Path used to infer parser and config\n * @param content Source content to format\n * @param logger Optional logger that receives formatting failures\n * @returns Formatted content or original content on failure\n */\nexport async function formatFile(\n filePath: string,\n content: string,\n logger?: ConsolaInstance\n): Promise<string> {\n try {\n const info = await prettier.getFileInfo(filePath, {\n resolveConfig: true,\n })\n\n const config = await prettier.resolveConfig(filePath, {\n editorconfig: true,\n })\n\n if (info.inferredParser == null) {\n return content\n }\n\n return await prettier.format(content, {\n ...config,\n parser: info.inferredParser,\n filepath: filePath,\n })\n } catch (error: unknown) {\n logger?.debug(\n `Formatting \"${filePath}\" failed and content stays unformatted: ${formatError(error)}`\n )\n\n return content\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Heading, Paragraph, PhrasingContent } from 'mdast'\n\n/**\n * Extract trimmed plain text from a Heading, Paragraph, or PhrasingContent node.\n *\n * Performs a depth-first traversal, concatenating string `value` tokens in\n * document order. Non-string values are ignored. Returns `null` for empty or\n * missing input.\n *\n * @param node Node to extract text from\n * @returns The trimmed plain-text string, or null if empty\n */\nexport function extractPlainText(\n node: Heading | Paragraph | PhrasingContent | null | undefined\n): string | null {\n if (!node) {\n return null\n }\n\n const queue = [node]\n let result = ''\n\n while ((node = queue.shift())) {\n if ('value' in node && typeof node.value === 'string') {\n result += node.value\n }\n\n /* istanbul ignore else */\n if ('children' in node && Array.isArray(node.children)) {\n queue.unshift(...node.children)\n }\n }\n\n return result.trim() || null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { SEMVER_REGEX } from '#config'\nimport { compact } from '#util'\n\nconst ANCHORED_SEMVER_REGEX = new RegExp(`^${SEMVER_REGEX.source}$`)\n\nconst BRACKETED_SEMVER_REGEX = new RegExp(`\\\\[${SEMVER_REGEX.source}\\\\]`)\n\n/**\n * Extract SemVer core strings from a line.\n *\n * Splits the line on runs of spaces or tabs and on `..`/`...`. For each token,\n * first attempts an anchored SemVer match (must match the whole token), then\n * a bracketed match that finds a SemVer inside `[...]`. Returns the captured\n * SemVer core (capture group 2) for each successful match; falsy results are\n * filtered out.\n *\n * @param line Line to scan for SemVer cores\n * @returns Array of extracted SemVer core strings; empty if none\n */\nexport function extractSemVer(line: string): string[] {\n const tokens = line.split(/[ \\t]+|\\.{2,3}/)\n\n return compact(\n tokens.map((token) => {\n return (\n ANCHORED_SEMVER_REGEX.exec(token) ?? BRACKETED_SEMVER_REGEX.exec(token)\n )?.at(2)\n })\n )\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { RootContent } from 'mdast'\nimport { fromMarkdown } from 'mdast-util-from-markdown'\nimport semver from 'semver'\nimport { extractPlainText } from './extractPlainText'\nimport { extractSemVer } from './extractSemVer'\n\nconst SENTENCE_TERMINAL_REGEX = /\\p{Sentence_Terminal}$/u\n\n/**\n * Iterate over Semantic Version strings extracted from a Markdown changelog.\n *\n * Parses `changelogContent` into an AST and evaluates nodes sequentially using\n * custom extractors. Evaluates heading nodes first before checking short\n * paragraph nodes. Stops execution after the first strategy yields valid\n * versions.\n *\n * @param changelogContent Raw Markdown text of the changelog\n * @yields Valid SemVer strings found in headings or candidate paragraphs\n */\nexport function* iterateChangelogVersions(\n changelogContent: string\n): Generator<string> {\n const root = fromMarkdown(changelogContent)\n\n const nodeExtractors = [\n (node: RootContent): string | null => {\n return node.type === 'heading' ? extractPlainText(node) : null\n },\n\n (node: RootContent): string | null => {\n if (node.type !== 'paragraph') return null\n\n const paragraphText = extractPlainText(node)\n\n if (\n !paragraphText ||\n paragraphText.length > 48 ||\n SENTENCE_TERMINAL_REGEX.test(paragraphText)\n ) {\n return null\n }\n\n return paragraphText\n },\n ]\n\n for (const extractText of nodeExtractors) {\n let isVersionFound = false\n\n for (const node of root.children) {\n const extractedText = extractText(node)\n\n const candidateVersion = extractedText\n ? semver.sort(extractSemVer(extractedText)).pop()\n : null\n\n if (candidateVersion && semver.valid(candidateVersion)) {\n isVersionFound = true\n yield candidateVersion\n }\n }\n\n if (isVersionFound) {\n return\n }\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport type { GitCommit, ReleaseContext } from '#types'\nimport { formatFile } from '#util'\nimport createPreset from 'conventional-changelog-conventionalcommits'\nimport {\n writeChangelogString,\n type CommitKnownProps,\n type FinalTemplateContext,\n type Options,\n type TemplateContext,\n} from 'conventional-changelog-writer'\nimport path from 'node:path'\n\nexport interface BuildChangelogOptions {\n packageDir?: string | undefined\n changelogFile?: string | undefined\n version?: string | null | undefined\n previousTag?: string | null | undefined\n currentTag?: string | null | undefined\n}\n\ninterface ConventionalCommitsPreset {\n writer: Options\n}\n\nlet presetCache: ConventionalCommitsPreset | undefined\n\n/**\n * Load the conventional commits preset on first use.\n *\n * Creating the preset performs setup work that used to run at import time\n * through a module-level await; loading it lazily keeps importing this\n * module synchronous and skips the cost for consumers that never build a\n * changelog.\n *\n * @returns The cached preset, created on the first call\n */\nasync function loadPreset(): Promise<ConventionalCommitsPreset> {\n presetCache ??= await createPreset()\n\n return presetCache\n}\n\n/**\n * Build the changelog string for a release.\n *\n * Compiles commit history and release context into a formatted changelog using\n * conventional commits and writer configurations. Resolves file paths and handles\n * tag comparisons when repository URLs are available.\n *\n * @param context The release context containing repository and working directory details\n * @param history The iterable or async iterable collection of commits to process\n * @param options The build configuration options for the changelog\n * @returns The formatted changelog content string\n */\nexport async function buildChangelog(\n context: ReleaseContext,\n history: Iterable<GitCommit> | AsyncIterable<GitCommit>,\n options: BuildChangelogOptions = {}\n): Promise<string> {\n const preset = await loadPreset()\n\n const repository = context.repository?.url || undefined\n\n const version = options.version || undefined\n\n const previousTag = options.previousTag || undefined\n\n const currentTag = options.currentTag || undefined\n\n const filePath = path.join(\n context.cwd,\n options.packageDir || '.',\n options.changelogFile || DEFAULT_CHANGELOG_FILE\n )\n\n const headerPartial = (context: FinalTemplateContext) => {\n return context.version ? preset.writer.headerPartial?.(context) : undefined\n }\n\n const content = await writeChangelogString<CommitKnownProps>(\n history,\n {\n date: context.today,\n version,\n previousTag,\n currentTag,\n linkCompare: !!repository && !!previousTag && !!currentTag,\n linkReferences: !!repository,\n repoUrl: repository,\n commit: 'commit',\n issue: 'issues',\n headerPartial,\n } as TemplateContext,\n preset.writer\n )\n\n return formatFile(filePath, content, context.logger)\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,SAAgB,UAAa,OAAmC;CAC9D,OAAO,SAAS;AAClB;;;;;;;;ACAA,SAAgB,QAAW,OAA+C;CACxE,OAAO,MAAM,OAAO,SAAS;AAC/B;;;;;;;;;;;;;;ACMA,eAAsB,WACpB,UACA,SACA,QACiB;CACjB,IAAI;EACF,MAAM,OAAO,MAAM,SAAS,YAAY,UAAU,EAChD,eAAe,KACjB,CAAC;EAED,MAAM,SAAS,MAAM,SAAS,cAAc,UAAU,EACpD,cAAc,KAChB,CAAC;EAED,IAAI,KAAK,kBAAkB,MACzB,OAAO;EAGT,OAAO,MAAM,SAAS,OAAO,SAAS;GACpC,GAAG;GACH,QAAQ,KAAK;GACb,UAAU;EACZ,CAAC;CACH,SAAS,OAAgB;EACvB,QAAQ,MACN,eAAe,SAAS,0CAA0C,YAAY,KAAK,GACrF;EAEA,OAAO;CACT;AACF;;;;;;;;;;;;AClCA,SAAgB,iBACd,MACe;CACf,IAAI,CAAC,MACH,OAAO;CAGT,MAAM,QAAQ,CAAC,IAAI;CACnB,IAAI,SAAS;CAEb,OAAQ,OAAO,MAAM,MAAM,GAAI;EAC7B,IAAI,WAAW,QAAQ,OAAO,KAAK,UAAU,UAC3C,UAAU,KAAK;;EAIjB,IAAI,cAAc,QAAQ,MAAM,QAAQ,KAAK,QAAQ,GACnD,MAAM,QAAQ,GAAG,KAAK,QAAQ;CAElC;CAEA,OAAO,OAAO,KAAK,KAAK;AAC1B;;AC/BA,IAAM,wBAAwB,IAAI,OAAO,IAAI,aAAa,OAAO,EAAE;AAEnE,IAAM,yBAAyB,IAAI,OAAO,MAAM,aAAa,OAAO,IAAI;;;;;;;;;;;;;AAcxE,SAAgB,cAAc,MAAwB;CAGpD,OAAO,QAFQ,KAAK,MAAM,gBAGxB,CA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BAAA,cACV;CAEA,MAAM,iBAAiB,YAAkC;EACvD,OAAO,QAAQ,UAAU,OAAO,OAAO,gBAAgB,OAAO,IAAI,KAAA;CACpE;CAmBA,OAAO,WAAW,UAAU,MAjBN,qBACpB,SACA;EACE,MAAM,QAAQ;EACd;EACA;EACA;EACA,aAAa,CAAC,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC,CAAC;EAChD,gBAAgB,CAAC,CAAC;EAClB,SAAS;EACT,QAAQ;EACR,OAAO;EACP;CACF,GACA,OAAO,MACT,GAEqC,QAAQ,MAAM;AACrD"}
|
|
1
|
+
{"version":3,"file":"buildChangelog-KqS15vOE.js","names":[],"sources":["../src/util/isDefined.ts","../src/util/compact.ts","../src/util/formatFile.ts","../src/workflow/changelog/extractPlainText.ts","../src/workflow/changelog/extractSemVer.ts","../src/workflow/changelog/iterateChangelogVersions.ts","../src/workflow/changelog/buildChangelog.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Type guard that asserts a value is neither `null` nor `undefined`.\n *\n * @param value Value to test\n * @returns `true` when `value` is not `null` or `undefined`\n */\nexport function isDefined<T>(value: T): value is NonNullable<T> {\n return value != null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { isDefined } from './isDefined'\n\n/**\n * Remove `null` and `undefined` values from an array.\n *\n * @param array The array to compact\n * @returns A new array that does not contain `null` or `undefined` values\n */\nexport function compact<T>(array: readonly (T | null | undefined)[]): T[] {\n return array.filter(isDefined)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ConsolaInstance } from 'consola/core'\nimport prettier from 'prettier'\nimport { formatError } from './formatError'\n\n/**\n * Format `content` for `filePath` using Prettier when possible.\n *\n * Resolves project/editorconfig settings and formats the provided content.\n * Returns the original content on error or when no parser is inferred, and\n * reports the failure through `logger` at debug level when one is provided.\n *\n * @param filePath Path used to infer parser and config\n * @param content Source content to format\n * @param logger Optional logger that receives formatting failures\n * @returns Formatted content or original content on failure\n */\nexport async function formatFile(\n filePath: string,\n content: string,\n logger?: ConsolaInstance\n): Promise<string> {\n try {\n const info = await prettier.getFileInfo(filePath, {\n resolveConfig: true,\n })\n\n const config = await prettier.resolveConfig(filePath, {\n editorconfig: true,\n })\n\n if (info.inferredParser == null) {\n return content\n }\n\n return await prettier.format(content, {\n ...config,\n parser: info.inferredParser,\n filepath: filePath,\n })\n } catch (error: unknown) {\n logger?.debug(\n `Formatting \"${filePath}\" failed and content stays unformatted: ${formatError(error)}`\n )\n\n return content\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Heading, Paragraph, PhrasingContent } from 'mdast'\n\n/**\n * Extract trimmed plain text from a Heading, Paragraph, or PhrasingContent node.\n *\n * Performs a depth-first traversal, concatenating string `value` tokens in\n * document order. Non-string values are ignored. Returns `null` for empty or\n * missing input.\n *\n * @param node Node to extract text from\n * @returns The trimmed plain-text string, or null if empty\n */\nexport function extractPlainText(\n node: Heading | Paragraph | PhrasingContent | null | undefined\n): string | null {\n if (!node) {\n return null\n }\n\n const queue = [node]\n let result = ''\n\n while ((node = queue.shift())) {\n if ('value' in node && typeof node.value === 'string') {\n result += node.value\n }\n\n /* istanbul ignore else */\n if ('children' in node && Array.isArray(node.children)) {\n queue.unshift(...node.children)\n }\n }\n\n return result.trim() || null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { SEMVER_REGEX } from '#config'\nimport { compact } from '#util'\n\nconst ANCHORED_SEMVER_REGEX = new RegExp(`^${SEMVER_REGEX.source}$`)\n\nconst BRACKETED_SEMVER_REGEX = new RegExp(`\\\\[${SEMVER_REGEX.source}\\\\]`)\n\n/**\n * Extract SemVer core strings from a line.\n *\n * Splits the line on runs of spaces or tabs and on `..`/`...`. For each token,\n * first attempts an anchored SemVer match (must match the whole token), then\n * a bracketed match that finds a SemVer inside `[...]`. Returns the captured\n * SemVer core (capture group 2) for each successful match; falsy results are\n * filtered out.\n *\n * @param line Line to scan for SemVer cores\n * @returns Array of extracted SemVer core strings; empty if none\n */\nexport function extractSemVer(line: string): string[] {\n const tokens = line.split(/[ \\t]+|\\.{2,3}/)\n\n return compact(\n tokens.map((token) => {\n return (\n ANCHORED_SEMVER_REGEX.exec(token) ?? BRACKETED_SEMVER_REGEX.exec(token)\n )?.at(2)\n })\n )\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { RootContent } from 'mdast'\nimport { fromMarkdown } from 'mdast-util-from-markdown'\nimport semver from 'semver'\nimport { extractPlainText } from './extractPlainText'\nimport { extractSemVer } from './extractSemVer'\n\nconst SENTENCE_TERMINAL_REGEX = /\\p{Sentence_Terminal}$/u\n\n/**\n * Iterate over Semantic Version strings extracted from a Markdown changelog.\n *\n * Parses `changelogContent` into an AST and evaluates nodes sequentially using\n * custom extractors. Evaluates heading nodes first before checking short\n * paragraph nodes. Stops execution after the first strategy yields valid\n * versions.\n *\n * @param changelogContent Raw Markdown text of the changelog\n * @yields Valid SemVer strings found in headings or candidate paragraphs\n */\nexport function* iterateChangelogVersions(\n changelogContent: string\n): Generator<string> {\n const root = fromMarkdown(changelogContent)\n\n const nodeExtractors = [\n (node: RootContent): string | null => {\n return node.type === 'heading' ? extractPlainText(node) : null\n },\n\n (node: RootContent): string | null => {\n if (node.type !== 'paragraph') return null\n\n const paragraphText = extractPlainText(node)\n\n if (\n !paragraphText ||\n paragraphText.length > 48 ||\n SENTENCE_TERMINAL_REGEX.test(paragraphText)\n ) {\n return null\n }\n\n return paragraphText\n },\n ]\n\n for (const extractText of nodeExtractors) {\n let isVersionFound = false\n\n for (const node of root.children) {\n const extractedText = extractText(node)\n\n const candidateVersion = extractedText\n ? semver.sort(extractSemVer(extractedText)).pop()\n : null\n\n if (candidateVersion && semver.valid(candidateVersion)) {\n isVersionFound = true\n yield candidateVersion\n }\n }\n\n if (isVersionFound) {\n return\n }\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport type { GitCommit, ReleaseContext } from '#types'\nimport { formatFile } from '#util'\nimport createPreset from 'conventional-changelog-conventionalcommits'\nimport {\n writeChangelogString,\n type CommitKnownProps,\n type FinalTemplateContext,\n type Options,\n type TemplateContext,\n} from 'conventional-changelog-writer'\nimport path from 'node:path'\n\nexport interface BuildChangelogOptions {\n packageDir?: string | undefined\n changelogFile?: string | undefined\n version?: string | null | undefined\n previousTag?: string | null | undefined\n currentTag?: string | null | undefined\n}\n\ninterface ConventionalCommitsPreset {\n writer: Options\n}\n\nlet presetCache: ConventionalCommitsPreset | undefined\n\n/**\n * Load the conventional commits preset on first use.\n *\n * Creating the preset performs setup work that used to run at import time\n * through a module-level await; loading it lazily keeps importing this\n * module synchronous and skips the cost for consumers that never build a\n * changelog.\n *\n * @returns The cached preset, created on the first call\n */\nasync function loadPreset(): Promise<ConventionalCommitsPreset> {\n presetCache ??= await createPreset()\n\n return presetCache\n}\n\n/**\n * Build the changelog string for a release.\n *\n * Compiles commit history and release context into a formatted changelog using\n * conventional commits and writer configurations. Resolves file paths and handles\n * tag comparisons when repository URLs are available.\n *\n * @param context The release context containing repository and working directory details\n * @param history The iterable or async iterable collection of commits to process\n * @param options The build configuration options for the changelog\n * @returns The formatted changelog content string\n */\nexport async function buildChangelog(\n context: ReleaseContext,\n history: Iterable<GitCommit> | AsyncIterable<GitCommit>,\n options: BuildChangelogOptions = {}\n): Promise<string> {\n const preset = await loadPreset()\n\n const repository = context.repository?.url || undefined\n\n const version = options.version || undefined\n\n const previousTag = options.previousTag || undefined\n\n const currentTag = options.currentTag || undefined\n\n const filePath = path.join(\n context.cwd,\n options.packageDir || '.',\n options.changelogFile || DEFAULT_CHANGELOG_FILE\n )\n\n const headerPartial = (context: FinalTemplateContext) => {\n return context.version ? preset.writer.headerPartial?.(context) : undefined\n }\n\n const content = await writeChangelogString<CommitKnownProps>(\n history,\n {\n date: context.today,\n version,\n previousTag,\n currentTag,\n linkCompare: !!repository && !!previousTag && !!currentTag,\n linkReferences: !!repository,\n repoUrl: repository,\n commit: 'commit',\n issue: 'issues',\n headerPartial,\n } as TemplateContext,\n preset.writer\n )\n\n return formatFile(filePath, content, context.logger)\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,SAAgB,UAAa,OAAmC;CAC9D,OAAO,SAAS;AAClB;;;;;;;;ACAA,SAAgB,QAAW,OAA+C;CACxE,OAAO,MAAM,OAAO,SAAS;AAC/B;;;;;;;;;;;;;;ACMA,eAAsB,WACpB,UACA,SACA,QACiB;CACjB,IAAI;EACF,MAAM,OAAO,MAAM,SAAS,YAAY,UAAU,EAChD,eAAe,KACjB,CAAC;EAED,MAAM,SAAS,MAAM,SAAS,cAAc,UAAU,EACpD,cAAc,KAChB,CAAC;EAED,IAAI,KAAK,kBAAkB,MACzB,OAAO;EAGT,OAAO,MAAM,SAAS,OAAO,SAAS;GACpC,GAAG;GACH,QAAQ,KAAK;GACb,UAAU;EACZ,CAAC;CACH,SAAS,OAAgB;EACvB,QAAQ,MACN,eAAe,SAAS,0CAA0C,YAAY,KAAK,GACrF;EAEA,OAAO;CACT;AACF;;;;;;;;;;;;AClCA,SAAgB,iBACd,MACe;CACf,IAAI,CAAC,MACH,OAAO;CAGT,MAAM,QAAQ,CAAC,IAAI;CACnB,IAAI,SAAS;CAEb,OAAQ,OAAO,MAAM,MAAM,GAAI;EAC7B,IAAI,WAAW,QAAQ,OAAO,KAAK,UAAU,UAC3C,UAAU,KAAK;;EAIjB,IAAI,cAAc,QAAQ,MAAM,QAAQ,KAAK,QAAQ,GACnD,MAAM,QAAQ,GAAG,KAAK,QAAQ;CAElC;CAEA,OAAO,OAAO,KAAK,KAAK;AAC1B;;AC/BA,IAAM,wBAAwB,IAAI,OAAO,IAAI,aAAa,OAAO,EAAE;AAEnE,IAAM,yBAAyB,IAAI,OAAO,MAAM,aAAa,OAAO,IAAI;;;;;;;;;;;;;AA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EzC,MAAM,WAAW,KAAK,KACpB,QAAQ,KACR,QAAQ,cAAc,KACtB,QAAQ,iBAAA,cACV;CAEA,MAAM,iBAAiB,YAAkC;EACvD,OAAO,QAAQ,UAAU,OAAO,OAAO,gBAAgB,OAAO,IAAI,KAAA;CACpE;CAmBA,OAAO,WAAW,UAAU,MAjBN,qBACpB,SACA;EACE,MAAM,QAAQ;EACd;EACA;EACA;EACA,aAAa,CAAC,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC,CAAC;EAChD,gBAAgB,CAAC,CAAC;EAClB,SAAS;EACT,QAAQ;EACR,OAAO;EACP;CACF,GACA,OAAO,MACT,GAEqC,QAAQ,MAAM;AACrD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as extractVersionQualifier } from "./readPackageHistory-
|
|
2
|
-
import { a as generateGitTagName, i as getGitTagMessage, k as DEFAULT_CHANGELOG_FILE, n as verifyPackageTag } from "./package-
|
|
3
|
-
import { a as formatFile, n as iterateChangelogVersions, t as buildChangelog } from "./buildChangelog-
|
|
1
|
+
import { a as extractVersionQualifier } from "./readPackageHistory-CpX-1QuK.js";
|
|
2
|
+
import { a as generateGitTagName, i as getGitTagMessage, k as DEFAULT_CHANGELOG_FILE, n as verifyPackageTag } from "./package-ZT0zvko1.js";
|
|
3
|
+
import { a as formatFile, n as iterateChangelogVersions, t as buildChangelog } from "./buildChangelog-KqS15vOE.js";
|
|
4
4
|
import semver from "semver";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
@@ -138,4 +138,4 @@ async function buildReleaseNotes(context, history) {
|
|
|
138
138
|
}
|
|
139
139
|
export { bumpVersion as i, resolvePackageStableTag as n, isSameReleaseCycle as r, buildReleaseNotes as t };
|
|
140
140
|
|
|
141
|
-
//# sourceMappingURL=buildReleaseNotes-
|
|
141
|
+
//# sourceMappingURL=buildReleaseNotes-D12vnood.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildReleaseNotes-Dk4bEclG.js","names":[],"sources":["../src/workflow/version/bumpVersion.ts","../src/workflow/version/isSameReleaseCycle.ts","../src/workflow/discovery/resolvePackageStableTag.ts","../src/workflow/changelog/buildReleaseNotes.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseType, VersionTransition } from '#types'\nimport semver from 'semver'\nimport { extractVersionQualifier } from './extractVersionQualifier'\n\nexport interface BumpVersionOptions {\n version: string\n release: ReleaseType | null | undefined\n identifier?: string | null | undefined\n transition?: VersionTransition | null | undefined\n}\n\n/**\n * Bump a semantic version string based on release and transition rules.\n *\n * Parses the target version and determines the next version string using the\n * specified release type, prerelease identifier, and transition mode. Adjusts\n * prerelease types when continuing an existing qualifier and returns `null` when\n * `options.release` is omitted or if transition conditions fail.\n *\n * @param options Version bump configuration including release type, identifier, and transition rules\n * @returns The bumped semantic version string, or `null` if no bump occurs\n * @throws If `options.version` is not a valid semantic version\n */\nexport function bumpVersion(options: BumpVersionOptions): string | null {\n const { version } = options\n\n const parsed = semver.parse(version)\n\n if (!parsed) {\n throw new Error(`Version \"${version}\" is not a valid semantic version.`)\n }\n\n if (!options.release) {\n return null\n }\n\n if (parsed.prerelease.length > 0) {\n if (options.transition === 'advance' && options.identifier == null) {\n return null\n }\n } else {\n if (options.transition === 'continue') {\n return null\n }\n }\n\n let release: semver.ReleaseType = options.release\n let identifier: string | undefined\n\n if (typeof options.identifier === 'string') {\n release = `pre${options.release}` as const\n identifier = options.identifier\n\n const parsedIdentifier = extractVersionQualifier(parsed)\n\n const transition =\n options.transition ??\n (parsedIdentifier && identifier === '' ? 'advance' : 'continue')\n\n if (typeof parsedIdentifier === 'string' && transition === 'continue') {\n if (\n (release === 'premajor' && parsed.minor === 0 && parsed.patch === 0) ||\n (release === 'preminor' && parsed.patch === 0) ||\n release === 'prepatch'\n ) {\n release = 'prerelease'\n }\n }\n }\n\n return semver.inc(parsed, release, { loose: false }, identifier, '0')\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport semver from 'semver'\n\n/**\n * Determine whether two semantic version strings or objects belong to the same release cycle.\n *\n * Compares the main version components of `currentVersion` and `nextVersion` to\n * determine equality. Treats a transition from a non-zero `0.x` version to\n * `1.0.0` as part of the same release cycle. Returns `false` if either input\n * cannot be parsed.\n *\n * @param currentVersion Starting version string, `semver.SemVer` instance, or nullish value\n * @param nextVersion Target version string, `semver.SemVer` instance, or nullish value\n * @returns `true` if both versions belong to the same release cycle, `false` otherwise\n */\nexport function isSameReleaseCycle(\n currentVersion: string | semver.SemVer | null | undefined,\n nextVersion: string | semver.SemVer | null | undefined\n): boolean {\n const current = semver.parse(currentVersion)\n const next = semver.parse(nextVersion)\n\n if (!current || !next) return false\n\n if (current.compareMain(next) === 0) return true\n\n return (\n current.major === 0 &&\n (current.minor > 0 || current.patch > 0) &&\n next.major === 1 &&\n next.minor === 0 &&\n next.patch === 0\n )\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport { generateGitTagName, getGitTagMessage } from '#git'\nimport type { EnsureGitTagOptions } from '#git'\nimport type { Package, Tag } from '#types'\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport semver from 'semver'\nimport { iterateChangelogVersions } from '../changelog/iterateChangelogVersions'\nimport { verifyPackageTag } from './verifyPackageTag'\n\n/**\n * Resolve the latest stable Git tag for a package.\n *\n * Reads changelog release versions for `pkg` and verifies strict descending\n * semver order. Ignores prerelease versions unless transitioning across major\n * or prerelease boundaries, and verifies that the matching Git tag exists.\n *\n * Stable releases below `1.0.0` are only considered when the preceding\n * version was a prerelease, so a repository with exclusively 0.x releases\n * resolves to no stable tag.\n *\n * @param cwd Absolute path to the root working directory\n * @param pkg Package configuration object\n * @param options Dry-run and logging guards for the local tag cleanup\n * @returns Verified tag metadata object or `null` if no stable tag is resolved\n * @throws If a version is invalid, versions are not in strict descending\n * order, or the corresponding Git tag is missing\n */\nexport async function resolvePackageStableTag(\n cwd: string,\n pkg: Package,\n options?: EnsureGitTagOptions\n): Promise<Tag | null> {\n const changelogFile = pkg.changelogFile || DEFAULT_CHANGELOG_FILE\n\n const changelogFilePath = path.resolve(cwd, pkg.location, changelogFile)\n\n let changelogContent: string\n\n try {\n changelogContent = await readFile(changelogFilePath, 'utf-8')\n } catch (error: unknown) {\n /* istanbul ignore else */\n if ((error as NodeJS.ErrnoException)?.code === 'ENOENT') {\n return null\n }\n\n /* istanbul ignore next */\n throw error\n }\n\n let precedingVersion: semver.SemVer | null = null\n\n for (const version of iterateChangelogVersions(changelogContent)) {\n const currentVersion = semver.parse(version)\n\n if (!currentVersion) {\n throw new Error(`Version \"${version}\" is not a valid semantic version.`)\n }\n\n if (precedingVersion && semver.gte(currentVersion, precedingVersion)) {\n throw new Error(\n `Version \"${version}\" must be strictly lower than preceding version \"${precedingVersion.raw}\".`\n )\n }\n\n if (\n !semver.prerelease(currentVersion) &&\n (currentVersion.major >= 1 ||\n (precedingVersion && semver.prerelease(precedingVersion)))\n ) {\n const tagName = generateGitTagName(pkg.entry, pkg.name, version)\n\n if (!(await verifyPackageTag(cwd, pkg, tagName, options))) {\n throw new Error(\n `Git tag \"${tagName}\" is not associated with package \"${pkg.name ?? ''}\" in directory \"${pkg.location}\".`\n )\n }\n\n return {\n name: tagName,\n message: await getGitTagMessage(cwd, tagName),\n }\n }\n\n precedingVersion = currentVersion\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport type { GitCommit, ReleaseContext } from '#types'\nimport { formatFile } from '#util'\nimport type { Heading, RootContent } from 'mdast'\nimport { fromMarkdown } from 'mdast-util-from-markdown'\nimport { toMarkdown } from 'mdast-util-to-markdown'\nimport path from 'node:path'\nimport { buildChangelog } from './buildChangelog'\n\n/**\n * Build release notes from a release context and commit history.\n *\n * Generates changelog content from commits, parses it into an abstract syntax\n * tree, shifts heading depths, and formats the resulting markdown file.\n *\n * @param context The release context containing repository and configuration details\n * @param history The iterable or async iterable collection of commits to process\n * @returns The formatted release notes as a markdown string\n */\nexport async function buildReleaseNotes(\n context: ReleaseContext,\n history: Iterable<GitCommit> | AsyncIterable<GitCommit>\n): Promise<string> {\n const changelogContent = await buildChangelog(context, history)\n\n const root = fromMarkdown(changelogContent)\n\n root.children = root.children.flatMap<RootContent>((node) => {\n if (node.type === 'heading') {\n /* istanbul ignore next */\n if (node.depth <= 2) {\n return []\n }\n\n node = {\n ...node,\n depth: (node.depth - 1) as Heading['depth'],\n }\n }\n\n return node\n })\n\n const filePath = path.join(context.cwd, DEFAULT_CHANGELOG_FILE)\n\n return formatFile(filePath, toMarkdown(root), context.logger)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,YAAY,SAA4C;CACtE,MAAM,EAAE,YAAY;CAEpB,MAAM,SAAS,OAAO,MAAM,OAAO;CAEnC,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,YAAY,QAAQ,mCAAmC;CAGzE,IAAI,CAAC,QAAQ,SACX,OAAO;CAGT,IAAI,OAAO,WAAW,SAAS,GACzB;MAAA,QAAQ,eAAe,aAAa,QAAQ,cAAc,MAC5D,OAAO;CAAA,OAGT,IAAI,QAAQ,eAAe,YACzB,OAAO;CAIX,IAAI,UAA8B,QAAQ;CAC1C,IAAI;CAEJ,IAAI,OAAO,QAAQ,eAAe,UAAU;EAC1C,UAAU,MAAM,QAAQ;EACxB,aAAa,QAAQ;EAErB,MAAM,mBAAmB,wBAAwB,MAAM;EAEvD,MAAM,aACJ,QAAQ,eACP,oBAAoB,eAAe,KAAK,YAAY;EAEvD,IAAI,OAAO,qBAAqB,YAAY,eAAe,YAEtD;OAAA,YAAY,cAAc,OAAO,UAAU,KAAK,OAAO,UAAU,KACjE,YAAY,cAAc,OAAO,UAAU,KAC5C,YAAY,YAEZ,UAAU;EAAA;CAGhB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,YAAY,QAAQ,oCAAoC,IAAI,QAAQ,GAAG,kBAAkB,IAAI,SAAS,GACxG;GAGF,OAAO;IACL,MAAM;IACN,SAAS,MAAM,iBAAiB,KAAK,OAAO;GAC9C;EACF;EAEA,mBAAmB;CACrB;CAEA,OAAO;AACT;;;;;;;;;;;;ACtEA,eAAsB,kBACpB,SACA,SACiB;CACjB,MAAM,mBAAmB,MAAM,eAAe,SAAS,OAAO;CAE9D,MAAM,OAAO,aAAa,gBAAgB;CAE1C,KAAK,WAAW,KAAK,SAAS,SAAsB,SAAS;EAC3D,IAAI,KAAK,SAAS,WAAW;;GAE3B,IAAI,KAAK,SAAS,GAChB,OAAO,CAAC;GAGV,OAAO;IACL,GAAG;IACH,OAAQ,KAAK,QAAQ;GACvB;EACF;EAEA,OAAO;CACT,CAAC;CAED,MAAM,WAAW,KAAK,KAAK,QAAQ,KAAK,sBAAsB;CAE9D,OAAO,WAAW,UAAU,WAAW,IAAI,GAAG,QAAQ,MAAM;AAC9D"}
|
|
1
|
+
{"version":3,"file":"buildReleaseNotes-D12vnood.js","names":[],"sources":["../src/workflow/version/bumpVersion.ts","../src/workflow/version/isSameReleaseCycle.ts","../src/workflow/discovery/resolvePackageStableTag.ts","../src/workflow/changelog/buildReleaseNotes.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseType, VersionTransition } from '#types'\nimport semver from 'semver'\nimport { extractVersionQualifier } from './extractVersionQualifier'\n\nexport interface BumpVersionOptions {\n version: string\n release: ReleaseType | null | undefined\n identifier?: string | null | undefined\n transition?: VersionTransition | null | undefined\n}\n\n/**\n * Bump a semantic version string based on release and transition rules.\n *\n * Parses the target version and determines the next version string using the\n * specified release type, prerelease identifier, and transition mode. Adjusts\n * prerelease types when continuing an existing qualifier and returns `null` when\n * `options.release` is omitted or if transition conditions fail.\n *\n * @param options Version bump configuration including release type, identifier, and transition rules\n * @returns The bumped semantic version string, or `null` if no bump occurs\n * @throws If `options.version` is not a valid semantic version\n */\nexport function bumpVersion(options: BumpVersionOptions): string | null {\n const { version } = options\n\n const parsed = semver.parse(version)\n\n if (!parsed) {\n throw new Error(`Version \"${version}\" is not a valid semantic version.`)\n }\n\n if (!options.release) {\n return null\n }\n\n if (parsed.prerelease.length > 0) {\n if (options.transition === 'advance' && options.identifier == null) {\n return null\n }\n } else {\n if (options.transition === 'continue') {\n return null\n }\n }\n\n let release: semver.ReleaseType = options.release\n let identifier: string | undefined\n\n if (typeof options.identifier === 'string') {\n release = `pre${options.release}` as const\n identifier = options.identifier\n\n const parsedIdentifier = extractVersionQualifier(parsed)\n\n const transition =\n options.transition ??\n (parsedIdentifier && identifier === '' ? 'advance' : 'continue')\n\n if (typeof parsedIdentifier === 'string' && transition === 'continue') {\n if (\n (release === 'premajor' && parsed.minor === 0 && parsed.patch === 0) ||\n (release === 'preminor' && parsed.patch === 0) ||\n release === 'prepatch'\n ) {\n release = 'prerelease'\n }\n }\n }\n\n return semver.inc(parsed, release, { loose: false }, identifier, '0')\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport semver from 'semver'\n\n/**\n * Determine whether two semantic version strings or objects belong to the same release cycle.\n *\n * Compares the main version components of `currentVersion` and `nextVersion` to\n * determine equality. Treats a transition from a non-zero `0.x` version to\n * `1.0.0` as part of the same release cycle. Returns `false` if either input\n * cannot be parsed.\n *\n * @param currentVersion Starting version string, `semver.SemVer` instance, or nullish value\n * @param nextVersion Target version string, `semver.SemVer` instance, or nullish value\n * @returns `true` if both versions belong to the same release cycle, `false` otherwise\n */\nexport function isSameReleaseCycle(\n currentVersion: string | semver.SemVer | null | undefined,\n nextVersion: string | semver.SemVer | null | undefined\n): boolean {\n const current = semver.parse(currentVersion)\n const next = semver.parse(nextVersion)\n\n if (!current || !next) return false\n\n if (current.compareMain(next) === 0) return true\n\n return (\n current.major === 0 &&\n (current.minor > 0 || current.patch > 0) &&\n next.major === 1 &&\n next.minor === 0 &&\n next.patch === 0\n )\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport { generateGitTagName, getGitTagMessage } from '#git'\nimport type { EnsureGitTagOptions } from '#git'\nimport type { Package, Tag } from '#types'\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport semver from 'semver'\nimport { iterateChangelogVersions } from '../changelog/iterateChangelogVersions'\nimport { verifyPackageTag } from './verifyPackageTag'\n\n/**\n * Resolve the latest stable Git tag for a package.\n *\n * Reads changelog release versions for `pkg` and verifies strict descending\n * semver order. Ignores prerelease versions unless transitioning across major\n * or prerelease boundaries, and verifies that the matching Git tag exists.\n *\n * Stable releases below `1.0.0` are only considered when the preceding\n * version was a prerelease, so a repository with exclusively 0.x releases\n * resolves to no stable tag.\n *\n * @param cwd Absolute path to the root working directory\n * @param pkg Package configuration object\n * @param options Dry-run and logging guards for the local tag cleanup\n * @returns Verified tag metadata object or `null` if no stable tag is resolved\n * @throws If a version is invalid, versions are not in strict descending\n * order, or the corresponding Git tag is missing\n */\nexport async function resolvePackageStableTag(\n cwd: string,\n pkg: Package,\n options?: EnsureGitTagOptions\n): Promise<Tag | null> {\n const changelogFile = pkg.changelogFile || DEFAULT_CHANGELOG_FILE\n\n const changelogFilePath = path.resolve(cwd, pkg.location, changelogFile)\n\n let changelogContent: string\n\n try {\n changelogContent = await readFile(changelogFilePath, 'utf-8')\n } catch (error: unknown) {\n /* istanbul ignore else */\n if ((error as NodeJS.ErrnoException)?.code === 'ENOENT') {\n return null\n }\n\n /* istanbul ignore next */\n throw error\n }\n\n let precedingVersion: semver.SemVer | null = null\n\n for (const version of iterateChangelogVersions(changelogContent)) {\n const currentVersion = semver.parse(version)\n\n if (!currentVersion) {\n throw new Error(`Version \"${version}\" is not a valid semantic version.`)\n }\n\n if (precedingVersion && semver.gte(currentVersion, precedingVersion)) {\n throw new Error(\n `Version \"${version}\" must be strictly lower than preceding version \"${precedingVersion.raw}\".`\n )\n }\n\n if (\n !semver.prerelease(currentVersion) &&\n (currentVersion.major >= 1 ||\n (precedingVersion && semver.prerelease(precedingVersion)))\n ) {\n const tagName = generateGitTagName(pkg.entry, pkg.name, version)\n\n if (!(await verifyPackageTag(cwd, pkg, tagName, options))) {\n throw new Error(\n `Git tag \"${tagName}\" is not associated with package \"${pkg.name ?? ''}\" in directory \"${pkg.location}\".`\n )\n }\n\n return {\n name: tagName,\n message: await getGitTagMessage(cwd, tagName),\n }\n }\n\n precedingVersion = currentVersion\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { DEFAULT_CHANGELOG_FILE } from '#config'\nimport type { GitCommit, ReleaseContext } from '#types'\nimport { formatFile } from '#util'\nimport type { Heading, RootContent } from 'mdast'\nimport { fromMarkdown } from 'mdast-util-from-markdown'\nimport { toMarkdown } from 'mdast-util-to-markdown'\nimport path from 'node:path'\nimport { buildChangelog } from './buildChangelog'\n\n/**\n * Build release notes from a release context and commit history.\n *\n * Generates changelog content from commits, parses it into an abstract syntax\n * tree, shifts heading depths, and formats the resulting markdown file.\n *\n * @param context The release context containing repository and configuration details\n * @param history The iterable or async iterable collection of commits to process\n * @returns The formatted release notes as a markdown string\n */\nexport async function buildReleaseNotes(\n context: ReleaseContext,\n history: Iterable<GitCommit> | AsyncIterable<GitCommit>\n): Promise<string> {\n const changelogContent = await buildChangelog(context, history)\n\n const root = fromMarkdown(changelogContent)\n\n root.children = root.children.flatMap<RootContent>((node) => {\n if (node.type === 'heading') {\n /* istanbul ignore next */\n if (node.depth <= 2) {\n return []\n }\n\n node = {\n ...node,\n depth: (node.depth - 1) as Heading['depth'],\n }\n }\n\n return node\n })\n\n const filePath = path.join(context.cwd, DEFAULT_CHANGELOG_FILE)\n\n return formatFile(filePath, toMarkdown(root), context.logger)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,YAAY,SAA4C;CACtE,MAAM,EAAE,YAAY;CAEpB,MAA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AAG,QAAQ,MAAM;AAC9D"}
|
package/dist/builder.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as generateGitTagName, t as version, w as formatError } from "./package-
|
|
2
|
-
import { i as bumpVersion, n as resolvePackageStableTag, r as isSameReleaseCycle, t as buildReleaseNotes } from "./buildReleaseNotes-
|
|
3
|
-
import { t as readPackageHistory } from "./readPackageHistory-
|
|
1
|
+
import { a as generateGitTagName, t as version, w as formatError } from "./package-ZT0zvko1.js";
|
|
2
|
+
import { i as bumpVersion, n as resolvePackageStableTag, r as isSameReleaseCycle, t as buildReleaseNotes } from "./buildReleaseNotes-D12vnood.js";
|
|
3
|
+
import { t as readPackageHistory } from "./readPackageHistory-CpX-1QuK.js";
|
|
4
4
|
import { colors } from "consola/utils";
|
|
5
5
|
// src/builder.ts
|
|
6
6
|
/**
|
package/dist/changelog.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as discoverPackageTag, n as Priority, r as writeChangelog } from "./HookDispatcher-
|
|
2
|
-
import { t as version, w as formatError } from "./package-
|
|
3
|
-
import { t as buildChangelog } from "./buildChangelog-
|
|
4
|
-
import { t as resolvePackageTag } from "./resolvePackageTag-
|
|
1
|
+
import { a as discoverPackageTag, n as Priority, r as writeChangelog } from "./HookDispatcher-BhDq-Kju.js";
|
|
2
|
+
import { t as version, w as formatError } from "./package-ZT0zvko1.js";
|
|
3
|
+
import { t as buildChangelog } from "./buildChangelog-KqS15vOE.js";
|
|
4
|
+
import { t as resolvePackageTag } from "./resolvePackageTag-pPUPCCmI.js";
|
|
5
5
|
import { colors } from "consola/utils";
|
|
6
6
|
// src/changelog.ts
|
|
7
7
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as extractVersionQualifier, i as unique, n as readParsedGitHistory, r as readGitHistory, t as readPackageHistory } from "./readPackageHistory-
|
|
2
|
-
import { i as bumpVersion, n as resolvePackageStableTag, r as isSameReleaseCycle, t as buildReleaseNotes } from "./buildReleaseNotes-
|
|
3
|
-
import { a as formatFile, i as extractPlainText, n as iterateChangelogVersions, o as compact, r as extractSemVer, s as isDefined, t as buildChangelog } from "./buildChangelog-
|
|
4
|
-
import { A as DEV_NULL, C as isMatch, D as buildTrailerPattern, E as execCommand, M as RELEASE_HOOK_NAMES, N as SEMVER_REGEX, O as ALL_FILES, S as packageContainsCommit, T as execGit, _ as GIT_PRETTY_FORMAT, a as generateGitTagName, b as TTLCache, c as deleteGitTag, d as isGitAncestor, f as withShallowLock, g as GIT_PRETTY_FIELD_SEPARATOR, h as getParsedGitCommit, i as getGitTagMessage, j as GIT_TRAILER_RELEASE_AGENT, k as DEFAULT_CHANGELOG_FILE, l as expandGitHistory, m as countGitHistory, n as verifyPackageTag, o as ensureGitTag, p as isGitShallowRepository, r as isGitTagConnected, s as isGitTagPresent, t as version, u as resolveGitRevision, v as parseGitPrettyFormat, w as formatError, x as extractMentions, y as parseGitCommit } from "./package-
|
|
5
|
-
import { a as detectGitRelationship, c as deriveReleaseType, i as GIT_REL_FLAGS, l as pickPriorityReleaseType, n as buildDependencyGraph, o as deriveTransitionReleases, r as mergeGitHistory, s as deriveChangeReleases, t as propagateDependencyUpdates, u as deriveCommitReleaseType } from "./propagateDependencyUpdates-
|
|
6
|
-
import { a as discoverPackageTag, i as prependChangelog, n as Priority, o as extractLatestVersion, r as writeChangelog, s as readGitFile, t as HookDispatcher } from "./HookDispatcher-
|
|
7
|
-
import { t as resolvePackageTag } from "./resolvePackageTag-
|
|
1
|
+
import { a as extractVersionQualifier, i as unique, n as readParsedGitHistory, r as readGitHistory, t as readPackageHistory } from "./readPackageHistory-CpX-1QuK.js";
|
|
2
|
+
import { i as bumpVersion, n as resolvePackageStableTag, r as isSameReleaseCycle, t as buildReleaseNotes } from "./buildReleaseNotes-D12vnood.js";
|
|
3
|
+
import { a as formatFile, i as extractPlainText, n as iterateChangelogVersions, o as compact, r as extractSemVer, s as isDefined, t as buildChangelog } from "./buildChangelog-KqS15vOE.js";
|
|
4
|
+
import { A as DEV_NULL, C as isMatch, D as buildTrailerPattern, E as execCommand, M as RELEASE_HOOK_NAMES, N as SEMVER_REGEX, O as ALL_FILES, S as packageContainsCommit, T as execGit, _ as GIT_PRETTY_FORMAT, a as generateGitTagName, b as TTLCache, c as deleteGitTag, d as isGitAncestor, f as withShallowLock, g as GIT_PRETTY_FIELD_SEPARATOR, h as getParsedGitCommit, i as getGitTagMessage, j as GIT_TRAILER_RELEASE_AGENT, k as DEFAULT_CHANGELOG_FILE, l as expandGitHistory, m as countGitHistory, n as verifyPackageTag, o as ensureGitTag, p as isGitShallowRepository, r as isGitTagConnected, s as isGitTagPresent, t as version, u as resolveGitRevision, v as parseGitPrettyFormat, w as formatError, x as extractMentions, y as parseGitCommit } from "./package-ZT0zvko1.js";
|
|
5
|
+
import { a as detectGitRelationship, c as deriveReleaseType, i as GIT_REL_FLAGS, l as pickPriorityReleaseType, n as buildDependencyGraph, o as deriveTransitionReleases, r as mergeGitHistory, s as deriveChangeReleases, t as propagateDependencyUpdates, u as deriveCommitReleaseType } from "./propagateDependencyUpdates-uFNP3wOj.js";
|
|
6
|
+
import { a as discoverPackageTag, i as prependChangelog, n as Priority, o as extractLatestVersion, r as writeChangelog, s as readGitFile, t as HookDispatcher } from "./HookDispatcher-BhDq-Kju.js";
|
|
7
|
+
import { t as resolvePackageTag } from "./resolvePackageTag-pPUPCCmI.js";
|
|
8
8
|
import "./types.js";
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import semver from "semver";
|
|
@@ -90,6 +90,15 @@ function buildTrailerPattern(markers = []) {
|
|
|
90
90
|
* Spawns the target process, collects output streams, and intercepts mutating
|
|
91
91
|
* `git` operations in test mode to inject deterministic commit timestamps.
|
|
92
92
|
*
|
|
93
|
+
* The child environment is assembled in two tiers: a fixed set of ambient
|
|
94
|
+
* variables — `HOME`, `PATH`, `SSH_AUTH_SOCK`, `GIT_SSH`, `GIT_SSH_COMMAND`,
|
|
95
|
+
* and the proxy variables — is always copied from `process.env`, and
|
|
96
|
+
* `options.env` is spread on top of it. Nothing is filtered beyond that:
|
|
97
|
+
* callers pass `{ ...context.env, ... }` — and the CLI's `context.env` is
|
|
98
|
+
* the live `process.env` — so the child receives the full environment the
|
|
99
|
+
* caller provides. Pass an explicit minimal `env` to restrict what the
|
|
100
|
+
* child sees.
|
|
101
|
+
*
|
|
93
102
|
* @param command Executable command name or path to spawn
|
|
94
103
|
* @param args Array of string arguments passed to the command
|
|
95
104
|
* @param options Execution environment, streaming, and signal options
|
|
@@ -878,7 +887,7 @@ async function verifyPackageTag(cwd, pkg, tagName, options) {
|
|
|
878
887
|
return isGitTagConnected(cwd, tagName);
|
|
879
888
|
}
|
|
880
889
|
// package.json
|
|
881
|
-
var version = "0.14.
|
|
890
|
+
var version = "0.14.1";
|
|
882
891
|
export { DEV_NULL as A, isMatch as C, buildTrailerPattern as D, execCommand as E, RELEASE_HOOK_NAMES as M, SEMVER_REGEX as N, ALL_FILES as O, packageContainsCommit as S, execGit as T, GIT_PRETTY_FORMAT as _, generateGitTagName as a, TTLCache as b, deleteGitTag as c, isGitAncestor as d, withShallowLock as f, GIT_PRETTY_FIELD_SEPARATOR as g, getParsedGitCommit as h, getGitTagMessage as i, GIT_TRAILER_RELEASE_AGENT as j, DEFAULT_CHANGELOG_FILE as k, expandGitHistory as l, countGitHistory as m, verifyPackageTag as n, ensureGitTag as o, isGitShallowRepository as p, isGitTagConnected as r, isGitTagPresent as s, version as t, resolveGitRevision as u, parseGitPrettyFormat as v, formatError as w, extractMentions as x, parseGitCommit as y };
|
|
883
892
|
|
|
884
|
-
//# sourceMappingURL=package-
|
|
893
|
+
//# sourceMappingURL=package-ZT0zvko1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-ZT0zvko1.js","names":[],"sources":["../src/config/const.ts","../src/util/buildTrailerPattern.ts","../src/util/execCommand.ts","../src/util/execGit.ts","../src/util/formatError.ts","../src/util/isMatch.ts","../src/workflow/analysis/packageContainsCommit.ts","../src/git/commit/extractMentions.ts","../src/cache/TTLCache.ts","../src/git/commit/parseGitCommit.ts","../src/git/commit/parseGitPrettyFormat.ts","../src/git/commit/getParsedGitCommit.ts","../src/git/history/countGitHistory.ts","../src/git/repository/isGitShallowRepository.ts","../src/git/repository/withShallowLock.ts","../src/git/revision/isGitAncestor.ts","../src/git/revision/resolveGitRevision.ts","../src/git/history/expandGitHistory.ts","../src/git/tag/deleteGitTag.ts","../src/git/tag/isGitTagPresent.ts","../src/git/tag/ensureGitTag.ts","../src/git/tag/generateGitTagName.ts","../src/git/tag/getGitTagMessage.ts","../src/git/tag/isGitTagConnected.ts","../src/workflow/discovery/verifyPackageTag.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseHookName } from '#types'\nimport { Writable } from 'node:stream'\n\nexport const ALL_FILES = '**/*'\n\nexport const DEFAULT_CHANGELOG_FILE = 'CHANGELOG.md'\n\nexport const GIT_TRAILER_RELEASE_AGENT = 'Release-Agent'\n\n/**\n * 1. Primitive Building Blocks\n *\n * Base regular expression patterns for wildcards, alphanumeric strings with hyphens,\n * and standard non-negative integers.\n */\nconst WILDCARD = '\\\\*'\nconst ALPHANUM_DASH = '[0-9a-zA-Z-]+'\nconst NUMERIC_IDENTIFIER = '0|[1-9]\\\\d*'\n\n/**\n * 2. Package Name & Prefix Constructs\n *\n * Matches package name prefixes (unscoped or scoped) or a simple `v` prefix.\n *\n * Capture Groups:\n * - Group 1: Package name (e.g., `my-package` or `@scope/my-package`)\n */\nconst PKG_NAME_PART = `(?:${WILDCARD}|${ALPHANUM_DASH})`\nconst CAPTURED_PACKAGE_NAME = `(${PKG_NAME_PART}|@${PKG_NAME_PART}\\\\/${PKG_NAME_PART})`\nconst OPTIONAL_VERSION_PREFIX = `(?:v|${CAPTURED_PACKAGE_NAME}@)`\n\n/**\n * 3. Core SemVer Components\n *\n * Matches standard `MAJOR.MINOR.PATCH` versions or wildcard variants (e.g., `1.0.0`, `*.*.*`).\n *\n * Capture Groups:\n * - Group 3: Major version\n * - Group 4: Minor version\n * - Group 5: Patch version\n */\nconst CAPTURED_VERSION_DIGIT = `(${WILDCARD}|${NUMERIC_IDENTIFIER})`\nconst SEMVER_CORE = `${CAPTURED_VERSION_DIGIT}\\\\.${CAPTURED_VERSION_DIGIT}\\\\.${CAPTURED_VERSION_DIGIT}`\n\n/**\n * 4. Prerelease & Build Metadata\n *\n * Matches optional prerelease identifiers (e.g., `-alpha.1`) and build metadata (e.g., `+build123`).\n *\n * Capture Groups:\n * - Group 6: Complete prerelease string (without `-`)\n * - Group 7: Non-numeric prerelease token\n * - Group 8: Complete build metadata string (without `+`)\n */\nconst CAPTURED_NON_NUMERIC_PRERELEASE_ID = `(\\\\d*[a-zA-Z-][0-9a-zA-Z-]*)`\nconst PRERELEASE_IDENTIFIER = `(?:${WILDCARD}|${NUMERIC_IDENTIFIER}|${CAPTURED_NON_NUMERIC_PRERELEASE_ID})`\nconst OPTIONAL_PRERELEASE_SECTION = `(?:-(${PRERELEASE_IDENTIFIER}(?:\\\\.${PRERELEASE_IDENTIFIER})*))`\nconst OPTIONAL_BUILD_SECTION = `(?:\\\\+(${ALPHANUM_DASH}(?:\\\\.${ALPHANUM_DASH})*))`\n\n/**\n * 5. Assembled SemVer Pattern\n *\n * Combines core SemVer components with optional prerelease identifiers and build metadata.\n *\n * Capture Groups:\n * - Group 2: Full SemVer version string (excluding package/prefix)\n */\nconst CAPTURED_SEMVER_VERSION = `(${SEMVER_CORE}${OPTIONAL_PRERELEASE_SECTION}?${OPTIONAL_BUILD_SECTION}?)`\nconst FULL_SEMVER_PATTERN = `${OPTIONAL_VERSION_PREFIX}?${CAPTURED_SEMVER_VERSION}`\n\n/**\n * Regular expression to match and capture Semantic Versioning (SemVer) strings,\n * including optional package prefixes (e.g., `@scope/pkg@`) and `v` prefixes.\n *\n * @example\n * ```ts\n * SEMVER_REGEX.test('1.0.0') // true\n * SEMVER_REGEX.test('v1.2.3-beta.1+sha.1234') // true\n * SEMVER_REGEX.test('@scope/package@1.0.0') // true\n * ```\n *\n * @see {@link https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SemVer Specification}\n */\nexport const SEMVER_REGEX = new RegExp(FULL_SEMVER_PATTERN)\n\nexport const DEV_NULL = new Writable({\n /* istanbul ignore next */\n write(_chunk, _encoding, callback) {\n callback()\n },\n})\n\nexport const RELEASE_HOOK_NAMES = [\n 'configure',\n 'discover',\n 'analyze',\n 'build',\n 'write',\n 'publish',\n 'finalize',\n] as const satisfies ReleaseHookName[]\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Build a regular expression to match trailer lines using custom markers.\n *\n * Combines the provided marker strings with a standard alphanumeric pattern\n * to construct a regular expression that matches trailer definitions.\n *\n * @param markers Optional array of custom trailer marker strings\n * @returns A regular expression matching trailer lines\n */\nexport function buildTrailerPattern(markers: readonly string[] = []) {\n return new RegExp(\n `^(${markers\n .map(RegExp.escape)\n .concat('[A-Za-z0-9_-]+')\n .join('|')})[ \\\\t]*:[ \\\\t]*(.*)$`\n )\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { spawn, type ChildProcessByStdio } from 'node:child_process'\nimport type { Stream } from 'node:stream'\n\nexport interface PromiseWithChild<T> extends Promise<T> {\n child: ChildProcessByStdio<null, Stream.Readable, Stream.Readable>\n}\n\nconst MUTATING_GIT_COMMANDS = new Set([\n 'commit',\n 'tag',\n 'cherry-pick',\n 'rebase',\n 'merge',\n 'revert',\n 'commit-tree',\n 'mktag',\n])\n\nlet deterministicCounter = 0\n\nexport interface ExecCommandOptions {\n cwd: string\n env?: Readonly<NodeJS.ProcessEnv> | undefined\n signal?: AbortSignal | undefined\n stdout?: NodeJS.WritableStream | undefined\n stderr?: NodeJS.WritableStream | undefined\n}\n\n/**\n * Execute a system command with arguments as a child process.\n *\n * Spawns the target process, collects output streams, and intercepts mutating\n * `git` operations in test mode to inject deterministic commit timestamps.\n *\n * The child environment is assembled in two tiers: a fixed set of ambient\n * variables — `HOME`, `PATH`, `SSH_AUTH_SOCK`, `GIT_SSH`, `GIT_SSH_COMMAND`,\n * and the proxy variables — is always copied from `process.env`, and\n * `options.env` is spread on top of it. Nothing is filtered beyond that:\n * callers pass `{ ...context.env, ... }` — and the CLI's `context.env` is\n * the live `process.env` — so the child receives the full environment the\n * caller provides. Pass an explicit minimal `env` to restrict what the\n * child sees.\n *\n * @param command Executable command name or path to spawn\n * @param args Array of string arguments passed to the command\n * @param options Execution environment, streaming, and signal options\n * @returns Promise attached to the child process resolving to standard output\n * @throws If process execution fails or exits with a non-zero status\n */\nexport function execCommand(\n command: string,\n args: readonly string[],\n options: ExecCommandOptions\n): PromiseWithChild<string> {\n const { cwd, signal } = options\n\n const env: NodeJS.ProcessEnv = {\n HOME: process.env.HOME,\n PATH: process.env.PATH,\n SSH_AUTH_SOCK: process.env.SSH_AUTH_SOCK,\n GIT_SSH: process.env.GIT_SSH,\n GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND,\n http_proxy: process.env.http_proxy,\n https_proxy: process.env.https_proxy,\n no_proxy: process.env.no_proxy,\n HTTP_PROXY: process.env.HTTP_PROXY,\n HTTPS_PROXY: process.env.HTTPS_PROXY,\n NO_PROXY: process.env.NO_PROXY,\n ...options.env,\n }\n\n if (import.meta.env.MODE === 'test' && command === 'git') {\n const primaryArg = args.find((arg) => MUTATING_GIT_COMMANDS.has(arg))\n\n if (primaryArg) {\n const base = Date.parse('2026-01-01T00:00:00Z')\n const date = new Date(base + deterministicCounter * 1000).toISOString()\n deterministicCounter += 1\n env.GIT_AUTHOR_DATE = date\n env.GIT_COMMITTER_DATE = date\n }\n }\n\n const child = spawn(command, args, {\n cwd,\n env,\n signal,\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n\n const promise = new Promise<string>((resolve, reject) => {\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n let settled = false\n\n function safeResolve(value: string) {\n /* istanbul ignore next */\n if (settled) return\n settled = true\n cleanup()\n resolve(value)\n }\n\n function safeReject(err: Error) {\n /* istanbul ignore next */\n if (settled) return\n settled = true\n cleanup()\n reject(err)\n }\n\n function cleanup() {\n child.off('error', onError)\n child.off('close', onClose)\n\n child.stdout.removeAllListeners('data')\n child.stderr.removeAllListeners('data')\n\n if (options.stdout) {\n child.stdout.unpipe(options.stdout)\n options.stdout.off('error', onError)\n }\n\n if (options.stderr) {\n child.stderr.unpipe(options.stderr)\n options.stderr.off('error', onError)\n }\n }\n\n function onError(err: Error) {\n safeReject(err)\n }\n\n function onClose(code: number | null, signal: NodeJS.Signals | null) {\n /* istanbul ignore next */\n if (settled) return\n\n if (code === 0) {\n return safeResolve(bufferArrayToString(stdout))\n }\n\n const quotedCommand = quoteCommandForMessage([command, ...args].join(' '))\n\n /* istanbul ignore next */\n const exitStatus =\n code !== null\n ? `exit code ${code}`\n : signal\n ? `signal ${signal}`\n : 'unknown status'\n\n const errorDiagnostics =\n bufferArrayToString(stderr).trim() || bufferArrayToString(stdout).trim()\n\n const errorMessage = [\n `Command ${quotedCommand} failed (${exitStatus})`,\n errorDiagnostics,\n ]\n .filter(Boolean)\n .join('\\n')\n\n const err = new Error(errorMessage, {\n cause: { code, signal, diagnostics: errorDiagnostics },\n })\n\n /* istanbul ignore else */\n if (code != null) {\n Object.defineProperty(err, 'code', { value: code })\n }\n\n safeReject(err)\n }\n\n child.on('error', onError)\n child.on('close', onClose)\n\n if (options.stdout) {\n options.stdout.on('error', onError)\n child.stdout.pipe(options.stdout)\n } else {\n child.stdout.on('data', (chunk) => stdout.push(chunk))\n }\n\n if (options.stderr) {\n options.stderr.on('error', onError)\n child.stderr.pipe(options.stderr)\n } else {\n child.stderr.on('data', (chunk) => stderr.push(chunk))\n }\n }) as PromiseWithChild<string>\n\n promise.child = child\n\n return promise\n}\n\nfunction bufferArrayToString(chunks: Buffer[]): string {\n return Buffer.concat(chunks).toString('utf-8')\n}\n\nfunction quoteCommandForMessage(command: string): string {\n if (!command.includes(\"'\")) {\n return `'${command}'`\n }\n\n if (!command.includes('\"')) {\n return `\"${command}\"`\n }\n\n return JSON.stringify(command)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {\n execCommand,\n type ExecCommandOptions,\n type PromiseWithChild,\n} from './execCommand'\n\n/**\n * Execute a Git command inside a target directory.\n *\n * Wraps `execCommand` to invoke the `git` executable using the provided\n * arguments and execution options.\n *\n * @param cwd Working directory path where the Git command runs\n * @param args Command-line arguments passed to Git\n * @param options Additional execution, environment, and stream options\n * @returns Promise attached to the child process resolving to stdout\n */\nexport function execGit(\n cwd: string,\n args: readonly string[],\n options?: Partial<ExecCommandOptions>\n): PromiseWithChild<string> {\n return execCommand('git', args, { ...options, cwd })\n}\n","// 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","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { minimatch } from 'minimatch'\n\n/**\n * Determine whether a target string matches glob patterns.\n *\n * Matches positive and negative glob patterns using dotfile support.\n * Negation-only patterns are expanded with a catch-all pattern so they match\n * every named target the patterns do not exclude.\n *\n * @param target Target string to evaluate against glob patterns\n * @param patterns Single glob pattern or list of patterns to evaluate\n * @returns True if target matches positive patterns and satisfies negative patterns\n */\nexport function isMatch(\n target: string,\n patterns: string | readonly string[]\n): boolean {\n if (typeof patterns === 'string') {\n patterns = [patterns]\n }\n\n if (\n patterns.length > 0 &&\n patterns.every((pattern) => pattern.startsWith('!'))\n ) {\n patterns = ['**/*', ...patterns]\n }\n\n const positives: string[] = []\n const negatives: string[] = []\n\n for (const pattern of patterns) {\n if (pattern.startsWith('!')) {\n negatives.push(pattern)\n } else {\n positives.push(pattern)\n }\n }\n\n return (\n positives.some((pattern) => minimatch(target, pattern, { dot: true })) &&\n negatives.every((pattern) => minimatch(target, pattern, { dot: true }))\n )\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { ALL_FILES } from '#config'\nimport type { GitCommit, Package } from '#types'\nimport { isMatch } from '#util'\nimport path from 'node:path'\n\n/**\n * Test whether a commit modifies files in a package.\n *\n * @param pkg Package with an explicit file pattern or base directory\n * @param commit Parsed commit containing changed file paths\n * @returns `true` if any changed file matches the package pattern\n */\nexport function packageContainsCommit(\n pkg: Package,\n commit: GitCommit\n): boolean {\n return commit.files.some((file) => {\n const { location } = pkg\n const files = pkg.files || path.join(location, ALL_FILES)\n\n return isMatch(file, files)\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nconst ALPHANUMERIC = '[a-zA-Z0-9]'\nconst SEPARATOR = '[-_]'\nconst USERNAME = `${ALPHANUMERIC}+(?:${SEPARATOR}+${ALPHANUMERIC}+)*`\nconst EMAIL_LOCAL = '[a-zA-Z0-9._%+-]'\nconst DOMAIN_SUFFIX = '[a-zA-Z0-9.-]*\\\\.[a-zA-Z]{2,}'\nconst SCOPED_PACKAGE_SPEC_SUFFIX = `/${USERNAME}@[0-9]+\\\\.[0-9]+\\\\.[0-9]+`\n\n/**\n * Extract unique mention handles from the input text string.\n *\n * Evaluates `text` against boundary rules to isolate valid handles while\n * excluding email addresses, domain names, and scoped package specs, then\n * de-duplicates the resulting handles.\n *\n * @param text The input string to parse for mentions\n * @returns An array of unique mention handles\n */\nexport function extractMentions(text: string): string[] {\n if (!text) return []\n\n const regex = new RegExp(\n `(?<!${EMAIL_LOCAL})@(${USERNAME})\\\\b(?!${SEPARATOR}|${DOMAIN_SUFFIX}|${SCOPED_PACKAGE_SPEC_SUFFIX})`,\n 'g'\n )\n\n const matches = text.matchAll(regex)\n\n const mentions = new Set(matches.map((match) => match[1] as string))\n\n return Array.from(mentions)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\ninterface Entry<V> {\n value: V\n timer: NodeJS.Timeout\n ttl: number\n}\n\n/**\n * A simple time-to-live cache that automatically evicts entries after a TTL.\n *\n * - Entries are removed automatically when their TTL expires.\n * - Reading an entry resets its TTL to the original value.\n * - Setting an existing key clears its previous timer and resets the TTL.\n *\n * @template K Type of cache keys\n * @template V Type of cache values\n */\nexport class TTLCache<K, V> {\n private cache = new Map<K, Entry<V>>()\n\n /**\n * Store a value under `key` for `ttl` milliseconds.\n *\n * If the key already exists its previous timer is cleared and the TTL is reset.\n *\n * @param key Cache key\n * @param value Value to store\n * @param ttl Time to live in milliseconds (default: 60_000)\n */\n set(key: K, value: V, ttl: number = 60_000): void {\n const ref = this.cache.get(key)\n\n if (ref) {\n clearTimeout(ref.timer)\n }\n\n const timer = setTimeout(() => {\n this.cache.delete(key)\n }, ttl).unref()\n\n this.cache.set(key, { value, timer, ttl })\n }\n\n /**\n * Retrieve the value for `key`, or `undefined` if not present.\n *\n * Reading an entry resets its TTL to the original `ttl` provided when it was set.\n *\n * @param key Cache key\n * @returns The stored value or `undefined` if not present\n */\n get(key: K): V | undefined {\n const ref = this.cache.get(key)\n\n if (!ref) return undefined\n\n this.set(key, ref.value, ref.ttl)\n\n return ref.value\n }\n\n /**\n * Check whether `key` exists in the cache.\n *\n * @param key Cache key\n * @returns `true` if present; otherwise `false`\n */\n has(key: K): boolean {\n return this.cache.has(key)\n }\n\n /**\n * Remove `key` from the cache and clear its eviction timer.\n *\n * @param key Cache key\n * @returns `true` if the key was present and removed; otherwise `false`\n */\n delete(key: K): boolean {\n const ref = this.cache.get(key)\n\n if (!ref) return false\n\n clearTimeout(ref.timer)\n\n return this.cache.delete(key)\n }\n\n /**\n * Clear all entries and their timers.\n */\n clear(): void {\n for (const { timer } of this.cache.values()) {\n clearTimeout(timer)\n }\n\n this.cache.clear()\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n GitCommit,\n GitCommitNote,\n GitCommitTrailer,\n GitCommitType,\n} from '#types'\nimport type {\n Commit as ParsedCommit,\n CommitBase,\n} from 'conventional-commits-parser'\nimport { CommitParser } from 'conventional-commits-parser'\nimport { buildTrailerPattern } from '../../util/buildTrailerPattern'\nimport { extractMentions } from './extractMentions'\n\nexport interface GitLogEntry {\n hash: string\n parent: string[]\n authorDate: string\n committerDate: string\n subject: string\n body: string\n files: string[]\n}\n\ninterface Commit extends CommitBase {\n type: GitCommitType | null\n scope: string | null\n subject: string\n header: string\n body: string | null\n footer: string | null\n}\n\nconst BREAKING_HEADER_REGEX = /^([\\w-]+)(?:\\(([^)]+)\\))?!: (.*)$/\n\nconst BREAKING_MARKERS: readonly string[] = [\n 'BREAKING CHANGE',\n 'BREAKING-CHANGE',\n]\n\n/**\n * Converge the parser's dynamically-shaped result into the typed commit\n * shape used for release analysis.\n *\n * The parser assigns `type`, `scope`, and `subject` at runtime through its\n * default header correspondence, so they exist on the result without being\n * part of its declared return type; `header` is always a string once\n * parsing succeeds because the parser rejects empty input.\n *\n * @param parsed The parser result to converge\n * @returns The typed commit shape\n */\nfunction toCommit(parsed: ParsedCommit): Commit {\n return {\n ...parsed,\n type: parsed.type ?? null,\n scope: parsed.scope ?? null,\n subject: parsed.subject ?? '',\n header: parsed.header ?? '',\n }\n}\n\n/**\n * Parse a git log entry into a structured commit object.\n *\n * Combines the commit subject and body, extracts conventional commit metadata\n * using custom trailer markers and breaking header patterns, and normalizes\n * dates to ISO format strings.\n *\n * @param entry The raw git log entry to parse\n * @param markers Optional array of custom trailer marker strings\n * @returns A structured commit object containing parsed details, notes, and mentions\n */\nexport async function parseGitCommit(\n entry: GitLogEntry,\n markers: readonly string[] = []\n): Promise<GitCommit> {\n const message = [entry.subject, entry.body].filter(Boolean).join('\\n\\n')\n\n const parser = new CommitParser({\n breakingHeaderPattern: BREAKING_HEADER_REGEX,\n noteKeywords: [],\n notesPattern: () => buildTrailerPattern(BREAKING_MARKERS.concat(markers)),\n })\n\n const commit = toCommit(parser.parse(message))\n\n const notes: GitCommitNote[] = []\n\n const trailers: GitCommitTrailer[] = []\n\n for (const note of commit.notes) {\n if (BREAKING_MARKERS.includes(note.title.toUpperCase())) {\n notes.push(note)\n }\n\n trailers.push({\n key: note.title,\n value: note.text,\n })\n }\n\n if (notes.length === 0 && BREAKING_HEADER_REGEX.test(commit.header)) {\n const note: GitCommitNote = {\n title: 'BREAKING CHANGE',\n text: commit.subject,\n }\n\n notes.push(note)\n\n trailers.push({\n key: note.title,\n value: note.text,\n })\n }\n\n const mentions = extractMentions(message)\n\n return {\n ...commit,\n hash: entry.hash,\n parent: entry.parent,\n authorDate: new Date(entry.authorDate).toISOString(),\n committerDate: new Date(entry.committerDate).toISOString(),\n type: commit.type?.toLowerCase() || null,\n scope: commit.scope || null,\n subject: commit.subject || null,\n header: commit.header,\n body: commit.body,\n footer: commit.footer,\n notes,\n mentions,\n trailers,\n files: entry.files,\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { colors } from 'consola/utils'\nimport type { GitLogEntry } from './parseGitCommit'\n\n/**\n * Field separator used in the git pretty format to produce a single-line\n *, machine-parseable record.\n */\nexport const GIT_PRETTY_FIELD_SEPARATOR = '\\x1f'\n\n/**\n * Pretty format string passed to `git log --pretty=format:`. Produces seven\n * fields separated by `GIT_PRETTY_FIELD_SEPARATOR`:\n * hash, parents, author date, committer date, subject, body, files.\n */\nexport const GIT_PRETTY_FORMAT = [\n '%H',\n '%P',\n '%aI',\n '%cI',\n '%s',\n '%b',\n '',\n].join(GIT_PRETTY_FIELD_SEPARATOR)\n\n/**\n * Parse a single line produced by `git log --pretty=format:${GIT_PRETTY_FORMAT}`.\n *\n * The input is expected to contain seven fields separated by\n * `GIT_PRETTY_FIELD_SEPARATOR`:\n * 1. `hash` (commit hash)\n * 2. `parent` (space-separated parent hashes)\n * 3. `authorDate` (ISO 8601)\n * 4. `committerDate` (ISO 8601)\n * 5. `subject`\n * 6. `body`\n * 7. `files` (newline-separated list)\n *\n * The function trims fields, converts parent hashes into an array, normalizes\n * dates to ISO strings, and splits `files` into an array. Missing optional\n * fields are normalized to sensible defaults.\n *\n * @param raw Raw pretty-format string produced by git\n * @returns Parsed `GitLogEntry` with `hash`, `parent`, `authorDate`, `committerDate`, `subject`, `body`, and `files`\n * @throws If required fields (hash, authorDate, committerDate, subject) are missing or malformed\n */\nexport function parseGitPrettyFormat(raw: string): GitLogEntry {\n let [hash, parentHashes, authorDate, committerDate, subject, body, files] =\n raw.split(GIT_PRETTY_FIELD_SEPARATOR)\n\n hash = hash?.trim()\n parentHashes = parentHashes?.trim()\n authorDate = authorDate?.trim()\n committerDate = committerDate?.trim()\n subject = subject?.trim()\n body = body?.trim()\n files = files?.trim()\n\n if (!hash || !authorDate || !committerDate || typeof subject !== 'string') {\n throw new Error(\n `The input \"${colors.bold(raw.slice(0, 200))}\" is not in the expected pretty format.`,\n {\n cause: new Error(`Pretty-format payload length: ${raw.length}`),\n }\n )\n }\n\n return {\n hash,\n parent: parentHashes ? parentHashes.split(/\\s+/) : [],\n authorDate: new Date(authorDate).toISOString(),\n committerDate: new Date(committerDate).toISOString(),\n subject,\n body: body ?? '',\n files: files ? files.split('\\n') : [],\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { TTLCache } from '#cache'\nimport type { GitCommit } from '#types'\nimport { execGit } from '#util'\nimport { parseGitCommit } from './parseGitCommit'\nimport { GIT_PRETTY_FORMAT, parseGitPrettyFormat } from './parseGitPrettyFormat'\n\nconst cache = new TTLCache<string, GitCommit>()\n\n/**\n * Retrieve and parse a git commit by its reference.\n *\n * Fetches the raw git log entry for the specified `ref`, checking the local cache\n * prior to parsing missing entries.\n *\n * @param cwd Current working directory path\n * @param ref Git reference to fetch\n * @param markers Optional array of custom trailer marker strings\n * @returns Structured commit object\n */\nexport async function getParsedGitCommit(\n cwd: string,\n ref: string,\n markers: readonly string[] = []\n): Promise<GitCommit> {\n const stdout = await execGit(cwd, [\n 'log',\n '-1',\n ref,\n '--name-only',\n `--pretty=format:${GIT_PRETTY_FORMAT}`,\n ])\n\n const entry = parseGitPrettyFormat(stdout)\n\n // The working directory is intentionally absent from the key: commit\n // hashes are content-addressed, so the same hash resolves to the same\n // commit in every repository that shares the object.\n const key = JSON.stringify([entry.hash, entry.parent, markers])\n\n const cached = cache.get(key)\n\n if (cached) return cached\n\n const parsed = await parseGitCommit(entry, markers)\n\n cache.set(key, parsed)\n\n return parsed\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Count mainline commits reachable from a given reference.\n *\n * Uses `git rev-list --count --first-parent` to calculate the length of the\n * primary history trunk, excluding commits introduced by side-branch merges.\n *\n * @param cwd Repository working directory\n * @param ref Commit reference to count from (defaults to `HEAD`)\n * @returns Number of commits along the primary branch line up to `ref`\n */\nexport async function countGitHistory(\n cwd: string,\n ref: string = 'HEAD'\n): Promise<number> {\n const stdout = await execGit(cwd, [\n 'rev-list',\n '--count',\n '--first-parent',\n ref,\n ])\n\n return Number.parseInt(stdout.trim(), 10)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Determine whether the repository at `cwd` is a shallow clone.\n *\n * Runs `git rev-parse --is-shallow-repository` to detect shallow clones.\n * Useful before operations that require full history.\n *\n * @param cwd Repository working directory\n * @returns `true` if shallow, `false` if full clone\n * @throws If the underlying Git command fails\n */\nexport async function isGitShallowRepository(cwd: string): Promise<boolean> {\n const stdout = (\n await execGit(cwd, ['rev-parse', '--is-shallow-repository'])\n ).trim()\n\n return stdout === 'true'\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { AsyncLocalStorage } from 'node:async_hooks'\nimport { isGitShallowRepository } from './isGitShallowRepository'\n\nconst lockQueue = new Map<string, Promise<void>>()\n\nconst context = new AsyncLocalStorage<Set<string>>()\n\n/**\n * Serialize access to a shallow Git repository while running a callback.\n *\n * If `cwd` is a shallow clone, callers from different async contexts are\n * executed one at a time; nested calls within the same async context run\n * immediately without waiting. If the repository becomes non-shallow before\n * a queued turn runs, downstream waiters are released early.\n *\n * @param cwd Repository working directory path string\n * @param callback Function to execute while the lock is held\n * @returns Promise resolving to the result of `callback`\n */\nexport async function withShallowLock<T>(\n cwd: string,\n callback: () => T | Promise<T>\n): Promise<T> {\n if (!(await isGitShallowRepository(cwd))) {\n return callback()\n }\n\n const active = context.getStore()\n\n if (active?.has(cwd)) {\n return callback()\n }\n\n const { promise, resolve } = Promise.withResolvers<void>()\n const previous = lockQueue.get(cwd) ?? Promise.resolve()\n const queued = previous.then(() => promise)\n\n lockQueue.set(cwd, queued)\n\n // Wait until previous tasks complete.\n await previous\n\n // If an earlier task made the repo non-shallow, release downstream waiters now.\n if (!(await isGitShallowRepository(cwd))) {\n resolve()\n }\n\n try {\n return await context.run(new Set(active).add(cwd), callback)\n } finally {\n // Ensure downstream waiters are unblocked even if callback throws.\n resolve()\n\n // Remove the queue entry only if no newer task has replaced it.\n if (lockQueue.get(cwd) === queued) {\n lockQueue.delete(cwd)\n }\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Determine whether `ancestor` is an ancestor of `descendant`.\n *\n * Runs `git merge-base --is-ancestor <ancestor> <descendant>` in the repository at `cwd`.\n * Resolves to `true` if `ancestor` is an ancestor, `false` if not.\n * Rethrows errors for invalid refs or other failures.\n *\n * @param cwd Repository working directory\n * @param ancestor Candidate ancestor ref\n * @param descendant Candidate descendant ref\n * @returns Resolves to `true` if `ancestor` is an ancestor of `descendant`, `false` otherwise\n * @throws If a ref is invalid or the Git command fails\n */\nexport function isGitAncestor(\n cwd: string,\n ancestor: string,\n descendant: string\n): Promise<boolean> {\n return execGit(cwd, ['merge-base', '--is-ancestor', ancestor, descendant])\n .then(() => true)\n .catch((err) => {\n if ((err as { code?: number })?.code === 1) {\n return false\n }\n\n throw err\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Resolve a Git revision or commit-ish expression to its full commit hash.\n *\n * Runs `git rev-parse --verify <revision>^{commit}` under the hood. Peels annotated\n * tags, branches, short SHAs, and relative expressions down to a verified commit object.\n *\n * @param cwd The repository working directory\n * @param revision The Git revision or expression to resolve\n * @returns A promise that resolves to the full, trimmed commit SHA-1 string\n */\nexport async function resolveGitRevision(\n cwd: string,\n revision: string\n): Promise<string> {\n return (\n await execGit(cwd, ['rev-parse', '--verify', `${revision}^{commit}`])\n ).trim()\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit, formatError } from '#util'\nimport type { ConsolaInstance } from 'consola/core'\nimport { isGitShallowRepository } from '../repository/isGitShallowRepository'\nimport { withShallowLock } from '../repository/withShallowLock'\nimport { isGitAncestor } from '../revision/isGitAncestor'\nimport { resolveGitRevision } from '../revision/resolveGitRevision'\nimport { countGitHistory } from './countGitHistory'\n\nexport interface ExpandGitHistoryOptions {\n /**\n * Number of commits to deepen the history by when paging\n * @default 50\n */\n pageSize?: number | undefined\n\n /**\n * Local reference used to measure current shallow depth (for example HEAD)\n * When provided the function accounts for existing depth before fetching more\n */\n from?: string | null | undefined\n\n /**\n * Target boundary reference where history deepening should stop\n * If provided the function will first attempt a single fetch to reach this commit\n */\n until?: string | null | undefined\n\n /**\n * Optional logger that receives failed fetch attempts at debug level\n */\n logger?: ConsolaInstance | undefined\n}\n\n/**\n * Deepen a shallow clone so additional commits become available.\n *\n * Attempts a single `--shallow-since` fetch to reach `until` (if provided),\n * otherwise deepens by `pageSize`, accounting for existing depth when `from`\n * is supplied. Operation is serialized to avoid concurrent deepens.\n *\n * @param cwd Repository working directory\n * @param options Options: { pageSize?, from?, until? }\n * @returns true if history was deepened or already sufficient, otherwise false\n */\nexport async function expandGitHistory(\n cwd: string,\n options: ExpandGitHistoryOptions = {}\n): Promise<boolean> {\n if (!(await isGitShallowRepository(cwd))) {\n return false\n }\n\n return withShallowLock(cwd, async () => {\n const { until } = options\n let { from } = options\n let { pageSize = 50 } = options\n\n // If an `until` boundary is provided, try a single fetch using the target commit's date\n if (until) {\n if (await isGitAncestor(cwd, until, 'HEAD')) {\n return true\n }\n\n const commitDate = (\n await execGit(cwd, ['show', '-s', '--format=%cI', `${until}^{commit}`])\n ).trim()\n\n try {\n await execGit(cwd, [\n '-c',\n 'fetch.negotiationAlgorithm=skipping',\n 'fetch',\n `--shallow-since=${commitDate}`,\n '--update-shallow',\n '--filter=blob:none',\n ])\n\n return true\n } catch (error: unknown) {\n options.logger?.debug(\n `Shallow fetch to reach \"${until}\" failed and incremental deepening will be attempted: ${formatError(error)}`\n )\n }\n }\n\n // Incremental deepening: account for existing local depth when `from` is set\n if (from) {\n from = await resolveGitRevision(cwd, from)\n\n const depth = await countGitHistory(cwd, from)\n\n if (depth > pageSize) {\n return true\n }\n\n // Reduce requested deepen amount by existing depth (exclude the `from` commit)\n pageSize -= depth - 1\n }\n\n // Perform a deepen fetch; if `from` is not an ancestor of HEAD, fetch that ref\n try {\n await execGit(cwd, [\n '-c',\n 'fetch.negotiationAlgorithm=skipping',\n 'fetch',\n `--deepen=${pageSize}`,\n '--update-shallow',\n '--filter=blob:none',\n ...(from && !(await isGitAncestor(cwd, from, 'HEAD'))\n ? ['origin', from, 'HEAD']\n : []),\n ])\n\n return true\n } catch (error: unknown) {\n options.logger?.debug(\n `Shallow history at \"${cwd}\" could not be deepened by ${pageSize} commits: ${formatError(error)}`\n )\n\n return false\n }\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Delete a local git tag in the repository at `cwd`.\n *\n * @param cwd Repository working directory\n * @param tag Tag name to delete\n * @returns `true` when deletion succeeded, otherwise `false`\n */\nexport function deleteGitTag(cwd: string, tag: string): Promise<boolean> {\n return execGit(cwd, ['tag', '-d', tag])\n .then(() => true)\n .catch(() => false)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { resolveGitRevision } from '../revision/resolveGitRevision'\n\n/**\n * Determine whether a specific git tag exists locally in the repository.\n *\n * @param cwd Working directory for the git command\n * @param tag Name of the tag to evaluate\n * @returns True if the tag reference exists locally, false otherwise\n */\nexport function isGitTagPresent(cwd: string, tag: string): Promise<boolean> {\n return resolveGitRevision(cwd, `refs/tags/${tag}`)\n .then(() => true)\n .catch(() => false)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\nimport type { ConsolaInstance } from 'consola'\nimport { countGitHistory } from '../history/countGitHistory'\nimport { withShallowLock } from '../repository/withShallowLock'\nimport { deleteGitTag } from './deleteGitTag'\nimport { isGitTagPresent } from './isGitTagPresent'\n\nconst MIN_HISTORY_DEPTH = 2\nconst ORIGIN_NOT_REPO = `fatal: 'origin' does not appear to be a git repository`\nconst REMOTE_REF_NOT_FOUND = `fatal: couldn't find remote ref`\n\n/**\n * Options guarding the destructive local tag cleanup in `ensureGitTag`.\n */\nexport interface EnsureGitTagOptions {\n /**\n * Logger warned before a stale local tag is deleted.\n */\n logger?: ConsolaInstance | undefined\n\n /**\n * Skip deleting stale local tags, warning instead.\n */\n dryRun?: boolean | undefined\n}\n\n/**\n * Ensure a tag exists locally, fetching it shallowly from `origin` if needed.\n *\n * Acquires a shallow-fetch lock, verifies local presence and history depth,\n * attempts a shallow fetch of `refs/tags/<tag>` when required, and removes a\n * local tag if the remote reports the tag is missing — warning before the\n * deletion and skipping it entirely in dry-run mode.\n *\n * @param cwd Working directory\n * @param tag Tag name (for example `v1.2.0`)\n * @param options Dry-run and logging guards for the local tag deletion\n * @returns `true` if the tag is present or was fetched; otherwise `false`\n */\nexport function ensureGitTag(\n cwd: string,\n tag: string,\n options?: EnsureGitTagOptions\n): Promise<boolean> {\n return withShallowLock(cwd, async () => {\n const tagRef = `refs/tags/${tag}`\n\n if (\n (await isGitTagPresent(cwd, tag)) &&\n (await countGitHistory(cwd, tagRef)) >= MIN_HISTORY_DEPTH\n ) {\n return true\n }\n\n try {\n await execGit(cwd, [\n 'fetch',\n 'origin',\n `${tagRef}:${tagRef}`,\n `--depth=${MIN_HISTORY_DEPTH}`,\n '--update-shallow',\n '--force',\n ])\n\n return true\n } catch (err) {\n const errorMessage = (err as Error | undefined)?.message\n\n if (errorMessage?.includes(ORIGIN_NOT_REPO)) {\n return await isGitTagPresent(cwd, tag)\n }\n\n if (errorMessage?.includes(REMOTE_REF_NOT_FOUND)) {\n if (await isGitTagPresent(cwd, tag)) {\n if (options?.dryRun) {\n options.logger?.warn(\n `[DRY RUN] Local tag \"${tag}\" would be deleted because the remote no longer reports it.`\n )\n } else {\n options?.logger?.warn(\n `Local tag \"${tag}\" is being deleted because the remote no longer reports it.`\n )\n\n await deleteGitTag(cwd, tag)\n }\n }\n }\n }\n\n return false\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Generate a git tag name for a package.\n *\n * For entry packages the tag is `v<version>`. For non-entry packages the\n * tag is `<name>@<version>`. Returns `null` when `version` is not provided.\n *\n * @param entry Whether the package is the repository entry package\n * @param name Package name (required for non-entry packages)\n * @param version Package version\n * @returns Tag string, or `null` when `version` is absent\n * @throws If a non-entry package has no name\n */\nexport function generateGitTagName(\n entry: boolean,\n name: string | null | undefined,\n version: string\n): string\nexport function generateGitTagName(\n entry: boolean,\n name: string | null | undefined,\n version: string | null | undefined\n): string | null\nexport function generateGitTagName(\n entry: boolean,\n name: string | null | undefined,\n version: string | null | undefined\n): string | null {\n if (!version) {\n return null\n }\n\n if (entry) {\n return `v${version}`\n }\n\n if (!name) {\n throw new Error('Package name is required to build a tag name.')\n }\n\n return `${name}@${version}`\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Get the message of an annotated git tag in the repository at `cwd`.\n *\n * @param cwd Repository working directory\n * @param tag Tag name to query\n * @returns The tag message string when found, otherwise `undefined`\n */\nexport async function getGitTagMessage(\n cwd: string,\n tag: string\n): Promise<string | undefined> {\n try {\n const stdout = await execGit(cwd, [\n 'for-each-ref',\n '--format=%(objecttype)%00%(contents)',\n `refs/tags/${tag}`,\n ])\n\n const [objectType, message] = stdout.split('\\0')\n\n if (objectType?.trim() !== 'tag') {\n return undefined\n }\n\n return message?.trim() || undefined\n } catch {\n /* istanbul ignore next */\n return undefined\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Determine whether a specific git tag commit is reachable from the current HEAD.\n *\n * Uses `git merge-base --is-ancestor refs/tags/<tag>^{commit} HEAD` to verify\n * that the tag's commit is an ancestor of the current reference. Any non-zero\n * exit status or execution error is treated as \"not reachable\".\n *\n * @param cwd Working directory where the git command will run\n * @param tag Tag name to evaluate (for example, \"v1.2.0\")\n * @returns True if the tag commit is reachable from HEAD, false otherwise\n */\nexport async function isGitTagConnected(\n cwd: string,\n tag: string\n): Promise<boolean> {\n try {\n await execGit(cwd, [\n 'merge-base',\n '--is-ancestor',\n `refs/tags/${tag}^{commit}`,\n 'HEAD',\n ])\n\n return true\n } catch {\n return false\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {\n ensureGitTag,\n expandGitHistory,\n getParsedGitCommit,\n isGitTagConnected,\n} from '#git'\nimport type { EnsureGitTagOptions } from '#git'\nimport type { GitCommit, Package } from '#types'\nimport { packageContainsCommit } from '../analysis/packageContainsCommit'\n\n/**\n * Verify a Git tag against package specifications and repository history.\n *\n * Ensures the target tag exists locally before parsing its commit data. Rejects\n * tags that do not target a commit matching the specified `pkg`. Expands the\n * history graph up to the tag reference before verifying structural connectivity.\n *\n * @param cwd Repository working directory path\n * @param pkg Package descriptor containing version and location context\n * @param tagName Name of the Git tag to verify\n * @param options Dry-run and logging guards for the local tag cleanup\n * @returns True if the tag is valid and connected; otherwise, false\n */\nexport async function verifyPackageTag(\n cwd: string,\n pkg: Package,\n tagName: string,\n options?: EnsureGitTagOptions\n): Promise<boolean> {\n await ensureGitTag(cwd, tagName, options)\n\n const tagRef = `refs/tags/${tagName}`\n\n let tagCommit: GitCommit\n\n try {\n tagCommit = await getParsedGitCommit(cwd, tagRef)\n } catch {\n return false\n }\n\n if (!packageContainsCommit(pkg, tagCommit)) {\n return false\n }\n\n await expandGitHistory(cwd, { until: tagRef, logger: options?.logger })\n\n return isGitTagConnected(cwd, tagName)\n}\n"],"mappings":";;;;;;;;AAMA,IAAa,YAAY;AAEzB,IAAa,yBAAyB;AAEtC,IAAa,4BAA4B;;;;;;;AAQzC,IAAM,WAAW;AACjB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;;;;;;;;;AAU3B,IAAM,gBAAgB,MAAM,SAAS,GAAG,cAAc;AAEtD,IAAM,0BAA0B,QAAQ,IADN,cAAc,IAAI,cAAc,KAAK,cAAc,GACvB;;;;;;;;;;;AAY9D,IAAM,yBAAyB,IAAI,SAAS,GAAG,mBAAmB;AAClE,IAAM,cAAc,GAAG,uBAAuB,KAAK,uBAAuB,KAAK;AAa/E,IAAM,wBAAwB,MAAM,SAAS,GAAG,mBAAmB;AAanE,IAAM,sBAAsB,GAAG,wBAAwB,GAAG,IADtB,cAAc,QAXN,sBAAsB,QAAQ,sBAAsB,MAWlB,GAAG,UAVxC,cAAc,QAAQ,cAAc,MAU2B;;;;;;;;;;;;;;AAgBxG,IAAa,eAAe,IAAI,OAAO,mBAAmB;AAE1D,IAAa,WAAW,IAAI,SAAS;;AAEnC,MAAM,QAAQ,WAAW,UAAU;CACjC,SAAS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AC;CAEtE,OAAO,kBAAkB,KAAK,OAAO;AACvC"}
|
package/dist/{propagateDependencyUpdates-xcPvP5SP.js → propagateDependencyUpdates-uFNP3wOj.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as extractVersionQualifier } from "./readPackageHistory-
|
|
2
|
-
import { S as packageContainsCommit, d as isGitAncestor } from "./package-
|
|
1
|
+
import { a as extractVersionQualifier } from "./readPackageHistory-CpX-1QuK.js";
|
|
2
|
+
import { S as packageContainsCommit, d as isGitAncestor } from "./package-ZT0zvko1.js";
|
|
3
3
|
import semver from "semver";
|
|
4
4
|
// src/workflow/version/deriveCommitReleaseType.ts
|
|
5
5
|
/**
|
|
@@ -303,4 +303,4 @@ async function propagateDependencyUpdates(cwd, plans) {
|
|
|
303
303
|
}
|
|
304
304
|
export { detectGitRelationship as a, deriveReleaseType as c, GIT_REL_FLAGS as i, pickPriorityReleaseType as l, buildDependencyGraph as n, deriveTransitionReleases as o, mergeGitHistory as r, deriveChangeReleases as s, propagateDependencyUpdates as t, deriveCommitReleaseType as u };
|
|
305
305
|
|
|
306
|
-
//# sourceMappingURL=propagateDependencyUpdates-
|
|
306
|
+
//# sourceMappingURL=propagateDependencyUpdates-uFNP3wOj.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propagateDependencyUpdates-xcPvP5SP.js","names":[],"sources":["../src/workflow/version/deriveCommitReleaseType.ts","../src/workflow/version/pickPriorityReleaseType.ts","../src/workflow/version/deriveReleaseType.ts","../src/workflow/analysis/deriveChangeReleases.ts","../src/workflow/analysis/deriveTransitionReleases.ts","../src/git/revision/detectGitRelationship.ts","../src/git/history/mergeGitHistory.ts","../src/workflow/discovery/buildDependencyGraph.ts","../src/workflow/analysis/propagateDependencyUpdates.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { CommitClassifier, GitCommit, ReleaseType } from '#types'\nimport semver from 'semver'\n\n/**\n * Derive the release type for a single commit.\n *\n * Returns `'minor'` for a commit marked as a breaking change while the\n * supplied `version` is zero-major (`0.y.z`), and `'major'` otherwise, since\n * SemVer treats `0.y.z` as initial development where breaking changes do not\n * require a new major version. Otherwise, routes the commit through the\n * custom `classifier` and ensures the resolved value is a valid semantic\n * versioning release type.\n *\n * @param classifier Function mapping commits to release types\n * @param commit Parsed commit to evaluate\n * @param version Current package version used to adjust zero-major breaking releases\n * @returns `ReleaseType` string, or `null` when no matching rule applies\n */\nexport function deriveCommitReleaseType(\n classifier: CommitClassifier,\n commit: GitCommit,\n version?: string | null | undefined\n): ReleaseType | null {\n if (commit.notes.length > 0) {\n return semver.parse(version)?.major === 0 ? 'minor' : 'major'\n }\n\n const type = classifier(commit)\n\n switch (type) {\n case 'major':\n case 'minor':\n case 'patch':\n return type\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseType } from '#types'\n\n/**\n * Determine the highest-priority release type between two candidates.\n *\n * Compares release types by precedence order: `major` > `minor` > `patch`.\n * Returns the higher-precedence type, or `null` if neither applies.\n *\n * @param curr Current accumulated release type\n * @param next Candidate release type to consider\n * @returns Highest-precedence `ReleaseType`, or `null` if neither applies\n */\nexport function pickPriorityReleaseType(\n curr: ReleaseType | null | undefined,\n next: ReleaseType | null | undefined\n): ReleaseType | null {\n for (const type of ['major', 'minor', 'patch'] satisfies ReleaseType[]) {\n if (curr === type || next === type) {\n return type\n }\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { CommitClassifier, ReleasePlan, ReleaseType } from '#types'\nimport { deriveCommitReleaseType } from './deriveCommitReleaseType'\nimport { pickPriorityReleaseType } from './pickPriorityReleaseType'\n\n/**\n * Derive the combined release type from a release plan.\n *\n * Processes the plan's commits sequentially, accumulating the\n * highest-precedence release type found by evaluating each individual commit\n * and comparing it against the current maximum via `pickPriorityReleaseType`.\n * Breaking commits resolve to `minor` while the plan's package version is\n * zero-major (`0.y.z`).\n *\n * @param classifier Function mapping commits to release types\n * @param plan Release plan carrying the commit history and package version\n * @returns `ReleaseType` string, or `null` when no matching rule applies\n */\nexport function deriveReleaseType(\n classifier: CommitClassifier,\n plan: Pick<ReleasePlan, 'history' | 'package'>\n): ReleaseType | null {\n let releaseType: ReleaseType | null = null\n\n for (const commit of plan.history) {\n releaseType = pickPriorityReleaseType(\n releaseType,\n deriveCommitReleaseType(classifier, commit, plan.package.version)\n )\n }\n\n return releaseType\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n CommitClassifier,\n GitCommit,\n ReleasePlan,\n ReleaseTypeHint,\n} from '#types'\nimport { deriveReleaseType, pickPriorityReleaseType } from '../version'\nimport { packageContainsCommit } from './packageContainsCommit'\n\n/**\n * Analyze commit history to update release plans for packages.\n *\n * Maps commit `history` across package release `plans` to associate matching\n * commits with their target packages. Calculates the release type for each\n * plan based on classified `history` and applies overrides according to the\n * provided `hint` or existing release priority. Downgrades breaking-change\n * `major` release types to `minor` while the package version is zero-major\n * (`0.y.z`).\n *\n * @param hint Release type override hint or default preference\n * @param classifier Classifier function to determine commit release types\n * @param plans List of release plans to analyze and update\n * @param history Stream or iterable of git commits to process\n * @returns Updated release plans with updated commit histories and release types\n */\nexport async function deriveChangeReleases(\n hint: ReleaseTypeHint,\n classifier: CommitClassifier,\n plans: readonly ReleasePlan[],\n history: Iterable<GitCommit> | AsyncIterable<GitCommit>\n): Promise<ReleasePlan[]> {\n for await (const commit of history) {\n plans = plans.map((plan): ReleasePlan => {\n if (!packageContainsCommit(plan.package, commit)) {\n return plan\n }\n\n return {\n ...plan,\n history: plan.history.concat(commit),\n }\n })\n }\n\n return plans.map((plan): ReleasePlan => {\n let { release } = plan\n\n let releaseType = deriveReleaseType(classifier, plan)\n\n if (releaseType) {\n switch (hint) {\n case 'major':\n case 'minor':\n case 'patch':\n releaseType = hint\n break\n default:\n releaseType = pickPriorityReleaseType(release?.type, releaseType)\n break\n }\n }\n\n if (releaseType) {\n release = {\n ...release,\n type: releaseType,\n }\n }\n\n return {\n ...plan,\n release,\n }\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n ReleasePlan,\n ReleaseType,\n ReleaseTypeHint,\n VersionTransition,\n} from '#types'\nimport semver from 'semver'\nimport { extractVersionQualifier } from '../version/extractVersionQualifier'\n\n/**\n * Derive transition release types for release plans based on version qualifiers.\n *\n * Evaluates unreleased `plans` by parsing package `semver` strings and checking\n * prerelease tags. Compares parsed version qualifiers against\n * `versionQualifier` and assigns `major`, `minor`, or `patch` release types\n * according to `hint`. When `hint` is `patch`, every package receives an\n * update: stable packages are assigned a patch release even without a\n * `versionQualifier`, and prerelease packages (pre-major, pre-minor, and\n * pre-patch cycles) continue their cycle with an incremented counter,\n * redirect to `versionQualifier` when it differs, or release their stable\n * base when no `versionQualifier` is set.\n *\n * @param hint Release type override hint to guide release classification\n * @param versionQualifier Optional qualifier string to compare against prerelease tags\n * @param plans List of release plans to analyze and update\n * @returns Updated release plans with derived transition release types\n */\nexport function deriveTransitionReleases(\n hint: ReleaseTypeHint,\n versionQualifier: string | undefined,\n plans: readonly ReleasePlan[]\n): ReleasePlan[] {\n return plans.map((plan) => {\n if (plan.release) return plan\n\n const parsed = semver.parse(plan.package.version)\n\n if (!parsed) return plan\n\n const { major, minor, patch } = parsed\n const parsedVersionQualifier = extractVersionQualifier(parsed)\n let releaseType: ReleaseType | undefined\n let versionTransition: VersionTransition | undefined\n\n switch (hint) {\n case 'major':\n if (parsed.prerelease.length === 0) {\n if (typeof versionQualifier === 'string') {\n releaseType = 'major'\n } else if (major === 0 && (minor > 0 || patch > 0)) {\n releaseType = 'major'\n }\n } else {\n if (\n minor === 0 &&\n patch === 0 &&\n parsedVersionQualifier !== versionQualifier\n ) {\n releaseType = 'major'\n }\n }\n break\n\n case 'minor':\n if (parsed.prerelease.length === 0) {\n if (typeof versionQualifier === 'string') {\n releaseType = 'minor'\n }\n } else {\n if (\n minor > 0 &&\n patch === 0 &&\n parsedVersionQualifier !== versionQualifier\n ) {\n releaseType = 'minor'\n }\n }\n break\n\n case 'patch':\n releaseType = 'patch'\n break\n\n default:\n if (parsed.prerelease.length === 0) {\n if (major === 0 && (minor > 0 || patch > 0)) {\n releaseType = 'major'\n }\n } else {\n if (\n minor === 0 &&\n patch === 0 &&\n parsedVersionQualifier !== versionQualifier\n ) {\n releaseType = 'major'\n } else if (\n minor > 0 &&\n patch === 0 &&\n parsedVersionQualifier !== versionQualifier\n ) {\n releaseType = 'minor'\n } else if (patch > 0 && parsedVersionQualifier !== versionQualifier) {\n releaseType = 'patch'\n }\n }\n break\n }\n\n if (\n parsedVersionQualifier == null ||\n (parsedVersionQualifier !== '' && versionQualifier === '')\n ) {\n versionTransition = 'advance'\n } else {\n versionTransition = 'continue'\n }\n\n if (!releaseType) return plan\n\n return {\n ...plan,\n release: {\n type: releaseType,\n transition: versionTransition,\n },\n }\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { isGitAncestor } from './isGitAncestor'\n\nexport const GIT_REL_FLAGS = {\n NONE: 0,\n IS_ANCESTOR: 1,\n IS_DESCENDANT: 2,\n IS_EQUAL: 3,\n} as const\n\nexport type GitRelFlags = (typeof GIT_REL_FLAGS)[keyof typeof GIT_REL_FLAGS]\n\n/**\n * Determine the relationship between two git refs.\n *\n * Runs `git merge-base --is-ancestor` in both directions and returns a\n * numeric bitmask using `GIT_REL_FLAGS`. A successful check (exit code 0)\n * indicates an ancestor relationship; non-zero exit is treated as \"not ancestor\".\n *\n * @param cwd Repository working directory\n * @param refA First ref (candidate ancestor)\n * @param refB Second ref (candidate descendant)\n * @returns Bitmask of type `GitRelFlags`\n */\nexport async function detectGitRelationship(\n cwd: string,\n refA: string,\n refB: string\n): Promise<GitRelFlags> {\n let flags = GIT_REL_FLAGS.NONE\n\n const [aIsAncestor, bIsAncestor] = await Promise.all([\n isGitAncestor(cwd, refA, refB),\n isGitAncestor(cwd, refB, refA),\n ])\n\n if (aIsAncestor) flags |= GIT_REL_FLAGS.IS_ANCESTOR\n if (bIsAncestor) flags |= GIT_REL_FLAGS.IS_DESCENDANT\n\n return flags as GitRelFlags\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { GitCommit } from '#types'\nimport {\n detectGitRelationship,\n GIT_REL_FLAGS,\n} from '../revision/detectGitRelationship'\n\n/**\n * Merge two newest-first commit lists into a single deduplicated newest-first list.\n *\n * Compares commits by hash, uses git relationship (ancestor/descendant) when needed,\n * and falls back to committerDate for unrelated commits.\n *\n * @param cwd Repository working directory used for relationship checks\n * @param a Commits from the first source (newest-first)\n * @param b Commits from the second source (newest-first)\n * @returns Merged commits in newest-first order with duplicates removed\n */\nexport async function mergeGitHistory(\n cwd: string,\n a: readonly GitCommit[],\n b: readonly GitCommit[]\n): Promise<GitCommit[]> {\n const merged: GitCommit[] = []\n const a2 = [...a]\n const b2 = [...b]\n let i = a2.shift()\n let j = b2.shift()\n\n while (i && j) {\n const rel =\n i.hash === j.hash\n ? GIT_REL_FLAGS.IS_EQUAL\n : await detectGitRelationship(cwd, i.hash, j.hash)\n\n switch (rel) {\n case GIT_REL_FLAGS.IS_EQUAL:\n merged.push(i)\n i = a2.shift()\n j = b2.shift()\n break\n\n case GIT_REL_FLAGS.IS_ANCESTOR:\n merged.push(j)\n j = b2.shift()\n break\n\n case GIT_REL_FLAGS.IS_DESCENDANT:\n merged.push(i)\n i = a2.shift()\n break\n\n case GIT_REL_FLAGS.NONE:\n if (i.committerDate < j.committerDate) {\n merged.push(j)\n j = b2.shift()\n } else {\n merged.push(i)\n i = a2.shift()\n }\n break\n }\n }\n\n if (i) {\n merged.push(i)\n }\n\n if (j) {\n merged.push(j)\n }\n\n return merged.concat(a2).concat(b2)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleasePlan } from '#types'\n\nexport type DependencyGraph = Map<string, Set<ReleasePlan>>\n\n/**\n * Build a dependency graph mapping package names to dependent release plans.\n *\n * Each key is a package name and the value is a set of `ReleasePlan`s that\n * list that package as a dependency.\n *\n * @param plans Array of release plans to analyze\n * @returns Dependency graph mapping package name -> set of dependent plans\n */\nexport function buildDependencyGraph(\n plans: readonly ReleasePlan[]\n): DependencyGraph {\n const graph = new Map<string, Set<ReleasePlan>>()\n\n const packageNames = new Set(\n plans\n .map((plan) => plan.package.name)\n .filter((name): name is string => !!name)\n )\n\n for (const plan of plans) {\n for (const depName of plan.package.dependencies) {\n let set = graph.get(depName)\n\n if (!set && packageNames.has(depName)) {\n graph.set(depName, (set = new Set()))\n }\n\n if (set) {\n set.add(plan)\n }\n }\n }\n\n return graph\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { mergeGitHistory } from '#git'\nimport type { GitCommit, ReleasePlan } from '#types'\nimport { buildDependencyGraph } from '../discovery'\n\n/**\n * Propagate release updates through package dependencies.\n *\n * Marks packages that depend on a releasing package for a `patch` release\n * when they do not already have a release type.\n *\n * @param cwd Working directory path used to read Git history\n * @param plans Array of release plans to update\n * @returns Updated array of release plans\n */\nexport async function propagateDependencyUpdates(\n cwd: string,\n plans: readonly ReleasePlan[]\n): Promise<ReleasePlan[]> {\n const graph = buildDependencyGraph(plans)\n\n const scheduled = new Map<ReleasePlan, GitCommit[]>()\n\n const stack: ReleasePlan[] = []\n\n for (const plan of plans) {\n if (plan.release?.type) {\n const visited = new Set([plan])\n\n stack.push(plan)\n\n let curr: ReleasePlan | undefined\n\n while ((curr = stack.pop())) {\n if (curr.package.name) {\n for (const dependent of graph.get(curr.package.name) ?? []) {\n if (!visited.has(dependent)) {\n visited.add(dependent)\n\n stack.push(dependent)\n\n scheduled.set(\n dependent,\n await mergeGitHistory(\n cwd,\n scheduled.get(dependent) ?? dependent.history,\n plan.history\n )\n )\n }\n }\n }\n }\n }\n }\n\n return plans.map((plan) => {\n const history = scheduled.get(plan)\n\n if (history) {\n plan = { ...plan, history }\n\n if (!plan.release?.type) {\n plan.release = { type: 'patch' }\n }\n }\n\n return plan\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,wBACd,YACA,QACA,SACoB;CACpB,IAAI,OAAO,MAAM,SAAS,GACxB,OAAO,OAAO,MAAM,OAAO,CAAC,EAAE,UAAU,IAAI,UAAU;CAGxD,MAAM,OAAO,WAAW,MAAM;CAE9B,QAAQ,MAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,SACH,OAAO;CACX;CAEA,OAAO;AACT;;;;;;;;;;;;ACzBA,SAAgB,wBACd,MACA,MACoB;CACpB,KAAK,MAAM,QAAQ;EAAC;EAAS;EAAS;CAAO,GAC3C,IAAI,SAAS,QAAQ,SAAS,MAC5B,OAAO;CAIX,OAAO;AACT;;;;;;;;;;;;;;;ACNA,SAAgB,kBACd,YACA,MACoB;CACpB,IAAI,cAAkC;CAEtC,KAAK,MAAM,UAAU,KAAK,SACxB,cAAc,wBACZ,aACA,wBAAwB,YAAY,QAAQ,KAAK,QAAQ,OAAO,CAClE;CAGF,OAAO;AACT;;;;;;;;;;;;;;;;;;ACNA,eAAsB,qBACpB,MACA,YACA,OACA,SACwB;CACxB,WAAW,MAAM,UAAU,SACzB,QAAQ,MAAM,KAAK,SAAsB;EACvC,IAAI,CAAC,sBAAsB,KAAK,SAAS,MAAM,GAC7C,OAAO;EAGT,OAAO;GACL,GAAG;GACH,SAAS,KAAK,QAAQ,OAAO,MAAM;EACrC;CACF,CAAC;CAGH,OAAO,MAAM,KAAK,SAAsB;EACtC,IAAI,EAAE,YAAY;EAElB,IAAI,cAAc,kBAAkB,YAAY,IAAI;EAEpD,IAAI,aACF,QAAQ,MAAR;GACE,KAAK;GACL,KAAK;GACL,KAAK;IACH,cAAc;IACd;GACF,SACE,cAAc,wBAAwB,SAAS,MAAM,WAAW;EAEpE;EAGF,IAAI,aACF,UAAU;GACR,GAAG;GACH,MAAM;EACR;EAGF,OAAO;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1
|
+
{"version":3,"file":"propagateDependencyUpdates-uFNP3wOj.js","names":[],"sources":["../src/workflow/version/deriveCommitReleaseType.ts","../src/workflow/version/pickPriorityReleaseType.ts","../src/workflow/version/deriveReleaseType.ts","../src/workflow/analysis/deriveChangeReleases.ts","../src/workflow/analysis/deriveTransitionReleases.ts","../src/git/revision/detectGitRelationship.ts","../src/git/history/mergeGitHistory.ts","../src/workflow/discovery/buildDependencyGraph.ts","../src/workflow/analysis/propagateDependencyUpdates.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { CommitClassifier, GitCommit, ReleaseType } from '#types'\nimport semver from 'semver'\n\n/**\n * Derive the release type for a single commit.\n *\n * Returns `'minor'` for a commit marked as a breaking change while the\n * supplied `version` is zero-major (`0.y.z`), and `'major'` otherwise, since\n * SemVer treats `0.y.z` as initial development where breaking changes do not\n * require a new major version. Otherwise, routes the commit through the\n * custom `classifier` and ensures the resolved value is a valid semantic\n * versioning release type.\n *\n * @param classifier Function mapping commits to release types\n * @param commit Parsed commit to evaluate\n * @param version Current package version used to adjust zero-major breaking releases\n * @returns `ReleaseType` string, or `null` when no matching rule applies\n */\nexport function deriveCommitReleaseType(\n classifier: CommitClassifier,\n commit: GitCommit,\n version?: string | null | undefined\n): ReleaseType | null {\n if (commit.notes.length > 0) {\n return semver.parse(version)?.major === 0 ? 'minor' : 'major'\n }\n\n const type = classifier(commit)\n\n switch (type) {\n case 'major':\n case 'minor':\n case 'patch':\n return type\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseType } from '#types'\n\n/**\n * Determine the highest-priority release type between two candidates.\n *\n * Compares release types by precedence order: `major` > `minor` > `patch`.\n * Returns the higher-precedence type, or `null` if neither applies.\n *\n * @param curr Current accumulated release type\n * @param next Candidate release type to consider\n * @returns Highest-precedence `ReleaseType`, or `null` if neither applies\n */\nexport function pickPriorityReleaseType(\n curr: ReleaseType | null | undefined,\n next: ReleaseType | null | undefined\n): ReleaseType | null {\n for (const type of ['major', 'minor', 'patch'] satisfies ReleaseType[]) {\n if (curr === type || next === type) {\n return type\n }\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { CommitClassifier, ReleasePlan, ReleaseType } from '#types'\nimport { deriveCommitReleaseType } from './deriveCommitReleaseType'\nimport { pickPriorityReleaseType } from './pickPriorityReleaseType'\n\n/**\n * Derive the combined release type from a release plan.\n *\n * Processes the plan's commits sequentially, accumulating the\n * highest-precedence release type found by evaluating each individual commit\n * and comparing it against the current maximum via `pickPriorityReleaseType`.\n * Breaking commits resolve to `minor` while the plan's package version is\n * zero-major (`0.y.z`).\n *\n * @param classifier Function mapping commits to release types\n * @param plan Release plan carrying the commit history and package version\n * @returns `ReleaseType` string, or `null` when no matching rule applies\n */\nexport function deriveReleaseType(\n classifier: CommitClassifier,\n plan: Pick<ReleasePlan, 'history' | 'package'>\n): ReleaseType | null {\n let releaseType: ReleaseType | null = null\n\n for (const commit of plan.history) {\n releaseType = pickPriorityReleaseType(\n releaseType,\n deriveCommitReleaseType(classifier, commit, plan.package.version)\n )\n }\n\n return releaseType\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n CommitClassifier,\n GitCommit,\n ReleasePlan,\n ReleaseTypeHint,\n} from '#types'\nimport { deriveReleaseType, pickPriorityReleaseType } from '../version'\nimport { packageContainsCommit } from './packageContainsCommit'\n\n/**\n * Analyze commit history to update release plans for packages.\n *\n * Maps commit `history` across package release `plans` to associate matching\n * commits with their target packages. Calculates the release type for each\n * plan based on classified `history` and applies overrides according to the\n * provided `hint` or existing release priority. Downgrades breaking-change\n * `major` release types to `minor` while the package version is zero-major\n * (`0.y.z`).\n *\n * @param hint Release type override hint or default preference\n * @param classifier Classifier function to determine commit release types\n * @param plans List of release plans to analyze and update\n * @param history Stream or iterable of git commits to process\n * @returns Updated release plans with updated commit histories and release types\n */\nexport async function deriveChangeReleases(\n hint: ReleaseTypeHint,\n classifier: CommitClassifier,\n plans: readonly ReleasePlan[],\n history: Iterable<GitCommit> | AsyncIterable<GitCommit>\n): Promise<ReleasePlan[]> {\n for await (const commit of history) {\n plans = plans.map((plan): ReleasePlan => {\n if (!packageContainsCommit(plan.package, commit)) {\n return plan\n }\n\n return {\n ...plan,\n history: plan.history.concat(commit),\n }\n })\n }\n\n return plans.map((plan): ReleasePlan => {\n let { release } = plan\n\n let releaseType = deriveReleaseType(classifier, plan)\n\n if (releaseType) {\n switch (hint) {\n case 'major':\n case 'minor':\n case 'patch':\n releaseType = hint\n break\n default:\n releaseType = pickPriorityReleaseType(release?.type, releaseType)\n break\n }\n }\n\n if (releaseType) {\n release = {\n ...release,\n type: releaseType,\n }\n }\n\n return {\n ...plan,\n release,\n }\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n ReleasePlan,\n ReleaseType,\n ReleaseTypeHint,\n VersionTransition,\n} from '#types'\nimport semver from 'semver'\nimport { extractVersionQualifier } from '../version/extractVersionQualifier'\n\n/**\n * Derive transition release types for release plans based on version qualifiers.\n *\n * Evaluates unreleased `plans` by parsing package `semver` strings and checking\n * prerelease tags. Compares parsed version qualifiers against\n * `versionQualifier` and assigns `major`, `minor`, or `patch` release types\n * according to `hint`. When `hint` is `patch`, every package receives an\n * update: stable packages are assigned a patch release even without a\n * `versionQualifier`, and prerelease packages (pre-major, pre-minor, and\n * pre-patch cycles) continue their cycle with an incremented counter,\n * redirect to `versionQualifier` when it differs, or release their stable\n * base when no `versionQualifier` is set.\n *\n * @param hint Release type override hint to guide release classification\n * @param versionQualifier Optional qualifier string to compare against prerelease tags\n * @param plans List of release plans to analyze and update\n * @returns Updated release plans with derived transition release types\n */\nexport function deriveTransitionReleases(\n hint: ReleaseTypeHint,\n versionQualifier: string | undefined,\n plans: readonly ReleasePlan[]\n): ReleasePlan[] {\n return plans.map((plan) => {\n if (plan.release) return plan\n\n const parsed = semver.parse(plan.package.version)\n\n if (!parsed) return plan\n\n const { major, minor, patch } = parsed\n const parsedVersionQualifier = extractVersionQualifier(parsed)\n let releaseType: ReleaseType | undefined\n let versionTransition: VersionTransition | undefined\n\n switch (hint) {\n case 'major':\n if (parsed.prerelease.length === 0) {\n if (typeof versionQualifier === 'string') {\n releaseType = 'major'\n } else if (major === 0 && (minor > 0 || patch > 0)) {\n releaseType = 'major'\n }\n } else {\n if (\n minor === 0 &&\n patch === 0 &&\n parsedVersionQualifier !== versionQualifier\n ) {\n releaseType = 'major'\n }\n }\n break\n\n case 'minor':\n if (parsed.prerelease.length === 0) {\n if (typeof versionQualifier === 'string') {\n releaseType = 'minor'\n }\n } else {\n if (\n minor > 0 &&\n patch === 0 &&\n parsedVersionQualifier !== versionQualifier\n ) {\n releaseType = 'minor'\n }\n }\n break\n\n case 'patch':\n releaseType = 'patch'\n break\n\n default:\n if (parsed.prerelease.length === 0) {\n if (major === 0 && (minor > 0 || patch > 0)) {\n releaseType = 'major'\n }\n } else {\n if (\n minor === 0 &&\n patch === 0 &&\n parsedVersionQualifier !== versionQualifier\n ) {\n releaseType = 'major'\n } else if (\n minor > 0 &&\n patch === 0 &&\n parsedVersionQualifier !== versionQualifier\n ) {\n releaseType = 'minor'\n } else if (patch > 0 && parsedVersionQualifier !== versionQualifier) {\n releaseType = 'patch'\n }\n }\n break\n }\n\n if (\n parsedVersionQualifier == null ||\n (parsedVersionQualifier !== '' && versionQualifier === '')\n ) {\n versionTransition = 'advance'\n } else {\n versionTransition = 'continue'\n }\n\n if (!releaseType) return plan\n\n return {\n ...plan,\n release: {\n type: releaseType,\n transition: versionTransition,\n },\n }\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { isGitAncestor } from './isGitAncestor'\n\nexport const GIT_REL_FLAGS = {\n NONE: 0,\n IS_ANCESTOR: 1,\n IS_DESCENDANT: 2,\n IS_EQUAL: 3,\n} as const\n\nexport type GitRelFlags = (typeof GIT_REL_FLAGS)[keyof typeof GIT_REL_FLAGS]\n\n/**\n * Determine the relationship between two git refs.\n *\n * Runs `git merge-base --is-ancestor` in both directions and returns a\n * numeric bitmask using `GIT_REL_FLAGS`. A successful check (exit code 0)\n * indicates an ancestor relationship; non-zero exit is treated as \"not ancestor\".\n *\n * @param cwd Repository working directory\n * @param refA First ref (candidate ancestor)\n * @param refB Second ref (candidate descendant)\n * @returns Bitmask of type `GitRelFlags`\n */\nexport async function detectGitRelationship(\n cwd: string,\n refA: string,\n refB: string\n): Promise<GitRelFlags> {\n let flags = GIT_REL_FLAGS.NONE\n\n const [aIsAncestor, bIsAncestor] = await Promise.all([\n isGitAncestor(cwd, refA, refB),\n isGitAncestor(cwd, refB, refA),\n ])\n\n if (aIsAncestor) flags |= GIT_REL_FLAGS.IS_ANCESTOR\n if (bIsAncestor) flags |= GIT_REL_FLAGS.IS_DESCENDANT\n\n return flags as GitRelFlags\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { GitCommit } from '#types'\nimport {\n detectGitRelationship,\n GIT_REL_FLAGS,\n} from '../revision/detectGitRelationship'\n\n/**\n * Merge two newest-first commit lists into a single deduplicated newest-first list.\n *\n * Compares commits by hash, uses git relationship (ancestor/descendant) when needed,\n * and falls back to committerDate for unrelated commits.\n *\n * @param cwd Repository working directory used for relationship checks\n * @param a Commits from the first source (newest-first)\n * @param b Commits from the second source (newest-first)\n * @returns Merged commits in newest-first order with duplicates removed\n */\nexport async function mergeGitHistory(\n cwd: string,\n a: readonly GitCommit[],\n b: readonly GitCommit[]\n): Promise<GitCommit[]> {\n const merged: GitCommit[] = []\n const a2 = [...a]\n const b2 = [...b]\n let i = a2.shift()\n let j = b2.shift()\n\n while (i && j) {\n const rel =\n i.hash === j.hash\n ? GIT_REL_FLAGS.IS_EQUAL\n : await detectGitRelationship(cwd, i.hash, j.hash)\n\n switch (rel) {\n case GIT_REL_FLAGS.IS_EQUAL:\n merged.push(i)\n i = a2.shift()\n j = b2.shift()\n break\n\n case GIT_REL_FLAGS.IS_ANCESTOR:\n merged.push(j)\n j = b2.shift()\n break\n\n case GIT_REL_FLAGS.IS_DESCENDANT:\n merged.push(i)\n i = a2.shift()\n break\n\n case GIT_REL_FLAGS.NONE:\n if (i.committerDate < j.committerDate) {\n merged.push(j)\n j = b2.shift()\n } else {\n merged.push(i)\n i = a2.shift()\n }\n break\n }\n }\n\n if (i) {\n merged.push(i)\n }\n\n if (j) {\n merged.push(j)\n }\n\n return merged.concat(a2).concat(b2)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleasePlan } from '#types'\n\nexport type DependencyGraph = Map<string, Set<ReleasePlan>>\n\n/**\n * Build a dependency graph mapping package names to dependent release plans.\n *\n * Each key is a package name and the value is a set of `ReleasePlan`s that\n * list that package as a dependency.\n *\n * @param plans Array of release plans to analyze\n * @returns Dependency graph mapping package name -> set of dependent plans\n */\nexport function buildDependencyGraph(\n plans: readonly ReleasePlan[]\n): DependencyGraph {\n const graph = new Map<string, Set<ReleasePlan>>()\n\n const packageNames = new Set(\n plans\n .map((plan) => plan.package.name)\n .filter((name): name is string => !!name)\n )\n\n for (const plan of plans) {\n for (const depName of plan.package.dependencies) {\n let set = graph.get(depName)\n\n if (!set && packageNames.has(depName)) {\n graph.set(depName, (set = new Set()))\n }\n\n if (set) {\n set.add(plan)\n }\n }\n }\n\n return graph\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { mergeGitHistory } from '#git'\nimport type { GitCommit, ReleasePlan } from '#types'\nimport { buildDependencyGraph } from '../discovery'\n\n/**\n * Propagate release updates through package dependencies.\n *\n * Marks packages that depend on a releasing package for a `patch` release\n * when they do not already have a release type.\n *\n * @param cwd Working directory path used to read Git history\n * @param plans Array of release plans to update\n * @returns Updated array of release plans\n */\nexport async function propagateDependencyUpdates(\n cwd: string,\n plans: readonly ReleasePlan[]\n): Promise<ReleasePlan[]> {\n const graph = buildDependencyGraph(plans)\n\n const scheduled = new Map<ReleasePlan, GitCommit[]>()\n\n const stack: ReleasePlan[] = []\n\n for (const plan of plans) {\n if (plan.release?.type) {\n const visited = new Set([plan])\n\n stack.push(plan)\n\n let curr: ReleasePlan | undefined\n\n while ((curr = stack.pop())) {\n if (curr.package.name) {\n for (const dependent of graph.get(curr.package.name) ?? []) {\n if (!visited.has(dependent)) {\n visited.add(dependent)\n\n stack.push(dependent)\n\n scheduled.set(\n dependent,\n await mergeGitHistory(\n cwd,\n scheduled.get(dependent) ?? dependent.history,\n plan.history\n )\n )\n }\n }\n }\n }\n }\n }\n\n return plans.map((plan) => {\n const history = scheduled.get(plan)\n\n if (history) {\n plan = { ...plan, history }\n\n if (!plan.release?.type) {\n plan.release = { type: 'patch' }\n }\n }\n\n return plan\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,wBACd,YACA,QACA,SACoB;CACpB,IAAI,OAAO,MAAM,SAAS,GACxB,OAAO,OAAO,MAAM,OAAO,CAAC,EAAE,UAAU,IAAI,UAAU;CAGxD,MAAM,OAAO,WAAW,MAAM;CAE9B,QAAQ,MAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,SACH,OAAO;CACX;CAEA,OAAO;AACT;;;;;;;;;;;;ACzBA,SAAgB,wBACd,MACA,MACoB;CACpB,KAAK,MAAM,QAAQ;EAAC;EAAS;EAAS;CAAO,GAC3C,IAAI,SAAS,QAAQ,SAAS,MAC5B,OAAO;CAIX,OAAO;AACT;;;;;;;;;;;;;;;ACNA,SAAgB,kBACd,YACA,MACoB;CACpB,IAAI,cAAkC;CAEtC,KAAK,MAAM,UAAU,KAAK,SACxB,cAAc,wBACZ,aACA,wBAAwB,YAAY,QAAQ,KAAK,QAAQ,OAAO,CAClE;CAGF,OAAO;AACT;;;;;;;;;;;;;;;;;;ACNA,eAAsB,qBACpB,MACA,YACA,OACA,SACwB;CACxB,WAAW,MAAM,UAAU,SACzB,QAAQ,MAAM,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,GACvD,IAAI,CAAC,QAAQ,IAAI,SAAS,GAAG;IAC3B,QAAQ,IAAI,SAAS;IAErB,MAAM,KAAK,SAAS;IAEpB,UAAU,IACR,WACA,MAAM,gBACJ,KACA,UAAU,IAAI,SAAS,KAAK,UAAU,SACtC,KAAK,OACP,CACF;GACF;;CAIR;CAGF,OAAO,MAAM,KAAK,SAAS;EACzB,MAAM,UAAU,UAAU,IAAI,IAAI;EAElC,IAAI,SAAS;GACX,OAAO;IAAE,GAAG;IAAM;GAAQ;GAE1B,IAAI,CAAC,KAAK,SAAS,MACjB,KAAK,UAAU,EAAE,MAAM,QAAQ;EAEnC;EAEA,OAAO;CACT,CAAC;AACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as packageContainsCommit, T as execGit, h as getParsedGitCommit, l as expandGitHistory, u as resolveGitRevision, w as formatError } from "./package-
|
|
1
|
+
import { S as packageContainsCommit, T as execGit, h as getParsedGitCommit, l as expandGitHistory, u as resolveGitRevision, w as formatError } from "./package-ZT0zvko1.js";
|
|
2
2
|
// src/workflow/version/extractVersionQualifier.ts
|
|
3
3
|
/**
|
|
4
4
|
* Extract the version qualifier string from a parsed `SemVer` instance.
|
|
@@ -130,4 +130,4 @@ async function* readPackageHistory(cwd, pkg, options = {}) {
|
|
|
130
130
|
}
|
|
131
131
|
export { extractVersionQualifier as a, unique as i, readParsedGitHistory as n, readGitHistory as r, readPackageHistory as t };
|
|
132
132
|
|
|
133
|
-
//# sourceMappingURL=readPackageHistory-
|
|
133
|
+
//# sourceMappingURL=readPackageHistory-CpX-1QuK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readPackageHistory-
|
|
1
|
+
{"version":3,"file":"readPackageHistory-CpX-1QuK.js","names":[],"sources":["../src/workflow/version/extractVersionQualifier.ts","../src/util/unique.ts","../src/git/history/readGitHistory.ts","../src/git/history/readParsedGitHistory.ts","../src/workflow/analysis/readPackageHistory.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type semver from 'semver'\n\n/**\n * Extract the version qualifier string from a parsed `SemVer` instance.\n *\n * Strips the trailing numeric counter from the `prerelease` components if\n * present. Joins any remaining prerelease identifiers with a dot separator.\n *\n * @param version Parsed `SemVer` instance or nullish value to inspect\n * @returns The extracted qualifier string or `undefined` if no prerelease exists\n */\nexport function extractVersionQualifier(\n version: semver.SemVer | null | undefined\n): string | undefined {\n if (version != null && version.prerelease.length > 0) {\n const prerelease = [...version.prerelease]\n\n if (typeof prerelease.at(-1) === 'number') {\n prerelease.pop()\n }\n\n return prerelease.join('.')\n } else {\n return undefined\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 { execGit } from '#util'\nimport { resolveGitRevision } from '../revision/resolveGitRevision'\nimport {\n expandGitHistory,\n type ExpandGitHistoryOptions,\n} from './expandGitHistory'\n\nexport interface ReadGitHistoryOptions extends ExpandGitHistoryOptions {\n filePath?: string | readonly string[] | undefined\n}\n\n/**\n * Yield commit SHAs from repository history in paginated order.\n *\n * Ensures commits are available via `expandGitHistory`, resolves `until` to a\n * commit id, and pages from `from` toward `until`, yielding each commit SHA.\n * If a git command fails the generator ends silently.\n *\n * @param cwd Repository working directory\n * @param options Supports `from`, `until`, `pageSize`, and `filePath`\n * @yields Commit SHA strings in paginated order\n */\nexport async function* readGitHistory(\n cwd: string,\n options: ReadGitHistoryOptions = {}\n): AsyncGenerator<string> {\n try {\n const { filePath, pageSize = 50 } = options\n let from = options.from || 'HEAD'\n let until = options.until || undefined\n\n if (until) {\n until = await resolveGitRevision(cwd, until)\n }\n\n while (true) {\n await expandGitHistory(cwd, { from, until, pageSize })\n\n const args = ['rev-list', `--max-count=${pageSize}`, from]\n\n if (until) {\n args.push(`^${until}`)\n }\n\n if (filePath) {\n args.push(\n '--',\n ...(Array.isArray(filePath) ? filePath : [filePath]).filter(Boolean)\n )\n }\n\n const stdout = await execGit(cwd, args)\n\n const list = stdout.trim().split('\\n').filter(Boolean)\n\n for (const item of list.slice(0, -1)) {\n yield item\n }\n\n const tail = list.at(-1)\n\n if (!tail) {\n return\n }\n\n if (tail === from) {\n yield tail\n\n from = `${tail}^`\n\n from = await resolveGitRevision(cwd, from)\n } else {\n from = tail\n }\n }\n } catch {}\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { GitCommit } from '#types'\nimport { formatError } from '#util'\nimport { getParsedGitCommit } from '../commit/getParsedGitCommit'\nimport { readGitHistory, type ReadGitHistoryOptions } from './readGitHistory'\n\n/**\n * Yield parsed commits sequentially from repository history.\n *\n * Fetches commits using `readGitHistory` and parses each commit with\n * `getParsedGitCommit`. Yields successfully parsed `GitCommit` objects on demand\n * and skips unparsable commits, reporting each skipped commit through\n * `options.logger` at debug level when one is provided.\n *\n * @param cwd Repository working directory path\n * @param options Filter and pagination options passed to `readGitHistory`\n * @yields Parsed `GitCommit` objects in historical order\n */\nexport async function* readParsedGitHistory(\n cwd: string,\n options?: ReadGitHistoryOptions\n): AsyncGenerator<GitCommit> {\n for await (const commit of readGitHistory(cwd, options)) {\n try {\n yield await getParsedGitCommit(cwd, commit)\n } catch (error: unknown) {\n options?.logger?.debug(\n `Commit \"${commit}\" could not be parsed and was skipped: ${formatError(error)}`\n )\n }\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { readParsedGitHistory, type ReadGitHistoryOptions } from '#git'\nimport type { GitCommit, Package } from '#types'\nimport { unique } from '#util'\nimport { packageContainsCommit } from './packageContainsCommit'\n\nconst LITERAL_PATH = /^[^*?[\\]{}!+@]*$/\n\n/**\n * Yield commits from git history associated with a package.\n *\n * Filters git commit history to yield only entries relevant to the target\n * `pkg` directory. When the package file pattern is a list, plain file\n * entries are added to the git path filter alongside the package directory\n * (duplicates removed), so commits touching extra package files (for example\n * the pnpm workspace manifest) are included. Only entries without glob or\n * pattern metacharacters (wildcards, braces, and the extglob or negation\n * characters used by package file patterns) are passed to git, because git\n * pathspecs would interpret those characters differently. Pattern-like\n * entries are left to `packageContainsCommit`, which matches them with the\n * package's own file-pattern semantics.\n *\n * @param cwd Path to the working directory for git commands\n * @param pkg Package configuration containing the target directory\n * @param options Options for parsing and filtering git history\n * @yields Commits belonging to the specified package\n */\nexport async function* readPackageHistory(\n cwd: string,\n pkg: Package,\n options: ReadGitHistoryOptions = {}\n): AsyncGenerator<GitCommit> {\n options = { ...options }\n\n if (!options.filePath) {\n if (Array.isArray(pkg.files)) {\n options.filePath = unique([\n pkg.location,\n ...pkg.files.filter((file) => LITERAL_PATH.test(file)),\n ])\n } else {\n options.filePath = pkg.location\n }\n }\n\n for await (const commit of readParsedGitHistory(cwd, options)) {\n if (packageContainsCommit(pkg, commit)) {\n yield commit\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAcA,SAAgB,wBACd,SACoB;CACpB,IAAI,WAAW,QAAQ,QAAQ,WAAW,SAAS,GAAG;EACpD,MAAM,aAAa,CAAC,GAAG,QAAQ,UAAU;EAEzC,IAAI,OAAO,WAAW,GAAG,EAAE,MAAM,UAC/B,WAAW,IAAI;EAGjB,OAAO,WAAW,KAAK,GAAG;CAC5B,OACE;AAEJ;;;;;;;;;;;;ACfA,SAAgB,OAAU,OAA0B;CAClD,MAAM,uBAAO,IAAI,IAAO;CACxB,MAAM,SAAc,CAAC;CAErB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,KA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eAAe;;;;;;;;;;;;;;;;;;;;AAqBrB,gBAAuB,mBACrB,KACA,KACA,UAAiC,CAAC,GACP;CAC3B,UAAU,EAAE,GAAG,QAAQ;CAEvB,IAAI,CAAC,QAAQ,UAAU;EACrB,IAAI,MAAM,QAAQ,IAAI,KAAK,GACzB,QAAQ,WAAW,OAAO,CACxB,IAAI,UACJ,GAAG,IAAI,MAAM,QAAQ,SAAS,aAAa,KAAK,IAAI,CAAC,CACvD,CAAC;OAED,QAAQ,WAAW,IAAI;CAE3B;CAEA,WAAW,MAAM,UAAU,qBAAqB,KAAK,OAAO,GAC1D,IAAI,sBAAsB,KAAK,MAAM,GACnC,MAAM;AAGZ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as generateGitTagName, i as getGitTagMessage, n as verifyPackageTag } from "./package-
|
|
1
|
+
import { a as generateGitTagName, i as getGitTagMessage, n as verifyPackageTag } from "./package-ZT0zvko1.js";
|
|
2
2
|
// src/workflow/discovery/resolvePackageTag.ts
|
|
3
3
|
/**
|
|
4
4
|
* Resolve the release tag for a single package version.
|
|
@@ -27,4 +27,4 @@ async function resolvePackageTag(cwd, pkg, options) {
|
|
|
27
27
|
}
|
|
28
28
|
export { resolvePackageTag as t };
|
|
29
29
|
|
|
30
|
-
//# sourceMappingURL=resolvePackageTag-
|
|
30
|
+
//# sourceMappingURL=resolvePackageTag-pPUPCCmI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePackageTag-
|
|
1
|
+
{"version":3,"file":"resolvePackageTag-pPUPCCmI.js","names":[],"sources":["../src/workflow/discovery/resolvePackageTag.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { generateGitTagName, getGitTagMessage } from '#git'\nimport type { EnsureGitTagOptions } from '#git'\nimport type { Package, Tag } from '#types'\nimport { verifyPackageTag } from './verifyPackageTag'\n\n/**\n * Resolve the release tag for a single package version.\n *\n * Returns the cached `pkg.tag` immediately if it already exists. Generates an\n * expected tag name from the package metadata and verifies its integrity using\n * `verifyPackageTag`.\n *\n * @param cwd Repository working directory\n * @param pkg Package descriptor containing version and location context\n * @param options Dry-run and logging guards for the local tag cleanup\n * @returns A promise resolving to the tag metadata or null when not found\n */\nexport async function resolvePackageTag(\n cwd: string,\n pkg: Package,\n options?: EnsureGitTagOptions\n): Promise<Tag | null> {\n if (pkg.tag) {\n return pkg.tag\n }\n\n let expectedTagName: string | null | undefined\n\n try {\n expectedTagName = generateGitTagName(pkg.entry, pkg.name, pkg.version)\n } catch {}\n\n if (!expectedTagName) {\n return null\n }\n\n if (await verifyPackageTag(cwd, pkg, expectedTagName, options)) {\n return {\n name: expectedTagName,\n message: await getGitTagMessage(cwd, expectedTagName),\n }\n }\n\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,eAAsB,kBACpB,KACA,KACA,SACqB;CACrB,IAAI,IAAI,KACN,OAAO,IAAI;CAGb,IAAI;CAEJ,IAAI;EACF,kBAAkB,mBAAmB,IAAI,OAAO,IAAI,MAAM,IAAI,OAAO;CACvE,QAAQ,CAAC;CAET,IAAI,CAAC,iBACH,OAAO;CAGT,IAAI,MAAM,iBAAiB,KAAK,KAAK,iBAAiB,OAAO,GAC3D,OAAO;EACL,MAAM;EACN,SAAS,MAAM,iBAAiB,KAAK,eAAe;CACtD;CAGF,OAAO;AACT"}
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -160,6 +160,11 @@ export interface ReleaseOutcome {
|
|
|
160
160
|
|
|
161
161
|
export interface ReleaseContext<P extends Package = Package> {
|
|
162
162
|
cwd: string
|
|
163
|
+
/**
|
|
164
|
+
* Environment of the release, stored by reference rather than copied:
|
|
165
|
+
* the CLI passes the live `process.env`, so later mutations of that
|
|
166
|
+
* object are visible through the context.
|
|
167
|
+
*/
|
|
163
168
|
env: Readonly<NodeJS.ProcessEnv>
|
|
164
169
|
today: string
|
|
165
170
|
signal: AbortSignal | undefined
|
package/src/util/execCommand.ts
CHANGED
|
@@ -35,6 +35,15 @@ export interface ExecCommandOptions {
|
|
|
35
35
|
* Spawns the target process, collects output streams, and intercepts mutating
|
|
36
36
|
* `git` operations in test mode to inject deterministic commit timestamps.
|
|
37
37
|
*
|
|
38
|
+
* The child environment is assembled in two tiers: a fixed set of ambient
|
|
39
|
+
* variables — `HOME`, `PATH`, `SSH_AUTH_SOCK`, `GIT_SSH`, `GIT_SSH_COMMAND`,
|
|
40
|
+
* and the proxy variables — is always copied from `process.env`, and
|
|
41
|
+
* `options.env` is spread on top of it. Nothing is filtered beyond that:
|
|
42
|
+
* callers pass `{ ...context.env, ... }` — and the CLI's `context.env` is
|
|
43
|
+
* the live `process.env` — so the child receives the full environment the
|
|
44
|
+
* caller provides. Pass an explicit minimal `env` to restrict what the
|
|
45
|
+
* child sees.
|
|
46
|
+
*
|
|
38
47
|
* @param command Executable command name or path to spawn
|
|
39
48
|
* @param args Array of string arguments passed to the command
|
|
40
49
|
* @param options Execution environment, streaming, and signal options
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-la-hLPRR.js","names":[],"sources":["../src/config/const.ts","../src/util/buildTrailerPattern.ts","../src/util/execCommand.ts","../src/util/execGit.ts","../src/util/formatError.ts","../src/util/isMatch.ts","../src/workflow/analysis/packageContainsCommit.ts","../src/git/commit/extractMentions.ts","../src/cache/TTLCache.ts","../src/git/commit/parseGitCommit.ts","../src/git/commit/parseGitPrettyFormat.ts","../src/git/commit/getParsedGitCommit.ts","../src/git/history/countGitHistory.ts","../src/git/repository/isGitShallowRepository.ts","../src/git/repository/withShallowLock.ts","../src/git/revision/isGitAncestor.ts","../src/git/revision/resolveGitRevision.ts","../src/git/history/expandGitHistory.ts","../src/git/tag/deleteGitTag.ts","../src/git/tag/isGitTagPresent.ts","../src/git/tag/ensureGitTag.ts","../src/git/tag/generateGitTagName.ts","../src/git/tag/getGitTagMessage.ts","../src/git/tag/isGitTagConnected.ts","../src/workflow/discovery/verifyPackageTag.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseHookName } from '#types'\nimport { Writable } from 'node:stream'\n\nexport const ALL_FILES = '**/*'\n\nexport const DEFAULT_CHANGELOG_FILE = 'CHANGELOG.md'\n\nexport const GIT_TRAILER_RELEASE_AGENT = 'Release-Agent'\n\n/**\n * 1. Primitive Building Blocks\n *\n * Base regular expression patterns for wildcards, alphanumeric strings with hyphens,\n * and standard non-negative integers.\n */\nconst WILDCARD = '\\\\*'\nconst ALPHANUM_DASH = '[0-9a-zA-Z-]+'\nconst NUMERIC_IDENTIFIER = '0|[1-9]\\\\d*'\n\n/**\n * 2. Package Name & Prefix Constructs\n *\n * Matches package name prefixes (unscoped or scoped) or a simple `v` prefix.\n *\n * Capture Groups:\n * - Group 1: Package name (e.g., `my-package` or `@scope/my-package`)\n */\nconst PKG_NAME_PART = `(?:${WILDCARD}|${ALPHANUM_DASH})`\nconst CAPTURED_PACKAGE_NAME = `(${PKG_NAME_PART}|@${PKG_NAME_PART}\\\\/${PKG_NAME_PART})`\nconst OPTIONAL_VERSION_PREFIX = `(?:v|${CAPTURED_PACKAGE_NAME}@)`\n\n/**\n * 3. Core SemVer Components\n *\n * Matches standard `MAJOR.MINOR.PATCH` versions or wildcard variants (e.g., `1.0.0`, `*.*.*`).\n *\n * Capture Groups:\n * - Group 3: Major version\n * - Group 4: Minor version\n * - Group 5: Patch version\n */\nconst CAPTURED_VERSION_DIGIT = `(${WILDCARD}|${NUMERIC_IDENTIFIER})`\nconst SEMVER_CORE = `${CAPTURED_VERSION_DIGIT}\\\\.${CAPTURED_VERSION_DIGIT}\\\\.${CAPTURED_VERSION_DIGIT}`\n\n/**\n * 4. Prerelease & Build Metadata\n *\n * Matches optional prerelease identifiers (e.g., `-alpha.1`) and build metadata (e.g., `+build123`).\n *\n * Capture Groups:\n * - Group 6: Complete prerelease string (without `-`)\n * - Group 7: Non-numeric prerelease token\n * - Group 8: Complete build metadata string (without `+`)\n */\nconst CAPTURED_NON_NUMERIC_PRERELEASE_ID = `(\\\\d*[a-zA-Z-][0-9a-zA-Z-]*)`\nconst PRERELEASE_IDENTIFIER = `(?:${WILDCARD}|${NUMERIC_IDENTIFIER}|${CAPTURED_NON_NUMERIC_PRERELEASE_ID})`\nconst OPTIONAL_PRERELEASE_SECTION = `(?:-(${PRERELEASE_IDENTIFIER}(?:\\\\.${PRERELEASE_IDENTIFIER})*))`\nconst OPTIONAL_BUILD_SECTION = `(?:\\\\+(${ALPHANUM_DASH}(?:\\\\.${ALPHANUM_DASH})*))`\n\n/**\n * 5. Assembled SemVer Pattern\n *\n * Combines core SemVer components with optional prerelease identifiers and build metadata.\n *\n * Capture Groups:\n * - Group 2: Full SemVer version string (excluding package/prefix)\n */\nconst CAPTURED_SEMVER_VERSION = `(${SEMVER_CORE}${OPTIONAL_PRERELEASE_SECTION}?${OPTIONAL_BUILD_SECTION}?)`\nconst FULL_SEMVER_PATTERN = `${OPTIONAL_VERSION_PREFIX}?${CAPTURED_SEMVER_VERSION}`\n\n/**\n * Regular expression to match and capture Semantic Versioning (SemVer) strings,\n * including optional package prefixes (e.g., `@scope/pkg@`) and `v` prefixes.\n *\n * @example\n * ```ts\n * SEMVER_REGEX.test('1.0.0') // true\n * SEMVER_REGEX.test('v1.2.3-beta.1+sha.1234') // true\n * SEMVER_REGEX.test('@scope/package@1.0.0') // true\n * ```\n *\n * @see {@link https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string SemVer Specification}\n */\nexport const SEMVER_REGEX = new RegExp(FULL_SEMVER_PATTERN)\n\nexport const DEV_NULL = new Writable({\n /* istanbul ignore next */\n write(_chunk, _encoding, callback) {\n callback()\n },\n})\n\nexport const RELEASE_HOOK_NAMES = [\n 'configure',\n 'discover',\n 'analyze',\n 'build',\n 'write',\n 'publish',\n 'finalize',\n] as const satisfies ReleaseHookName[]\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Build a regular expression to match trailer lines using custom markers.\n *\n * Combines the provided marker strings with a standard alphanumeric pattern\n * to construct a regular expression that matches trailer definitions.\n *\n * @param markers Optional array of custom trailer marker strings\n * @returns A regular expression matching trailer lines\n */\nexport function buildTrailerPattern(markers: readonly string[] = []) {\n return new RegExp(\n `^(${markers\n .map(RegExp.escape)\n .concat('[A-Za-z0-9_-]+')\n .join('|')})[ \\\\t]*:[ \\\\t]*(.*)$`\n )\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { spawn, type ChildProcessByStdio } from 'node:child_process'\nimport type { Stream } from 'node:stream'\n\nexport interface PromiseWithChild<T> extends Promise<T> {\n child: ChildProcessByStdio<null, Stream.Readable, Stream.Readable>\n}\n\nconst MUTATING_GIT_COMMANDS = new Set([\n 'commit',\n 'tag',\n 'cherry-pick',\n 'rebase',\n 'merge',\n 'revert',\n 'commit-tree',\n 'mktag',\n])\n\nlet deterministicCounter = 0\n\nexport interface ExecCommandOptions {\n cwd: string\n env?: Readonly<NodeJS.ProcessEnv> | undefined\n signal?: AbortSignal | undefined\n stdout?: NodeJS.WritableStream | undefined\n stderr?: NodeJS.WritableStream | undefined\n}\n\n/**\n * Execute a system command with arguments as a child process.\n *\n * Spawns the target process, collects output streams, and intercepts mutating\n * `git` operations in test mode to inject deterministic commit timestamps.\n *\n * @param command Executable command name or path to spawn\n * @param args Array of string arguments passed to the command\n * @param options Execution environment, streaming, and signal options\n * @returns Promise attached to the child process resolving to standard output\n * @throws If process execution fails or exits with a non-zero status\n */\nexport function execCommand(\n command: string,\n args: readonly string[],\n options: ExecCommandOptions\n): PromiseWithChild<string> {\n const { cwd, signal } = options\n\n const env: NodeJS.ProcessEnv = {\n HOME: process.env.HOME,\n PATH: process.env.PATH,\n SSH_AUTH_SOCK: process.env.SSH_AUTH_SOCK,\n GIT_SSH: process.env.GIT_SSH,\n GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND,\n http_proxy: process.env.http_proxy,\n https_proxy: process.env.https_proxy,\n no_proxy: process.env.no_proxy,\n HTTP_PROXY: process.env.HTTP_PROXY,\n HTTPS_PROXY: process.env.HTTPS_PROXY,\n NO_PROXY: process.env.NO_PROXY,\n ...options.env,\n }\n\n if (import.meta.env.MODE === 'test' && command === 'git') {\n const primaryArg = args.find((arg) => MUTATING_GIT_COMMANDS.has(arg))\n\n if (primaryArg) {\n const base = Date.parse('2026-01-01T00:00:00Z')\n const date = new Date(base + deterministicCounter * 1000).toISOString()\n deterministicCounter += 1\n env.GIT_AUTHOR_DATE = date\n env.GIT_COMMITTER_DATE = date\n }\n }\n\n const child = spawn(command, args, {\n cwd,\n env,\n signal,\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n\n const promise = new Promise<string>((resolve, reject) => {\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n let settled = false\n\n function safeResolve(value: string) {\n /* istanbul ignore next */\n if (settled) return\n settled = true\n cleanup()\n resolve(value)\n }\n\n function safeReject(err: Error) {\n /* istanbul ignore next */\n if (settled) return\n settled = true\n cleanup()\n reject(err)\n }\n\n function cleanup() {\n child.off('error', onError)\n child.off('close', onClose)\n\n child.stdout.removeAllListeners('data')\n child.stderr.removeAllListeners('data')\n\n if (options.stdout) {\n child.stdout.unpipe(options.stdout)\n options.stdout.off('error', onError)\n }\n\n if (options.stderr) {\n child.stderr.unpipe(options.stderr)\n options.stderr.off('error', onError)\n }\n }\n\n function onError(err: Error) {\n safeReject(err)\n }\n\n function onClose(code: number | null, signal: NodeJS.Signals | null) {\n /* istanbul ignore next */\n if (settled) return\n\n if (code === 0) {\n return safeResolve(bufferArrayToString(stdout))\n }\n\n const quotedCommand = quoteCommandForMessage([command, ...args].join(' '))\n\n /* istanbul ignore next */\n const exitStatus =\n code !== null\n ? `exit code ${code}`\n : signal\n ? `signal ${signal}`\n : 'unknown status'\n\n const errorDiagnostics =\n bufferArrayToString(stderr).trim() || bufferArrayToString(stdout).trim()\n\n const errorMessage = [\n `Command ${quotedCommand} failed (${exitStatus})`,\n errorDiagnostics,\n ]\n .filter(Boolean)\n .join('\\n')\n\n const err = new Error(errorMessage, {\n cause: { code, signal, diagnostics: errorDiagnostics },\n })\n\n /* istanbul ignore else */\n if (code != null) {\n Object.defineProperty(err, 'code', { value: code })\n }\n\n safeReject(err)\n }\n\n child.on('error', onError)\n child.on('close', onClose)\n\n if (options.stdout) {\n options.stdout.on('error', onError)\n child.stdout.pipe(options.stdout)\n } else {\n child.stdout.on('data', (chunk) => stdout.push(chunk))\n }\n\n if (options.stderr) {\n options.stderr.on('error', onError)\n child.stderr.pipe(options.stderr)\n } else {\n child.stderr.on('data', (chunk) => stderr.push(chunk))\n }\n }) as PromiseWithChild<string>\n\n promise.child = child\n\n return promise\n}\n\nfunction bufferArrayToString(chunks: Buffer[]): string {\n return Buffer.concat(chunks).toString('utf-8')\n}\n\nfunction quoteCommandForMessage(command: string): string {\n if (!command.includes(\"'\")) {\n return `'${command}'`\n }\n\n if (!command.includes('\"')) {\n return `\"${command}\"`\n }\n\n return JSON.stringify(command)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {\n execCommand,\n type ExecCommandOptions,\n type PromiseWithChild,\n} from './execCommand'\n\n/**\n * Execute a Git command inside a target directory.\n *\n * Wraps `execCommand` to invoke the `git` executable using the provided\n * arguments and execution options.\n *\n * @param cwd Working directory path where the Git command runs\n * @param args Command-line arguments passed to Git\n * @param options Additional execution, environment, and stream options\n * @returns Promise attached to the child process resolving to stdout\n */\nexport function execGit(\n cwd: string,\n args: readonly string[],\n options?: Partial<ExecCommandOptions>\n): PromiseWithChild<string> {\n return execCommand('git', args, { ...options, cwd })\n}\n","// 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","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { minimatch } from 'minimatch'\n\n/**\n * Determine whether a target string matches glob patterns.\n *\n * Matches positive and negative glob patterns using dotfile support.\n * Negation-only patterns are expanded with a catch-all pattern so they match\n * every named target the patterns do not exclude.\n *\n * @param target Target string to evaluate against glob patterns\n * @param patterns Single glob pattern or list of patterns to evaluate\n * @returns True if target matches positive patterns and satisfies negative patterns\n */\nexport function isMatch(\n target: string,\n patterns: string | readonly string[]\n): boolean {\n if (typeof patterns === 'string') {\n patterns = [patterns]\n }\n\n if (\n patterns.length > 0 &&\n patterns.every((pattern) => pattern.startsWith('!'))\n ) {\n patterns = ['**/*', ...patterns]\n }\n\n const positives: string[] = []\n const negatives: string[] = []\n\n for (const pattern of patterns) {\n if (pattern.startsWith('!')) {\n negatives.push(pattern)\n } else {\n positives.push(pattern)\n }\n }\n\n return (\n positives.some((pattern) => minimatch(target, pattern, { dot: true })) &&\n negatives.every((pattern) => minimatch(target, pattern, { dot: true }))\n )\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { ALL_FILES } from '#config'\nimport type { GitCommit, Package } from '#types'\nimport { isMatch } from '#util'\nimport path from 'node:path'\n\n/**\n * Test whether a commit modifies files in a package.\n *\n * @param pkg Package with an explicit file pattern or base directory\n * @param commit Parsed commit containing changed file paths\n * @returns `true` if any changed file matches the package pattern\n */\nexport function packageContainsCommit(\n pkg: Package,\n commit: GitCommit\n): boolean {\n return commit.files.some((file) => {\n const { location } = pkg\n const files = pkg.files || path.join(location, ALL_FILES)\n\n return isMatch(file, files)\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nconst ALPHANUMERIC = '[a-zA-Z0-9]'\nconst SEPARATOR = '[-_]'\nconst USERNAME = `${ALPHANUMERIC}+(?:${SEPARATOR}+${ALPHANUMERIC}+)*`\nconst EMAIL_LOCAL = '[a-zA-Z0-9._%+-]'\nconst DOMAIN_SUFFIX = '[a-zA-Z0-9.-]*\\\\.[a-zA-Z]{2,}'\nconst SCOPED_PACKAGE_SPEC_SUFFIX = `/${USERNAME}@[0-9]+\\\\.[0-9]+\\\\.[0-9]+`\n\n/**\n * Extract unique mention handles from the input text string.\n *\n * Evaluates `text` against boundary rules to isolate valid handles while\n * excluding email addresses, domain names, and scoped package specs, then\n * de-duplicates the resulting handles.\n *\n * @param text The input string to parse for mentions\n * @returns An array of unique mention handles\n */\nexport function extractMentions(text: string): string[] {\n if (!text) return []\n\n const regex = new RegExp(\n `(?<!${EMAIL_LOCAL})@(${USERNAME})\\\\b(?!${SEPARATOR}|${DOMAIN_SUFFIX}|${SCOPED_PACKAGE_SPEC_SUFFIX})`,\n 'g'\n )\n\n const matches = text.matchAll(regex)\n\n const mentions = new Set(matches.map((match) => match[1] as string))\n\n return Array.from(mentions)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\ninterface Entry<V> {\n value: V\n timer: NodeJS.Timeout\n ttl: number\n}\n\n/**\n * A simple time-to-live cache that automatically evicts entries after a TTL.\n *\n * - Entries are removed automatically when their TTL expires.\n * - Reading an entry resets its TTL to the original value.\n * - Setting an existing key clears its previous timer and resets the TTL.\n *\n * @template K Type of cache keys\n * @template V Type of cache values\n */\nexport class TTLCache<K, V> {\n private cache = new Map<K, Entry<V>>()\n\n /**\n * Store a value under `key` for `ttl` milliseconds.\n *\n * If the key already exists its previous timer is cleared and the TTL is reset.\n *\n * @param key Cache key\n * @param value Value to store\n * @param ttl Time to live in milliseconds (default: 60_000)\n */\n set(key: K, value: V, ttl: number = 60_000): void {\n const ref = this.cache.get(key)\n\n if (ref) {\n clearTimeout(ref.timer)\n }\n\n const timer = setTimeout(() => {\n this.cache.delete(key)\n }, ttl).unref()\n\n this.cache.set(key, { value, timer, ttl })\n }\n\n /**\n * Retrieve the value for `key`, or `undefined` if not present.\n *\n * Reading an entry resets its TTL to the original `ttl` provided when it was set.\n *\n * @param key Cache key\n * @returns The stored value or `undefined` if not present\n */\n get(key: K): V | undefined {\n const ref = this.cache.get(key)\n\n if (!ref) return undefined\n\n this.set(key, ref.value, ref.ttl)\n\n return ref.value\n }\n\n /**\n * Check whether `key` exists in the cache.\n *\n * @param key Cache key\n * @returns `true` if present; otherwise `false`\n */\n has(key: K): boolean {\n return this.cache.has(key)\n }\n\n /**\n * Remove `key` from the cache and clear its eviction timer.\n *\n * @param key Cache key\n * @returns `true` if the key was present and removed; otherwise `false`\n */\n delete(key: K): boolean {\n const ref = this.cache.get(key)\n\n if (!ref) return false\n\n clearTimeout(ref.timer)\n\n return this.cache.delete(key)\n }\n\n /**\n * Clear all entries and their timers.\n */\n clear(): void {\n for (const { timer } of this.cache.values()) {\n clearTimeout(timer)\n }\n\n this.cache.clear()\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n GitCommit,\n GitCommitNote,\n GitCommitTrailer,\n GitCommitType,\n} from '#types'\nimport type {\n Commit as ParsedCommit,\n CommitBase,\n} from 'conventional-commits-parser'\nimport { CommitParser } from 'conventional-commits-parser'\nimport { buildTrailerPattern } from '../../util/buildTrailerPattern'\nimport { extractMentions } from './extractMentions'\n\nexport interface GitLogEntry {\n hash: string\n parent: string[]\n authorDate: string\n committerDate: string\n subject: string\n body: string\n files: string[]\n}\n\ninterface Commit extends CommitBase {\n type: GitCommitType | null\n scope: string | null\n subject: string\n header: string\n body: string | null\n footer: string | null\n}\n\nconst BREAKING_HEADER_REGEX = /^([\\w-]+)(?:\\(([^)]+)\\))?!: (.*)$/\n\nconst BREAKING_MARKERS: readonly string[] = [\n 'BREAKING CHANGE',\n 'BREAKING-CHANGE',\n]\n\n/**\n * Converge the parser's dynamically-shaped result into the typed commit\n * shape used for release analysis.\n *\n * The parser assigns `type`, `scope`, and `subject` at runtime through its\n * default header correspondence, so they exist on the result without being\n * part of its declared return type; `header` is always a string once\n * parsing succeeds because the parser rejects empty input.\n *\n * @param parsed The parser result to converge\n * @returns The typed commit shape\n */\nfunction toCommit(parsed: ParsedCommit): Commit {\n return {\n ...parsed,\n type: parsed.type ?? null,\n scope: parsed.scope ?? null,\n subject: parsed.subject ?? '',\n header: parsed.header ?? '',\n }\n}\n\n/**\n * Parse a git log entry into a structured commit object.\n *\n * Combines the commit subject and body, extracts conventional commit metadata\n * using custom trailer markers and breaking header patterns, and normalizes\n * dates to ISO format strings.\n *\n * @param entry The raw git log entry to parse\n * @param markers Optional array of custom trailer marker strings\n * @returns A structured commit object containing parsed details, notes, and mentions\n */\nexport async function parseGitCommit(\n entry: GitLogEntry,\n markers: readonly string[] = []\n): Promise<GitCommit> {\n const message = [entry.subject, entry.body].filter(Boolean).join('\\n\\n')\n\n const parser = new CommitParser({\n breakingHeaderPattern: BREAKING_HEADER_REGEX,\n noteKeywords: [],\n notesPattern: () => buildTrailerPattern(BREAKING_MARKERS.concat(markers)),\n })\n\n const commit = toCommit(parser.parse(message))\n\n const notes: GitCommitNote[] = []\n\n const trailers: GitCommitTrailer[] = []\n\n for (const note of commit.notes) {\n if (BREAKING_MARKERS.includes(note.title.toUpperCase())) {\n notes.push(note)\n }\n\n trailers.push({\n key: note.title,\n value: note.text,\n })\n }\n\n if (notes.length === 0 && BREAKING_HEADER_REGEX.test(commit.header)) {\n const note: GitCommitNote = {\n title: 'BREAKING CHANGE',\n text: commit.subject,\n }\n\n notes.push(note)\n\n trailers.push({\n key: note.title,\n value: note.text,\n })\n }\n\n const mentions = extractMentions(message)\n\n return {\n ...commit,\n hash: entry.hash,\n parent: entry.parent,\n authorDate: new Date(entry.authorDate).toISOString(),\n committerDate: new Date(entry.committerDate).toISOString(),\n type: commit.type?.toLowerCase() || null,\n scope: commit.scope || null,\n subject: commit.subject || null,\n header: commit.header,\n body: commit.body,\n footer: commit.footer,\n notes,\n mentions,\n trailers,\n files: entry.files,\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { colors } from 'consola/utils'\nimport type { GitLogEntry } from './parseGitCommit'\n\n/**\n * Field separator used in the git pretty format to produce a single-line\n *, machine-parseable record.\n */\nexport const GIT_PRETTY_FIELD_SEPARATOR = '\\x1f'\n\n/**\n * Pretty format string passed to `git log --pretty=format:`. Produces seven\n * fields separated by `GIT_PRETTY_FIELD_SEPARATOR`:\n * hash, parents, author date, committer date, subject, body, files.\n */\nexport const GIT_PRETTY_FORMAT = [\n '%H',\n '%P',\n '%aI',\n '%cI',\n '%s',\n '%b',\n '',\n].join(GIT_PRETTY_FIELD_SEPARATOR)\n\n/**\n * Parse a single line produced by `git log --pretty=format:${GIT_PRETTY_FORMAT}`.\n *\n * The input is expected to contain seven fields separated by\n * `GIT_PRETTY_FIELD_SEPARATOR`:\n * 1. `hash` (commit hash)\n * 2. `parent` (space-separated parent hashes)\n * 3. `authorDate` (ISO 8601)\n * 4. `committerDate` (ISO 8601)\n * 5. `subject`\n * 6. `body`\n * 7. `files` (newline-separated list)\n *\n * The function trims fields, converts parent hashes into an array, normalizes\n * dates to ISO strings, and splits `files` into an array. Missing optional\n * fields are normalized to sensible defaults.\n *\n * @param raw Raw pretty-format string produced by git\n * @returns Parsed `GitLogEntry` with `hash`, `parent`, `authorDate`, `committerDate`, `subject`, `body`, and `files`\n * @throws If required fields (hash, authorDate, committerDate, subject) are missing or malformed\n */\nexport function parseGitPrettyFormat(raw: string): GitLogEntry {\n let [hash, parentHashes, authorDate, committerDate, subject, body, files] =\n raw.split(GIT_PRETTY_FIELD_SEPARATOR)\n\n hash = hash?.trim()\n parentHashes = parentHashes?.trim()\n authorDate = authorDate?.trim()\n committerDate = committerDate?.trim()\n subject = subject?.trim()\n body = body?.trim()\n files = files?.trim()\n\n if (!hash || !authorDate || !committerDate || typeof subject !== 'string') {\n throw new Error(\n `The input \"${colors.bold(raw.slice(0, 200))}\" is not in the expected pretty format.`,\n {\n cause: new Error(`Pretty-format payload length: ${raw.length}`),\n }\n )\n }\n\n return {\n hash,\n parent: parentHashes ? parentHashes.split(/\\s+/) : [],\n authorDate: new Date(authorDate).toISOString(),\n committerDate: new Date(committerDate).toISOString(),\n subject,\n body: body ?? '',\n files: files ? files.split('\\n') : [],\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { TTLCache } from '#cache'\nimport type { GitCommit } from '#types'\nimport { execGit } from '#util'\nimport { parseGitCommit } from './parseGitCommit'\nimport { GIT_PRETTY_FORMAT, parseGitPrettyFormat } from './parseGitPrettyFormat'\n\nconst cache = new TTLCache<string, GitCommit>()\n\n/**\n * Retrieve and parse a git commit by its reference.\n *\n * Fetches the raw git log entry for the specified `ref`, checking the local cache\n * prior to parsing missing entries.\n *\n * @param cwd Current working directory path\n * @param ref Git reference to fetch\n * @param markers Optional array of custom trailer marker strings\n * @returns Structured commit object\n */\nexport async function getParsedGitCommit(\n cwd: string,\n ref: string,\n markers: readonly string[] = []\n): Promise<GitCommit> {\n const stdout = await execGit(cwd, [\n 'log',\n '-1',\n ref,\n '--name-only',\n `--pretty=format:${GIT_PRETTY_FORMAT}`,\n ])\n\n const entry = parseGitPrettyFormat(stdout)\n\n // The working directory is intentionally absent from the key: commit\n // hashes are content-addressed, so the same hash resolves to the same\n // commit in every repository that shares the object.\n const key = JSON.stringify([entry.hash, entry.parent, markers])\n\n const cached = cache.get(key)\n\n if (cached) return cached\n\n const parsed = await parseGitCommit(entry, markers)\n\n cache.set(key, parsed)\n\n return parsed\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Count mainline commits reachable from a given reference.\n *\n * Uses `git rev-list --count --first-parent` to calculate the length of the\n * primary history trunk, excluding commits introduced by side-branch merges.\n *\n * @param cwd Repository working directory\n * @param ref Commit reference to count from (defaults to `HEAD`)\n * @returns Number of commits along the primary branch line up to `ref`\n */\nexport async function countGitHistory(\n cwd: string,\n ref: string = 'HEAD'\n): Promise<number> {\n const stdout = await execGit(cwd, [\n 'rev-list',\n '--count',\n '--first-parent',\n ref,\n ])\n\n return Number.parseInt(stdout.trim(), 10)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Determine whether the repository at `cwd` is a shallow clone.\n *\n * Runs `git rev-parse --is-shallow-repository` to detect shallow clones.\n * Useful before operations that require full history.\n *\n * @param cwd Repository working directory\n * @returns `true` if shallow, `false` if full clone\n * @throws If the underlying Git command fails\n */\nexport async function isGitShallowRepository(cwd: string): Promise<boolean> {\n const stdout = (\n await execGit(cwd, ['rev-parse', '--is-shallow-repository'])\n ).trim()\n\n return stdout === 'true'\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { AsyncLocalStorage } from 'node:async_hooks'\nimport { isGitShallowRepository } from './isGitShallowRepository'\n\nconst lockQueue = new Map<string, Promise<void>>()\n\nconst context = new AsyncLocalStorage<Set<string>>()\n\n/**\n * Serialize access to a shallow Git repository while running a callback.\n *\n * If `cwd` is a shallow clone, callers from different async contexts are\n * executed one at a time; nested calls within the same async context run\n * immediately without waiting. If the repository becomes non-shallow before\n * a queued turn runs, downstream waiters are released early.\n *\n * @param cwd Repository working directory path string\n * @param callback Function to execute while the lock is held\n * @returns Promise resolving to the result of `callback`\n */\nexport async function withShallowLock<T>(\n cwd: string,\n callback: () => T | Promise<T>\n): Promise<T> {\n if (!(await isGitShallowRepository(cwd))) {\n return callback()\n }\n\n const active = context.getStore()\n\n if (active?.has(cwd)) {\n return callback()\n }\n\n const { promise, resolve } = Promise.withResolvers<void>()\n const previous = lockQueue.get(cwd) ?? Promise.resolve()\n const queued = previous.then(() => promise)\n\n lockQueue.set(cwd, queued)\n\n // Wait until previous tasks complete.\n await previous\n\n // If an earlier task made the repo non-shallow, release downstream waiters now.\n if (!(await isGitShallowRepository(cwd))) {\n resolve()\n }\n\n try {\n return await context.run(new Set(active).add(cwd), callback)\n } finally {\n // Ensure downstream waiters are unblocked even if callback throws.\n resolve()\n\n // Remove the queue entry only if no newer task has replaced it.\n if (lockQueue.get(cwd) === queued) {\n lockQueue.delete(cwd)\n }\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Determine whether `ancestor` is an ancestor of `descendant`.\n *\n * Runs `git merge-base --is-ancestor <ancestor> <descendant>` in the repository at `cwd`.\n * Resolves to `true` if `ancestor` is an ancestor, `false` if not.\n * Rethrows errors for invalid refs or other failures.\n *\n * @param cwd Repository working directory\n * @param ancestor Candidate ancestor ref\n * @param descendant Candidate descendant ref\n * @returns Resolves to `true` if `ancestor` is an ancestor of `descendant`, `false` otherwise\n * @throws If a ref is invalid or the Git command fails\n */\nexport function isGitAncestor(\n cwd: string,\n ancestor: string,\n descendant: string\n): Promise<boolean> {\n return execGit(cwd, ['merge-base', '--is-ancestor', ancestor, descendant])\n .then(() => true)\n .catch((err) => {\n if ((err as { code?: number })?.code === 1) {\n return false\n }\n\n throw err\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Resolve a Git revision or commit-ish expression to its full commit hash.\n *\n * Runs `git rev-parse --verify <revision>^{commit}` under the hood. Peels annotated\n * tags, branches, short SHAs, and relative expressions down to a verified commit object.\n *\n * @param cwd The repository working directory\n * @param revision The Git revision or expression to resolve\n * @returns A promise that resolves to the full, trimmed commit SHA-1 string\n */\nexport async function resolveGitRevision(\n cwd: string,\n revision: string\n): Promise<string> {\n return (\n await execGit(cwd, ['rev-parse', '--verify', `${revision}^{commit}`])\n ).trim()\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit, formatError } from '#util'\nimport type { ConsolaInstance } from 'consola/core'\nimport { isGitShallowRepository } from '../repository/isGitShallowRepository'\nimport { withShallowLock } from '../repository/withShallowLock'\nimport { isGitAncestor } from '../revision/isGitAncestor'\nimport { resolveGitRevision } from '../revision/resolveGitRevision'\nimport { countGitHistory } from './countGitHistory'\n\nexport interface ExpandGitHistoryOptions {\n /**\n * Number of commits to deepen the history by when paging\n * @default 50\n */\n pageSize?: number | undefined\n\n /**\n * Local reference used to measure current shallow depth (for example HEAD)\n * When provided the function accounts for existing depth before fetching more\n */\n from?: string | null | undefined\n\n /**\n * Target boundary reference where history deepening should stop\n * If provided the function will first attempt a single fetch to reach this commit\n */\n until?: string | null | undefined\n\n /**\n * Optional logger that receives failed fetch attempts at debug level\n */\n logger?: ConsolaInstance | undefined\n}\n\n/**\n * Deepen a shallow clone so additional commits become available.\n *\n * Attempts a single `--shallow-since` fetch to reach `until` (if provided),\n * otherwise deepens by `pageSize`, accounting for existing depth when `from`\n * is supplied. Operation is serialized to avoid concurrent deepens.\n *\n * @param cwd Repository working directory\n * @param options Options: { pageSize?, from?, until? }\n * @returns true if history was deepened or already sufficient, otherwise false\n */\nexport async function expandGitHistory(\n cwd: string,\n options: ExpandGitHistoryOptions = {}\n): Promise<boolean> {\n if (!(await isGitShallowRepository(cwd))) {\n return false\n }\n\n return withShallowLock(cwd, async () => {\n const { until } = options\n let { from } = options\n let { pageSize = 50 } = options\n\n // If an `until` boundary is provided, try a single fetch using the target commit's date\n if (until) {\n if (await isGitAncestor(cwd, until, 'HEAD')) {\n return true\n }\n\n const commitDate = (\n await execGit(cwd, ['show', '-s', '--format=%cI', `${until}^{commit}`])\n ).trim()\n\n try {\n await execGit(cwd, [\n '-c',\n 'fetch.negotiationAlgorithm=skipping',\n 'fetch',\n `--shallow-since=${commitDate}`,\n '--update-shallow',\n '--filter=blob:none',\n ])\n\n return true\n } catch (error: unknown) {\n options.logger?.debug(\n `Shallow fetch to reach \"${until}\" failed and incremental deepening will be attempted: ${formatError(error)}`\n )\n }\n }\n\n // Incremental deepening: account for existing local depth when `from` is set\n if (from) {\n from = await resolveGitRevision(cwd, from)\n\n const depth = await countGitHistory(cwd, from)\n\n if (depth > pageSize) {\n return true\n }\n\n // Reduce requested deepen amount by existing depth (exclude the `from` commit)\n pageSize -= depth - 1\n }\n\n // Perform a deepen fetch; if `from` is not an ancestor of HEAD, fetch that ref\n try {\n await execGit(cwd, [\n '-c',\n 'fetch.negotiationAlgorithm=skipping',\n 'fetch',\n `--deepen=${pageSize}`,\n '--update-shallow',\n '--filter=blob:none',\n ...(from && !(await isGitAncestor(cwd, from, 'HEAD'))\n ? ['origin', from, 'HEAD']\n : []),\n ])\n\n return true\n } catch (error: unknown) {\n options.logger?.debug(\n `Shallow history at \"${cwd}\" could not be deepened by ${pageSize} commits: ${formatError(error)}`\n )\n\n return false\n }\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Delete a local git tag in the repository at `cwd`.\n *\n * @param cwd Repository working directory\n * @param tag Tag name to delete\n * @returns `true` when deletion succeeded, otherwise `false`\n */\nexport function deleteGitTag(cwd: string, tag: string): Promise<boolean> {\n return execGit(cwd, ['tag', '-d', tag])\n .then(() => true)\n .catch(() => false)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { resolveGitRevision } from '../revision/resolveGitRevision'\n\n/**\n * Determine whether a specific git tag exists locally in the repository.\n *\n * @param cwd Working directory for the git command\n * @param tag Name of the tag to evaluate\n * @returns True if the tag reference exists locally, false otherwise\n */\nexport function isGitTagPresent(cwd: string, tag: string): Promise<boolean> {\n return resolveGitRevision(cwd, `refs/tags/${tag}`)\n .then(() => true)\n .catch(() => false)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\nimport type { ConsolaInstance } from 'consola'\nimport { countGitHistory } from '../history/countGitHistory'\nimport { withShallowLock } from '../repository/withShallowLock'\nimport { deleteGitTag } from './deleteGitTag'\nimport { isGitTagPresent } from './isGitTagPresent'\n\nconst MIN_HISTORY_DEPTH = 2\nconst ORIGIN_NOT_REPO = `fatal: 'origin' does not appear to be a git repository`\nconst REMOTE_REF_NOT_FOUND = `fatal: couldn't find remote ref`\n\n/**\n * Options guarding the destructive local tag cleanup in `ensureGitTag`.\n */\nexport interface EnsureGitTagOptions {\n /**\n * Logger warned before a stale local tag is deleted.\n */\n logger?: ConsolaInstance | undefined\n\n /**\n * Skip deleting stale local tags, warning instead.\n */\n dryRun?: boolean | undefined\n}\n\n/**\n * Ensure a tag exists locally, fetching it shallowly from `origin` if needed.\n *\n * Acquires a shallow-fetch lock, verifies local presence and history depth,\n * attempts a shallow fetch of `refs/tags/<tag>` when required, and removes a\n * local tag if the remote reports the tag is missing — warning before the\n * deletion and skipping it entirely in dry-run mode.\n *\n * @param cwd Working directory\n * @param tag Tag name (for example `v1.2.0`)\n * @param options Dry-run and logging guards for the local tag deletion\n * @returns `true` if the tag is present or was fetched; otherwise `false`\n */\nexport function ensureGitTag(\n cwd: string,\n tag: string,\n options?: EnsureGitTagOptions\n): Promise<boolean> {\n return withShallowLock(cwd, async () => {\n const tagRef = `refs/tags/${tag}`\n\n if (\n (await isGitTagPresent(cwd, tag)) &&\n (await countGitHistory(cwd, tagRef)) >= MIN_HISTORY_DEPTH\n ) {\n return true\n }\n\n try {\n await execGit(cwd, [\n 'fetch',\n 'origin',\n `${tagRef}:${tagRef}`,\n `--depth=${MIN_HISTORY_DEPTH}`,\n '--update-shallow',\n '--force',\n ])\n\n return true\n } catch (err) {\n const errorMessage = (err as Error | undefined)?.message\n\n if (errorMessage?.includes(ORIGIN_NOT_REPO)) {\n return await isGitTagPresent(cwd, tag)\n }\n\n if (errorMessage?.includes(REMOTE_REF_NOT_FOUND)) {\n if (await isGitTagPresent(cwd, tag)) {\n if (options?.dryRun) {\n options.logger?.warn(\n `[DRY RUN] Local tag \"${tag}\" would be deleted because the remote no longer reports it.`\n )\n } else {\n options?.logger?.warn(\n `Local tag \"${tag}\" is being deleted because the remote no longer reports it.`\n )\n\n await deleteGitTag(cwd, tag)\n }\n }\n }\n }\n\n return false\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Generate a git tag name for a package.\n *\n * For entry packages the tag is `v<version>`. For non-entry packages the\n * tag is `<name>@<version>`. Returns `null` when `version` is not provided.\n *\n * @param entry Whether the package is the repository entry package\n * @param name Package name (required for non-entry packages)\n * @param version Package version\n * @returns Tag string, or `null` when `version` is absent\n * @throws If a non-entry package has no name\n */\nexport function generateGitTagName(\n entry: boolean,\n name: string | null | undefined,\n version: string\n): string\nexport function generateGitTagName(\n entry: boolean,\n name: string | null | undefined,\n version: string | null | undefined\n): string | null\nexport function generateGitTagName(\n entry: boolean,\n name: string | null | undefined,\n version: string | null | undefined\n): string | null {\n if (!version) {\n return null\n }\n\n if (entry) {\n return `v${version}`\n }\n\n if (!name) {\n throw new Error('Package name is required to build a tag name.')\n }\n\n return `${name}@${version}`\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Get the message of an annotated git tag in the repository at `cwd`.\n *\n * @param cwd Repository working directory\n * @param tag Tag name to query\n * @returns The tag message string when found, otherwise `undefined`\n */\nexport async function getGitTagMessage(\n cwd: string,\n tag: string\n): Promise<string | undefined> {\n try {\n const stdout = await execGit(cwd, [\n 'for-each-ref',\n '--format=%(objecttype)%00%(contents)',\n `refs/tags/${tag}`,\n ])\n\n const [objectType, message] = stdout.split('\\0')\n\n if (objectType?.trim() !== 'tag') {\n return undefined\n }\n\n return message?.trim() || undefined\n } catch {\n /* istanbul ignore next */\n return undefined\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { execGit } from '#util'\n\n/**\n * Determine whether a specific git tag commit is reachable from the current HEAD.\n *\n * Uses `git merge-base --is-ancestor refs/tags/<tag>^{commit} HEAD` to verify\n * that the tag's commit is an ancestor of the current reference. Any non-zero\n * exit status or execution error is treated as \"not reachable\".\n *\n * @param cwd Working directory where the git command will run\n * @param tag Tag name to evaluate (for example, \"v1.2.0\")\n * @returns True if the tag commit is reachable from HEAD, false otherwise\n */\nexport async function isGitTagConnected(\n cwd: string,\n tag: string\n): Promise<boolean> {\n try {\n await execGit(cwd, [\n 'merge-base',\n '--is-ancestor',\n `refs/tags/${tag}^{commit}`,\n 'HEAD',\n ])\n\n return true\n } catch {\n return false\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {\n ensureGitTag,\n expandGitHistory,\n getParsedGitCommit,\n isGitTagConnected,\n} from '#git'\nimport type { EnsureGitTagOptions } from '#git'\nimport type { GitCommit, Package } from '#types'\nimport { packageContainsCommit } from '../analysis/packageContainsCommit'\n\n/**\n * Verify a Git tag against package specifications and repository history.\n *\n * Ensures the target tag exists locally before parsing its commit data. Rejects\n * tags that do not target a commit matching the specified `pkg`. Expands the\n * history graph up to the tag reference before verifying structural connectivity.\n *\n * @param cwd Repository working directory path\n * @param pkg Package descriptor containing version and location context\n * @param tagName Name of the Git tag to verify\n * @param options Dry-run and logging guards for the local tag cleanup\n * @returns True if the tag is valid and connected; otherwise, false\n */\nexport async function verifyPackageTag(\n cwd: string,\n pkg: Package,\n tagName: string,\n options?: EnsureGitTagOptions\n): Promise<boolean> {\n await ensureGitTag(cwd, tagName, options)\n\n const tagRef = `refs/tags/${tagName}`\n\n let tagCommit: GitCommit\n\n try {\n tagCommit = await getParsedGitCommit(cwd, tagRef)\n } catch {\n return false\n }\n\n if (!packageContainsCommit(pkg, tagCommit)) {\n return false\n }\n\n await expandGitHistory(cwd, { until: tagRef, logger: options?.logger })\n\n return isGitTagConnected(cwd, tagName)\n}\n"],"mappings":";;;;;;;;AAMA,IAAa,YAAY;AAEzB,IAAa,yBAAyB;AAEtC,IAAa,4BAA4B;;;;;;;AAQzC,IAAM,WAAW;AACjB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;;;;;;;;;AAU3B,IAAM,gBAAgB,MAAM,SAAS,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