import type { Env } from "./ci/env.js"; import type { CiProvider } from "./ci/provider.js"; import type { ImportPlugin } from "./config/plugins.js"; import type { Forge } from "./forge/forge.js"; import type { RepoGit } from "./git/reader.js"; import type { GitWriter } from "./git/writer.js"; import type { Writer } from "./output/writer.js"; import type { BuildChannel, Plan, PlanOptions, ReadonlyFs, Warning, Workspace } from "@tallyrelease/core"; /** Injected environment of a cli run; `bin.ts` wires the real one. */ export interface Deps { env: Env; cwd: string; stdout: Writer; stderr: Writer; /** Defaults to the `git` executable at the repo root. */ git?: RepoGit; /** Defaults to `node:fs` at the repo root. */ fs?: ReadonlyFs; /** Files at a commit; defaults to the git object store at the repo root. */ fsAt?: (ref: string) => ReadonlyFs; /** Defaults to GitHub when a token is available; used only with a token. */ forge?: Forge; /** Defaults to the `git` executable at the repo root. */ gitWriter?: GitWriter; /** Writes a file relative to the repo root; defaults to `node:fs`. */ writeFile?: (path: string, content: string) => void; /** Writes a file at `path` as given, such as `--out`; defaults to `node:fs`. */ writeOutFile?: (path: string, content: string) => void; /** Appends to a file at `path` as given, such as `$GITHUB_OUTPUT`; defaults to `node:fs`. */ appendFile?: (path: string, content: string) => void; /** Defaults to the system clock. */ clock?: () => Date; /** Imports plugin modules from the repo root; defaults to jiti. */ importPlugin?: ImportPlugin; } export interface GlobalOptions { cwd?: string; config: string; token?: string; verbose?: boolean; /** Git remote to push to and read the repository from; defaults to `origin`. */ remote?: string; /** `--allow-local-plugins`: privileged commands may load local plugins. */ allowLocalPlugins?: boolean; /** `--channel`: channel of build prereleases. */ channel?: BuildChannel; /** Set by commands that hold write tokens (`pr`, `release`, `run`, `version`). */ privileged?: boolean; } /** The selected build channel; `explicit` when chosen by flag or env. */ export interface ChannelSelection { channel: BuildChannel; explicit: boolean; } /** Resolved dependencies shared by all commands. */ export interface Session { readonly cwd: string; readonly root: string; readonly env: Env; readonly stdout: Writer; readonly fs: ReadonlyFs; readonly git: RepoGit; readonly ci: CiProvider; /** Undefined without a token. */ readonly forge: Forge | undefined; /** `--token`, else `GITHUB_TOKEN`. */ readonly token: string | undefined; /** `--remote`, else `origin`. */ readonly remote: string; /** * `--channel`, else `TALLYRELEASE_CHANNEL`, else `nightly` on a schedule * event, else `build`; `E_CHANNEL_SELECT` for an invalid env value. */ readonly channel: () => ChannelSelection; readonly gitWriter: GitWriter; readonly writeFile: (path: string, content: string) => void; readonly writeOutFile: (path: string, content: string) => void; readonly clock: () => Date; /** Web URL of the repository for changelog links, null when unknown. */ readonly repoUrl: () => Promise; readonly workspace: () => Promise; /** Content of `path` at commit `ref`, undefined when absent. */ readonly readAt: (ref: string, path: string) => string | undefined; /** * Runs `use` with the workspace and files at commit `ref`, or of the * working tree when `ref` is null; the config is always read from the * working tree. The working tree's workspace loads once per session. */ readonly workspaceAt: (ref: string | null, use: (workspace: Workspace, fs: ReadonlyFs) => Promise) => Promise; /** * `computePlan` with the workspace and files of `workspaceAt(ref)`; * `fill.released` fills `released` (`withReleased`). */ readonly planAt: (ref: string | null, opts: Omit, fill?: { released: boolean; }) => Promise; readonly warn: (warnings: readonly Warning[]) => void; } /** * Https web URL of a git remote without credentials or `.git`, null when not * recognised. URL remotes keep the hostname (no port), scp-style `user@host:path` * maps to `https://host/path`. */ export declare const webUrl: (remote: string) => string | null; export declare const createSession: (deps: Deps, opts: GlobalOptions) => Session; /** The CI branch, else the checked-out branch, else `HEAD`. */ export declare const branchName: (session: Pick) => Promise;