{"id":26057335,"url":"https://github.com/apache/cordova-common","last_synced_at":"2025-04-12T16:34:26.558Z","repository":{"id":13865972,"uuid":"74950508","full_name":"apache/cordova-common","owner":"apache","description":"Apache Cordova Common Tooling Library","archived":false,"fork":false,"pushed_at":"2025-02-02T05:05:15.000Z","size":1211,"stargazers_count":41,"open_issues_count":15,"forks_count":41,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-03T04:16:52.509Z","etag":null,"topics":["cordova","hacktoberfest","javascript","mobile","nodejs"],"latest_commit_sha":null,"homepage":"https://cordova.apache.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-28T08:00:08.000Z","updated_at":"2025-02-27T02:25:07.000Z","dependencies_parsed_at":"2024-06-17T18:29:17.739Z","dependency_job_id":"e5367d82-f88b-494e-97c0-02c0f22451d0","html_url":"https://github.com/apache/cordova-common","commit_stats":{"total_commits":303,"total_committers":50,"mean_commits":6.06,"dds":0.8118811881188119,"last_synced_commit":"e6afc1cff11afc26e6be53bdcd7c0431bc822179"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-common","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-common/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-common/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-common/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/cordova-common/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247910597,"owners_count":21016714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cordova","hacktoberfest","javascript","mobile","nodejs"],"created_at":"2025-03-08T11:08:30.888Z","updated_at":"2025-04-12T16:34:26.535Z","avatar_url":"https://github.com/apache.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n#\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n#  KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n#\n--\u003e\n\n# cordova-common\n\n[![NPM](https://nodei.co/npm/cordova-common.png)](https://nodei.co/npm/cordova-common/)\n\n[![Node CI](https://github.com/apache/cordova-common/workflows/Node%20CI/badge.svg?branch=master)](https://github.com/apache/cordova-common/actions?query=branch%3Amaster)\n\nExposes shared functionality used by [cordova-lib](https://github.com/apache/cordova-lib/) and Cordova platforms.\n\n## Exposed APIs\n\n### `events`\n\nRepresents special instance of NodeJS `EventEmitter` which is intended to be used to post events to `cordova-lib` and `cordova-cli`\n\nUsage:\n\n```js\nconst { events } = require('cordova-common');\nevents.emit('warn', 'Some warning message')\n```\n\nHere are the following supported events by `cordova-cli`:\n\n* `verbose`\n* `log`\n* `info`\n* `warn`\n* `error`\n\n### `CordovaError`\n\nAn 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).\n\nUsage:\n\n```js\nconst { CordovaError } = require('cordova-common');\nthrow new CordovaError('Some error message', SOME_ERR_CODE);\n```\n\nSee [CordovaError](src/CordovaError/CordovaError.js) for supported error codes.\n\n### `ConfigParser`\n\nExposes functionality to deal with cordova project `config.xml` files. For `ConfigParser` API reference check [ConfigParser Readme](src/ConfigParser/README.md).\n\nUsage:\n\n```js\nconst { ConfigParser } = require('cordova-common');\nconst appConfig = new ConfigParser('path/to/cordova-app/config.xml');\nconsole.log(`${appconfig.name()}:${appConfig.version()}`);\n```\n\n### `PluginInfoProvider` and `PluginInfo`\n\n`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.\n\nUsage:\n\n```js\nconst { PluginInfo, PluginInfoProvider }  = require('cordova-common');\n\n// The following instances are equal\nconst plugin1 = new PluginInfo('path/to/plugin_directory');\nconst plugin2 = new PluginInfoProvider().get('path/to/plugin_directory');\n\nconsole.log(`The plugin ${plugin1.id} has version ${plugin1.version}`)\n```\n\n### `ActionStack`\n\nUtility 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.\n\nUsage:\n\n```js\nconst { ActionStack } = require('cordova-common');\n\nconst stack = new ActionStack();\nconst action1 = stack.createAction(task1, [\u003ctask parameters\u003e], task1_reverter, [\u003creverter_parameters\u003e]);\nconst action2 = stack.createAction(task2, [\u003ctask parameters\u003e], task2_reverter, [\u003creverter_parameters\u003e]);\n\nstack.push(action1);\nstack.push(action2);\n\nstack.process()\n    .then(() =\u003e {\n        // all actions succeded\n    })\n    .catch(error =\u003e {\n        // One of actions failed with error\n    });\n```\n\n### `superspawn`\n\nModule for spawning child processes with some advanced logic.\n\nUsage:\n\n```js\nconst { superspawn } = require('cordova-common');\n\nsuperspawn.spawn('adb', ['devices'])\n    .progress(data =\u003e {\n        if (data.stderr) console.error(`\"adb devices\" raised an error: ${data.stderr}`);\n    })\n    .then(devices =\u003e {\n        // Do something...\n    });\n```\n\n### `xmlHelpers`\n\nA set of utility methods for dealing with XML files.\n\nUsage:\n\n```js\nconst { xmlHelpers } = require('cordova-common');\n\nconst doc1 = xmlHelpers.parseElementtreeSync('some/xml/file');\nconst doc2 = xmlHelpers.parseElementtreeSync('another/xml/file');\n\nxmlHelpers.mergeXml(doc1, doc2); // doc2 now contains all the nodes from doc1\n```\n\n### Other APIs\n\nThe APIs listed below are also exposed but are intended to be only used internally by cordova plugin installation routines.\n\n* `PlatformJson`\n* `ConfigChanges`\n* `ConfigKeeper`\n* `ConfigFile`\n\n## Setup\n\n* Clone this repository onto your local machine\n\n    ```bash\n    git clone https://github.com/apache/cordova-common.git\n    ```\n\n* Navigate to cordova-common directory, install dependencies and npm-link\n\n    ```bash\n    cd cordova-common \u0026\u0026 npm install \u0026\u0026 npm link\n    ```\n\n* Navigate to cordova-lib directory and link cordova-common\n\n    ```bash\n    cd \u003ccordova-lib directory\u003e \u0026\u0026 npm link cordova-common \u0026\u0026 npm install\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-common","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fcordova-common","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-common/lists"}