import { type ScriptRegistry, type ScriptValue } from './resolve-scripts.js'; import { type Step } from './steps.js'; import type { NmrConfig } from './types.js'; /** * Replace the first token of a command with a `devBin` substitute. * Relative paths in the replacement are resolved from `monorepoRoot`. */ export declare function applyDevBin(command: string, devBin: Record | undefined, monorepoRoot: string): string; /** * Applies a `devBin` substitution to each opaque step, leaving nmr's own compositions alone. * * A structural step names a command nmr resolves for itself, so substituting its first token would replace the * `nmr` that carries the composite rather than the leaf tool `devBin` documents replacing. */ export declare function applyDevBinToSteps(steps: readonly Step[], devBin: Record | undefined, monorepoRoot: string): readonly Step[]; /** * Where a resolved script was read from. * * `registry` covers the built-in defaults and the repo-wide config together, which resolution cannot tell * apart: it receives the two already merged. A caller holding the config refines the two. */ export type ScriptOrigin = { tier: 'registry'; key: string; } | { tier: 'package'; file: string; key: string; }; export interface ResolvedScript { origin: ScriptOrigin; steps: readonly Step[]; } /** * Expands a script value into the ordered steps it runs as: a string is one opaque step, and an array is one * structural step per element. * * A bare string element and the `{ run }` spec compose the same step. The spec's only addition is the * declaration of what the step does with the invocation's trailing arguments, which position cannot carry. */ export declare function expandScript(script: ScriptValue, workspaceRoot: boolean): readonly Step[]; /** * Returns a description of a script for help output. */ export declare function describeScript(script: ScriptValue): string; /** * Reads a package.json's `scripts`, rejecting any value that is not a string. * * npm and pnpm read a script as a string too, so a value of any other type is malformed however it got there. * Dropping one silently would run the registry's entry in its place, which is what an array written here after * being told a step list resolves a shelled-nmr crossing would otherwise do. */ export declare function readPackageJsonScripts(packageDir: string): Record | undefined; /** * Builds the merged workspace script registry: * tier 1 (defaults) + tier 2 (config overrides) */ export declare function buildWorkspaceRegistry(config: NmrConfig): ScriptRegistry; /** * Builds the merged root script registry: * tier 1 (defaults) + tier 2 (config overrides) */ export declare function buildRootRegistry(config: NmrConfig): ScriptRegistry; /** * Returns a `package.json` entry that re-invokes the command it is declared under alongside other steps, or * `undefined` where the entry declares no such thing. * * Resolution discards a self-referential entry however it reads, so an entry that chains loses the steps it * chained. This is what an invocation rejects on, read where the command runs rather than raised from * resolution: the same scripts are resolved speculatively, for packages nobody named. */ export declare function findChainedSelfReference(packageDir: string | undefined, commandName: string): string | undefined; /** * Reports whether a `package.json` entry re-invokes the command it is declared under, wherever the * re-invocation stands in it, e.g. `"build": "nmr build"` or `"build": "rdy compile && nmr build"`. * * Honouring one spawns a shell that runs the same command in the same directory, reaching the same entry * again without bound, so resolution discards it. */ export declare function isSelfReferential(script: string, commandName: string, packageDir: string): boolean; /** * Resolves a script command using the three-tier override system: * 1. Package defaults (built-in registry) * 2. Repo-wide config (.config/nmr.config.ts) * 3. Per-package overrides (package.json scripts) * * Returns undefined if the command is not found in the registry. A package.json override of `""` (indicating * skip) resolves to a single opaque step carrying it, which renders back to the empty string. */ export declare function resolveScript(commandName: string, registry: ScriptRegistry, packageDir: string | undefined, workspaceRoot: boolean): ResolvedScript | undefined;