// Name: Generate scripts.d.ts // Description: Enables autocompletion for the `run` command import "@johnlindquist/kit" import { writeFile } from "node:fs/promises" const scripts = await getScripts() const availableScripts = scripts.map((x) => ` | "${x.command}"`).join("\n") const body = `// Do not edit. Autogenerated by generate-scripts-declarations.ts import type { Run } from "../../.kit/types/kit" type AvailableScript = ${availableScripts}; declare module "@johnlindquist/kit/types/kit" { export interface Run { // biome-ignore lint/style/useShorthandFunctionType: <explanation> (command?: AvailableScript, ...args: string[]): Promise<any> } } declare global { var run: Run }` await ensureDir(kenvPath("@types")) await writeFile(kenvPath("@types", "scripts.d.ts"), body, { encoding: "utf-8" })