@capgo/cli
Version:
A CLI to upload to capgo servers
179 lines (178 loc) • 6.48 kB
TypeScript
import type { FC } from 'react';
import type { DiffLine } from '../diff-utils.js';
export declare const Divider: FC<{
width?: number;
}>;
export declare const BOX_HEADER_ROWS = 5;
export declare const COMPACT_HEADER_ROWS = 1;
export declare const WIZARD_PADDING_ROWS = 2;
/**
* Minimal in-house Table component. Auto-sizes each column to the widest
* value (header or any row cell) up to `maxColumnWidth`, truncates with
* an ellipsis when a cell exceeds that width, and renders box-drawing
* borders.
*
* Why inline instead of `ink-table`: the published `ink-table@3.1.0` is
* CommonJS and modern `ink` (v5+) is ESM with top-level await, so bundling
* fails. This component is the small subset of ink-table's API we need
* (rows of plain string cells) without the compat headache.
*
* The `data` rows must share a single key order so columns line up — we
* derive the column list from the first row's keys.
*
* `cellColor` runs per-cell and returns an Ink color name (or undefined
* for default). Used by the available/unavailable-certs tables to colour
* the status column green/red while keeping Name/Team dim.
*/
export interface TableProps {
data: Record<string, string>[];
/** Hard cap on column width before truncation. Default 50. */
maxColumnWidth?: number;
/** Optional per-cell color function. */
cellColor?: (column: string, value: string, rowIndex: number) => string | undefined;
/** Optional per-cell dim flag (defaults to false). */
cellDim?: (column: string, value: string, rowIndex: number) => boolean;
/** Padding inside each cell (left/right). Default 1. */
cellPadding?: number;
}
export declare const Table: FC<TableProps>;
export declare const SpinnerLine: FC<{
text: string;
}>;
export declare const SuccessLine: FC<{
text: string;
detail?: string;
}>;
export declare const ErrorLine: FC<{
text: string;
}>;
export type AiResultKind = 'already_analyzed' | 'too_big' | 'error';
export declare const AiResultBanner: FC<{
kind: AiResultKind;
message: string;
dense?: boolean;
}>;
/**
* Custom TextInput that filters out specific characters (e.g. '=').
* @inkjs/ui's TextInput is uncontrolled and can't filter keystrokes,
* so we build a minimal one with Ink's useInput.
*/
export declare const FilteredTextInput: FC<{
placeholder?: string;
/**
* Blacklist of characters to strip from input. Each char in this string is
* removed from the buffer after every keystroke. Used for casual filtering
* (e.g. stripping `=` from env-var values).
*/
filter?: string;
/**
* Whitelist regex matched per-character. Anything not matching is dropped.
* Takes precedence over `filter` when both are set. Used when the field has
* a tight format (Apple Key ID is exactly 10 alphanumeric chars; Issuer ID
* is a UUID; etc.) so users can't even type invalid characters.
*/
allowedPattern?: RegExp;
/**
* Hard cap on input length. Extra characters past the cap are dropped
* silently (paste-safe). Pair with `allowedPattern` for known-format fields
* — e.g. Apple Key ID has `maxLength=10` so a paste of "Key ID: KDTXMK292V"
* truncates to the first 10 valid chars after filtering.
*/
maxLength?: number;
/**
* Post-filter transform applied to the entire buffer after each keystroke.
* Most common use: `(s) => s.toUpperCase()` for fields that are case-
* insensitive but conventionally uppercase. Runs after filter + maxLength.
*/
transform?: (value: string) => string;
mask?: boolean;
/**
* Pre-fills the input. Used when the user is editing an already-entered
* value (e.g. fixing a typo in their ASC Key ID / Issuer ID after a
* verifying-key failure) so they don't have to retype everything.
* Backspace works normally to delete from the pre-filled value.
*/
initialValue?: string;
onSubmit: (value: string) => void;
}>;
export declare const Header: FC<{
compact?: boolean;
}>;
/**
* Scrollable, fullscreen viewer for the AI build-analysis markdown when it
* is taller than the user's terminal viewport. Mirrors the shape of the
* workflow-file diff viewer on main, but for pre-rendered ANSI lines (no
* `add`/`del` colouring — the markdown renderer already styled them).
*
* Keybindings:
* ↑/k scroll one line up
* ↓/j scroll one line down
* PgUp/u jump up one viewport
* PgDn/d/␣ jump down one viewport
* Home/g jump to top
* End/G jump to bottom
* Esc/Enter dismiss the viewer (returns control to the parent step)
*/
export declare const FullscreenAiViewer: FC<{
title: string;
subtitle?: string;
lines: string[];
terminalRows: number;
onExit: () => void;
}>;
export declare function isBuildCompleteDismissKey(input: string, key: {
return?: boolean;
escape?: boolean;
}): boolean;
export interface BuildScrollState {
scrollOffset: number;
follow: boolean;
}
export declare function buildScrollAction(input: string, key: {
upArrow?: boolean;
downArrow?: boolean;
pageUp?: boolean;
pageDown?: boolean;
}, state: {
scrollOffset: number;
maxScrollOffset: number;
viewportRows: number;
}): BuildScrollState | null;
export declare function formatElapsed(ms: number): string;
export declare const FullscreenBuildOutput: FC<{
title: string;
lines: string[];
terminalRows: number;
}>;
/**
* Minimal bordered table component for the confirm-secrets-push step.
*
* Rolled in-house instead of pulling `ink-table` because that package is
* CommonJS-only and Ink 5 uses top-level await — bun can't bundle the combo.
* Replicates the visual style (box-drawing borders, aligned columns) with
* ~50 lines of Ink primitives, lets us color the Status column per-row, and
* leaves nothing to maintain outside this repo.
*/
export interface SecretRow {
name: string;
status: 'NEW' | 'REPLACE';
}
export declare const DiffSummary: FC<{
title: string;
subtitle?: string;
lines: DiffLine[];
}>;
export declare const FullscreenDiffViewer: FC<{
title: string;
subtitle?: string;
lines: DiffLine[];
terminalRows: number;
onExit: () => void;
}>;
/**
* Render the secrets table inline. Keep this dynamic so the onboarding header
* and prompt stay in one live Ink frame.
*/
export declare const SecretsTable: FC<{
rows: SecretRow[];
}>;