Apache Cordova CLI

repository·master·Indexed 21 days ago

https://github.com/apache/cordova-cli

A command-line interface tool used to build, deploy, and manage Apache Cordova-based applications. It enables the creation of multi-platform mobile apps using HTML, CSS, and JavaScript, and provides utilities for managing platform integrations, plugins, and environment configurations.

Tokens
4.2K
Snippets
24
Records
33
Agent score
76%

What's inside cordova-cli

  1. Upgrade to Cordova-cli v11.0.0

    master

    When upgrading to version 11.0.0 (released Dec 17, 2021), note these changes:

    • Android Command Change: The deprecated android command has been replaced with avdmanager.
    • Deprecated Field: The preferGlobal field in package.json is deprecated and has been removed.
    • Plugin Save Command: The plugin save command has been removed from the CLI help.
    • Node Support: Node support has been updated (refer to specific version requirements for your environment).
  2. Create and run a new Cordova project

    master

    Follow these steps to initialize a new project, add a plugin (e.g., camera), add a platform (e.g., android), verify requirements, build, and run the application.

    # Create the project: cordova create <directory> <package_id> <name>
    cordova create myApp com.myCompany.myApp myApp
    cd myApp
    
    # Add a plugin
    cordova plugin add cordova-plugin-camera --save
    
    # Add a platform
    cordova platform add android --save
    
    # Check if system requirements for the platform are met
    cordova requirements android
    
    # Build the application
    cordova build android --verbose
    
    # Run the application on a connected device or emulator
    cordova run android
  3. Install Bash tab-completion for Cordova CLI

    master

    Cordova CLI includes a script to provide command-line tab-completion for Bash on Unix-like systems (Linux, BSD, OS X). This makes typing Cordova commands and arguments faster and less error-prone.

    Linux or BSD

    Copy the scripts/cordova.completion file (found within the Cordova installation) to your /etc/bash_completion.d directory. The completion will be active in any new shell session.

    OS X

    1. Place the scripts/cordova.completion file in a readable location on your filesystem.
    2. Add the following line to the end of your ~/.bashrc file: source <path to>/cordova.completion
    3. The completion will be active in any new shell session.
    # Example for OS X
    source /path/to/your/scripts/cordova.completion
  4. Update a Cordova platform

    master

    In version 3.0.10 and later, you can update an existing platform using the cordova platform update <platform> command. This command triggers the platform's specific update script. Supported platforms with update scripts include:

    • Android
    • iOS
    • WP7
    • WP8
    cordova platform update <platform>
  5. Install the Cordova CLI

    master

    Install the Cordova command-line tool globally using npm. This allows you to manage multi-platform Cordova applications and integrate plugins from your terminal.

    # On Windows
    npm install -g cordova
    
    # On Mac OS X/Linux
    sudo npm install -g cordova
  6. Upgrade to Cordova-cli v13.0.0

    master

    When upgrading to version 13.0.0 (released Nov 23, 2025), be aware of the following breaking changes:

    • Node.js Engine Requirement: The Node.js engine requirement has been bumped. Ensure your environment meets the new minimum version.
    • Telemetry Removal: The telemetry feature has been removed.
    • Dependency Updates: Various npm packages and dependencies have been bumped to newer versions.
  7. Upgrade to Cordova-cli v10.0.0

    master

    When upgrading to version 10.0.0 (released Jul 31, 2020), be aware of the following breaking changes and removals:

    • Command Removals/Undocumentations:
      • platform save command is removed/undocumented.
      • plugin save command is removed/undocumented.
      • --copy-from option is no longer supported.
      • hooks/ directory mentions have been removed from documentation.
      • platform check command is undocumented.
    • Configuration Changes:
      • Support for <project>/.cordova/config.json has been removed.
      • The autosave setting in config has been removed.
    • Node.js Support:
      • Support for Node.js 6 and 8 has been dropped.
    • Other Changes:
      • cordova info logic has been migrated from the library to the CLI.
    • Dependency Bumps: Significant updates to cordova-lib (v10.0.0) and various other core dependencies.
  8. Use Bash tab-completion for Cordova commands

    master

    Once installed, you can use the <TAB> key to autocomplete Cordova commands, platform names, and plugin identifiers. The completion works as long as your command line begins with an executable named cordova.

    Completion Examples

    Command completion:

    $ cordova <TAB>
    build     compile   create    emulate   platform  plugin    prepare   serve

    Subcommand completion:

    $ cordova pla<TAB>
    cordova platform <TAB>
    add ls remove rm

    Argument completion (Platforms):

    $ cordova platform a<TAB>
    android     blackberry  ios         wp8         www

    Argument completion (Plugins):

    $ cordova plugin rm org.apache.cordova.<TAB>
    org.apache.cordova.file    org.apache.cordova.inappbrowser
    $ cordova <TAB>
    $ cordova platform add <TAB>
  9. Add platforms from Git URLs

    master

    The --usegit flag was deprecated in version 6.0.0. The recommended way to add a platform from a Git repository is to use the following syntax: cordova platform add <git_url>#<branch>.

    cordova platform add https://github.com/example/cordova-platform-example.git#master
  10. Get help and command syntax for cordova-cli

    master

    You can view the general syntax summary or obtain detailed help for a specific command using the help command or the -h flag.

    To see the general help summary, use: cordova-cli help

    To see help for a specific command, use one of the following patterns:

    • cordova-cli help [command]
    • cordova-cli [command] -h
    • cordova-cli -h [command]
    # Show general help
    cordova-cli help
    
    # Show help for a specific command (e.g., 'platform')
    cordova-cli help platform
    cordova-cli platform -h
    cordova-cli -h platform
  11. Upgrade to Cordova-cli v12.0.0

    master

    When upgrading to version 12.0.0 (released May 20, 2023), be aware of the following breaking changes:

    • Node.js Requirement: The minimum Node.js requirement is now >=16.13.0.
    • cordova run behavior: The run command now calls the platform API to list targets.
    • update-notifier removal: Support for update-notifier has been removed.
    • Dependency Bumps: Significant updates to cordova-create (v5.0.0) and cordova-lib (v12.0.0).