UNPKG

@capgo/cli

Version:
68 lines (67 loc) 3.03 kB
export type BuilderCtaSurface = 'skip' | 'ci-ad' | 'prompt-onboarding' | 'prompt-build'; export type BuilderCtaAction = 'continue' | 'abort' | 'launch-onboarding' | 'launch-build'; export interface BuilderCtaContext { incompatible: boolean; interactive: boolean; hasCredentials: boolean; } /** * Pure decision: which Builder CTA surface (if any) to show for this upload. * - `skip`: do nothing (compatible bundle). * - `ci-ad`: non-interactive — print a one-off ad, never prompt. * - `prompt-onboarding` / `prompt-build`: interactive prompt, branched on * whether the app already has build credentials. */ export declare function decideBuilderCtaSurface(ctx: BuilderCtaContext): BuilderCtaSurface; export interface ShouldBlockIncompatibleUploadContext { incompatible: boolean; failOnIncompatible: boolean; interactive: boolean; /** The resolved Builder CTA action (`continue` in CI / when declined). */ builderAction: BuilderCtaAction; } /** * Pure decision: should an incompatible upload be blocked (abort + exit non-zero) * instead of uploaded, given `--fail-on-incompatible`? * * - Only confirmed-incompatible bundles with the flag set are candidates. * - Non-interactive (CI): block immediately. * - Interactive: block only when the user declined the Capgo Builder native-build * escape hatch (`builderAction === 'continue'`). Accepting a native build * (`launch-build` / `launch-onboarding`) supersedes the OTA upload, so do not block. */ export declare function shouldBlockIncompatibleUpload(ctx: ShouldBlockIncompatibleUploadContext): boolean; export declare function printBuilderCiAd(hasCredentials: boolean): void; export type BuilderCtaChoice = 'yes' | 'no' | 'learn'; interface BuilderSelectOption { value: BuilderCtaChoice; label: string; } interface BuilderSelectOptions { message: string; options: BuilderSelectOption[]; initialValue?: BuilderCtaChoice; } /** Select-prompt seam (`@clack/prompts` `select` satisfies it); injectable for tests. */ export type BuilderSelect = (opts: BuilderSelectOptions) => Promise<BuilderCtaChoice | symbol>; export interface MaybePromptBuilderCtaParams { incompatible: boolean; interactive: boolean; /** Whether the app already has saved build credentials (resolved by the caller). */ hasCredentials: boolean; appId: string; orgId: string; apikey: string; incompatibleCount: number; /** Injectable for tests; defaults to the `@clack/prompts` select prompt. */ select?: BuilderSelect; /** Injectable for tests; defaults to opening the learn page in the browser. */ openUrl?: (url: string) => Promise<unknown>; } /** * Surface the Capgo Builder CTA for an incompatible upload and return the action * the caller should take. Never throws; telemetry and prompt failures degrade to * `continue` so the upload is never blocked by the CTA. */ export declare function maybePromptBuilderCta(params: MaybePromptBuilderCtaParams): Promise<BuilderCtaAction>; export {};