# apache/cordova-cli architecture

> Architecture diagram of the GitHub repository apache/cordova-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/apache/cordova-cli
- Repository: https://github.com/apache/cordova-cli

## Overview

##### Project type and purpose
- This is a Node.js–based command‐line interface (CLI) tool called “Cordova CLI.”
- Its purpose is to orchestrate, build, deploy, and manage Apache Cordova–based mobile projects: parsing user commands, delegating tasks to cordova-lib and platform toolchains (Android, iOS, etc.), and managing plugins.

##### File structure
- Top-level “bin/cordova” and “bin/cordova.cmd”: the executable shims/users invoke.
- “src/”: core JS modules that implement command parsing (`cli.js`), help text (`help.js`), info commands (`info.js`), and route subcommands.
- “scripts/cordova.completion”: shell completion support.
- “doc/”: per-command usage guides.
- “spec/”: Jasmine test specs for each command and helpers.
- Config and metadata: `package.json`, `.eslintrc.yml`, GitHub workflows, CONTRIBUTING, etc.

##### Extract insights from README
- Confirms it’s purely a CLI orchestrator.
- Delegates most functionality to “cordova-lib” for platform/plugin logic.
- Targets multiple mobile platforms via plugin/adapter pattern.
- Integrates with external toolchains (Gradle, Xcode, Android SDK).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User / Shell"]:::user
    CLI_Launcher["CLI Launcher\n(bin/cordova, bin/cordova.cmd)"]:::cli
    Command_Parser["Command Parser & Dispatcher\n(src/cli.js)"]:::cli
    ShellCompletion["Shell Completion Support\n(scripts/cordova.completion)"]:::cli
    Documentation["Per-Command Documentation\n(doc/)"]:::docs
    Config["Config & Metadata\n(package.json, .eslintrc.yml)"]:::cfg
    CoreStub["Core CLI Stub\n(cordova.js)"]:::cli

    subgraph "Commands Subsystem"
        Help["Help Command"]:::cli
        Info["Info Command"]:::cli
        Create["Create Command"]:::cli
        Build["Build Command"]:::cli
        PluginCmd["Plugin Command"]:::cli
        PlatformCmd["Platform Command"]:::cli
    end

    CordovaLib["cordova-lib\n(Core Library)"]:::lib

    subgraph "Plugin System"
        PluginSys["Plugin System"]:::lib
    end

    subgraph "Platform Adapters"
        Android["Android Adapter"]:::adapter
        iOS["iOS Adapter"]:::adapter
        Windows["Windows Adapter"]:::adapter
    end

    subgraph "External Toolchains"
        Gradle["Gradle"]:::ext
        Xcode["Xcode"]:::ext
        AndroidSDK["Android SDK CLI"]:::ext
        NPMRegistry["NPM Registry"]:::ext
    end

    FileSystem["File System\n(project dir, config.xml, www)"]:::fs

    subgraph "CI & Testing"
        Tests["Jasmine Test Specs"]:::testing
        CI["CI Workflows"]:::testing
    end

    User -->|"invoke"| CLI_Launcher
    CLI_Launcher -->|"bootstrap"| Command_Parser
    CLI_Launcher -->|"load completion"| ShellCompletion
    CLI_Launcher -->|"load docs"| Documentation
    CLI_Launcher -->|"load config"| Config
    CLI_Launcher --> CoreStub
    Command_Parser --> Help
    Command_Parser --> Info
    Command_Parser --> Create
    Command_Parser --> Build
    Command_Parser --> PluginCmd
    Command_Parser --> PlatformCmd
    Help -->|"calls API"| CordovaLib
    Info -->|"calls API"| CordovaLib
    Create -->|"calls API"| CordovaLib
    Build -->|"calls API"| CordovaLib
    PluginCmd -->|"calls API"| CordovaLib
    PlatformCmd -->|"calls API"| CordovaLib
    CoreStub --> CordovaLib
    CordovaLib --> PluginSys
    CordovaLib --> Android
    CordovaLib --> iOS
    CordovaLib --> Windows
    PluginSys -->|"fetch/install"| NPMRegistry
    Android -->|"spawn process"| Gradle
    Android -->|"spawn process"| AndroidSDK
    iOS -->|"spawn process"| Xcode
    Windows -->|"spawn process"| Gradle
    Android --> FileSystem
    iOS --> FileSystem
    Windows --> FileSystem
    PluginSys --> FileSystem
    CI -->|"runs"| Tests
    Tests -->|"reports"| CI
    CI --> User

    click CLI_Launcher "https://github.com/apache/cordova-cli/tree/master/bin/cordova"
    click Command_Parser "https://github.com/apache/cordova-cli/blob/master/src/cli.js"
    click Help "https://github.com/apache/cordova-cli/blob/master/src/help.js"
    click Info "https://github.com/apache/cordova-cli/blob/master/src/info.js"
    click ShellCompletion "https://github.com/apache/cordova-cli/blob/master/scripts/cordova.completion"
    click Documentation "https://github.com/apache/cordova-cli/tree/master/doc/"
    click Config "https://github.com/apache/cordova-cli/blob/master/package.json"
    click CoreStub "https://github.com/apache/cordova-cli/blob/master/cordova.js"
    click Tests "https://github.com/apache/cordova-cli/tree/master/spec/"
    click CI "https://github.com/apache/cordova-cli/blob/master/.github/workflows/ci.yml"

    classDef user fill:#e6ffe6,stroke:#008000,color:#000
    classDef cli fill:#e6ffe6,stroke:#008000,color:#000
    classDef lib fill:#cce5ff,stroke:#004085,color:#000
    classDef adapter fill:#ffe5cc,stroke:#994d00,color:#000
    classDef ext fill:#f2f2f2,stroke:#666,color:#000
    classDef fs fill:#f2f2f2,stroke:#666,color:#000
    classDef testing fill:#f5f5f5,stroke:#a6a6a6,color:#000
    classDef docs fill:#f5f5f5,stroke:#a6a6a6,color:#000
    classDef cfg fill:#f5f5f5,stroke:#a6a6a6,color:#000
```
