Skip to content
Browse files
updated cordova-fetch proposal
  • Loading branch information
stevengill committed Jun 2, 2016
1 parent 96a345d commit 67c1097824af72b2aa1038af05bb17340a4f02be
Showing 1 changed file with 29 additions and 6 deletions.
@@ -9,9 +9,16 @@ Three existing fetching implementations.
- Lazy Load

2. Plugin Fetching
- possiblyFetch
- fetch.js
- registry.fetch

a) cordova plugin fetching
- plugin.js
- fetch.js
- registry.fetch
b) plugman plugin fetching
- install.js
- possiblyFetch
- fetch.js
- registry.fetch

3. Template Fetching
- create.js
@@ -23,7 +30,23 @@ Currently, platforms and templates are cached at `~/.cordova/lib/npm_cache/PACKA

### Proposal:

* Create a new module named `cordova-fetch`. Fetches from npm, git and local paths.
* Create a new module named `cordova-fetch`. Fetches from npm and git.
* Start using system installed `npm` instead of packaging our own `npm` in `cordoba-lib`. We already check for `git` being installed, we should do the same for `npm`. We would use `superspawn` to shell out to the system `npm`.
* Stop using `.cordova/npm_cache/` and instead use `.npm/` for all of our `npm caching`. This will allow us to move away from passing custom config options to npm.
* Update existing fetching logic to use new `cordova-fetch` module.
* Stop using `.cordova/npm_cache/`. Modules instead get fetched to root `node_modules` directory in your applications
* Add new `--fetch` flag to `cordova` and `plugman` to use `cordova-fetch` over existing fetching methods
* Plugin/platform removal should run `npm uninstall` on your cordova projects to remove the module from the apps `node_modules` directory.
* if a `package.json` exists, adding `--save` will also add the dependency to `package.json` (as well as to `config.xml`). This won't be used until a future update is made to move save functionality from `config.xml` to `package.json`. Just adding it now for future proofing.

### New Requirements

* Have to remove support for installing plugins/platforms from git subdirectoires. I recommend we add deprecation notices for this ASAP.
* Every plugin, platform and template requires a `package.json`

### Quirks

* Currently, I am using a diff of `npm ls` to determine which module was just installed. This is because the user can pass in a git url as a target to `cordova-fetch`. If the git url repo-name is different than the ``, 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 applications `node_modules` directory.
* 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.

### Future goals

* add a package.json to cordova projects, update `cordova` to start using `package.json` instead of `config.xml`. This requires moving over a lot of properties we currently parse in `config.xml` and updating tools to look in `package.json` before checking `config.xml`.

0 comments on commit 67c1097

Please sign in to comment.