Existing save/restore functionality
cordova plugin add/rm PLUGINNAME||gitURL||localPlugin --save
<plugin name="cordova-plugin-device" spec="../../cordova-plugin-device" />
to config.xml
.cordova platform add/rm Platform||gitURL||localPath --save
<engine name="ios" spec="~4.2.1" />
to config.xml
cordova platform/plugin save
config.xml
autosave for platforms and plugins (didn't test, not documented)
"auto_save_plugins":"true"
and "auto_save_platforms":"true"
cordova prepare
restores missing plugins and platforms based on config.xml
package.json
. Introduce new cordova
key in package.json
that stores what plugins and platforms have been saved. This is required for restoring.{ ... "dependencies": { "cordova-plugin-device": "^1.1.3", "cordova-android": "^5.2.2" } "cordova": { "platforms": ["andoid"], "plugins": ["cordova-plugin-device"] } ... }
--save
logic to save to package.json
. cordova-fetch
allows us to pass the --save
flag down to our npm install PLUGIN/PLATFORM
command. Plugins and Platforms get added as regular dependencies in package.json
this way. cordova plugin/platform add/rm
would also add/rm the plugin/platform to/from the new cordova
key in package.json
.npm config set save=true
. cordova-fetch
will use system npm, so this should work, but we will have to test it.config.xml
, look in package.json
at cordova
key.cordova
key and edits dependencies
with platoform/plugins + versions.cordovaDependencies
will be fetched.My plan is to keep the existing save/restore config.xml
logic for cordova@6.x and start adding the package.json
logic beside it. If your project has a package.json
, it will start saving to it as well as config.xml
. In cordova@7, I want to rip out saving to config.xml
logic.
The reason for this change is to add package.json
in a standard cordova app and have it work as it would in a node style project. This will lead to cordova developers able to use npm modules while building their apps.
config.xml
saved platforms and plugins into package.json
. I'm thinking this happens during the restore phase which runs on prepare. Alternatively, we could create a new command to do it.package.json
to existing cordova projects which don't have it.npm install
on your projects will fetch the dependencies in package.json
, but a cordova prepare
(restore) will be needed to install them to your cordova project.npm install cordova-plugin-device
will fetch the plugin, but won't install it. cordova plugin add cordova-plugin-device --save
will still be required. Same goes for platforms. Positive is, the plugin/platform will already be fetched.config.xml
and only use package.json