@capgo/cli
Version:
A CLI to upload to capgo servers
37 lines (36 loc) • 1.44 kB
TypeScript
/**
* Thin wrapper that turns the pure `generateWorkflow` output into actual files
* on disk. Kept separate from `workflow-generator.ts` so the generator stays
* trivially unit-testable without mocking fs.
*
* The wizard's Ink layer owns all prompts (overwrite confirmation, etc.); this
* module only handles "does it exist?" and "write it".
*/
import type { WorkflowGeneratorOpts } from './workflow-generator.js';
import { WORKFLOW_PATH } from './workflow-generator.js';
export { WORKFLOW_PATH };
export interface WorkflowWriteOptions {
/** When true, overwrite an existing file. Default: false. */
overwrite?: boolean;
/** Optional base dir override. Defaults to cwd(). */
baseDir?: string;
}
export type WorkflowWriteResult = {
kind: 'written';
absolutePath: string;
content: string;
} | {
kind: 'exists';
absolutePath: string;
existingContent: string;
newContent: string;
};
/**
* Generate the workflow YAML and write it to `.github/workflows/capgo-build.yml`.
* Creates the `.github/workflows/` directory if it doesn't exist.
*
* If the file already exists and `overwrite` is false, returns `kind: 'exists'`
* with both the existing and proposed content so the caller can render a diff
* and ask for explicit confirmation before clobbering.
*/
export declare function writeWorkflowFile(opts: WorkflowGeneratorOpts, writeOptions?: WorkflowWriteOptions): WorkflowWriteResult;