- Status: Completed
Three existing fetching implementations.
-
Platform Fetching
-
Plugin Fetching
a) cordova plugin fetching - plugin.js https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/cordova/plugin.js#L147 - fetch.js https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/plugman/fetch.js - registry.fetch https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/plugman/registry/registry.js#L123 b) plugman plugin fetching - install.js https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/plugman/install.js - possiblyFetch https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/plugman/install.js#L104 - fetch.js https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/plugman/fetch.js - registry.fetch https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/plugman/registry/registry.js#L123
-
Template Fetching
Both lazy load and remote load use gitclone.js https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/gitclone.js
Currently, platforms and templates are cached at ~/.cordova/lib/npm_cache/PACKAGE. On master, plugins are being cached to ~/.npm/PACKAGE.
- Create a new module named
cordova-fetch. Fetches from npm and git. - Start using system installed
npminstead of packaging our ownnpmincordoba-lib. We already check forgitbeing installed, we should do the same fornpm. We would usesuperspawnto shell out to the systemnpm. - Stop using
.cordova/lib/npm_cache/. Modules instead get fetched to rootnode_modulesdirectory in your applications - Add new
--fetchflag tocordovaandplugmanto usecordova-fetchover existing fetching methods - Plugin/platform removal should run
npm uninstallon your cordova projects to remove the module from the appsnode_modulesdirectory. - if a
package.jsonexists, adding--savewill also add the dependency topackage.json(as well as toconfig.xml). This won't be used until a future update is made to move save functionality fromconfig.xmltopackage.json. Just adding it now for future proofing. - Add
--fetchflag tocordova create APPID --template TEMPLATEID/GITURLto use cordova-fetch when getting the template. The template is fetched to.cordova/node_modules/directory and the appropriate files are added.
- Have to remove support for installing plugins/platforms from git subdirectoires. https://cordova.apache.org/docs/en/5.0.0/guide/cli/#advanced-plugin-options. I recommend we add deprecation notices for this ASAP.
- Every plugin, platform and template requires a
package.json
- Currently, I am using a diff of
npm lsto determine which module was just installed. This is because the user can pass in a git url as a target tocordova-fetch. If the git url repo-name is different than thepackage.name, only way to get what module was just installed is by doing a diff before and after the installation. The diffing technique can fail if the user is adding a module that has already been npm installed. Luckily cordova doesn't allow adding platform/plugin which has already been added. cordova platform/plugin rm will also remove the module from the applicationsnode_modulesdirectory. - As a fallback to the diffing method, I am taking the target or repo-name as the module name. Hopefully this won't be needed.
- add a package.json to cordova projects, update
cordovato start usingpackage.jsonas well asconfig.xml. This requires moving over some functionality fromconfig.xmland updating tools to look inpackage.jsonbefore checkingconfig.xml.
Issues: https://issues.apache.org/jira/browse/CB-9858 & https://issues.apache.org/jira/browse/CB-11349