CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-capacitor--cli

Command-line interface for Capacitor cross-platform native runtime that enables building web apps for iOS, Android, and other platforms

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

cli-commands.mddocs/

CLI Commands

Capacitor CLI provides a comprehensive command-line interface for managing Capacitor projects throughout the development lifecycle.

Capabilities

Main CLI Entry Points

Primary functions for running the Capacitor CLI programmatically.

/**
 * Main CLI entry point - loads config and runs the program
 */
function run(): Promise<void>;

/**
 * Configures and runs the CLI program with provided config
 * @param config - Loaded Capacitor configuration
 */
function runProgram(config: Config): void;

Available Commands

Project Initialization

init

Initialize Capacitor configuration in an existing project.

npx cap init [appName] [appId] [options]

Options:

  • --web-dir <value> - Directory of your project's built web assets
  • --skip-appid-validation - Skip validating the app ID for iOS and Android compatibility
function initCommand(
  config: Config,
  name: string,
  id: string,
  webDirFromCLI?: string,
  skipAppIDValidation?: boolean
): Promise<void>;

Usage Examples:

# Interactive initialization
npx cap init

# Specify app details
npx cap init "My App" com.example.myapp

# Custom web directory
npx cap init "My App" com.example.myapp --web-dir build

Platform Management

add

Add a native platform project to your Capacitor app.

npx cap add [platform] [options]

Options:

  • --packagemanager <packageManager> - Package manager for dependency installs (CocoaPods or SPM)
function addCommand(config: Config, platform: string): Promise<void>;

Usage Examples:

# Add iOS platform
npx cap add ios

# Add Android platform  
npx cap add android

# Add iOS with Swift Package Manager
npx cap add ios --packagemanager SPM

Asset Management

sync

Copy web assets and update native dependencies (combines copy + update).

npx cap sync [platform] [options]

Options:

  • --deployment - Use deployment option for pod install
  • --inline - Inline all source maps for easier debugging on mobile devices
function syncCommand(
  config: Config,
  selectedPlatformName: string,
  deployment: boolean,
  inline?: boolean
): Promise<void>;

function sync(
  config: Config,
  platformName: string,
  deployment: boolean,
  inline?: boolean
): Promise<void>;

copy

Copy web app build into the native app.

npx cap copy [platform] [options]

Options:

  • --inline - Inline all source maps for easier debugging on mobile devices
function copy(config: Config, platformName: string, inline?: boolean): Promise<void>;

update

Update native plugins and dependencies based on package.json.

npx cap update [platform] [options]

Options:

  • --deployment - Use deployment option for pod install
function update(config: Config, platformName: string, deployment: boolean): Promise<void>;

Usage Examples:

# Sync all platforms
npx cap sync

# Sync specific platform
npx cap sync ios

# Copy with inline source maps
npx cap copy android --inline

# Update with deployment flag
npx cap update ios --deployment

Build and Run

build

Build the release version of the selected platform.

npx cap build <platform> [options]

Options:

  • --scheme <schemeToBuild> - iOS Scheme to build
  • --flavor <flavorToBuild> - Android Flavor to build
  • --keystorepath <keystorePath> - Path to the keystore (Android)
  • --keystorepass <keystorePass> - Password to the keystore (Android)
  • --keystorealias <keystoreAlias> - Key Alias in the keystore (Android)
  • --keystorealiaspass <keystoreAliasPass> - Password for the Key Alias (Android)
  • --androidreleasetype <type> - Release type: APK or AAB
  • --signing-type <signingtype> - Program used to sign apps (apksigner or jarsigner)
  • --configuration <name> - Configuration name of the iOS Scheme
  • Various Xcode options for iOS builds
interface BuildCommandOptions {
  scheme?: string;
  flavor?: string;
  keystorepath?: string;
  keystorepass?: string;
  keystorealias?: string;
  keystorealiaspass?: string;
  androidreleasetype?: 'AAB' | 'APK';
  signingtype?: 'apksigner' | 'jarsigner';
  configuration: string; // Required property
  xcodeTeamId?: string;
  xcodeExportMethod?: string;
  xcodeSigningType?: 'automatic' | 'manual';
  xcodeSigningCertificate?: string;
  xcodeProvisioningProfile?: string;
}

run

Run sync, then build and deploy the native app.

npx cap run [platform] [options]

Options:

  • --scheme <schemeName> - Set the scheme of the iOS project
  • --flavor <flavorName> - Set the flavor of the Android project
  • --list - List targets, then quit
  • --target <id> - Use a specific target
  • --no-sync - Do not run sync
  • --forwardPorts <port:port> - Automatically run "adb reverse" for better live-reloading support
  • -l, --live-reload - Enable Live Reload
  • --host <host> - Host used for live reload
  • --port <port> - Port used for live reload
  • --configuration <name> - Configuration name of the iOS Scheme
interface RunCommandOptions {
  scheme?: string;
  flavor?: string;
  list?: boolean;
  json?: boolean;
  target?: string;
  sync?: boolean;
  forwardPorts?: string;
  liveReload?: boolean;
  host?: string;
  port?: string;
  configuration?: string;
}

Usage Examples:

# Build Android APK
npx cap build android --androidreleasetype APK

# Build iOS with specific scheme
npx cap build ios --scheme MyAppScheme

# Run on device with live reload
npx cap run ios --live-reload --host 192.168.1.100

# List available targets
npx cap run android --list

# Run on specific target
npx cap run ios --target "iPhone 15 Pro"

Development Tools

open

Open the native project workspace (Xcode for iOS, Android Studio for Android).

npx cap open [platform]
function openCommand(config: Config, platform: string): Promise<void>;

doctor

Check the current setup for common errors.

npx cap doctor [platform]
function doctorCommand(config: Config, platform?: string): Promise<void>;

ls

List installed Cordova and Capacitor plugins.

npx cap ls [platform]
function listCommand(config: Config, platform?: string): Promise<void>;

Usage Examples:

# Open iOS project in Xcode
npx cap open ios

# Open Android project in Android Studio
npx cap open android

# Check setup for all platforms
npx cap doctor

# Check iOS-specific setup
npx cap doctor ios

# List all plugins
npx cap ls

# List Android-specific plugins
npx cap ls android

Migration and Updates

migrate

Migrate your current Capacitor app to the latest major version of Capacitor.

npx cap migrate [options]

Options:

  • --noprompt - Do not prompt for confirmation
  • --packagemanager <packageManager> - Package manager to use for dependency installs (npm, pnpm, yarn)
function migrateCommand(
  config: Config,
  noprompt?: boolean,
  packagemanager?: string
): Promise<void>;

spm-migration-assistant

Remove Cocoapods from project and switch to Swift Package Manager.

npx cap spm-migration-assistant

Usage Examples:

# Interactive migration
npx cap migrate

# Migrate without prompts using yarn
npx cap migrate --noprompt --packagemanager yarn

# Migrate iOS to Swift Package Manager
npx cap spm-migration-assistant

Configuration and Debugging

config

Print evaluated Capacitor config (hidden command).

npx cap config [options]

Options:

  • --json - Print in JSON format
function configCommand(config: Config, json?: boolean): Promise<void>;

telemetry

Enable or disable telemetry (hidden command).

npx cap telemetry [on|off]

Usage Examples:

# View current config
npx cap config

# View config as JSON
npx cap config --json

# Enable telemetry
npx cap telemetry on

# Disable telemetry
npx cap telemetry off

Plugin Development

plugin:generate

Start a new Capacitor plugin (hidden command).

npx cap plugin:generate

Usage Example:

# Create a new plugin
npx cap plugin:generate

Command Execution Context

All commands operate within the context of a loaded Capacitor configuration and provide comprehensive error handling and validation.

type CommanderAction = (...args: any[]) => void | Promise<void>;

function wrapAction(action: CommanderAction): CommanderAction;

Install with Tessl CLI

npx tessl i tessl/npm-capacitor--cli

docs

asset-management.md

cli-commands.md

configuration.md

index.md

platform-operations.md

plugin-management.md

validation.md

tile.json