/** What a written config should point at, when lookout already knows. */ export interface ConfigSeed { /** Base URL from --url: the run that prompted the write. */ url?: string; /** Dev command for `startHint`; `createConfig` derives it from the lockfile. */ devCommand?: string; } /** * The dev command the project's lockfile implies. The lockfile is a fact * about which package manager the project uses; without one there is no * basis to name any, and npm is the ecosystem default, not a preference. */ export declare function devCommandFor(projectDir: string): string; export declare function configTemplate(seed?: ConfigSeed): string; /** * Write `lookout.config.ts` at a project root. Refuses when the project already * has a config anywhere, root or legacy: two configs is a question about which * one is live, and lookout does not get to answer it silently. */ export declare function createConfig(projectDir: string, seed?: ConfigSeed): Promise; /** * Keep `.lookout/` out of git, creating the `.gitignore` when there is none. * * Beside the config writer rather than in `init`, because the ignore line is * part of writing a config: a project configured by `--url` on a first run * never runs `init`, and its `.lookout/` holds screenshots. Creating the file * is the change of posture the workspace's move earned: printing a note was * fair when the ignored directory held text, and is not now that a capture * puts megabytes of PNGs in the working tree. */ export declare function ensureIgnored(root: string): Promise; /** What a directory resolves to: its config, found or freshly written. */ export interface LocatedOrCreated { configPath: string; projectDir: string; /** True when nothing was there and this call wrote the config. */ created: boolean; } /** * The config a directory should be served with: the nearest one up its own * tree, or a fresh one written at the nearest project root. Null when the * directory is not a project at all, so the caller knows to refuse rather * than litter. * * One decision, two callers: `lookout ui` makes it at startup * (`projectToServe`) and the settings panel makes it again whenever it is * pointed somewhere else at runtime. Both are the screen a project gets * configured ON, so both create rather than refuse a directory for want of a * config that is not there yet. */ export declare function locateOrCreateConfig(dir: string): Promise; /** The config already in this directory (root form or legacy), if any. */ export declare function existingConfigIn(projectDir: string): string | null; /** The pre-root config in this directory, if one is still there. */ export declare function legacyConfigIn(projectDir: string): string | null; export interface Migration { from: string; to: string; /** Config-relative references rewritten to keep pointing where they did. */ rewritten: string[]; /** References that moved with the file and now need a hand. */ unresolved: string[]; } /** * Move a pre-root config to the project root, references included. * * The config is loaded first, and only to read its path references: a config * that will not load still moves, because refusing to migrate it would leave * the project on a home lookout is retiring for a problem the move does not * cause. */ export declare function migrateLegacyConfig(legacyPath: string): Promise; export interface EnsureOptions { cwd: string; /** --config: an explicit path means the caller has already chosen a file. */ configPath?: string; /** --url: what a written config should point at. */ url?: string; } /** * Make sure the project has a config where lookout keeps one, before a verb * goes looking for it. * * Three outcomes: a root config is left alone, a legacy config is moved up to * the root, and a project with neither gets one written. "stop" is returned * for the last case when there was no --url to seed the file with, because a * template pointing at localhost:3000 is a placeholder, and running against it * would report on whatever happens to answer there. */ export declare function ensureProjectConfig(opts: EnsureOptions): Promise<"go" | "stop">;