You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by rk...@apache.org on 2016/03/22 22:09:55 UTC

[1/2] docs commit: CB-10679: Adding docs for new plugin version fetching implementation

Repository: cordova-docs
Updated Branches:
  refs/heads/master 3b88544f7 -> b22300790


CB-10679: Adding docs for new plugin version fetching implementation


Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/3def9d42
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/3def9d42
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/3def9d42

Branch: refs/heads/master
Commit: 3def9d4281af3d00e719bc4637b434619d99bdf4
Parents: 3b88544
Author: riknoll <ri...@gmail.com>
Authored: Wed Feb 24 13:25:40 2016 -0800
Committer: Richard Knoll <ri...@gmail.com>
Committed: Tue Mar 22 13:43:18 2016 -0700

----------------------------------------------------------------------
 www/docs/en/dev/guide/hybrid/plugins/index.md | 100 +++++++++++++++++++++
 1 file changed, 100 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/3def9d42/www/docs/en/dev/guide/hybrid/plugins/index.md
----------------------------------------------------------------------
diff --git a/www/docs/en/dev/guide/hybrid/plugins/index.md b/www/docs/en/dev/guide/hybrid/plugins/index.md
index e1f3cd8..d8b2712 100644
--- a/www/docs/en/dev/guide/hybrid/plugins/index.md
+++ b/www/docs/en/dev/guide/hybrid/plugins/index.md
@@ -245,4 +245,104 @@ For example, for a plugin that supports android, iOS & Windows, the keywords in
 
 For more detailed example of a package.json, review the [package.json file of cordova-plugin-device](https://github.com/apache/cordova-plugin-device/blob/master/package.json).
 
+### Specifying Cordova Dependencies
+
+**Cordova 6.1.0** added support for specifying the Cordova-related dependencies of a plugin
+as part of the plugin's `package.json` file. Plugins may list the dependencies for multiple
+releases so as to provide guidance to the Cordova CLI when it is selecting the version of a
+plugin to fetch from npm. The CLI will choose the latest release of a plugin that is
+compatible with the local project's installed platforms and plugins as well as the
+the local Cordova CLI version. If no releases of the plugin are compatible, the CLI will warn
+the user about the failed requirements and fall back to the old behavior of fetching the
+latest release.
+
+Listing dependencies is a good way to ensure that your plugin will not appear broken or cause
+build errors when fetched from npm. If the latest release of the plugin is not compatible with
+a project, the CLI will give the app developer a list of unmet project requirements so that
+they are aware of incompatibilites and can update their project to support your plugin. This
+allows your plugin to respond to breaking changes without fear of confusing devlopers who
+are building against old platforms and plugins.
+
+To specify Cordova-related dependencies for a plugin, alter the `engines` element in
+`package.json` to include a `cordovaDependencies` object using the following
+structure:
+
+```javascript
+engines: {
+    cordovaDependencies: {
+        PLUGIN_VERSION: {
+            DEPENDENCY: SEMVER_RANGE,
+            DEPENDENCY: SEMVER_RANGE,
+            ...
+        },
+        ...
+    }
+}
+```
+
+* `PLUGIN_VERSION` specifies a version of your plugin. It should adhere the syntax for a single version as defined by [npm's semver package][npm-semver] or an upper bound (see [below](#upper-bounds))
+* `DEPENDENCY` may be one of the following:
+    * The Cordova CLI, `"cordova"`
+    * A Cordova platform (e.g. `"cordova-android"`, `"cordova-ios"`, `"cordova-windows"`, etc.)
+    * Another Cordova plugin (e.g. `"cordova-plugin-camera"`, etc.)
+* `SEMVER_RANGE` should adhere to the syntax for a range as defined by [npm's semver package][npm-semver]
+
+**NOTE:** A Cordova platform `DEPENDENCY` refers to the Cordova platform and not
+the OS (i.e. `cordova-android` rather than the Android OS)
+
+Your `cordovaDependencies` may list any number of `PLUGIN_VERSION` requirements
+and any number of `DEPENDENCY` constraints within them. Versions of your plugin
+that do not have their dependencies listed will be assumed to have the same
+dependency information as the highest `PLUGIN_VERSION` listed below them. For
+example, consider the following entry:
+
+```javascript
+engines: {
+    cordovaDependencies: {
+        "1.0.0": { "cordova-android": "<3.0.0"},
+        "2.1.0": { "cordova-android": ">4.0.0"}
+    }
+}
+```
+All plugin versions below the lowest entry (1.0.0 in this example) are assumed
+to have no dependencies. Any version of the plugin between 1.0.0 and 2.1.0 is
+assumed to have the same dependencies as version 1.0.0 (a cordova-android
+version less than 3.0.0). This lets you only update your `cordovaDependencies`
+information when there are breaking changes.
+
+#### Upper Bounds
+
+In addition to a single version, a `PLUGIN_VERSION` in `cordovaDependencies`
+may also specify an upper bound to amend entries for older releases
+of your plugin. This is useful when a breaking change occurs in a `DEPENDENCY`
+and a new constraint must be added for all older versions of a plugin that do
+not support it. These bounds should be written as, a `<` followed by a single
+[semver][npm-semver] version (**Not an arbitrary range!**). This will apply
+whatever `DEPENDENCY` values are given to all versions of the plugin below the
+specified version. For example, consider the following entry:
+
+```javascript
+engines: {
+    cordovaDependencies: {
+        "0.0.1":  { "cordova-ios": ">1.0.0" },
+        "<1.0.0": { "cordova-ios": "<2.0.0" },
+        "<2.0.0": { "cordova-ios": "<5.0.0" }
+    }
+}
+```
+
+Here we specify one plugin version (0.0.1) and two upper bounds (<1.0.0 and <2.0.0)
+that constrain cordova-ios. The two upper bounds do not override the constraint
+of 0.0.1, they are combined via AND at evaluation time. When the CLI checks the
+cordova-ios version of the project, the constraint that will be evaluated for
+plugin version 0.0.1 will be the combination of these three:
+
+```
+    cordova-ios >1.0.0 AND cordova-ios <2.0.0 AND cordova-ios <5.0.0
+```
+
+Please note that the only `PLUGIN_VERSION` values allowed are single versions or
+upper bounds; no other semver ranges are supported.
+
 [cdv_plugin]: ../../../reference/cordova-cli/index.html#cordova-plugin-command
+[npm-semver]: https://www.npmjs.com/package/semver


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[2/2] docs commit: CB-10679: Adding blog post for plugin version selection docs

Posted by rk...@apache.org.
CB-10679: Adding blog post for plugin version selection docs

This closes #559


Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/b2230079
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/b2230079
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/b2230079

Branch: refs/heads/master
Commit: b2230079045a6dde3363b562de243ca202561c23
Parents: 3def9d4
Author: Richard Knoll <ri...@gmail.com>
Authored: Wed Mar 16 11:13:13 2016 -0700
Committer: Richard Knoll <ri...@gmail.com>
Committed: Tue Mar 22 13:43:54 2016 -0700

----------------------------------------------------------------------
 www/_posts/2016-03-22-new-plugin-fetching.md  | 46 ++++++++++++++++++++++
 www/docs/en/dev/guide/hybrid/plugins/index.md |  1 +
 2 files changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/b2230079/www/_posts/2016-03-22-new-plugin-fetching.md
----------------------------------------------------------------------
diff --git a/www/_posts/2016-03-22-new-plugin-fetching.md b/www/_posts/2016-03-22-new-plugin-fetching.md
new file mode 100644
index 0000000..84dc0c7
--- /dev/null
+++ b/www/_posts/2016-03-22-new-plugin-fetching.md
@@ -0,0 +1,46 @@
+---
+layout: post
+author:
+    name: Richard Knoll
+    url: https://github.com/riknoll
+title:  "Upcoming Changes to Plugin Fetching"
+categories: announcements
+tags: news
+---
+
+The Cordova 6.0.0 release introduced the pinning of core plugin
+versions in cordova-lib.
+
+We are happy to announce that one of the new features in the upcoming
+Cordova 6.1.0 release is a general API that allows any plugin to guide
+the CLI in choosing a compatible plugin release to fetch for a given project.
+This moves the plugin dependency information out of cordova-lib so that it
+can update independently of the Cordova tools and support third-party plugins
+outside of core. Our hope is that this feature will improve Cordova's plugin
+ecosystem and reduce some of the frustration that Cordova developers face when
+adding a new plugin to a project.
+
+<!--more-->
+
+The new API allows for plugin developers to give a mapping of plugin
+releases to project requirements in their `package.json`. When an app developer
+adds a plugin to their Cordova project, cordova-lib will examine their
+installed plugins, platforms, and cordova-lib version and decide which
+version of the plugin to fetch based on the provided mapping.
+If the project does not fulfill the requirements for the latest release of the
+plugin, the CLI will print warnings indicating the problems and fetch the
+latest release of the plugin that is compatible.
+
+This API will eventually replace the [engines element](http://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#engines-and-engine) in `plugin.xml`.
+It extends that element's capabilities by allowing the CLI to intelligently
+select a compatible plugin release rather than failing abruptly. Printed warnings
+still clearly tell the app developer that the version they are using
+is not latest and show what they must update to fulfill the latest release's
+requirements. Implementing this API helps you prevent your plugin from causing
+unexpected build errors when added to a project.
+
+See the [documentation](http://cordova.apache.org/docs/en/latest/guide/hybrid/plugins/index.html#specifying-cordova-dependencies)
+for more information about how to use this API in your plugin.
+
+If you have feedback or questions about this feature, please leave
+a comment on this post.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/b2230079/www/docs/en/dev/guide/hybrid/plugins/index.md
----------------------------------------------------------------------
diff --git a/www/docs/en/dev/guide/hybrid/plugins/index.md b/www/docs/en/dev/guide/hybrid/plugins/index.md
index d8b2712..ec6191f 100644
--- a/www/docs/en/dev/guide/hybrid/plugins/index.md
+++ b/www/docs/en/dev/guide/hybrid/plugins/index.md
@@ -256,6 +256,7 @@ the local Cordova CLI version. If no releases of the plugin are compatible, the
 the user about the failed requirements and fall back to the old behavior of fetching the
 latest release.
 
+This feature is intended to eventually replace the [engines element](../../../plugin_ref/spec.html#engines-and-engine) in plugin.xml.
 Listing dependencies is a good way to ensure that your plugin will not appear broken or cause
 build errors when fetched from npm. If the latest release of the plugin is not compatible with
 a project, the CLI will give the app developer a list of unmet project requirements so that


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org