@capgo/cli
Version:
A CLI to upload to capgo servers
95 lines (94 loc) • 4.4 kB
TypeScript
import type { PlatformFlow, StepView } from '../flow/contract';
import type { AppflowInput, AppflowProgress, AppflowStep } from './types';
import type { AppflowToken } from './auth';
import type { TailStep } from '../tail/flow.js';
import type { AppflowTailDepsOptions } from './tail.js';
export interface AppflowEffectResult {
progress: AppflowProgress;
next?: AppflowStep;
transient?: Record<string, unknown>;
}
export interface AppflowValidationResult {
id: 'sa' | 'keystore' | 'app-password' | 'p12';
status: 'pass' | 'warn' | 'skipped';
message: string;
}
export interface AppflowGenerateResult {
ok: boolean;
creds?: Record<string, string>;
message?: string;
}
export interface AppflowEffectDeps {
appId?: string;
log?: (s: string) => void;
loadToken?: () => AppflowToken | null;
saveToken?: (t: AppflowToken) => void;
openBrowser?: (url: string) => void;
validateServiceAccountJson?: (json: string, packageName?: string) => Promise<{
ok: boolean;
reason?: string;
}>;
tryUnlockPrivateKey?: (keystoreB64: string, storePass: string, alias: string) => Promise<boolean>;
validateAppleAppPassword?: (user: string, pw: string) => Promise<{
valid: boolean;
message?: string;
kind?: 'authenticated' | 'rejected' | 'unreachable';
}>;
validateP12?: (p12B64: string, password: string) => Promise<boolean>;
generateIosP8Key?: () => Promise<AppflowGenerateResult>;
generateAndroidServiceAccount?: (opts: {
packageName?: string;
}) => Promise<AppflowGenerateResult>;
readP8File?: (path: string) => Promise<string | null>;
carried?: Record<string, unknown>;
tailOptions?: AppflowTailDepsOptions;
}
export declare function isAppflowTailStep(step: AppflowStep): step is TailStep;
export declare function autoSelect<T>(items: T[]): T | 'prompt' | null;
export interface AppflowCert {
tag?: string;
name?: string;
type?: string;
credentials?: {
ios?: unknown;
android?: unknown;
};
}
export interface AppflowDistCred {
id?: number | string;
type?: string;
name?: string;
}
export declare function decideAfterFetchSigning(progress: Pick<AppflowProgress, 'scope' | 'migratable'>): AppflowStep;
export declare function platformsToBuild(progress: Pick<AppflowProgress, 'scope' | 'ios' | 'android'>): ('ios' | 'android')[];
export declare function runValidations(progress: AppflowProgress, deps?: AppflowEffectDeps): Promise<AppflowValidationResult[]>;
export declare function appflowViewForStep(step: AppflowStep, progress: AppflowProgress, ctx?: Record<string, unknown>): StepView;
/**
* Decode the `email` claim from an Appflow token's id_token JWT WITHOUT verifying
* the signature (jsonwebtoken.decode) — we only need the human-readable account
* identity to surface which Appflow account is being migrated, not to trust it.
* Returns undefined when there is no id_token or no string email claim.
*/
export declare function appflowAccountEmail(token: {
id_token?: string;
} | null | undefined): string | undefined;
export declare function applyAppflowInput(step: AppflowStep, progress: AppflowProgress, input: AppflowInput): AppflowProgress;
export declare function getAppflowResumeStep(progress: AppflowProgress | null): AppflowStep;
/**
* Resume the inline build phase after the user chose 'build'. The migration is
* single-platform, so the build enters the shared tail at saving-credentials for
* the migrated platform and finishes ('done') once that build run completes.
*/
export declare function getAppflowBuildResumeStep(progress: AppflowProgress): AppflowStep;
export declare function nextTailStep(step: TailStep, value: string | undefined, progress: AppflowProgress): TailStep;
/**
* Record the migration's single inline tail run as complete (reached at
* build-complete via any path — built, skipped, or failed). Returns the next
* overall appflow step, which is always 'done' for a single-platform migration.
*/
export declare function markTailRunComplete(progress: AppflowProgress): {
progress: AppflowProgress;
next: AppflowStep;
};
export declare function runAppflowEffect(step: AppflowStep, progress: AppflowProgress, deps: AppflowEffectDeps): Promise<AppflowEffectResult>;
export declare const appflowFlow: PlatformFlow<AppflowStep, AppflowProgress, AppflowInput>;