@capgo/cli
Version:
A CLI to upload to capgo servers
97 lines (96 loc) • 4.92 kB
TypeScript
/**
* Native Build Request Module
*
* This module handles native iOS and Android build requests through Capgo's cloud build service.
*
* CREDENTIAL SECURITY GUARANTEE:
* ═══════════════════════════════════════════════════════════════════════════
* Your build credentials (certificates, keystores, passwords, API keys) are:
*
* ✓ NEVER stored permanently on Capgo servers
* ✓ Used ONLY during the active build process
* ✓ Automatically deleted from Capgo servers after build completion
* ✓ Retained for a MAXIMUM of 24 hours (even if build fails)
* ✓ Builds sent DIRECTLY to app stores (Apple/Google)
* ✓ Build outputs may optionally be uploaded for time-limited download links
*
* Credentials are transmitted securely over HTTPS and used only in ephemeral
* build environments that are destroyed after each build completes.
* ═══════════════════════════════════════════════════════════════════════════
*
* BEFORE BUILDING:
* You must save your credentials first using:
* - `npx @capgo/cli build credentials save --platform ios` (for iOS)
* - `npx @capgo/cli build credentials save --platform android` (for Android)
* - Credentials stored in ~/.capgo/credentials.json (local machine only)
* - Use `build credentials clear` to remove saved credentials
*/
import type { BuildOptionsPayload, BuildRequestOptions, BuildRequestResult } from '../schemas/build';
/**
* Callback interface for build logging.
* Allows callers (like the onboarding UI) to capture log output
* without stdout/stderr interception hacks.
*/
export interface BuildLogger {
info: (msg: string) => void;
error: (msg: string) => void;
warn: (msg: string) => void;
success: (msg: string) => void;
/** Called with build log lines streamed from the builder */
buildLog: (msg: string) => void;
/** Called with upload progress percentage (0-100) */
uploadProgress: (percent: number) => void;
/** Called with custom messages from the builder (QR codes, etc.) */
customMsg: (kind: string, data: Record<string, unknown>) => void | Promise<void>;
}
export type { BuildCredentials, BuildRequestOptions, BuildRequestResponse, BuildRequestResult } from '../schemas/build';
/**
* Extract native node_modules roots that contain platform folders.
*/
interface NativeDependencies {
packages: Set<string>;
cordovaPackages: Set<string>;
usesSPM: boolean;
usesCocoaPods: boolean;
}
/**
* Check if a file path should be included in the zip
*/
export declare function shouldIncludeFile(filePath: string, platform: 'ios' | 'android', nativeDeps: NativeDependencies, platformDir: string): boolean;
/**
* Zip directory for native build, including only necessary files:
* - ios/ OR android/ folder (based on platform)
* - node_modules with native code (from Podfile/settings.gradle)
* - capacitor.config.*, package.json, package-lock.json
*/
export declare function zipDirectory(projectDir: string, outputPath: string, platform: 'ios' | 'android', capConfig: any): Promise<void>;
/**
* Request a native build from Capgo's cloud build service
*
* @param appId - The app ID (e.g., com.example.app)
* @param options - Build request options including platform and credentials
* @param silent - Suppress console output
*
* @returns Build request result with job ID and status
*
* SECURITY NOTE:
* Credentials provided to this function are:
* - Transmitted securely over HTTPS to Capgo's build servers
* - Used ONLY during the active build process
* - Automatically deleted after build completion
* - NEVER stored permanently on Capgo servers
* - Build outputs may optionally be uploaded for time-limited download links
*/
/** Keys that are non-secret build options and should NOT be sent in the credentials blob. */
export declare const NON_CREDENTIAL_KEYS: Set<string>;
/**
* Split merged credentials into a build options payload and a credentials-only payload.
* Non-secret configuration keys (schemes, directories, output control) go into buildOptions.
* Only actual secrets (certificates, passwords, API keys) remain in buildCredentials.
*/
export declare function splitPayload(mergedCredentials: Record<string, string | undefined>, platform: 'ios' | 'android', buildMode: string, cliVersion: string): {
buildOptions: BuildOptionsPayload;
buildCredentials: Record<string, string>;
};
export declare function requestBuildInternal(appId: string, options: BuildRequestOptions, silent?: boolean, logger?: BuildLogger): Promise<BuildRequestResult>;
export declare function requestBuildCommand(appId: string, options: BuildRequestOptions): Promise<void>;