Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of fetch.json file inside cordova plugins folder?

Tags:

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": {}     } } 
like image 809
rtf_leg Avatar asked May 17 '15 09:05

rtf_leg


People also ask

How do Cordova plugins work?

A plugin is a package of injected code that allows the Cordova webview within which the app renders to communicate with the native platform on which it runs. Plugins provide access to device and platform functionality that is ordinarily unavailable to web-based apps.

What is Cordova plugin AndroidX?

This Cordova/Phonegap plugin enables AndroidX in a Cordova project (AndroidX is the successor to the Android Support Library). This plugin is useful if your project contains plugins which have migrated to AndroidX or if you otherwise want to enable AndroidX in your Cordova Android platform project.

What is Cordova plugin whitelist?

The plugin whitelist can be defined as the security model that is responsible for controlling an access to the external domains. The Cordova mainly offers a configurable security policy that defines which of the external sites can be accessed.

How to parse data from JSON using FETCH in JavaScript?

Calling fetch () starts a request and returns a promise. When the request completes, the promise resolves to the response object. Response object provides useful methods to extract data from a multitude of formats. But to parse data from JSON you need just one method — response.json ().

What is a Cordova plugin?

A Plugin can be defined as a package of add-on code that is used to enable a Cordova web view to communicate with the native platform. It can offer a JavaScript interface to the native components.

Is the FileSystem API supported in Cordova applications?

Note While the W3C FileSystem spec is deprecated for web browsers, the FileSystem APIs are supported in Cordova applications with this plugin for the platforms listed in the Supported Platforms list, with the exception of the Browser platform. To get a few ideas how to use the plugin, check out the sample at the bottom of this page.

How to use fetch () API to load or post data?

In this post, I'll guide you on how to use fetch () API to load (usually using GET method) or post data (usually using a POST method) JSON data. 1. Recalling fetch () The first obligatory argument of fetch () is the URL of the request, or generally a request object. options, the optional second argument, lets you configure the request.


1 Answers

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

like image 65
jujule Avatar answered Sep 17 '22 23:09

jujule