@reelout/core 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HookDispatcher-Di79rwtu.js +236 -0
- package/dist/HookDispatcher-Di79rwtu.js.map +1 -0
- package/dist/analyzer.js +12 -3
- package/dist/analyzer.js.map +1 -1
- package/dist/buildChangelog-Cxm9_lq2.js +187 -0
- package/dist/buildChangelog-Cxm9_lq2.js.map +1 -0
- package/dist/buildReleaseNotes-S6HcEQnE.js +141 -0
- package/dist/buildReleaseNotes-S6HcEQnE.js.map +1 -0
- package/dist/builder.js +14 -6
- package/dist/builder.js.map +1 -1
- package/dist/changelog.js +17 -6
- package/dist/changelog.js.map +1 -1
- package/dist/index.js +1201 -8
- package/dist/index.js.map +1 -1
- package/dist/package-Bczytil1.js +884 -0
- package/dist/package-Bczytil1.js.map +1 -0
- package/dist/propagateDependencyUpdates-QWn0H1qa.js +306 -0
- package/dist/propagateDependencyUpdates-QWn0H1qa.js.map +1 -0
- package/dist/readPackageHistory-CN5nqMcE.js +133 -0
- package/dist/readPackageHistory-CN5nqMcE.js.map +1 -0
- package/dist/resolvePackageTag-cwqG1GGt.js +30 -0
- package/dist/resolvePackageTag-cwqG1GGt.js.map +1 -0
- package/dist/types.js +0 -1
- package/package.json +15 -3
- package/src/analyzer.ts +7 -2
- package/src/builder.ts +12 -3
- package/src/changelog.ts +17 -6
- package/src/config/resolvePlugin.ts +1 -1
- package/src/git/commit/getParsedGitCommit.ts +4 -1
- package/src/git/commit/parseGitCommit.ts +27 -2
- package/src/git/commit/parseGitPrettyFormat.ts +4 -1
- package/src/git/history/expandGitHistory.ts +17 -3
- package/src/git/history/readParsedGitHistory.ts +8 -2
- package/src/git/repository/isGitShallowRepository.ts +2 -1
- package/src/git/tag/ensureGitTag.ts +35 -3
- package/src/plugin/createHostReleasePlugin.ts +255 -0
- package/src/plugin/index.ts +1 -0
- package/src/util/execCommand.ts +9 -0
- package/src/util/formatFile.ts +12 -3
- package/src/util/interpolate.ts +5 -3
- package/src/workflow/analysis/propagateDependencyUpdates.ts +1 -0
- package/src/workflow/changelog/buildChangelog.ts +27 -4
- package/src/workflow/changelog/buildReleaseNotes.ts +1 -1
- package/src/workflow/changelog/index.ts +0 -1
- package/src/workflow/changelog/prependChangelog.ts +5 -2
- package/src/workflow/changelog/writeChangelog.ts +5 -2
- package/src/workflow/commit/generateReleaseCommitMessage.ts +1 -1
- package/src/workflow/discovery/discoverPackageTag.ts +5 -2
- package/src/workflow/discovery/resolvePackageStableTag.ts +12 -7
- package/src/workflow/discovery/resolvePackageTag.ts +5 -2
- package/src/workflow/discovery/sortPackages.ts +5 -4
- package/src/workflow/discovery/verifyPackageTag.ts +6 -3
- package/src/workflow/report/printReleaseReport.ts +6 -1
- package/src/workflow/version/bumpVersion.ts +0 -1
- package/src/workflow/version/index.ts +0 -1
- package/dist/formatError-BMsun8Wi.js +0 -22
- package/dist/formatError-BMsun8Wi.js.map +0 -1
- package/dist/types-la_KkjCS.js +0 -1
- package/dist/workflow-Cqg6rLVB.js +0 -2936
- package/dist/workflow-Cqg6rLVB.js.map +0 -1
- package/src/workflow/changelog/extractPreviousVersion.ts +0 -77
- package/src/workflow/version/promotePrereleaseVersions.ts +0 -51
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-Bczytil1.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,I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AChC;GACA;GACA,aAAa;EACf,CAAC,EAAA,CAEoC,MAAM,IAAI;EAE/C,IAAI,YAAY,KAAK,MAAM,OACzB;EAGF,OAAO,SAAS,KAAK,KAAK,KAAA;CAC5B,QAAQ;;EAEN;CACF;AACF;;;;;;;;;;;;;AClBA,eAAsB,kBACpB,KACA,KACkB;CAClB,IAAI;EACF,MAAM,QAAQ,KAAK;GACjB;GACA;GACA,aAAa,IAAI;GACjB;EACF,CAAC;EAED,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;;;;ACNA,eAAsB,iBACpB,KACA,KACA,SACA,SACkB;CAClB,MAAM,aAAa,KAAK,SAAS,OAAO;CAExC,MAAM,SAAS,aAAa;CAE5B,IAAI;CAEJ,IAAI;EACF,YAAY,MAAM,mBAAmB,KAAK,MAAM;CAClD,QAAQ;EACN,OAAO;CACT;CAEA,IAAI,CAAC,sBAAsB,KAAK,SAAS,GACvC,OAAO;CAGT,MAAM,iBAAiB,KAAK;EAAE,OAAO;EAAQ,QAAQ,SAAS;CAAO,CAAC;CAEtE,OAAO,kBAAkB,KAAK,OAAO;AACvC"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { a as extractVersionQualifier } from "./readPackageHistory-CN5nqMcE.js";
|
|
2
|
+
import { S as packageContainsCommit, d as isGitAncestor } from "./package-Bczytil1.js";
|
|
3
|
+
import semver from "semver";
|
|
4
|
+
// src/workflow/version/deriveCommitReleaseType.ts
|
|
5
|
+
/**
|
|
6
|
+
* Derive the release type for a single commit.
|
|
7
|
+
*
|
|
8
|
+
* Returns `'minor'` for a commit marked as a breaking change while the
|
|
9
|
+
* supplied `version` is zero-major (`0.y.z`), and `'major'` otherwise, since
|
|
10
|
+
* SemVer treats `0.y.z` as initial development where breaking changes do not
|
|
11
|
+
* require a new major version. Otherwise, routes the commit through the
|
|
12
|
+
* custom `classifier` and ensures the resolved value is a valid semantic
|
|
13
|
+
* versioning release type.
|
|
14
|
+
*
|
|
15
|
+
* @param classifier Function mapping commits to release types
|
|
16
|
+
* @param commit Parsed commit to evaluate
|
|
17
|
+
* @param version Current package version used to adjust zero-major breaking releases
|
|
18
|
+
* @returns `ReleaseType` string, or `null` when no matching rule applies
|
|
19
|
+
*/
|
|
20
|
+
function deriveCommitReleaseType(classifier, commit, version) {
|
|
21
|
+
if (commit.notes.length > 0) return semver.parse(version)?.major === 0 ? "minor" : "major";
|
|
22
|
+
const type = classifier(commit);
|
|
23
|
+
switch (type) {
|
|
24
|
+
case "major":
|
|
25
|
+
case "minor":
|
|
26
|
+
case "patch": return type;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
// src/workflow/version/pickPriorityReleaseType.ts
|
|
31
|
+
/**
|
|
32
|
+
* Determine the highest-priority release type between two candidates.
|
|
33
|
+
*
|
|
34
|
+
* Compares release types by precedence order: `major` > `minor` > `patch`.
|
|
35
|
+
* Returns the higher-precedence type, or `null` if neither applies.
|
|
36
|
+
*
|
|
37
|
+
* @param curr Current accumulated release type
|
|
38
|
+
* @param next Candidate release type to consider
|
|
39
|
+
* @returns Highest-precedence `ReleaseType`, or `null` if neither applies
|
|
40
|
+
*/
|
|
41
|
+
function pickPriorityReleaseType(curr, next) {
|
|
42
|
+
for (const type of [
|
|
43
|
+
"major",
|
|
44
|
+
"minor",
|
|
45
|
+
"patch"
|
|
46
|
+
]) if (curr === type || next === type) return type;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
// src/workflow/version/deriveReleaseType.ts
|
|
50
|
+
/**
|
|
51
|
+
* Derive the combined release type from a release plan.
|
|
52
|
+
*
|
|
53
|
+
* Processes the plan's commits sequentially, accumulating the
|
|
54
|
+
* highest-precedence release type found by evaluating each individual commit
|
|
55
|
+
* and comparing it against the current maximum via `pickPriorityReleaseType`.
|
|
56
|
+
* Breaking commits resolve to `minor` while the plan's package version is
|
|
57
|
+
* zero-major (`0.y.z`).
|
|
58
|
+
*
|
|
59
|
+
* @param classifier Function mapping commits to release types
|
|
60
|
+
* @param plan Release plan carrying the commit history and package version
|
|
61
|
+
* @returns `ReleaseType` string, or `null` when no matching rule applies
|
|
62
|
+
*/
|
|
63
|
+
function deriveReleaseType(classifier, plan) {
|
|
64
|
+
let releaseType = null;
|
|
65
|
+
for (const commit of plan.history) releaseType = pickPriorityReleaseType(releaseType, deriveCommitReleaseType(classifier, commit, plan.package.version));
|
|
66
|
+
return releaseType;
|
|
67
|
+
}
|
|
68
|
+
// src/workflow/analysis/deriveChangeReleases.ts
|
|
69
|
+
/**
|
|
70
|
+
* Analyze commit history to update release plans for packages.
|
|
71
|
+
*
|
|
72
|
+
* Maps commit `history` across package release `plans` to associate matching
|
|
73
|
+
* commits with their target packages. Calculates the release type for each
|
|
74
|
+
* plan based on classified `history` and applies overrides according to the
|
|
75
|
+
* provided `hint` or existing release priority. Downgrades breaking-change
|
|
76
|
+
* `major` release types to `minor` while the package version is zero-major
|
|
77
|
+
* (`0.y.z`).
|
|
78
|
+
*
|
|
79
|
+
* @param hint Release type override hint or default preference
|
|
80
|
+
* @param classifier Classifier function to determine commit release types
|
|
81
|
+
* @param plans List of release plans to analyze and update
|
|
82
|
+
* @param history Stream or iterable of git commits to process
|
|
83
|
+
* @returns Updated release plans with updated commit histories and release types
|
|
84
|
+
*/
|
|
85
|
+
async function deriveChangeReleases(hint, classifier, plans, history) {
|
|
86
|
+
for await (const commit of history) plans = plans.map((plan) => {
|
|
87
|
+
if (!packageContainsCommit(plan.package, commit)) return plan;
|
|
88
|
+
return {
|
|
89
|
+
...plan,
|
|
90
|
+
history: plan.history.concat(commit)
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
return plans.map((plan) => {
|
|
94
|
+
let { release } = plan;
|
|
95
|
+
let releaseType = deriveReleaseType(classifier, plan);
|
|
96
|
+
if (releaseType) switch (hint) {
|
|
97
|
+
case "major":
|
|
98
|
+
case "minor":
|
|
99
|
+
case "patch":
|
|
100
|
+
releaseType = hint;
|
|
101
|
+
break;
|
|
102
|
+
default: releaseType = pickPriorityReleaseType(release?.type, releaseType);
|
|
103
|
+
}
|
|
104
|
+
if (releaseType) release = {
|
|
105
|
+
...release,
|
|
106
|
+
type: releaseType
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
...plan,
|
|
110
|
+
release
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// src/workflow/analysis/deriveTransitionReleases.ts
|
|
115
|
+
/**
|
|
116
|
+
* Derive transition release types for release plans based on version qualifiers.
|
|
117
|
+
*
|
|
118
|
+
* Evaluates unreleased `plans` by parsing package `semver` strings and checking
|
|
119
|
+
* prerelease tags. Compares parsed version qualifiers against
|
|
120
|
+
* `versionQualifier` and assigns `major`, `minor`, or `patch` release types
|
|
121
|
+
* according to `hint`. When `hint` is `patch`, every package receives an
|
|
122
|
+
* update: stable packages are assigned a patch release even without a
|
|
123
|
+
* `versionQualifier`, and prerelease packages (pre-major, pre-minor, and
|
|
124
|
+
* pre-patch cycles) continue their cycle with an incremented counter,
|
|
125
|
+
* redirect to `versionQualifier` when it differs, or release their stable
|
|
126
|
+
* base when no `versionQualifier` is set.
|
|
127
|
+
*
|
|
128
|
+
* @param hint Release type override hint to guide release classification
|
|
129
|
+
* @param versionQualifier Optional qualifier string to compare against prerelease tags
|
|
130
|
+
* @param plans List of release plans to analyze and update
|
|
131
|
+
* @returns Updated release plans with derived transition release types
|
|
132
|
+
*/
|
|
133
|
+
function deriveTransitionReleases(hint, versionQualifier, plans) {
|
|
134
|
+
return plans.map((plan) => {
|
|
135
|
+
if (plan.release) return plan;
|
|
136
|
+
const parsed = semver.parse(plan.package.version);
|
|
137
|
+
if (!parsed) return plan;
|
|
138
|
+
const { major, minor, patch } = parsed;
|
|
139
|
+
const parsedVersionQualifier = extractVersionQualifier(parsed);
|
|
140
|
+
let releaseType;
|
|
141
|
+
let versionTransition;
|
|
142
|
+
switch (hint) {
|
|
143
|
+
case "major":
|
|
144
|
+
if (parsed.prerelease.length === 0) {
|
|
145
|
+
if (typeof versionQualifier === "string") releaseType = "major";
|
|
146
|
+
else if (major === 0 && (minor > 0 || patch > 0)) releaseType = "major";
|
|
147
|
+
} else if (minor === 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "major";
|
|
148
|
+
break;
|
|
149
|
+
case "minor":
|
|
150
|
+
if (parsed.prerelease.length === 0) {
|
|
151
|
+
if (typeof versionQualifier === "string") releaseType = "minor";
|
|
152
|
+
} else if (minor > 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "minor";
|
|
153
|
+
break;
|
|
154
|
+
case "patch":
|
|
155
|
+
releaseType = "patch";
|
|
156
|
+
break;
|
|
157
|
+
default: if (parsed.prerelease.length === 0) {
|
|
158
|
+
if (major === 0 && (minor > 0 || patch > 0)) releaseType = "major";
|
|
159
|
+
} else if (minor === 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "major";
|
|
160
|
+
else if (minor > 0 && patch === 0 && parsedVersionQualifier !== versionQualifier) releaseType = "minor";
|
|
161
|
+
else if (patch > 0 && parsedVersionQualifier !== versionQualifier) releaseType = "patch";
|
|
162
|
+
}
|
|
163
|
+
if (parsedVersionQualifier == null || parsedVersionQualifier !== "" && versionQualifier === "") versionTransition = "advance";
|
|
164
|
+
else versionTransition = "continue";
|
|
165
|
+
if (!releaseType) return plan;
|
|
166
|
+
return {
|
|
167
|
+
...plan,
|
|
168
|
+
release: {
|
|
169
|
+
type: releaseType,
|
|
170
|
+
transition: versionTransition
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
// src/git/revision/detectGitRelationship.ts
|
|
176
|
+
var GIT_REL_FLAGS = {
|
|
177
|
+
NONE: 0,
|
|
178
|
+
IS_ANCESTOR: 1,
|
|
179
|
+
IS_DESCENDANT: 2,
|
|
180
|
+
IS_EQUAL: 3
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Determine the relationship between two git refs.
|
|
184
|
+
*
|
|
185
|
+
* Runs `git merge-base --is-ancestor` in both directions and returns a
|
|
186
|
+
* numeric bitmask using `GIT_REL_FLAGS`. A successful check (exit code 0)
|
|
187
|
+
* indicates an ancestor relationship; non-zero exit is treated as "not ancestor".
|
|
188
|
+
*
|
|
189
|
+
* @param cwd Repository working directory
|
|
190
|
+
* @param refA First ref (candidate ancestor)
|
|
191
|
+
* @param refB Second ref (candidate descendant)
|
|
192
|
+
* @returns Bitmask of type `GitRelFlags`
|
|
193
|
+
*/
|
|
194
|
+
async function detectGitRelationship(cwd, refA, refB) {
|
|
195
|
+
let flags = GIT_REL_FLAGS.NONE;
|
|
196
|
+
const [aIsAncestor, bIsAncestor] = await Promise.all([isGitAncestor(cwd, refA, refB), isGitAncestor(cwd, refB, refA)]);
|
|
197
|
+
if (aIsAncestor) flags |= GIT_REL_FLAGS.IS_ANCESTOR;
|
|
198
|
+
if (bIsAncestor) flags |= GIT_REL_FLAGS.IS_DESCENDANT;
|
|
199
|
+
return flags;
|
|
200
|
+
}
|
|
201
|
+
// src/git/history/mergeGitHistory.ts
|
|
202
|
+
/**
|
|
203
|
+
* Merge two newest-first commit lists into a single deduplicated newest-first list.
|
|
204
|
+
*
|
|
205
|
+
* Compares commits by hash, uses git relationship (ancestor/descendant) when needed,
|
|
206
|
+
* and falls back to committerDate for unrelated commits.
|
|
207
|
+
*
|
|
208
|
+
* @param cwd Repository working directory used for relationship checks
|
|
209
|
+
* @param a Commits from the first source (newest-first)
|
|
210
|
+
* @param b Commits from the second source (newest-first)
|
|
211
|
+
* @returns Merged commits in newest-first order with duplicates removed
|
|
212
|
+
*/
|
|
213
|
+
async function mergeGitHistory(cwd, a, b) {
|
|
214
|
+
const merged = [];
|
|
215
|
+
const a2 = [...a];
|
|
216
|
+
const b2 = [...b];
|
|
217
|
+
let i = a2.shift();
|
|
218
|
+
let j = b2.shift();
|
|
219
|
+
while (i && j) switch (i.hash === j.hash ? GIT_REL_FLAGS.IS_EQUAL : await detectGitRelationship(cwd, i.hash, j.hash)) {
|
|
220
|
+
case GIT_REL_FLAGS.IS_EQUAL:
|
|
221
|
+
merged.push(i);
|
|
222
|
+
i = a2.shift();
|
|
223
|
+
j = b2.shift();
|
|
224
|
+
break;
|
|
225
|
+
case GIT_REL_FLAGS.IS_ANCESTOR:
|
|
226
|
+
merged.push(j);
|
|
227
|
+
j = b2.shift();
|
|
228
|
+
break;
|
|
229
|
+
case GIT_REL_FLAGS.IS_DESCENDANT:
|
|
230
|
+
merged.push(i);
|
|
231
|
+
i = a2.shift();
|
|
232
|
+
break;
|
|
233
|
+
case GIT_REL_FLAGS.NONE: if (i.committerDate < j.committerDate) {
|
|
234
|
+
merged.push(j);
|
|
235
|
+
j = b2.shift();
|
|
236
|
+
} else {
|
|
237
|
+
merged.push(i);
|
|
238
|
+
i = a2.shift();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (i) merged.push(i);
|
|
242
|
+
if (j) merged.push(j);
|
|
243
|
+
return merged.concat(a2).concat(b2);
|
|
244
|
+
}
|
|
245
|
+
// src/workflow/discovery/buildDependencyGraph.ts
|
|
246
|
+
/**
|
|
247
|
+
* Build a dependency graph mapping package names to dependent release plans.
|
|
248
|
+
*
|
|
249
|
+
* Each key is a package name and the value is a set of `ReleasePlan`s that
|
|
250
|
+
* list that package as a dependency.
|
|
251
|
+
*
|
|
252
|
+
* @param plans Array of release plans to analyze
|
|
253
|
+
* @returns Dependency graph mapping package name -> set of dependent plans
|
|
254
|
+
*/
|
|
255
|
+
function buildDependencyGraph(plans) {
|
|
256
|
+
const graph = /* @__PURE__ */ new Map();
|
|
257
|
+
const packageNames = new Set(plans.map((plan) => plan.package.name).filter((name) => !!name));
|
|
258
|
+
for (const plan of plans) for (const depName of plan.package.dependencies) {
|
|
259
|
+
let set = graph.get(depName);
|
|
260
|
+
if (!set && packageNames.has(depName)) graph.set(depName, set = /* @__PURE__ */ new Set());
|
|
261
|
+
if (set) set.add(plan);
|
|
262
|
+
}
|
|
263
|
+
return graph;
|
|
264
|
+
}
|
|
265
|
+
// src/workflow/analysis/propagateDependencyUpdates.ts
|
|
266
|
+
/**
|
|
267
|
+
* Propagate release updates through package dependencies.
|
|
268
|
+
*
|
|
269
|
+
* Marks packages that depend on a releasing package for a `patch` release
|
|
270
|
+
* when they do not already have a release type.
|
|
271
|
+
*
|
|
272
|
+
* @param cwd Working directory path used to read Git history
|
|
273
|
+
* @param plans Array of release plans to update
|
|
274
|
+
* @returns Updated array of release plans
|
|
275
|
+
*/
|
|
276
|
+
async function propagateDependencyUpdates(cwd, plans) {
|
|
277
|
+
const graph = buildDependencyGraph(plans);
|
|
278
|
+
const scheduled = /* @__PURE__ */ new Map();
|
|
279
|
+
const stack = [];
|
|
280
|
+
for (const plan of plans) if (plan.release?.type) {
|
|
281
|
+
const visited = /* @__PURE__ */ new Set([plan]);
|
|
282
|
+
stack.push(plan);
|
|
283
|
+
let curr;
|
|
284
|
+
while (curr = stack.pop()) if (curr.package.name) {
|
|
285
|
+
for (const dependent of graph.get(curr.package.name) ?? []) if (!visited.has(dependent)) {
|
|
286
|
+
visited.add(dependent);
|
|
287
|
+
stack.push(dependent);
|
|
288
|
+
scheduled.set(dependent, await mergeGitHistory(cwd, scheduled.get(dependent) ?? dependent.history, plan.history));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return plans.map((plan) => {
|
|
293
|
+
const history = scheduled.get(plan);
|
|
294
|
+
if (history) {
|
|
295
|
+
plan = {
|
|
296
|
+
...plan,
|
|
297
|
+
history
|
|
298
|
+
};
|
|
299
|
+
if (!plan.release?.type) plan.release = { type: "patch" };
|
|
300
|
+
}
|
|
301
|
+
return plan;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
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
|
+
|
|
306
|
+
//# sourceMappingURL=propagateDependencyUpdates-QWn0H1qa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propagateDependencyUpdates-QWn0H1qa.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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EAEJ,OAAQ,OAAO,MAAM,IAAI,GACvB,IAAI,KAAK,QAAQ,MACV;QAAA,MAAM,aAAa,MAAM,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,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"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { S as packageContainsCommit, T as execGit, h as getParsedGitCommit, l as expandGitHistory, u as resolveGitRevision, w as formatError } from "./package-Bczytil1.js";
|
|
2
|
+
// src/workflow/version/extractVersionQualifier.ts
|
|
3
|
+
/**
|
|
4
|
+
* Extract the version qualifier string from a parsed `SemVer` instance.
|
|
5
|
+
*
|
|
6
|
+
* Strips the trailing numeric counter from the `prerelease` components if
|
|
7
|
+
* present. Joins any remaining prerelease identifiers with a dot separator.
|
|
8
|
+
*
|
|
9
|
+
* @param version Parsed `SemVer` instance or nullish value to inspect
|
|
10
|
+
* @returns The extracted qualifier string or `undefined` if no prerelease exists
|
|
11
|
+
*/
|
|
12
|
+
function extractVersionQualifier(version) {
|
|
13
|
+
if (version != null && version.prerelease.length > 0) {
|
|
14
|
+
const prerelease = [...version.prerelease];
|
|
15
|
+
if (typeof prerelease.at(-1) === "number") prerelease.pop();
|
|
16
|
+
return prerelease.join(".");
|
|
17
|
+
} else return;
|
|
18
|
+
}
|
|
19
|
+
// src/util/unique.ts
|
|
20
|
+
/**
|
|
21
|
+
* Return a new array containing only the first-seen occurrence of each item.
|
|
22
|
+
*
|
|
23
|
+
* This preserves the original iteration order and performs equality checks
|
|
24
|
+
* using JavaScript's `Set` semantics (i.e., primitives by value, objects by
|
|
25
|
+
* reference). The input array is not mutated.
|
|
26
|
+
*
|
|
27
|
+
* @param array The array of items to deduplicate
|
|
28
|
+
* @returns A new array with duplicates removed, preserving first-seen order
|
|
29
|
+
*/
|
|
30
|
+
function unique(array) {
|
|
31
|
+
const seen = /* @__PURE__ */ new Set();
|
|
32
|
+
const result = [];
|
|
33
|
+
for (const item of array) if (!seen.has(item)) {
|
|
34
|
+
seen.add(item);
|
|
35
|
+
result.push(item);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
// src/git/history/readGitHistory.ts
|
|
40
|
+
/**
|
|
41
|
+
* Yield commit SHAs from repository history in paginated order.
|
|
42
|
+
*
|
|
43
|
+
* Ensures commits are available via `expandGitHistory`, resolves `until` to a
|
|
44
|
+
* commit id, and pages from `from` toward `until`, yielding each commit SHA.
|
|
45
|
+
* If a git command fails the generator ends silently.
|
|
46
|
+
*
|
|
47
|
+
* @param cwd Repository working directory
|
|
48
|
+
* @param options Supports `from`, `until`, `pageSize`, and `filePath`
|
|
49
|
+
* @yields Commit SHA strings in paginated order
|
|
50
|
+
*/
|
|
51
|
+
async function* readGitHistory(cwd, options = {}) {
|
|
52
|
+
try {
|
|
53
|
+
const { filePath, pageSize = 50 } = options;
|
|
54
|
+
let from = options.from || "HEAD";
|
|
55
|
+
let until = options.until || void 0;
|
|
56
|
+
if (until) until = await resolveGitRevision(cwd, until);
|
|
57
|
+
while (true) {
|
|
58
|
+
await expandGitHistory(cwd, {
|
|
59
|
+
from,
|
|
60
|
+
until,
|
|
61
|
+
pageSize
|
|
62
|
+
});
|
|
63
|
+
const args = [
|
|
64
|
+
"rev-list",
|
|
65
|
+
`--max-count=${pageSize}`,
|
|
66
|
+
from
|
|
67
|
+
];
|
|
68
|
+
if (until) args.push(`^${until}`);
|
|
69
|
+
if (filePath) args.push("--", ...(Array.isArray(filePath) ? filePath : [filePath]).filter(Boolean));
|
|
70
|
+
const list = (await execGit(cwd, args)).trim().split("\n").filter(Boolean);
|
|
71
|
+
for (const item of list.slice(0, -1)) yield item;
|
|
72
|
+
const tail = list.at(-1);
|
|
73
|
+
if (!tail) return;
|
|
74
|
+
if (tail === from) {
|
|
75
|
+
yield tail;
|
|
76
|
+
from = `${tail}^`;
|
|
77
|
+
from = await resolveGitRevision(cwd, from);
|
|
78
|
+
} else from = tail;
|
|
79
|
+
}
|
|
80
|
+
} catch {}
|
|
81
|
+
}
|
|
82
|
+
// src/git/history/readParsedGitHistory.ts
|
|
83
|
+
/**
|
|
84
|
+
* Yield parsed commits sequentially from repository history.
|
|
85
|
+
*
|
|
86
|
+
* Fetches commits using `readGitHistory` and parses each commit with
|
|
87
|
+
* `getParsedGitCommit`. Yields successfully parsed `GitCommit` objects on demand
|
|
88
|
+
* and skips unparsable commits, reporting each skipped commit through
|
|
89
|
+
* `options.logger` at debug level when one is provided.
|
|
90
|
+
*
|
|
91
|
+
* @param cwd Repository working directory path
|
|
92
|
+
* @param options Filter and pagination options passed to `readGitHistory`
|
|
93
|
+
* @yields Parsed `GitCommit` objects in historical order
|
|
94
|
+
*/
|
|
95
|
+
async function* readParsedGitHistory(cwd, options) {
|
|
96
|
+
for await (const commit of readGitHistory(cwd, options)) try {
|
|
97
|
+
yield await getParsedGitCommit(cwd, commit);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
options?.logger?.debug(`Commit "${commit}" could not be parsed and was skipped: ${formatError(error)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// src/workflow/analysis/readPackageHistory.ts
|
|
103
|
+
var LITERAL_PATH = /^[^*?[\]{}!+@]*$/;
|
|
104
|
+
/**
|
|
105
|
+
* Yield commits from git history associated with a package.
|
|
106
|
+
*
|
|
107
|
+
* Filters git commit history to yield only entries relevant to the target
|
|
108
|
+
* `pkg` directory. When the package file pattern is a list, plain file
|
|
109
|
+
* entries are added to the git path filter alongside the package directory
|
|
110
|
+
* (duplicates removed), so commits touching extra package files (for example
|
|
111
|
+
* the pnpm workspace manifest) are included. Only entries without glob or
|
|
112
|
+
* pattern metacharacters (wildcards, braces, and the extglob or negation
|
|
113
|
+
* characters used by package file patterns) are passed to git, because git
|
|
114
|
+
* pathspecs would interpret those characters differently. Pattern-like
|
|
115
|
+
* entries are left to `packageContainsCommit`, which matches them with the
|
|
116
|
+
* package's own file-pattern semantics.
|
|
117
|
+
*
|
|
118
|
+
* @param cwd Path to the working directory for git commands
|
|
119
|
+
* @param pkg Package configuration containing the target directory
|
|
120
|
+
* @param options Options for parsing and filtering git history
|
|
121
|
+
* @yields Commits belonging to the specified package
|
|
122
|
+
*/
|
|
123
|
+
async function* readPackageHistory(cwd, pkg, options = {}) {
|
|
124
|
+
options = { ...options };
|
|
125
|
+
if (!options.filePath) {
|
|
126
|
+
if (Array.isArray(pkg.files)) options.filePath = unique([pkg.location, ...pkg.files.filter((file) => LITERAL_PATH.test(file))]);
|
|
127
|
+
else options.filePath = pkg.location;
|
|
128
|
+
}
|
|
129
|
+
for await (const commit of readParsedGitHistory(cwd, options)) if (packageContainsCommit(pkg, commit)) yield commit;
|
|
130
|
+
}
|
|
131
|
+
export { extractVersionQualifier as a, unique as i, readParsedGitHistory as n, readGitHistory as r, readPackageHistory as t };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=readPackageHistory-CN5nqMcE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readPackageHistory-CN5nqMcE.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,KAAK,IAAI,IAAI,GAAG;EACnB,KAAK,IAAI,IAAI;EACb,OAAO,KAAK,IAAI;CAClB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