5.0.1 • Published 3 months ago

cordova-common v5.0.1

Weekly downloads
143,333
License
Apache-2.0
Repository
github
Last release
3 months ago

cordova-common

NPM

Node CI

Exposes shared functionality used by cordova-lib and Cordova platforms.

Exposed APIs

events

Represents special instance of NodeJS EventEmitter which is intended to be used to post events to cordova-lib and cordova-cli

Usage:

const { events } = require('cordova-common');
events.emit('warn', 'Some warning message')

Here are the following supported events by cordova-cli:

  • verbose
  • log
  • info
  • warn
  • error

CordovaError

An error class used by Cordova to throw cordova-specific errors. The CordovaError class is inherited from Error, so it is a valid instance of Error. (instanceof check succeeds).

Usage:

const { CordovaError } = require('cordova-common');
throw new CordovaError('Some error message', SOME_ERR_CODE);

See CordovaError for supported error codes.

ConfigParser

Exposes functionality to deal with cordova project config.xml files. For ConfigParser API reference check ConfigParser Readme.

Usage:

const { ConfigParser } = require('cordova-common');
const appConfig = new ConfigParser('path/to/cordova-app/config.xml');
console.log(`${appconfig.name()}:${appConfig.version()}`);

PluginInfoProvider and PluginInfo

PluginInfo is a wrapper for cordova plugins' plugin.xml files. This class may be instantiated directly or via PluginInfoProvider. The difference is that PluginInfoProvider caches PluginInfo instances based on plugin source directory.

Usage:

const { PluginInfo, PluginInfoProvider }  = require('cordova-common');

// The following instances are equal
const plugin1 = new PluginInfo('path/to/plugin_directory');
const plugin2 = new PluginInfoProvider().get('path/to/plugin_directory');

console.log(`The plugin ${plugin1.id} has version ${plugin1.version}`)

ActionStack

Utility module for dealing with sequential tasks. Provides a set of tasks that are needed to be done and reverts all tasks that are already completed if one of those tasks fail to complete. Used internally by cordova-lib and platform's plugin installation routines.

Usage:

const { ActionStack } = require('cordova-common');

const stack = new ActionStack();
const action1 = stack.createAction(task1, [<task parameters>], task1_reverter, [<reverter_parameters>]);
const action2 = stack.createAction(task2, [<task parameters>], task2_reverter, [<reverter_parameters>]);

stack.push(action1);
stack.push(action2);

stack.process()
    .then(() => {
        // all actions succeded
    })
    .catch(error => {
        // One of actions failed with error
    });

superspawn

Module for spawning child processes with some advanced logic.

Usage:

const { superspawn } = require('cordova-common');

superspawn.spawn('adb', ['devices'])
    .progress(data => {
        if (data.stderr) console.error(`"adb devices" raised an error: ${data.stderr}`);
    })
    .then(devices => {
        // Do something...
    });

xmlHelpers

A set of utility methods for dealing with XML files.

Usage:

const { xmlHelpers } = require('cordova-common');

const doc1 = xmlHelpers.parseElementtreeSync('some/xml/file');
const doc2 = xmlHelpers.parseElementtreeSync('another/xml/file');

xmlHelpers.mergeXml(doc1, doc2); // doc2 now contains all the nodes from doc1

Other APIs

The APIs listed below are also exposed but are intended to be only used internally by cordova plugin installation routines.

  • PlatformJson
  • ConfigChanges
  • ConfigKeeper
  • ConfigFile

Setup

  • Clone this repository onto your local machine

    git clone https://github.com/apache/cordova-common.git
  • Navigate to cordova-common directory, install dependencies and npm-link

    cd cordova-common && npm install && npm link
  • Navigate to cordova-lib directory and link cordova-common

    cd <cordova-lib directory> && npm link cordova-common && npm install
@infinitebrahmanuniverse/nolb-cordova-c@everything-registry/sub-chunk-1381tanngoweexpack-androidweexpack-ios@dishuostec/cordova-fetch@drkmtrx/cordovajudpack-androidsqy-syberosumi-plugin-cordova@alitajs/cordova@ckk/cordova-set-version@chacabuk/cordova-plugin-googlemaps@cleveradssolutions/cas.cordova.ironsource@cleveradssolutions/cas.cordova.kidoz@cleveradssolutions/cas.cordova.mintegral@cleveradssolutions/cas.cordova.mytarget@cleveradssolutions/cas.cordova.optimal@cleveradssolutions/cas.cordova.pangle@cleveradssolutions/cas.cordova.superawesome@cleveradssolutions/cas.cordova.tapjoy@cleveradssolutions/cas.cordova.unity@cleveradssolutions/cas.cordova.vungle@cleveradssolutions/cas.cordova.yandex@cleveradssolutions/cas.cordova.adcolony@cleveradssolutions/cas.cordova.admob@cleveradssolutions/cas.cordova.applovin@cleveradssolutions/cas.cordova.facebook@cleveradssolutions/cas.cordova.families@cleveradssolutions/cas.cordova.fyber@cleveradssolutions/cas.cordova.inmobi@herdwatch/cordova@ionic-enterprise/cordova@ionic-enterprise/cordova-lib@keyri/cordova-keyri@parrino/cordova-plugin-googlemaps@situm/cordovaseymournguyepgb-cordova-libplugxsitum-cordova-plugin-officialhadesbridgehadesbridge2hadesxhades-android-template2kountexample@totalpave/cordova-plugin-date@stevegill/cordova-ios@tecnosolve/cordova-plugin-app-nameadmob-plusaemmartefaktasreaderchocobi-ioschocobi-libcatapush-cordovacom.meenrios.samplecordova-androidcordova-plugin-amplify-paycordova-plugin-amplify-paymentcordovacordova-adcel-plugincorbercordova-osxcordova-paramedic-runnercordova-createcordova-fetchcordova-electroncordova-plugin-newplugincordova-plugin-flyff-location-baiducordova-plugin-flavorscordova_ios_for_windowscordova-update-configcordova-update-config-enhancedcordova-testbedcordova-windowscordova-browsercordova-browser-jehecordova-android-gradle-memory-fixcordova-android-transcordova-check-pluginscordova-platform-testcordova-libcordova-ioscordova-ios-devcordova-plugin-baidulocation-xhcordova-plugin-googlemaps-alwayscordova-plugin-googlemaps-latestcordova-plugin-googlemaps-multiple-maps-branchcordova-plugin-googlemapscordova-plugin-googlemaps-18cordova-plusbrowser-jeheeeft-plugin-googlemapsdroiv-vueember-cordova
5.0.1

4 months ago

5.0.1-nightly

2 years ago

5.0.0

2 years ago

4.1.0

3 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.0

6 years ago

3.0.0

7 years ago

2.2.5

7 years ago

2.2.4

7 years ago

2.2.3

7 years ago

2.2.2-dev

7 years ago

2.2.1

7 years ago

2.2.1-dev

8 years ago

2.2.0

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.4-dev

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.5.1

9 years ago

1.5.0

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

10 years ago

0.1.0

10 years ago