To get an architecture overview of Apache Cordova and how it works and how all its many libraries are connected, it makes sense to follow the journey a typical user of Cordova would take:
$ npm install -g cordova
The user then can run commands like
cordova -v in their command line, which executes the
bin/cordova program (or
bin/cordova.cmd on Windows, which just executes
bin/cordova with node) that is installed in the global npm packages directory.
cordova-cli, the user also installed two other Cordova libraries via the dependencies in
package.json (next to several other, external libraries) :
cordova-cli itself is a pretty thin layer of code that handles parsing and redirecting the commands the CLI can execute over to
cordova-lib. Besides, it handles outputting the
help commands and prompting for permission and sending telemetry data. From
cordova-common it uses mainly the logger and some error handling.
cordova-lib on the other hand is the heart of the Cordova CLI: Most commands executed with
cordova-cli are then actually handled by
cordova-lib. For that it has dependencies on the rest of the Cordova tooling libraries:
To understand how those are used, it is best to look at some Cordova CLI command the user will execute:
$ cordova create
If they don't have a project via Git or download, they will run
cordova create to create a new Cordova project.
$ cordova info
$ cordova platform add ...
Adds platform pinned versions
contains default plugins
$ cordova plugin add ...
manually add plugins
$ cordova serve
$ cordova prepare/compile/clean/run(/emulate/build) ...
CLI command to run/emulate/build platform
$ cordova requirements