rylease 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -851
- package/dist/cli.mjs +1 -375
- package/dist/index-BGDTM9bX.d.cts +1672 -0
- package/dist/index-BGDTM9bX.d.cts.map +1 -0
- package/dist/index-CDKUm2-t.d.mts +1671 -0
- package/dist/index-CDKUm2-t.d.mts.map +1 -0
- package/dist/index.cjs +35 -4991
- package/dist/index.d.cts +2 -1572
- package/dist/index.d.mts +2 -1571
- package/dist/index.mjs +1 -4928
- package/dist/internal.cjs +239 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +50 -0
- package/dist/internal.d.cts.map +1 -0
- package/dist/internal.d.mts +50 -0
- package/dist/internal.d.mts.map +1 -0
- package/dist/internal.mjs +232 -0
- package/dist/internal.mjs.map +1 -0
- package/dist/src-BtTYwep4.cjs +6004 -0
- package/dist/src-BtTYwep4.cjs.map +1 -0
- package/dist/src-dp4Eayux.mjs +5758 -0
- package/dist/src-dp4Eayux.mjs.map +1 -0
- package/package.json +17 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["z","normalize","sep","isAbsolute","relative","resolve","posix","glob","isAbsolute","stat","readdir","join","readFile","readFile","join","DEPENDENCY_FIELDS","z","glob","readFile","join","PATTERN","classify","RANK","performance","classify","z","join","readFile","classify","z","z","z","z","readdir","join","posix","readFile","rm","join","RANK","z","RANK","z","z","z","format","z","z","readFile","writeFile","z","z","readFile","posix","relative","writeFile","z","z","z","z","promisify","deflateRaw","crc32","createHash","dirname","relative","sep","readFile","stat","z","z","stat","basename","readFile","createHash","z","z","readFile","z","readFile","writeFile","RANK","z","z","z","posix","join","dirname","access","homedir","readFile","mkdtemp","tmpdir","writeFile","rm","z","steps","presets","schemes","histories","components","z","pathToFileURL","resolve","createRequire","join"],"sources":["../src/core/options.ts","../src/core/factory.ts","../src/core/components.ts","../src/utils/files.ts","../src/components/npm/read.ts","../src/components/npm/workspaces.ts","../src/components/index.ts","../src/utils/text.ts","../src/utils/git.ts","../src/utils/version.ts","../src/utils/template.ts","../src/core/channels.ts","../src/core/facts.ts","../src/core/reporter.ts","../src/core/types.ts","../src/core/engine.ts","../src/core/define.ts","../src/core/expression.ts","../src/core/history.ts","../src/steps/npm/package-json.ts","../src/steps/fs/formats.ts","../src/histories/fs/version-file.ts","../src/histories/git/git-tags.ts","../src/utils/retry.ts","../src/steps/github/api.ts","../src/steps/github/release.ts","../src/steps/github/release-pr.ts","../src/histories/github/release-pr.ts","../src/histories/index.ts","../src/steps/channels.ts","../src/steps/change-files/parse.ts","../src/steps/change-files/files.ts","../src/steps/change-files/clean.ts","../src/steps/change-files/read.ts","../src/steps/components/dependents.ts","../src/steps/conventional/classify.ts","../src/steps/conventional/determine-kind.ts","../src/steps/notes.ts","../src/steps/conventional/determine-notes.ts","../src/steps/conventional/read-commits.ts","../src/utils/exec.ts","../src/steps/exec/run.ts","../src/steps/exec/command.ts","../src/steps/fs/write-changes.ts","../src/core/scheme.ts","../src/schemes/semver.ts","../src/steps/fs/write-version.ts","../src/steps/git/placeholders.ts","../src/steps/git/commit.ts","../src/steps/git/create-tag.ts","../src/steps/github/create-release.ts","../src/steps/github/open-release-pr.ts","../src/steps/github/read-pull-requests.ts","../src/utils/zip.ts","../src/steps/github/artifact.ts","../src/steps/github/upload-artifact.ts","../src/steps/github/upload-release-assets.ts","../src/steps/gitlab/create-release.ts","../src/steps/keep-a-changelog/changelog.ts","../src/steps/keep-a-changelog/read-unreleased.ts","../src/steps/keep-a-changelog/write-release.ts","../src/steps/labels/labels.ts","../src/steps/labels/determine-kind.ts","../src/steps/labels/determine-notes.ts","../src/steps/npm/publish.ts","../src/steps/index.ts","../src/presets/change-files.ts","../src/schemes/calver.ts","../src/schemes/index.ts","../src/presets/conventional.ts","../src/presets/conventional-pr.ts","../src/presets/keep-a-changelog.ts","../src/presets/index.ts","../src/config/workflow.ts","../src/core/summary.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type * as core from \"zod/v4/core\";\n\nexport { z };\n\n/** A step's options: a zod shape, from `zod` or `zod/mini`. */\nexport type OptionsShape = core.$ZodShape;\n\n/** What a step accepts: options with a default may be left out. */\nexport type OptionsInput<S extends OptionsShape> = core.$InferObjectInput<\n\tS,\n\tEmpty\n>;\n\n/** What a step's `run` receives: every default applied. */\nexport type OptionsValue<S extends OptionsShape> = core.$InferObjectOutput<\n\tS,\n\tEmpty\n>;\n\n/** An object type with no properties. */\nexport type Empty = Record<never, never>;\n\n/** Options that don't match a step's schema; the message lists every problem. */\nexport class OptionsError extends Error {\n\treadonly issues: readonly string[];\n\n\tconstructor(issues: readonly string[]) {\n\t\tsuper(issues.join(\"\\n\"));\n\t\tthis.name = \"OptionsError\";\n\t\tthis.issues = issues;\n\t}\n}\n\n/**\n * Validates options against a shape, applying defaults. Unknown keys are\n * rejected. Each problem is reported with `path` prepended, e.g.\n * `conventional/determine-kind.types.docs: Invalid option: ...`.\n */\nexport function parseOptions<S extends OptionsShape>(\n\tshape: S,\n\tvalue: unknown,\n\tpath: string,\n): OptionsValue<S> {\n\tconst result = z.strictObject(shape).safeParse(value ?? {});\n\tif (result.success) return result.data as OptionsValue<S>;\n\tthrow new OptionsError(\n\t\tresult.error.issues.map(\n\t\t\t(issue) => `${joinPath(path, issue.path)}: ${issue.message}`,\n\t\t),\n\t);\n}\n\nexport function joinPath(\n\tpath: string,\n\tkeys: readonly PropertyKey[] = [],\n): string {\n\treturn keys.reduce<string>(\n\t\t(text, key) =>\n\t\t\ttypeof key === \"number\"\n\t\t\t\t? `${text}[${key}]`\n\t\t\t\t: /^[\\w-]+$/.test(String(key))\n\t\t\t\t\t? `${text}.${String(key)}`\n\t\t\t\t\t: `${text}[${JSON.stringify(String(key))}]`,\n\t\tpath,\n\t);\n}\n","import {\n\ttype Empty,\n\ttype OptionsInput,\n\ttype OptionsShape,\n\ttype OptionsValue,\n\tparseOptions,\n} from \"./options.ts\";\n\n/** What a factory makes: a step, preset, scheme, history or component source. */\nexport type FactoryKind =\n\t| \"step\"\n\t| \"preset\"\n\t| \"scheme\"\n\t| \"history\"\n\t| \"components\";\n\n/**\n * Something configured with options declared as a zod shape, the same way in\n * TypeScript as in a workflow file; the options argument is optional when\n * every option is.\n */\nexport interface Factory<\n\tK extends FactoryKind,\n\tN extends string,\n\tS extends OptionsShape,\n\tR,\n> {\n\t(\n\t\t...options: Empty extends OptionsInput<S>\n\t\t\t? [options?: OptionsInput<S>]\n\t\t\t: [options: OptionsInput<S>]\n\t): R;\n\treadonly kind: K;\n\treadonly name: N;\n\treadonly description: string | undefined;\n\treadonly options: S;\n}\n\n/** Any factory of a kind, whatever its name or options. */\nexport interface AnyFactory<K extends FactoryKind = FactoryKind, R = unknown> {\n\t// biome-ignore lint/suspicious/noExplicitAny: options are checked at runtime\n\t(options?: any): R;\n\treadonly kind: K;\n\treadonly name: string;\n\treadonly description: string | undefined;\n\treadonly options: OptionsShape;\n}\n\nexport interface FactoryDefinition<\n\tN extends string,\n\tS extends OptionsShape,\n\tR,\n> {\n\t/** Identifies it in reports and in workflow files, e.g. `calver`. */\n\tname: N;\n\t/** One line on what it does, for generated docs. */\n\tdescription?: string;\n\t/** A zod shape; use `.default()` for optional options and `.describe()` to document them. */\n\toptions?: S;\n\tcreate: (options: OptionsValue<S>) => R;\n}\n\n/** Makes a factory that validates its options on every call. */\nexport function makeFactory<\n\tK extends FactoryKind,\n\tconst N extends string,\n\tS extends OptionsShape,\n\tR,\n>(kind: K, definition: FactoryDefinition<N, S, R>): Factory<K, N, S, R> {\n\tconst shape = (definition.options ?? {}) as S;\n\tconst factory = (options?: unknown) =>\n\t\tdefinition.create(parseOptions(shape, options, definition.name));\n\treturn Object.defineProperties(factory, {\n\t\tkind: { value: kind, enumerable: true },\n\t\tname: { value: definition.name, enumerable: true },\n\t\tdescription: { value: definition.description, enumerable: true },\n\t\toptions: { value: shape, enumerable: true },\n\t}) as unknown as Factory<K, N, S, R>;\n}\n\n/** Whether a value is a factory, of any kind or of the given one. */\nexport function isFactory<K extends FactoryKind>(\n\tvalue: unknown,\n\tkind?: K,\n): value is AnyFactory<K> {\n\tif (typeof value !== \"function\") return false;\n\tconst factory = value as Partial<AnyFactory>;\n\treturn (\n\t\ttypeof factory.kind === \"string\" &&\n\t\t(kind === undefined || factory.kind === kind) &&\n\t\ttypeof factory.name === \"string\"\n\t);\n}\n","import { isAbsolute, normalize, relative, sep } from \"node:path\";\nimport { type FactoryDefinition, makeFactory } from \"./factory.ts\";\nimport type { History } from \"./history.ts\";\nimport { OptionsError, type OptionsShape } from \"./options.ts\";\nimport type { Scheme } from \"./scheme.ts\";\nimport type { ComponentInfo, Environment } from \"./types.ts\";\n\n/** A versioned unit of the project; see {@link ComponentInfo}. */\nexport interface Component {\n\tname: string;\n\t/** Its directory, relative to the project. Defaults to `.`. */\n\tpath?: string;\n\t/** Components it depends on, by name. */\n\tdependsOn?: readonly string[];\n\t/** Overrides the release's scheme. */\n\tscheme?: Scheme;\n\t/** Overrides the release's tag template. */\n\ttag?: string;\n\t/** Overrides where the release finds previous versions. */\n\thistory?: History;\n}\n\n/** Finds a project's components, e.g. the packages of a workspace. */\nexport interface ComponentSource {\n\treadonly name: string;\n\tresolve(env: Environment): Promise<Component[]>;\n}\n\n/** Defines a source of components, with options as a zod shape. */\nexport function defineComponents<\n\tconst N extends string,\n\tS extends OptionsShape,\n>(definition: FactoryDefinition<N, S, ComponentSource>) {\n\treturn makeFactory(\"components\", definition);\n}\n\n/** A component with everything worked out. */\nexport interface ResolvedComponent {\n\tinfo: ComponentInfo;\n\tscheme: Scheme;\n\thistory: History;\n\t/** The tag template, with `{name}` filled in. */\n\ttag: string;\n}\n\nexport interface Defaults {\n\tscheme: Scheme;\n\thistory: History;\n\t/** Defaults to `v{version}` for one component, `{name}@{version}` for more. */\n\ttag: string | undefined;\n}\n\n/**\n * Checks components and fills in their defaults, ordered so that each comes\n * after the components it depends on.\n */\nexport function resolveComponents(\n\tcomponents: readonly Component[],\n\tdefaults: Defaults,\n): ResolvedComponent[] {\n\tconst issues: string[] = [];\n\tconst names = new Set<string>();\n\tfor (const [index, component] of components.entries()) {\n\t\tif (typeof component.name !== \"string\" || component.name === \"\") {\n\t\t\tissues.push(`components[${index}].name: expected a name`);\n\t\t} else if (names.has(component.name)) {\n\t\t\tissues.push(\n\t\t\t\t`components[${index}].name: '${component.name}' is listed twice`,\n\t\t\t);\n\t\t}\n\t\tnames.add(component.name);\n\t}\n\tconst paths = components.map((component, index) => {\n\t\tconst path = normalize(component.path ?? \".\").replaceAll(sep, \"/\");\n\t\tif (isAbsolute(path) || path === \"..\" || path.startsWith(\"../\")) {\n\t\t\tissues.push(\n\t\t\t\t`components[${index}].path: '${component.path}' must be inside the project`,\n\t\t\t);\n\t\t}\n\t\treturn path.replace(/\\/$/, \"\");\n\t});\n\tfor (const [index, component] of components.entries()) {\n\t\tfor (const dependency of component.dependsOn ?? []) {\n\t\t\tif (!names.has(dependency)) {\n\t\t\t\tissues.push(\n\t\t\t\t\t`components[${index}].dependsOn: '${dependency}' isn't a component`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tconst several = components.length > 1;\n\tconst tags = components.map((component) => {\n\t\tconst template =\n\t\t\tcomponent.tag ??\n\t\t\tdefaults.tag ??\n\t\t\t(several ? \"{name}@{version}\" : \"v{version}\");\n\t\treturn template.replaceAll(\"{name}\", component.name);\n\t});\n\tfor (const [index, tag] of tags.entries()) {\n\t\tconst at =\n\t\t\tcomponents[index]?.tag === undefined ? \"tag\" : `components[${index}].tag`;\n\t\tconst unknown = [...tag.matchAll(/\\{(\\w+)\\}/g)]\n\t\t\t.map(([, name]) => name)\n\t\t\t.filter((name) => name !== \"version\");\n\t\tif (!tag.includes(\"{version}\")) {\n\t\t\tissues.push(`${at}: '${tag}' has no {version} placeholder`);\n\t\t} else if (unknown.length > 0) {\n\t\t\tissues.push(\n\t\t\t\t`${at}: unknown placeholder {${unknown[0]}} in '${tag}'; use {version} or {name}`,\n\t\t\t);\n\t\t}\n\t}\n\tconst seen = new Map<string, string>();\n\tfor (const [index, tag] of tags.entries()) {\n\t\tconst other = seen.get(tag);\n\t\tconst name = components[index]?.name ?? \"\";\n\t\tif (other !== undefined) {\n\t\t\tissues.push(\n\t\t\t\t`components: '${other}' and '${name}' share the tag '${tag}'; add {name} to it`,\n\t\t\t);\n\t\t}\n\t\tseen.set(tag, name);\n\t}\n\tif (issues.length > 0) throw new OptionsError(issues);\n\n\tconst resolved = components.map((component, index): ResolvedComponent => {\n\t\tconst path = paths[index] ?? \".\";\n\t\tconst nested = paths.filter(\n\t\t\t(other, i) => i !== index && isInside(other, path),\n\t\t);\n\t\tconst whole = path === \".\" && nested.length === 0;\n\t\treturn {\n\t\t\tinfo: {\n\t\t\t\tname: component.name,\n\t\t\t\tpath,\n\t\t\t\tdependsOn: [...(component.dependsOn ?? [])],\n\t\t\t\tpathspec: whole\n\t\t\t\t\t? []\n\t\t\t\t\t: [path, ...nested.map((other) => `:(exclude)${other}`)],\n\t\t\t},\n\t\t\tscheme: component.scheme ?? defaults.scheme,\n\t\t\thistory: component.history ?? defaults.history,\n\t\t\ttag: tags[index] ?? \"\",\n\t\t};\n\t});\n\treturn dependencyOrder(resolved);\n}\n\n/** Whether `path` is strictly inside `parent`, both relative to the project. */\nfunction isInside(path: string, parent: string): boolean {\n\tif (path === parent) return false;\n\tif (parent === \".\") return path !== \".\";\n\tconst between = relative(parent, path);\n\treturn between !== \"\" && !between.startsWith(\"..\") && !isAbsolute(between);\n}\n\n/** Dependencies first, otherwise in the order given. */\nfunction dependencyOrder(components: ResolvedComponent[]): ResolvedComponent[] {\n\tconst ordered: ResolvedComponent[] = [];\n\tconst done = new Set<string>();\n\tlet remaining = components;\n\twhile (remaining.length > 0) {\n\t\tconst ready = remaining.filter(({ info }) =>\n\t\t\tinfo.dependsOn.every((name) => done.has(name)),\n\t\t);\n\t\tif (ready.length === 0) {\n\t\t\tthrow new OptionsError([\n\t\t\t\t`components: ${remaining.map(({ info }) => info.name).join(\", \")} depend on each other in a cycle`,\n\t\t\t]);\n\t\t}\n\t\tfor (const component of ready) {\n\t\t\tordered.push(component);\n\t\t\tdone.add(component.info.name);\n\t\t}\n\t\tremaining = remaining.filter((component) => !ready.includes(component));\n\t}\n\treturn ordered;\n}\n","import { glob, readdir, readFile, stat } from \"node:fs/promises\";\nimport { isAbsolute, join, posix, resolve } from \"node:path\";\n\n/**\n * A path relative to a component's directory: where it is, and how it's\n * written relative to the project, e.g. in `files` and reasons.\n */\nexport function inComponent(\n\tenv: { cwd: string },\n\tcomponent: { path: string },\n\tpath: string,\n): { file: string; relative: string } {\n\treturn {\n\t\tfile: resolve(env.cwd, component.path, path),\n\t\trelative: posix.normalize(\n\t\t\tposix.join(component.path, path.replaceAll(\"\\\\\", \"/\")),\n\t\t),\n\t};\n}\n\n/**\n * Resolves globs, relative to `cwd` unless absolute, to the absolute paths of\n * the files they match, sorted; a directory stands for every file in it.\n * Every pattern must match something, so a typo fails instead of uploading\n * nothing.\n */\nexport async function resolveFiles(\n\tcwd: string,\n\tpatterns: readonly string[],\n): Promise<string[]> {\n\tconst files = new Set<string>();\n\tfor (const pattern of patterns) {\n\t\t// Forward slashes work on Windows too, where a backslash would escape.\n\t\tconst normalized = pattern.replaceAll(\"\\\\\", \"/\");\n\t\tlet matched = false;\n\t\tfor await (const match of glob(normalized, { cwd })) {\n\t\t\tconst path = isAbsolute(match) ? match : resolve(cwd, match);\n\t\t\t// An empty directory matches no files.\n\t\t\tfor (const file of await filesIn(path)) {\n\t\t\t\tfiles.add(file);\n\t\t\t\tmatched = true;\n\t\t\t}\n\t\t}\n\t\tif (!matched) throw new Error(`no files match '${pattern}'`);\n\t}\n\treturn [...files].sort();\n}\n\nasync function filesIn(path: string): Promise<string[]> {\n\tif (!(await stat(path)).isDirectory()) return [path];\n\tconst entries = await readdir(path, { recursive: true, withFileTypes: true });\n\treturn entries\n\t\t.filter((entry) => entry.isFile())\n\t\t.map((entry) => join(entry.parentPath, entry.name));\n}\n\n/** `1.2 MB`, `340 kB`, `12 B`. */\nexport function formatSize(bytes: number): string {\n\tconst units = [\"B\", \"kB\", \"MB\", \"GB\"];\n\tlet size = bytes;\n\tlet unit = 0;\n\twhile (size >= 1000 && unit < units.length - 1) {\n\t\tsize /= 1000;\n\t\tunit++;\n\t}\n\treturn `${unit === 0 ? size : size.toFixed(1)} ${units[unit]}`;\n}\n\nexport async function loadJson(path: string): Promise<Record<string, unknown>> {\n\treturn JSON.parse(await readFile(path, \"utf8\")) as Record<string, unknown>;\n}\n","import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { loadJson } from \"../../utils/files.ts\";\n\n/**\n * The `packages:` list of a pnpm-workspace.yaml, in block style; negated\n * patterns are left out.\n */\nfunction pnpmPackages(text: string): string[] {\n\tconst patterns: string[] = [];\n\tlet inPackages = false;\n\tfor (const line of text.split(/\\r?\\n/)) {\n\t\tif (/^packages:\\s*$/.test(line)) {\n\t\t\tinPackages = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!inPackages) continue;\n\t\tconst item = /^\\s+-\\s+(.+?)\\s*$/.exec(line);\n\t\tif (item?.[1]) {\n\t\t\tconst pattern =\n\t\t\t\t/^(['\"])(.*)\\1$/.exec(item[1])?.[2] ?? item[1].replace(/\\s+#.*$/, \"\");\n\t\t\tif (!pattern.startsWith(\"!\")) patterns.push(pattern);\n\t\t} else if (/^\\S/.test(line)) {\n\t\t\tinPackages = false;\n\t\t}\n\t}\n\treturn patterns;\n}\n\n/** Globs of the workspace's packages, from pnpm-workspace.yaml or package.json. */\nexport async function getPackages(cwd: string): Promise<string[]> {\n\tconst pnpm = await readFile(join(cwd, \"pnpm-workspace.yaml\"), \"utf8\").catch(\n\t\t() => undefined,\n\t);\n\tif (pnpm !== undefined) {\n\t\tconst patterns = pnpmPackages(pnpm);\n\t\tif (patterns.length > 0) return patterns;\n\t}\n\tconst json = await loadJson(join(cwd, \"package.json\")).catch(() => ({}));\n\tconst workspaces = (json as { workspaces?: unknown }).workspaces;\n\tconst list = Array.isArray(workspaces)\n\t\t? workspaces\n\t\t: (workspaces as { packages?: unknown } | undefined)?.packages;\n\tif (!Array.isArray(list) || list.length === 0) {\n\t\tthrow new Error(\n\t\t\t\"no workspaces: list them in package.json `workspaces`, or in pnpm-workspace.yaml `packages`\",\n\t\t);\n\t}\n\treturn list.filter((item): item is string => typeof item === \"string\");\n}\n","import { glob, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { type Component, defineComponents } from \"../../core/components.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { getPackages } from \"./read.ts\";\n\nconst DEPENDENCY_FIELDS = [\n\t\"dependencies\",\n\t\"devDependencies\",\n\t\"peerDependencies\",\n\t\"optionalDependencies\",\n] as const;\n\n/**\n * The packages of an npm, Yarn or pnpm workspace, as components named after\n * them, each depending on the workspace packages it lists as dependencies.\n */\nexport const npmWorkspaces = defineComponents({\n\tname: \"npm/workspaces\",\n\tdescription:\n\t\t\"Each package of the npm, Yarn or pnpm workspace, named after it and depending on the workspace packages it depends on.\",\n\toptions: {\n\t\tprivate: z\n\t\t\t.boolean()\n\t\t\t.default(false)\n\t\t\t.describe(\"Include packages marked `private`.\"),\n\t\texclude: z\n\t\t\t.array(z.string())\n\t\t\t.default([])\n\t\t\t.describe(\"Packages to leave out, by name.\"),\n\t},\n\tcreate: (options) => ({\n\t\tname: \"npm/workspaces\",\n\t\tresolve: async (env) => {\n\t\t\tconst patterns = await getPackages(env.cwd);\n\t\t\tconst found: {\n\t\t\t\tname: string;\n\t\t\t\tpath: string;\n\t\t\t\tjson: Record<string, unknown>;\n\t\t\t}[] = [];\n\t\t\tfor (const pattern of patterns) {\n\t\t\t\tfor await (const match of glob(\n\t\t\t\t\t`${pattern.replace(/\\/$/, \"\")}/package.json`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: env.cwd,\n\t\t\t\t\t},\n\t\t\t\t)) {\n\t\t\t\t\tconst path =\n\t\t\t\t\t\tmatch.replaceAll(\"\\\\\", \"/\").replace(/\\/?package\\.json$/, \"\") || \".\";\n\t\t\t\t\tif (path.includes(\"node_modules\")) continue;\n\t\t\t\t\tconst json = JSON.parse(\n\t\t\t\t\t\tawait readFile(join(env.cwd, match), \"utf8\"),\n\t\t\t\t\t) as Record<string, unknown>;\n\t\t\t\t\tif (typeof json.name !== \"string\") continue;\n\t\t\t\t\tif (json.private === true && !options.private) continue;\n\t\t\t\t\tif (options.exclude.includes(json.name)) continue;\n\t\t\t\t\tif (!found.some((other) => other.path === path)) {\n\t\t\t\t\t\tfound.push({ name: json.name, path, json });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (found.length === 0) {\n\t\t\t\tthrow new Error(`no workspace packages in ${env.cwd}`);\n\t\t\t}\n\t\t\tfound.sort((a, b) => a.path.localeCompare(b.path));\n\t\t\tconst names = new Set(found.map(({ name }) => name));\n\t\t\treturn found.map(({ name, path, json }): Component => {\n\t\t\t\tconst dependsOn = new Set<string>();\n\t\t\t\tfor (const field of DEPENDENCY_FIELDS) {\n\t\t\t\t\tconst deps = json[field];\n\t\t\t\t\tif (typeof deps !== \"object\" || deps === null) continue;\n\t\t\t\t\tfor (const dep of Object.keys(deps)) {\n\t\t\t\t\t\tif (names.has(dep) && dep !== name) dependsOn.add(dep);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { name, path, dependsOn: [...dependsOn] };\n\t\t\t});\n\t\t},\n\t}),\n});\n","export * from \"./npm/index.ts\";\n","export function plural(\n\tcount: number,\n\tnoun: string,\n\tnouns = `${noun}s`,\n): string {\n\treturn `${count} ${count === 1 ? noun : nouns}`;\n}\n\n/** `a`, `a and b`, `a, b and c`. */\nexport function joinList(parts: readonly string[]): string {\n\treturn parts.length > 1\n\t\t? `${parts.slice(0, -1).join(\", \")} and ${parts.at(-1)}`\n\t\t: (parts[0] ?? \"\");\n}\n","import { execFile } from \"node:child_process\";\n\n/** Runs `git` in `cwd` and resolves with its trimmed stdout. */\nexport function git(cwd: string, ...args: string[]): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\texecFile(\n\t\t\t\"git\",\n\t\t\targs,\n\t\t\t{ cwd, maxBuffer: 64 * 1024 * 1024 },\n\t\t\t(error, stdout, stderr) => {\n\t\t\t\tif (error) {\n\t\t\t\t\tconst detail = stderr.trim() || error.message;\n\t\t\t\t\treject(new Error(`git ${args.join(\" \")} failed: ${detail}`));\n\t\t\t\t} else {\n\t\t\t\t\tresolve(stdout.trim());\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t});\n}\n\n/** Like {@link git}, but resolves with `undefined` instead of rejecting. */\nexport async function tryGit(\n\tcwd: string,\n\t...args: string[]\n): Promise<string | undefined> {\n\ttry {\n\t\treturn await git(cwd, ...args);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** `GITHUB_REPOSITORY`, or `owner/repo` from the `origin` remote. */\nexport async function detectRepo(cwd: string): Promise<string | undefined> {\n\tif (process.env.GITHUB_REPOSITORY) return process.env.GITHUB_REPOSITORY;\n\tconst url = await tryGit(cwd, \"remote\", \"get-url\", \"origin\");\n\treturn url ? parseGitHubRepo(url) : undefined;\n}\n\n/** `git@github.com:o/r.git`, `https://github.com/o/r` and similar → `o/r`. */\nexport function parseGitHubRepo(url: string): string | undefined {\n\treturn /github\\.com[:/]([^/]+\\/[^/]+?)(?:\\.git)?\\/?$/.exec(url.trim())?.[1];\n}\n\n/** Rejects shallow clones, whose history would silently miss commits. */\nexport async function assertFullHistory(cwd: string): Promise<void> {\n\tif ((await git(cwd, \"rev-parse\", \"--is-shallow-repository\")) === \"true\") {\n\t\tthrow new Error(\n\t\t\t\"the repository is a shallow clone; fetch full history (e.g. `fetch-depth: 0`)\",\n\t\t);\n\t}\n}\n\n/**\n * `git log` of the commits since `ref` (or all of them), touching a\n * component's pathspec. A component that's the whole project still only\n * counts the commits of the working directory, when that's a subdirectory.\n */\nexport async function logSince(\n\tcwd: string,\n\toptions: {\n\t\tref?: string | undefined;\n\t\tpathspec: readonly string[];\n\t\tformat: string;\n\t},\n): Promise<string> {\n\tconst range = options.ref ? `${options.ref}..HEAD` : \"HEAD\";\n\tlet pathspec = options.pathspec;\n\tif (pathspec.length === 0) {\n\t\tconst prefix = await git(cwd, \"rev-parse\", \"--show-prefix\");\n\t\tif (prefix) pathspec = [\".\"];\n\t}\n\treturn git(\n\t\tcwd,\n\t\t\"log\",\n\t\t`--format=${options.format}`,\n\t\trange,\n\t\t...(pathspec.length > 0 ? [\"--\", ...pathspec] : []),\n\t);\n}\n\n/**\n * The oldest commit of the latest run of commits in which `file` had\n * `version`, as `read` finds it in the file's content at each commit; that is,\n * the commit that set the version. `undefined` outside a git repository, or\n * when no commit has it.\n */\nexport async function findVersionCommit(\n\tcwd: string,\n\tfile: string,\n\tversion: string,\n\tread: (content: string) => string | undefined,\n): Promise<string | undefined> {\n\tconst log = await tryGit(cwd, \"log\", \"--format=%H\", \"--\", file);\n\tif (log === undefined) return undefined; // not a git repository\n\tawait assertFullHistory(cwd);\n\tlet found: string | undefined;\n\tfor (const sha of log.split(\"\\n\").filter(Boolean)) {\n\t\tconst content = await tryGit(cwd, \"show\", `${sha}:./${file}`);\n\t\tif (content === undefined || read(content) !== version) break;\n\t\tfound = sha;\n\t}\n\treturn found;\n}\n\nconst BOT_IDENTITY = [\n\t\"-c\",\n\t\"user.name=github-actions[bot]\",\n\t\"-c\",\n\t\"user.email=41898282+github-actions[bot]@users.noreply.github.com\",\n];\n\n/**\n * Arguments that set the CI's identity when none is set, for commands that\n * commit or tag: the bot's in GitHub Actions, the user who started the\n * pipeline's in GitLab CI.\n */\nexport async function identity(cwd: string): Promise<string[]> {\n\tif (await tryGit(cwd, \"config\", \"user.email\")) return [];\n\tif (process.env.GITHUB_ACTIONS === \"true\") return BOT_IDENTITY;\n\tconst { GITLAB_CI, GITLAB_USER_NAME, GITLAB_USER_EMAIL } = process.env;\n\tif (GITLAB_CI === \"true\" && GITLAB_USER_NAME && GITLAB_USER_EMAIL) {\n\t\treturn [\n\t\t\t\"-c\",\n\t\t\t`user.name=${GITLAB_USER_NAME}`,\n\t\t\t\"-c\",\n\t\t\t`user.email=${GITLAB_USER_EMAIL}`,\n\t\t];\n\t}\n\treturn [];\n}\n","/**\n * A version as most schemes write it: dot-separated numbers, then an optional\n * `-pre.release` and `+build`. Semver (`1.2.3-rc.1`), CalVer (`2026.01.3`),\n * `24.04` and `1.2.3.4` all fit; nothing here requires a particular scheme.\n */\nexport interface Version {\n\t/** The numbers, as written, e.g. `[\"2026\", \"01\", \"3\"]`. */\n\trelease: string[];\n\tprerelease?: string;\n\tbuild?: string;\n}\n\nconst PATTERN =\n\t/^v?(\\d+(?:\\.\\d+)*)(?:-([0-9A-Za-z.-]+))?(?:\\+([0-9A-Za-z.-]+))?$/;\n\n/** Parses a version, or returns `undefined` if it isn't one, e.g. `next`. */\nexport function parseVersion(version: string): Version | undefined {\n\tconst match = PATTERN.exec(version.trim());\n\tif (!match) return undefined;\n\tconst [, release = \"\", prerelease, build] = match;\n\treturn {\n\t\trelease: release.split(\".\"),\n\t\t...(prerelease !== undefined && { prerelease }),\n\t\t...(build !== undefined && { build }),\n\t};\n}\n\n/**\n * Orders versions by precedence: number by number, a missing number counting\n * as 0 (`1.2` = `1.2.0`), then by pre-release as in semver. Build metadata is\n * ignored.\n */\nexport function compareVersions(a: Version, b: Version): number {\n\tfor (let i = 0; i < Math.max(a.release.length, b.release.length); i++) {\n\t\tconst order = compareNumbers(a.release[i] ?? \"0\", b.release[i] ?? \"0\");\n\t\tif (order !== 0) return order;\n\t}\n\treturn comparePrerelease(a.prerelease, b.prerelease);\n}\n\n/** The index of the first number that differs, or `undefined` if none does. */\nexport function firstDifference(a: Version, b: Version): number | undefined {\n\tfor (let i = 0; i < Math.max(a.release.length, b.release.length); i++) {\n\t\tif (compareNumbers(a.release[i] ?? \"0\", b.release[i] ?? \"0\") !== 0) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** Compares digit strings by value, however long, ignoring leading zeros. */\nfunction compareNumbers(a: string, b: string): number {\n\tconst x = BigInt(a);\n\tconst y = BigInt(b);\n\treturn x < y ? -1 : x > y ? 1 : 0;\n}\n\nfunction comparePrerelease(a?: string, b?: string): number {\n\tif (a === b) return 0;\n\t// A version without a pre-release ranks above one with it.\n\tif (a === undefined) return 1;\n\tif (b === undefined) return -1;\n\tconst left = a.split(\".\");\n\tconst right = b.split(\".\");\n\tfor (let i = 0; i < Math.max(left.length, right.length); i++) {\n\t\tconst x = left[i];\n\t\tconst y = right[i];\n\t\tif (x === undefined) return -1;\n\t\tif (y === undefined) return 1;\n\t\tconst numeric = /^\\d+$/.test(x) && /^\\d+$/.test(y);\n\t\tconst order = numeric ? compareNumbers(x, y) : x < y ? -1 : x > y ? 1 : 0;\n\t\tif (order !== 0) return order;\n\t}\n\treturn 0;\n}\n","import { parseVersion } from \"./version.ts\";\n\nconst PLACEHOLDER = /\\{(\\w+)\\}/g;\n\n/** Replaces `{name}` placeholders, e.g. `v{version}` → `v1.2.3`. */\nexport function fill(\n\ttemplate: string,\n\tvalues: Readonly<Record<string, string>>,\n): string {\n\treturn template.replace(PLACEHOLDER, (_, name: string) => {\n\t\tconst value = values[name];\n\t\tif (value === undefined) {\n\t\t\tconst known = Object.keys(values).map((key) => `{${key}}`);\n\t\t\tthrow new Error(\n\t\t\t\t`unknown placeholder {${name}} in '${template}'; use ${known.join(\" or \")}`,\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t});\n}\n\n/**\n * Matches text produced by `fill(template, { [name]: ... })`, capturing the\n * value of `name`, e.g. `v{version}` → `/^v(.+)$/`.\n */\nexport function templatePattern(template: string, name: string): RegExp {\n\tlet found = false;\n\tconst source = template\n\t\t.split(PLACEHOLDER)\n\t\t.map((part, index) => {\n\t\t\t// Odd indices are placeholder names.\n\t\t\tif (index % 2 === 0) return part.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t\tif (part !== name) {\n\t\t\t\tthrow new Error(`unknown placeholder {${part}} in '${template}'`);\n\t\t\t}\n\t\t\tfound = true;\n\t\t\treturn \"(.+)\";\n\t\t})\n\t\t.join(\"\");\n\tif (!found) throw new Error(`'${template}' has no {${name}} placeholder`);\n\treturn new RegExp(`^${source}$`);\n}\n\nexport const VERSION_PLACEHOLDERS =\n\t\"`{version}`, `{tag}` and `{name}` (the component's) are filled in, and the scheme's own, e.g. `{major}`, `{minor}` and `{patch}`\";\n\n/**\n * Generic placeholders of a version, in any scheme, under the scheme's own:\n * `2026.01.3` gives `{major}` 2026, `{minor}` 01 and `{patch}` 3. A part the\n * version doesn't have is left out, so using it fails.\n */\nexport function versionValues(version: string): Record<string, string> {\n\tconst [major, minor, patch] = parseVersion(version)?.release ?? [];\n\treturn Object.fromEntries(\n\t\tObject.entries({ version, major, minor, patch }).filter(\n\t\t\t(entry): entry is [string, string] => entry[1] !== undefined,\n\t\t),\n\t);\n}\n","import { fill } from \"../utils/template.ts\";\nimport { OptionsError } from \"./options.ts\";\nimport type { Scheme } from \"./scheme.ts\";\n\n/**\n * A release channel: versions that wrap the scheme's own in a format with a\n * counter, e.g. `2.0.0-next.1`. A `prerelease` comes before the version it\n * leads up to; a `build` comes after the version it numbers builds of.\n */\nexport interface Channel {\n\t/** Branches that release on this channel, as globs, e.g. `beta/*`. */\n\tbranches?: readonly string[];\n\t/** Defaults to `prerelease`. */\n\ttype?: ChannelType;\n\t/**\n\t * How its versions are written: `{version}` is the target version, `{n}`\n\t * the counter and `{channel}` the channel's name. Defaults to the\n\t * scheme's, or `{version}-{channel}.{n}` for a prerelease and\n\t * `{version}+{channel}.{n}` for a build.\n\t */\n\tformat?: string;\n}\n\nexport type ChannelType = \"prerelease\" | \"build\";\n\n/** The channel a run releases on. */\nexport interface RunChannel {\n\tname: string;\n\ttype: ChannelType;\n}\n\n/** A channel, with its format worked out for a scheme. */\nexport interface ResolvedChannel extends RunChannel {\n\tformat: string;\n}\n\nconst DEFAULT_FORMATS: Record<ChannelType, string> = {\n\tprerelease: \"{version}-{channel}.{n}\",\n\tbuild: \"{version}+{channel}.{n}\",\n};\n\n/** Checks channels, so a typo fails before anything runs. */\nexport function checkChannels(\n\tchannels: Readonly<Record<string, Channel>>,\n): void {\n\tconst issues: string[] = [];\n\tfor (const [name, channel] of Object.entries(channels)) {\n\t\tconst at = `channels.${name}`;\n\t\tif (!/^[0-9A-Za-z-]+$/.test(name)) {\n\t\t\tissues.push(`${at}: names may only have letters, digits and '-'`);\n\t\t}\n\t\tif (\n\t\t\tchannel.type !== undefined &&\n\t\t\tchannel.type !== \"prerelease\" &&\n\t\t\tchannel.type !== \"build\"\n\t\t) {\n\t\t\tissues.push(`${at}.type: expected prerelease or build`);\n\t\t}\n\t\tconst format = channel.format;\n\t\tif (format !== undefined) {\n\t\t\tfor (const name of [\"{version}\", \"{n}\"]) {\n\t\t\t\tif (!format.includes(name)) {\n\t\t\t\t\tissues.push(`${at}.format: '${format}' has no ${name} placeholder`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst unknown = [...format.matchAll(/\\{(\\w+)\\}/g)]\n\t\t\t\t.map(([, name]) => name)\n\t\t\t\t.find((name) => ![\"version\", \"n\", \"channel\"].includes(name ?? \"\"));\n\t\t\tif (unknown) {\n\t\t\t\tissues.push(\n\t\t\t\t\t`${at}.format: unknown placeholder {${unknown}}; use {version}, {n} or {channel}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tif (issues.length > 0) throw new OptionsError(issues);\n}\n\n/**\n * The channel a run releases on: the one asked for, or the first whose\n * branches match; none means a stable release.\n */\nexport function selectChannel(\n\tchannels: Readonly<Record<string, Channel>>,\n\tbranch: string,\n\tasked: string | undefined,\n): RunChannel | undefined {\n\tif (asked !== undefined && asked !== \"\") {\n\t\tconst channel = channels[asked];\n\t\tif (!channel) {\n\t\t\tconst known = Object.keys(channels);\n\t\t\tthrow new OptionsError([\n\t\t\t\t`channel: '${asked}' isn't a channel${known.length > 0 ? `; use ${known.join(\", \")}` : \"; define it in channels\"}`,\n\t\t\t]);\n\t\t}\n\t\treturn { name: asked, type: channel.type ?? \"prerelease\" };\n\t}\n\tfor (const [name, channel] of Object.entries(channels)) {\n\t\tif (channel.branches?.some((pattern) => matchesGlob(branch, pattern))) {\n\t\t\treturn { name, type: channel.type ?? \"prerelease\" };\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** Every channel, with its format for the scheme. */\nexport function resolveChannels(\n\tchannels: Readonly<Record<string, Channel>>,\n\tscheme: Scheme,\n): ResolvedChannel[] {\n\treturn Object.entries(channels).map(([name, channel]) => {\n\t\tconst type = channel.type ?? \"prerelease\";\n\t\treturn {\n\t\t\tname,\n\t\t\ttype,\n\t\t\tformat: channel.format ?? scheme.formats?.[type] ?? DEFAULT_FORMATS[type],\n\t\t};\n\t});\n}\n\n/** What a version is, as far as the scheme and channels can tell. */\nexport type Classified =\n\t| { type: \"stable\"; target: string }\n\t| { type: ChannelType; channel: string; target: string; n: number }\n\t| { type: \"foreign\" };\n\n/**\n * Classifies a version: on one of the channels (`2.0.0-next.3`), stable in\n * the scheme (`2.0.0`), or neither.\n */\nexport function classify(\n\tversion: string,\n\tscheme: Scheme,\n\tchannels: readonly ResolvedChannel[],\n): Classified {\n\tfor (const channel of channels) {\n\t\tconst match = channelPattern(channel).exec(version);\n\t\tconst target = match?.groups?.version;\n\t\tconst n = match?.groups?.n;\n\t\tif (target !== undefined && n !== undefined && scheme.matches(target)) {\n\t\t\treturn {\n\t\t\t\ttype: channel.type,\n\t\t\t\tchannel: channel.name,\n\t\t\t\ttarget,\n\t\t\t\tn: Number(n),\n\t\t\t};\n\t\t}\n\t}\n\treturn scheme.matches(version)\n\t\t? { type: \"stable\", target: version }\n\t\t: { type: \"foreign\" };\n}\n\n/** A version on a channel. */\nexport function channelVersion(\n\tchannel: ResolvedChannel,\n\ttarget: string,\n\tn: number,\n): string {\n\treturn fill(channel.format, {\n\t\tversion: target,\n\t\tchannel: channel.name,\n\t\tn: String(n),\n\t});\n}\n\nconst RANK = { prerelease: -1, stable: 0, build: 1 } as const;\n\n/**\n * Orders classified versions: by target in the scheme, then a prerelease\n * before the stable version before a build, then by counter.\n */\nexport function compareClassified(\n\ta: Classified,\n\tb: Classified,\n\tscheme: Scheme,\n): number {\n\tif (a.type === \"foreign\" || b.type === \"foreign\") return 0;\n\tconst order = scheme.compare(a.target, b.target);\n\tif (order !== 0) return order;\n\tif (a.type !== b.type) return RANK[a.type] - RANK[b.type];\n\treturn a.type === \"stable\" || b.type === \"stable\" ? 0 : a.n - b.n;\n}\n\nfunction channelPattern(channel: ResolvedChannel): RegExp {\n\tconst source = channel.format\n\t\t.split(/(\\{\\w+\\})/)\n\t\t.map((part) => {\n\t\t\tif (part === \"{version}\") return \"(?<version>.+?)\";\n\t\t\tif (part === \"{n}\") return \"(?<n>\\\\d+)\";\n\t\t\tconst literal = part === \"{channel}\" ? channel.name : part;\n\t\t\treturn literal.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t})\n\t\t.join(\"\");\n\treturn new RegExp(`^${source}$`);\n}\n\n/** `*` matches within a path segment, `**` across them. */\nexport function matchesGlob(text: string, pattern: string): boolean {\n\tconst source = pattern\n\t\t.split(/(\\*\\*|\\*)/)\n\t\t.map((part) =>\n\t\t\tpart === \"**\"\n\t\t\t\t? \".*\"\n\t\t\t\t: part === \"*\"\n\t\t\t\t\t? \"[^/]*\"\n\t\t\t\t\t: part.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"),\n\t\t)\n\t\t.join(\"\");\n\treturn new RegExp(`^${source}$`).test(text);\n}\n","import type { Change } from \"./types.ts\";\n\n/**\n * What can be known about a release before it's made, beyond its shape: what\n * steps declare they `need`, and what steps and schemes declare they\n * `provide`. Add your own by declaration merging:\n *\n * ```ts\n * declare module \"rylease\" {\n * interface Facts { \"changes.jira\": true }\n * }\n * ```\n */\nexport interface Facts {\n\t/** Every change has a `title`. */\n\t\"changes.title\": true;\n\t/** Every change has a `description`. */\n\t\"changes.description\": true;\n\t/** Every change has `labels`, if only `[]`. */\n\t\"changes.labels\": true;\n\t/** Every change has a `link`. */\n\t\"changes.link\": true;\n\t/** There's a previous version, in the release's scheme. */\n\tpreviousVersion: true;\n\t/** Versions are semantic versions, e.g. as npm requires. */\n\t\"version.semver\": true;\n}\n\nexport type Fact = Extract<keyof Facts, string>;\n\n/** The facts about `changes`, which hold only as long as the changes do. */\nconst CHANGE_FIELDS = [\"title\", \"description\", \"labels\", \"link\"] as const;\n\ntype ChangeField<N> = N extends `changes.${infer K}`\n\t? Extract<K, keyof Change>\n\t: never;\n\n/** A change that's known to have the given fields. */\nexport type ChangeWith<K extends keyof Change> = Change & {\n\t[P in K]-?: Exclude<Change[P], undefined>;\n};\n\n/** A step's input, with what its `needs` guarantee. */\nexport type Narrow<R, N extends Fact> = [N] extends [never]\n\t? R\n\t: Omit<\n\t\t\tR,\n\t\t\t| ([ChangeField<N>] extends [never] ? never : \"changes\")\n\t\t\t| (\"previousVersion\" extends N ? \"previousVersion\" : never)\n\t\t> &\n\t\t\t([ChangeField<N>] extends [never]\n\t\t\t\t? unknown\n\t\t\t\t: { changes: ChangeWith<ChangeField<N>>[] }) &\n\t\t\t(\"previousVersion\" extends N ? { previousVersion: string } : unknown);\n\n/** A step's output, with what its `provides` promise. */\nexport type ProvidedOutput<O, P extends Fact> = [ChangeField<P>] extends [never]\n\t? O\n\t: O extends { changes: Change[] }\n\t\t? Omit<O, \"changes\"> & { changes: ChangeWith<ChangeField<P>>[] }\n\t\t: O;\n\nexport function isChangeFact(fact: string): boolean {\n\treturn fact.startsWith(\"changes.\");\n}\n\n/**\n * Throws unless every change has what the facts promise, e.g. `labels` for\n * `changes.labels`. Facts that aren't about changes aren't checked here.\n */\nexport function checkChanges(\n\tchanges: readonly Change[],\n\tfacts: readonly string[],\n): void {\n\tfor (const fact of facts) {\n\t\tconst field = CHANGE_FIELDS.find((name) => fact === `changes.${name}`);\n\t\tif (field === undefined) continue;\n\t\tconst index = changes.findIndex((change) => change[field] === undefined);\n\t\tif (index !== -1) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`invalid output: it provides ${fact}, but change ${index} (${changes[index]?.reason}) has no '${field}'`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Steps that provide each fact, by name, as they're defined; for error messages. */\nconst providers = new Map<string, Set<string>>();\n\nexport function registerProvider(name: string, facts: readonly string[]) {\n\tfor (const fact of facts) {\n\t\tconst names = providers.get(fact) ?? new Set();\n\t\tnames.add(name);\n\t\tproviders.set(fact, names);\n\t}\n}\n\n/** The defined steps that provide a fact, e.g. to suggest one. */\nexport function providersOf(fact: string): string[] {\n\treturn [...(providers.get(fact) ?? [])];\n}\n","import type { ComponentReport, ReleaseReport } from \"./engine.ts\";\nimport type {\n\tComponentInfo,\n\tEnginePhase,\n\tEnvironment,\n\tPhase,\n\tStepRecord,\n} from \"./types.ts\";\n\n/** Receives progress from the engine; every hook is optional. */\nexport interface Reporter {\n\tstart?(\n\t\tenv: Environment,\n\t\t/** Every step, and the engine's own rows: `read-version` and `determine-version`. */\n\t\tsteps: readonly { phase: Phase | EnginePhase; name: string }[],\n\t\tcomponents: readonly ComponentInfo[],\n\t): void;\n\tstep?(record: StepRecord): void;\n\tfinish?(report: ReleaseReport): void;\n}\n\nexport interface PrettyReporterOptions {\n\t/** Defaults to writing to stdout. */\n\twrite?: (text: string) => void;\n\t/** Defaults to `true` on a TTY unless `NO_COLOR` is set. */\n\tcolor?: boolean;\n}\n\nconst ANSI = {\n\tbold: [1, 22],\n\tdim: [2, 22],\n\tred: [31, 39],\n\tgreen: [32, 39],\n\tyellow: [33, 39],\n\tmagenta: [35, 39],\n\tcyan: [36, 39],\n} as const;\n\ntype Style = keyof typeof ANSI;\n\n/** Aligned, colored output: one row per step with phase, name, duration and reason. */\nexport function prettyReporter(options: PrettyReporterOptions = {}): Reporter {\n\tconst write =\n\t\toptions.write ?? ((text: string) => void process.stdout.write(text));\n\tconst color =\n\t\toptions.color ??\n\t\t(process.env.FORCE_COLOR !== undefined ||\n\t\t\t(process.stdout.isTTY === true && process.env.NO_COLOR === undefined));\n\tconst paint = (style: Style, text: string) =>\n\t\tcolor ? `\\x1b[${ANSI[style][0]}m${text}\\x1b[${ANSI[style][1]}m` : text;\n\n\tlet phaseWidth = 0;\n\tlet nameWidth = 0;\n\tlet componentWidth = 0;\n\tlet dryRun = false;\n\n\treturn {\n\t\tstart(env, steps, components) {\n\t\t\tdryRun = env.dryRun;\n\t\t\tphaseWidth = Math.max(0, ...steps.map((step) => step.phase.length));\n\t\t\tnameWidth = Math.max(0, ...steps.map((step) => step.name.length));\n\t\t\tcomponentWidth =\n\t\t\t\tcomponents.length > 1\n\t\t\t\t\t? Math.max(...components.map((component) => component.name.length))\n\t\t\t\t\t: 0;\n\t\t\tconst mode = env.dryRun ? paint(\"yellow\", \"dry run\") : \"release\";\n\t\t\twrite(\n\t\t\t\t`\\n${paint(\"bold\", \"rylease\")} ${mode} ${paint(\"dim\", \"·\")} ${paint(\"cyan\", env.branch)} ${paint(\"dim\", `· ${env.cwd}`)}\\n\\n`,\n\t\t\t);\n\t\t},\n\t\tstep(record) {\n\t\t\tconst icon = {\n\t\t\t\tok: paint(\"green\", \"✔\"),\n\t\t\t\tskipped: paint(\"dim\", \"○\"),\n\t\t\t\tfailed: paint(\"red\", \"✖\"),\n\t\t\t}[record.status];\n\t\t\tconst phase = paint(\"magenta\", record.phase.padEnd(phaseWidth));\n\t\t\tconst name = paint(\"bold\", record.name.padEnd(nameWidth));\n\t\t\tconst component =\n\t\t\t\tcomponentWidth > 0\n\t\t\t\t\t? `${paint(\"cyan\", (record.component ?? \"*\").padEnd(componentWidth))} `\n\t\t\t\t\t: \"\";\n\t\t\tconst duration = paint(\n\t\t\t\t\"dim\",\n\t\t\t\t(record.status === \"skipped\"\n\t\t\t\t\t? \"-\"\n\t\t\t\t\t: formatDuration(record.durationMs)\n\t\t\t\t).padStart(7),\n\t\t\t);\n\t\t\tconst reason =\n\t\t\t\trecord.status === \"ok\"\n\t\t\t\t\t? record.reason\n\t\t\t\t\t: paint(record.status === \"failed\" ? \"red\" : \"dim\", record.reason);\n\t\t\twrite(\n\t\t\t\t` ${icon} ${component}${phase} ${name} ${duration} ${reason}\\n`,\n\t\t\t);\n\t\t},\n\t\tfinish(report) {\n\t\t\tconst line = (component: ComponentReport) => {\n\t\t\t\tconst from = component.previousVersion ?? \"nothing\";\n\t\t\t\tconst action =\n\t\t\t\t\tcomponent.status === \"pending\"\n\t\t\t\t\t\t? paint(\"yellow\", dryRun ? \"would be proposed\" : \"proposed\")\n\t\t\t\t\t\t: dryRun\n\t\t\t\t\t\t\t? paint(\"yellow\", \"would release\")\n\t\t\t\t\t\t\t: \"released\";\n\t\t\t\tif (component.status !== \"released\" && component.status !== \"pending\") {\n\t\t\t\t\treturn `${paint(\"bold\", from)} ${paint(\"dim\", \"·\")} nothing to release`;\n\t\t\t\t}\n\t\t\t\tconst to = paint(\"green\", paint(\"bold\", component.version ?? \"?\"));\n\t\t\t\t// A given release may not say what it was released from.\n\t\t\t\treturn from === component.version\n\t\t\t\t\t? `${to} ${paint(\"dim\", \"·\")} ${action}`\n\t\t\t\t\t: `${paint(\"bold\", from)} → ${to} ${paint(\"dim\", `(${component.kind})`)} ${paint(\"dim\", \"·\")} ${action}`;\n\t\t\t};\n\t\t\tlet summary: string;\n\t\t\tif (report.status === \"failed\") {\n\t\t\t\tsummary = paint(\"red\", \"release failed\");\n\t\t\t} else if (report.components.length === 1 && report.components[0]) {\n\t\t\t\tsummary = line(report.components[0]);\n\t\t\t} else {\n\t\t\t\tconst width = Math.max(\n\t\t\t\t\t...report.components.map((component) => component.name.length),\n\t\t\t\t);\n\t\t\t\tsummary = report.components\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(component) =>\n\t\t\t\t\t\t\t`${paint(\"cyan\", component.name.padEnd(width))} ${line(component)}`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\\n \");\n\t\t\t}\n\t\t\tconst deferred =\n\t\t\t\treport.deferred === undefined\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: `\\n ${paint(\"dim\", report.deferred)}`;\n\t\t\twrite(`\\n ${summary}${deferred}\\n\\n`);\n\t\t},\n\t};\n}\n\nexport function defaultReporter(): Reporter {\n\treturn prettyReporter();\n}\n\nexport function formatDuration(ms: number): string {\n\tif (ms < 1) return \"<1ms\";\n\tif (ms < 1000) return `${Math.round(ms)}ms`;\n\treturn `${(ms / 1000).toFixed(2)}s`;\n}\n","import type { RunChannel } from \"./channels.ts\";\nimport type { ChangeWith, Fact, Narrow, ProvidedOutput } from \"./facts.ts\";\nimport type { History } from \"./history.ts\";\nimport type { Scheme } from \"./scheme.ts\";\n\n/** Every phase, in the order the engine runs its steps. */\nexport const PHASES = [\n\t\"read-changes\",\n\t\"determine-kind\",\n\t\"determine-notes\",\n\t\"write\",\n\t\"stage\",\n\t\"release\",\n] as const;\n\nexport type Phase = (typeof PHASES)[number];\n\n/**\n * How much a release changes, whatever the version scheme: the scheme decides\n * what each kind bumps, e.g. semver's `MAJOR.minor.patch`.\n */\nexport const KINDS = [\"breaking\", \"feature\", \"fix\", \"none\"] as const;\n\nexport type Kind = (typeof KINDS)[number];\n\n/** A kind that actually produces a release; `none` releases nothing. */\nexport type ReleaseKind = Exclude<Kind, \"none\">;\n\n/** A single, source-agnostic change (a commit section, an issue, a PR, ...). */\nexport interface Change {\n\ttitle?: string;\n\tdescription?: string;\n\t/** Where this change came from, e.g. `commit aefc3af`. */\n\treason: string;\n\t/** Where to read more, e.g. `{ label: \"aefc3af\", url: \".../commit/aefc3af...\" }`. */\n\tlink?: { label: string; url: string };\n\t/**\n\t * How the source categorized it, e.g. a pull request's labels, or the\n\t * `### Fixed` section of a changelog.\n\t */\n\tlabels?: string[];\n}\n\n/**\n * A versioned unit, as steps see it: one package, a Go module, a Docker\n * image, or several packages released together under one version.\n */\nexport interface ComponentInfo {\n\tname: string;\n\t/** Its directory, relative to `env.cwd`; `.` for the whole project. */\n\tpath: string;\n\t/** Components it depends on, by name; they're released first. */\n\tdependsOn: readonly string[];\n\t/**\n\t * Pathspecs for git: its directory, without the directories of components\n\t * inside it. Empty when every path counts.\n\t */\n\tpathspec: readonly string[];\n}\n\nexport interface ChangesOutput {\n\tchanges: Change[];\n\t/** e.g. `6 changes in 4 commits since 1a2b3c4`. */\n\treason: string;\n}\n\nexport interface KindOutput {\n\tkind: Kind;\n\t/**\n\t * Releases exactly this version instead of bumping by the kind, e.g. from\n\t * a `Release-As:` footer. It must be valid in the scheme, and later than\n\t * the previous version.\n\t */\n\tversion?: string;\n\t/** e.g. `'feat!' in title (commit aefc3af)`. */\n\treason: string;\n}\n\nexport interface NotesOutput {\n\tnotes: string;\n\t/** e.g. `feature release, 3 features, 1 fix`. */\n\treason: string;\n}\n\nexport interface ReleaseOutput {\n\toutput: unknown;\n\t/** Files the step changed (or would change in a dry run), relative to `cwd`. */\n\tfiles?: string[];\n\t/** e.g. `wrote 1.3.0 to package.json`. */\n\treason: string;\n}\n\n/** What `write` and `stage` steps return. */\nexport interface WriteOutput extends ReleaseOutput {\n\t/**\n\t * Leaves the release to later, e.g. once a release pull request merges:\n\t * every `release` step is skipped with this reason, and the run is\n\t * `pending`.\n\t */\n\tdefer?: string;\n}\n\n/** What the steps of each phase must return. */\nexport interface StepOutputs {\n\t\"read-changes\": ChangesOutput;\n\t\"determine-kind\": KindOutput;\n\t\"determine-notes\": NotesOutput;\n\twrite: WriteOutput;\n\tstage: WriteOutput;\n\trelease: ReleaseOutput;\n}\n\n/** The output of a prior `write`, `stage` or `release` step, as later ones see it. */\nexport interface ReleaseResult {\n\tname: string;\n\toutput: unknown;\n\tfiles: readonly string[];\n}\n\n/** Where a component's release starts from; found before any step runs. */\nexport interface Previous {\n\tcomponent: ComponentInfo;\n\t/** Absent on a first release, or when the scheme changed since the last one. */\n\tpreviousVersion?: string;\n\t/** The commit of the previous release; changes are collected since it. */\n\tpreviousRef?: string;\n\t/** The tag of the previous release, when it was found by its tag. */\n\tpreviousTag?: string;\n}\n\n/** The release being made, from `determine-notes` on. */\nexport interface Next {\n\tkind: ReleaseKind;\n\tversion: string;\n\t/** The release's tag, e.g. `v1.2.0`. */\n\ttag: string;\n\t/**\n\t * Values for `{placeholders}` in templates: `version`, `tag`, `name`, and\n\t * the scheme's own, e.g. semver's `major`, `minor` and `patch`.\n\t */\n\tplaceholders: Readonly<Record<string, string>>;\n\t/** The components it depends on that are released along with it. */\n\tdependencies: readonly Dependency[];\n}\n\n/** A dependency released along with a component. */\nexport interface Dependency {\n\tname: string;\n\tversion: string;\n\tpreviousVersion?: string;\n\tkind: ReleaseKind;\n}\n\n/**\n * What a step receives for one component, by phase. Values from earlier phases\n * are always present; the value of a step's own phase is only present when\n * an earlier step of the same phase already ran.\n */\nexport interface StepResults {\n\t\"read-changes\": Previous & { changes?: Change[] };\n\t\"determine-kind\": Previous & { changes: Change[]; kind?: Kind };\n\t\"determine-notes\": Previous & Next & { changes: Change[]; notes?: string };\n\twrite: Previous &\n\t\tNext & {\n\t\t\tchanges: Change[];\n\t\t\tnotes: string;\n\t\t\treleases: readonly ReleaseResult[];\n\t\t};\n\tstage: StepResults[\"write\"];\n\trelease: StepResults[\"write\"];\n}\n\nexport interface Environment {\n\t/** Root directory of the project being released. */\n\tcwd: string;\n\t/** Current branch name. */\n\tbranch: string;\n\t/** When set, steps must not cause side effects. */\n\tdryRun: boolean;\n\t/** The channel being released on; absent for a stable release. */\n\tchannel?: RunChannel;\n}\n\n/**\n * How a step runs: once per component (`each`, the default), or once with\n * every component (`all`), e.g. to commit or push their releases together.\n */\nexport type Scope = \"each\" | \"all\";\n\nexport type StepStatus = \"ok\" | \"skipped\" | \"failed\";\n\n/** What the engine itself records: the previous version, and the next. */\nexport type EnginePhase = \"read-version\" | \"determine-version\";\n\n/** The audit record of a single step, or of the engine's own work. */\nexport interface StepRecord {\n\tphase: Phase | EnginePhase;\n\tname: string;\n\t/** The component it ran for; absent for `all` steps. */\n\tcomponent?: string;\n\tstatus: StepStatus;\n\tdurationMs: number;\n\treason: string;\n\toutput?: unknown;\n\terror?: unknown;\n}\n\ninterface Shared<Ctx> {\n\tenv: Environment;\n\t/** User-defined state shared by every step. Never used by bundled steps. */\n\tcontext: Ctx;\n\t/** Records of every step that ran before this one. */\n\thistory: readonly StepRecord[];\n}\n\n/** What a step receives, for one component. */\nexport type StepInput<\n\tT extends Phase,\n\tCtx = unknown,\n\tN extends Fact = never,\n> = Narrow<StepResults[T], N> & Shared<Ctx>;\n\n/** What an `all` step receives: every component that's still releasing. */\nexport type AllStepInput<\n\tT extends Phase,\n\tCtx = unknown,\n\tN extends Fact = never,\n> = { components: readonly Narrow<StepResults[T], N>[] } & Shared<Ctx>;\n\n/** What a step returns, for one component. */\nexport type StepOutput<\n\tT extends Phase,\n\tP extends Fact = never,\n> = ProvidedOutput<StepOutputs[T], P>;\n\n/**\n * What an `all` step returns: in `write`, `stage` and `release`, one result for all of them;\n * otherwise a result per component, by name, leaving out those it doesn't\n * change.\n */\nexport type AllStepOutput<\n\tT extends Phase,\n\tP extends Fact = never,\n> = T extends \"release\"\n\t? ReleaseOutput\n\t: T extends \"write\" | \"stage\"\n\t\t? WriteOutput\n\t\t: {\n\t\t\t\tresults: Partial<Record<string, StepOutput<T, P>>>;\n\t\t\t\treason: string;\n\t\t\t};\n\n/**\n * Whether a step runs, decided just before it would, from what it would\n * receive. `source` describes it in reports, e.g. the expression it came from.\n */\nexport interface StepCondition<I> {\n\t(input: I): boolean;\n\treadonly source?: string;\n}\n\ninterface StepBase<T extends Phase> {\n\tphase: T;\n\tname: string;\n\t/** Facts the step relies on, e.g. `changes.labels`; checked before anything runs. */\n\tneeds?: readonly Fact[];\n\t/** Facts the step guarantees, e.g. that every change has `labels`; checked on its output. */\n\tprovides?: readonly Fact[];\n\t/** The preset that made the step, with the scheme and history it provides. */\n\tpreset?: StepPreset;\n}\n\n/** A preset, as the steps it makes carry it. */\nexport interface StepPreset {\n\tname: string;\n\tscheme?: Scheme;\n\thistory?: History | readonly History[];\n}\n\nexport interface EachStepDefinition<T extends Phase, Ctx = unknown>\n\textends StepBase<T> {\n\tscope?: \"each\";\n\t/** When set, the step only runs if this returns true; otherwise it's skipped. */\n\tif?: StepCondition<StepInput<T, Ctx>>;\n\trun: (input: StepInput<T, Ctx>) => StepOutputs[T] | Promise<StepOutputs[T]>;\n}\n\nexport interface AllStepDefinition<T extends Phase, Ctx = unknown>\n\textends StepBase<T> {\n\tscope: \"all\";\n\t/** When set, the step only runs if this returns true; otherwise it's skipped. */\n\tif?: StepCondition<AllStepInput<T, Ctx>>;\n\trun: (\n\t\tinput: AllStepInput<T, Ctx>,\n\t) => AllStepOutput<T> | Promise<AllStepOutput<T>>;\n}\n\nexport type StepDefinition<T extends Phase, Ctx = unknown> =\n\t| EachStepDefinition<T, Ctx>\n\t| AllStepDefinition<T, Ctx>;\n\n/** Any step, discriminated by `phase` and `scope`. */\nexport type Step<Ctx = unknown> = {\n\t[T in Phase]: StepDefinition<T, Ctx>;\n}[Phase];\n\nexport type { ChangeWith, Fact };\n","import { performance } from \"node:perf_hooks\";\nimport { tryGit } from \"../utils/git.ts\";\nimport { fill, versionValues } from \"../utils/template.ts\";\nimport { firstDifference, parseVersion } from \"../utils/version.ts\";\nimport {\n\ttype Channel,\n\ttype Classified,\n\tchannelVersion,\n\tcheckChannels,\n\tclassify,\n\tcompareClassified,\n\ttype ResolvedChannel,\n\tresolveChannels,\n\tselectChannel,\n} from \"./channels.ts\";\nimport {\n\ttype Component,\n\ttype ComponentSource,\n\ttype ResolvedComponent,\n\tresolveComponents,\n} from \"./components.ts\";\nimport { checkChanges, isChangeFact, providersOf } from \"./facts.ts\";\nimport type { Found, History, HistoryInput } from \"./history.ts\";\nimport { defaultReporter, type Reporter } from \"./reporter.ts\";\nimport type { Scheme } from \"./scheme.ts\";\nimport {\n\ttype Change,\n\ttype Dependency,\n\ttype Environment,\n\tKINDS,\n\ttype Kind,\n\tPHASES,\n\ttype Phase,\n\ttype ReleaseKind,\n\ttype ReleaseResult,\n\ttype Step,\n\ttype StepRecord,\n} from \"./types.ts\";\n\nexport interface RunOptions {\n\t/** Defaults to `process.cwd()`. */\n\tcwd?: string;\n\t/** Defaults to the CI's branch (GitHub Actions or GitLab CI), or the checked-out one. */\n\tbranch?: string;\n\t/** Defaults to `false`. */\n\tdryRun?: boolean;\n\t/** Defaults to pretty output on stdout; pass `null` for silence. */\n\treporter?: Reporter | null;\n\t/**\n\t * Releases that have already been worked out, e.g. by an earlier job: only\n\t * the `release` steps run, for these versions, and every other step is\n\t * skipped. With several components, each names its own.\n\t */\n\trelease?: GivenRelease | readonly GivenRelease[];\n\t/**\n\t * The channel to release on, e.g. `nightly`. Defaults to the first whose\n\t * branches match, or a stable release.\n\t */\n\tchannel?: string;\n}\n\nexport interface GivenRelease {\n\tversion: string;\n\t/** Defaults to none. */\n\tnotes?: string;\n\t/** Defaults to the version itself. */\n\tpreviousVersion?: string;\n\t/** Defaults to the difference between the versions, or `fix`. */\n\tkind?: ReleaseKind;\n\t/** The component it's for; needed when there are several. */\n\tcomponent?: string;\n}\n\n/** How a release is made: its steps, and how versions are found and made. */\nexport interface ReleaseSetup<Ctx> {\n\tsteps: readonly Step<Ctx>[];\n\tcontext: Ctx;\n\tscheme: Scheme;\n\t/** Defaults to `v{version}` for one component, `{name}@{version}` for several. */\n\ttag?: string | undefined;\n\t/** Where previous releases are found; the first that finds one wins. */\n\thistory: History | readonly History[];\n\t/** Defaults to one component, the whole project. */\n\tcomponents?: readonly Component[] | ComponentSource | undefined;\n\t/** Prerelease and build channels, by name. Defaults to none. */\n\tchannels?: Readonly<Record<string, Channel>> | undefined;\n}\n\n/**\n * `pending` when a `write` step left the release to later, e.g. to a\n * release pull request.\n */\nexport type ReleaseStatus = \"released\" | \"pending\" | \"unchanged\" | \"failed\";\n\nexport interface ComponentReport {\n\tname: string;\n\tpath: string;\n\tstatus: ReleaseStatus;\n\tpreviousVersion?: string;\n\tpreviousRef?: string;\n\tpreviousTag?: string;\n\tkind?: Kind;\n\tversion?: string;\n\ttag?: string;\n\tnotes?: string;\n\t/** The components it depends on that were released along with it. */\n\tdependencies: Dependency[];\n\treleases: ReleaseResult[];\n}\n\nexport interface ReleaseReport {\n\tenv: Environment;\n\tstatus: ReleaseStatus;\n\trecords: StepRecord[];\n\t/** Every component, dependencies first. */\n\tcomponents: ComponentReport[];\n\t/** With one component, its values, for convenience. */\n\tpreviousVersion?: string;\n\tpreviousRef?: string;\n\tkind?: Kind;\n\tversion?: string;\n\tnotes?: string;\n\t/** With one component, the results of its `write`, `stage` and `release` steps. */\n\treleases: ReleaseResult[];\n\t/** Why the release was left to later, when it's `pending`. */\n\tdeferred?: string;\n\terror?: unknown;\n}\n\nexport class ReleaseError extends Error {\n\treadonly report: ReleaseReport;\n\n\tconstructor(message: string, report: ReleaseReport, options?: ErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.name = \"ReleaseError\";\n\t\tthis.report = report;\n\t}\n}\n\nfunction phaseIndex(phase: Phase): number {\n\treturn PHASES.indexOf(phase);\n}\n\nconst KIND_PHASE = phaseIndex(\"determine-kind\");\n\n/** Phases that must have at least one step for a release to be possible. */\nconst REQUIRED_PHASES = PHASES.filter(\n\t(phase) => phase !== \"write\" && phase !== \"stage\" && phase !== \"release\",\n);\n\n/** What each phase produces, where later phases read it. */\nconst PHASE_VALUES = {\n\t\"read-changes\": \"changes\",\n\t\"determine-kind\": \"kind\",\n\t\"determine-notes\": \"notes\",\n\twrite: \"releases\",\n\tstage: \"releases\",\n\trelease: \"releases\",\n} as const satisfies Record<Phase, keyof State>;\n\nconst CHANGE_FACTS = [\n\t\"changes.title\",\n\t\"changes.description\",\n\t\"changes.labels\",\n\t\"changes.link\",\n];\n\ninterface State {\n\tcomponent: ResolvedComponent;\n\tpreviousVersion: string | undefined;\n\tpreviousRef: string | undefined;\n\tpreviousTag: string | undefined;\n\tchanges: Change[] | undefined;\n\tkind: Kind | undefined;\n\t/** A version a `determine-kind` step asked for. */\n\texact: string | undefined;\n\tversion: string | undefined;\n\ttag: string | undefined;\n\tplaceholders: Record<string, string> | undefined;\n\tnotes: string | undefined;\n\tdependencies: Dependency[];\n\treleases: ReleaseResult[];\n\t/** What's known to hold, e.g. `changes.labels`. */\n\tfacts: Set<string>;\n\t/** Whether it's still being released: false once its kind is `none`. */\n\tlive: boolean;\n\t/** The previous stable version, which new versions are bumped from. */\n\tstable: string | undefined;\n\t/** The channel it's released on, with its format for the scheme. */\n\tchannel: ResolvedChannel | undefined;\n\tchannels: ResolvedChannel[];\n\t/** Why only its `release` steps run, when its version was given. */\n\tgiven: string | undefined;\n}\n\n/** Stable sort of steps by phase; steps of the same phase keep their order. */\nexport function sortSteps<S extends { phase: Phase }>(\n\tsteps: readonly S[],\n): S[] {\n\treturn [...steps].sort((a, b) => phaseIndex(a.phase) - phaseIndex(b.phase));\n}\n\n/** Steps as the engine handles them, whatever their phase and scope. */\ntype AnyStep = {\n\tphase: Phase;\n\tname: string;\n\tscope?: \"each\" | \"all\";\n\tneeds?: readonly string[];\n\tprovides?: readonly string[];\n\tif?: ((input: unknown) => boolean) & { source?: string };\n\trun: (input: unknown) => unknown;\n};\n\nexport async function runRelease<Ctx>(\n\tsetup: ReleaseSetup<Ctx>,\n\toptions: RunOptions = {},\n): Promise<ReleaseReport> {\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst env: Environment = {\n\t\tcwd,\n\t\tbranch: options.branch ?? (await detectBranch(cwd)),\n\t\tdryRun: options.dryRun ?? false,\n\t};\n\tconst reporter =\n\t\toptions.reporter === undefined ? defaultReporter() : options.reporter;\n\tconst given = options.release === undefined ? [] : [options.release].flat();\n\tconst ordered = sortSteps(setup.steps as unknown as readonly AnyStep[]);\n\tconst records: StepRecord[] = [];\n\tlet states: State[] = [];\n\tlet deferred: string | undefined;\n\n\tconst report = (status: ReleaseStatus, error?: unknown): ReleaseReport => {\n\t\tconst components = states.map(\n\t\t\t(state): ComponentReport => ({\n\t\t\t\tname: state.component.info.name,\n\t\t\t\tpath: state.component.info.path,\n\t\t\t\tstatus:\n\t\t\t\t\tstate.kind === \"none\" || !state.live\n\t\t\t\t\t\t? \"unchanged\"\n\t\t\t\t\t\t: status === \"failed\"\n\t\t\t\t\t\t\t? \"failed\"\n\t\t\t\t\t\t\t: status,\n\t\t\t\tdependencies: state.dependencies,\n\t\t\t\treleases: state.releases,\n\t\t\t\t...definedOnly({\n\t\t\t\t\tpreviousVersion: state.previousVersion,\n\t\t\t\t\tpreviousRef: state.previousRef,\n\t\t\t\t\tpreviousTag: state.previousTag,\n\t\t\t\t\tkind: state.kind,\n\t\t\t\t\tversion: state.version,\n\t\t\t\t\ttag: state.tag,\n\t\t\t\t\tnotes: state.notes,\n\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\t\tconst only = states.length === 1 ? states[0] : undefined;\n\t\treturn {\n\t\t\tenv,\n\t\t\tstatus,\n\t\t\trecords,\n\t\t\tcomponents,\n\t\t\treleases: only?.releases ?? [],\n\t\t\t...definedOnly({\n\t\t\t\tpreviousVersion: only?.previousVersion,\n\t\t\t\tpreviousRef: only?.previousRef,\n\t\t\t\tkind: only?.kind,\n\t\t\t\tversion: only?.version,\n\t\t\t\tnotes: only?.notes,\n\t\t\t\tdeferred,\n\t\t\t\terror,\n\t\t\t}),\n\t\t};\n\t};\n\tconst record = (entry: StepRecord) => {\n\t\trecords.push(entry);\n\t\treporter?.step?.(entry);\n\t};\n\tconst fail = (error: unknown, message = errorMessage(error)): never => {\n\t\tconst result = report(\"failed\", error);\n\t\treporter?.finish?.(result);\n\t\tthrow new ReleaseError(message, result, { cause: error });\n\t};\n\n\tlet resolved: ResolvedComponent[];\n\ttry {\n\t\tconst channels = setup.channels ?? {};\n\t\tcheckChannels(channels);\n\t\tconst channel = selectChannel(channels, env.branch, options.channel);\n\t\tif (channel) env.channel = channel;\n\t\tresolved = await resolveSetup(setup, env);\n\t} catch (error) {\n\t\treporter?.start?.(env, ordered, []);\n\t\treturn fail(error);\n\t}\n\treporter?.start?.(\n\t\tenv,\n\t\t[\n\t\t\t...resolved.flatMap((component) => [\n\t\t\t\t...historiesOf(component).map(({ name }) => ({\n\t\t\t\t\tphase: \"read-version\" as const,\n\t\t\t\t\tname,\n\t\t\t\t})),\n\t\t\t\t{ phase: \"determine-version\" as const, name: component.scheme.name },\n\t\t\t]),\n\t\t\t...ordered,\n\t\t],\n\t\tresolved.map(({ info }) => info),\n\t);\n\tstates = resolved.map((component) =>\n\t\tnewState(component, setup.channels ?? {}, env),\n\t);\n\n\tconst missing =\n\t\tgiven.length > 0\n\t\t\t? []\n\t\t\t: REQUIRED_PHASES.filter(\n\t\t\t\t\t(phase) => !ordered.some((step) => step.phase === phase),\n\t\t\t\t);\n\tif (missing.length > 0) {\n\t\tfail(new Error(`no step provided for: ${missing.join(\", \")}`));\n\t}\n\n\tif (given.length > 0) {\n\t\tfor (const state of states) state.live = false;\n\t\tfor (const release of given) {\n\t\t\tconst target = givenTarget(states, release.component);\n\t\t\tif (typeof target === \"string\") fail(new Error(target));\n\t\t\tconst state = target as State;\n\t\t\tsetGiven(state, release, `releasing the given ${release.version}`);\n\t\t\tif (release.previousVersion !== undefined) {\n\t\t\t\tstate.facts.add(\"previousVersion\");\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (const state of states) {\n\t\t\tconst start = performance.now();\n\t\t\tconst { scheme } = state.component;\n\t\t\ttry {\n\t\t\t\tconst found = await findPrevious(state, env);\n\t\t\t\tconst previous = found.found;\n\t\t\t\tconst kind =\n\t\t\t\t\tprevious?.version === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: classify(previous.version, scheme, state.channels);\n\t\t\t\tconst foreign = kind?.type === \"foreign\";\n\t\t\t\tObject.assign(state, {\n\t\t\t\t\tpreviousVersion: foreign ? undefined : previous?.version,\n\t\t\t\t\tpreviousRef: previous?.ref,\n\t\t\t\t\tpreviousTag: previous?.tag,\n\t\t\t\t\tstable:\n\t\t\t\t\t\tprevious?.stable?.version ??\n\t\t\t\t\t\t(kind?.type === \"stable\" ? previous?.version : undefined),\n\t\t\t\t});\n\t\t\t\tif (state.previousVersion !== undefined) {\n\t\t\t\t\tstate.facts.add(\"previousVersion\");\n\t\t\t\t}\n\t\t\t\trecord({\n\t\t\t\t\tphase: \"read-version\",\n\t\t\t\t\tname: found.name,\n\t\t\t\t\tcomponent: state.component.info.name,\n\t\t\t\t\tstatus: \"ok\",\n\t\t\t\t\tdurationMs: performance.now() - start,\n\t\t\t\t\treason: previous\n\t\t\t\t\t\t? `${previous.reason}${foreign ? `; ${previous.version} isn't ${scheme.name}, so this release is its first` : \"\"}`\n\t\t\t\t\t\t: \"no previous release; every change counts\",\n\t\t\t\t\toutput: previous ?? null,\n\t\t\t\t});\n\t\t\t\tif (previous?.pending) {\n\t\t\t\t\tconst pending = previous.pending;\n\t\t\t\t\tsetGiven(\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tversion: pending.version,\n\t\t\t\t\t\t\t...definedOnly({\n\t\t\t\t\t\t\t\tnotes: pending.notes,\n\t\t\t\t\t\t\t\tkind: pending.kind,\n\t\t\t\t\t\t\t\tpreviousVersion: pending.previousVersion,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t`releasing ${pending.version}, ${pending.reason}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\trecord({\n\t\t\t\t\tphase: \"read-version\",\n\t\t\t\t\tname: historiesOf(state.component)\n\t\t\t\t\t\t.map(({ name }) => name)\n\t\t\t\t\t\t.join(\", \"),\n\t\t\t\t\tcomponent: state.component.info.name,\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\tdurationMs: performance.now() - start,\n\t\t\t\t\treason: errorMessage(error),\n\t\t\t\t\terror,\n\t\t\t\t});\n\t\t\t\tfail(error);\n\t\t\t}\n\t\t}\n\t\t// A prepared release is released on its own; the rest come later.\n\t\tif (states.some((state) => state.given !== undefined)) {\n\t\t\tfor (const state of states.filter((state) => state.given === undefined)) {\n\t\t\t\tstate.live = false;\n\t\t\t}\n\t\t}\n\t}\n\tconst publishing = states.find((state) => state.given !== undefined)?.given;\n\n\tconst problems = preflight(ordered, states, publishing !== undefined);\n\tif (problems.length > 0) fail(new Error(problems.join(\"\\n\")));\n\n\tlet bumped = publishing !== undefined;\n\tif (bumped) setDependencies(states);\n\tconst skipRest = (from: number, reason: string) => {\n\t\tfor (const step of ordered.slice(from)) {\n\t\t\trecord({\n\t\t\t\tphase: step.phase,\n\t\t\t\tname: step.name,\n\t\t\t\tstatus: \"skipped\",\n\t\t\t\tdurationMs: 0,\n\t\t\t\treason,\n\t\t\t});\n\t\t}\n\t};\n\tconst finish = (status: ReleaseStatus) => {\n\t\tconst result = report(status);\n\t\treporter?.finish?.(result);\n\t\treturn result;\n\t};\n\n\tfor (const [index, step] of ordered.entries()) {\n\t\tif (publishing !== undefined && step.phase !== \"release\") {\n\t\t\trecord({\n\t\t\t\tphase: step.phase,\n\t\t\t\tname: step.name,\n\t\t\t\tstatus: \"skipped\",\n\t\t\t\tdurationMs: 0,\n\t\t\t\treason: publishing,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (!bumped && phaseIndex(step.phase) > KIND_PHASE) {\n\t\t\tbumped = true;\n\t\t\tawait bump(states, env, record, fail);\n\t\t\tsetDependencies(states);\n\t\t}\n\t\tconst live = states.filter((state) => state.live);\n\t\tif (live.length === 0) {\n\t\t\tskipRest(index, \"no release-worthy changes\");\n\t\t\treturn finish(\"unchanged\");\n\t\t}\n\t\tif (deferred !== undefined && step.phase === \"release\") {\n\t\t\tskipRest(index, deferred);\n\t\t\treturn finish(\"pending\");\n\t\t}\n\n\t\tconst targets: (State | undefined)[] =\n\t\t\tstep.scope === \"all\" ? [undefined] : live;\n\t\tfor (const target of targets) {\n\t\t\tconst start = performance.now();\n\t\t\tconst group = target ? [target] : live;\n\t\t\tconst component = target?.component.info.name;\n\t\t\ttry {\n\t\t\t\t// Conditions may have skipped every step of an earlier phase.\n\t\t\t\tfor (const state of group) assertEarlierPhases(state, step.phase);\n\t\t\t\tconst input = target\n\t\t\t\t\t? { ...values(target), ...shared(env, setup.context, records) }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tcomponents: live.map(values),\n\t\t\t\t\t\t\t...shared(env, setup.context, records),\n\t\t\t\t\t\t};\n\t\t\t\tconst condition = step.if;\n\t\t\t\tif (condition && !condition(input)) {\n\t\t\t\t\tconst source = condition.source;\n\t\t\t\t\trecord({\n\t\t\t\t\t\tphase: step.phase,\n\t\t\t\t\t\tname: step.name,\n\t\t\t\t\t\t...(component !== undefined && { component }),\n\t\t\t\t\t\tstatus: \"skipped\",\n\t\t\t\t\t\tdurationMs: performance.now() - start,\n\t\t\t\t\t\treason: source\n\t\t\t\t\t\t\t? `\\`${source}\\` is false`\n\t\t\t\t\t\t\t: \"its condition is false\",\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (const state of group) assertNeeds(step, state);\n\t\t\t\tconst output = await step.run(input);\n\t\t\t\tconst applied = apply(step, group, target === undefined, output);\n\t\t\t\tdeferred ??= applied.defer;\n\t\t\t\trecord({\n\t\t\t\t\tphase: step.phase,\n\t\t\t\t\tname: step.name,\n\t\t\t\t\t...(component !== undefined && { component }),\n\t\t\t\t\tstatus: \"ok\",\n\t\t\t\t\tdurationMs: performance.now() - start,\n\t\t\t\t\treason: applied.reason,\n\t\t\t\t\toutput,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconst message = errorMessage(error);\n\t\t\t\trecord({\n\t\t\t\t\tphase: step.phase,\n\t\t\t\t\tname: step.name,\n\t\t\t\t\t...(component !== undefined && { component }),\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\tdurationMs: performance.now() - start,\n\t\t\t\t\treason: message,\n\t\t\t\t\terror,\n\t\t\t\t});\n\t\t\t\tskipRest(index + 1, `'${step.phase}' step '${step.name}' failed`);\n\t\t\t\tfail(\n\t\t\t\t\terror,\n\t\t\t\t\t`${step.phase} step '${step.name}'${component !== undefined && states.length > 1 ? ` (${component})` : \"\"} failed: ${message}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tif (!bumped) {\n\t\tawait bump(states, env, record, fail);\n\t\tsetDependencies(states);\n\t}\n\n\tif (!states.some((state) => state.live)) return finish(\"unchanged\");\n\treturn finish(deferred !== undefined ? \"pending\" : \"released\");\n}\n\nasync function resolveSetup<Ctx>(\n\tsetup: ReleaseSetup<Ctx>,\n\tenv: Environment,\n): Promise<ResolvedComponent[]> {\n\tconst source = setup.components;\n\tconst components =\n\t\tsource === undefined\n\t\t\t? [{ name: \"root\" }]\n\t\t\t: \"resolve\" in source\n\t\t\t\t? await source.resolve(env)\n\t\t\t\t: source;\n\tconst { history } = setup;\n\treturn resolveComponents(components, {\n\t\tscheme: setup.scheme,\n\t\thistory: Array.isArray(history) ? chain(history) : (history as History),\n\t\ttag: setup.tag,\n\t});\n}\n\n/** Histories tried in turn; the first that finds a release wins. */\nfunction chain(histories: readonly History[]): History {\n\tconst [only] = histories;\n\tif (histories.length === 1 && only) return only;\n\treturn Object.assign(\n\t\t{\n\t\t\tname: histories.map(({ name }) => name).join(\", \"),\n\t\t\tfind: async () => undefined,\n\t\t},\n\t\t{ chain: histories },\n\t);\n}\n\nfunction historiesOf(component: ResolvedComponent): readonly History[] {\n\tconst history = component.history as History & {\n\t\tchain?: readonly History[];\n\t};\n\treturn history.chain ?? [history];\n}\n\n/** What a history is asked, for a component. */\nfunction historyInput(state: State, env: Environment): HistoryInput {\n\treturn {\n\t\tenv,\n\t\tcomponent: state.component.info,\n\t\tscheme: state.component.scheme,\n\t\ttag: state.component.tag,\n\t\tchannel: state.channel,\n\t\tchannels: state.channels,\n\t};\n}\n\nasync function findPrevious(\n\tstate: State,\n\tenv: Environment,\n): Promise<{ name: string; found: Found | undefined }> {\n\tconst histories = historiesOf(state.component);\n\tfor (const history of histories) {\n\t\tconst found = await history.find(historyInput(state, env));\n\t\tif (found) return { name: history.name, found };\n\t}\n\treturn {\n\t\tname: histories.map(({ name }) => name).join(\", \"),\n\t\tfound: undefined,\n\t};\n}\n\nfunction newState(\n\tcomponent: ResolvedComponent,\n\tchannels: Readonly<Record<string, Channel>>,\n\tenv: Environment,\n): State {\n\tconst resolved = resolveChannels(channels, component.scheme);\n\treturn {\n\t\tcomponent,\n\t\tpreviousVersion: undefined,\n\t\tpreviousRef: undefined,\n\t\tpreviousTag: undefined,\n\t\tchanges: undefined,\n\t\tkind: undefined,\n\t\texact: undefined,\n\t\tversion: undefined,\n\t\ttag: undefined,\n\t\tplaceholders: undefined,\n\t\tnotes: undefined,\n\t\tdependencies: [],\n\t\treleases: [],\n\t\tfacts: new Set(component.scheme.traits ?? []),\n\t\tlive: true,\n\t\tstable: undefined,\n\t\tchannel: resolved.find(({ name }) => name === env.channel?.name),\n\t\tchannels: resolved,\n\t\tgiven: undefined,\n\t};\n}\n\n/** Makes a component release a version worked out before, e.g. by a job. */\nfunction setGiven(state: State, release: GivenRelease, reason: string) {\n\tconst previousVersion = release.previousVersion ?? release.version;\n\tstate.live = true;\n\tstate.given = reason;\n\tstate.previousVersion = previousVersion;\n\tstate.changes = [];\n\tstate.kind = release.kind ?? difference(previousVersion, release.version);\n\tstate.notes = release.notes ?? \"\";\n\tconst kind = classify(\n\t\trelease.version,\n\t\tstate.component.scheme,\n\t\tstate.channels,\n\t);\n\tsetVersion(\n\t\tstate,\n\t\trelease.version,\n\t\tkind.type === \"foreign\" ? release.version : kind.target,\n\t);\n\tfor (const fact of CHANGE_FACTS) state.facts.add(fact);\n}\n\n/** Each live component's dependencies released along with it. */\nfunction setDependencies(states: readonly State[]) {\n\tfor (const state of states.filter((state) => state.live)) {\n\t\tstate.dependencies = state.component.info.dependsOn.flatMap((name) => {\n\t\t\tconst other = states.find((s) => s.component.info.name === name);\n\t\t\treturn other?.live &&\n\t\t\t\tother.version !== undefined &&\n\t\t\t\tother.kind &&\n\t\t\t\tother.kind !== \"none\"\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tversion: other.version,\n\t\t\t\t\t\t\t...definedOnly({ previousVersion: other.previousVersion }),\n\t\t\t\t\t\t\tkind: other.kind,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: [];\n\t\t});\n\t}\n}\n\nfunction givenTarget(\n\tstates: State[],\n\tname: string | undefined,\n): State | string {\n\tif (name === undefined) {\n\t\tconst [only] = states;\n\t\treturn states.length === 1 && only\n\t\t\t? only\n\t\t\t: `there are several components (${names(states)}); say which the given release is for`;\n\t}\n\treturn (\n\t\tstates.find((state) => state.component.info.name === name) ??\n\t\t`'${name}' isn't a component; use ${names(states)}`\n\t);\n}\n\nfunction names(states: readonly State[]): string {\n\treturn states.map((state) => state.component.info.name).join(\", \");\n}\n\n/**\n * Sets the version, and what follows from it: the tag and placeholders. On a\n * channel, the scheme's placeholders are its target's.\n */\nfunction setVersion(state: State, version: string, target = version) {\n\tconst { component } = state;\n\tconst tag = fill(component.tag, { version });\n\tstate.version = version;\n\tstate.tag = tag;\n\tstate.placeholders = {\n\t\t...versionValues(target),\n\t\t...(component.scheme.matches(target)\n\t\t\t? component.scheme.fields?.(target)\n\t\t\t: {}),\n\t\tversion,\n\t\ttag,\n\t\tname: component.info.name,\n\t\t...(state.channel && { channel: state.channel.name }),\n\t};\n}\n\n/**\n * After the last `determine-kind` step: components with nothing to release\n * drop out, and the others get their next version from their scheme, on\n * their channel if there is one.\n */\nasync function bump(\n\tstates: State[],\n\tenv: Environment,\n\trecord: (entry: StepRecord) => void,\n\tfail: (error: unknown) => never,\n) {\n\tfor (const state of states.filter((state) => state.live)) {\n\t\tconst start = performance.now();\n\t\tconst { scheme, info } = state.component;\n\t\tconst base = {\n\t\t\tphase: \"determine-version\",\n\t\t\tname: scheme.name,\n\t\t\tcomponent: info.name,\n\t\t} as const;\n\t\tif (state.kind === undefined) {\n\t\t\tconst error = new Error(\n\t\t\t\t\"no 'determine-kind' step ran, so it has no kind\",\n\t\t\t);\n\t\t\trecord({\n\t\t\t\t...base,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tdurationMs: 0,\n\t\t\t\treason: error.message,\n\t\t\t\terror,\n\t\t\t});\n\t\t\tfail(error);\n\t\t}\n\t\tif (state.kind === \"none\") {\n\t\t\tstate.live = false;\n\t\t\trecord({\n\t\t\t\t...base,\n\t\t\t\tstatus: \"skipped\",\n\t\t\t\tdurationMs: 0,\n\t\t\t\treason: \"no release-worthy changes\",\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst kind = state.kind;\n\t\tconst previous = state.previousVersion;\n\t\ttry {\n\t\t\tconst next = await nextVersion(state, kind, env);\n\t\t\tconst { version, target } = next;\n\t\t\tif (!scheme.matches(target)) {\n\t\t\t\tthrow new Error(`${target} isn't a ${scheme.name} version`);\n\t\t\t}\n\t\t\tif (previous !== undefined) {\n\t\t\t\tconst order = compareClassified(\n\t\t\t\t\tclassify(version, scheme, state.channels),\n\t\t\t\t\tclassify(previous, scheme, state.channels),\n\t\t\t\t\tscheme,\n\t\t\t\t);\n\t\t\t\tif (order <= 0) {\n\t\t\t\t\tthrow new Error(`${version} wouldn't come after ${previous}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsetVersion(state, version, target);\n\t\t\tconst exists = historiesOf(state.component).find((h) => h.exists);\n\t\t\tif (\n\t\t\t\tstate.tag !== undefined &&\n\t\t\t\t(await exists?.exists?.({\n\t\t\t\t\t...historyInput(state, env),\n\t\t\t\t\treleaseTag: state.tag,\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${state.tag} already exists; it was released from another branch`,\n\t\t\t\t);\n\t\t\t}\n\t\t\trecord({\n\t\t\t\t...base,\n\t\t\t\tstatus: \"ok\",\n\t\t\t\tdurationMs: performance.now() - start,\n\t\t\t\treason:\n\t\t\t\t\tprevious === undefined\n\t\t\t\t\t\t? `${version}: '${kind}', ${next.how}`\n\t\t\t\t\t\t: `${version}: '${kind}' from ${previous}, ${next.how}`,\n\t\t\t\toutput: { version, tag: state.tag },\n\t\t\t});\n\t\t} catch (error) {\n\t\t\trecord({\n\t\t\t\t...base,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tdurationMs: performance.now() - start,\n\t\t\t\treason: errorMessage(error),\n\t\t\t\terror,\n\t\t\t});\n\t\t\tfail(error);\n\t\t}\n\t}\n}\n\n/**\n * The next version, and the scheme's version it stands for: on a\n * prerelease channel, the next stable version's next prerelease (keeping a\n * higher target that its channel already leads up to); on a build channel,\n * the stable version's next build.\n */\nasync function nextVersion(\n\tstate: State,\n\tkind: ReleaseKind,\n\tenv: Environment,\n): Promise<{ version: string; target: string; how: string }> {\n\tconst { scheme } = state.component;\n\tconst channel = state.channel;\n\tlet target: string;\n\tlet how: string;\n\tif (channel?.type === \"build\") {\n\t\tif (state.stable === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`a build on '${channel.name}' needs a previous release to number builds of`,\n\t\t\t);\n\t\t}\n\t\ttarget = state.stable;\n\t\thow = `build of ${target}`;\n\t} else if (state.exact !== undefined) {\n\t\ttarget = state.exact;\n\t\thow = \"as determined\";\n\t} else {\n\t\tconst bumped = scheme.bump({\n\t\t\t...(state.stable !== undefined && { previous: state.stable }),\n\t\t\tkind,\n\t\t\tbranch: env.branch,\n\t\t\tdate: new Date(),\n\t\t});\n\t\ttarget = bumped.version;\n\t\thow = bumped.reason;\n\t}\n\tif (!channel) return { version: target, target, how };\n\n\tconst previous: Classified | undefined =\n\t\tstate.previousVersion === undefined\n\t\t\t? undefined\n\t\t\t: classify(state.previousVersion, scheme, state.channels);\n\tconst onChannel =\n\t\tprevious !== undefined &&\n\t\tprevious.type !== \"stable\" &&\n\t\tprevious.type !== \"foreign\" &&\n\t\tprevious.channel === channel.name\n\t\t\t? previous\n\t\t\t: undefined;\n\tif (\n\t\tchannel.type === \"prerelease\" &&\n\t\tonChannel &&\n\t\tscheme.compare(onChannel.target, target) > 0\n\t) {\n\t\ttarget = onChannel.target;\n\t\thow = `continues ${target}`;\n\t}\n\tconst counter = historiesOf(state.component).find((h) => h.count);\n\tconst counted =\n\t\t(await counter?.count?.({ ...historyInput(state, env), target })) ?? 0;\n\tconst last =\n\t\tonChannel && scheme.compare(onChannel.target, target) === 0\n\t\t\t? onChannel.n\n\t\t\t: 0;\n\tconst n = Math.max(counted, last) + 1;\n\treturn {\n\t\tversion: channelVersion(channel, target, n),\n\t\ttarget,\n\t\thow: `${how}, ${channel.name} ${n}`,\n\t};\n}\n\n/**\n * Checks, before anything runs, that every step's needs are met by the\n * scheme and the steps before it, naming steps that would meet them.\n */\nfunction preflight(\n\tsteps: readonly AnyStep[],\n\tstates: readonly State[],\n\tgiven: boolean,\n): string[] {\n\tconst problems = new Set<string>();\n\tfor (const state of states) {\n\t\tconst facts = new Set(state.facts);\n\t\tlet source: string | undefined;\n\t\tfor (const step of steps) {\n\t\t\tif (given && step.phase !== \"release\") continue;\n\t\t\tfor (const fact of step.needs ?? []) {\n\t\t\t\tif (facts.has(fact)) continue;\n\t\t\t\tconst by = isChangeFact(fact)\n\t\t\t\t\t? source === undefined\n\t\t\t\t\t\t? \"no step\"\n\t\t\t\t\t\t: source\n\t\t\t\t\t: fact === \"previousVersion\"\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: `the scheme ${state.component.scheme.name}`;\n\t\t\t\tconst providers = providersOf(fact).filter((name) => name !== source);\n\t\t\t\tconst prefix =\n\t\t\t\t\tstates.length > 1 ? `${state.component.info.name}: ` : \"\";\n\t\t\t\tproblems.add(\n\t\t\t\t\tby === undefined\n\t\t\t\t\t\t? `${prefix}${step.name} needs a previous ${state.component.scheme.name} version, and there's none`\n\t\t\t\t\t\t: `${prefix}${step.name} needs ${fact}, which ${by} doesn't provide${\n\t\t\t\t\t\t\t\tproviders.length > 0\n\t\t\t\t\t\t\t\t\t? `; ${joinOr(providers)} ${providers.length > 1 ? \"do\" : \"does\"}`\n\t\t\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (step.phase === \"read-changes\" && !step.if) {\n\t\t\t\tfor (const fact of [...facts])\n\t\t\t\t\tif (isChangeFact(fact)) facts.delete(fact);\n\t\t\t\tsource = step.name;\n\t\t\t}\n\t\t\tfor (const fact of step.provides ?? []) facts.add(fact);\n\t\t}\n\t}\n\treturn [...problems];\n}\n\nfunction joinOr(items: readonly string[]): string {\n\treturn items.length <= 1\n\t\t? (items[0] ?? \"\")\n\t\t: `${items.slice(0, -1).join(\", \")} or ${items.at(-1)}`;\n}\n\nfunction assertNeeds(step: AnyStep, state: State) {\n\tconst missing = (step.needs ?? []).filter((fact) => !state.facts.has(fact));\n\tif (missing.length > 0) {\n\t\tthrow new Error(\n\t\t\t`it needs ${missing.join(\", \")}, which no step that ran provides`,\n\t\t);\n\t}\n}\n\nfunction assertEarlierPhases(state: State, before: Phase) {\n\tfor (const phase of PHASES.slice(0, phaseIndex(before))) {\n\t\tif (state[PHASE_VALUES[phase]] === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`no '${phase}' step ran, so it has no ${PHASE_VALUES[phase]}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** What a step receives for a component. */\nfunction values(state: State) {\n\treturn {\n\t\tcomponent: state.component.info,\n\t\t...definedOnly({\n\t\t\tpreviousVersion: state.previousVersion,\n\t\t\tpreviousRef: state.previousRef,\n\t\t\tpreviousTag: state.previousTag,\n\t\t\tchanges: state.changes,\n\t\t\tkind: state.kind,\n\t\t\tversion: state.version,\n\t\t\ttag: state.tag,\n\t\t\tplaceholders: state.placeholders,\n\t\t\tnotes: state.notes,\n\t\t}),\n\t\t...(state.version !== undefined && {\n\t\t\tdependencies: [...state.dependencies],\n\t\t}),\n\t\treleases: [...state.releases],\n\t};\n}\n\nfunction shared(env: Environment, context: unknown, records: StepRecord[]) {\n\treturn { env: { ...env }, context, history: [...records] };\n}\n\n/** Checks a step's output and applies it; resolves with its reason. */\nfunction apply(\n\tstep: AnyStep,\n\tgroup: readonly State[],\n\tall: boolean,\n\tvalue: unknown,\n): { reason: string; defer?: string } {\n\tconst output = checkObject(value);\n\tif (\n\t\tstep.phase === \"write\" ||\n\t\tstep.phase === \"stage\" ||\n\t\tstep.phase === \"release\"\n\t) {\n\t\tcheckRelease(output);\n\t\tif (step.phase !== \"release\" && output.defer !== undefined) {\n\t\t\tif (typeof output.defer !== \"string\" || output.defer.trim() === \"\") {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\"invalid output: 'defer' must be a non-empty string when present\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst result: ReleaseResult = {\n\t\t\tname: step.name,\n\t\t\toutput: output.output,\n\t\t\tfiles: (output.files as string[] | undefined) ?? [],\n\t\t};\n\t\tfor (const state of group) {\n\t\t\tstate.releases.push(result);\n\t\t\tfor (const fact of step.provides ?? []) state.facts.add(fact);\n\t\t}\n\t\treturn {\n\t\t\treason: output.reason as string,\n\t\t\t...(typeof output.defer === \"string\" && { defer: output.defer }),\n\t\t};\n\t}\n\tif (!all) {\n\t\tconst [state] = group;\n\t\tif (state) applyTo(step, state, output);\n\t\treturn { reason: output.reason as string };\n\t}\n\tconst results = output.results;\n\tif (\n\t\ttypeof results !== \"object\" ||\n\t\tresults === null ||\n\t\tArray.isArray(results)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"invalid output: 'results' must map components to their results\",\n\t\t);\n\t}\n\tfor (const name of Object.keys(results)) {\n\t\tif (!group.some((state) => state.component.info.name === name)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`invalid output: '${name}' isn't a component being released`,\n\t\t\t);\n\t\t}\n\t}\n\tfor (const state of group) {\n\t\tconst own = (results as Record<string, unknown>)[state.component.info.name];\n\t\tif (own !== undefined) applyTo(step, state, checkObject(own));\n\t}\n\treturn { reason: output.reason as string };\n}\n\nfunction applyTo(step: AnyStep, state: State, output: Record<string, unknown>) {\n\tswitch (step.phase) {\n\t\tcase \"read-changes\": {\n\t\t\tconst changes = parseChanges(output);\n\t\t\tcheckChanges(changes, step.provides ?? []);\n\t\t\tstate.changes = changes;\n\t\t\tfor (const fact of [...state.facts]) {\n\t\t\t\tif (isChangeFact(fact)) state.facts.delete(fact);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"determine-kind\":\n\t\t\tif (!(KINDS as readonly unknown[]).includes(output.kind)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`invalid output: 'kind' must be one of ${KINDS.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (\n\t\t\t\toutput.version !== undefined &&\n\t\t\t\t(typeof output.version !== \"string\" || output.version === \"\")\n\t\t\t) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\"invalid output: 'version' must be a non-empty string when present\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tstate.kind = output.kind as Kind;\n\t\t\tstate.exact = output.version as string | undefined;\n\t\t\tbreak;\n\t\tcase \"determine-notes\":\n\t\t\tif (typeof output.notes !== \"string\") {\n\t\t\t\tthrow new TypeError(\"invalid output: 'notes' must be a string\");\n\t\t\t}\n\t\t\tstate.notes = output.notes;\n\t\t\tbreak;\n\t}\n\tfor (const fact of step.provides ?? []) state.facts.add(fact);\n}\n\n/** Guards against untyped (e.g. plain JS) steps returning malformed output. */\nfunction checkObject(value: unknown): Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null) {\n\t\tthrow new TypeError(\"invalid output: expected an object\");\n\t}\n\tconst output = value as Record<string, unknown>;\n\tif (typeof output.reason !== \"string\" || output.reason.trim() === \"\") {\n\t\tthrow new TypeError(\"invalid output: 'reason' must be a non-empty string\");\n\t}\n\treturn output;\n}\n\nfunction parseChanges(output: Record<string, unknown>): Change[] {\n\tconst changes = output.changes;\n\tif (\n\t\t!Array.isArray(changes) ||\n\t\t!changes.every(\n\t\t\t(change: unknown) =>\n\t\t\t\ttypeof change === \"object\" &&\n\t\t\t\tchange !== null &&\n\t\t\t\ttypeof (change as Change).reason === \"string\",\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"invalid output: 'changes' must be an array of changes, each with a 'reason'\",\n\t\t);\n\t}\n\tif (\n\t\t!(changes as Change[]).every(\n\t\t\t({ labels }) =>\n\t\t\t\tlabels === undefined ||\n\t\t\t\t(Array.isArray(labels) &&\n\t\t\t\t\tlabels.every((label) => typeof label === \"string\")),\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"invalid output: a change's 'labels' must be an array of strings when present\",\n\t\t);\n\t}\n\treturn changes as Change[];\n}\n\nfunction checkRelease(output: Record<string, unknown>) {\n\tif (!(\"output\" in output)) {\n\t\tthrow new TypeError(\n\t\t\t\"invalid output: 'output' is required (use null for none)\",\n\t\t);\n\t}\n\tif (\n\t\toutput.files !== undefined &&\n\t\t!(\n\t\t\tArray.isArray(output.files) &&\n\t\t\toutput.files.every((file) => typeof file === \"string\")\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"invalid output: 'files' must be an array of paths when present\",\n\t\t);\n\t}\n}\n\n/**\n * `breaking` or `feature` when the first or second number differs;\n * otherwise, or when either isn't a version, `fix`.\n */\nfunction difference(from: string, to: string): ReleaseKind {\n\tconst a = parseVersion(from);\n\tconst b = parseVersion(to);\n\tconst index = a && b ? firstDifference(a, b) : undefined;\n\treturn index === 0 ? \"breaking\" : index === 1 ? \"feature\" : \"fix\";\n}\n\nasync function detectBranch(cwd: string): Promise<string> {\n\tconst fromCi =\n\t\tprocess.env.GITHUB_HEAD_REF ||\n\t\tprocess.env.GITHUB_REF_NAME ||\n\t\tprocess.env.CI_COMMIT_REF_NAME;\n\tif (fromCi) return fromCi;\n\treturn (await tryGit(cwd, \"rev-parse\", \"--abbrev-ref\", \"HEAD\")) ?? \"unknown\";\n}\n\nexport function errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\n/** Drops `undefined` properties, for `exactOptionalPropertyTypes`. */\nfunction definedOnly<T extends object>(\n\tobject: T,\n): { [K in keyof T]?: Exclude<T[K], undefined> } {\n\treturn Object.fromEntries(\n\t\tObject.entries(object).filter(([, value]) => value !== undefined),\n\t) as { [K in keyof T]?: Exclude<T[K], undefined> };\n}\n","import { joinList } from \"../utils/text.ts\";\nimport type { Channel } from \"./channels.ts\";\nimport type { Component, ComponentSource } from \"./components.ts\";\nimport { type ReleaseReport, type RunOptions, runRelease } from \"./engine.ts\";\nimport type { AnyFactory, Factory } from \"./factory.ts\";\nimport { type Fact, registerProvider } from \"./facts.ts\";\nimport type { History } from \"./history.ts\";\nimport {\n\ttype Empty,\n\tOptionsError,\n\ttype OptionsInput,\n\ttype OptionsShape,\n\ttype OptionsValue,\n\tparseOptions,\n} from \"./options.ts\";\nimport type { Scheme } from \"./scheme.ts\";\nimport type {\n\tAllStepDefinition,\n\tAllStepInput,\n\tAllStepOutput,\n\tEachStepDefinition,\n\tPhase,\n\tScope,\n\tStep,\n\tStepCondition,\n\tStepInput,\n\tStepOutput,\n\tStepPreset,\n} from \"./types.ts\";\n\nexport type ReleaseConfig<Context> = {\n\t/** Steps to run; they're ordered by phase, keeping their order within a phase. */\n\tsteps: readonly Step<Context>[];\n\t/**\n\t * How versions look, are ordered and bumped, e.g. `semver()`. Needed\n\t * unless a preset among `steps` provides one, as `conventional` does.\n\t */\n\tscheme?: Scheme;\n\t/**\n\t * Each release's tag; `{version}` and `{name}` (the component's) are\n\t * filled in. Defaults to `v{version}`, or `{name}@{version}` with several\n\t * components.\n\t */\n\ttag?: string;\n\t/**\n\t * Where previous releases are found, e.g. `gitTags()`; with several, the\n\t * first that finds one wins. Needed unless a preset among `steps`\n\t * provides one, as every built-in preset does.\n\t */\n\thistory?: History | readonly History[];\n\t/**\n\t * What's versioned and released: a list, or a source such as\n\t * `npmWorkspaces()`. Defaults to the whole project, as one component.\n\t */\n\tcomponents?: readonly Component[] | ComponentSource;\n\t/**\n\t * Prerelease and build channels, by name, e.g.\n\t * `{ next: { branches: [\"next\"] } }` for `2.0.0-next.1`. A run releases\n\t * on the first whose branches match, or the one it's given.\n\t */\n\tchannels?: Readonly<Record<string, Channel>>;\n} & (undefined extends Context\n\t? {\n\t\t\t/** Shared, mutable state passed to every step. */\n\t\t\tcontext?: Context;\n\t\t}\n\t: {\n\t\t\t/** Shared, mutable state passed to every step. */\n\t\t\tcontext: Context;\n\t\t});\n\nexport interface Release<Context> {\n\treadonly steps: readonly Step<Context>[];\n\t/** Its own scheme, or its preset's. */\n\treadonly scheme: Scheme;\n\t/** Its own history, or its preset's. */\n\treadonly history: History | readonly History[];\n\trun(options?: RunOptions): Promise<ReleaseReport>;\n}\n\n/**\n * Defines a release pipeline. Pass a custom context type to type the `context`\n * every step receives: `defineRelease<{ slackTs?: string }>({ context: {}, steps })`.\n * Its `scheme` and `history` are its own, or else the preset's its steps come from.\n */\nexport function defineRelease<Context = undefined>(\n\tconfig: ReleaseConfig<Context>,\n): Release<Context> {\n\tconst issues: string[] = [];\n\tconst scheme = config.scheme ?? fromPreset(config.steps, \"scheme\", issues);\n\tconst history = config.history ?? fromPreset(config.steps, \"history\", issues);\n\tif (!scheme || !history) throw new OptionsError(issues);\n\treturn {\n\t\tsteps: config.steps,\n\t\tscheme,\n\t\thistory,\n\t\trun: (options) =>\n\t\t\trunRelease(\n\t\t\t\t{\n\t\t\t\t\tsteps: config.steps,\n\t\t\t\t\tcontext: config.context as Context,\n\t\t\t\t\tscheme,\n\t\t\t\t\ttag: config.tag,\n\t\t\t\t\thistory,\n\t\t\t\t\tcomponents: config.components,\n\t\t\t\t\tchannels: config.channels,\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t),\n\t};\n}\n\nconst EXAMPLES = { scheme: \"semver\", history: \"git/tags\" };\n\n/** The scheme or history provided by the one preset `steps` come from that has it. */\nfunction fromPreset<K extends \"scheme\" | \"history\">(\n\tsteps: readonly Step<never>[],\n\tkey: K,\n\tissues: string[],\n): StepPreset[K] | undefined {\n\tconst provided = new Map<string, StepPreset[K]>();\n\tfor (const { preset } of steps) {\n\t\tif (preset?.[key] && !provided.has(preset.name)) {\n\t\t\tprovided.set(preset.name, preset[key]);\n\t\t}\n\t}\n\tconst [only, ...others] = provided.values();\n\tif (only && others.length === 0) return only;\n\tissues.push(\n\t\tprovided.size === 0\n\t\t\t? `${key}: expected one, e.g. ${EXAMPLES[key]}, or a preset that provides one`\n\t\t\t: `${key}: ${joinList([...provided.keys()])} each provide one; set it`,\n\t);\n\treturn undefined;\n}\n\n/** The step a factory makes, by scope. */\nexport type ScopedStep<T extends Phase, Sc extends Scope> = Sc extends \"all\"\n\t? AllStepDefinition<T>\n\t: EachStepDefinition<T>;\n\nexport interface StepFactoryDefinition<\n\tT extends Phase,\n\tN extends string,\n\tS extends OptionsShape,\n\tSc extends Scope,\n\tNeeds extends Fact,\n\tProvides extends Fact,\n> {\n\t/** Its phase; a function works it out from its options, e.g. a `phase` option. */\n\tphase: T | ((options: OptionsValue<S>) => T);\n\t/** Identifies the step in reports and in workflow `steps`, e.g. `git/commit`. */\n\tname: N;\n\t/** One line on what the step does, for generated docs. */\n\tdescription?: string;\n\t/** Runs once per component (`each`, the default) or once with all of them (`all`). */\n\tscope?: Sc;\n\t/**\n\t * Facts it relies on, e.g. `changes.labels`; its input is typed\n\t * accordingly. A function works them out from its options, e.g. by format.\n\t */\n\tneeds?: readonly Needs[] | ((options: OptionsValue<S>) => readonly Fact[]);\n\t/** Facts it guarantees, e.g. that every change has `labels`. */\n\tprovides?: readonly Provides[];\n\t/** A zod shape; use `.default()` for optional options and `.describe()` to document them. */\n\toptions?: S;\n\trun: (\n\t\tinput: (Sc extends \"all\"\n\t\t\t? AllStepInput<T, unknown, Needs>\n\t\t\t: StepInput<T, unknown, Needs>) & { options: OptionsValue<S> },\n\t) => Sc extends \"all\"\n\t\t? AllStepOutput<T, Provides> | Promise<AllStepOutput<T, Provides>>\n\t\t: StepOutput<T, Provides> | Promise<StepOutput<T, Provides>>;\n}\n\n/** Creates a configured step; the options argument is optional when every option is. */\nexport interface StepFactory<\n\tT extends Phase = Phase,\n\tN extends string = string,\n\tS extends OptionsShape = OptionsShape,\n\tSc extends Scope = Scope,\n> extends Factory<\"step\", N, S, ScopedStep<T, Sc>> {\n\t/** Its phase, or a function of its options that works it out. */\n\treadonly phase: T | ((options: OptionsValue<S>) => T);\n\treadonly scope: Sc;\n\treadonly needs: readonly Fact[];\n\treadonly provides: readonly Fact[];\n}\n\n/** Any step factory, whatever its phase, name or options. */\nexport interface AnyStepFactory extends AnyFactory<\"step\", Step> {\n\treadonly phase: Phase | ((options: never) => Phase);\n\treadonly scope: Scope;\n\treadonly needs: readonly Fact[];\n\treadonly provides: readonly Fact[];\n}\n\n/** What a factory accepts, e.g. `FactoryOptions<typeof gitCommit>`. */\nexport type FactoryOptions<F extends { options: OptionsShape }> = OptionsInput<\n\tF[\"options\"]\n>;\n\n/**\n * Defines a reusable step whose options are declared as a zod shape. The\n * result is a factory: call it with options to get a step. Its options are\n * validated on every call, so they're just as safe when they come from a\n * workflow file.\n *\n * ```ts\n * export const header = defineStep({\n * phase: \"determine-notes\",\n * name: \"header\",\n * options: { text: z.string().default(\"Released by rylease\") },\n * run: ({ notes, options }) => ({ notes: `> ${options.text}\\n\\n${notes}`, reason: \"added header\" }),\n * });\n * header({ text: \"Hi\" });\n * ```\n */\nexport function defineStep<\n\tT extends Phase,\n\tconst N extends string,\n\tS extends OptionsShape = Empty,\n\tSc extends Scope = \"each\",\n\tconst Needs extends Fact = never,\n\tconst Provides extends Fact = never,\n>(\n\tdefinition: StepFactoryDefinition<T, N, S, Sc, Needs, Provides>,\n): StepFactory<T, N, S, Sc> {\n\tconst shape = (definition.options ?? {}) as S;\n\tconst scope = (definition.scope ?? \"each\") as Sc;\n\tconst declared = definition.needs ?? [];\n\tconst needs: readonly Fact[] = typeof declared === \"function\" ? [] : declared;\n\tconst provides: readonly Fact[] = definition.provides ?? [];\n\tfor (const key of [\"phase\", \"name\"]) {\n\t\tif (!(key in definition)) {\n\t\t\tthrow new OptionsError([`${definition.name}: ${key} is required`]);\n\t\t}\n\t}\n\tregisterProvider(definition.name, provides);\n\tconst factory = (options?: unknown) => {\n\t\tconst parsed = parseOptions(shape, options, definition.name);\n\t\tconst run = definition.run as (input: unknown) => unknown;\n\t\tconst needs: readonly Fact[] =\n\t\t\ttypeof declared === \"function\" ? declared(parsed) : declared;\n\t\treturn {\n\t\t\tphase:\n\t\t\t\ttypeof definition.phase === \"function\"\n\t\t\t\t\t? definition.phase(parsed)\n\t\t\t\t\t: definition.phase,\n\t\t\tname: definition.name,\n\t\t\t...(scope === \"all\" && { scope }),\n\t\t\t...(needs.length > 0 && { needs }),\n\t\t\t...(provides.length > 0 && { provides }),\n\t\t\trun: (input: object) => run({ ...input, options: parsed }),\n\t\t};\n\t};\n\treturn Object.defineProperties(factory, {\n\t\tkind: { value: \"step\", enumerable: true },\n\t\tphase: { value: definition.phase, enumerable: true },\n\t\tname: { value: definition.name, enumerable: true },\n\t\tdescription: { value: definition.description, enumerable: true },\n\t\tscope: { value: scope, enumerable: true },\n\t\tneeds: { value: needs, enumerable: true },\n\t\tprovides: { value: provides, enumerable: true },\n\t\toptions: { value: shape, enumerable: true },\n\t}) as unknown as StepFactory<T, N, S, Sc>;\n}\n\n/** Options for each step of a preset, by name; `false` leaves a step out. */\nexport type PresetOptions<F extends readonly AnyStepFactory[]> = {\n\t[K in F[number] as K[\"name\"]]?: FactoryOptions<K> | false;\n};\n\n/** A preset's own options for its steps, by name. */\nexport type PresetDefaults<F extends readonly AnyStepFactory[]> = {\n\t[K in F[number] as K[\"name\"]]?: FactoryOptions<K>;\n};\n\n/** A named list of step factories that's configured, and used, as one. */\nexport interface Preset<\n\tN extends string = string,\n\tF extends readonly AnyStepFactory[] = readonly AnyStepFactory[],\n> {\n\t(options?: PresetOptions<F>): Step[];\n\treadonly kind: \"preset\";\n\treadonly name: N;\n\treadonly description: string | undefined;\n\treadonly steps: F;\n\treadonly defaults: PresetDefaults<F>;\n\t/** Makes the scheme of releases made with it, unless they set their own. */\n\treadonly scheme: (() => Scheme) | undefined;\n\t/** Makes the history of releases made with it, unless they set their own. */\n\treadonly history: (() => History | readonly History[]) | undefined;\n}\n\n/**\n * Bundles step factories under one name. Calling the preset creates every\n * step, passing each its options by name:\n * `conventional({ \"github/create-release\": false, \"conventional/determine-kind\": { fallback: \"none\" } })`.\n * `defaults` sets the preset's own options per step, under the caller's;\n * `scheme` and `history` make the release's, unless it sets its own, e.g.\n * `history: gitTags` for a preset that tags its releases.\n */\nexport function definePreset<\n\tconst N extends string,\n\tconst F extends readonly AnyStepFactory[],\n>(definition: {\n\tname: N;\n\tdescription?: string;\n\tsteps: F;\n\tdefaults?: PresetDefaults<F>;\n\tscheme?: () => Scheme;\n\thistory?: () => History | readonly History[];\n}): Preset<N, F> {\n\tconst names = definition.steps.map((step) => step.name);\n\tconst defaults: Record<string, object | undefined> =\n\t\tdefinition.defaults ?? {};\n\tconst preset = (options: Record<string, unknown> = {}): Step[] => {\n\t\tconst unknown = Object.keys(options).filter((key) => !names.includes(key));\n\t\tif (unknown.length > 0) {\n\t\t\tthrow new OptionsError(\n\t\t\t\tunknown.map(\n\t\t\t\t\t(key) =>\n\t\t\t\t\t\t`${definition.name}: '${key}' isn't one of its steps (${names.join(\", \")})`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\t// Made per call: histories may keep state for the run, e.g. a lookup.\n\t\tconst made: StepPreset = {\n\t\t\tname: definition.name,\n\t\t\t...(definition.scheme && { scheme: definition.scheme() }),\n\t\t\t...(definition.history && { history: definition.history() }),\n\t\t};\n\t\treturn definition.steps.flatMap((factory) => {\n\t\t\tconst value = options[factory.name];\n\t\t\tif (value === false) return [];\n\t\t\tconst base = defaults[factory.name];\n\t\t\t// Anything but options (or none) is left for the step to reject.\n\t\t\tconst merged =\n\t\t\t\tbase && (value == null || typeof value === \"object\")\n\t\t\t\t\t? { ...base, ...value }\n\t\t\t\t\t: value;\n\t\t\ttry {\n\t\t\t\tconst step = (factory as (options: unknown) => Step)(merged);\n\t\t\t\treturn [{ ...step, preset: made }];\n\t\t\t} catch (error) {\n\t\t\t\t// Point at the option inside the preset, e.g. `conventional.git/commit.x`.\n\t\t\t\tthrow error instanceof OptionsError\n\t\t\t\t\t? new OptionsError(\n\t\t\t\t\t\t\terror.issues.map((issue) => `${definition.name}.${issue}`),\n\t\t\t\t\t\t)\n\t\t\t\t\t: error;\n\t\t\t}\n\t\t});\n\t};\n\treturn Object.defineProperties(preset, {\n\t\tkind: { value: \"preset\", enumerable: true },\n\t\tname: { value: definition.name, enumerable: true },\n\t\tdescription: { value: definition.description, enumerable: true },\n\t\tsteps: { value: definition.steps, enumerable: true },\n\t\tdefaults: { value: definition.defaults ?? {}, enumerable: true },\n\t\tscheme: { value: definition.scheme, enumerable: true },\n\t\thistory: { value: definition.history, enumerable: true },\n\t}) as unknown as Preset<N, F>;\n}\n\n/** What a step's condition receives. */\nexport type ConditionInput<S> = S extends { run: (input: infer I) => unknown }\n\t? I\n\t: never;\n\n/**\n * Makes a step run only when `condition` holds, on top of any condition it\n * already has: `when(steps.npmPublish(), ({ env }) => !env.dryRun)`.\n */\nexport function when<S extends Step<never>>(\n\tstep: S,\n\tcondition: StepCondition<ConditionInput<S>>,\n): S {\n\tconst own = step.if as StepCondition<ConditionInput<S>> | undefined;\n\tconst source = condition.source ?? \"its condition\";\n\tconst combined: StepCondition<ConditionInput<S>> = own\n\t\t? Object.assign(\n\t\t\t\t(input: ConditionInput<S>) => condition(input) && own(input),\n\t\t\t\t{ source: `${source} && ${own.source ?? \"its own condition\"}` },\n\t\t\t)\n\t\t: condition;\n\treturn { ...step, if: combined };\n}\n","import type { ComponentInfo, Environment, StepRecord } from \"./types.ts\";\n\n/**\n * What an `if:` expression can read: the release so far, as the step itself\n * would receive it.\n */\nexport interface ExpressionContext {\n\tdryRun: boolean;\n\tbranch: string;\n\tcwd: string;\n\t/** The channel being released on, or `null` for a stable release. */\n\tchannel: string | null;\n\t/** Whether the release is on a prerelease channel. */\n\tprerelease: boolean;\n\t/** The component the step runs for: `{ name, path }`; absent for `all` steps. */\n\tcomponent?: { name: string; path: string };\n\t/** For `all` steps: every component being released, with its values. */\n\tcomponents?: readonly unknown[];\n\tpreviousVersion?: string;\n\tpreviousRef?: string;\n\tpreviousTag?: string;\n\tchanges?: readonly unknown[];\n\tkind?: string;\n\tversion?: string;\n\ttag?: string;\n\tnotes?: string;\n\t/** The components it depends on released along with it: `{ name, version, … }`. */\n\tdependencies?: readonly unknown[];\n\t/** The steps that ran before, by name: `{ phase, status, reason, output }`. */\n\tsteps: Record<string, unknown>;\n}\n\nconst NAMES: readonly (keyof ExpressionContext)[] = [\n\t\"dryRun\",\n\t\"branch\",\n\t\"cwd\",\n\t\"channel\",\n\t\"prerelease\",\n\t\"component\",\n\t\"components\",\n\t\"previousVersion\",\n\t\"previousRef\",\n\t\"previousTag\",\n\t\"changes\",\n\t\"kind\",\n\t\"version\",\n\t\"tag\",\n\t\"notes\",\n\t\"dependencies\",\n\t\"steps\",\n];\n\nconst VALUES = [\n\t\"previousVersion\",\n\t\"previousRef\",\n\t\"previousTag\",\n\t\"changes\",\n\t\"kind\",\n\t\"version\",\n\t\"tag\",\n\t\"notes\",\n\t\"dependencies\",\n] as const;\n\n/** Values of a component, as expressions read them. */\nfunction valuesOf(results: Record<string, unknown>) {\n\tconst component = results.component as ComponentInfo | undefined;\n\treturn {\n\t\t...(component && {\n\t\t\tcomponent: { name: component.name, path: component.path },\n\t\t}),\n\t\t...Object.fromEntries(\n\t\t\tVALUES.flatMap((name) =>\n\t\t\t\tresults[name] === undefined ? [] : [[name, results[name]]],\n\t\t\t),\n\t\t),\n\t};\n}\n\n/** What an expression reads, from what a step receives: for one component, or all. */\nexport function expressionContext(input: unknown): ExpressionContext {\n\tconst fields = input as {\n\t\tenv: Environment;\n\t\thistory: readonly StepRecord[];\n\t\tcomponents?: readonly Record<string, unknown>[];\n\t} & Record<string, unknown>;\n\tconst own = fields.component as ComponentInfo | undefined;\n\tconst all = fields.components;\n\treturn {\n\t\tdryRun: fields.env.dryRun,\n\t\tbranch: fields.env.branch,\n\t\tcwd: fields.env.cwd,\n\t\tchannel: fields.env.channel?.name ?? null,\n\t\tprerelease: fields.env.channel?.type === \"prerelease\",\n\t\t...(all\n\t\t\t? {\n\t\t\t\t\tcomponents: all.map(valuesOf),\n\t\t\t\t\t// With one component, `all` steps read its values like any other.\n\t\t\t\t\t...(all.length === 1 && all[0] ? valuesOf(all[0]) : {}),\n\t\t\t\t}\n\t\t\t: valuesOf(fields)),\n\t\tsteps: Object.fromEntries(\n\t\t\tfields.history\n\t\t\t\t// A component's own steps, and those for all of them.\n\t\t\t\t.filter(\n\t\t\t\t\t(record) =>\n\t\t\t\t\t\trecord.phase !== \"read-version\" &&\n\t\t\t\t\t\trecord.phase !== \"determine-version\" &&\n\t\t\t\t\t\t(record.component === undefined ||\n\t\t\t\t\t\t\town === undefined ||\n\t\t\t\t\t\t\trecord.component === own.name),\n\t\t\t\t)\n\t\t\t\t.map((record) => [\n\t\t\t\t\trecord.name,\n\t\t\t\t\t{\n\t\t\t\t\t\tphase: record.phase,\n\t\t\t\t\t\tstatus: record.status,\n\t\t\t\t\t\treason: record.reason,\n\t\t\t\t\t\toutput:\n\t\t\t\t\t\t\trecord.phase === \"release\"\n\t\t\t\t\t\t\t\t? (record.output as { output?: unknown } | undefined)?.output\n\t\t\t\t\t\t\t\t: record.output,\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t),\n\t};\n}\n\nexport class ExpressionError extends Error {\n\toverride name = \"ExpressionError\";\n}\n\ntype Node = (context: ExpressionContext) => unknown;\n\nconst FUNCTIONS: Record<string, (...args: unknown[]) => unknown> = {\n\tcontains: (search, item) =>\n\t\tArray.isArray(search)\n\t\t\t? search.includes(item)\n\t\t\t: String(search ?? \"\").includes(String(item ?? \"\")),\n\tstartsWith: (text, prefix) =>\n\t\tString(text ?? \"\").startsWith(String(prefix ?? \"\")),\n\tendsWith: (text, suffix) => String(text ?? \"\").endsWith(String(suffix ?? \"\")),\n};\n\nconst TOKEN =\n\t/\\s*(?:(\\d+(?:\\.\\d+)?)|'((?:[^']|'')*)'|([A-Za-z_][\\w-]*)|(==|!=|<=|>=|&&|\\|\\||[!<>().[\\],]))/y;\n\ntype Token =\n\t| { kind: \"number\"; value: number }\n\t| { kind: \"string\"; value: string }\n\t| { kind: \"name\"; value: string }\n\t| { kind: \"op\"; value: string };\n\nfunction tokenize(source: string): Token[] {\n\tconst tokens: Token[] = [];\n\tTOKEN.lastIndex = 0;\n\twhile (source.slice(TOKEN.lastIndex).trim() !== \"\") {\n\t\tconst at = TOKEN.lastIndex;\n\t\tconst match = TOKEN.exec(source);\n\t\tif (!match) {\n\t\t\tconst rest = source.slice(at).trimStart();\n\t\t\t// Most likely a step name read as `steps.git/commit`.\n\t\t\tconst hint =\n\t\t\t\trest[0] === \"/\" ? \"; read names with '/' as steps['git/commit']\" : \"\";\n\t\t\tthrow new ExpressionError(\n\t\t\t\t`unexpected '${rest[0]}' at ${source.length - rest.length + 1}${hint}`,\n\t\t\t);\n\t\t}\n\t\tconst [, number, string, name, op] = match;\n\t\tif (number !== undefined)\n\t\t\ttokens.push({ kind: \"number\", value: Number(number) });\n\t\telse if (string !== undefined)\n\t\t\ttokens.push({ kind: \"string\", value: string.replaceAll(\"''\", \"'\") });\n\t\telse if (name !== undefined) tokens.push({ kind: \"name\", value: name });\n\t\telse tokens.push({ kind: \"op\", value: op ?? \"\" });\n\t}\n\treturn tokens;\n}\n\n/**\n * Compiles an `if:` expression, in the style of GitHub's: literals (`true`,\n * `'text'`, `1`, `null`), names from {@link ExpressionContext} with `.x` and\n * `['x']` access, `!`, `==`, `!=`, `<`, `<=`, `>`, `>=`, `&&`, `||`,\n * parentheses, and `contains`, `startsWith` and `endsWith`.\n */\nexport function compileExpression(source: string): Node {\n\tconst tokens = tokenize(source);\n\tlet position = 0;\n\tconst peek = () => tokens[position];\n\tconst isOp = (value: string) => {\n\t\tconst token = peek();\n\t\treturn token?.kind === \"op\" && token.value === value;\n\t};\n\tconst expect = (value: string) => {\n\t\tif (!isOp(value)) throw unexpected();\n\t\tposition++;\n\t};\n\tconst unexpected = () => {\n\t\tconst token = peek();\n\t\treturn new ExpressionError(\n\t\t\ttoken ? `unexpected '${token.value}'` : \"unexpected end\",\n\t\t);\n\t};\n\n\tconst binary = (\n\t\tnext: () => Node,\n\t\toperators: Record<string, (a: unknown, b: () => unknown) => unknown>,\n\t) => {\n\t\treturn (): Node => {\n\t\t\tlet left = next();\n\t\t\tfor (;;) {\n\t\t\t\tconst token = peek();\n\t\t\t\tconst apply = token?.kind === \"op\" ? operators[token.value] : undefined;\n\t\t\t\tif (!apply) return left;\n\t\t\t\tposition++;\n\t\t\t\tconst right = next();\n\t\t\t\tconst l = left;\n\t\t\t\tleft = (context) => apply(l(context), () => right(context));\n\t\t\t}\n\t\t};\n\t};\n\n\tconst compare =\n\t\t(test: (a: number | string, b: number | string) => boolean) =>\n\t\t(a: unknown, b: () => unknown) => {\n\t\t\tconst right = b();\n\t\t\treturn (\n\t\t\t\t(typeof a === \"number\" || typeof a === \"string\") &&\n\t\t\t\ttypeof right === typeof a &&\n\t\t\t\ttest(a, right as number | string)\n\t\t\t);\n\t\t};\n\n\tconst primary = (): Node => {\n\t\tconst token = peek();\n\t\tif (!token) throw unexpected();\n\t\tposition++;\n\t\tif (token.kind === \"number\" || token.kind === \"string\") {\n\t\t\treturn () => token.value;\n\t\t}\n\t\tif (token.kind === \"op\") {\n\t\t\tif (token.value === \"!\") {\n\t\t\t\tconst operand = primary();\n\t\t\t\treturn (context) => !operand(context);\n\t\t\t}\n\t\t\tif (token.value === \"(\") {\n\t\t\t\tconst inner = or();\n\t\t\t\texpect(\")\");\n\t\t\t\treturn inner;\n\t\t\t}\n\t\t\tposition--;\n\t\t\tthrow unexpected();\n\t\t}\n\t\tconst literals: Record<string, unknown> = {\n\t\t\ttrue: true,\n\t\t\tfalse: false,\n\t\t\tnull: null,\n\t\t};\n\t\tif (token.value in literals) return () => literals[token.value];\n\t\tif (isOp(\"(\")) {\n\t\t\tconst fn = FUNCTIONS[token.value];\n\t\t\tif (!fn) {\n\t\t\t\tthrow new ExpressionError(\n\t\t\t\t\t`unknown function '${token.value}'; use ${Object.keys(FUNCTIONS).join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tposition++;\n\t\t\tconst args: Node[] = [];\n\t\t\tif (!isOp(\")\")) {\n\t\t\t\targs.push(or());\n\t\t\t\twhile (isOp(\",\")) {\n\t\t\t\t\tposition++;\n\t\t\t\t\targs.push(or());\n\t\t\t\t}\n\t\t\t}\n\t\t\texpect(\")\");\n\t\t\treturn (context) => fn(...args.map((arg) => arg(context)));\n\t\t}\n\t\tif (!(NAMES as readonly string[]).includes(token.value)) {\n\t\t\tthrow new ExpressionError(\n\t\t\t\t`unknown name '${token.value}'; use ${NAMES.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t\tconst name = token.value as keyof ExpressionContext;\n\t\tlet node: Node = (context) => context[name];\n\t\tfor (;;) {\n\t\t\tif (isOp(\".\")) {\n\t\t\t\tposition++;\n\t\t\t\tconst key = peek();\n\t\t\t\tif (key?.kind !== \"name\") throw unexpected();\n\t\t\t\tposition++;\n\t\t\t\tconst object = node;\n\t\t\t\tnode = (context) => property(object(context), key.value);\n\t\t\t} else if (isOp(\"[\")) {\n\t\t\t\tposition++;\n\t\t\t\tconst key = or();\n\t\t\t\texpect(\"]\");\n\t\t\t\tconst object = node;\n\t\t\t\tnode = (context) => property(object(context), key(context));\n\t\t\t} else {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t};\n\n\tconst comparison = binary(primary, {\n\t\t\"<\": compare((a, b) => a < b),\n\t\t\"<=\": compare((a, b) => a <= b),\n\t\t\">\": compare((a, b) => a > b),\n\t\t\">=\": compare((a, b) => a >= b),\n\t});\n\tconst equality = binary(comparison, {\n\t\t\"==\": (a, b) => (a ?? null) === (b() ?? null),\n\t\t\"!=\": (a, b) => (a ?? null) !== (b() ?? null),\n\t});\n\tconst and = binary(equality, { \"&&\": (a, b) => (a ? b() : a) });\n\tconst or: () => Node = binary(and, { \"||\": (a, b) => a || b() });\n\n\tif (tokens.length === 0) throw new ExpressionError(\"empty expression\");\n\tconst root = or();\n\tif (position < tokens.length) throw unexpected();\n\treturn root;\n}\n\nfunction property(object: unknown, key: unknown): unknown {\n\tif (typeof object !== \"object\" || object === null) return undefined;\n\tconst name = String(key);\n\treturn Object.hasOwn(object, name)\n\t\t? (object as Record<string, unknown>)[name]\n\t\t: undefined;\n}\n","import type { ResolvedChannel } from \"./channels.ts\";\nimport { type FactoryDefinition, makeFactory } from \"./factory.ts\";\nimport type { OptionsShape } from \"./options.ts\";\nimport type { Scheme } from \"./scheme.ts\";\nimport type { ComponentInfo, Environment, ReleaseKind } from \"./types.ts\";\n\n/** Where a component's previous release is found: tags, a file, ... */\nexport interface History {\n\treadonly name: string;\n\tfind(input: HistoryInput): Promise<Found | undefined>;\n\t/**\n\t * The highest counter of a channel's versions of a target, among every\n\t * release, not only those on HEAD, so channel versions never collide.\n\t */\n\tcount?(input: HistoryInput & { target: string }): Promise<number>;\n\t/** Whether a release's tag exists already. */\n\texists?(input: HistoryInput & { releaseTag: string }): Promise<boolean>;\n}\n\nexport interface HistoryInput {\n\tenv: Environment;\n\tcomponent: ComponentInfo;\n\tscheme: Scheme;\n\t/** The component's tag template, with `{name}` filled in, e.g. `v{version}`. */\n\ttag: string;\n\t/** The channel being released on; without one, only stable releases count. */\n\tchannel?: ResolvedChannel | undefined;\n\t/** Every channel, to tell their versions from stable ones. */\n\tchannels: readonly ResolvedChannel[];\n}\n\n/** The previous release; `undefined` from `find` when there's none. */\nexport interface Found {\n\t/** Absent when the release's version isn't one of the scheme's. */\n\tversion?: string;\n\t/** Its commit; without one, changes are collected from all history. */\n\tref?: string;\n\ttag?: string;\n\t/** e.g. `v1.4.0 at abc1234, nearest on HEAD`. */\n\treason: string;\n\t/**\n\t * On a channel, the nearest stable release, when `version` is a channel\n\t * version; new versions are bumped from it.\n\t */\n\tstable?: { version: string; ref?: string; tag?: string };\n\t/**\n\t * A release that's been prepared but not released, e.g. by a merged\n\t * release pull request: only its `release` steps run.\n\t */\n\tpending?: Pending;\n}\n\n/** A prepared release, as a history finds it. */\nexport interface Pending {\n\tversion: string;\n\tnotes?: string;\n\tkind?: ReleaseKind;\n\tpreviousVersion?: string;\n\t/** e.g. `prepared in #12`. */\n\treason: string;\n}\n\n/** Defines where previous releases are found, with options as a zod shape. */\nexport function defineHistory<const N extends string, S extends OptionsShape>(\n\tdefinition: FactoryDefinition<N, S, History>,\n) {\n\treturn makeFactory(\"history\", definition);\n}\n","export function versionOf(\n\tjson: Record<string, unknown>,\n\tsource: string,\n): string {\n\tif (typeof json.version !== \"string\" || json.version === \"\") {\n\t\tthrow new Error(`${source} has no 'version'`);\n\t}\n\treturn json.version;\n}\n\nconst DEPENDENCY_FIELDS = [\n\t\"dependencies\",\n\t\"devDependencies\",\n\t\"peerDependencies\",\n\t\"optionalDependencies\",\n] as const;\n\n/**\n * A package.json's text with a new `version`, and with dependencies on the\n * given packages pointed at theirs, keeping each range's operator (`^`, `~`,\n * `>=` or none). `workspace:`, `file:` and ranges like `1.x` are left for the\n * package manager. Its indentation and trailing newline are kept.\n */\nexport function setPackageJsonVersion(\n\ttext: string,\n\tversion: string,\n\tpackages: ReadonlyMap<string, string>,\n): { text: string; dependencies: string[] } {\n\tconst json = JSON.parse(text) as Record<string, unknown>;\n\tjson.version = version;\n\tconst changed: string[] = [];\n\tfor (const field of DEPENDENCY_FIELDS) {\n\t\tconst deps = json[field] as Record<string, unknown> | undefined;\n\t\tif (typeof deps !== \"object\" || deps === null) continue;\n\t\tfor (const [name, range] of Object.entries(deps)) {\n\t\t\tconst next = packages.get(name);\n\t\t\tif (next === undefined || typeof range !== \"string\") continue;\n\t\t\tconst updated = withOperator(range, next);\n\t\t\tif (updated === undefined || updated === range) continue;\n\t\t\tdeps[name] = updated;\n\t\t\tchanged.push(`${name}@${updated}`);\n\t\t}\n\t}\n\tconst indent = /^[ \\t]+(?=\")/m.exec(text)?.[0] ?? \"\\t\";\n\tconst newline = text.endsWith(\"\\n\") ? \"\\n\" : \"\";\n\treturn {\n\t\ttext: JSON.stringify(json, null, indent) + newline,\n\t\tdependencies: [...new Set(changed)],\n\t};\n}\n\n/**\n * A range pointed at a new version, keeping its operator, or `undefined`\n * when it isn't a plain range on one version.\n */\nexport function withOperator(\n\trange: string,\n\tversion: string,\n): string | undefined {\n\tconst match = /^(\\^|~|>=|=)?v?\\d+(?:\\.\\d+)*(?:[-+][0-9A-Za-z.+-]+)?$/.exec(\n\t\trange.trim(),\n\t);\n\treturn match ? `${match[1] ?? \"\"}${version}` : undefined;\n}\n","import type { Fact } from \"../../core/facts.ts\";\nimport { setPackageJsonVersion, withOperator } from \"../npm/package-json.ts\";\n\n/**\n * Where a kind of project keeps its version, and how to read and write it,\n * keeping everything else in the file as it was.\n */\nexport interface VersionFormat {\n\tname: string;\n\t/** Where it's usually kept, relative to a component's directory. */\n\tpath: string;\n\t/** Facts its versions need, e.g. `version.semver` for npm. */\n\tneeds?: readonly Fact[];\n\tread(text: string): string | undefined;\n\t/**\n\t * The text with the new version; dependencies on the given packages, by\n\t * name, are pointed at theirs where the format knows how.\n\t */\n\twrite(\n\t\ttext: string,\n\t\tversion: string,\n\t\tpackages: ReadonlyMap<string, string>,\n\t): { text: string; dependencies: string[] };\n\t/** The package's name, for other packages' dependencies on it. */\n\tpackageName?(text: string): string | undefined;\n}\n\nexport const FORMAT_NAMES = [\n\t\"plain\",\n\t\"npm\",\n\t\"cargo\",\n\t\"python\",\n\t\"helm\",\n\t\"gradle\",\n\t\"maven\",\n\t\"pattern\",\n] as const;\n\nexport type FormatName = (typeof FORMAT_NAMES)[number];\n\n/** The format by name; `pattern` needs its template, e.g. `VERSION = \"{version}\"`. */\nexport function versionFormat(\n\tname: FormatName,\n\tpattern?: string,\n): VersionFormat {\n\tswitch (name) {\n\t\tcase \"plain\":\n\t\t\treturn plain;\n\t\tcase \"npm\":\n\t\t\treturn npm;\n\t\tcase \"cargo\":\n\t\t\treturn cargo;\n\t\tcase \"python\":\n\t\t\treturn python;\n\t\tcase \"helm\":\n\t\t\treturn helm;\n\t\tcase \"gradle\":\n\t\t\treturn gradle;\n\t\tcase \"maven\":\n\t\t\treturn maven;\n\t\tcase \"pattern\":\n\t\t\tif (pattern === undefined) {\n\t\t\t\tthrow new Error(\"the pattern format needs a `pattern`\");\n\t\t\t}\n\t\t\treturn fromPattern(pattern);\n\t}\n}\n\nconst unchanged = (text: string) => ({ text, dependencies: [] });\n\nconst plain: VersionFormat = {\n\tname: \"plain\",\n\tpath: \"VERSION\",\n\tread: (text) => text.trim() || undefined,\n\t// Keep the file's trailing newline, or lack of one; new files get one.\n\twrite: (text, version) =>\n\t\tunchanged(`${version}${text === \"\" || text.endsWith(\"\\n\") ? \"\\n\" : \"\"}`),\n};\n\nconst npm: VersionFormat = {\n\tname: \"npm\",\n\tpath: \"package.json\",\n\tneeds: [\"version.semver\"],\n\tread: (text) => {\n\t\tconst json = parseJson(text);\n\t\treturn typeof json?.version === \"string\" && json.version !== \"\"\n\t\t\t? json.version\n\t\t\t: undefined;\n\t},\n\twrite: setPackageJsonVersion,\n\tpackageName: (text) => {\n\t\tconst name = parseJson(text)?.name;\n\t\treturn typeof name === \"string\" ? name : undefined;\n\t},\n};\n\nfunction parseJson(text: string): Record<string, unknown> | undefined {\n\ttry {\n\t\tconst json: unknown = JSON.parse(text);\n\t\treturn typeof json === \"object\" && json !== null\n\t\t\t? (json as Record<string, unknown>)\n\t\t\t: undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** `key = \"value\"` in the first of the TOML tables that has it. */\nfunction tomlKey(tables: readonly string[], key: string) {\n\tconst find = (text: string) => {\n\t\tconst lines = text.split(\"\\n\");\n\t\tfor (const table of tables) {\n\t\t\tlet inside = false;\n\t\t\tfor (const [index, line] of lines.entries()) {\n\t\t\t\tconst header = /^\\s*\\[([^[\\]]+)\\]\\s*(#.*)?$/.exec(line);\n\t\t\t\tif (header) {\n\t\t\t\t\tinside = header[1]?.trim() === table;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (/^\\s*\\[\\[/.test(line)) {\n\t\t\t\t\tinside = false;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst match = new RegExp(\n\t\t\t\t\t`^(\\\\s*${key}\\\\s*=\\\\s*)([\"'])([^\"']*)\\\\2(.*)$`,\n\t\t\t\t).exec(line);\n\t\t\t\tif (inside && match) return { lines, index, match };\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t};\n\treturn {\n\t\tread: (text: string) => find(text)?.match[3],\n\t\twrite: (text: string, value: string) => {\n\t\t\tconst found = find(text);\n\t\t\tif (!found) return undefined;\n\t\t\tconst [, before, quote, , after] = found.match;\n\t\t\tfound.lines[found.index] = `${before}${quote}${value}${quote}${after}`;\n\t\t\treturn found.lines.join(\"\\n\");\n\t\t},\n\t};\n}\n\nconst CARGO_TABLES = [\n\t\"dependencies\",\n\t\"dev-dependencies\",\n\t\"build-dependencies\",\n\t\"workspace.dependencies\",\n];\n\nconst cargoVersion = tomlKey([\"package\", \"workspace.package\"], \"version\");\nconst cargoName = tomlKey([\"package\"], \"name\");\n\nconst cargo: VersionFormat = {\n\tname: \"cargo\",\n\tpath: \"Cargo.toml\",\n\tneeds: [\"version.semver\"],\n\tread: cargoVersion.read,\n\twrite: (text, version, packages) => {\n\t\tconst written = cargoVersion.write(text, version);\n\t\tif (written === undefined) throw new Error(\"it has no [package] version\");\n\t\t// `name = { path = \"..\", version = \"1.2\" }` in dependency tables.\n\t\tconst dependencies: string[] = [];\n\t\tlet table = \"\";\n\t\tconst lines = written.split(\"\\n\").map((line) => {\n\t\t\tconst header = /^\\s*\\[([^[\\]]+)\\]/.exec(line);\n\t\t\tif (header) table = header[1]?.trim() ?? \"\";\n\t\t\tif (!CARGO_TABLES.some((name) => table.endsWith(name))) return line;\n\t\t\tconst match =\n\t\t\t\t/^(\\s*\"?([\\w-]+)\"?\\s*=\\s*\\{[^}]*\\bversion\\s*=\\s*\")([^\"]*)(\".*)$/.exec(\n\t\t\t\t\tline,\n\t\t\t\t);\n\t\t\tconst next = match?.[2] ? packages.get(match[2]) : undefined;\n\t\t\tconst range = match?.[3];\n\t\t\tif (!match || next === undefined || range === undefined) return line;\n\t\t\tconst updated = withOperator(range, next);\n\t\t\tif (updated === undefined || updated === range) return line;\n\t\t\tdependencies.push(`${match[2]}@${updated}`);\n\t\t\treturn `${match[1]}${updated}${match[4]}`;\n\t\t});\n\t\treturn { text: lines.join(\"\\n\"), dependencies };\n\t},\n\tpackageName: cargoName.read,\n};\n\nconst pythonVersion = tomlKey([\"project\", \"tool.poetry\"], \"version\");\n\nconst python: VersionFormat = {\n\tname: \"python\",\n\tpath: \"pyproject.toml\",\n\tread: pythonVersion.read,\n\twrite: (text, version) => {\n\t\tconst written = pythonVersion.write(text, version);\n\t\tif (written === undefined) {\n\t\t\tthrow new Error(\"it has no [project] or [tool.poetry] version\");\n\t\t}\n\t\treturn unchanged(written);\n\t},\n};\n\n/** A top-level `key: value` line, e.g. in YAML or a properties file. */\nfunction lineKey(name: string, path: string, pattern: RegExp): VersionFormat {\n\treturn {\n\t\tname,\n\t\tpath,\n\t\tread: (text) => pattern.exec(text)?.[3],\n\t\twrite: (text, version) => {\n\t\t\tif (!pattern.test(text)) throw new Error(`it has no ${name} version`);\n\t\t\treturn unchanged(\n\t\t\t\ttext.replace(\n\t\t\t\t\tpattern,\n\t\t\t\t\t(_, before: string, quote: string, __: string, after: string) =>\n\t\t\t\t\t\t`${before}${quote}${version}${quote}${after}`,\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t};\n}\n\nconst helm = lineKey(\n\t\"helm\",\n\t\"Chart.yaml\",\n\t/^(version:\\s*)([\"']?)([^\"'\\s#]+)\\2(.*)$/m,\n);\n\nconst gradle = lineKey(\n\t\"gradle\",\n\t\"gradle.properties\",\n\t/^(\\s*version\\s*[=:]\\s*)()([^\\s#]+)()$/m,\n);\n\n/** The project's own `<version>`: the one directly in `<project>`. */\nfunction mavenVersion(\n\ttext: string,\n): { start: number; end: number } | undefined {\n\tconst tags = /<!--[\\s\\S]*?-->|<\\?[\\s\\S]*?\\?>|<(\\/?)([\\w.:-]+)[^>]*?(\\/?)>/g;\n\tlet depth = 0;\n\tlet open: number | undefined;\n\tfor (const match of text.matchAll(tags)) {\n\t\tconst [whole, closing, name, selfClosing] = match;\n\t\tif (name === undefined || selfClosing) continue;\n\t\tif (closing) {\n\t\t\tdepth--;\n\t\t\tif (name === \"version\" && depth === 1 && open !== undefined) {\n\t\t\t\treturn { start: open, end: match.index };\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (name === \"version\" && depth === 1) open = match.index + whole.length;\n\t\tdepth++;\n\t}\n\treturn undefined;\n}\n\nconst maven: VersionFormat = {\n\tname: \"maven\",\n\tpath: \"pom.xml\",\n\tread: (text) => {\n\t\tconst found = mavenVersion(text);\n\t\treturn found ? text.slice(found.start, found.end).trim() : undefined;\n\t},\n\twrite: (text, version) => {\n\t\tconst found = mavenVersion(text);\n\t\tif (!found) throw new Error(\"it has no project <version>\");\n\t\treturn unchanged(\n\t\t\t`${text.slice(0, found.start)}${version}${text.slice(found.end)}`,\n\t\t);\n\t},\n};\n\n/**\n * Versions wherever a template matches, e.g. `__version__ = \"{version}\"`;\n * every match is written.\n */\nfunction fromPattern(template: string): VersionFormat {\n\tif (!template.includes(\"{version}\")) {\n\t\tthrow new Error(`the pattern '${template}' has no {version} placeholder`);\n\t}\n\tconst source = template\n\t\t.split(\"{version}\")\n\t\t.map((part) => part.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"))\n\t\t.join(\"([^\\\\s\\\"'`,;<>]+)\");\n\tconst pattern = new RegExp(source, \"g\");\n\treturn {\n\t\tname: \"pattern\",\n\t\tpath: \"\",\n\t\tread: (text) => new RegExp(source).exec(text)?.[1],\n\t\twrite: (text, version) => {\n\t\t\tif (!new RegExp(source).test(text)) {\n\t\t\t\tthrow new Error(`nothing matches '${template}'`);\n\t\t\t}\n\t\t\treturn unchanged(\n\t\t\t\ttext.replace(pattern, () => template.replaceAll(\"{version}\", version)),\n\t\t\t);\n\t\t},\n\t};\n}\n","import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { defineHistory } from \"../../core/history.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { FORMAT_NAMES, versionFormat } from \"../../steps/fs/formats.ts\";\nimport { findVersionCommit } from \"../../utils/git.ts\";\n\n/**\n * Finds the previous release in the project's version file: the version in\n * it, released at the commit that set it. For projects that kept their\n * version in a file before tagging releases, like `package.json` or a\n * `VERSION` file.\n */\nexport const fsVersionFile = defineHistory({\n\tname: \"fs/version-file\",\n\tdescription:\n\t\t\"The version in the project's version file, in any format `fs/write-version` writes, released at the commit that set it.\",\n\toptions: {\n\t\tformat: z\n\t\t\t.enum(FORMAT_NAMES)\n\t\t\t.default(\"plain\")\n\t\t\t.describe(\"As for `fs/write-version`.\"),\n\t\tpath: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Relative to the component's directory; defaults to the format's file.\",\n\t\t\t),\n\t\tpattern: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"With the `pattern` format, where the version is.\"),\n\t},\n\tcreate: (options) => {\n\t\tconst format = versionFormat(options.format, options.pattern);\n\t\tconst path = options.path ?? format.path;\n\t\tif (path === \"\") throw new Error(\"the pattern format needs a `path`\");\n\t\treturn {\n\t\t\tname: \"fs/version-file\",\n\t\t\tfind: async ({ env, component }) => {\n\t\t\t\tconst dir = join(env.cwd, component.path);\n\t\t\t\tconst shown = join(component.path, path).replaceAll(\"\\\\\", \"/\");\n\t\t\t\tconst version = format.read(await readFile(join(dir, path), \"utf8\"));\n\t\t\t\tif (version === undefined) throw new Error(`${shown} has no version`);\n\t\t\t\tconst ref = await findVersionCommit(dir, path, version, format.read);\n\t\t\t\treturn {\n\t\t\t\t\tversion,\n\t\t\t\t\t...(ref && { ref }),\n\t\t\t\t\treason: ref\n\t\t\t\t\t\t? `${version} in ${shown}, set in ${ref.slice(0, 7)}`\n\t\t\t\t\t\t: `${version} in ${shown}, not in git history`,\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t},\n});\n","import {\n\ttype Classified,\n\tclassify,\n\tcompareClassified,\n} from \"../../core/channels.ts\";\nimport { defineHistory, type HistoryInput } from \"../../core/history.ts\";\nimport { assertFullHistory, git, tryGit } from \"../../utils/git.ts\";\nimport { templatePattern } from \"../../utils/template.ts\";\nimport { parseVersion } from \"../../utils/version.ts\";\n\ninterface Tag {\n\tname: string;\n\tversion: string;\n\tcommit: string;\n\t/** When it was tagged, or for a lightweight tag, committed; in seconds. */\n\tdate: number;\n\tkind: Classified;\n}\n\nconst FIELD = \"\\x1f\";\n\n/**\n * Finds the previous release by its tag: the nearest on HEAD. Of the release\n * tags merged into HEAD, only those that no other one comes after count, so\n * a `1.x` branch finds its own latest release, not `main`'s; of those, the\n * highest version in the scheme wins. When the scheme changed since, the\n * nearest release still marks where changes start, but there's no previous\n * version to bump: the release is the scheme's first.\n *\n * A stable release only counts stable releases. On a channel, its own\n * releases count too, and the nearest stable release is what's bumped.\n */\nexport const gitTags = defineHistory({\n\tname: \"git/tags\",\n\tdescription:\n\t\t\"The nearest release tag on HEAD: the highest version among the tags no other release tag comes after. On a channel, its own releases count too.\",\n\tcreate: () => ({\n\t\tname: \"git/tags\",\n\t\tfind: async (input) => {\n\t\t\tconst cwd = input.env.cwd;\n\t\t\t// Not a git repository, or one without commits: no previous release.\n\t\t\tif (\n\t\t\t\t(await tryGit(cwd, \"rev-parse\", \"--verify\", \"--quiet\", \"HEAD\")) ===\n\t\t\t\tundefined\n\t\t\t) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tawait assertFullHistory(cwd);\n\t\t\tconst tags = await listTags(input, true);\n\t\t\tconst channel = input.channel?.name;\n\t\t\tconst counts = (tag: Tag) =>\n\t\t\t\ttag.kind.type === \"stable\" ||\n\t\t\t\ttag.kind.type === \"foreign\" ||\n\t\t\t\ttag.kind.channel === channel;\n\t\t\tconst best = await nearest(cwd, tags.filter(counts), input);\n\t\t\tif (!best) return undefined;\n\t\t\tconst at = `${best.name} at ${best.commit.slice(0, 7)}`;\n\t\t\tif (best.kind.type === \"foreign\") {\n\t\t\t\treturn {\n\t\t\t\t\tref: best.commit,\n\t\t\t\t\ttag: best.name,\n\t\t\t\t\treason: `${at}, nearest on HEAD; not ${input.scheme.name}, so this release is its first`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst stable =\n\t\t\t\tbest.kind.type === \"stable\"\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await nearest(\n\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\ttags.filter((tag) => tag.kind.type === \"stable\"),\n\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t);\n\t\t\treturn {\n\t\t\t\tversion: best.version,\n\t\t\t\tref: best.commit,\n\t\t\t\ttag: best.name,\n\t\t\t\treason: `${at}, nearest on HEAD${stable ? `; ${stable.version} before it` : \"\"}`,\n\t\t\t\t...(stable && {\n\t\t\t\t\tstable: {\n\t\t\t\t\t\tversion: stable.version,\n\t\t\t\t\t\tref: stable.commit,\n\t\t\t\t\t\ttag: stable.name,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t};\n\t\t},\n\t\tcount: async (input) => {\n\t\t\tconst channel = input.channel?.name;\n\t\t\tlet highest = 0;\n\t\t\tfor (const { kind } of await listTags(input, false)) {\n\t\t\t\tif (\n\t\t\t\t\tkind.type !== \"stable\" &&\n\t\t\t\t\tkind.type !== \"foreign\" &&\n\t\t\t\t\tkind.channel === channel &&\n\t\t\t\t\tinput.scheme.compare(kind.target, input.target) === 0\n\t\t\t\t) {\n\t\t\t\t\thighest = Math.max(highest, kind.n);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn highest;\n\t\t},\n\t\texists: async ({ env, releaseTag }) =>\n\t\t\t(await tryGit(\n\t\t\t\tenv.cwd,\n\t\t\t\t\"rev-parse\",\n\t\t\t\t\"--verify\",\n\t\t\t\t\"--quiet\",\n\t\t\t\t`refs/tags/${releaseTag}`,\n\t\t\t)) !== undefined,\n\t}),\n});\n\n/** Release tags, of HEAD or of the whole repository, classified. */\nasync function listTags(input: HistoryInput, merged: boolean): Promise<Tag[]> {\n\tconst pattern = templatePattern(input.tag, \"version\");\n\tconst listing = await git(\n\t\tinput.env.cwd,\n\t\t\"for-each-ref\",\n\t\t...(merged ? [\"--merged=HEAD\"] : []),\n\t\t`--format=%(refname:strip=2)${FIELD}%(objectname)${FIELD}%(*objectname)${FIELD}%(creatordate:unix)`,\n\t\t\"refs/tags\",\n\t);\n\tconst tags: Tag[] = [];\n\tfor (const line of listing.split(\"\\n\").filter(Boolean)) {\n\t\tconst [name = \"\", object = \"\", peeled = \"\", date = \"0\"] = line.split(FIELD);\n\t\tconst version = pattern.exec(name)?.[1];\n\t\tif (version === undefined) continue;\n\t\tconst kind = classify(version, input.scheme, input.channels);\n\t\t// Neither the scheme's nor a channel's, nor any version at all.\n\t\tif (kind.type === \"foreign\" && parseVersion(version) === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\ttags.push({\n\t\t\tname,\n\t\t\tversion,\n\t\t\tcommit: peeled || object,\n\t\t\tdate: Number(date),\n\t\t\tkind,\n\t\t});\n\t}\n\treturn tags;\n}\n\n/**\n * The nearest of the tags: of those no other one comes after, the highest\n * in the scheme, or failing that, the latest of another scheme.\n */\nasync function nearest(\n\tcwd: string,\n\ttags: readonly Tag[],\n\tinput: HistoryInput,\n): Promise<Tag | undefined> {\n\tif (tags.length === 0) return undefined;\n\tconst commits = [...new Set(tags.map((tag) => tag.commit))];\n\tconst frontier = new Set(\n\t\tcommits.length === 1\n\t\t\t? commits\n\t\t\t: (await git(cwd, \"merge-base\", \"--independent\", ...commits)).split(\"\\n\"),\n\t);\n\tconst near = tags.filter((tag) => frontier.has(tag.commit));\n\tconst ours = near.filter((tag) => tag.kind.type !== \"foreign\");\n\treturn ours.length > 0\n\t\t? ours.reduce((a, b) =>\n\t\t\t\tcompareClassified(b.kind, a.kind, input.scheme) > 0 ? b : a,\n\t\t\t)\n\t\t: near.reduce((a, b) => (b.date > a.date ? b : a));\n}\n","/** Waits; replaceable in tests. */\nexport const clock = {\n\tsleep: (ms: number): Promise<void> =>\n\t\tnew Promise((resolve) => setTimeout(resolve, ms)),\n};\n\nexport interface RetryOptions {\n\t/** Tries in all, the first included. */\n\tattempts: number;\n\t/** The wait before retry `n` (1-based); defaults to `n` seconds. */\n\tdelayMs?: (retry: number) => number;\n\t/** Whether an error is worth another try; defaults to every error. */\n\tretryIf?: (error: unknown) => boolean;\n}\n\n/** Calls `run` until it resolves, waiting longer before each retry. */\nexport async function retry<T>(\n\trun: (attempt: number) => Promise<T>,\n\toptions: RetryOptions,\n): Promise<T> {\n\tconst delayMs = options.delayMs ?? ((retry) => retry * 1000);\n\tfor (let attempt = 1; ; attempt++) {\n\t\ttry {\n\t\t\treturn await run(attempt);\n\t\t} catch (error) {\n\t\t\tif (attempt >= options.attempts || !(options.retryIf?.(error) ?? true)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tawait clock.sleep(delayMs(attempt));\n\t\t}\n\t}\n}\n\n/**\n * Polls `check` until it resolves with a value, e.g. until something another\n * job created becomes visible; resolves with `undefined` if it never does.\n */\nexport async function waitFor<T>(\n\tcheck: () => Promise<T | undefined>,\n\toptions: Omit<RetryOptions, \"retryIf\">,\n): Promise<T | undefined> {\n\ttry {\n\t\treturn await retry(\n\t\t\tasync () => {\n\t\t\t\tconst value = await check();\n\t\t\t\tif (value === undefined) throw new NotYet();\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t{ ...options, retryIf: (error) => error instanceof NotYet },\n\t\t);\n\t} catch (error) {\n\t\tif (error instanceof NotYet) return undefined;\n\t\tthrow error;\n\t}\n}\n\nclass NotYet extends Error {}\n","import { clock, retry } from \"../../utils/retry.ts\";\n\n/** The token option, `GITHUB_TOKEN` or `GH_TOKEN`. */\nexport function githubToken(token: string | undefined): string {\n\tconst found = token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;\n\tif (!found) throw new Error(\"no token; set GITHUB_TOKEN or GH_TOKEN\");\n\treturn found;\n}\n\nexport class GitHubError extends Error {\n\treadonly status: number;\n\n\tconstructor(status: number, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"GitHubError\";\n\t\tthis.status = status;\n\t}\n}\n\n/** Statuses worth another try: rate limits and server errors. */\nexport function isTransient(error: unknown): boolean {\n\tif (error instanceof GitHubError) {\n\t\treturn error.status === 429 || error.status >= 500;\n\t}\n\t// fetch rejects with a TypeError when the connection fails.\n\treturn error instanceof TypeError;\n}\n\ninterface RequestOptions {\n\tbody?: unknown;\n\t/** Sends `body` as is, with this content type, instead of as JSON. */\n\tcontentType?: string;\n\t/** Statuses that resolve instead of rejecting, e.g. `[404]`. */\n\tallow?: number[];\n\t/** Tries in all; defaults to 5. */\n\tattempts?: number;\n}\n\nexport interface GitHubClient {\n\treadonly repo: string;\n\t/** `path` is relative to the repository's API URL, unless it's a full URL. */\n\trequest<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\toptions?: RequestOptions,\n\t): Promise<{ status: number; data: T }>;\n}\n\n/** A GitHub REST client for one repository that retries transient failures. */\nexport function githubClient(repo: string, token: string): GitHubClient {\n\tconst apiUrl = process.env.GITHUB_API_URL ?? \"https://api.github.com\";\n\treturn {\n\t\trepo,\n\t\trequest: (method, path, options = {}) =>\n\t\t\tretry(\n\t\t\t\tasync () => {\n\t\t\t\t\tconst url = /^https?:/.test(path)\n\t\t\t\t\t\t? path\n\t\t\t\t\t\t: `${apiUrl}/repos/${repo}${path}`;\n\t\t\t\t\tconst response = await fetch(url, {\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\taccept: \"application/vnd.github+json\",\n\t\t\t\t\t\t\tauthorization: `Bearer ${token}`,\n\t\t\t\t\t\t\t\"x-github-api-version\": \"2022-11-28\",\n\t\t\t\t\t\t\t...(options.body !== undefined && {\n\t\t\t\t\t\t\t\t\"content-type\": options.contentType ?? \"application/json\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...(options.body !== undefined && {\n\t\t\t\t\t\t\tbody:\n\t\t\t\t\t\t\t\toptions.contentType === undefined\n\t\t\t\t\t\t\t\t\t? JSON.stringify(options.body)\n\t\t\t\t\t\t\t\t\t: (options.body as Uint8Array<ArrayBuffer>),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\tif (!response.ok && !options.allow?.includes(response.status)) {\n\t\t\t\t\t\t// GitHub asks to wait this long when rate limiting.\n\t\t\t\t\t\tconst wait = Number(response.headers.get(\"retry-after\"));\n\t\t\t\t\t\tif (response.status === 429 && wait > 0) {\n\t\t\t\t\t\t\tawait clock.sleep(Math.min(wait, 60) * 1000);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new GitHubError(\n\t\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\t\t`GitHub responded ${response.status} to ${method} ${url}: ${text}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: response.status,\n\t\t\t\t\t\tdata: (text ? JSON.parse(text) : null) as never,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{ attempts: options.attempts ?? 5, retryIf: isTransient },\n\t\t\t),\n\t};\n}\n","import { z } from \"../../core/options.ts\";\nimport { detectRepo } from \"../../utils/git.ts\";\nimport { retry, waitFor } from \"../../utils/retry.ts\";\nimport { type GitHubClient, GitHubError, isTransient } from \"./api.ts\";\n\n/** The `repo` option, or the repository being released. */\nexport async function releaseRepo(\n\tcwd: string,\n\trepo: string | undefined,\n): Promise<string> {\n\tconst found = repo ?? (await detectRepo(cwd));\n\tif (!found) {\n\t\tthrow new Error(\n\t\t\t\"couldn't determine the GitHub repository; set `repo` or GITHUB_REPOSITORY\",\n\t\t);\n\t}\n\treturn found;\n}\n\n/** Options of the steps that create a release, or find one. */\nexport const releaseOptions = {\n\ttitle: z\n\t\t.string()\n\t\t.default(\"{tag}\")\n\t\t.describe(\n\t\t\t\"`{tag}`, `{version}`, `{name}` and the scheme's placeholders are filled in.\",\n\t\t),\n\tdraft: z.boolean().default(false),\n\tprerelease: z\n\t\t.union([z.boolean(), z.literal(\"auto\")])\n\t\t.default(\"auto\")\n\t\t.describe(\"`auto` marks releases on a prerelease channel.\"),\n\trepo: z\n\t\t.string()\n\t\t.optional()\n\t\t.describe(\n\t\t\t\"`owner/repo`; defaults to `GITHUB_REPOSITORY` or the `origin` remote.\",\n\t\t),\n\ttoken: z\n\t\t.string()\n\t\t.optional()\n\t\t.describe(\"Defaults to `GITHUB_TOKEN` or `GH_TOKEN`.\"),\n};\n\nexport interface ReleaseAsset {\n\tid: number;\n\tname: string;\n\t/** `uploaded`, or `starter` when an upload never finished. */\n\tstate: string;\n\tsize: number;\n\tbrowser_download_url: string;\n}\n\nexport interface Release {\n\tid: number;\n\ttag_name: string;\n\thtml_url: string;\n\tupload_url: string;\n\tdraft: boolean;\n}\n\n/** The release of a tag, drafts included, or `undefined`. */\nasync function findRelease(\n\tclient: GitHubClient,\n\ttag: string,\n): Promise<Release | undefined> {\n\tconst { status, data } = await client.request<Release>(\n\t\t\"GET\",\n\t\t`/releases/tags/${encodeURIComponent(tag)}`,\n\t\t{ allow: [404] },\n\t);\n\tif (status !== 404) return data;\n\t// Drafts have no tag yet, so only a listing finds them.\n\tconst { data: releases } = await client.request<Release[]>(\n\t\t\"GET\",\n\t\t\"/releases?per_page=100\",\n\t);\n\treturn releases.find((release) => release.tag_name === tag);\n}\n\nexport interface NewRelease {\n\ttag: string;\n\ttarget: string;\n\ttitle: string;\n\tnotes: string;\n\tdraft: boolean;\n\tprerelease: boolean;\n}\n\n/**\n * Finds the release of a tag, or creates it. Other jobs may be doing the same\n * at once: when one of them wins, this waits until its release is visible and\n * uses that.\n */\nexport async function ensureRelease(\n\tclient: GitHubClient,\n\trelease: NewRelease,\n): Promise<{ release: Release; created: boolean }> {\n\tconst existing = await findRelease(client, release.tag);\n\tif (existing) return { release: existing, created: false };\n\ttry {\n\t\tconst { data } = await client.request<Release>(\"POST\", \"/releases\", {\n\t\t\tbody: {\n\t\t\t\ttag_name: release.tag,\n\t\t\t\ttarget_commitish: release.target,\n\t\t\t\tname: release.title,\n\t\t\t\tbody: release.notes,\n\t\t\t\tdraft: release.draft,\n\t\t\t\tprerelease: release.prerelease,\n\t\t\t},\n\t\t});\n\t\treturn { release: data, created: true };\n\t} catch (error) {\n\t\t// 422: the tag already has a release, created since we looked.\n\t\tif (!(error instanceof GitHubError && error.status === 422)) throw error;\n\t\tconst created = await waitFor(() => findRelease(client, release.tag), {\n\t\t\tattempts: 5,\n\t\t});\n\t\tif (!created) throw error;\n\t\treturn { release: created, created: false };\n\t}\n}\n\n/** The name GitHub stores an asset under, e.g. `My App.zip` → `My.App.zip`. */\nexport function assetName(file: string): string {\n\treturn file.replace(/[^\\w.+@~-]/g, \".\");\n}\n\nasync function listAssets(\n\tclient: GitHubClient,\n\trelease: Release,\n): Promise<ReleaseAsset[]> {\n\tconst assets: ReleaseAsset[] = [];\n\tfor (let page = 1; ; page++) {\n\t\tconst { data } = await client.request<ReleaseAsset[]>(\n\t\t\t\"GET\",\n\t\t\t`/releases/${release.id}/assets?per_page=100&page=${page}`,\n\t\t);\n\t\tassets.push(...data);\n\t\tif (data.length < 100) return assets;\n\t}\n}\n\n/**\n * Uploads a file as an asset of the release, retrying failed uploads. An\n * asset of the same name is replaced if `clobber` is set, or if it's what's\n * left of an unfinished upload.\n */\nexport async function uploadAsset(\n\tclient: GitHubClient,\n\trelease: Release,\n\tasset: { name: string; content: Uint8Array },\n\tclobber: boolean,\n): Promise<ReleaseAsset> {\n\tconst name = assetName(asset.name);\n\treturn retry(\n\t\tasync () => {\n\t\t\tconst existing = (await listAssets(client, release)).find(\n\t\t\t\t(other) => other.name === name,\n\t\t\t);\n\t\t\tif (existing) {\n\t\t\t\tif (existing.state === \"uploaded\" && !clobber) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`release ${release.tag_name} already has ${name}; set clobber to replace it`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait client.request(\"DELETE\", `/releases/assets/${existing.id}`, {\n\t\t\t\t\tallow: [404],\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst url = new URL(release.upload_url.replace(/\\{.*\\}$/, \"\"));\n\t\t\turl.searchParams.set(\"name\", asset.name);\n\t\t\tconst { data } = await client.request<ReleaseAsset>(\"POST\", url.href, {\n\t\t\t\tbody: asset.content,\n\t\t\t\tcontentType: \"application/octet-stream\",\n\t\t\t\t// Retried as a whole, after clearing what a failed upload left.\n\t\t\t\tattempts: 1,\n\t\t\t});\n\t\t\treturn data;\n\t\t},\n\t\t{ attempts: 5, retryIf: isTransient },\n\t);\n}\n\n/** Whether a release is a prerelease, by the `prerelease` option. */\nexport function isPrerelease(\n\toption: boolean | \"auto\",\n\tenv: { channel?: { type: string } },\n): boolean {\n\treturn option === \"auto\" ? env.channel?.type === \"prerelease\" : option;\n}\n","import type { Kind } from \"../../core/types.ts\";\n\n/** The branch prefix of release pull requests, and their label until released. */\nexport const RELEASE_BRANCH = \"rylease/\";\nexport const PENDING_LABEL = \"rylease: pending\";\n\n/** What a release pull request releases once it merges, by component. */\nexport interface Manifest {\n\tcomponents: Record<\n\t\tstring,\n\t\t{\n\t\t\tversion: string;\n\t\t\ttag: string;\n\t\t\tkind: Kind;\n\t\t\tpreviousVersion?: string;\n\t\t\tnotes: string;\n\t\t}\n\t>;\n}\n\nconst MARKER = /<!-- rylease (\\{[\\s\\S]*?\\}) -->\\s*$/;\n\n/** A pull request's body: each release's notes, then the manifest, hidden. */\nexport function releaseBody(manifest: Manifest): string {\n\tconst sections = Object.values(manifest.components).map(\n\t\t({ tag, notes }) => `## ${tag}\\n\\n${notes.trim() || \"_No notes._\"}`,\n\t);\n\treturn `${sections.join(\"\\n\\n\")}\\n\\n<!-- rylease ${JSON.stringify(manifest)} -->\\n`;\n}\n\n/** The manifest in a pull request's body, if it has a valid one. */\nexport function readManifest(body: string | null): Manifest | undefined {\n\tconst json = MARKER.exec(body ?? \"\")?.[1];\n\tif (json === undefined) return undefined;\n\ttry {\n\t\tconst manifest = JSON.parse(json) as Manifest;\n\t\treturn typeof manifest.components === \"object\" ? manifest : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n","import { defineHistory, type Found } from \"../../core/history.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { githubClient, githubToken } from \"../../steps/github/api.ts\";\nimport { releaseRepo } from \"../../steps/github/release.ts\";\nimport {\n\ttype Manifest,\n\tPENDING_LABEL,\n\tRELEASE_BRANCH,\n\treadManifest,\n} from \"../../steps/github/release-pr.ts\";\nimport { git, tryGit } from \"../../utils/git.ts\";\nimport { gitTags } from \"../git/git-tags.ts\";\n\ninterface PullRequest {\n\tnumber: number;\n\tbody: string | null;\n\tmerged_at: string | null;\n\thead: { ref: string };\n\tlabels: { name: string }[];\n}\n\n/**\n * Finds a release that a merged release pull request proposed: when HEAD is\n * its merge, the release steps run for the versions it proposed, with its\n * notes. Components it doesn't name, or whose tag exists already, are found\n * by their tags, as with `git/tags`.\n */\nexport const githubReleasePr = defineHistory({\n\tname: \"github/release-pr\",\n\tdescription:\n\t\t\"A release proposed by a release pull request from `github/open-release-pr`, once it's merged; otherwise the nearest release tag on HEAD, as `git/tags`.\",\n\toptions: {\n\t\tlabel: z\n\t\t\t.string()\n\t\t\t.default(PENDING_LABEL)\n\t\t\t.describe(\"The label of release pull requests not yet released.\"),\n\t\trepo: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"`owner/repo`; defaults to `GITHUB_REPOSITORY` or the `origin` remote.\",\n\t\t\t),\n\t\ttoken: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Defaults to `GITHUB_TOKEN` or `GH_TOKEN`.\"),\n\t},\n\tcreate: (options) => {\n\t\tconst tags = gitTags();\n\t\t// Looked up once per run, for every component.\n\t\tlet merged:\n\t\t\t| Promise<{ number: number; manifest: Manifest } | undefined>\n\t\t\t| undefined;\n\t\tconst find = async (cwd: string) => {\n\t\t\tconst head = await tryGit(cwd, \"rev-parse\", \"HEAD\");\n\t\t\tif (head === undefined) return undefined;\n\t\t\tconst client = githubClient(\n\t\t\t\tawait releaseRepo(cwd, options.repo),\n\t\t\t\tgithubToken(options.token),\n\t\t\t);\n\t\t\tconst { data } = await client.request<PullRequest[]>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/commits/${head}/pulls`,\n\t\t\t);\n\t\t\tfor (const pull of data) {\n\t\t\t\tconst manifest = readManifest(pull.body);\n\t\t\t\tif (\n\t\t\t\t\tpull.merged_at &&\n\t\t\t\t\tpull.head.ref.startsWith(RELEASE_BRANCH) &&\n\t\t\t\t\tpull.labels.some((label) => label.name === options.label) &&\n\t\t\t\t\tmanifest\n\t\t\t\t) {\n\t\t\t\t\treturn { number: pull.number, manifest };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn undefined;\n\t\t};\n\t\treturn {\n\t\t\tname: \"github/release-pr\",\n\t\t\tfind: async (input) => {\n\t\t\t\tmerged ??= find(input.env.cwd);\n\t\t\t\tconst pull = await merged;\n\t\t\t\tconst entry = pull?.manifest.components[input.component.name];\n\t\t\t\tconst released =\n\t\t\t\t\tentry === undefined ||\n\t\t\t\t\t(await tryGit(\n\t\t\t\t\t\tinput.env.cwd,\n\t\t\t\t\t\t\"rev-parse\",\n\t\t\t\t\t\t\"--verify\",\n\t\t\t\t\t\t\"--quiet\",\n\t\t\t\t\t\t`refs/tags/${entry.tag}`,\n\t\t\t\t\t)) !== undefined;\n\t\t\t\tif (!pull || !entry || released) return tags.find(input);\n\t\t\t\tconst head = await git(input.env.cwd, \"rev-parse\", \"HEAD\");\n\t\t\t\tconst found: Found = {\n\t\t\t\t\t...(entry.previousVersion !== undefined && {\n\t\t\t\t\t\tversion: entry.previousVersion,\n\t\t\t\t\t}),\n\t\t\t\t\treason: `#${pull.number} merged at ${head.slice(0, 7)}`,\n\t\t\t\t\tpending: {\n\t\t\t\t\t\tversion: entry.version,\n\t\t\t\t\t\tnotes: entry.notes,\n\t\t\t\t\t\tkind: entry.kind === \"none\" ? \"fix\" : entry.kind,\n\t\t\t\t\t\t...(entry.previousVersion !== undefined && {\n\t\t\t\t\t\t\tpreviousVersion: entry.previousVersion,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\treason: `proposed in #${pull.number}`,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn found;\n\t\t\t},\n\t\t\tcount: (input) => tags.count?.(input) ?? Promise.resolve(0),\n\t\t\texists: (input) => tags.exists?.(input) ?? Promise.resolve(false),\n\t\t};\n\t},\n});\n","export * from \"./fs/index.ts\";\nexport * from \"./git/index.ts\";\nexport * from \"./github/index.ts\";\n","import { z } from \"../core/options.ts\";\nimport type { Environment } from \"../core/types.ts\";\n\n/** The `channels` option of steps that a channel's releases skip by default. */\nexport const channelsOption = z\n\t.boolean()\n\t.default(false)\n\t.describe(\n\t\t\"Also run for releases on a channel, e.g. prereleases; by default only stable releases do.\",\n\t);\n\n/**\n * For a step that leaves channel releases to the stable release, e.g. so a\n * prerelease doesn't take the changelog's entries: its output when it's\n * skipped, or `undefined` when it runs.\n */\nexport function skipOnChannel(\n\tenv: Environment,\n\tchannels: boolean,\n\twhat: string,\n): { output: null; reason: string } | undefined {\n\tif (!env.channel || channels) return undefined;\n\treturn {\n\t\toutput: null,\n\t\treason: `left ${what} for the stable release, as this is on ${env.channel.name}`,\n\t};\n}\n","import { KINDS, type Kind } from \"../../core/types.ts\";\n\n/** A change file: kinds by component, then what changed. */\nexport interface ChangeFile {\n\t/** Kinds by component name; `kind` alone stands for the only component. */\n\tkinds: Record<string, Kind>;\n\ttitle: string;\n\tdescription?: string;\n}\n\n/**\n * Parses a change file:\n *\n * ```md\n * ---\n * \"@x/core\": feature\n * cli: fix\n * ---\n * Add dark mode.\n *\n * More about it.\n * ```\n */\nexport function parseChangeFile(text: string, path: string): ChangeFile {\n\tconst lines = text.replace(/^/, \"\").split(/\\r?\\n/);\n\tif (lines[0]?.trim() !== \"---\") {\n\t\tthrow new Error(`${path} must start with '---', then kinds by component`);\n\t}\n\tconst end = lines.findIndex((line, i) => i > 0 && line.trim() === \"---\");\n\tif (end === -1) throw new Error(`${path} has no closing '---'`);\n\tconst kinds: Record<string, Kind> = {};\n\tfor (const [i, line] of lines.slice(1, end).entries()) {\n\t\tif (line.trim() === \"\" || line.trim().startsWith(\"#\")) continue;\n\t\tconst match = /^\\s*(?:\"([^\"]+)\"|'([^']+)'|([^:\\s]+))\\s*:\\s*(\\S+)\\s*$/.exec(\n\t\t\tline,\n\t\t);\n\t\tconst name = match?.[1] ?? match?.[2] ?? match?.[3];\n\t\tconst kind = match?.[4];\n\t\tif (name === undefined || kind === undefined) {\n\t\t\tthrow new Error(`${path} line ${i + 2}: expected 'component: kind'`);\n\t\t}\n\t\tif (!(KINDS as readonly string[]).includes(kind)) {\n\t\t\tthrow new Error(\n\t\t\t\t`${path} line ${i + 2}: '${kind}' isn't a kind; use ${KINDS.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t\tkinds[name] = kind as Kind;\n\t}\n\tconst body = lines\n\t\t.slice(end + 1)\n\t\t.join(\"\\n\")\n\t\t.trim();\n\tconst [title = \"\", ...rest] = body.split(\"\\n\");\n\tif (title.trim() === \"\")\n\t\tthrow new Error(`${path} says nothing after its kinds`);\n\tconst description = rest.join(\"\\n\").trim();\n\treturn {\n\t\tkinds,\n\t\ttitle: title.trim(),\n\t\t...(description && { description }),\n\t};\n}\n\n/** A change file's text, as `rylease add` writes it. */\nexport function formatChangeFile(file: ChangeFile): string {\n\tconst kinds = Object.entries(file.kinds).map(\n\t\t([name, kind]) =>\n\t\t\t`${/^[\\w-]+$/.test(name) ? name : JSON.stringify(name)}: ${kind}`,\n\t);\n\treturn `---\\n${kinds.join(\"\\n\")}\\n---\\n${file.title}\\n${file.description ? `\\n${file.description}\\n` : \"\"}`;\n}\n\n/** A file name from a change's title, e.g. `add-dark-mode`. */\nexport function slug(title: string): string {\n\treturn (\n\t\ttitle\n\t\t\t.toLowerCase()\n\t\t\t.replace(/[^a-z0-9]+/g, \"-\")\n\t\t\t.replace(/^-+|-+$/g, \"\")\n\t\t\t.slice(0, 48)\n\t\t\t.replace(/-+$/, \"\") || \"change\"\n\t);\n}\n","import { readdir, readFile } from \"node:fs/promises\";\nimport { join, posix } from \"node:path\";\nimport { z } from \"../../core/options.ts\";\nimport { type ChangeFile, parseChangeFile } from \"./parse.ts\";\n\nexport const directoryOption = z\n\t.string()\n\t.default(\".changes\")\n\t.describe(\"Where change files are kept, relative to the project.\");\n\n/** Every change file in the directory, parsed, by its path in the project. */\nexport async function readChangeFiles(\n\tcwd: string,\n\tdirectory: string,\n): Promise<{ path: string; file: ChangeFile }[]> {\n\tconst names = await readdir(join(cwd, directory)).catch((error: unknown) => {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\tthrow error;\n\t});\n\tconst files = [];\n\tfor (const name of names.filter((name) => name.endsWith(\".md\")).sort()) {\n\t\tif (name.toLowerCase() === \"readme.md\") continue;\n\t\tconst path = posix.join(directory.replaceAll(\"\\\\\", \"/\"), name);\n\t\tfiles.push({\n\t\t\tpath,\n\t\t\tfile: parseChangeFile(await readFile(join(cwd, path), \"utf8\"), path),\n\t\t});\n\t}\n\treturn files;\n}\n\n/**\n * The kind a change file gives a component: its own, or `kind` when the\n * component is the only one.\n */\nexport function kindFor(\n\tfile: ChangeFile,\n\tcomponent: string,\n\tonly: boolean,\n): string | undefined {\n\treturn file.kinds[component] ?? (only ? file.kinds.kind : undefined);\n}\n","import { rm } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { defineStep } from \"../../core/define.ts\";\nimport { joinList, plural } from \"../../utils/text.ts\";\nimport { channelsOption, skipOnChannel } from \"../channels.ts\";\nimport { directoryOption, kindFor, readChangeFiles } from \"./files.ts\";\n\n/**\n * Deletes the change files a release consumed, those naming a component\n * that's released, and reports them for `git/commit` to commit their\n * deletion. Releases on a channel leave them for the stable release.\n */\nexport const changeFilesClean = defineStep({\n\tphase: \"write\",\n\tname: \"change-files/clean\",\n\tscope: \"all\",\n\tdescription:\n\t\t\"Deletes the change files of the components being released, for `git/commit` to commit; releases on a channel leave them for the stable release.\",\n\toptions: { directory: directoryOption, channels: channelsOption },\n\trun: async ({ env, components, options }) => {\n\t\tconst skipped = skipOnChannel(env, options.channels, \"the change files\");\n\t\tif (skipped) return skipped;\n\t\tconst only =\n\t\t\tcomponents.length === 1 && components[0]?.component.path === \".\";\n\t\tconst released = components.map(({ component }) => component.name);\n\t\tconst files = (await readChangeFiles(env.cwd, options.directory))\n\t\t\t.filter(({ file }) =>\n\t\t\t\treleased.some((name) => kindFor(file, name, only) !== undefined),\n\t\t\t)\n\t\t\t.map(({ path }) => path);\n\t\tif (files.length === 0) {\n\t\t\treturn { output: { deleted: [] }, reason: \"no change files to delete\" };\n\t\t}\n\t\tif (!env.dryRun) {\n\t\t\tfor (const path of files) await rm(join(env.cwd, path));\n\t\t}\n\t\treturn {\n\t\t\toutput: { deleted: env.dryRun ? [] : files },\n\t\t\tfiles,\n\t\t\treason: `${env.dryRun ? \"would delete\" : \"deleted\"} ${files.length > 3 ? plural(files.length, \"change file\") : joinList(files)}`,\n\t\t};\n\t},\n});\n","import { defineStep } from \"../../core/define.ts\";\nimport type { ChangeWith } from \"../../core/types.ts\";\nimport { plural } from \"../../utils/text.ts\";\nimport { directoryOption, kindFor, readChangeFiles } from \"./files.ts\";\n\n/**\n * Collects the change files in `.changes/`: each says what changed, and\n * how much for each component it names. A change's label is its kind, for\n * `labels/determine-kind` and `labels/determine-notes`.\n */\nexport const changeFilesRead = defineStep({\n\tphase: \"read-changes\",\n\tname: \"change-files/read\",\n\tscope: \"all\",\n\tprovides: [\"changes.title\", \"changes.labels\"],\n\tdescription:\n\t\t\"Collects the change files in `.changes/`, each naming the components it changes and how much, e.g. `core: feature`; each change is labeled with its kind.\",\n\toptions: { directory: directoryOption },\n\trun: async ({ env, components, options }) => {\n\t\tconst files = await readChangeFiles(env.cwd, options.directory);\n\t\tconst names = new Set(components.map(({ component }) => component.name));\n\t\t// `kind` alone is for a project that's one component, as a whole.\n\t\tconst only =\n\t\t\tcomponents.length === 1 && components[0]?.component.path === \".\";\n\t\tfor (const { path, file } of files) {\n\t\t\tfor (const name of Object.keys(file.kinds)) {\n\t\t\t\tif (names.has(name) || (only && name === \"kind\")) continue;\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${path} names '${name}', which isn't a component; use ${only ? \"kind\" : [...names].join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst results: Record<\n\t\t\tstring,\n\t\t\t{ changes: ChangeWith<\"title\" | \"labels\">[]; reason: string }\n\t\t> = {};\n\t\tfor (const { component } of components) {\n\t\t\tconst changes = files.flatMap(({ path, file }) => {\n\t\t\t\tconst kind = kindFor(file, component.name, only);\n\t\t\t\treturn kind === undefined\n\t\t\t\t\t? []\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: file.title,\n\t\t\t\t\t\t\t\t...(file.description && { description: file.description }),\n\t\t\t\t\t\t\t\tlabels: [kind],\n\t\t\t\t\t\t\t\treason: path,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t];\n\t\t\t});\n\t\t\tresults[component.name] = {\n\t\t\t\tchanges,\n\t\t\t\treason: `${plural(changes.length, \"change file\")} in ${options.directory}`,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tresults,\n\t\t\treason: `${plural(files.length, \"change file\")} in ${options.directory}`,\n\t\t};\n\t},\n});\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport type { Kind } from \"../../core/types.ts\";\nimport { joinList, plural } from \"../../utils/text.ts\";\n\nconst RANK: Record<Kind, number> = { none: 0, fix: 1, feature: 2, breaking: 3 };\n\n/**\n * Releases the components that depend on a released component, so their\n * releases pick up the new version, e.g. with `npm/write-version` updating\n * their dependency on it. Dependents of dependents follow.\n */\nexport const componentsDependents = defineStep({\n\tphase: \"determine-kind\",\n\tname: \"components/dependents\",\n\tscope: \"all\",\n\tdescription:\n\t\t\"Releases each component that depends on a released one, as at least a `fix`; list it after the steps that determine kinds.\",\n\toptions: {\n\t\tkind: z\n\t\t\t.enum([\"breaking\", \"feature\", \"fix\"])\n\t\t\t.default(\"fix\")\n\t\t\t.describe(\"The least kind of a dependent's release.\"),\n\t\ton: z\n\t\t\t.array(z.enum([\"breaking\", \"feature\", \"fix\"]))\n\t\t\t.default([\"breaking\", \"feature\", \"fix\"])\n\t\t\t.describe(\n\t\t\t\t\"The kinds of a dependency's release that release its dependents.\",\n\t\t\t),\n\t},\n\trun: ({ components, options }) => {\n\t\tconst kinds = new Map(\n\t\t\tcomponents.map(({ component, kind }) => [component.name, kind ?? \"none\"]),\n\t\t);\n\t\tconst results: Record<string, { kind: Kind; reason: string }> = {};\n\t\t// Dependencies come first, so their own raised kinds count.\n\t\tfor (const { component } of components) {\n\t\t\tconst released = component.dependsOn.filter((name) => {\n\t\t\t\tconst kind = kinds.get(name) ?? \"none\";\n\t\t\t\treturn kind !== \"none\" && options.on.includes(kind);\n\t\t\t});\n\t\t\tconst current = kinds.get(component.name) ?? \"none\";\n\t\t\tif (released.length === 0 || RANK[current] >= RANK[options.kind]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tkinds.set(component.name, options.kind);\n\t\t\tresults[component.name] = {\n\t\t\t\tkind: options.kind,\n\t\t\t\treason: `depends on ${joinList(released)}, released too`,\n\t\t\t};\n\t\t}\n\t\tconst raised = Object.keys(results);\n\t\treturn {\n\t\t\tresults,\n\t\t\treason:\n\t\t\t\traised.length > 0\n\t\t\t\t\t? `${plural(raised.length, \"dependent\")} released: ${joinList(raised)}`\n\t\t\t\t\t: \"no dependents of released components\",\n\t\t};\n\t},\n});\n","import type { Change, Kind } from \"../../core/types.ts\";\n\n/** A conventional commit header, e.g. `feat(api)!: drop node 18`. */\nconst HEADER = /^([a-z][\\w-]*)(?:\\(([^()]*)\\))?(!)?: (.+)$/;\nconst BREAKING = /\\bBREAKING(?:[ -]CHANGES?)?\\b/;\n\nexport interface Section {\n\t/** The header line, e.g. `fix(x)!: handle nulls`. */\n\ttitle: string;\n\t/** Lines following the header, up to the next header. */\n\tdescription?: string;\n}\n\nexport interface Title {\n\ttype: string;\n\tscope?: string;\n\tbreaking: boolean;\n\tsubject: string;\n}\n\n/**\n * Splits a commit message into conventional sections. Every line that looks\n * like a conventional header starts a new section, so squashed messages with\n * several entries yield several sections. Types must start lowercase, so\n * footers like `Refs: #12` aren't mistaken for headers. Text before the first\n * header (e.g. a merge commit's subject) is ignored.\n */\nexport function parseSections(message: string): Section[] {\n\tconst sections: { title: string; lines: string[] }[] = [];\n\tfor (const line of message.split(/\\r?\\n/)) {\n\t\tif (HEADER.test(line.trim())) {\n\t\t\tsections.push({ title: line.trim(), lines: [] });\n\t\t} else {\n\t\t\tsections.at(-1)?.lines.push(line);\n\t\t}\n\t}\n\treturn sections.map(({ title, lines }) => {\n\t\tconst description = lines.join(\"\\n\").trim();\n\t\treturn description ? { title, description } : { title };\n\t});\n}\n\nexport function parseTitle(title: string): Title | undefined {\n\tconst match = HEADER.exec(title.trim());\n\tif (!match) return undefined;\n\tconst [, type = \"\", scope, bang, subject = \"\"] = match;\n\treturn {\n\t\ttype,\n\t\t...(scope ? { scope } : {}),\n\t\tbreaking: bang === \"!\",\n\t\tsubject,\n\t};\n}\n\n/** Whether a text mentions a breaking change (`BREAKING CHANGE:`, `BREAKING-CHANGE`, ...). */\nexport function mentionsBreaking(text: string | undefined): boolean {\n\treturn text !== undefined && BREAKING.test(text);\n}\n\n/**\n * How a change maps to a kind: `types` by `type(scope)` first, then by `type`;\n * anything else, untyped changes included, is `fallback`.\n */\nexport interface KindRules {\n\ttypes: Readonly<Record<string, Kind>>;\n\tfallback: Kind;\n}\n\n/** `!` or `BREAKING` → breaking; otherwise by the rules (by default `feat` → feature, the rest → fix). */\nexport function classify(\n\tchange: Change,\n\trules: KindRules = { types: { feat: \"feature\" }, fallback: \"fix\" },\n): { kind: Kind; reason: string } {\n\tconst source = `(${change.reason})`;\n\tconst title =\n\t\tchange.title === undefined ? undefined : parseTitle(change.title);\n\tconst prefix = title\n\t\t? `${title.type}${title.scope ? `(${title.scope})` : \"\"}${title.breaking ? \"!\" : \"\"}`\n\t\t: undefined;\n\tif (title?.breaking) {\n\t\treturn { kind: \"breaking\", reason: `'${prefix}' in title ${source}` };\n\t}\n\tif (mentionsBreaking(change.title)) {\n\t\treturn { kind: \"breaking\", reason: `'BREAKING' in title ${source}` };\n\t}\n\tif (mentionsBreaking(change.description)) {\n\t\treturn { kind: \"breaking\", reason: `'BREAKING' in description ${source}` };\n\t}\n\tif (!title) {\n\t\treturn { kind: rules.fallback, reason: `untyped change ${source}` };\n\t}\n\treturn {\n\t\tkind: typeKey(title, rules.types) ?? rules.fallback,\n\t\treason: `'${prefix}' in title ${source}`,\n\t};\n}\n\n/** Looks up `type(scope)`, then `type`, in a map keyed by either. */\nexport function typeKey<V>(\n\ttitle: Title,\n\tmap: Readonly<Record<string, V>>,\n): V | undefined {\n\tconst scoped = title.scope ? map[`${title.type}(${title.scope})`] : undefined;\n\treturn scoped ?? map[title.type];\n}\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { KINDS, type Kind } from \"../../core/types.ts\";\nimport { classify } from \"./classify.ts\";\n\nconst RANK: Record<Kind, number> = { none: 0, fix: 1, feature: 2, breaking: 3 };\n\n/**\n * `!` or `BREAKING` → breaking; otherwise each change's kind comes from its\n * conventional type, and the highest kind wins.\n */\nexport const conventionalDetermineKind = defineStep({\n\tphase: \"determine-kind\",\n\tname: \"conventional/determine-kind\",\n\tdescription:\n\t\t\"`!` or `BREAKING` → breaking; otherwise by conventional type (`feat` → feature, anything else → fix). The highest kind wins.\",\n\toptions: {\n\t\ttypes: z\n\t\t\t.record(z.string(), z.enum(KINDS))\n\t\t\t.default({})\n\t\t\t.describe(\n\t\t\t\t\"Kinds by `type` or `type(scope)`, on top of `feat: feature`, e.g. `{ docs: none, chore(deps): fix }`.\",\n\t\t\t),\n\t\tfallback: z\n\t\t\t.enum(KINDS)\n\t\t\t.default(\"fix\")\n\t\t\t.describe(\"The kind of any other change, untyped ones included.\"),\n\t},\n\trun: ({ changes, options }) => {\n\t\tconst rules = {\n\t\t\ttypes: { feat: \"feature\", ...options.types } as const,\n\t\t\tfallback: options.fallback,\n\t\t};\n\t\tlet best: { kind: Kind; reason: string } | undefined;\n\t\tfor (const change of changes) {\n\t\t\tconst candidate = classify(change, rules);\n\t\t\tif (!best || RANK[candidate.kind] > RANK[best.kind]) best = candidate;\n\t\t\tif (best.kind === \"breaking\") break;\n\t\t}\n\t\treturn best ?? { kind: \"none\", reason: \"no changes\" };\n\t},\n});\n","import { z } from \"../core/options.ts\";\nimport type { Dependency, ReleaseKind } from \"../core/types.ts\";\n\n/** The `dependencies` option of the steps that build notes. */\nexport const dependenciesOption = z\n\t.union([z.string(), z.literal(false)])\n\t.default(\"Dependencies\")\n\t.describe(\n\t\t\"The last section, for the components it depends on that were released along with it; `false` leaves it out.\",\n\t);\n\n/** A section of notes, as the steps that build notes collect them. */\nexport interface Section {\n\ttitle: string;\n\tentries: string[];\n}\n\n/** A section listing released dependencies, e.g. `- core 1.2.0 → 2.0.0`. */\nexport function dependencySection(\n\ttitle: string | false,\n\tdependencies: readonly Dependency[],\n): Section[] {\n\tif (title === false || dependencies.length === 0) return [];\n\treturn [\n\t\t{\n\t\t\ttitle,\n\t\t\tentries: dependencies.map(({ name, version, previousVersion }) =>\n\t\t\t\tpreviousVersion === undefined\n\t\t\t\t\t? `- ${name} ${version}`\n\t\t\t\t\t: `- ${name} ${previousVersion} → ${version}`,\n\t\t\t),\n\t\t},\n\t];\n}\n\n/** Notes from the sections that have entries, and their reason. */\nexport function joinSections(\n\tkind: ReleaseKind,\n\tsections: readonly Section[],\n): { notes: string; reason: string } {\n\tconst filled = sections.filter(({ entries }) => entries.length > 0);\n\treturn {\n\t\tnotes: filled\n\t\t\t.map(({ title, entries }) => `### ${title}\\n\\n${entries.join(\"\\n\")}`)\n\t\t\t.join(\"\\n\\n\"),\n\t\treason: `${kind} release; ${\n\t\t\tfilled\n\t\t\t\t.map(\n\t\t\t\t\t({ title, entries }) => `${title.toLowerCase()}: ${entries.length}`,\n\t\t\t\t)\n\t\t\t\t.join(\", \") || \"no entries\"\n\t\t}`,\n\t};\n}\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport type { Change } from \"../../core/types.ts\";\nimport {\n\tdependenciesOption,\n\tdependencySection,\n\tjoinSections,\n} from \"../notes.ts\";\nimport { mentionsBreaking, parseTitle, type Title } from \"./classify.ts\";\n\n/**\n * A `### Title` section for breaking changes, then one per group of\n * conventional types, then the rest.\n */\nexport const conventionalBuildNotes = defineStep({\n\tphase: \"determine-notes\",\n\tname: \"conventional/determine-notes\",\n\tdescription:\n\t\t\"`### Breaking Changes`, `### Features`, `### Bug Fixes`, `### Performance Improvements` and `### Reverts` sections, then `### Other` for everything else.\",\n\toptions: {\n\t\tsections: z\n\t\t\t.array(\n\t\t\t\tz.strictObject({\n\t\t\t\t\ttitle: z.string(),\n\t\t\t\t\ttypes: z.array(z.string()).describe(\"`type` or `type(scope)`\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.default([\n\t\t\t\t{ title: \"Features\", types: [\"feat\"] },\n\t\t\t\t{ title: \"Bug Fixes\", types: [\"fix\"] },\n\t\t\t\t{ title: \"Performance Improvements\", types: [\"perf\"] },\n\t\t\t\t{ title: \"Reverts\", types: [\"revert\"] },\n\t\t\t])\n\t\t\t.describe(\n\t\t\t\t\"Sections in order; a change goes in the first that lists its type.\",\n\t\t\t),\n\t\tbreaking: z\n\t\t\t.union([z.string(), z.literal(false)])\n\t\t\t.default(\"Breaking Changes\")\n\t\t\t.describe(\n\t\t\t\t\"The first section, for breaking changes of any type; `false` marks them **(breaking)** in their own section instead.\",\n\t\t\t),\n\t\tother: z\n\t\t\t.union([z.string(), z.literal(false)])\n\t\t\t.default(\"Other\")\n\t\t\t.describe(\"The section for remaining changes; `false` leaves them out.\"),\n\t\tlinks: z\n\t\t\t.boolean()\n\t\t\t.default(true)\n\t\t\t.describe(\"Link each change to its source, e.g. its commit.\"),\n\t\tdependencies: dependenciesOption,\n\t},\n\trun: ({ changes, kind, dependencies, options }) => {\n\t\tconst section = (title: string, types: readonly string[] = []) => ({\n\t\t\ttitle,\n\t\t\ttypes,\n\t\t\tentries: [] as string[],\n\t\t});\n\t\tconst breaking =\n\t\t\toptions.breaking === false ? undefined : section(options.breaking);\n\t\tconst other = options.other === false ? undefined : section(options.other);\n\t\tconst typed = options.sections.map(({ title, types }) =>\n\t\t\tsection(title, types),\n\t\t);\n\t\tfor (const change of changes) {\n\t\t\tconst title = change.title ? parseTitle(change.title) : undefined;\n\t\t\tconst isBreaking =\n\t\t\t\ttitle?.breaking ||\n\t\t\t\tmentionsBreaking(change.title) ||\n\t\t\t\tmentionsBreaking(change.description);\n\t\t\tconst target =\n\t\t\t\t(isBreaking ? breaking : undefined) ??\n\t\t\t\t(title && typed.find((s) => matches(title, s.types))) ??\n\t\t\t\tother;\n\t\t\tif (!target) continue;\n\t\t\tconst entry = format(change, title, {\n\t\t\t\tmarker: isBreaking && target !== breaking,\n\t\t\t\tlink: options.links,\n\t\t\t});\n\t\t\tif (entry !== undefined) target.entries.push(entry);\n\t\t}\n\n\t\treturn joinSections(kind, [\n\t\t\t...[breaking, ...typed, other].filter((s) => s !== undefined),\n\t\t\t...dependencySection(options.dependencies, dependencies),\n\t\t]);\n\t},\n});\n\nfunction matches(title: Title, types: readonly string[]): boolean {\n\treturn (\n\t\ttypes.includes(title.type) ||\n\t\t(title.scope !== undefined &&\n\t\t\ttypes.includes(`${title.type}(${title.scope})`))\n\t);\n}\n\nfunction format(\n\tchange: Change,\n\tparsed: Title | undefined,\n\tstyle: { marker: boolean; link: boolean },\n): string | undefined {\n\tconst text = parsed\n\t\t? `${parsed.scope ? `**${parsed.scope}:** ` : \"\"}${parsed.subject}`\n\t\t: (change.title ?? change.description?.split(\"\\n\")[0])?.trim();\n\tif (!text) return undefined;\n\tconst marker = style.marker ? \" **(breaking)**\" : \"\";\n\tconst link =\n\t\tstyle.link && change.link\n\t\t\t? ` ([${change.link.label}](${change.link.url}))`\n\t\t\t: \"\";\n\treturn `- ${text}${marker}${link}`;\n}\n","import { defineStep } from \"../../core/define.ts\";\nimport type { ChangeWith } from \"../../core/types.ts\";\nimport { assertFullHistory, detectRepo, logSince } from \"../../utils/git.ts\";\nimport { plural } from \"../../utils/text.ts\";\nimport { parseSections } from \"./classify.ts\";\n\nconst COMMIT_SEPARATOR = \"\\x1e\";\nconst FIELD_SEPARATOR = \"\\x1f\";\n\n/**\n * Collects every conventional section (`feat: ...`, `fix(x)!: ...`) in the\n * commits since the previous release, or in all history without one. Only\n * commits touching the component count; for the whole project, when the\n * working directory is a subdirectory of the repository, only those touching\n * it. Each change links to its commit when the repository is known: on\n * GitHub, or in GitLab CI, on GitLab.\n */\nexport const conventionalReadCommits = defineStep({\n\tphase: \"read-changes\",\n\tname: \"conventional/read-commits\",\n\tdescription:\n\t\t\"Collects each conventional section (`feat:`, `fix(x)!:` …) of every commit touching the component since the previous release, or in all history without one.\",\n\tprovides: [\"changes.title\"],\n\trun: async ({ env, component, previousRef }) => {\n\t\tconst cwd = env.cwd;\n\t\tawait assertFullHistory(cwd);\n\t\tconst log = await logSince(cwd, {\n\t\t\tref: previousRef,\n\t\t\tpathspec: component.pathspec,\n\t\t\tformat: `%H${FIELD_SEPARATOR}%B${COMMIT_SEPARATOR}`,\n\t\t});\n\t\tconst commitUrl = await commitUrlOf(cwd);\n\t\tconst changes: ChangeWith<\"title\">[] = [];\n\t\tlet commits = 0;\n\t\tfor (const entry of log.split(COMMIT_SEPARATOR)) {\n\t\t\tconst [sha, message = \"\"] = entry.trim().split(FIELD_SEPARATOR);\n\t\t\tif (!sha) continue;\n\t\t\tcommits++;\n\t\t\tconst short = sha.slice(0, 7);\n\t\t\tconst link = commitUrl\n\t\t\t\t? { label: short, url: commitUrl(sha) }\n\t\t\t\t: undefined;\n\t\t\tfor (const section of parseSections(message)) {\n\t\t\t\tchanges.push({\n\t\t\t\t\t...section,\n\t\t\t\t\treason: `commit ${short}`,\n\t\t\t\t\t...(link && { link }),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tconst since = previousRef\n\t\t\t? `since ${previousRef.slice(0, 7)}`\n\t\t\t: \"in all history\";\n\t\treturn {\n\t\t\tchanges,\n\t\t\treason: `${plural(changes.length, \"change\")} in ${plural(commits, \"commit\")} ${since}`,\n\t\t};\n\t},\n});\n\n/** Links to commits on GitHub, or in GitLab CI on GitLab, when the repository is known. */\nasync function commitUrlOf(\n\tcwd: string,\n): Promise<((sha: string) => string) | undefined> {\n\tconst repo = await detectRepo(cwd);\n\tif (repo) {\n\t\tconst server = process.env.GITHUB_SERVER_URL || \"https://github.com\";\n\t\treturn (sha) => `${server}/${repo}/commit/${sha}`;\n\t}\n\tconst project = process.env.CI_PROJECT_URL;\n\treturn project ? (sha) => `${project}/-/commit/${sha}` : undefined;\n}\n","import { execFile } from \"node:child_process\";\n\n/** Runs a command and resolves with its trimmed stdout; fails with its stderr. */\nexport function exec(\n\tcommand: string,\n\targs: readonly string[],\n\toptions: { cwd: string; env?: NodeJS.ProcessEnv },\n): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\texecFile(\n\t\t\tcommand,\n\t\t\targs,\n\t\t\t{ ...options, maxBuffer: 64 * 1024 * 1024 },\n\t\t\t(error, stdout, stderr) => {\n\t\t\t\tif (error) {\n\t\t\t\t\tconst detail = stderr.trim() || error.message;\n\t\t\t\t\treject(new Error(`${command} ${args.join(\" \")} failed: ${detail}`));\n\t\t\t\t} else {\n\t\t\t\t\tresolve(stdout.trim());\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t});\n}\n","import { exec } from \"../../utils/exec.ts\";\nimport { inComponent } from \"../../utils/files.ts\";\nimport { fill } from \"../../utils/template.ts\";\n\ntype Command = string | readonly string[];\n\n/**\n * Runs a step's command for a component, or in a dry run its `dryRun`\n * command if it has one; resolves with what it ran, and its output.\n */\nexport async function runCommand(\n\tinput: {\n\t\tenv: { cwd: string; dryRun: boolean };\n\t\tcomponent: { path: string };\n\t\tplaceholders: Readonly<Record<string, string>>;\n\t},\n\toptions: {\n\t\tcommand: Command;\n\t\tdryRun?: Command | undefined;\n\t\tcwd: string;\n\t\tenv: Readonly<Record<string, string>>;\n\t},\n): Promise<{ shown: string; stdout: string | null }> {\n\tconst { env, component, placeholders } = input;\n\tconst command =\n\t\tenv.dryRun && options.dryRun !== undefined\n\t\t\t? options.dryRun\n\t\t\t: options.command;\n\tconst argv =\n\t\ttypeof command === \"string\"\n\t\t\t? [\"sh\", \"-c\", fill(command, placeholders)]\n\t\t\t: command.map((part) => fill(part, placeholders));\n\tconst shown = typeof command === \"string\" ? (argv[2] ?? \"\") : argv.join(\" \");\n\tif (env.dryRun && options.dryRun === undefined) {\n\t\treturn { shown, stdout: null };\n\t}\n\tconst [program = \"\", ...args] = argv;\n\tconst stdout = await exec(program, args, {\n\t\tcwd: inComponent(env, component, options.cwd).file,\n\t\tenv: {\n\t\t\t...process.env,\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries(options.env).map(([key, value]) => [\n\t\t\t\t\tkey,\n\t\t\t\t\tfill(value, placeholders),\n\t\t\t\t]),\n\t\t\t),\n\t\t},\n\t});\n\treturn { shown, stdout };\n}\n\n/** The last lines of a command's output, for its reason. */\nexport function tail(stdout: string, lines = 1): string {\n\tconst last = stdout\n\t\t.split(\"\\n\")\n\t\t.filter((line) => line.trim())\n\t\t.slice(-lines);\n\treturn last.join(\" \").slice(0, 200);\n}\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { inComponent } from \"../../utils/files.ts\";\nimport { runCommand, tail } from \"./run.ts\";\n\n/**\n * Runs a command for each component in the phase it's given: in `write`,\n * e.g. `cargo update --workspace` to update a lockfile; in `release`, e.g.\n * `cargo publish` or `docker push app:{version}`.\n */\nexport const execCommand = defineStep({\n\tphase: (options) => options.phase,\n\tname: \"exec/command\",\n\tdescription:\n\t\t\"Runs a command for each component in its `phase`: `write` e.g. to update a lockfile, listing what it changes as `files`, or `release` e.g. `cargo publish` or `docker push app:{version}`.\",\n\toptions: {\n\t\tphase: z\n\t\t\t.enum([\"write\", \"stage\", \"release\"])\n\t\t\t.describe(\"The phase it runs in.\"),\n\t\tcommand: z\n\t\t\t.union([z.string(), z.array(z.string()).min(1)])\n\t\t\t.describe(\n\t\t\t\t\"`{placeholders}` are filled in. Text runs in `sh -c`; a list runs as it is, without a shell.\",\n\t\t\t),\n\t\tdryRun: z\n\t\t\t.union([z.string(), z.array(z.string()).min(1)])\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Runs instead in a dry run, e.g. `cargo publish --dry-run`; without it, a dry run only says what it would run.\",\n\t\t\t),\n\t\tcwd: z\n\t\t\t.string()\n\t\t\t.default(\".\")\n\t\t\t.describe(\"Where it runs, relative to the component's directory.\"),\n\t\tenv: z\n\t\t\t.record(z.string(), z.string())\n\t\t\t.default({})\n\t\t\t.describe(\"More environment variables, with `{placeholders}` filled in.\"),\n\t\tfiles: z\n\t\t\t.array(z.string())\n\t\t\t.default([])\n\t\t\t.describe(\n\t\t\t\t\"What it changes, relative to the component's directory, for `git/commit`.\",\n\t\t\t),\n\t},\n\trun: async (input) => {\n\t\tconst { env, component, options } = input;\n\t\tconst files = options.files.map(\n\t\t\t(file) => inComponent(env, component, file).relative,\n\t\t);\n\t\tconst { shown, stdout } = await runCommand(input, options);\n\t\tif (stdout === null) {\n\t\t\treturn {\n\t\t\t\toutput: { command: shown, stdout: null },\n\t\t\t\tfiles,\n\t\t\t\treason: `would run ${shown}`,\n\t\t\t};\n\t\t}\n\t\tconst last = tail(stdout);\n\t\treturn {\n\t\t\toutput: { command: shown, stdout },\n\t\t\tfiles,\n\t\t\treason: `ran ${shown}${last ? `: ${last}` : \"\"}`,\n\t\t};\n\t},\n});\n","import { readFile, writeFile } from \"node:fs/promises\";\nimport { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { inComponent } from \"../../utils/files.ts\";\nimport { fill, VERSION_PLACEHOLDERS } from \"../../utils/template.ts\";\nimport { channelsOption, skipOnChannel } from \"../channels.ts\";\n\n/** Writes release notes to a file, creating it if needed. */\nexport const fsWriteChanges = defineStep({\n\tphase: \"write\",\n\tname: \"fs/write-changes\",\n\tdescription: \"Writes a heading and the notes to a file.\",\n\toptions: {\n\t\tpath: z\n\t\t\t.string()\n\t\t\t.default(\"CHANGELOG.md\")\n\t\t\t.describe(\"Relative to the component's directory.\"),\n\t\theading: z\n\t\t\t.string()\n\t\t\t.default(\"## {tag} ({date})\")\n\t\t\t.describe(`${VERSION_PLACEHOLDERS}, and \\`{date}\\` (YYYY-MM-DD).`),\n\t\tmode: z.enum([\"prepend\", \"append\", \"replace\"]).default(\"prepend\"),\n\t\tchannels: channelsOption,\n\t},\n\trun: async ({ env, component, placeholders, notes, options }) => {\n\t\tconst { heading, mode } = options;\n\t\tconst { file, relative: path } = inComponent(env, component, options.path);\n\t\tconst skipped = skipOnChannel(env, options.channels, path);\n\t\tif (skipped) return skipped;\n\t\tconst existing = await readFile(file, \"utf8\").catch((error: unknown) => {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n\t\t\tthrow error;\n\t\t});\n\t\tconst date = new Date().toISOString().slice(0, 10);\n\t\tconst entry =\n\t\t\t`${fill(heading, { ...placeholders, date })}\\n\\n${notes}`.trimEnd();\n\t\tconst action = existing === undefined ? \"create\" : mode;\n\t\tif (env.dryRun) {\n\t\t\treturn {\n\t\t\t\toutput: { path, entry, written: false },\n\t\t\t\tfiles: [path],\n\t\t\t\treason: `would ${action} ${path}`,\n\t\t\t};\n\t\t}\n\t\tlet content = [entry];\n\t\tif (mode !== \"replace\") {\n\t\t\tcontent = [\n\t\t\t\t...(mode === \"prepend\" ? [entry] : []),\n\t\t\t\t...(existing?.trim() ? [existing.trim()] : []),\n\t\t\t\t...(mode === \"append\" ? [entry] : []),\n\t\t\t];\n\t\t}\n\t\tawait writeFile(file, `${content.join(\"\\n\\n\")}\\n`);\n\t\treturn {\n\t\t\toutput: { path, entry, written: true },\n\t\t\tfiles: [path],\n\t\t\treason: `${existing === undefined ? \"created\" : `${mode}${mode.endsWith(\"e\") ? \"d\" : \"ed\"}`} ${path}`,\n\t\t};\n\t},\n});\n","import { type FactoryDefinition, makeFactory } from \"./factory.ts\";\nimport type { Fact } from \"./facts.ts\";\nimport type { OptionsShape } from \"./options.ts\";\nimport type { ReleaseKind } from \"./types.ts\";\n\n/**\n * A version scheme: the one place that knows what a version looks like. It\n * recognizes and orders versions, works out the next, and names their parts\n * for templates. Everything else treats versions as plain text.\n */\nexport interface Scheme {\n\t/** Describes it in reports, e.g. `semver` or `calver YYYY.MM.MICRO`. */\n\treadonly name: string;\n\t/** Facts that hold for every version it makes, e.g. `version.semver`. */\n\treadonly traits?: readonly Fact[];\n\t/** Whether a version is one of this scheme's, strictly. */\n\tmatches(version: string): boolean;\n\t/** Orders two of its versions. */\n\tcompare(a: string, b: string): number;\n\t/**\n\t * The next version: after `previous` by `kind`, or the first one without\n\t * a previous version, e.g. on a first release.\n\t */\n\tbump(input: BumpInput): { version: string; reason: string };\n\t/** `{placeholders}` for templates, e.g. `{ major: \"1\", minor: \"2\", patch: \"3\" }`. */\n\tfields?(version: string): Record<string, string>;\n\t/**\n\t * How channel versions are written, by channel type, e.g.\n\t * `{ prerelease: \"{version}rc{n}\" }`; by default `{version}-{channel}.{n}`\n\t * and `{version}+{channel}.{n}`.\n\t */\n\treadonly formats?: { readonly prerelease?: string; readonly build?: string };\n}\n\nexport interface BumpInput {\n\t/** Absent on a first release, or when the scheme changed since the last one. */\n\tprevious?: string;\n\tkind: ReleaseKind;\n\tbranch: string;\n\tdate: Date;\n}\n\n/**\n * Defines a version scheme whose options are declared as a zod shape. The\n * result is a factory, like a step's: `calver({ format: \"YY.MINOR.MICRO\" })`.\n */\nexport function defineScheme<const N extends string, S extends OptionsShape>(\n\tdefinition: FactoryDefinition<N, S, Scheme>,\n) {\n\treturn makeFactory(\"scheme\", definition);\n}\n","import { z } from \"../core/options.ts\";\nimport { defineScheme } from \"../core/scheme.ts\";\nimport type { ReleaseKind } from \"../core/types.ts\";\nimport {\n\tcompareVersions,\n\tparseVersion,\n\ttype Version,\n} from \"../utils/version.ts\";\n\n/** A strict semantic version. */\nexport interface Semver {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tprerelease?: string;\n\tbuild?: string;\n}\n\nconst PATTERN =\n\t/^v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z.-]+))?(?:\\+([0-9A-Za-z.-]+))?$/;\n\n/** Whether a version is valid semver: `MAJOR.MINOR.PATCH`, without leading zeros. */\nexport function isSemver(version: string): boolean {\n\treturn PATTERN.test(version.trim());\n}\n\n/**\n * Whether a version is a stable semantic version: one without a pre-release\n * part, which the scheme leaves to channels.\n */\nfunction isStable(version: string): boolean {\n\tconst match = PATTERN.exec(version.trim());\n\treturn match !== null && match[4] === undefined;\n}\n\nexport function parseSemver(version: string): Semver {\n\tconst match = PATTERN.exec(version.trim());\n\tif (!match) throw new Error(`'${version}' is not a valid semantic version`);\n\tconst [, major, minor, patch, prerelease, build] = match;\n\treturn {\n\t\tmajor: Number(major),\n\t\tminor: Number(minor),\n\t\tpatch: Number(patch),\n\t\t...(prerelease !== undefined && { prerelease }),\n\t\t...(build !== undefined && { build }),\n\t};\n}\n\nexport function formatSemver(version: Semver): string {\n\tlet text = `${version.major}.${version.minor}.${version.patch}`;\n\tif (version.prerelease !== undefined) text += `-${version.prerelease}`;\n\tif (version.build !== undefined) text += `+${version.build}`;\n\treturn text;\n}\n\n/** Bumps a version: `breaking` → major, `feature` → minor, `fix` → patch. */\nexport function bumpSemver(version: Semver, kind: ReleaseKind): Semver {\n\tconst { major, minor, patch } = version;\n\tswitch (kind) {\n\t\tcase \"breaking\":\n\t\t\treturn { major: major + 1, minor: 0, patch: 0 };\n\t\tcase \"feature\":\n\t\t\treturn { major, minor: minor + 1, patch: 0 };\n\t\tcase \"fix\":\n\t\t\treturn { major, minor, patch: patch + 1 };\n\t}\n}\n\nconst POSITION = { breaking: \"major\", feature: \"minor\", fix: \"patch\" } as const;\n\n/**\n * `MAJOR.minor.patch`: breaking changes bump the major number, features the\n * minor and fixes the patch. Before 1.0.0, bumps shift down a level by\n * default (`0.MAJOR.minorOrPatch`).\n */\nexport const semver = defineScheme({\n\tname: \"semver\",\n\tdescription:\n\t\t\"`MAJOR.minor.patch` by the kind: breaking, feature or fix; `0.MAJOR.minorOrPatch` before 1.0.0.\",\n\toptions: {\n\t\tshiftPreMajor: z\n\t\t\t.boolean()\n\t\t\t.default(true)\n\t\t\t.describe(\n\t\t\t\t\"Before 1.0.0, bump breaking changes as minor and features as patch.\",\n\t\t\t),\n\t\tinitial: z\n\t\t\t.string()\n\t\t\t.default(\"0.1.0\")\n\t\t\t.refine(isSemver, \"must be a semantic version, e.g. 1.0.0\")\n\t\t\t.describe(\"The first version, when there's no previous one.\"),\n\t},\n\tcreate: (options) => ({\n\t\tname: \"semver\",\n\t\ttraits: [\"version.semver\"],\n\t\tmatches: isStable,\n\t\tcompare: (a, b) =>\n\t\t\tcompareVersions(parseVersion(a) as Version, parseVersion(b) as Version),\n\t\tbump: ({ previous, kind }) => {\n\t\t\tif (previous === undefined) {\n\t\t\t\treturn { version: options.initial, reason: `first release` };\n\t\t\t}\n\t\t\tconst parsed = parseSemver(previous);\n\t\t\tconst shifted =\n\t\t\t\tparsed.major === 0 && options.shiftPreMajor\n\t\t\t\t\t? kind === \"breaking\"\n\t\t\t\t\t\t? \"feature\"\n\t\t\t\t\t\t: \"fix\"\n\t\t\t\t\t: kind;\n\t\t\treturn {\n\t\t\t\tversion: formatSemver(bumpSemver(parsed, shifted)),\n\t\t\t\treason:\n\t\t\t\t\tshifted === kind\n\t\t\t\t\t\t? `bumps ${POSITION[kind]}`\n\t\t\t\t\t\t: `bumps ${POSITION[shifted]} (pre-1.0)`,\n\t\t\t};\n\t\t},\n\t\tfields: (version) => {\n\t\t\tconst { major, minor, patch, prerelease } = parseSemver(version);\n\t\t\treturn {\n\t\t\t\tmajor: String(major),\n\t\t\t\tminor: String(minor),\n\t\t\t\tpatch: String(patch),\n\t\t\t\t...(prerelease !== undefined && { prerelease }),\n\t\t\t};\n\t\t},\n\t}),\n});\n","import { readFile, writeFile } from \"node:fs/promises\";\nimport { posix, relative } from \"node:path\";\nimport { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { isSemver } from \"../../schemes/semver.ts\";\nimport { inComponent, resolveFiles } from \"../../utils/files.ts\";\nimport { joinList } from \"../../utils/text.ts\";\nimport { FORMAT_NAMES, versionFormat } from \"./formats.ts\";\n\n/**\n * Writes each component's new version to its version file, in the project's\n * own format, keeping everything else as it was. With the `npm` and `cargo`\n * formats, dependencies on the other components released with it are\n * pointed at their new versions too, keeping each range's operator.\n */\nexport const fsWriteVersion = defineStep({\n\tphase: \"write\",\n\tname: \"fs/write-version\",\n\tscope: \"all\",\n\tdescription:\n\t\t\"Writes each component's new version to its version file: `VERSION`, `package.json`, `Cargo.toml`, `pyproject.toml`, `Chart.yaml`, `gradle.properties`, `pom.xml`, or any file by pattern. With `npm` and `cargo`, it also updates dependencies on the other components released with it, and needs `version.semver`.\",\n\toptions: {\n\t\tformat: z\n\t\t\t.enum(FORMAT_NAMES)\n\t\t\t.default(\"plain\")\n\t\t\t.describe(\n\t\t\t\t\"`plain` (the whole file), `npm`, `cargo`, `python`, `helm`, `gradle`, `maven`, or `pattern`.\",\n\t\t\t),\n\t\tpath: z\n\t\t\t.union([z.string(), z.array(z.string()).min(1)])\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Relative to each component's directory; globs, or a list, write several, e.g. `packages/*/package.json` for packages sharing a version. Defaults to the format's file.\",\n\t\t\t),\n\t\tpattern: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t'With the `pattern` format, where the version is, e.g. `__version__ = \"{version}\"`.',\n\t\t\t),\n\t},\n\tneeds: (options) =>\n\t\tversionFormat(options.format, options.pattern ?? \"{version}\").needs ?? [],\n\trun: async ({ env, components, options }) => {\n\t\tconst format = versionFormat(options.format, options.pattern);\n\t\tconst patterns = [options.path ?? format.path].flat();\n\t\tif (patterns.includes(\"\")) {\n\t\t\tthrow new Error(\"the pattern format needs a `path`\");\n\t\t}\n\t\tif (format.needs?.includes(\"version.semver\")) {\n\t\t\tfor (const { version } of components) {\n\t\t\t\t// npm and cargo would \"clean\" anything else, e.g. publish\n\t\t\t\t// 2026.01.0 as 2026.1.0, so the package and its tag would disagree.\n\t\t\t\tif (!isSemver(version)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${format.name} needs a semantic version, and '${version}' isn't one`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Package names may differ from component names; read them all first.\n\t\tconst files = (\n\t\t\tawait Promise.all(\n\t\t\t\tcomponents.map(async ({ component, version }) => {\n\t\t\t\t\tconst dir = inComponent(env, component, \".\").file;\n\t\t\t\t\tconst found =\n\t\t\t\t\t\toptions.format === \"plain\"\n\t\t\t\t\t\t\t? patterns.map(\n\t\t\t\t\t\t\t\t\t(pattern) => inComponent(env, component, pattern).file,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: await resolveFiles(dir, patterns);\n\t\t\t\t\treturn Promise.all(\n\t\t\t\t\t\tfound.map(async (file) => ({\n\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\tversion,\n\t\t\t\t\t\t\ttext: await readFile(file, \"utf8\").catch((error: unknown) => {\n\t\t\t\t\t\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n\t\t\t\t\t\t\t\t\treturn \"\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\trelative: posix.normalize(\n\t\t\t\t\t\t\t\trelative(env.cwd, file).replaceAll(\"\\\\\", \"/\"),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t})),\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t)\n\t\t).flat();\n\t\tconst packages = new Map<string, string>();\n\t\tfor (const { text, version } of files) {\n\t\t\tconst name = format.packageName?.(text);\n\t\t\tif (name !== undefined) packages.set(name, version);\n\t\t}\n\t\tconst written: { path: string; version: string; dependencies: string[] }[] =\n\t\t\t[];\n\t\tfor (const { file, version, text, relative: path } of files) {\n\t\t\tif (text === \"\" && options.format !== \"plain\") {\n\t\t\t\tthrow new Error(`${path} doesn't exist`);\n\t\t\t}\n\t\t\tlet result: { text: string; dependencies: string[] };\n\t\t\ttry {\n\t\t\t\tresult = format.write(text, version, packages);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`can't write ${version} to ${path}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!env.dryRun) await writeFile(file, result.text);\n\t\t\twritten.push({ path, version, dependencies: result.dependencies });\n\t\t}\n\t\tconst described = joinList(\n\t\t\twritten.map(\n\t\t\t\t({ path, version, dependencies }) =>\n\t\t\t\t\t`${version} to ${path}${dependencies.length > 0 ? ` (and ${joinList(dependencies)})` : \"\"}`,\n\t\t\t),\n\t\t);\n\t\treturn {\n\t\t\toutput: { written: env.dryRun ? [] : written },\n\t\t\tfiles: written.map(({ path }) => path),\n\t\t\treason: `${env.dryRun ? \"would write\" : \"wrote\"} ${described}`,\n\t\t};\n\t},\n});\n","/**\n * Placeholders for what's released as a whole: `{tags}`, every release's\n * tag, and with one component, its own placeholders.\n */\nexport function releasedPlaceholders(\n\tcomponents: readonly {\n\t\ttag: string;\n\t\tplaceholders: Readonly<Record<string, string>>;\n\t}[],\n): Record<string, string> {\n\tconst [only] = components;\n\treturn {\n\t\t...(components.length === 1 && only ? only.placeholders : {}),\n\t\ttags: components.map(({ tag }) => tag).join(\", \"),\n\t};\n}\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { git, identity } from \"../../utils/git.ts\";\nimport { fill } from \"../../utils/template.ts\";\nimport { releasedPlaceholders } from \"./placeholders.ts\";\n\n/**\n * Commits the files that earlier `release` steps changed, for every\n * component, in one commit. Without this the version bump never lands.\n * Pushing is off by default, so `git/create-tag` can push the commit and its\n * tags together.\n */\nexport const gitCommit = defineStep({\n\tphase: \"stage\",\n\tname: \"git/commit\",\n\tscope: \"all\",\n\tdescription:\n\t\t\"Commits the files earlier release steps changed, for every component, in one commit.\",\n\toptions: {\n\t\tfiles: z\n\t\t\t.array(z.string())\n\t\t\t.default([])\n\t\t\t.describe(\"More files to commit, relative to the working directory.\"),\n\t\tmessage: z\n\t\t\t.string()\n\t\t\t.default(\"chore(release): {tags}\")\n\t\t\t.describe(\n\t\t\t\t\"The commit message; `{tags}` is filled in with every release's tag, and with one component, its placeholders too, e.g. `{version}`.\",\n\t\t\t),\n\t\tpush: z\n\t\t\t.union([z.string(), z.literal(false)])\n\t\t\t.default(false)\n\t\t\t.describe(\n\t\t\t\t\"The remote to push the branch to; `false` leaves it to a later step, e.g. `git/create-tag`, so the commit and tag land together.\",\n\t\t\t),\n\t},\n\trun: async ({ env, components, options }) => {\n\t\tconst remote = options.push;\n\t\tconst message = fill(options.message, releasedPlaceholders(components));\n\t\tconst files = [\n\t\t\t...new Set([\n\t\t\t\t...components.flatMap(({ releases }) =>\n\t\t\t\t\treleases.flatMap((release) => release.files),\n\t\t\t\t),\n\t\t\t\t...options.files,\n\t\t\t]),\n\t\t];\n\t\tif (files.length === 0) {\n\t\t\tthrow new Error(\"no files to commit; no earlier step reported any\");\n\t\t}\n\t\tconst pushing = remote ? ` and push to ${remote}` : \"\";\n\t\tif (env.dryRun) {\n\t\t\treturn {\n\t\t\t\toutput: { commit: null, pushed: false },\n\t\t\t\treason: `would commit ${files.join(\", \")}${pushing}`,\n\t\t\t};\n\t\t}\n\n\t\tconst cwd = env.cwd;\n\t\tawait git(cwd, \"add\", \"--all\", \"--\", ...files);\n\t\tconst staged = await git(cwd, \"diff\", \"--cached\", \"--name-only\");\n\t\tif (staged === \"\") throw new Error(\"nothing to commit\");\n\t\tawait git(cwd, ...(await identity(cwd)), \"commit\", \"-m\", message);\n\t\tconst commit = await git(cwd, \"rev-parse\", \"HEAD\");\n\t\tif (remote) await git(cwd, \"push\", remote, \"HEAD\");\n\t\treturn {\n\t\t\toutput: { commit, pushed: remote !== false },\n\t\t\treason: `committed ${commit.slice(0, 7)}${remote ? ` and pushed to ${remote}` : \"\"}`,\n\t\t};\n\t},\n});\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { git, identity, tryGit } from \"../../utils/git.ts\";\nimport { fill, VERSION_PLACEHOLDERS } from \"../../utils/template.ts\";\nimport { joinList } from \"../../utils/text.ts\";\n\n/**\n * Tags HEAD with every component's release, moves any floating tags to it,\n * and pushes them along with the current branch in one atomic push, so a\n * commit from `git/commit` and its tags land together or not at all.\n */\nexport const gitCreateTag = defineStep({\n\tphase: \"release\",\n\tname: \"git/create-tag\",\n\tscope: \"all\",\n\tdescription:\n\t\t\"Tags HEAD with each release's tag and pushes them, along with the branch, in one atomic push.\",\n\toptions: {\n\t\tmessage: z\n\t\t\t.string()\n\t\t\t.default(\"chore(release): {tag}\")\n\t\t\t.describe(`The tag message; ${VERSION_PLACEHOLDERS}.`),\n\t\tmove: z\n\t\t\t.array(z.string())\n\t\t\t.default([])\n\t\t\t.describe(\n\t\t\t\t\"Tags to create or move to each release, e.g. `v{major}`; force-pushed. Those with `{channel}` only move on a channel, e.g. to `next`, and the others only on stable releases.\",\n\t\t\t),\n\t\tpush: z\n\t\t\t.union([z.string(), z.literal(false)])\n\t\t\t.default(false)\n\t\t\t.describe(\n\t\t\t\t\"The remote to push the tags and the current branch to; `false` skips pushing.\",\n\t\t\t),\n\t},\n\trun: async ({ env, components, options }) => {\n\t\tconst remote = options.push;\n\t\tconst tags = components.map(({ tag, placeholders }) => ({\n\t\t\ttag,\n\t\t\tmessage: fill(options.message, placeholders),\n\t\t}));\n\t\tconst moved = [\n\t\t\t...new Set(\n\t\t\t\tcomponents.flatMap(({ placeholders }) =>\n\t\t\t\t\toptions.move\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(name) =>\n\t\t\t\t\t\t\t\tname.includes(\"{channel}\") === (env.channel !== undefined),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((name) => fill(name, placeholders)),\n\t\t\t\t),\n\t\t\t),\n\t\t];\n\t\tconst names = joinList(tags.map(({ tag }) => tag));\n\t\tif (env.dryRun) {\n\t\t\treturn {\n\t\t\t\toutput: { tags: tags.map(({ tag }) => tag), moved, pushed: false },\n\t\t\t\treason: `would ${joinList([\n\t\t\t\t\t`tag ${names}`,\n\t\t\t\t\t...(moved.length ? [`move ${moved.join(\", \")}`] : []),\n\t\t\t\t\t...(remote ? [`push to ${remote}`] : []),\n\t\t\t\t])}`,\n\t\t\t};\n\t\t}\n\t\tconst cwd = env.cwd;\n\t\tconst head = await git(cwd, \"rev-parse\", \"HEAD\");\n\t\tconst who = await identity(cwd);\n\t\tfor (const { tag, message } of tags) {\n\t\t\tawait git(cwd, ...who, \"tag\", \"-a\", tag, \"-m\", message);\n\t\t}\n\t\tfor (const name of moved) await git(cwd, \"tag\", \"-f\", name, \"HEAD\");\n\t\tif (remote) {\n\t\t\t// One atomic push, so a release lands entirely or not at all. Only the\n\t\t\t// moved tags are forced. A detached HEAD has no branch to push.\n\t\t\tconst onBranch = await tryGit(cwd, \"symbolic-ref\", \"-q\", \"HEAD\");\n\t\t\tawait git(\n\t\t\t\tcwd,\n\t\t\t\t\"push\",\n\t\t\t\t\"--atomic\",\n\t\t\t\tremote,\n\t\t\t\t...(onBranch ? [\"HEAD\"] : []),\n\t\t\t\t...tags.map(({ tag }) => `refs/tags/${tag}`),\n\t\t\t\t...moved.map((name) => `+refs/tags/${name}`),\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\toutput: {\n\t\t\t\ttags: tags.map(({ tag }) => tag),\n\t\t\t\tmoved,\n\t\t\t\tpushed: remote !== false,\n\t\t\t},\n\t\t\treason: joinList([\n\t\t\t\t`tagged ${names} at ${head.slice(0, 7)}`,\n\t\t\t\t...(moved.length ? [`moved ${moved.join(\", \")}`] : []),\n\t\t\t\t...(remote ? [`pushed to ${remote}`] : []),\n\t\t\t]),\n\t\t};\n\t},\n});\n","import { defineStep } from \"../../core/define.ts\";\nimport { git } from \"../../utils/git.ts\";\nimport { fill } from \"../../utils/template.ts\";\nimport { githubClient, githubToken } from \"./api.ts\";\nimport {\n\tensureRelease,\n\tisPrerelease,\n\treleaseOptions,\n\treleaseRepo,\n} from \"./release.ts\";\n\n/**\n * Creates a GitHub release for the version, with the notes as its body, or\n * finds the one another job already created.\n */\nexport const githubCreateRelease = defineStep({\n\tphase: \"release\",\n\tname: \"github/create-release\",\n\tdescription:\n\t\t\"Creates a GitHub release of the tag with the notes, unless it already has one; the tag is created at HEAD if it doesn't exist. Needs a token with `contents: write`.\",\n\toptions: releaseOptions,\n\trun: async ({ env, tag, placeholders, notes, options }) => {\n\t\tconst title = fill(options.title, placeholders);\n\t\tconst repo = await releaseRepo(env.cwd, options.repo);\n\t\tif (env.dryRun) {\n\t\t\treturn {\n\t\t\t\toutput: { repo, tag, url: null },\n\t\t\t\treason: `would create release ${tag} on ${repo}`,\n\t\t\t};\n\t\t}\n\n\t\tconst client = githubClient(repo, githubToken(options.token));\n\t\tconst { release, created } = await ensureRelease(client, {\n\t\t\ttag,\n\t\t\ttarget: await git(env.cwd, \"rev-parse\", \"HEAD\"),\n\t\t\ttitle,\n\t\t\tnotes,\n\t\t\tdraft: options.draft,\n\t\t\tprerelease: isPrerelease(options.prerelease, env),\n\t\t});\n\t\treturn {\n\t\t\toutput: { repo, tag, id: release.id, url: release.html_url },\n\t\t\treason: `${created ? \"created\" : \"found existing\"} release ${tag}: ${release.html_url}`,\n\t\t};\n\t},\n});\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { git, identity, tryGit } from \"../../utils/git.ts\";\nimport { fill } from \"../../utils/template.ts\";\nimport { joinList, plural } from \"../../utils/text.ts\";\nimport { githubClient, githubToken } from \"./api.ts\";\nimport { releaseRepo } from \"./release.ts\";\nimport {\n\ttype Manifest,\n\tPENDING_LABEL,\n\tRELEASE_BRANCH,\n\treleaseBody,\n} from \"./release-pr.ts\";\n\ninterface PullRequest {\n\tnumber: number;\n\thtml_url: string;\n}\n\n/**\n * Proposes the release as a pull request instead of releasing it: commits\n * what earlier `write` steps changed to a release branch, and opens a pull\n * request for it, or updates the one that's open. The release steps wait\n * until it merges; then the `github/release-pr` history finds it, and they\n * run for what it proposed.\n */\nexport const githubOpenReleasePr = defineStep({\n\tphase: \"stage\",\n\tname: \"github/open-release-pr\",\n\tscope: \"all\",\n\tdescription:\n\t\t\"Commits the prepared release to a branch and opens a pull request for it, or updates the open one; the release waits until it merges. Use with the `github/release-pr` history. List it after the `write` steps, in place of `git/commit`.\",\n\toptions: {\n\t\tbranch: z\n\t\t\t.string()\n\t\t\t.default(`${RELEASE_BRANCH}{branch}`)\n\t\t\t.describe(\n\t\t\t\t\"The release branch, force-pushed; `{branch}` is the branch being released.\",\n\t\t\t),\n\t\ttitle: z\n\t\t\t.string()\n\t\t\t.default(\"chore(release): {tags}\")\n\t\t\t.describe(\n\t\t\t\t\"The commit message and title; `{tags}` lists every release's tag.\",\n\t\t\t),\n\t\tlabels: z\n\t\t\t.array(z.string())\n\t\t\t.default([PENDING_LABEL])\n\t\t\t.describe(\n\t\t\t\t\"Labels for the pull request; `github/release-pr` looks for the first.\",\n\t\t\t),\n\t\tremote: z.string().default(\"origin\").describe(\"Where to push the branch.\"),\n\t\trepo: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"`owner/repo`; defaults to `GITHUB_REPOSITORY` or the `origin` remote.\",\n\t\t\t),\n\t\ttoken: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Defaults to `GITHUB_TOKEN` or `GH_TOKEN`; needs `pull-requests: write`.\",\n\t\t\t),\n\t},\n\trun: async ({ env, components, options }) => {\n\t\tconst tags = components.map(({ tag }) => tag).join(\", \");\n\t\tconst branch = fill(options.branch, { branch: env.branch });\n\t\tconst title = fill(options.title, { tags });\n\t\tconst files = [\n\t\t\t...new Set(\n\t\t\t\tcomponents.flatMap(({ releases }) =>\n\t\t\t\t\treleases.flatMap((release) => release.files),\n\t\t\t\t),\n\t\t\t),\n\t\t];\n\t\tconst manifest: Manifest = {\n\t\t\tcomponents: Object.fromEntries(\n\t\t\t\tcomponents.map((component) => [\n\t\t\t\t\tcomponent.component.name,\n\t\t\t\t\t{\n\t\t\t\t\t\tversion: component.version,\n\t\t\t\t\t\ttag: component.tag,\n\t\t\t\t\t\tkind: component.kind,\n\t\t\t\t\t\t...(component.previousVersion !== undefined && {\n\t\t\t\t\t\t\tpreviousVersion: component.previousVersion,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tnotes: component.notes,\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t\t),\n\t\t};\n\t\tconst repo = await releaseRepo(env.cwd, options.repo);\n\t\tif (env.dryRun) {\n\t\t\treturn {\n\t\t\t\toutput: { branch, number: null, url: null },\n\t\t\t\tfiles,\n\t\t\t\treason: `would push ${files.length > 0 ? joinList(files) : \"nothing new\"} to ${branch} and propose ${tags} on ${repo}`,\n\t\t\t\tdefer: `released when the pull request for ${tags} merges`,\n\t\t\t};\n\t\t}\n\t\tconst client = githubClient(repo, githubToken(options.token));\n\t\tconst cwd = env.cwd;\n\t\t// Commit on a detached HEAD, push it, and leave the checkout as it was.\n\t\tconst back =\n\t\t\t(await tryGit(cwd, \"symbolic-ref\", \"-q\", \"--short\", \"HEAD\")) ??\n\t\t\t(await git(cwd, \"rev-parse\", \"HEAD\"));\n\t\tawait git(cwd, \"checkout\", \"-q\", \"--detach\");\n\t\ttry {\n\t\t\tif (files.length > 0) await git(cwd, \"add\", \"--all\", \"--\", ...files);\n\t\t\tawait git(\n\t\t\t\tcwd,\n\t\t\t\t...(await identity(cwd)),\n\t\t\t\t\"commit\",\n\t\t\t\t\"-q\",\n\t\t\t\t\"--allow-empty\",\n\t\t\t\t\"-m\",\n\t\t\t\ttitle,\n\t\t\t);\n\t\t\tawait git(\n\t\t\t\tcwd,\n\t\t\t\t\"push\",\n\t\t\t\t\"--force\",\n\t\t\t\toptions.remote,\n\t\t\t\t`HEAD:refs/heads/${branch}`,\n\t\t\t);\n\t\t} finally {\n\t\t\tawait git(cwd, \"checkout\", \"-q\", \"--force\", back);\n\t\t}\n\t\tconst owner = repo.split(\"/\")[0];\n\t\tconst { data: open } = await client.request<PullRequest[]>(\n\t\t\t\"GET\",\n\t\t\t`/pulls?state=open&head=${encodeURIComponent(`${owner}:${branch}`)}`,\n\t\t);\n\t\tconst body = releaseBody(manifest);\n\t\tlet pull: PullRequest;\n\t\tconst [existing] = open;\n\t\tif (existing) {\n\t\t\tpull = (\n\t\t\t\tawait client.request<PullRequest>(\n\t\t\t\t\t\"PATCH\",\n\t\t\t\t\t`/pulls/${existing.number}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tbody: { title, body },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t).data;\n\t\t} else {\n\t\t\tpull = (\n\t\t\t\tawait client.request<PullRequest>(\"POST\", \"/pulls\", {\n\t\t\t\t\tbody: { title, body, head: branch, base: env.branch },\n\t\t\t\t})\n\t\t\t).data;\n\t\t}\n\t\tif (options.labels.length > 0) {\n\t\t\tawait client.request(\"POST\", `/issues/${pull.number}/labels`, {\n\t\t\t\tbody: { labels: options.labels },\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\toutput: { branch, number: pull.number, url: pull.html_url },\n\t\t\tfiles,\n\t\t\treason: `${existing ? \"updated\" : \"opened\"} #${pull.number} for ${tags}, with ${plural(files.length, \"file\")}: ${pull.html_url}`,\n\t\t\tdefer: `released when #${pull.number} merges`,\n\t\t};\n\t},\n});\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport type { ChangeWith } from \"../../core/types.ts\";\nimport { assertFullHistory, logSince } from \"../../utils/git.ts\";\nimport { plural } from \"../../utils/text.ts\";\nimport { githubClient, githubToken } from \"./api.ts\";\nimport { releaseRepo } from \"./release.ts\";\n\ninterface PullRequest {\n\tnumber: number;\n\ttitle: string;\n\tbody: string | null;\n\thtml_url: string;\n\tmerged_at: string | null;\n\tbase: { ref: string };\n\tlabels: { name: string }[];\n}\n\n/** Commits looked up at once. */\nconst CONCURRENCY = 8;\n\n/**\n * Collects the pull requests merged into the branch through the commits\n * touching the component since the previous release, or in all history\n * without one, each with its labels. Commits that weren't merged through a\n * pull request aren't counted.\n */\nexport const githubReadPullRequests = defineStep({\n\tphase: \"read-changes\",\n\tname: \"github/read-pull-requests\",\n\tdescription:\n\t\t\"Collects the pull requests merged into the branch by the commits touching the component since the previous release, with their labels. Needs a token that can read pull requests.\",\n\tprovides: [\"changes.title\", \"changes.labels\", \"changes.link\"],\n\toptions: {\n\t\trepo: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"`owner/repo`; defaults to `GITHUB_REPOSITORY` or the `origin` remote.\",\n\t\t\t),\n\t\ttoken: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Defaults to `GITHUB_TOKEN` or `GH_TOKEN`.\"),\n\t},\n\trun: async ({ env, component, previousRef, options }) => {\n\t\tconst cwd = env.cwd;\n\t\tawait assertFullHistory(cwd);\n\t\tconst shas = (\n\t\t\tawait logSince(cwd, {\n\t\t\t\tref: previousRef,\n\t\t\t\tpathspec: component.pathspec,\n\t\t\t\tformat: \"%H\",\n\t\t\t})\n\t\t)\n\t\t\t.split(\"\\n\")\n\t\t\t.filter(Boolean);\n\t\tconst client = githubClient(\n\t\t\tawait releaseRepo(cwd, options.repo),\n\t\t\tgithubToken(options.token),\n\t\t);\n\n\t\tconst found = new Map<number, PullRequest>();\n\t\tfor (let i = 0; i < shas.length; i += CONCURRENCY) {\n\t\t\tconst batch = await Promise.all(\n\t\t\t\tshas.slice(i, i + CONCURRENCY).map(async (sha) => {\n\t\t\t\t\tconst { data } = await client.request<PullRequest[]>(\n\t\t\t\t\t\t\"GET\",\n\t\t\t\t\t\t`/commits/${sha}/pulls`,\n\t\t\t\t\t);\n\t\t\t\t\treturn data;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tfor (const pull of batch.flat()) {\n\t\t\t\tif (pull.merged_at && pull.base.ref === env.branch) {\n\t\t\t\t\tfound.set(pull.number, pull);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Newest first, as commits are.\n\t\tconst changes: ChangeWith<\"title\" | \"labels\" | \"link\">[] = [\n\t\t\t...found.values(),\n\t\t].map((pull) => ({\n\t\t\ttitle: pull.title,\n\t\t\t...(pull.body?.trim() && { description: pull.body.trim() }),\n\t\t\treason: `PR #${pull.number}`,\n\t\t\tlink: { label: `#${pull.number}`, url: pull.html_url },\n\t\t\tlabels: pull.labels.map((label) => label.name),\n\t\t}));\n\t\tconst since = previousRef\n\t\t\t? `since ${previousRef.slice(0, 7)}`\n\t\t\t: \"in all history\";\n\t\treturn {\n\t\t\tchanges,\n\t\t\treason: `${plural(changes.length, \"pull request\")} in ${plural(shas.length, \"commit\")} ${since}`,\n\t\t};\n\t},\n});\n","import { promisify } from \"node:util\";\nimport { crc32, deflateRaw } from \"node:zlib\";\n\nconst deflate = promisify(deflateRaw);\n\nconst LIMIT = 0xffff_ffff;\n\n/**\n * Zips files, deflated, into one buffer. Without ZIP64, the archive and each\n * file must stay under 4 GiB.\n */\nexport async function zip(\n\tentries: readonly { name: string; content: Uint8Array }[],\n): Promise<Buffer> {\n\tconst parts: Buffer[] = [];\n\tconst central: Buffer[] = [];\n\tlet offset = 0;\n\tfor (const entry of entries) {\n\t\tconst name = Buffer.from(entry.name.replaceAll(\"\\\\\", \"/\"));\n\t\tconst data = await deflate(entry.content);\n\t\tif (entry.content.length >= LIMIT || offset + data.length >= LIMIT) {\n\t\t\tthrow new Error(`'${entry.name}' is too large to zip (4 GiB at most)`);\n\t\t}\n\t\tconst crc = crc32(entry.content);\n\t\t// Version 2.0, UTF-8 names, deflate, no timestamp (1980-01-01).\n\t\tconst fields = (header: Buffer, at: number) => {\n\t\t\theader.writeUInt16LE(20, at);\n\t\t\theader.writeUInt16LE(0x0800, at + 2);\n\t\t\theader.writeUInt16LE(8, at + 4);\n\t\t\theader.writeUInt16LE(0, at + 6);\n\t\t\theader.writeUInt16LE(0x21, at + 8);\n\t\t\theader.writeUInt32LE(crc, at + 10);\n\t\t\theader.writeUInt32LE(data.length, at + 14);\n\t\t\theader.writeUInt32LE(entry.content.length, at + 18);\n\t\t\theader.writeUInt16LE(name.length, at + 22);\n\t\t\theader.writeUInt16LE(0, at + 24);\n\t\t};\n\t\tconst local = Buffer.alloc(30);\n\t\tlocal.writeUInt32LE(0x04034b50, 0);\n\t\tfields(local, 4);\n\t\tconst record = Buffer.alloc(46);\n\t\trecord.writeUInt32LE(0x02014b50, 0);\n\t\trecord.writeUInt16LE(20, 4); // made by\n\t\tfields(record, 6);\n\t\trecord.writeUInt32LE(offset, 42);\n\t\tcentral.push(record, name);\n\t\tparts.push(local, name, data);\n\t\toffset += local.length + name.length + data.length;\n\t}\n\tconst directory = Buffer.concat(central);\n\tconst end = Buffer.alloc(22);\n\tend.writeUInt32LE(0x06054b50, 0);\n\tend.writeUInt16LE(entries.length, 8);\n\tend.writeUInt16LE(entries.length, 10);\n\tend.writeUInt32LE(directory.length, 12);\n\tend.writeUInt32LE(offset, 16);\n\treturn Buffer.concat([...parts, directory, end]);\n}\n","import { createHash } from \"node:crypto\";\nimport { readFile, stat } from \"node:fs/promises\";\nimport { dirname, relative, sep } from \"node:path\";\nimport { retry } from \"../../utils/retry.ts\";\nimport { zip } from \"../../utils/zip.ts\";\n\nconst SERVICE = \"twirp/github.actions.results.api.v1.ArtifactService\";\n\n/** Whether this is a job that can upload workflow artifacts. */\nexport function canUploadArtifacts(): boolean {\n\treturn Boolean(\n\t\tprocess.env.ACTIONS_RESULTS_URL && process.env.ACTIONS_RUNTIME_TOKEN,\n\t);\n}\n\n/** The job's artifact service, from what the runner gives JavaScript actions. */\nfunction service() {\n\tconst url = process.env.ACTIONS_RESULTS_URL;\n\tconst token = process.env.ACTIONS_RUNTIME_TOKEN;\n\tif (!url || !token) {\n\t\tthrow new Error(\n\t\t\t\"no artifact service; workflow artifacts can only be uploaded by the rylease action in a GitHub Actions job\",\n\t\t);\n\t}\n\t// The token's scope names the run and job to attach artifacts to.\n\tconst payload = JSON.parse(\n\t\tBuffer.from(token.split(\".\")[1] ?? \"\", \"base64url\").toString(),\n\t) as { scp?: string };\n\tconst scope = payload.scp\n\t\t?.split(\" \")\n\t\t.find((scope) => scope.startsWith(\"Actions.Results:\"));\n\tconst [, run, job] = scope?.split(\":\") ?? [];\n\tif (!run || !job) throw new Error(\"the runtime token names no job\");\n\treturn {\n\t\tids: { workflow_run_backend_id: run, workflow_job_run_backend_id: job },\n\t\tcall: async <T>(method: string, body: object): Promise<T> => {\n\t\t\tconst response = await fetch(\n\t\t\t\t`${new URL(url).origin}/${SERVICE}/${method}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tauthorization: `Bearer ${token}`,\n\t\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\t},\n\t\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\t},\n\t\t\t);\n\t\t\tconst text = await response.text();\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`artifact service responded ${response.status} to ${method}: ${text}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn JSON.parse(text) as T;\n\t\t},\n\t};\n}\n\n/** Uploads a zip as a workflow artifact; resolves with its id. */\nasync function uploadArtifact(\n\tname: string,\n\tcontent: Buffer,\n\tretentionDays?: number,\n): Promise<string> {\n\tconst { ids, call } = service();\n\tconst created = await call<{ ok: boolean; signed_upload_url: string }>(\n\t\t\"CreateArtifact\",\n\t\t{\n\t\t\t...ids,\n\t\t\tname,\n\t\t\tversion: 4,\n\t\t\t...(retentionDays !== undefined && {\n\t\t\t\texpires_at: new Date(\n\t\t\t\t\tDate.now() + retentionDays * 86_400_000,\n\t\t\t\t).toISOString(),\n\t\t\t}),\n\t\t},\n\t);\n\tif (!created.ok) throw new Error(`couldn't create artifact '${name}'`);\n\n\tawait retry(\n\t\tasync () => {\n\t\t\tconst response = await fetch(created.signed_upload_url, {\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders: {\n\t\t\t\t\t\"x-ms-blob-type\": \"BlockBlob\",\n\t\t\t\t\t\"x-ms-version\": \"2020-10-02\",\n\t\t\t\t\t\"content-type\": \"application/zip\",\n\t\t\t\t},\n\t\t\t\tbody: content,\n\t\t\t});\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`artifact storage responded ${response.status}: ${await response.text()}`,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t{ attempts: 5 },\n\t);\n\n\tconst finalized = await call<{ ok: boolean; artifact_id: string }>(\n\t\t\"FinalizeArtifact\",\n\t\t{\n\t\t\t...ids,\n\t\t\tname,\n\t\t\tsize: String(content.length),\n\t\t\thash: `sha256:${createHash(\"sha256\").update(content).digest(\"hex\")}`,\n\t\t},\n\t);\n\tif (!finalized.ok) throw new Error(`couldn't finalize artifact '${name}'`);\n\treturn finalized.artifact_id;\n}\n\n/**\n * Zips files as a workflow artifact, with paths relative to their closest\n * common directory, as `actions/upload-artifact` does.\n */\nexport async function uploadFiles(\n\tname: string,\n\tfiles: readonly string[],\n\tretentionDays?: number,\n): Promise<{ id: string; files: string[]; size: number }> {\n\tconst root = files.map(dirname).reduce(commonDirectory);\n\tconst entries = await Promise.all(\n\t\tfiles.map(async (file) => ({\n\t\t\tname: relative(root, file).split(sep).join(\"/\"),\n\t\t\tcontent: await readFile(file),\n\t\t})),\n\t);\n\tconst sizes = await Promise.all(\n\t\tfiles.map(async (file) => (await stat(file)).size),\n\t);\n\tconst id = await uploadArtifact(name, await zip(entries), retentionDays);\n\treturn {\n\t\tid,\n\t\tfiles: entries.map((entry) => entry.name),\n\t\tsize: sizes.reduce((sum, bytes) => sum + bytes, 0),\n\t};\n}\n\nfunction commonDirectory(a: string, b: string): string {\n\tconst left = a.split(sep);\n\tconst right = b.split(sep);\n\tlet length = 0;\n\twhile (length < left.length && left[length] === right[length]) length++;\n\treturn left.slice(0, length).join(sep) || sep;\n}\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { formatSize, inComponent, resolveFiles } from \"../../utils/files.ts\";\nimport { fill } from \"../../utils/template.ts\";\nimport { plural } from \"../../utils/text.ts\";\nimport { canUploadArtifacts, uploadFiles } from \"./artifact.ts\";\n\n/**\n * Keeps files as an artifact of the workflow run; with `dryRunArtifact`, in\n * dry runs too, e.g. to keep what a dry run built.\n */\nexport const githubUploadArtifact = defineStep({\n\tphase: \"release\",\n\tname: \"github/upload-artifact\",\n\tdescription:\n\t\t\"Uploads files as a workflow artifact. Only works in the GitHub Action.\",\n\toptions: {\n\t\tname: z\n\t\t\t.string()\n\t\t\t.describe(\n\t\t\t\t\"The artifact's name, unique in the run; `{version}`, `{tag}` and the other placeholders are filled in.\",\n\t\t\t),\n\t\tfiles: z\n\t\t\t.array(z.string())\n\t\t\t.min(1)\n\t\t\t.describe(\n\t\t\t\t\"Paths, globs or directories, relative to the component's directory unless absolute; each must match.\",\n\t\t\t),\n\t\tdryRunArtifact: z\n\t\t\t.boolean()\n\t\t\t.default(false)\n\t\t\t.describe(\"Upload in dry runs too.\"),\n\t\tretentionDays: z\n\t\t\t.number()\n\t\t\t.int()\n\t\t\t.min(1)\n\t\t\t.optional()\n\t\t\t.describe(\"Defaults to the repository's setting.\"),\n\t},\n\trun: async ({ env, component, placeholders, options }) => {\n\t\tconst name = fill(options.name, placeholders);\n\t\tconst files = await resolveFiles(\n\t\t\tinComponent(env, component, \".\").file,\n\t\t\toptions.files,\n\t\t);\n\t\tconst listed = `${plural(files.length, \"file\")} as artifact ${name}`;\n\t\tif (env.dryRun && !(options.dryRunArtifact && canUploadArtifacts())) {\n\t\t\treturn {\n\t\t\t\toutput: { name, id: null, files: [] },\n\t\t\t\treason: `would upload ${listed}${options.dryRunArtifact ? \" (outside GitHub Actions)\" : \"\"}`,\n\t\t\t};\n\t\t}\n\t\tconst uploaded = await uploadFiles(name, files, options.retentionDays);\n\t\treturn {\n\t\t\toutput: { name, id: uploaded.id, files: uploaded.files },\n\t\t\treason: `uploaded ${plural(files.length, \"file\")} (${formatSize(uploaded.size)}) as artifact ${name}`,\n\t\t};\n\t},\n});\n","import { createHash } from \"node:crypto\";\nimport { readFile, stat } from \"node:fs/promises\";\nimport { basename } from \"node:path\";\nimport { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { formatSize, inComponent, resolveFiles } from \"../../utils/files.ts\";\nimport { git } from \"../../utils/git.ts\";\nimport { fill } from \"../../utils/template.ts\";\nimport { joinList } from \"../../utils/text.ts\";\nimport { githubClient, githubToken } from \"./api.ts\";\nimport { canUploadArtifacts, uploadFiles } from \"./artifact.ts\";\nimport {\n\tassetName,\n\tensureRelease,\n\tisPrerelease,\n\treleaseOptions,\n\treleaseRepo,\n\tuploadAsset,\n} from \"./release.ts\";\n\n/**\n * Uploads files to the version's GitHub release, creating the release if no\n * other step or job has yet, so that jobs building different files can each\n * upload their own.\n */\nexport const githubUploadReleaseAssets = defineStep({\n\tphase: \"release\",\n\tname: \"github/upload-release-assets\",\n\tdescription:\n\t\t\"Uploads files to the GitHub release, creating it (with the notes) if no other job has yet.\",\n\toptions: {\n\t\tfiles: z\n\t\t\t.array(z.string())\n\t\t\t.min(1)\n\t\t\t.describe(\n\t\t\t\t\"Paths or globs, relative to the component's directory unless absolute; each must match.\",\n\t\t\t),\n\t\tclobber: z\n\t\t\t.boolean()\n\t\t\t.default(true)\n\t\t\t.describe(\"Replace assets of the same name.\"),\n\t\tdryRunArtifact: z\n\t\t\t.boolean()\n\t\t\t.default(false)\n\t\t\t.describe(\n\t\t\t\t\"In dry runs, keep the files as a workflow artifact instead; only in the GitHub Action.\",\n\t\t\t),\n\t\tartifactName: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Unique in the run; `{version}`, `{tag}` and the other placeholders are filled in. Defaults to the asset's name, or for several, a name made from theirs.\",\n\t\t\t),\n\t\t...releaseOptions,\n\t},\n\trun: async ({ env, component, tag, placeholders, notes, options }) => {\n\t\tconst title = fill(options.title, placeholders);\n\t\tconst repo = await releaseRepo(env.cwd, options.repo);\n\t\tconst files = await resolveFiles(\n\t\t\tinComponent(env, component, \".\").file,\n\t\t\toptions.files,\n\t\t);\n\t\tconst sizes = await Promise.all(\n\t\t\tfiles.map(async (file) => (await stat(file)).size),\n\t\t);\n\t\tconst listed = files.map(\n\t\t\t(file, index) =>\n\t\t\t\t`${assetName(basename(file))} (${formatSize(sizes[index] ?? 0)})`,\n\t\t);\n\t\tif (env.dryRun) {\n\t\t\tconst reason = `would upload ${joinList(listed)} to release ${tag} on ${repo}`;\n\t\t\tif (!options.dryRunArtifact) {\n\t\t\t\treturn { output: { repo, tag, url: null, assets: [] }, reason };\n\t\t\t}\n\t\t\tconst artifact = artifactNameOf(\n\t\t\t\tfiles,\n\t\t\t\toptions.artifactName,\n\t\t\t\tplaceholders,\n\t\t\t);\n\t\t\tif (!canUploadArtifacts()) {\n\t\t\t\treturn {\n\t\t\t\t\toutput: { repo, tag, url: null, assets: [], artifact: null },\n\t\t\t\t\treason: `${reason} (no artifact ${artifact} outside GitHub Actions)`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst { id } = await uploadFiles(artifact, files);\n\t\t\treturn {\n\t\t\t\toutput: {\n\t\t\t\t\trepo,\n\t\t\t\t\ttag,\n\t\t\t\t\turl: null,\n\t\t\t\t\tassets: [],\n\t\t\t\t\tartifact: { name: artifact, id },\n\t\t\t\t},\n\t\t\t\treason: `${reason}; kept them as artifact ${artifact}`,\n\t\t\t};\n\t\t}\n\n\t\tconst client = githubClient(repo, githubToken(options.token));\n\t\tconst { release, created } = await ensureRelease(client, {\n\t\t\ttag,\n\t\t\ttarget: await git(env.cwd, \"rev-parse\", \"HEAD\"),\n\t\t\ttitle,\n\t\t\tnotes,\n\t\t\tdraft: options.draft,\n\t\t\tprerelease: isPrerelease(options.prerelease, env),\n\t\t});\n\t\tconst assets = [];\n\t\tfor (const file of files) {\n\t\t\tconst asset = await uploadAsset(\n\t\t\t\tclient,\n\t\t\t\trelease,\n\t\t\t\t{ name: basename(file), content: await readFile(file) },\n\t\t\t\toptions.clobber,\n\t\t\t);\n\t\t\tassets.push({\n\t\t\t\tname: asset.name,\n\t\t\t\tsize: asset.size,\n\t\t\t\turl: asset.browser_download_url,\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\toutput: { repo, tag, url: release.html_url, assets },\n\t\t\treason: `uploaded ${joinList(listed)} to ${created ? \"new\" : \"existing\"} release ${tag}: ${release.html_url}`,\n\t\t};\n\t},\n});\n\nfunction artifactNameOf(\n\tfiles: readonly string[],\n\tname: string | undefined,\n\tplaceholders: Readonly<Record<string, string>>,\n): string {\n\tif (name !== undefined) return fill(name, placeholders);\n\tconst assets = files.map((file) => assetName(basename(file)));\n\tif (assets.length === 1 && assets[0]) return assets[0];\n\tconst hash = createHash(\"sha256\").update(assets.join(\"\\n\")).digest(\"hex\");\n\treturn `release-assets-${hash.slice(0, 8)}`;\n}\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { git } from \"../../utils/git.ts\";\nimport { retry } from \"../../utils/retry.ts\";\nimport { fill } from \"../../utils/template.ts\";\n\ninterface Release {\n\ttag_name: string;\n\t_links: { self: string };\n}\n\nclass GitLabError extends Error {\n\treadonly status: number;\n\n\tconstructor(status: number, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"GitLabError\";\n\t\tthis.status = status;\n\t}\n}\n\n/**\n * Creates a GitLab release for the version, with the notes as its\n * description, or finds the one another job already created. In GitLab CI,\n * the project, API and job token come from the job's environment.\n */\nexport const gitlabCreateRelease = defineStep({\n\tphase: \"release\",\n\tname: \"gitlab/create-release\",\n\tdescription:\n\t\t\"Creates a GitLab release of the tag with the notes, unless it already has one; the tag is created at HEAD if it doesn't exist.\",\n\toptions: {\n\t\ttitle: z\n\t\t\t.string()\n\t\t\t.default(\"{tag}\")\n\t\t\t.describe(\n\t\t\t\t\"`{tag}`, `{version}`, `{name}` and the scheme's placeholders are filled in.\",\n\t\t\t),\n\t\tproject: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"The project's ID or path, e.g. `group/project`; defaults to `CI_PROJECT_ID`.\",\n\t\t\t),\n\t\ttoken: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Defaults to `GITLAB_TOKEN`, then the job's `CI_JOB_TOKEN`.\"),\n\t},\n\trun: async ({ env, tag, placeholders, notes, options }) => {\n\t\tconst title = fill(options.title, placeholders);\n\t\tconst project = options.project ?? process.env.CI_PROJECT_ID;\n\t\tif (!project) {\n\t\t\tthrow new Error(\n\t\t\t\t\"couldn't determine the GitLab project; set `project` or CI_PROJECT_ID\",\n\t\t\t);\n\t\t}\n\t\tif (env.dryRun) {\n\t\t\treturn {\n\t\t\t\toutput: { project, tag, url: null },\n\t\t\t\treason: `would create release ${tag} on ${project}`,\n\t\t\t};\n\t\t}\n\t\tconst request = gitlabClient(project, options.token);\n\t\tlet created = true;\n\t\tlet release: Release;\n\t\ttry {\n\t\t\trelease = await request<Release>(\"POST\", \"/releases\", {\n\t\t\t\ttag_name: tag,\n\t\t\t\tref: await git(env.cwd, \"rev-parse\", \"HEAD\"),\n\t\t\t\tname: title,\n\t\t\t\tdescription: notes,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// 409: the tag already has a release, e.g. from another job.\n\t\t\tif (!(error instanceof GitLabError && error.status === 409)) throw error;\n\t\t\tcreated = false;\n\t\t\trelease = await request<Release>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/releases/${encodeURIComponent(tag)}`,\n\t\t\t);\n\t\t}\n\t\tconst url = release._links.self;\n\t\treturn {\n\t\t\toutput: { project, tag, url },\n\t\t\treason: `${created ? \"created\" : \"found existing\"} release ${tag}: ${url}`,\n\t\t};\n\t},\n});\n\n/** Requests to a project's REST API, retrying rate limits and server errors. */\nfunction gitlabClient(project: string, token: string | undefined) {\n\tconst api = process.env.CI_API_V4_URL || \"https://gitlab.com/api/v4\";\n\tconst auth = token ?? process.env.GITLAB_TOKEN;\n\tconst header = auth\n\t\t? { \"private-token\": auth }\n\t\t: process.env.CI_JOB_TOKEN\n\t\t\t? { \"job-token\": process.env.CI_JOB_TOKEN }\n\t\t\t: undefined;\n\tif (!header)\n\t\tthrow new Error(\"no token; set GITLAB_TOKEN, or run in GitLab CI\");\n\treturn <T>(method: string, path: string, body?: unknown): Promise<T> =>\n\t\tretry(\n\t\t\tasync () => {\n\t\t\t\tconst url = `${api}/projects/${encodeURIComponent(project)}${path}`;\n\t\t\t\tconst response = await fetch(url, {\n\t\t\t\t\tmethod,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t...header,\n\t\t\t\t\t\t...(body !== undefined && { \"content-type\": \"application/json\" }),\n\t\t\t\t\t},\n\t\t\t\t\t...(body !== undefined && { body: JSON.stringify(body) }),\n\t\t\t\t});\n\t\t\t\tconst text = await response.text();\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new GitLabError(\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\t`GitLab responded ${response.status} to ${method} ${url}: ${text}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn JSON.parse(text) as T;\n\t\t\t},\n\t\t\t{\n\t\t\t\tattempts: 5,\n\t\t\t\tretryIf: (error) =>\n\t\t\t\t\terror instanceof GitLabError\n\t\t\t\t\t\t? error.status === 429 || error.status >= 500\n\t\t\t\t\t\t: error instanceof TypeError,\n\t\t\t},\n\t\t);\n}\n","/** The `## [Unreleased]` heading of a Keep a Changelog file. */\nconst UNRELEASED = /^##\\s+\\[?unreleased\\]?\\s*$/i;\n\nexport interface Unreleased {\n\t/** Line indices of the heading, and of the next `## ` heading or the end. */\n\tstart: number;\n\tend: number;\n}\n\n/** Finds the `## [Unreleased]` section of a changelog's lines. */\nexport function findUnreleased(\n\tlines: readonly string[],\n\tpath: string,\n): Unreleased {\n\tconst start = lines.findIndex((line) => UNRELEASED.test(line));\n\tif (start === -1) throw new Error(`${path} has no '## [Unreleased]' section`);\n\tconst next = lines.findIndex((line, i) => i > start && /^##\\s/.test(line));\n\treturn { start, end: next === -1 ? lines.length : next };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport type { ChangeWith } from \"../../core/types.ts\";\nimport { inComponent } from \"../../utils/files.ts\";\nimport { plural } from \"../../utils/text.ts\";\nimport { findUnreleased } from \"./changelog.ts\";\n\n/**\n * Collects the entries of the `## [Unreleased]` section of a changelog kept as\n * on keepachangelog.com: each top-level bullet is a change, labeled with its\n * `### Added`, `### Fixed` … heading, and the lines under it its description.\n */\nexport const keepAChangelogReadUnreleased = defineStep({\n\tphase: \"read-changes\",\n\tname: \"keep-a-changelog/read-unreleased\",\n\tdescription:\n\t\t\"Collects each entry under `## [Unreleased]` in a Keep a Changelog file, labeled with its `### Added`, `### Fixed` … heading.\",\n\tprovides: [\"changes.title\", \"changes.labels\"],\n\toptions: {\n\t\tpath: z\n\t\t\t.string()\n\t\t\t.default(\"CHANGELOG.md\")\n\t\t\t.describe(\"Relative to the component's directory.\"),\n\t},\n\trun: async ({ env, component, options }) => {\n\t\tconst { file, relative: path } = inComponent(env, component, options.path);\n\t\tconst lines = (await readFile(file, \"utf8\")).split(/\\r?\\n/);\n\t\tconst { start, end } = findUnreleased(lines, path);\n\t\tconst changes: ChangeWith<\"title\" | \"labels\">[] = [];\n\t\tlet category: string | undefined;\n\t\tlet current:\n\t\t\t| { change: ChangeWith<\"title\" | \"labels\">; body: string[] }\n\t\t\t| undefined;\n\t\tconst finish = () => {\n\t\t\tconst description = current?.body.join(\"\\n\").trim();\n\t\t\tif (current && description) current.change.description = description;\n\t\t\tcurrent = undefined;\n\t\t};\n\t\tfor (let i = start + 1; i < end; i++) {\n\t\t\tconst line = lines[i] ?? \"\";\n\t\t\tconst heading = /^###\\s+(.+?)\\s*$/.exec(line);\n\t\t\tconst bullet = /^[-*+]\\s+(.*)$/.exec(line);\n\t\t\tif (heading) {\n\t\t\t\tfinish();\n\t\t\t\tcategory = heading[1];\n\t\t\t} else if (bullet) {\n\t\t\t\tfinish();\n\t\t\t\tcurrent = {\n\t\t\t\t\tchange: {\n\t\t\t\t\t\ttitle: (bullet[1] ?? \"\").trim(),\n\t\t\t\t\t\treason: `${path} line ${i + 1}`,\n\t\t\t\t\t\tlabels: category ? [category] : [],\n\t\t\t\t\t},\n\t\t\t\t\tbody: [],\n\t\t\t\t};\n\t\t\t\tchanges.push(current.change);\n\t\t\t} else if (current && (line.trim() === \"\" || /^\\s/.test(line))) {\n\t\t\t\t// Continuation lines, indented under the bullet.\n\t\t\t\tcurrent.body.push(line.replace(/^ {1,2}|^\\t/, \"\"));\n\t\t\t} else {\n\t\t\t\tfinish();\n\t\t\t}\n\t\t}\n\t\tfinish();\n\t\treturn {\n\t\t\tchanges,\n\t\t\treason: `${plural(changes.length, \"entry\", \"entries\")} under ${lines[start]?.trim()} in ${path}`,\n\t\t};\n\t},\n});\n","import { readFile, writeFile } from \"node:fs/promises\";\nimport { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { inComponent } from \"../../utils/files.ts\";\nimport { fill, VERSION_PLACEHOLDERS } from \"../../utils/template.ts\";\nimport { channelsOption, skipOnChannel } from \"../channels.ts\";\nimport { findUnreleased } from \"./changelog.ts\";\n\n/** A `[unreleased]: <base>/compare/<tag>...HEAD` link definition. */\nconst UNRELEASED_LINK =\n\t/^\\[unreleased\\]:\\s*(\\S+)\\/compare\\/(\\S+?)\\.\\.\\.HEAD\\s*$/i;\n\n/**\n * Releases the `## [Unreleased]` section of a Keep a Changelog file: its\n * entries move under a heading for the version, and an empty\n * `## [Unreleased]` takes its place. A `[unreleased]: …/compare/v1.0.0...HEAD`\n * link moves on to the new tag, and the version gets its own compare link.\n */\nexport const keepAChangelogWriteRelease = defineStep({\n\tphase: \"write\",\n\tname: \"keep-a-changelog/write-release\",\n\tdescription:\n\t\t\"Moves the entries under `## [Unreleased]` to a heading for the version, and updates the compare links, if there are any.\",\n\toptions: {\n\t\tpath: z\n\t\t\t.string()\n\t\t\t.default(\"CHANGELOG.md\")\n\t\t\t.describe(\"Relative to the component's directory.\"),\n\t\theading: z\n\t\t\t.string()\n\t\t\t.default(\"## [{version}] - {date}\")\n\t\t\t.describe(`${VERSION_PLACEHOLDERS}, and \\`{date}\\` (YYYY-MM-DD).`),\n\t\tchannels: channelsOption,\n\t},\n\trun: async ({ env, component, version, tag, placeholders, options }) => {\n\t\tconst { file, relative: path } = inComponent(env, component, options.path);\n\t\tconst skipped = skipOnChannel(env, options.channels, path);\n\t\tif (skipped) return skipped;\n\t\tconst text = await readFile(file, \"utf8\");\n\t\tconst lines = text.split(/\\r?\\n/);\n\t\tconst { start } = findUnreleased(lines, path);\n\t\tconst date = new Date().toISOString().slice(0, 10);\n\t\tconst heading = fill(options.heading, { ...placeholders, date });\n\t\tlines.splice(start + 1, 0, \"\", heading);\n\n\t\tconst link = lines.findIndex((line) => UNRELEASED_LINK.test(line));\n\t\tconst [, base, previous] = UNRELEASED_LINK.exec(lines[link] ?? \"\") ?? [];\n\t\tif (base !== undefined && previous !== undefined) {\n\t\t\tlines.splice(\n\t\t\t\tlink,\n\t\t\t\t1,\n\t\t\t\t`[unreleased]: ${base}/compare/${tag}...HEAD`,\n\t\t\t\t`[${version}]: ${base}/compare/${previous}...${tag}`,\n\t\t\t);\n\t\t}\n\n\t\tconst updated = `${heading}${base ? \" and its compare link\" : \"\"}`;\n\t\tif (env.dryRun) {\n\t\t\treturn {\n\t\t\t\toutput: { path, heading, written: false },\n\t\t\t\tfiles: [path],\n\t\t\t\treason: `would add ${updated} to ${path}`,\n\t\t\t};\n\t\t}\n\t\tawait writeFile(file, lines.join(text.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\"));\n\t\treturn {\n\t\t\toutput: { path, heading, written: true },\n\t\t\tfiles: [path],\n\t\t\treason: `added ${updated} to ${path}`,\n\t\t};\n\t},\n});\n","import type { Change } from \"../../core/types.ts\";\n\n/** Labels compare case-insensitively, as GitHub's do. */\nexport function hasLabel(change: Change, labels: readonly string[]): boolean {\n\tconst wanted = labels.map((label) => label.toLowerCase());\n\treturn (change.labels ?? []).some((label) =>\n\t\twanted.includes(label.toLowerCase()),\n\t);\n}\n\n/** Looks a label up in a map keyed by labels, ignoring case. */\nexport function lookup<V>(\n\tmap: Readonly<Record<string, V>>,\n\tlabel: string,\n): V | undefined {\n\tconst key = Object.keys(map).find(\n\t\t(other) => other.toLowerCase() === label.toLowerCase(),\n\t);\n\treturn key === undefined ? undefined : map[key];\n}\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { KINDS, type Kind } from \"../../core/types.ts\";\nimport { lookup } from \"./labels.ts\";\n\nconst RANK: Record<Kind, number> = { none: 0, fix: 1, feature: 2, breaking: 3 };\n\n/**\n * Each change's kind comes from its labels, e.g. a pull request's: the\n * highest of them, or `fallback` when none is mapped. The highest kind wins.\n */\nexport const labelsDetermineKind = defineStep({\n\tphase: \"determine-kind\",\n\tname: \"labels/determine-kind\",\n\tdescription:\n\t\t\"By each change's labels, e.g. a pull request's (`breaking` → breaking, `enhancement` → feature, anything else → fix). The highest kind wins.\",\n\tneeds: [\"changes.labels\"],\n\toptions: {\n\t\tkinds: z\n\t\t\t.record(z.string(), z.enum(KINDS))\n\t\t\t.default({\n\t\t\t\tbreaking: \"breaking\",\n\t\t\t\t\"semver:major\": \"breaking\",\n\t\t\t\tfeature: \"feature\",\n\t\t\t\tenhancement: \"feature\",\n\t\t\t\t\"semver:minor\": \"feature\",\n\t\t\t})\n\t\t\t.describe(\"Kinds by label, ignoring case.\"),\n\t\tfallback: z\n\t\t\t.enum(KINDS)\n\t\t\t.default(\"fix\")\n\t\t\t.describe(\"The kind of a change without a label in `kinds`.\"),\n\t},\n\trun: ({ changes, options }) => {\n\t\tlet best: { kind: Kind; reason: string } | undefined;\n\t\tfor (const change of changes) {\n\t\t\tlet candidate = {\n\t\t\t\tkind: options.fallback,\n\t\t\t\treason: `no label in kinds (${change.reason})`,\n\t\t\t};\n\t\t\tfor (const label of change.labels ?? []) {\n\t\t\t\tconst kind = lookup(options.kinds, label);\n\t\t\t\tif (kind !== undefined && RANK[kind] > RANK[candidate.kind]) {\n\t\t\t\t\tcandidate = { kind, reason: `'${label}' label (${change.reason})` };\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!best || RANK[candidate.kind] > RANK[best.kind]) best = candidate;\n\t\t\tif (best.kind === \"breaking\") break;\n\t\t}\n\t\treturn best ?? { kind: \"none\", reason: \"no changes\" };\n\t},\n});\n","import { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport type { Change } from \"../../core/types.ts\";\nimport {\n\tdependenciesOption,\n\tdependencySection,\n\tjoinSections,\n} from \"../notes.ts\";\nimport { hasLabel } from \"./labels.ts\";\n\n/**\n * A `### Title` section per group of labels, like GitHub's own release notes\n * categories, then the rest.\n */\nexport const labelsBuildNotes = defineStep({\n\tphase: \"determine-notes\",\n\tname: \"labels/determine-notes\",\n\tdescription:\n\t\t\"A `### Title` section per group of labels, e.g. `### Bug Fixes` for `bug`, then `### Other` for everything else.\",\n\tneeds: [\"changes.labels\"],\n\toptions: {\n\t\tsections: z\n\t\t\t.array(z.strictObject({ title: z.string(), labels: z.array(z.string()) }))\n\t\t\t.default([\n\t\t\t\t{ title: \"Breaking Changes\", labels: [\"breaking\", \"semver:major\"] },\n\t\t\t\t{ title: \"Features\", labels: [\"feature\", \"enhancement\"] },\n\t\t\t\t{ title: \"Bug Fixes\", labels: [\"bug\", \"fix\"] },\n\t\t\t])\n\t\t\t.describe(\n\t\t\t\t\"Sections in order; a change goes in the first with one of its labels, ignoring case.\",\n\t\t\t),\n\t\tother: z\n\t\t\t.union([z.string(), z.literal(false)])\n\t\t\t.default(\"Other\")\n\t\t\t.describe(\"The section for remaining changes; `false` leaves them out.\"),\n\t\texclude: z\n\t\t\t.array(z.string())\n\t\t\t.default([\"skip-changelog\"])\n\t\t\t.describe(\"Changes with any of these labels are left out.\"),\n\t\tdescriptions: z\n\t\t\t.boolean()\n\t\t\t.default(false)\n\t\t\t.describe(\"Write each change's description, indented, under it.\"),\n\t\tlinks: z\n\t\t\t.boolean()\n\t\t\t.default(true)\n\t\t\t.describe(\"Link each change to its source, e.g. its pull request.\"),\n\t\tdependencies: dependenciesOption,\n\t},\n\trun: ({ changes, kind, dependencies, options }) => {\n\t\tconst sections = [\n\t\t\t...options.sections,\n\t\t\t...(options.other === false ? [] : [{ title: options.other }]),\n\t\t].map((section) => ({ ...section, entries: [] as string[] }));\n\t\tfor (const change of changes) {\n\t\t\tif (hasLabel(change, options.exclude)) continue;\n\t\t\tconst target = sections.find(\n\t\t\t\t(section) => !(\"labels\" in section) || hasLabel(change, section.labels),\n\t\t\t);\n\t\t\tconst entry = format(change, options);\n\t\t\tif (target && entry !== undefined) target.entries.push(entry);\n\t\t}\n\t\treturn joinSections(kind, [\n\t\t\t...sections,\n\t\t\t...dependencySection(options.dependencies, dependencies),\n\t\t]);\n\t},\n});\n\nfunction format(\n\tchange: Change,\n\tstyle: { descriptions: boolean; links: boolean },\n): string | undefined {\n\tconst lines = (change.title ?? change.description ?? \"\").trim().split(\"\\n\");\n\tconst text = lines[0]?.trim();\n\tif (!text) return undefined;\n\tconst link =\n\t\tstyle.links && change.link\n\t\t\t? ` ([${change.link.label}](${change.link.url}))`\n\t\t\t: \"\";\n\t// Without a title, the description's first line stands in for it.\n\tconst body =\n\t\tchange.title === undefined ? lines.slice(1) : [change.description ?? \"\"];\n\tconst details = body.join(\"\\n\").trim();\n\tconst indented =\n\t\tstyle.descriptions && details\n\t\t\t? `\\n${details\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.map((line) => (line.trim() ? ` ${line}` : \"\"))\n\t\t\t\t\t.join(\"\\n\")}`\n\t\t\t: \"\";\n\treturn `- ${text}${link}${indented}`;\n}\n","import { access, mkdtemp, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { homedir, tmpdir } from \"node:os\";\nimport { dirname, join, posix } from \"node:path\";\nimport { defineStep } from \"../../core/define.ts\";\nimport { z } from \"../../core/options.ts\";\nimport { exec } from \"../../utils/exec.ts\";\nimport { inComponent, loadJson } from \"../../utils/files.ts\";\nimport { versionOf } from \"./package-json.ts\";\n\nconst DEFAULT_REGISTRY = \"https://registry.npmjs.org/\";\n\n/**\n * Publishes the package to npm, after earlier steps wrote the new version to\n * `package.json`. Lifecycle scripts like `prepublishOnly` run as usual.\n */\nexport const npmPublish = defineStep({\n\tphase: \"release\",\n\tname: \"npm/publish\",\n\tdescription:\n\t\t\"Publishes the component's package to the npm registry with `npm` or `pnpm publish`; components are published dependencies first.\",\n\tneeds: [\"version.semver\"],\n\toptions: {\n\t\tpath: z\n\t\t\t.string()\n\t\t\t.default(\".\")\n\t\t\t.describe(\"The package's directory, relative to the component's.\"),\n\t\tclient: z\n\t\t\t.enum([\"npm\", \"pnpm\"])\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Defaults to the `packageManager` in package.json, then `pnpm` if there's a `pnpm-lock.yaml`, then `npm`.\",\n\t\t\t),\n\t\ttag: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"The dist-tag; defaults to the channel's name on a channel, then `publishConfig.tag`, or `latest`.\",\n\t\t\t),\n\t\taccess: z\n\t\t\t.enum([\"public\", \"restricted\"])\n\t\t\t.optional()\n\t\t\t.describe(\"Defaults to `publishConfig.access`.\"),\n\t\tprovenance: z\n\t\t\t.boolean()\n\t\t\t.default(false)\n\t\t\t.describe(\n\t\t\t\t\"Publishes with a provenance statement; needs `id-token: write`.\",\n\t\t\t),\n\t\tregistry: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\"Defaults to `publishConfig.registry`, or the npm registry.\"),\n\t\ttoken: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.describe(\n\t\t\t\t\"Defaults to `NPM_TOKEN` or `NODE_AUTH_TOKEN`; without one, the client's own auth is used, e.g. trusted publishing.\",\n\t\t\t),\n\t},\n\trun: async ({ env, component, version, options }) => {\n\t\tconst { file: dir, relative } = inComponent(env, component, options.path);\n\t\tconst manifest = posix.join(relative, \"package.json\");\n\t\tconst json = await loadJson(join(dir, \"package.json\"));\n\t\tconst name = typeof json.name === \"string\" ? json.name : undefined;\n\t\tif (!name) throw new Error(`${manifest} has no 'name'`);\n\t\tif (json.private === true) {\n\t\t\tthrow new Error(`${manifest} is private; npm won't publish it`);\n\t\t}\n\t\tconst publishConfig = (json.publishConfig ?? {}) as Record<string, unknown>;\n\t\tconst registry =\n\t\t\toptions.registry ??\n\t\t\t(typeof publishConfig.registry === \"string\"\n\t\t\t\t? publishConfig.registry\n\t\t\t\t: DEFAULT_REGISTRY);\n\t\tconst client = options.client ?? (await detectClient(dir, json));\n\t\tconst tag =\n\t\t\toptions.tag ??\n\t\t\tenv.channel?.name ??\n\t\t\t(typeof publishConfig.tag === \"string\" ? publishConfig.tag : \"latest\");\n\t\tconst target = `${name}@${version} to ${registry} as ${tag}`;\n\t\tconst output = { name, version, client, tag, registry };\n\n\t\tif (env.dryRun) {\n\t\t\treturn {\n\t\t\t\toutput: { ...output, published: false },\n\t\t\t\treason: `would ${client} publish ${target}`,\n\t\t\t};\n\t\t}\n\n\t\t// Never publish a version other than the one being released, e.g. when\n\t\t// no earlier step wrote it to package.json.\n\t\tconst current = versionOf(json, manifest);\n\t\tif (current !== version) {\n\t\t\tthrow new Error(\n\t\t\t\t`${manifest} is at ${current}, not ${version}; write it first (npm/write-version)`,\n\t\t\t);\n\t\t}\n\n\t\tconst args = [\"publish\", \"--registry\", registry, \"--tag\", tag];\n\t\tif (options.access) args.push(\"--access\", options.access);\n\t\tif (options.provenance) args.push(\"--provenance\");\n\t\t// rylease commits and tags the release itself.\n\t\tif (client === \"pnpm\") args.push(\"--no-git-checks\");\n\n\t\tconst token =\n\t\t\toptions.token ?? process.env.NPM_TOKEN ?? process.env.NODE_AUTH_TOKEN;\n\t\tawait withToken(token, registry, (env) =>\n\t\t\texec(client, args, { cwd: dir, env }),\n\t\t);\n\t\treturn {\n\t\t\toutput: { ...output, published: true },\n\t\t\treason: `published ${target}`,\n\t\t};\n\t},\n});\n\nasync function detectClient(\n\tdir: string,\n\tjson: Record<string, unknown>,\n): Promise<\"npm\" | \"pnpm\"> {\n\tif (typeof json.packageManager === \"string\") {\n\t\treturn json.packageManager.startsWith(\"pnpm@\") ? \"pnpm\" : \"npm\";\n\t}\n\t// The lockfile may be at a workspace root above the package.\n\tfor (let current = dir; ; current = dirname(current)) {\n\t\tif (await exists(join(current, \"pnpm-lock.yaml\"))) return \"pnpm\";\n\t\tif (await exists(join(current, \"package-lock.json\"))) return \"npm\";\n\t\tif (dirname(current) === current) return \"npm\";\n\t}\n}\n\nfunction exists(path: string): Promise<boolean> {\n\treturn access(path).then(\n\t\t() => true,\n\t\t() => false,\n\t);\n}\n\n/**\n * Runs `run` with an environment that authenticates to the registry with the\n * token, if there is one: a copy of the user's npmrc with the token's key\n * added, which both npm and pnpm read. The token itself stays in the\n * environment, never on disk.\n */\nasync function withToken<T>(\n\ttoken: string | undefined,\n\tregistry: string,\n\trun: (env: NodeJS.ProcessEnv) => Promise<T>,\n): Promise<T> {\n\tif (!token) return run(process.env);\n\tconst userconfig =\n\t\tprocess.env.NPM_CONFIG_USERCONFIG ??\n\t\tprocess.env.npm_config_userconfig ??\n\t\tjoin(homedir(), \".npmrc\");\n\tconst existing = await readFile(userconfig, \"utf8\").catch(() => \"\");\n\tconst dir = await mkdtemp(join(tmpdir(), \"rylease-npmrc-\"));\n\ttry {\n\t\tconst npmrc = join(dir, \".npmrc\");\n\t\tawait writeFile(\n\t\t\tnpmrc,\n\t\t\t`${existing.trimEnd()}\\n${authKey(registry)}=\\${RYLEASE_NPM_TOKEN}\\n`.trimStart(),\n\t\t);\n\t\tconst { npm_config_userconfig: _, ...env } = process.env;\n\t\treturn await run({\n\t\t\t...env,\n\t\t\tNPM_CONFIG_USERCONFIG: npmrc,\n\t\t\tRYLEASE_NPM_TOKEN: token,\n\t\t});\n\t} finally {\n\t\tawait rm(dir, { recursive: true, force: true });\n\t}\n}\n\n/** The npmrc key of a registry's token, e.g. `//registry.npmjs.org/:_authToken`. */\nfunction authKey(registry: string): string {\n\tconst url = new URL(registry);\n\tconst path = url.pathname.endsWith(\"/\") ? url.pathname : `${url.pathname}/`;\n\treturn `//${url.host}${path}:_authToken`;\n}\n","export * from \"./change-files/index.ts\";\nexport * from \"./components/index.ts\";\nexport * from \"./conventional/index.ts\";\nexport * from \"./exec/index.ts\";\nexport * from \"./fs/index.ts\";\nexport * from \"./git/index.ts\";\nexport * from \"./github/index.ts\";\nexport * from \"./gitlab/index.ts\";\nexport * from \"./keep-a-changelog/index.ts\";\nexport * from \"./labels/index.ts\";\nexport * from \"./npm/index.ts\";\n","import { definePreset } from \"../core/define.ts\";\nimport { gitTags } from \"../histories/index.ts\";\nimport {\n\tchangeFilesClean,\n\tchangeFilesRead,\n\tfsWriteChanges,\n\tgitCommit,\n\tgitCreateTag,\n\tgithubCreateRelease,\n\tlabelsBuildNotes,\n\tlabelsDetermineKind,\n} from \"../steps/index.ts\";\n\n/**\n * Change files in `.changes/` → notes by kind → the changelog written and\n * the change files deleted, committed and tagged → GitHub release. Each\n * file names the components it changes and how much, so a monorepo's\n * releases don't depend on commit messages. Add files with `rylease add`.\n * Releases are found by their tags; set the release's `scheme`.\n */\nexport const changeFiles = definePreset({\n\tname: \"change-files\",\n\tdescription:\n\t\t\"Change files in `.changes/` → changelog written and change files deleted, committed, git tag and GitHub release.\",\n\tsteps: [\n\t\tchangeFilesRead,\n\t\tlabelsDetermineKind,\n\t\tlabelsBuildNotes,\n\t\tchangeFilesClean,\n\t\tfsWriteChanges,\n\t\tgitCommit,\n\t\tgitCreateTag,\n\t\tgithubCreateRelease,\n\t],\n\tdefaults: {\n\t\t\"labels/determine-kind\": {\n\t\t\tkinds: {\n\t\t\t\tbreaking: \"breaking\",\n\t\t\t\tfeature: \"feature\",\n\t\t\t\tfix: \"fix\",\n\t\t\t\tnone: \"none\",\n\t\t\t},\n\t\t},\n\t\t\"labels/determine-notes\": {\n\t\t\tsections: [\n\t\t\t\t{ title: \"Breaking Changes\", labels: [\"breaking\"] },\n\t\t\t\t{ title: \"Features\", labels: [\"feature\"] },\n\t\t\t\t{ title: \"Fixes\", labels: [\"fix\"] },\n\t\t\t],\n\t\t\tother: false,\n\t\t\texclude: [\"none\"],\n\t\t\tdescriptions: true,\n\t\t},\n\t\t\"git/create-tag\": { push: \"origin\" },\n\t},\n\thistory: gitTags,\n});\n","import { z } from \"../core/options.ts\";\nimport { defineScheme } from \"../core/scheme.ts\";\nimport type { ReleaseKind } from \"../core/types.ts\";\nimport {\n\tcompareVersions,\n\tparseVersion,\n\ttype Version,\n} from \"../utils/version.ts\";\n\n/** The date tokens of calver.org, by what they're made from. */\nconst DATES = {\n\tYYYY: (date: Parts) => String(date.year),\n\tYY: (date: Parts) => String(date.year - 2000),\n\t\"0Y\": (date: Parts) => String(date.year - 2000).padStart(2, \"0\"),\n\tMM: (date: Parts) => String(date.month),\n\t\"0M\": (date: Parts) => String(date.month).padStart(2, \"0\"),\n\tWW: (date: Parts) => String(date.week),\n\t\"0W\": (date: Parts) => String(date.week).padStart(2, \"0\"),\n\tDD: (date: Parts) => String(date.day),\n\t\"0D\": (date: Parts) => String(date.day).padStart(2, \"0\"),\n} as const;\n\n/** Counters, from the kind each one is bumped for. */\nconst COUNTERS = { MAJOR: \"breaking\", MINOR: \"feature\", MICRO: \"fix\" } as const;\n\nconst RANK: Record<ReleaseKind, number> = { fix: 0, feature: 1, breaking: 2 };\n\ntype DateToken = keyof typeof DATES;\ntype Counter = keyof typeof COUNTERS;\ntype Token = DateToken | Counter;\n\nconst TOKENS = [...Object.keys(DATES), ...Object.keys(COUNTERS)];\n\ninterface Parts {\n\tyear: number;\n\tmonth: number;\n\tday: number;\n\tweek: number;\n}\n\n/**\n * Calendar versioning, as on calver.org: the format's date tokens come from\n * the release date, and its counters (`MAJOR`, `MINOR`, `MICRO`) number the\n * releases within the same period. A counter is bumped by the kind it stands\n * for (`breaking`, `feature`, `fix`), or by a higher kind when the format has\n * no counter for that; the counters after it start again from 0, as do all of\n * them in a new period.\n */\nexport const calver = defineScheme({\n\tname: \"calver\",\n\tdescription:\n\t\t\"Dates the version, as on calver.org, e.g. `YYYY.MM.MICRO` → `2026.10.0`; a counter numbers releases in the same period, bumped by the kind.\",\n\toptions: {\n\t\tformat: z\n\t\t\t.string()\n\t\t\t.default(\"YYYY.MM.MICRO\")\n\t\t\t.refine(\n\t\t\t\t(format) =>\n\t\t\t\t\tformat.split(\".\").every((token) => TOKENS.includes(token)) &&\n\t\t\t\t\tnew Set(format.split(\".\")).size === format.split(\".\").length,\n\t\t\t\t`must be distinct tokens joined by '.', of ${TOKENS.join(\", \")}`,\n\t\t\t)\n\t\t\t.refine(\n\t\t\t\t(format) => format.split(\".\").some((token) => token in DATES),\n\t\t\t\t\"must have a date token, e.g. YYYY\",\n\t\t\t)\n\t\t\t.describe(\n\t\t\t\t\"Tokens joined by `.`: `YYYY`, `YY`, `0Y`, `MM`, `0M`, `WW`, `0W`, `DD`, `0D` (ISO 8601 weeks, with the ISO year), and the counters `MAJOR`, `MINOR`, `MICRO`. Zero-padded tokens (`0M` …) aren't valid semver, which npm needs.\",\n\t\t\t),\n\t\ttimezone: z\n\t\t\t.string()\n\t\t\t.default(\"UTC\")\n\t\t\t.refine(isTimezone, \"must be an IANA time zone, e.g. Europe/Berlin\")\n\t\t\t.describe(\"Where the release date is taken, e.g. `America/New_York`.\"),\n\t},\n\tcreate: (options) => {\n\t\tconst format = options.format.split(\".\") as Token[];\n\t\tconst matches = (version: string) => {\n\t\t\tconst parts = version.trim().split(\".\");\n\t\t\treturn (\n\t\t\t\tparts.length === format.length &&\n\t\t\t\tparts.every((part, i) => SHAPES[format[i] as Token].test(part))\n\t\t\t);\n\t\t};\n\t\tconst padded = format.some((token) => token.startsWith(\"0\"));\n\t\treturn {\n\t\t\tname: `calver ${options.format}`,\n\t\t\ttraits: padded ? [] : [\"version.semver\"],\n\t\t\tmatches,\n\t\t\tcompare: (a, b) =>\n\t\t\t\tcompareVersions(parseVersion(a) as Version, parseVersion(b) as Version),\n\t\t\tbump: ({ previous, kind, date: now }) => {\n\t\t\t\tconst date = dateParts(now, options.timezone, format);\n\t\t\t\t// The previous version's numbers, by token.\n\t\t\t\tconst before = previous?.split(\".\").map(Number);\n\t\t\t\tconst samePeriod =\n\t\t\t\t\tbefore !== undefined &&\n\t\t\t\t\tformat.every(\n\t\t\t\t\t\t(token, i) =>\n\t\t\t\t\t\t\t!(token in DATES) ||\n\t\t\t\t\t\t\tNumber(DATES[token as DateToken](date)) === before[i],\n\t\t\t\t\t);\n\t\t\t\tconst counters = format.filter((token): token is Counter =>\n\t\t\t\t\tObject.hasOwn(COUNTERS, token),\n\t\t\t\t);\n\t\t\t\tconst bumped = samePeriod ? bumpedCounter(counters, kind) : undefined;\n\t\t\t\tif (samePeriod && bumped === undefined) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${previous} is already this period's release; add a counter (e.g. MICRO) to '${options.format}' to release more often`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst values = format.map((token, i) => {\n\t\t\t\t\tif (token in DATES) return DATES[token as DateToken](date);\n\t\t\t\t\tif (!samePeriod || bumped === undefined) return \"0\";\n\t\t\t\t\tconst index = format.indexOf(bumped);\n\t\t\t\t\tif (i < index) return String(before?.[i]);\n\t\t\t\t\treturn i === index ? String((before?.[i] ?? 0) + 1) : \"0\";\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tversion: values.join(\".\"),\n\t\t\t\t\treason:\n\t\t\t\t\t\tprevious === undefined\n\t\t\t\t\t\t\t? \"first release\"\n\t\t\t\t\t\t\t: samePeriod\n\t\t\t\t\t\t\t\t? `bumps ${bumped}`\n\t\t\t\t\t\t\t\t: \"new period\",\n\t\t\t\t};\n\t\t\t},\n\t\t\tfields: (version) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tformat.map((token, i) => [token, version.split(\".\")[i] ?? \"\"]),\n\t\t\t\t),\n\t\t};\n\t},\n});\n\n/** What each token looks like in a version. */\nconst SHAPES: Record<Token, RegExp> = {\n\tYYYY: /^[1-9]\\d{3}$/,\n\tYY: /^(0|[1-9]\\d*)$/,\n\t\"0Y\": /^\\d{2,}$/,\n\tMM: /^([1-9]|1[0-2])$/,\n\t\"0M\": /^(0[1-9]|1[0-2])$/,\n\tWW: /^([1-9]|[1-4]\\d|5[0-3])$/,\n\t\"0W\": /^(0[1-9]|[1-4]\\d|5[0-3])$/,\n\tDD: /^([1-9]|[12]\\d|3[01])$/,\n\t\"0D\": /^(0[1-9]|[12]\\d|3[01])$/,\n\tMAJOR: /^(0|[1-9]\\d*)$/,\n\tMINOR: /^(0|[1-9]\\d*)$/,\n\tMICRO: /^(0|[1-9]\\d*)$/,\n};\n\n/**\n * The counter a kind bumps: its own, or the nearest one below it, or else the\n * lowest the format has (e.g. `MINOR` alone takes fixes too).\n */\nfunction bumpedCounter(\n\tcounters: readonly Counter[],\n\tkind: ReleaseKind,\n): Counter | undefined {\n\tconst ranked = [...counters].sort(\n\t\t(a, b) => RANK[COUNTERS[b]] - RANK[COUNTERS[a]],\n\t);\n\treturn (\n\t\tranked.find((counter) => RANK[COUNTERS[counter]] <= RANK[kind]) ??\n\t\tranked.at(-1)\n\t);\n}\n\nfunction dateParts(\n\tnow: Date,\n\ttimezone: string,\n\tformat: readonly Token[],\n): Parts {\n\tconst fields = Object.fromEntries(\n\t\tnew Intl.DateTimeFormat(\"en-US\", {\n\t\t\ttimeZone: timezone,\n\t\t\tyear: \"numeric\",\n\t\t\tmonth: \"numeric\",\n\t\t\tday: \"numeric\",\n\t\t})\n\t\t\t.formatToParts(now)\n\t\t\t.map(({ type, value }) => [type, Number(value)]),\n\t) as { year: number; month: number; day: number };\n\tconst iso = isoWeek(fields.year, fields.month, fields.day);\n\t// With weeks, the year is the ISO year, so the last days of December can\n\t// belong to week 1 of the next.\n\tconst weekly = format.includes(\"WW\") || format.includes(\"0W\");\n\treturn { ...fields, year: weekly ? iso.year : fields.year, week: iso.week };\n}\n\n/** The ISO 8601 week of a date, and the year that week belongs to. */\nfunction isoWeek(\n\tyear: number,\n\tmonth: number,\n\tday: number,\n): { year: number; week: number } {\n\tconst date = new Date(Date.UTC(year, month - 1, day));\n\t// The week's Thursday decides its year; week 1 is the one with January 4th.\n\tdate.setUTCDate(date.getUTCDate() + 3 - weekday(date));\n\tconst weekYear = date.getUTCFullYear();\n\tconst first = new Date(Date.UTC(weekYear, 0, 4));\n\tfirst.setUTCDate(first.getUTCDate() + 3 - weekday(first));\n\tconst weeks = (date.getTime() - first.getTime()) / (7 * 86_400_000);\n\treturn { year: weekYear, week: 1 + Math.round(weeks) };\n}\n\n/** Monday is 0. */\nfunction weekday(date: Date): number {\n\treturn (date.getUTCDay() + 6) % 7;\n}\n\nfunction isTimezone(timezone: string): boolean {\n\ttry {\n\t\tnew Intl.DateTimeFormat(\"en-US\", { timeZone: timezone });\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n","export * from \"./calver.ts\";\nexport * from \"./semver.ts\";\n","import { definePreset } from \"../core/define.ts\";\nimport { gitTags } from \"../histories/index.ts\";\nimport { semver } from \"../schemes/index.ts\";\nimport {\n\tconventionalBuildNotes,\n\tconventionalDetermineKind,\n\tconventionalReadCommits,\n\tgitCreateTag,\n\tgithubCreateRelease,\n} from \"../steps/index.ts\";\n\n/**\n * Conventional commits since the previous release → git tag → GitHub\n * release, versioned by semver and found by its tags. Nothing specific to a\n * language or ecosystem; add steps like `fs/write-version`,\n * `fs/write-changes` and `git/commit` for that. The tag is pushed, with the\n * branch, to `origin`.\n */\nexport const conventional = definePreset({\n\tname: \"conventional\",\n\tdescription: \"Conventional commits → notes → git tag and GitHub release.\",\n\tsteps: [\n\t\tconventionalReadCommits,\n\t\tconventionalDetermineKind,\n\t\tconventionalBuildNotes,\n\t\tgitCreateTag,\n\t\tgithubCreateRelease,\n\t],\n\tdefaults: { \"git/create-tag\": { push: \"origin\" } },\n\tscheme: semver,\n\thistory: gitTags,\n});\n","import { definePreset } from \"../core/define.ts\";\nimport { githubReleasePr } from \"../histories/index.ts\";\nimport { semver } from \"../schemes/index.ts\";\nimport {\n\tconventionalBuildNotes,\n\tconventionalDetermineKind,\n\tconventionalReadCommits,\n\tfsWriteChanges,\n\tgitCreateTag,\n\tgithubCreateRelease,\n\tgithubOpenReleasePr,\n} from \"../steps/index.ts\";\n\n/**\n * Conventional commits → the changelog written and proposed in a release\n * pull request, kept up to date with each push; merging it tags the release\n * and creates its GitHub release. Versioned by semver; its history,\n * `github/release-pr`, is how the run on the merge finds what the pull\n * request proposed.\n */\nexport const conventionalPr = definePreset({\n\tname: \"conventional-pr\",\n\tdescription:\n\t\t\"Conventional commits → changelog proposed in a release pull request; merging it tags the release and creates its GitHub release.\",\n\tsteps: [\n\t\tconventionalReadCommits,\n\t\tconventionalDetermineKind,\n\t\tconventionalBuildNotes,\n\t\tfsWriteChanges,\n\t\tgithubOpenReleasePr,\n\t\tgitCreateTag,\n\t\tgithubCreateRelease,\n\t],\n\tdefaults: { \"git/create-tag\": { push: \"origin\" } },\n\tscheme: semver,\n\thistory: githubReleasePr,\n});\n","import { definePreset } from \"../core/define.ts\";\nimport { gitTags } from \"../histories/index.ts\";\nimport {\n\tgitCommit,\n\tgitCreateTag,\n\tgithubCreateRelease,\n\tkeepAChangelogReadUnreleased,\n\tkeepAChangelogWriteRelease,\n\tlabelsBuildNotes,\n\tlabelsDetermineKind,\n} from \"../steps/index.ts\";\n\nconst SECTIONS = [\n\t\"Added\",\n\t\"Changed\",\n\t\"Deprecated\",\n\t\"Removed\",\n\t\"Fixed\",\n\t\"Security\",\n];\n\n/**\n * `## [Unreleased]` in CHANGELOG.md → the changelog released, committed and\n * tagged → GitHub release. Each entry's kind comes from its section:\n * `Removed` is breaking, `Added`, `Changed` and `Deprecated` features, and\n * the rest fixes. Releases are found by their tags; set the release's\n * `scheme`, e.g. `semver()`, or `calver()` to date them.\n */\nexport const keepAChangelog = definePreset({\n\tname: \"keep-a-changelog\",\n\tdescription:\n\t\t\"`## [Unreleased]` in CHANGELOG.md → changelog committed, git tag and GitHub release.\",\n\tsteps: [\n\t\tkeepAChangelogReadUnreleased,\n\t\tlabelsDetermineKind,\n\t\tlabelsBuildNotes,\n\t\tkeepAChangelogWriteRelease,\n\t\tgitCommit,\n\t\tgitCreateTag,\n\t\tgithubCreateRelease,\n\t],\n\tdefaults: {\n\t\t\"labels/determine-kind\": {\n\t\t\tkinds: {\n\t\t\t\tRemoved: \"breaking\",\n\t\t\t\tAdded: \"feature\",\n\t\t\t\tChanged: \"feature\",\n\t\t\t\tDeprecated: \"feature\",\n\t\t\t},\n\t\t},\n\t\t\"labels/determine-notes\": {\n\t\t\tsections: SECTIONS.map((title) => ({ title, labels: [title] })),\n\t\t\tdescriptions: true,\n\t\t},\n\t\t\"git/create-tag\": { push: \"origin\" },\n\t},\n\thistory: gitTags,\n});\n","export * from \"./change-files.ts\";\nexport * from \"./conventional.ts\";\nexport * from \"./conventional-pr.ts\";\nexport * from \"./keep-a-changelog.ts\";\n","import { createRequire } from \"node:module\";\nimport { join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport * as components from \"../components/index.ts\";\nimport type { Channel } from \"../core/channels.ts\";\nimport type { Component, ComponentSource } from \"../core/components.ts\";\nimport type { AnyStepFactory, Preset, ReleaseConfig } from \"../core/define.ts\";\nimport { when } from \"../core/define.ts\";\nimport {\n\tcompileExpression,\n\tExpressionError,\n\texpressionContext,\n} from \"../core/expression.ts\";\nimport {\n\ttype AnyFactory,\n\ttype FactoryKind,\n\tisFactory,\n} from \"../core/factory.ts\";\nimport type { History } from \"../core/history.ts\";\nimport { joinPath, OptionsError, z } from \"../core/options.ts\";\nimport type { Scheme } from \"../core/scheme.ts\";\nimport type { Step } from \"../core/types.ts\";\nimport * as histories from \"../histories/index.ts\";\nimport * as presets from \"../presets/index.ts\";\nimport * as schemes from \"../schemes/index.ts\";\nimport * as steps from \"../steps/index.ts\";\n\ntype Loadable = AnyStepFactory | Preset | AnyFactory;\n\nconst builtins = new Map<string, Loadable>(\n\t(\n\t\t[\n\t\t\t...Object.values(steps),\n\t\t\t...Object.values(presets),\n\t\t\t...Object.values(schemes),\n\t\t\t...Object.values(histories),\n\t\t\t...Object.values(components),\n\t\t] as unknown[]\n\t)\n\t\t.filter((item): item is Loadable => isFactory(item))\n\t\t.map((item) => [item.name, item]),\n);\n\n/** What a workflow gives, already parsed from YAML. */\nexport interface WorkflowInput {\n\tsteps: unknown;\n\tscheme?: unknown;\n\ttag?: unknown;\n\thistory?: unknown;\n\tcomponents?: unknown;\n\tchannels?: unknown;\n}\n\nconst CHANNELS = z.record(\n\tz.string(),\n\tz.strictObject({\n\t\tbranches: z.array(z.string()).optional(),\n\t\ttype: z.enum([\"prerelease\", \"build\"]).optional(),\n\t\tformat: z.string().optional(),\n\t}),\n);\n\n/** A release defined in a workflow, ready for `defineRelease`. */\nexport type WorkflowRelease = Omit<ReleaseConfig<undefined>, \"context\">;\n\n/**\n * Turns a workflow's inputs into a release: its `steps`, and how versions are\n * made (`scheme`), tagged (`tag`), found (`history`), and of what\n * (`components`). Each of those but `tag` names what it `uses` and passes\n * it options `with`, or is just a name:\n *\n * ```yaml\n * scheme: { uses: calver, with: { format: YY.MINOR.MICRO } }\n * components: npm/workspaces\n * ```\n */\nexport async function resolveWorkflow(\n\tinput: WorkflowInput,\n\toptions: WorkflowOptions,\n): Promise<WorkflowRelease> {\n\tconst scheme =\n\t\tinput.scheme == null\n\t\t\t? undefined\n\t\t\t: await create<Scheme>(input.scheme, \"scheme\", \"scheme\", options.cwd);\n\tconst history =\n\t\tinput.history == null\n\t\t\t? undefined\n\t\t\t: await Promise.all(\n\t\t\t\t\t(Array.isArray(input.history) ? input.history : [input.history]).map(\n\t\t\t\t\t\t(entry, index) =>\n\t\t\t\t\t\t\tcreate<History>(\n\t\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\t\t\"history\",\n\t\t\t\t\t\t\t\tArray.isArray(input.history) ? `history[${index}]` : \"history\",\n\t\t\t\t\t\t\t\toptions.cwd,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\tif (input.tag != null && typeof input.tag !== \"string\") {\n\t\tthrow new OptionsError([\"tag: expected a template, e.g. v{version}\"]);\n\t}\n\treturn {\n\t\tsteps: await resolveWorkflowSteps(input.steps, options),\n\t\t...(scheme && { scheme }),\n\t\t...(typeof input.tag === \"string\" &&\n\t\t\tinput.tag !== \"\" && { tag: input.tag }),\n\t\t...(history && { history }),\n\t\t...(input.components != null && {\n\t\t\tcomponents: await resolveComponentsInput(input.components, options.cwd),\n\t\t}),\n\t\t...(input.channels != null && { channels: parseChannels(input.channels) }),\n\t};\n}\n\nfunction parseChannels(value: unknown): Record<string, Channel> {\n\tconst result = CHANNELS.safeParse(value);\n\tif (result.success) return result.data as Record<string, Channel>;\n\tthrow new OptionsError(\n\t\tresult.error.issues.map(\n\t\t\t(issue) => `${joinPath(\"channels\", issue.path)}: ${issue.message}`,\n\t\t),\n\t);\n}\n\nasync function resolveComponentsInput(\n\tvalue: unknown,\n\tcwd: string,\n): Promise<Component[] | ComponentSource> {\n\tif (!Array.isArray(value)) {\n\t\treturn create<ComponentSource>(value, \"components\", \"components\", cwd);\n\t}\n\tconst keys = [\"name\", \"path\", \"dependsOn\", \"tag\", \"scheme\", \"history\"];\n\tconst components: Component[] = [];\n\tfor (const [index, entry] of value.entries()) {\n\t\tconst at = `components[${index}]`;\n\t\tif (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n\t\t\tthrow new OptionsError([`${at}: expected a map with 'name' and 'path'`]);\n\t\t}\n\t\tconst fields = entry as Record<string, unknown>;\n\t\tconst unknown = Object.keys(fields).filter((key) => !keys.includes(key));\n\t\tif (unknown.length > 0) {\n\t\t\tthrow new OptionsError(\n\t\t\t\tunknown.map(\n\t\t\t\t\t(key) => `${at}.${key}: unknown key; use ${keys.join(\", \")}`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tconst text = (key: string) => {\n\t\t\tconst field = fields[key];\n\t\t\tif (field != null && typeof field !== \"string\") {\n\t\t\t\tthrow new OptionsError([`${at}.${key}: expected text`]);\n\t\t\t}\n\t\t\treturn field ?? undefined;\n\t\t};\n\t\tconst dependsOn = fields.dependsOn;\n\t\tif (\n\t\t\tdependsOn != null &&\n\t\t\t!(\n\t\t\t\tArray.isArray(dependsOn) &&\n\t\t\t\tdependsOn.every((item) => typeof item === \"string\")\n\t\t\t)\n\t\t) {\n\t\t\tthrow new OptionsError([\n\t\t\t\t`${at}.dependsOn: expected a list of component names`,\n\t\t\t]);\n\t\t}\n\t\tconst name = text(\"name\");\n\t\tconst path = text(\"path\");\n\t\tconst tag = text(\"tag\");\n\t\tcomponents.push({\n\t\t\tname: name ?? \"\",\n\t\t\t...(path !== undefined && { path }),\n\t\t\t...(tag !== undefined && { tag }),\n\t\t\t...(dependsOn != null && { dependsOn: dependsOn as string[] }),\n\t\t\t...(fields.scheme != null && {\n\t\t\t\tscheme: await create<Scheme>(\n\t\t\t\t\tfields.scheme,\n\t\t\t\t\t\"scheme\",\n\t\t\t\t\t`${at}.scheme`,\n\t\t\t\t\tcwd,\n\t\t\t\t),\n\t\t\t}),\n\t\t\t...(fields.history != null && {\n\t\t\t\thistory: await create<History>(\n\t\t\t\t\tfields.history,\n\t\t\t\t\t\"history\",\n\t\t\t\t\t`${at}.history`,\n\t\t\t\t\tcwd,\n\t\t\t\t),\n\t\t\t}),\n\t\t});\n\t}\n\treturn components;\n}\n\n/** Creates a scheme, history or component source from `name` or `{ uses, with }`. */\nasync function create<R>(\n\tvalue: unknown,\n\tkind: FactoryKind,\n\tat: string,\n\tcwd: string,\n): Promise<R> {\n\tconst entry =\n\t\ttypeof value === \"string\" ? { uses: value, with: undefined } : value;\n\tif (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n\t\tthrow new OptionsError([\n\t\t\t`${at}: expected a name, or a map with 'uses' and 'with'`,\n\t\t]);\n\t}\n\tconst fields = entry as Record<string, unknown>;\n\tconst unknown = Object.keys(fields).filter(\n\t\t(key) => key !== \"uses\" && key !== \"with\",\n\t);\n\tif (unknown.length > 0) {\n\t\tthrow new OptionsError(\n\t\t\tunknown.map((key) => `${at}.${key}: unknown key; use uses, with`),\n\t\t);\n\t}\n\tif (typeof fields.uses !== \"string\" || fields.uses === \"\") {\n\t\tthrow new OptionsError([\n\t\t\t`${at}.uses: expected the name of a ${kind === \"components\" ? \"component source\" : kind}`,\n\t\t]);\n\t}\n\tconst target = await load(fields.uses, `${at}.uses`, cwd);\n\tif (target.kind !== kind) {\n\t\tthrow new OptionsError([\n\t\t\t`${at}.uses: '${fields.uses}' is a ${target.kind}, not a ${kind === \"components\" ? \"component source\" : kind}`,\n\t\t]);\n\t}\n\ttry {\n\t\treturn (target as AnyFactory<FactoryKind, R>)(fields.with ?? undefined);\n\t} catch (error) {\n\t\tif (!(error instanceof OptionsError)) throw error;\n\t\tthrow new OptionsError(\n\t\t\terror.issues.map(\n\t\t\t\t(issue) =>\n\t\t\t\t\t`${at}.with${issue.startsWith(target.name) ? issue.slice(target.name.length) : `: ${issue}`}`,\n\t\t\t),\n\t\t);\n\t}\n}\n\nexport interface WorkflowOptions {\n\t/** Paths and packages are resolved from here. */\n\tcwd: string;\n}\n\n/**\n * Turns workflow `steps` (already parsed from YAML) into steps. Each entry\n * names what it `uses`, passes it options `with`, and may run only `if` an\n * expression holds:\n *\n * ```yaml\n * - uses: conventional # a bundled preset or step\n * with:\n * github/create-release: false\n * - uses: ./release/announce.ts # a file's default export\n * if: \"!dryRun && kind != 'patch'\"\n * with:\n * channel: \"#releases\"\n * - uses: some-package#slackNotes # a package's named export\n * ```\n */\nexport async function resolveWorkflowSteps(\n\tentries: unknown,\n\toptions: WorkflowOptions,\n): Promise<Step[]> {\n\tif (!Array.isArray(entries)) {\n\t\tthrow new OptionsError([\"steps: expected a list of steps\"]);\n\t}\n\tconst parsed = entries.map((entry, index) => parseEntry(entry, index));\n\tconst steps: Step[] = [];\n\t// Which preset each step came from, to catch steps configured twice.\n\tconst fromPreset = new Map<string, string>();\n\tconst explicit: { name: string; at: string }[] = [];\n\n\tfor (const { uses, with: value, condition, at } of parsed) {\n\t\tconst target = await load(uses, `${at}.uses`, options.cwd);\n\t\tif (target.kind !== \"step\" && target.kind !== \"preset\") {\n\t\t\tthrow new OptionsError([\n\t\t\t\t`${at}.uses: '${uses}' is a ${target.kind}, not a step; set it as \\`${target.kind}\\` instead`,\n\t\t\t]);\n\t\t}\n\t\tlet created: Step[];\n\t\ttry {\n\t\t\tif (isPreset(target)) {\n\t\t\t\tcreated = target(value as never);\n\t\t\t\tfor (const step of created) fromPreset.set(step.name, target.name);\n\t\t\t} else {\n\t\t\t\tcreated = [(target as AnyStepFactory)(value)];\n\t\t\t\texplicit.push({ name: target.name, at });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof OptionsError)) throw error;\n\t\t\t// Issues start with the step's or preset's name; point at `with`.\n\t\t\tthrow new OptionsError(\n\t\t\t\terror.issues.map(\n\t\t\t\t\t(issue) =>\n\t\t\t\t\t\t`${at}.with${issue.startsWith(target.name) ? issue.slice(target.name.length) : `: ${issue}`}`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tsteps.push(\n\t\t\t...created.map((step) =>\n\t\t\t\tcondition ? (when(step as Step<never>, condition) as Step) : step,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst twice = explicit.flatMap(({ name, at }) => {\n\t\tconst preset = fromPreset.get(name);\n\t\treturn preset\n\t\t\t? [\n\t\t\t\t\t`${at}.uses: '${name}' is already in '${preset}'; configure it there (with: { ${name}: ... }), or set it to false there to replace it`,\n\t\t\t\t]\n\t\t\t: [];\n\t});\n\tif (twice.length > 0) throw new OptionsError(twice);\n\treturn steps;\n}\n\nconst ENTRY_KEYS = [\"uses\", \"with\", \"if\"];\n\nfunction parseEntry(\n\tentry: unknown,\n\tindex: number,\n): { uses: string; with: unknown; condition?: Condition; at: string } {\n\tconst at = `steps[${index}]`;\n\tif (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n\t\tthrow new OptionsError([\n\t\t\t`${at}: expected a map with 'uses', and optionally 'with' and 'if'`,\n\t\t]);\n\t}\n\tconst fields = entry as Record<string, unknown>;\n\tconst unknown = Object.keys(fields).filter(\n\t\t(key) => !ENTRY_KEYS.includes(key),\n\t);\n\tif (unknown.length > 0) {\n\t\tthrow new OptionsError(\n\t\t\tunknown.map(\n\t\t\t\t(key) => `${at}.${key}: unknown key; use ${ENTRY_KEYS.join(\", \")}`,\n\t\t\t),\n\t\t);\n\t}\n\tif (typeof fields.uses !== \"string\" || fields.uses === \"\") {\n\t\tthrow new OptionsError([\n\t\t\t`${at}.uses: expected the name of a step or preset`,\n\t\t]);\n\t}\n\tif (\n\t\tfields.with != null &&\n\t\t(typeof fields.with !== \"object\" || Array.isArray(fields.with))\n\t) {\n\t\tthrow new OptionsError([`${at}.with: expected a map of options`]);\n\t}\n\tconst condition = parseCondition(fields.if, `${at}.if`);\n\treturn {\n\t\tuses: fields.uses,\n\t\twith: fields.with ?? undefined,\n\t\t...(condition && { condition }),\n\t\tat,\n\t};\n}\n\ntype Condition = { (input: unknown): boolean; source: string };\n\n/**\n * `if:` is a rylease expression, or a boolean, e.g. what GitHub made of\n * `${{ ... }}` before rylease ran.\n */\nfunction parseCondition(value: unknown, at: string): Condition | undefined {\n\tif (value === undefined || value === null) return undefined;\n\tif (typeof value === \"boolean\") {\n\t\treturn Object.assign(() => value, { source: String(value) });\n\t}\n\tif (typeof value !== \"string\") {\n\t\tthrow new OptionsError([`${at}: expected an expression or a boolean`]);\n\t}\n\ttry {\n\t\tconst evaluate = compileExpression(value);\n\t\treturn Object.assign(\n\t\t\t(input: unknown) => Boolean(evaluate(expressionContext(input))),\n\t\t\t{ source: value },\n\t\t);\n\t} catch (error) {\n\t\tif (!(error instanceof ExpressionError)) throw error;\n\t\tthrow new OptionsError([`${at}: ${error.message} in \\`${value}\\``]);\n\t}\n}\n\nasync function load(\n\tname: string,\n\tpath: string,\n\tcwd: string,\n): Promise<Loadable> {\n\tconst builtin = builtins.get(name);\n\tif (builtin) return builtin;\n\n\tconst [specifier = name, exportName = \"default\"] = name.split(\"#\");\n\tconst isPath = /^\\.{0,2}\\//.test(specifier);\n\tlet url: string;\n\ttry {\n\t\turl = isPath\n\t\t\t? pathToFileURL(resolve(cwd, specifier)).href\n\t\t\t: pathToFileURL(\n\t\t\t\t\tcreateRequire(join(cwd, \"package.json\")).resolve(specifier),\n\t\t\t\t).href;\n\t} catch {\n\t\tthrow new OptionsError([\n\t\t\t`${path}: unknown step ${name}; use one of ${[...builtins.keys()].join(\", \")}, a path like ./steps/x.ts, or an installed package`,\n\t\t]);\n\t}\n\n\tconst module = (await import(url)) as Record<string, unknown>;\n\tconst target = module[exportName];\n\tif (isFactory(target)) return target as Loadable;\n\tthrow new OptionsError([\n\t\t`${path}: export '${exportName}' of ${specifier} isn't made with defineStep, definePreset, defineScheme, defineHistory or defineComponents`,\n\t]);\n}\n\nfunction isPreset(value: Loadable): value is Preset {\n\treturn value.kind === \"preset\";\n}\n","import type { ComponentReport, ReleaseReport } from \"./engine.ts\";\nimport { formatDuration } from \"./reporter.ts\";\n\nconst ICONS = { ok: \"✅\", skipped: \"⚪\", failed: \"❌\" } as const;\n\n/**\n * The report as Markdown, for GitHub's job summary: what happened, a row per\n * step, and the release notes.\n */\nexport function markdownSummary(report: ReleaseReport): string {\n\tconst dryRun = report.env.dryRun;\n\tconst several = report.components.length > 1;\n\tconst describe = (component: ComponentReport) => {\n\t\tconst from = component.previousVersion ?? \"nothing\";\n\t\tconst to = component.version ?? \"?\";\n\t\tif (component.status !== \"released\" && component.status !== \"pending\") {\n\t\t\treturn `**${from}** · nothing to release`;\n\t\t}\n\t\tconst versions =\n\t\t\tfrom === to ? `**${to}**` : `**${from}** → **${to}** (${component.kind})`;\n\t\tconst action =\n\t\t\tcomponent.status === \"pending\"\n\t\t\t\t? dryRun\n\t\t\t\t\t? \"would be proposed\"\n\t\t\t\t\t: \"proposed\"\n\t\t\t\t: dryRun\n\t\t\t\t\t? \"would release\"\n\t\t\t\t\t: \"released\";\n\t\treturn `${versions} · ${action}`;\n\t};\n\tconst [only] = report.components;\n\tconst headline =\n\t\treport.status === \"failed\"\n\t\t\t? \"release failed\"\n\t\t\t: !several && only\n\t\t\t\t? describe(only)\n\t\t\t\t: report.status === \"released\"\n\t\t\t\t\t? dryRun\n\t\t\t\t\t\t? \"would release\"\n\t\t\t\t\t\t: \"released\"\n\t\t\t\t\t: report.status === \"pending\"\n\t\t\t\t\t\t? dryRun\n\t\t\t\t\t\t\t? \"would be proposed\"\n\t\t\t\t\t\t\t: \"proposed\"\n\t\t\t\t\t\t: \"nothing to release\";\n\tconst lines = [\n\t\t`### ${report.status === \"failed\" ? \"❌ \" : \"\"}rylease${dryRun ? \" dry run\" : \"\"} · ${headline}`,\n\t\t\"\",\n\t\t`On \\`${report.env.branch}\\`${report.env.channel ? `, on the \\`${report.env.channel.name}\\` channel` : \"\"}${dryRun ? \", without side effects\" : \"\"}.${report.deferred ? ` ${report.deferred[0]?.toUpperCase()}${report.deferred.slice(1)}.` : \"\"}`,\n\t\t...(several && report.status !== \"failed\"\n\t\t\t? [\n\t\t\t\t\t\"\",\n\t\t\t\t\t...report.components.map(\n\t\t\t\t\t\t(component) => `- \\`${component.name}\\`: ${describe(component)}`,\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t\t\"\",\n\t\tseveral\n\t\t\t? \"| | Component | Type | Step | Time | |\"\n\t\t\t: \"| | Type | Step | Time | |\",\n\t\tseveral ? \"|:-:|---|---|---|--:|---|\" : \"|:-:|---|---|--:|---|\",\n\t\t...report.records.map(\n\t\t\t(record) =>\n\t\t\t\t`| ${ICONS[record.status]} |${several ? ` ${record.component ? `\\`${record.component}\\`` : \"all\"} |` : \"\"} \\`${record.phase}\\` | \\`${record.name}\\` | ${\n\t\t\t\t\trecord.status === \"skipped\" ? \"\" : formatDuration(record.durationMs)\n\t\t\t\t} | ${cell(record.reason)} |`,\n\t\t),\n\t];\n\tfor (const component of report.components) {\n\t\tif (report.status === \"failed\" || report.status === \"unchanged\") continue;\n\t\tif (component.status !== \"released\" && component.status !== \"pending\")\n\t\t\tcontinue;\n\t\tif (!component.notes?.trim()) continue;\n\t\tlines.push(\n\t\t\t\"\",\n\t\t\t`<details open><summary>Release notes${several ? ` of ${component.name} ${component.version}` : \"\"}</summary>`,\n\t\t\t\"\",\n\t\t\tcomponent.notes.trim(),\n\t\t\t\"\",\n\t\t\t\"</details>\",\n\t\t);\n\t}\n\treturn `${lines.join(\"\\n\")}\\n\\n`;\n}\n\n/** Problems with the input itself, before any step ran. */\nexport function markdownProblems(issues: readonly string[]): string {\n\treturn [\n\t\t\"### ❌ rylease · invalid input\",\n\t\t\"\",\n\t\t...issues.map((issue) => `- ${cell(issue)}`),\n\t\t\"\",\n\t\t\"\",\n\t].join(\"\\n\");\n}\n\n/** Text that stays inside one table cell or list item. */\nfunction cell(text: string): string {\n\treturn text\n\t\t.replaceAll(\"|\", \"\\\\|\")\n\t\t.replaceAll(\"<\", \"<\")\n\t\t.replace(/\\r?\\n/g, \"<br>\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAa,eAAb,cAAkC,MAAM;CACvC;CAEA,YAAY,QAA2B;EACtC,MAAM,OAAO,KAAK,IAAI,CAAC;EACvB,KAAK,OAAO;EACZ,KAAK,SAAS;CACf;AACD;;;;;;AAOA,SAAgB,aACf,OACA,OACA,MACkB;CAClB,MAAM,SAASA,IAAE,aAAa,KAAK,CAAC,CAAC,UAAU,SAAS,CAAC,CAAC;CAC1D,IAAI,OAAO,SAAS,OAAO,OAAO;CAClC,MAAM,IAAI,aACT,OAAO,MAAM,OAAO,KAClB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