问题
File fetch.json created inside plugins folder after cordova plugin add executed first time. This file also modified each time I add/remove plugins.
- What purpose of this file exactly?
- What tools use this file, when and why?
- Is there a way to restore plugins using fetch.json (try not to place plugins into repositiory)?
- Where can I find some docs about content of this file?
Content of fetch.json:
{
"com.phonegap.plugins.PushPlugin": {
"source": {
"type": "git",
"url": "https://github.com/phonegap-build/PushPlugin.git",
"subdir": "."
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-file": {
"source": {
"type": "registry",
"id": "cordova-plugin-file"
},
"is_top_level": true,
"variables": {}
}
}
回答1:
Looks like this file tracks installed plugins, their origin and revision, like npm package.json dependencies does, but for plugman. I guess and hope this should migrate to the npm standard soon.
This file is updated on cordova add/remove plugins (https://github.com/apache/cordova-lib/blob/e4e5904619bab05705d62bce92a4c4cd0d45bb82/cordova-lib/src/cordova/plugin.js#L272)
When we cordova prepare
, cordova reads plugin list from plugins/ios.json
(for ios), then, for each one :
- get the plugin infos from
plugins/fetch.json
- try to find the plugin locally
looks like its not possible to restore plugins with this file. My workflow is :
- define plugins dependencies in config.xml
- remote platforms and empty plugins folder
- run
cordova platform add xxx
this will refetch plugins as defined in config.xml
Looks like the only doc is the source code : https://github.com/apache/cordova-lib/search?utf8=%E2%9C%93&q=fetch
来源:https://stackoverflow.com/questions/30285200/what-is-the-purpose-of-fetch-json-file-inside-cordova-plugins-folder