You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2016/03/19 01:56:48 UTC

[01/37] cordova-lib git commit: CB-10626 Incremented cordova-common package version to -dev

Repository: cordova-lib
Updated Branches:
  refs/heads/common-1.1.x d5b101e1b -> 80b70040b
  refs/heads/master 9c7dead50 -> 9f630271d


CB-10626 Incremented cordova-common package version to -dev


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

Branch: refs/heads/common-1.1.x
Commit: 69178cf8b6219a7279b520d7d10dddb0272b9e4f
Parents: d5b101e
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Tue Feb 16 12:46:42 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Tue Feb 16 12:47:19 2016 +0300

----------------------------------------------------------------------
 cordova-common/package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/69178cf8/cordova-common/package.json
----------------------------------------------------------------------
diff --git a/cordova-common/package.json b/cordova-common/package.json
index 6c8a2d3..e84b6a5 100644
--- a/cordova-common/package.json
+++ b/cordova-common/package.json
@@ -3,7 +3,7 @@
   "name": "cordova-common",
   "description": "Apache Cordova tools and platforms shared routines",
   "license": "Apache-2.0",
-  "version": "1.1.0",
+  "version": "1.2.0-dev",
   "repository": {
     "type": "git",
     "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"


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


[25/37] cordova-lib git commit: CB-10808 CLI Support templates with subdirectory

Posted by st...@apache.org.
CB-10808 CLI Support templates with subdirectory

 This closes #410


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

Branch: refs/heads/common-1.1.x
Commit: 07354885e62b4c1c48577e9ed878e8c45193443c
Parents: d779242
Author: Carlos Santana <cs...@gmail.com>
Authored: Mon Mar 14 12:17:58 2016 -0400
Committer: Carlos Santana <cs...@gmail.com>
Committed: Tue Mar 15 16:58:13 2016 -0400

----------------------------------------------------------------------
 cordova-lib/spec-cordova/create.spec.js         | 105 +++++++++++++++++--
 .../templates/nopackage_json/config.xml         |  45 ++++++++
 .../templates/nopackage_json/www/index.html     |  49 +++++++++
 .../templates/withpackage_json/config.xml       |  45 ++++++++
 .../templates/withpackage_json/pacakge.json     |  14 +++
 .../templates/withpackage_json/www/index.html   |  49 +++++++++
 .../templates/withsubdirectory/index.js         |   4 +
 .../templates/withsubdirectory/package.json     |  11 ++
 .../withsubdirectory/template/config.xml        |  45 ++++++++
 .../withsubdirectory/template/www/index.html    |  49 +++++++++
 .../withsubdirectory_package_json/index.js      |   4 +
 .../withsubdirectory_package_json/package.json  |  11 ++
 .../template/config.xml                         |  45 ++++++++
 .../template/package.json                       |  10 ++
 .../template/www/index.html                     |  49 +++++++++
 cordova-lib/src/cordova/create.js               |  23 +++-
 16 files changed, 550 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/create.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/create.spec.js b/cordova-lib/spec-cordova/create.spec.js
index 1f4be51..99579a2 100644
--- a/cordova-lib/spec-cordova/create.spec.js
+++ b/cordova-lib/spec-cordova/create.spec.js
@@ -35,8 +35,7 @@ var configNormal = {
       lib: {
         www: {
           url: path.join(__dirname, 'fixtures', 'base', 'www'),
-          version: 'testCordovaCreate',
-          id: appName
+          version: 'testCordovaCreate'
         }
       }
     };
@@ -54,8 +53,7 @@ var configGit = {
         www: {
             url: 'https://github.com/apache/cordova-app-hello-world',
             template: true,
-            version: 'not_versioned',
-            id: appName
+            version: 'not_versioned'
         }
     }
 };
@@ -65,8 +63,7 @@ var configNPM = {
         www: {
             template: true,
             url: 'cordova-app-hello-world',
-            version: '',
-            id: appName
+            version: ''
         }
     }
 };
@@ -194,6 +191,102 @@ describe('create end-to-end', function() {
             })
             .fin(done);
     });
+    
+    it('should successfully run with template not having a package.json at toplevel', function(done) {
+        // Call cordova create with no args, should return help.
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 'nopackage_json'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                // Create a real project
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkProject)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
+    
+    it('should successfully run with template having package.json and no sub directory', function(done) {
+        // Call cordova create with no args, should return help.
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 'withpackage_json'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                // Create a real project
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkProject)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
+    
+    it('should successfully run with template having package.json, and subdirectory, and no package.json in subdirectory', function(done) {
+        // Call cordova create with no args, should return help.
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 'withsubdirectory'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                // Create a real project
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkProject)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
+    
+    it('should successfully run with template having package.json, and subdirectory, and package.json in subdirectory', function(done) {
+        // Call cordova create with no args, should return help.
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 'withsubdirectory_package_json'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                // Create a real project
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkProject)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
 
 
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/config.xml b/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/config.xml
new file mode 100644
index 0000000..02e616c
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/config.xml
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+    <name>HelloCordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html -->
+    <plugin name="cordova-plugin-whitelist" spec="1" />
+    <access origin="*" />
+    <allow-intent href="http://*/*" />
+    <allow-intent href="https://*/*" />
+    <allow-intent href="tel:*" />
+    <allow-intent href="sms:*" />
+    <allow-intent href="mailto:*" />
+    <allow-intent href="geo:*" />
+    <platform name="android">
+        <allow-intent href="market:*" />
+    </platform>
+    <platform name="ios">
+        <allow-intent href="itms:*" />
+        <allow-intent href="itms-apps:*" />
+    </platform>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/www/index.html b/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/www/index.html
new file mode 100644
index 0000000..646f9cb
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/www/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<html>
+    <head>
+        <!--
+        Customize this policy to fit your own app's needs. For more guidance, see:
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
+        Some notes:
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
+                * Enable inline JS: add 'unsafe-inline' to default-src
+        -->
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="msapplication-tap-highlight" content="no">
+        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
+        <link rel="stylesheet" type="text/css" href="css/index.css">
+        <title>Hello World</title>
+    </head>
+    <body>
+        <div class="app">
+            <h1>Apache Cordova</h1>
+            <div id="deviceready" class="blink">
+                <p class="event listening">Connecting to Device</p>
+                <p class="event received">Device is Ready</p>
+            </div>
+        </div>
+        <script type="text/javascript" src="cordova.js"></script>
+        <script type="text/javascript" src="js/index.js"></script>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/config.xml b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/config.xml
new file mode 100644
index 0000000..02e616c
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/config.xml
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+    <name>HelloCordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html -->
+    <plugin name="cordova-plugin-whitelist" spec="1" />
+    <access origin="*" />
+    <allow-intent href="http://*/*" />
+    <allow-intent href="https://*/*" />
+    <allow-intent href="tel:*" />
+    <allow-intent href="sms:*" />
+    <allow-intent href="mailto:*" />
+    <allow-intent href="geo:*" />
+    <platform name="android">
+        <allow-intent href="market:*" />
+    </platform>
+    <platform name="ios">
+        <allow-intent href="itms:*" />
+        <allow-intent href="itms-apps:*" />
+    </platform>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/pacakge.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/pacakge.json b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/pacakge.json
new file mode 100644
index 0000000..ef6f89e
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/pacakge.json
@@ -0,0 +1,14 @@
+{
+  "name": "template",
+  "version": "1.0.0",
+  "description": "Apache Cordova Application",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/cordova-app-hello-world.git"
+  },
+  "license": "Apache-2.0",
+  "scripts": {
+    "preinstall": "echo \"Yay npm preinstall script\" ",
+    "postinstall": "echo \"Yay npm postinstall script\" "
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/www/index.html b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/www/index.html
new file mode 100644
index 0000000..646f9cb
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/www/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<html>
+    <head>
+        <!--
+        Customize this policy to fit your own app's needs. For more guidance, see:
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
+        Some notes:
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
+                * Enable inline JS: add 'unsafe-inline' to default-src
+        -->
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="msapplication-tap-highlight" content="no">
+        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
+        <link rel="stylesheet" type="text/css" href="css/index.css">
+        <title>Hello World</title>
+    </head>
+    <body>
+        <div class="app">
+            <h1>Apache Cordova</h1>
+            <div id="deviceready" class="blink">
+                <p class="event listening">Connecting to Device</p>
+                <p class="event received">Device is Ready</p>
+            </div>
+        </div>
+        <script type="text/javascript" src="cordova.js"></script>
+        <script type="text/javascript" src="js/index.js"></script>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/index.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/index.js b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/index.js
new file mode 100644
index 0000000..4cb425b
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/index.js
@@ -0,0 +1,4 @@
+var path = require('path');
+module.exports = {
+  "dirname": path.join(__dirname, 'template')
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/package.json b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/package.json
new file mode 100644
index 0000000..51cbb55
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/package.json
@@ -0,0 +1,11 @@
+{
+  "name": "template",
+  "version": "1.0.0",
+  "description": "Apache Cordova Application",
+  "main": "index.js",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/cordova-app-hello-world.git"
+  },
+  "license": "Apache-2.0"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/config.xml b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/config.xml
new file mode 100644
index 0000000..02e616c
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/config.xml
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+    <name>HelloCordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html -->
+    <plugin name="cordova-plugin-whitelist" spec="1" />
+    <access origin="*" />
+    <allow-intent href="http://*/*" />
+    <allow-intent href="https://*/*" />
+    <allow-intent href="tel:*" />
+    <allow-intent href="sms:*" />
+    <allow-intent href="mailto:*" />
+    <allow-intent href="geo:*" />
+    <platform name="android">
+        <allow-intent href="market:*" />
+    </platform>
+    <platform name="ios">
+        <allow-intent href="itms:*" />
+        <allow-intent href="itms-apps:*" />
+    </platform>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/www/index.html b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/www/index.html
new file mode 100644
index 0000000..646f9cb
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/www/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<html>
+    <head>
+        <!--
+        Customize this policy to fit your own app's needs. For more guidance, see:
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
+        Some notes:
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
+                * Enable inline JS: add 'unsafe-inline' to default-src
+        -->
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="msapplication-tap-highlight" content="no">
+        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
+        <link rel="stylesheet" type="text/css" href="css/index.css">
+        <title>Hello World</title>
+    </head>
+    <body>
+        <div class="app">
+            <h1>Apache Cordova</h1>
+            <div id="deviceready" class="blink">
+                <p class="event listening">Connecting to Device</p>
+                <p class="event received">Device is Ready</p>
+            </div>
+        </div>
+        <script type="text/javascript" src="cordova.js"></script>
+        <script type="text/javascript" src="js/index.js"></script>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/index.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/index.js b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/index.js
new file mode 100644
index 0000000..4cb425b
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/index.js
@@ -0,0 +1,4 @@
+var path = require('path');
+module.exports = {
+  "dirname": path.join(__dirname, 'template')
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/package.json b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/package.json
new file mode 100644
index 0000000..51cbb55
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/package.json
@@ -0,0 +1,11 @@
+{
+  "name": "template",
+  "version": "1.0.0",
+  "description": "Apache Cordova Application",
+  "main": "index.js",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/cordova-app-hello-world.git"
+  },
+  "license": "Apache-2.0"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/config.xml b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/config.xml
new file mode 100644
index 0000000..02e616c
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/config.xml
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+    <name>HelloCordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html -->
+    <plugin name="cordova-plugin-whitelist" spec="1" />
+    <access origin="*" />
+    <allow-intent href="http://*/*" />
+    <allow-intent href="https://*/*" />
+    <allow-intent href="tel:*" />
+    <allow-intent href="sms:*" />
+    <allow-intent href="mailto:*" />
+    <allow-intent href="geo:*" />
+    <platform name="android">
+        <allow-intent href="market:*" />
+    </platform>
+    <platform name="ios">
+        <allow-intent href="itms:*" />
+        <allow-intent href="itms-apps:*" />
+    </platform>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/package.json b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/package.json
new file mode 100644
index 0000000..30a86ba
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/package.json
@@ -0,0 +1,10 @@
+{
+  "name": "template",
+  "version": "1.0.0",
+  "description": "Apache Cordova Application",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/cordova-app-hello-world.git"
+  },
+  "license": "Apache-2.0"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/www/index.html b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/www/index.html
new file mode 100644
index 0000000..646f9cb
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/www/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<html>
+    <head>
+        <!--
+        Customize this policy to fit your own app's needs. For more guidance, see:
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
+        Some notes:
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
+                * Enable inline JS: add 'unsafe-inline' to default-src
+        -->
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="msapplication-tap-highlight" content="no">
+        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
+        <link rel="stylesheet" type="text/css" href="css/index.css">
+        <title>Hello World</title>
+    </head>
+    <body>
+        <div class="app">
+            <h1>Apache Cordova</h1>
+            <div id="deviceready" class="blink">
+                <p class="event listening">Connecting to Device</p>
+                <p class="event received">Device is Ready</p>
+            </div>
+        </div>
+        <script type="text/javascript" src="cordova.js"></script>
+        <script type="text/javascript" src="js/index.js"></script>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index 5d8cef7..9150020 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -220,8 +220,19 @@ function create(dir, optionalId, optionalName, cfg) {
             }
         }
     })
-    .then(function(import_from_path) {
-
+    .then(function(input_directory) {
+        var import_from_path = input_directory;
+        
+        //handle when input wants to specify sub-directory 
+        try {
+            var templatePkg = require(input_directory);
+            if (templatePkg && templatePkg.dirname){
+                import_from_path = templatePkg.dirname;
+            }
+        } catch (e) {
+            events.emit('verbose', 'Can not load template package.json using directory ' + input_directory); 
+        }
+         
         if (!fs.existsSync(import_from_path)) {
             throw new CordovaError('Could not find directory: ' +
                 import_from_path);
@@ -361,5 +372,13 @@ function create(dir, optionalId, optionalName, cfg) {
         if (cfg.id) conf.setPackageName(cfg.id);
         if (cfg.name) conf.setName(cfg.name);
         conf.write();
+        
+        //run npm install if package.json is at the root of cordova project
+        if (fs.existsSync(path.join(dir,'package.json'))){
+            shell.pushd(dir);
+            events.emit('log', 'Executing npm install...');
+            shell.exec('npm install');
+            shell.popd();
+        }
     });
 }


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


[05/37] cordova-lib git commit: CB-10641 Run prepare _after_ plugins were installed

Posted by st...@apache.org.
CB-10641 Run prepare _after_ plugins were installed


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

Branch: refs/heads/common-1.1.x
Commit: 3b9face5187857d354d85f3e3f4316cbace100db
Parents: 5da4364
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Wed Feb 17 18:48:31 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Thu Feb 18 12:36:21 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/cordova/platform.js | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/3b9face5/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index 87f2e58..96c5f2f 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -180,18 +180,21 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) {
                     PlatformApi.createPlatform.bind(null, destination, cfg, options, events) :
                     PlatformApi.updatePlatform.bind(null, destination, options, events);
 
-                return promise().then(function () {
+                return promise()
+                .then(function() {
+                    if (cmd == 'add') {
+                        return installPluginsForNewPlatform(platform, projectRoot, opts);
+                    }
+                })
+                .then(function () {
                     // Call prepare for the current platform.
                     var prepOpts = {
                         platforms :[platform],
                         searchpath :opts.searchpath
                     };
                     return require('./cordova').raw.prepare(prepOpts);
-                }).then(function() {
-                    if (cmd == 'add') {
-                        return installPluginsForNewPlatform(platform, projectRoot, opts);
-                    }
-                }).then(function() {
+                })
+                .then(function() {
                     var saveVersion = !spec || semver.validRange(spec, true);
 
                     // Save platform@spec into platforms.json, where 'spec' is a version or a soure location. If a


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


[17/37] cordova-lib git commit: CB-10314 avoid fetching plugins when oldId is already fetched

Posted by st...@apache.org.
CB-10314 avoid fetching plugins when oldId is already fetched

This closes #396


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

Branch: refs/heads/common-1.1.x
Commit: 618eeca9583defa81054158ac456674fe5c5b1d0
Parents: 8f15136
Author: Byoungro So <by...@intel.com>
Authored: Sat Feb 20 21:48:13 2016 -0800
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Sat Mar 5 14:24:40 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/plugman/fetch.js   | 45 ++++++++++++++++++++++-----
 cordova-lib/src/plugman/install.js | 54 ++++++++++++++-------------------
 2 files changed, 60 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/618eeca9/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index 8a48626..a6f5eda 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -135,13 +135,33 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
             var splitVersion = plugin_src.split('@');
             var newID = pluginMapperotn[splitVersion[0]];
             if(newID) {
-                events.emit('warn', 'Notice: ' + splitVersion[0] + ' has been automatically converted to ' + newID + ' to be fetched from npm. This is due to our old plugins registry shutting down.');
                 plugin_src = newID;
                 if (splitVersion[1]) {
                     plugin_src += '@'+splitVersion[1];
                 }
-            } 
-            return registry.fetch([plugin_src])
+            }
+            var P, skipCopyingPlugin;
+            plugin_dir = path.join(plugins_dir, splitVersion[0]);
+            // if the plugin has already been fetched, use it.
+            if (fs.existsSync(plugin_dir)) {
+                P = Q(plugin_dir);
+                skipCopyingPlugin = true;
+            } else {
+                // if the plugin alias has already been fetched, use it.
+                var alias = pluginMappernto[splitVersion[0]] || newID;
+                if (alias && fs.existsSync(path.join(plugins_dir, alias))) {
+                    events.emit('warn', 'Found '+alias+' is already fetched. Skipped fetching '+splitVersion[0]);
+                    P = Q(path.join(plugins_dir, alias));
+                    skipCopyingPlugin = true;
+                } else {
+                    if (newID) {
+                        events.emit('warn', 'Notice: ' + splitVersion[0] + ' has been automatically converted to ' + newID + ' to be fetched from npm. This is due to our old plugins registry shutting down.');
+                    }
+                    P = registry.fetch([plugin_src]);
+                    skipCopyingPlugin = false;
+                }
+            }
+            return P
             .fail(function (error) {
                 var message = 'Failed to fetch plugin ' + plugin_src + ' via registry.' +
                     '\nProbably this is either a connection problem, or plugin spec is incorrect.' +
@@ -151,17 +171,23 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
             })
             .then(function(dir) {
                 return {
-                        pinfo: pluginInfoProvider.get(dir),
+                    pinfo: pluginInfoProvider.get(dir),
                     fetchJsonSource: {
                         type: 'registry',
                         id: plugin_src
-                    }
+                    },
+                    skipCopyingPlugin: skipCopyingPlugin
                 };
             });
         }).then(function(result) {
             options.plugin_src_dir = result.pinfo.dir;
-            return Q.when(copyPlugin(result.pinfo, plugins_dir, options.link && result.fetchJsonSource.type == 'local'))
-            .then(function(dir) {
+            var P;
+            if (result.skipCopyingPlugin) {
+                P = Q(options.plugin_src_dir);
+            } else {
+                P = Q.when(copyPlugin(result.pinfo, plugins_dir, options.link && result.fetchJsonSource.type == 'local'));
+            }
+            return P.then(function(dir) {
                 result.dest = dir;
                 return result;
             });
@@ -182,7 +208,10 @@ function checkID(expectedIdAndVersion, pinfo) {
     var expectedId = expectedIdAndVersion.split('@')[0];
     var expectedVersion = expectedIdAndVersion.split('@')[1];
     if (expectedId != pinfo.id) {
-        throw new Error('Expected plugin to have ID "' + expectedId + '" but got "' + pinfo.id + '".');
+        var alias = pluginMappernto[expectedId] || pluginMapperotn[expectedId];
+        if (alias !== pinfo.id) {
+            throw new Error('Expected plugin to have ID "' + expectedId + '" but got "' + pinfo.id + '".');
+        }
     }
     if (expectedVersion && !semver.satisfies(pinfo.version, expectedVersion)) {
         throw new Error('Expected plugin ' + pinfo.id + ' to satisfy version "' + expectedVersion + '" but got "' + pinfo.version + '".');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/618eeca9/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index ff02f1c..a7e793f 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -36,7 +36,7 @@ var path = require('path'),
     plugman = require('./plugman'),
     HooksRunner = require('../hooks/HooksRunner'),
     isWindows = (os.platform().substr(0,3) === 'win'),
-    pluginMapper = require('cordova-registry-mapper').oldToNew,
+    pluginMapper = require('cordova-registry-mapper'),
     cordovaUtil = require('../cordova/util');
 
 var superspawn = require('cordova-common').superspawn;
@@ -79,43 +79,50 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
     }
 
     var current_stack = new action_stack();
+    return possiblyFetch(id, plugins_dir, options)
+    .then(function(plugin_dir) {
+        return runInstall(current_stack, platform, project_dir, plugin_dir, plugins_dir, options);
+    });
+};
 
+// possible options: subdir, cli_variables, www_dir, git_ref, is_top_level
+// Returns a promise.
+function possiblyFetch(id, plugins_dir, options) {
     // Split @Version from the plugin id if it exists.
     var splitVersion = id.split('@');
     //Check if a mapping exists for the plugin id
     //if it does, convert id to new name id
-    var newId = pluginMapper[splitVersion[0]];
+    var newId = pluginMapper.oldToNew[splitVersion[0]];
     if(newId) {
-        events.emit('warn', 'Notice: ' + id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
         if(splitVersion[1]) {
             id = newId +'@'+splitVersion[1];
         } else {
             id = newId;
         }
-     }
-    return possiblyFetch(id, plugins_dir, options)
-    .then(function(plugin_dir) {
-        return runInstall(current_stack, platform, project_dir, plugin_dir, plugins_dir, options);
-    });
-};
-
-// possible options: subdir, cli_variables, www_dir, git_ref, is_top_level
-// Returns a promise.
-function possiblyFetch(id, plugins_dir, options) {
-
+    }
     // if plugin is a relative path, check if it already exists
-    var plugin_src_dir = isAbsolutePath(id) ? id : path.join(plugins_dir, id);
+    var plugin_src_dir = isAbsolutePath(id) ? id : path.join(plugins_dir, splitVersion[0]);
 
     // Check that the plugin has already been fetched.
     if (fs.existsSync(plugin_src_dir)) {
         return Q(plugin_src_dir);
     }
 
+    var alias = pluginMapper.newToOld[splitVersion[0]] || newId;
+    // if the plugin alias has already been fetched, use it.
+    if (alias && fs.existsSync(path.join(plugins_dir, alias))) {
+        events.emit('warn', 'Found ' + alias + ' is already fetched, so it is installed instead of '+splitVersion[0]);
+        return Q(path.join(plugins_dir, alias));
+    }
+
+    // if plugin doesnt exist, use fetch to get it.
+    if (newId) {
+        events.emit('warn', 'Notice: ' + splitVersion[0] + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
+    }
     var opts = underscore.extend({}, options, {
         client: 'plugman'
     });
 
-    // if plugin doesnt exist, use fetch to get it.
     return plugman.raw.fetch(id, plugins_dir, opts);
 }
 
@@ -291,7 +298,6 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
     var pluginInfoProvider = options.pluginInfoProvider;
     var pluginInfo   = pluginInfoProvider.get(plugin_dir);
     var filtered_variables = {};
-
     var platformJson = PlatformJson.load(plugins_dir, platform);
 
     if (platformJson.isPluginInstalled(pluginInfo.id)) {
@@ -432,20 +438,6 @@ function installDependencies(install, dependencies, options) {
     return dependencies.reduce(function(soFar, dep) {
         return soFar.then(
             function() {
-                // Split @Version from the plugin id if it exists.
-                var splitVersion = dep.id.split('@');
-                //Check if a mapping exists for the plugin id
-                //if it does, convert id to new name id
-                var newId = pluginMapper[splitVersion[0]];
-                if(newId) {
-                    events.emit('warn', 'Notice: ' + dep.id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
-                    if(splitVersion[1]) {
-                        dep.id = newId +'@'+splitVersion[1];
-                    } else {
-                        dep.id = newId;
-                    }
-                }
-
                 dep.git_ref = dep.commit;
 
                 if (dep.subdir) {


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


[34/37] cordova-lib git commit: CB-10902 Incremented package version to -dev

Posted by st...@apache.org.
CB-10902 Incremented package version to -dev


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

Branch: refs/heads/common-1.1.x
Commit: 9c7dead50a5a32ff2910903b5d6da6ec96844944
Parents: 31b58d0
Author: Steve Gill <st...@gmail.com>
Authored: Fri Mar 18 12:51:50 2016 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Mar 18 12:51:50 2016 -0700

----------------------------------------------------------------------
 cordova-lib/package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9c7dead5/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 193c226..50dc8f5 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -2,7 +2,7 @@
   "author": "Apache Software Foundation",
   "name": "cordova-lib",
   "description": "Apache Cordova tools core lib and API",
-  "version": "6.1.0",
+  "version": "6.1.1-dev",
   "repository": {
     "type": "git",
     "url": "git://git-wip-us.apache.org/repos/asf/cordova-lib.git"


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


[09/37] cordova-lib git commit: CB-10644 Adds deprecation message about old platforms support removal. This closes #394

Posted by st...@apache.org.
CB-10644 Adds deprecation message about old platforms support removal. This closes #394


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

Branch: refs/heads/common-1.1.x
Commit: 96cd416df9edbb9e6a41307a15721282e24fc9fa
Parents: 3cef082
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Fri Jan 22 14:22:35 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Wed Feb 24 22:26:04 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/platforms/platforms.js         | 10 ++++++++--
 cordova-lib/src/platforms/platformsConfig.json |  4 ++++
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/96cd416d/cordova-lib/src/platforms/platforms.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/platforms/platforms.js b/cordova-lib/src/platforms/platforms.js
index a932267..2f8ab7c 100644
--- a/cordova-lib/src/platforms/platforms.js
+++ b/cordova-lib/src/platforms/platforms.js
@@ -48,11 +48,17 @@ function getPlatformApi(platform, platformRootDir) {
     var PlatformApi;
     try {
         // First we need to find whether platform exposes its' API via js module
-        // If it has, then we have to require it and extend BasePlatformApi
-        // with platform's API.
+        // If it does, then we require and instantiate it.
         var platformApiModule = path.join(platformRootDir, 'cordova', 'Api.js');
         PlatformApi = require(platformApiModule);
     } catch (err) {
+        // Check if platform already compatible w/ PlatformApi and show deprecation warning
+        if (err && err.code === 'MODULE_NOT_FOUND' && platforms[platform].apiCompatibleSince) {
+            events.emit('warn', ' Using this version of Cordova with older version of cordova-' + platform +
+                ' is being deprecated. Consider upgrading to cordova-' + platform + '@' +
+                platforms[platform].apiCompatibleSince + ' or newer.');
+        }
+
         PlatformApi = require('./PlatformApiPoly');
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/96cd416d/cordova-lib/src/platforms/platformsConfig.json
----------------------------------------------------------------------
diff --git a/cordova-lib/src/platforms/platformsConfig.json b/cordova-lib/src/platforms/platformsConfig.json
index ff5c3d3..8b4a649 100644
--- a/cordova-lib/src/platforms/platformsConfig.json
+++ b/cordova-lib/src/platforms/platformsConfig.json
@@ -5,6 +5,7 @@
         "handler_file": "../plugman/platforms/ios",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git",
         "version": "~4.0.1",
+        "apiCompatibleSince": "4.0.0",
         "deprecated": false
     },
     "osx": {
@@ -13,6 +14,7 @@
         "handler_file": "../plugman/platforms/ios",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-osx.git",
         "version": "~4.0.0",
+        "apiCompatibleSince": "4.0.0",
         "deprecated": false
     },
     "android": {
@@ -20,6 +22,7 @@
         "handler_file": "../plugman/platforms/android",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git",
         "version": "~5.1.0",
+        "apiCompatibleSince": "5.0.0",
         "deprecated": false
     },
     "ubuntu": {
@@ -73,6 +76,7 @@
         "handler_file": "../plugman/platforms/windows",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git",
         "version": "~4.3.0",
+        "apiCompatibleSince": "4.3.0",
         "deprecated": false
     },
     "webos": {


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


[18/37] cordova-lib git commit: CB-10328 set top-level property when adding new platforms

Posted by st...@apache.org.
CB-10328 set top-level property when adding new platforms

This closes #402


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

Branch: refs/heads/common-1.1.x
Commit: 114de6cd532e2218c1b302ae61bf8e3f50ec749d
Parents: 618eeca
Author: Byoungro So <by...@intel.com>
Authored: Fri Mar 4 18:51:43 2016 -0800
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Sat Mar 5 14:50:39 2016 +0300

----------------------------------------------------------------------
 cordova-lib/spec-cordova/platform.spec.js | 47 ++++++++++++++++++++++++++
 cordova-lib/src/cordova/platform.js       |  8 +++--
 cordova-lib/src/plugman/install.js        |  3 +-
 3 files changed, 54 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/114de6cd/cordova-lib/spec-cordova/platform.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/platform.spec.js b/cordova-lib/spec-cordova/platform.spec.js
index 2c99b4a..a35216f 100644
--- a/cordova-lib/spec-cordova/platform.spec.js
+++ b/cordova-lib/spec-cordova/platform.spec.js
@@ -201,3 +201,50 @@ describe('add function', function () {
         });
     });
 });
+
+describe('platform add plugin rm end-to-end', function () {
+
+    var tmpDir = helpers.tmpDir('plugin_rm_test');
+    var project = path.join(tmpDir, 'hello');
+    var pluginsDir = path.join(project, 'plugins');
+    
+    beforeEach(function() {
+        process.chdir(tmpDir);
+    });
+    
+    afterEach(function() {
+        process.chdir(path.join(__dirname, '..'));  // Needed to rm the dir on Windows.
+        shell.rm('-rf', tmpDir);
+    });
+
+    it('should remove dependency when removing parent plugin', function(done) {
+        
+        cordova.raw.create('hello')
+        .then(function() {
+            process.chdir(project);
+            return cordova.raw.platform('add', 'ios');
+        })
+        .then(function() {
+            return cordova.raw.plugin('add', 'cordova-plugin-media');
+        })
+        .then(function() {
+            expect(path.join(pluginsDir, 'cordova-plugin-media')).toExist();
+            expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist();
+            return cordova.raw.platform('add', 'android');
+        })
+        .then(function() {
+            expect(path.join(pluginsDir, 'cordova-plugin-media')).toExist();
+            expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist();
+            return cordova.raw.plugin('rm', 'cordova-plugin-media');
+        })
+        .then(function() {
+            expect(path.join(pluginsDir, 'cordova-plugin-media')).not.toExist();
+            expect(path.join(pluginsDir, 'cordova-plugin-file')).not.toExist();
+        })
+        .fail(function(err) {
+            console.error(err);
+            expect(err).toBeUndefined();
+        })
+        .fin(done);
+    }, 20000);
+});

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/114de6cd/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index 2dff594..d130772 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -644,6 +644,9 @@ function installPluginsForNewPlatform(platform, projectRoot, opts) {
             events.emit('verbose', 'Installing plugin "' + plugin + '" following successful platform add of ' + platform);
             plugin = path.basename(plugin);
 
+            // Get plugin variables from fetch.json if have any and pass them as cli_variables to plugman
+            var pluginMetadata = fetchMetadata.get_fetch_metadata(path.join(plugins_dir, plugin));
+
             var options = {
                 searchpath: opts.searchpath,
                 // Set up platform to install asset files/js modules to <platform>/platform_www dir
@@ -654,11 +657,10 @@ function installPluginsForNewPlatform(platform, projectRoot, opts) {
                 // NOTE: there is another code path for plugin installation (see CB-10274 and the
                 // related PR: https://github.com/apache/cordova-lib/pull/360) so we need to
                 // specify the option below in both places
-                usePlatformWww: true
+                usePlatformWww: true,
+                is_top_level: pluginMetadata.is_top_level
             };
 
-            // Get plugin variables from fetch.json if have any and pass them as cli_variables to plugman
-            var pluginMetadata = fetchMetadata.get_fetch_metadata(path.join(plugins_dir, plugin));
             var variables = pluginMetadata && pluginMetadata.variables;
             if (variables) {
                 events.emit('verbose', 'Found variables for "' + plugin + '". Processing as cli_variables.');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/114de6cd/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index a7e793f..c0a12c1 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -71,7 +71,8 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
     project_dir = cordovaUtil.convertToRealPathSafe(project_dir);
     plugins_dir = cordovaUtil.convertToRealPathSafe(plugins_dir);
     options = options || {};
-    options.is_top_level = true;
+    if (!options.hasOwnProperty('is_top_level')) options.is_top_level = true;
+    
     plugins_dir = plugins_dir || path.join(project_dir, 'cordova', 'plugins');
 
     if (!platform_modules[platform]) {


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


[32/37] cordova-lib git commit: CB-10902 Updated version and RELEASENOTES.md for release 6.1.0

Posted by st...@apache.org.
CB-10902 Updated version and RELEASENOTES.md for release 6.1.0


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

Branch: refs/heads/common-1.1.x
Commit: f0d5a3e8c7722203db3fa3c5af75cce85f09d166
Parents: 3502274
Author: Steve Gill <st...@gmail.com>
Authored: Thu Mar 17 19:31:11 2016 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Thu Mar 17 19:31:11 2016 -0700

----------------------------------------------------------------------
 cordova-lib/RELEASENOTES.md | 35 +++++++++++++++++++++++++++++++++++
 cordova-lib/package.json    |  4 ++--
 2 files changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/f0d5a3e8/cordova-lib/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/cordova-lib/RELEASENOTES.md b/cordova-lib/RELEASENOTES.md
index 0c89745..a08eadb 100644
--- a/cordova-lib/RELEASENOTES.md
+++ b/cordova-lib/RELEASENOTES.md
@@ -20,6 +20,41 @@
 -->
 # Cordova-lib Release Notes
 
+### 6.1.0 (Mar 17, 2016)
+* CB-10902 updated pinned platforms
+* CB-10808 revert npm install for templates
+* CB-10808 CLI Support templates with subdirectory
+* CB-10880 Removed plugin pinning
+* CB-10679 Improving version choosing logic test coverage
+* CB-10673 add plugin `--force` option. 
+* CB-10679 New version choosing logic for plugin add
+* CB-10328 set top-level property when adding new platforms
+* CB-10314 avoid fetching plugins when oldId is already fetched
+* CB-10708 Install/uninstall plugins correctly into CLI project using plugman
+* CB-10462 Get rid of npmconf in favor of npm.
+* CB-10662 Use project's `config.xml` as a fallback for package name
+* CB-10644 Adds deprecation message about old platforms support removal.
+* CB-10519 Wrap all sync calls inside of `cordova.raw` methods into promises
+* CB-10641 Adds tests for order of operations in platform add
+* CB-10641 Run prepare `_after_` plugins were installed
+* CB-10618 Do not call `prepBuildFiles` for `cordova-android@>=5.2.0`.
+* CB-10518 Correct log level and error messages for some cordova errors
+* CB-10550 Fix plugin id mapper not enforced when a version is specified
+* CB-10611 fix `before_plugin_install` hook not disabled with `--nohooks`
+* CB-10235 Added clearer error message for info command.
+* CB-10584 Splashscreen plugin crashes the app on windows 10 when built with browserify
+* CB-10592 Don't quote platform specific args values
+* CB-10482 Remove references to **windows8** from cordova-lib/cli
+* CB-10567 Bubble up `cordova.raw.run()` error to the caller
+* CB-10553 Fix framework tag handler for **Android**
+* CB-10461 `cordova platform ls` should list the versions of platforms pinned
+* CB-10531 Enable coverage reports for cordova-lib
+* CB-10465 Pass correct options to prepare from compile
+* CB-10459 cordova platform list should mark amazon-fireos and wp8 as deprecated
+* CB-10499 `--template` should pull the latest template from npm when version isn't specified
+* CB-10432 Adds e2e test to protect against future regressions.
+* Added node versions matrix to `.travis.yml`.
+
 ### 6.0.0 (Jan 25, 2016)
 * CB-10432 Fix plugin installation for newly added platform
 * CB-10423 allow recursive folder copy skipping whatever .. was

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/f0d5a3e8/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 3e0fadb..73638bb 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -2,7 +2,7 @@
   "author": "Apache Software Foundation",
   "name": "cordova-lib",
   "description": "Apache Cordova tools core lib and API",
-  "version": "6.0.1-dev",
+  "version": "6.1.0",
   "repository": {
     "type": "git",
     "url": "git://git-wip-us.apache.org/repos/asf/cordova-lib.git"
@@ -20,7 +20,7 @@
     "aliasify": "^1.7.2",
     "cordova-app-hello-world": "3.10.0",
     "cordova-common": "1.0.x",
-    "cordova-js": "4.1.3",
+    "cordova-js": "4.1.4",
     "cordova-registry-mapper": "1.x",
     "cordova-serve": "^1.0.0",
     "dep-graph": "1.1.0",


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


[28/37] cordova-lib git commit: CB-9264 - Duplicate entries in config.xml

Posted by st...@apache.org.
CB-9264 - Duplicate entries in config.xml


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

Branch: refs/heads/common-1.1.x
Commit: cc9165647197e63de43bab0335d4f8fcd07f9858
Parents: 186eea0
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Mar 16 14:02:46 2016 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Mar 16 14:02:46 2016 -0700

----------------------------------------------------------------------
 cordova-common/spec/util/xml-helpers.spec.js | 22 ++++++++++++++++++++++
 cordova-common/src/util/xml-helpers.js       | 23 +++++++++++++++++++++++
 2 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cc916564/cordova-common/spec/util/xml-helpers.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/util/xml-helpers.spec.js b/cordova-common/spec/util/xml-helpers.spec.js
index 8cc46ca..9d714f0 100644
--- a/cordova-common/spec/util/xml-helpers.spec.js
+++ b/cordova-common/spec/util/xml-helpers.spec.js
@@ -267,5 +267,27 @@ describe('xml-helpers', function(){
             expect(testElements.length).toEqual(2);
 
         });
+        
+        it('should remove duplicate preferences (by name attribute value)', function () {
+            var testXml = et.XML(
+                '<?xml version="1.0" encoding="UTF-8"?>\n' +
+                '<widget xmlns     = "http://www.w3.org/ns/widgets"\n' +
+                '        xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
+                '        id        = "io.cordova.hellocordova"\n' +
+                '        version   = "0.0.1">\n' +
+                '    <preference name="Orientation" value="default" />\n' +
+                '    <preference name="Orientation" value="portrait" />\n' +
+                '    <preference name="Orientation" value="landscape" />\n' +
+                '    <platform name="ios">\n' +
+                '        <preference name="Orientation" value="all" />\n' +
+                '        <preference name="Orientation" value="portrait" />\n' +
+                '    </platform>\n' +
+                '</widget>\n'
+            );
+            xml_helpers.mergeXml(testXml, dstXml, 'ios');
+            var testElements = dstXml.findall('preference[@name="Orientation"]');
+            expect(testElements.length).toEqual(1);
+        });
+                
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cc916564/cordova-common/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/util/xml-helpers.js b/cordova-common/src/util/xml-helpers.js
index 8b02989..85d9799 100644
--- a/cordova-common/src/util/xml-helpers.js
+++ b/cordova-common/src/util/xml-helpers.js
@@ -218,6 +218,9 @@ function mergeXml(src, dest, platform, clobber) {
 
     //Handle children
     src.getchildren().forEach(mergeChild);
+    
+    //Handle duplicate preference tags (by name attribute)
+    removeDuplicatePreferences(dest);
 
     function mergeChild (srcChild) {
         var srcTag = srcChild.tag,
@@ -254,6 +257,26 @@ function mergeXml(src, dest, platform, clobber) {
             dest.append(destChild);
         }
     }
+    
+    function removeDuplicatePreferences(xml) {
+        // reduce preference tags to a hashtable to remove dupes
+        var prefHash = xml.findall('preference[@name][@value]').reduce(function(previousValue, currentValue) {
+            previousValue[ currentValue.attrib.name ] = currentValue.attrib.value;
+            return previousValue;
+        }, {});
+        
+        // remove all preferences
+        xml.findall('preference[@name][@value]').forEach(function(pref) {
+            xml.remove(pref);
+        });
+        
+        // write new preferences
+        Object.keys(prefHash).forEach(function(key, index) {
+            var element = et.SubElement(xml, 'preference');
+            element.set('name', key);
+            element.set('value', this[key]);
+        }, prefHash);
+    }
 }
 
 // Expose for testing.


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


[15/37] cordova-lib git commit: CB-10462 Get rid of npmconf in favor of npm. This closes #401

Posted by st...@apache.org.
CB-10462 Get rid of npmconf in favor of npm. This closes #401


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

Branch: refs/heads/common-1.1.x
Commit: 0aef8928e19cc32051fcda9afb66364022ab9c5f
Parents: cda2b72
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Fri Feb 26 14:20:14 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Sat Feb 27 12:38:51 2016 +0300

----------------------------------------------------------------------
 cordova-lib/package.json                   |  1 -
 cordova-lib/spec-cordova/lazy_load.spec.js | 12 +++++-------
 cordova-lib/src/cordova/lazy_load.js       |  9 ++++-----
 3 files changed, 9 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0aef8928/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 0be249d..1d452fa 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -53,7 +53,6 @@
     "init-package-json": "^1.2.0",
     "nopt": "^3.0.6",
     "npm": "^2.10.x",
-    "npmconf": "^2.1.x",
     "opener": "1.4.1",
     "plist": "^1.2.0",
     "properties-parser": "0.2.3",

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0aef8928/cordova-lib/spec-cordova/lazy_load.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/lazy_load.spec.js b/cordova-lib/spec-cordova/lazy_load.spec.js
index a986f27..410c99c 100644
--- a/cordova-lib/spec-cordova/lazy_load.spec.js
+++ b/cordova-lib/spec-cordova/lazy_load.spec.js
@@ -22,7 +22,7 @@
 var lazy_load = require('../src/cordova/lazy_load'),
     config = require('../src/cordova/config'),
     shell = require('shelljs'),
-    npmconf = require('npmconf'),
+    npm = require('npm'),
     path = require('path'),
     HooksRunner = require('../src/hooks/HooksRunner'),
     request = require('request'),
@@ -113,9 +113,7 @@ describe('lazy_load module', function() {
         });
 
         describe('remote URLs for libraries', function() {
-            var npmConfProxy;
             var req,
-                load_spy,
                 events = {},
                 fakeRequest = {
                     on: jasmine.createSpy().andCallFake(function(event, cb) {
@@ -125,7 +123,6 @@ describe('lazy_load module', function() {
                     pipe: jasmine.createSpy().andCallFake(function() { return fakeRequest; })
                 };
             beforeEach(function() {
-                npmConfProxy = null;
                 events = {};
                 fakeRequest.on.reset();
                 fakeRequest.pipe.reset();
@@ -136,7 +133,8 @@ describe('lazy_load module', function() {
                     }, 10);
                     return fakeRequest;
                 });
-                load_spy = spyOn(npmconf, 'load').andCallFake(function(cb) { cb(null, { get: function() { return npmConfProxy; }}); });
+                spyOn(npm, 'load').andCallFake(function(cb) { cb(); });
+                spyOn(npm.config, 'get').andReturn(null);
             });
 
             it('should call request with appropriate url params', function(done) {
@@ -158,7 +156,7 @@ describe('lazy_load module', function() {
             });
             it('should take into account https-proxy npm configuration var if exists for https:// calls', function(done) {
                 var proxy = 'https://somelocalproxy.com';
-                npmConfProxy = proxy;
+                npm.config.get.andReturn(proxy);
                 var url = 'https://github.com/apache/someplugin';
                 var with_android_platform = {
                     'android': {
@@ -178,7 +176,7 @@ describe('lazy_load module', function() {
             });
             it('should take into account proxy npm config var if exists for http:// calls', function(done) {
                 var proxy = 'http://somelocalproxy.com';
-                npmConfProxy = proxy;
+                npm.config.get.andReturn(proxy);
                 var url = 'http://github.com/apache/someplugin';
                 var with_android_platform = {
                     'android': {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0aef8928/cordova-lib/src/cordova/lazy_load.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/lazy_load.js b/cordova-lib/src/cordova/lazy_load.js
index 9079329..bdd01c9 100644
--- a/cordova-lib/src/cordova/lazy_load.js
+++ b/cordova-lib/src/cordova/lazy_load.js
@@ -25,7 +25,6 @@ var path          = require('path'),
     fs            = require('fs'),
     shell         = require('shelljs'),
     platforms     = require('../platforms/platforms'),
-    npmconf       = require('npmconf'),
     events        = require('cordova-common').events,
     request       = require('request'),
     config        = require('./config'),
@@ -216,15 +215,15 @@ function custom(platforms, platform) {
     }).then(function() {
         var uri = URL.parse(url);
         var d = Q.defer();
-        npmconf.load(function(err, conf) {
+        npm.load(function(err) {
             // Check if NPM proxy settings are set. If so, include them in the request() call.
             var proxy;
             if (uri.protocol == 'https:') {
-                proxy = conf.get('https-proxy');
+                proxy = npm.config.get('https-proxy');
             } else if (uri.protocol == 'http:') {
-                proxy = conf.get('proxy');
+                proxy = npm.config.get('proxy');
             }
-            var strictSSL = conf.get('strict-ssl');
+            var strictSSL = npm.config.get('strict-ssl');
 
             // Create a tmp dir. Using /tmp is a problem because it's often on a different partition and sehll.mv()
             // fails in this case with "EXDEV, cross-device link not permitted".


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


[13/37] cordova-lib git commit: CB-10622 fix target attribute being ignored for images in config.xml. This closes #392

Posted by st...@apache.org.
CB-10622 fix target attribute being ignored for images in config.xml. This closes #392


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

Branch: refs/heads/common-1.1.x
Commit: 84d4ea0c04b57e0907a9b68a1e9063792a95817b
Parents: 8a5bd8f
Author: Andor Polgari <an...@sap.com>
Authored: Tue Feb 16 11:17:27 2016 +0100
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Fri Feb 26 16:22:15 2016 +0300

----------------------------------------------------------------------
 cordova-common/src/ConfigParser/ConfigParser.js | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/84d4ea0c/cordova-common/src/ConfigParser/ConfigParser.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/ConfigParser/ConfigParser.js b/cordova-common/src/ConfigParser/ConfigParser.js
index 7abddf6..aae59db 100644
--- a/cordova-common/src/ConfigParser/ConfigParser.js
+++ b/cordova-common/src/ConfigParser/ConfigParser.js
@@ -186,6 +186,7 @@ ConfigParser.prototype = {
         staticResources.forEach(function (elt) {
             var res = {};
             res.src = elt.attrib.src;
+            res.target = elt.attrib.target || undefined;
             res.density = elt.attrib['density'] || elt.attrib[that.cdvNamespacePrefix+':density'] || elt.attrib['gap:density'];
             res.platform = elt.platform || null; // null means icon represents default icon (shared between platforms)
             res.width = +elt.attrib.width || undefined;


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


[20/37] cordova-lib git commit: CB-10673 add plugin --force option. This closes #404

Posted by st...@apache.org.
CB-10673 add plugin --force option. This closes #404


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

Branch: refs/heads/common-1.1.x
Commit: e1bde1afa0f22b783d3cecc5f7d14c39ab17528b
Parents: 45a235f
Author: Byoungro So <by...@intel.com>
Authored: Tue Mar 1 23:23:19 2016 -0800
Committer: Nikhil Khandelwal <ni...@microsoft.com>
Committed: Mon Mar 7 22:43:42 2016 -0800

----------------------------------------------------------------------
 cordova-lib/src/cordova/platform.js | 1 +
 cordova-lib/src/cordova/plugin.js   | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e1bde1af/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index 1b745be..9b1157e 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -654,6 +654,7 @@ function installPluginsForNewPlatform(platform, projectRoot, opts) {
                 // specify the option below in both places
                 usePlatformWww: true,
                 is_top_level: pluginMetadata.is_top_level
+                force: opts.force
             };
 
             var variables = pluginMetadata && pluginMetadata.variables;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e1bde1af/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index c5ead29..a5398a0 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -176,7 +176,8 @@ module.exports = function plugin(command, targets, opts) {
                                     // and files from 'platform_www' merged into 'www'. Thus we need to persist these
                                     // files platform_www directory, so they'll be applied to www on each prepare.
                                     usePlatformWww: true,
-                                    nohooks: opts.nohooks
+                                    nohooks: opts.nohooks,
+                                    force: opts.force
                                 };
 
                                 events.emit('verbose', 'Calling plugman.install on plugin "' + pluginInfo.dir + '" for platform "' + platform);


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


[21/37] cordova-lib git commit: Fix syntax error introduced in e1bde1

Posted by st...@apache.org.
Fix syntax error introduced in e1bde1


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

Branch: refs/heads/common-1.1.x
Commit: e740debffe6f83174126ba3c1711d017b3052d4f
Parents: e1bde1a
Author: Nikhil Khandelwal <ni...@microsoft.com>
Authored: Tue Mar 8 09:54:30 2016 -0800
Committer: Nikhil Khandelwal <ni...@microsoft.com>
Committed: Tue Mar 8 09:54:30 2016 -0800

----------------------------------------------------------------------
 cordova-lib/src/cordova/platform.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e740debf/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index 9b1157e..2ea8c01 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -653,7 +653,7 @@ function installPluginsForNewPlatform(platform, projectRoot, opts) {
                 // related PR: https://github.com/apache/cordova-lib/pull/360) so we need to
                 // specify the option below in both places
                 usePlatformWww: true,
-                is_top_level: pluginMetadata.is_top_level
+                is_top_level: pluginMetadata.is_top_level,
                 force: opts.force
             };
 


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


[26/37] cordova-lib git commit: CB-10808 revert npm install for templates

Posted by st...@apache.org.
CB-10808 revert npm install for templates


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

Branch: refs/heads/common-1.1.x
Commit: 186eea067d3d05f9e65ef89faf55c00b4cea9224
Parents: 0735488
Author: Carlos Santana <cs...@gmail.com>
Authored: Tue Mar 15 22:49:11 2016 -0400
Committer: Carlos Santana <cs...@gmail.com>
Committed: Tue Mar 15 22:49:11 2016 -0400

----------------------------------------------------------------------
 cordova-lib/src/cordova/create.js | 8 --------
 1 file changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/186eea06/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index 9150020..0960131 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -372,13 +372,5 @@ function create(dir, optionalId, optionalName, cfg) {
         if (cfg.id) conf.setPackageName(cfg.id);
         if (cfg.name) conf.setName(cfg.name);
         conf.write();
-        
-        //run npm install if package.json is at the root of cordova project
-        if (fs.existsSync(path.join(dir,'package.json'))){
-            shell.pushd(dir);
-            events.emit('log', 'Executing npm install...');
-            shell.exec('npm install');
-            shell.popd();
-        }
     });
 }


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


[16/37] cordova-lib git commit: CB-10708 Install/uninstall plugins correctly into CLI project using plugman

Posted by st...@apache.org.
CB-10708 Install/uninstall plugins correctly into CLI project using plugman


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

Branch: refs/heads/common-1.1.x
Commit: 8f15136e8892ee7f6d93b0249d2d0e9b26f9eb94
Parents: 0aef892
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Sat Feb 27 15:29:08 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Sat Feb 27 15:41:26 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/plugman/install.js   | 5 +++++
 cordova-lib/src/plugman/uninstall.js | 5 +++++
 2 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f15136e/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index 53f37ef..ff02f1c 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -385,6 +385,11 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
                     nohooks: options.nohooks
                 };
 
+                // CB-10708 This is the case when we're trying to install plugin using plugman to specific
+                // platform inside of the existing CLI project. In this case we need to put plugin's files
+                // into platform_www but plugman CLI doesn't allow us to do that, so we set it here
+                options.usePlatformWww = true;
+
                 var hooksRunner = new HooksRunner(projectRoot);
 
                 return hooksRunner.fire('before_plugin_install', hookOptions).then(function() {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8f15136e/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index bf136eb..f481950 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -303,6 +303,11 @@ function runUninstallPlatform(actions, platform, project_dir, plugin_dir, plugin
             }
         };
 
+        // CB-10708 This is the case when we're trying to uninstall plugin using plugman from specific
+        // platform inside of the existing CLI project. This option is usually set by cordova-lib for CLI projects
+        // but since we're running this code through plugman, we need to set it here implicitly
+        options.usePlatformWww = true;
+
         var hooksRunner = new HooksRunner(projectRoot);
 
         return promise.then(function() {


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


[12/37] cordova-lib git commit: Some corrections and enhancements for cordova-serve readme.

Posted by st...@apache.org.
Some corrections and enhancements for cordova-serve readme.


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

Branch: refs/heads/common-1.1.x
Commit: 8a5bd8f17577197e289f537563955aec9f99c9ce
Parents: d437ae1
Author: Tim Barham <ti...@microsoft.com>
Authored: Fri Feb 26 18:49:28 2016 +1000
Committer: Tim Barham <ti...@microsoft.com>
Committed: Fri Feb 26 18:49:28 2016 +1000

----------------------------------------------------------------------
 cordova-serve/README.md | 59 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 51 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8a5bd8f1/cordova-serve/README.md
----------------------------------------------------------------------
diff --git a/cordova-serve/README.md b/cordova-serve/README.md
index 4d45447..f2700af 100644
--- a/cordova-serve/README.md
+++ b/cordova-serve/README.md
@@ -24,26 +24,53 @@ This module can be used to serve up a Cordova application in the browser. It has
 to be called using the following API:
 
 ``` js
-var serve = require('cordova-serve');
-serve.launchServer(opts);
-serve.servePlatform(platform, opts);
-serve.launchBrowser(ops);
+var cordovaServe = require('cordova-serve')();
+cordovaServe.launchServer(opts);
+cordovaServe.servePlatform(platform, opts);
+cordovaServe.launchBrowser(ops);
 ```
 
 ## launchServer()
 
 ``` js
-launchServer(opts);
+var cordovaServe = require('cordova-serve')();
+cordovaServe.launchServer(opts).then(function () {
+    var server = cordovaServe.server;
+    var root = cordovaServe.root;
+    var port = cordovaServe.port;
+
+    ...
+}, function (error) {
+    console.log('An error occurred: ' + error);
+});
 ```
 
 Launches a server with the specified options. Parameters:
 
 * **opts**: Options, as described below.
 
+Returns a promise that is fulfilled once the server has launched, or rejected if the server fails to launch. Once the
+promise is fulfilled, the following properties are available on the `cordovaServe` object:
+ 
+ * **cordovaServe.serve**: The Node http.Server instance.
+ * **cordovaServe.root**: The root that was specified, or cwd if none specified.
+ * **cordovaServe.port**: The port that was used (could be the requested port, the default port, or some incremented
+   value if the chosen port was in use).
+
 ## servePlatform()
 
 ``` js
-servePlatform(platform, opts);
+var cordovaServe = require('cordova-serve')();
+cordovaServe.servePlatform(platform, opts).then(function () {
+    var server = cordovaServe.server;
+    var port = cordovaServe.port;
+    var projectRoot = cordovaServe.projectRoot;
+    var platformRoot = cordovaServe.root;
+
+    ...
+}, function (error) {
+    console.log('An error occurred: ' + error);
+});
 ```
 
 Launches a server that serves up any Cordova platform (e.g. `browser`, `android` etc) from the current project.
@@ -53,10 +80,24 @@ Parameters:
   root folder, or any folder within it - `servePlatform()` will replace it with the platform's `www_dir` folder. If this
   value is not specified, the *cwd* will be used.
 
+Returns a promise that is fulfilled once the server has launched, or rejected if the server fails to launch. Once the
+promise is fulfilled, the following properties are available on the `cordovaServe` object:
+ 
+ * **cordovaServe.serve**: The Node http.Server instance.
+ * **cordovaServe.root**: The requested platform's `www` folder.
+ * **cordovaServe.projectRoot**: The root folder of the Cordova project.
+ * **cordovaServe.port**: The port that was used (could be the requested port, the default port, or some incremented
+   value if the chosen port was in use).
+
 ## launchBrowser()
 
 ``` js
-launchBrowser(opts);
+var cordovaServe = require('cordova-serve')();
+cordovaServe.launchBrowser(opts).then(function (stdout) {
+    console.log('Browser was launched successfully: ' + stdout);
+}, function (error) {
+    console.log('An error occurred: ' + error);
+});
 ```
 
 Launches a browser window pointing to the specified URL. The single parameter is an options object that supports the
@@ -64,7 +105,9 @@ following values (both optional):
 
 * **url**: The URL to open in the browser.
 * **target**: The name of the browser to launch. Can be any of the following: `chrome`, `chromium`, `firefox`, `ie`,
-  `opera`, `safari`. If no browser is specified, 
+  `opera`, `safari`. Defaults to `chrome` if no browser is specified.
+
+Returns a promise that is fulfilled once the browser has been launched, or rejected if an error occurs.
 
 ## The *opts* Options Object
 The opts object passed to `launchServer()` and `servePlatform()` supports the following values (all optional):


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


[10/37] cordova-lib git commit: CB-10662 Use project's config.xml as a fallback for package name

Posted by st...@apache.org.
CB-10662 Use project's config.xml as a fallback for package name


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

Branch: refs/heads/common-1.1.x
Commit: bfea262310d7cad01f7d23725492703a11f1ba13
Parents: 96cd416
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Thu Feb 25 13:03:12 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Thu Feb 25 14:32:38 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/plugman/platforms/browser.js   | 22 +-------------
 cordova-lib/src/plugman/platforms/common.js    | 32 +++++++++++++++++++++
 cordova-lib/src/plugman/platforms/firefoxos.js | 22 +-------------
 cordova-lib/src/plugman/platforms/webos.js     | 22 +-------------
 4 files changed, 35 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/bfea2623/cordova-lib/src/plugman/platforms/browser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/browser.js b/cordova-lib/src/plugman/platforms/browser.js
index b9cb54f..3aaa961 100644
--- a/cordova-lib/src/plugman/platforms/browser.js
+++ b/cordova-lib/src/plugman/platforms/browser.js
@@ -20,10 +20,8 @@
 /* jshint laxcomma:true, sub:true */
 
 var path = require('path')
-    , fs = require('fs')
     , common = require('./common')
     , events = require('cordova-common').events
-    , xml_helpers = require('cordova-common').xmlHelpers
     ;
 
 module.exports = {
@@ -31,25 +29,7 @@ module.exports = {
         return path.join(project_dir, 'www');
     },
     package_name:function(project_dir) {
-        // preferred location if cordova >= 3.4
-        var preferred_path = path.join(project_dir, 'config.xml');
-        var config_path;
-
-        if (!fs.existsSync(preferred_path)) {
-            // older location
-            var old_config_path = path.join(module.exports.www_dir(project_dir), 'config.xml');
-            if (!fs.existsSync(old_config_path)) {
-                // output newer location and fail reading
-                config_path = preferred_path;
-                events.emit('verbose', 'unable to find '+config_path);
-            } else {
-                config_path = old_config_path;
-            }
-        } else {
-            config_path = preferred_path;
-        }
-        var widget_doc = xml_helpers.parseElementtreeSync(config_path);
-        return widget_doc._root.attrib['id'];
+        return common.package_name(project_dir, this.www_dir(project_dir));
     },
     'source-file':{
         install:function(obj, plugin_dir, project_dir, plugin_id, options) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/bfea2623/cordova-lib/src/plugman/platforms/common.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/common.js b/cordova-lib/src/plugman/platforms/common.js
index df5befa..cb5075d 100644
--- a/cordova-lib/src/plugman/platforms/common.js
+++ b/cordova-lib/src/plugman/platforms/common.js
@@ -22,7 +22,39 @@ var shell = require('shelljs'),
     fs    = require('fs'),
     common;
 
+var cordovaUtil = require('../../cordova/util');
+var CordovaError = require('cordova-common').CordovaError;
+var xmlHelpers = require('cordova-common').xmlHelpers;
+
 module.exports = common = {
+    package_name: function(project_dir, www_dir) {
+
+        var configPaths = [
+            // preferred location if cordova >= 3.4
+            path.join(project_dir, 'config.xml'),
+            // older location
+            path.join(www_dir || path.join(project_dir, 'www'), 'config.xml'),
+        ];
+
+        var cordovaRoot = cordovaUtil.isCordova();
+        if (cordovaRoot) {
+            // CB-10662 If we're in cli project then add project's config as a fallback
+            configPaths.push(path.join(cordovaRoot, 'config.xml'));
+        }
+
+        for (var i = 0; i < configPaths.length; i++) {
+            var configPath = configPaths[i];
+            // If no config there try next path
+            if (!fs.existsSync(configPath)) continue;
+
+            var widget_doc = xmlHelpers.parseElementtreeSync(configPath);
+            return widget_doc._root.attrib.id;
+        }
+
+        // No configs found - fail with meaningful error message
+        throw new CordovaError('Unable to find project\'s config in any of ' +
+            'the following directories:\n\t' + configPaths.join('\n\t'));
+    },
     // helper for resolving source paths from plugin.xml
     resolveSrcPath:function(plugin_dir, relative_path) {
         var full_path = path.resolve(plugin_dir, relative_path);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/bfea2623/cordova-lib/src/plugman/platforms/firefoxos.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/firefoxos.js b/cordova-lib/src/plugman/platforms/firefoxos.js
index 067d301..1289d13 100644
--- a/cordova-lib/src/plugman/platforms/firefoxos.js
+++ b/cordova-lib/src/plugman/platforms/firefoxos.js
@@ -20,10 +20,8 @@
 /* jshint laxcomma:true, sub:true */
 
 var path = require('path')
-    , fs = require('fs')
     , common = require('./common')
     , events = require('cordova-common').events
-    , xml_helpers = require('cordova-common').xmlHelpers
     ;
 
 module.exports = {
@@ -31,25 +29,7 @@ module.exports = {
         return path.join(project_dir, 'www');
     },
     package_name:function(project_dir) {
-        // preferred location if cordova >= 3.4
-        var preferred_path = path.join(project_dir, 'config.xml');
-        var config_path;
-
-        if (!fs.existsSync(preferred_path)) {
-            // older location
-            var old_config_path = path.join(module.exports.www_dir(project_dir), 'config.xml');
-            if (!fs.existsSync(old_config_path)) {
-                // output newer location and fail reading
-                config_path = preferred_path;
-                events.emit('verbose', 'unable to find '+config_path);
-            } else {
-                config_path = old_config_path;
-            }
-        } else {
-            config_path = preferred_path;
-        }
-        var widget_doc = xml_helpers.parseElementtreeSync(config_path);
-        return widget_doc._root.attrib['id'];
+        return common.package_name(project_dir, this.www_dir(project_dir));
     },
     'source-file':{
         install:function(obj, plugin_dir, project_dir, plugin_id, options) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/bfea2623/cordova-lib/src/plugman/platforms/webos.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/webos.js b/cordova-lib/src/plugman/platforms/webos.js
index ca2f94b..183ea82 100755
--- a/cordova-lib/src/plugman/platforms/webos.js
+++ b/cordova-lib/src/plugman/platforms/webos.js
@@ -23,10 +23,8 @@
 */
 
 var path = require('path')
-    , fs = require('fs')
     , common = require('./common')
     , events = require('cordova-common').events
-    , xml_helpers = require('cordova-common').xmlHelpers
     ;
 
 module.exports = {
@@ -34,25 +32,7 @@ module.exports = {
         return path.join(project_dir, 'www');
     },
     package_name:function(project_dir) {
-        // preferred location if cordova >= 3.4
-        var preferred_path = path.join(project_dir, 'config.xml');
-        var config_path;
-
-        if (!fs.existsSync(preferred_path)) {
-            // older location
-            var old_config_path = path.join(module.exports.www_dir(project_dir), 'config.xml');
-            if (!fs.existsSync(old_config_path)) {
-                // output newer location and fail reading
-                config_path = preferred_path;
-                events.emit('verbose', 'unable to find '+config_path);
-            } else {
-                config_path = old_config_path;
-            }
-        } else {
-            config_path = preferred_path;
-        }
-        var widget_doc = xml_helpers.parseElementtreeSync(config_path);
-        return widget_doc._root.attrib['id'];
+        return common.package_name(project_dir, this.www_dir(project_dir));
     },
     'source-file':{
         install:function(obj, plugin_dir, project_dir, plugin_id, options) {


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


[29/37] cordova-lib git commit: Merge branch 'CB-10694'

Posted by st...@apache.org.
Merge branch 'CB-10694'


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

Branch: refs/heads/common-1.1.x
Commit: 4d4fbac273f910e8e868b43100fb2e4092084d96
Parents: cc91656 11d1380
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Mar 16 16:38:28 2016 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Mar 16 16:38:28 2016 -0700

----------------------------------------------------------------------
 cordova-common/spec/util/xml-helpers.spec.js | 19 +++++++++++++++++++
 cordova-common/src/util/xml-helpers.js       |  6 +++---
 2 files changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4d4fbac2/cordova-common/spec/util/xml-helpers.spec.js
----------------------------------------------------------------------
diff --cc cordova-common/spec/util/xml-helpers.spec.js
index 9d714f0,59b760a..2138f5c
--- a/cordova-common/spec/util/xml-helpers.spec.js
+++ b/cordova-common/spec/util/xml-helpers.spec.js
@@@ -268,26 -268,25 +268,45 @@@ describe('xml-helpers', function()
  
          });
          
 +        it('should remove duplicate preferences (by name attribute value)', function () {
 +            var testXml = et.XML(
 +                '<?xml version="1.0" encoding="UTF-8"?>\n' +
 +                '<widget xmlns     = "http://www.w3.org/ns/widgets"\n' +
 +                '        xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
 +                '        id        = "io.cordova.hellocordova"\n' +
 +                '        version   = "0.0.1">\n' +
 +                '    <preference name="Orientation" value="default" />\n' +
 +                '    <preference name="Orientation" value="portrait" />\n' +
 +                '    <preference name="Orientation" value="landscape" />\n' +
 +                '    <platform name="ios">\n' +
 +                '        <preference name="Orientation" value="all" />\n' +
 +                '        <preference name="Orientation" value="portrait" />\n' +
 +                '    </platform>\n' +
 +                '</widget>\n'
 +            );
 +            xml_helpers.mergeXml(testXml, dstXml, 'ios');
 +            var testElements = dstXml.findall('preference[@name="Orientation"]');
 +            expect(testElements.length).toEqual(1);
 +        });
 +                
+         it('should merge preferences, with platform preferences written last', function () {
+             var testXml = et.XML(
+                 '<?xml version="1.0" encoding="UTF-8"?>\n' +
+                 '<widget xmlns     = "http://www.w3.org/ns/widgets"\n' +
+                 '        xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
+                 '        id        = "io.cordova.hellocordova"\n' +
+                 '        version   = "0.0.1">\n' +
+                 '    <preference name="Orientation" value="default" />\n' +
+                 '    <platform name="ios">\n' +
+                 '        <preference name="Orientation" value="all" />\n' +
+                 '    </platform>\n' +
+                 '</widget>\n'
+             );
+             xml_helpers.mergeXml(testXml, dstXml, 'ios');
+             var testElements = dstXml.findall('preference[@name="Orientation"]');
+             expect(testElements.length).toEqual(2);
+             expect(testElements[0].attrib.value).toEqual('default');
+             expect(testElements[1].attrib.value).toEqual('all');
+         });
 -        
      });
  });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4d4fbac2/cordova-common/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --cc cordova-common/src/util/xml-helpers.js
index 85d9799,487a763..fc84128
--- a/cordova-common/src/util/xml-helpers.js
+++ b/cordova-common/src/util/xml-helpers.js
@@@ -216,12 -219,6 +219,9 @@@ function mergeXml(src, dest, platform, 
          });
      }
  
-     //Handle children
-     src.getchildren().forEach(mergeChild);
-     
 +    //Handle duplicate preference tags (by name attribute)
 +    removeDuplicatePreferences(dest);
 +
      function mergeChild (srcChild) {
          var srcTag = srcChild.tag,
              destChild = new et.Element(srcTag),


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


[24/37] cordova-lib git commit: CB-10880: Remove plugin pinning

Posted by st...@apache.org.
CB-10880: Remove plugin pinning

This closes #409


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

Branch: refs/heads/common-1.1.x
Commit: d779242e8acd31231c3be98a941624ad89a5a67c
Parents: 0386ac2
Author: Richard Knoll <ri...@gmail.com>
Authored: Thu Mar 10 18:59:53 2016 -0800
Committer: Richard Knoll <ri...@gmail.com>
Committed: Tue Mar 15 10:40:07 2016 -0700

----------------------------------------------------------------------
 cordova-lib/package.json          | 24 ------------------------
 cordova-lib/src/cordova/plugin.js |  8 +++-----
 2 files changed, 3 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d779242e/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 1d452fa..3e0fadb 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -16,30 +16,6 @@
     "node": ">=0.9.9"
   },
   "engineStrict": true,
-  "cordovaPlugins": {
-    "cordova-plugin-battery-status": "~1.1.1",
-    "cordova-plugin-camera": "~2.1.0",
-    "cordova-plugin-console": "~1.0.2",
-    "cordova-plugin-contacts": "~2.0.1",
-    "cordova-plugin-device": "~1.1.1",
-    "cordova-plugin-device-motion": "~1.2.0",
-    "cordova-plugin-device-orientation": "~1.0.2",
-    "cordova-plugin-dialogs": "~1.2.0",
-    "cordova-plugin-file": "~4.1.0",
-    "cordova-plugin-file-transfer": "~1.5.0",
-    "cordova-plugin-geolocation": "~2.1.0",
-    "cordova-plugin-globalization": "~1.0.2",
-    "cordova-plugin-inappbrowser": "~1.2.0",
-    "cordova-plugin-legacy-whitelist": "~1.1.1",
-    "cordova-plugin-media": "~2.1.0",
-    "cordova-plugin-media-capture": "~1.2.0",
-    "cordova-plugin-network-information": "~1.2.0",
-    "cordova-plugin-splashscreen": "~3.1.0",
-    "cordova-plugin-statusbar": "~2.1.0",
-    "cordova-plugin-test-framework": "~1.1.1",
-    "cordova-plugin-vibration": "~2.1.0",
-    "cordova-plugin-whitelist": "~1.2.1"
-  },
   "dependencies": {
     "aliasify": "^1.7.2",
     "cordova-app-hello-world": "3.10.0",

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d779242e/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index a5398a0..46b84be 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -326,8 +326,6 @@ function determinePluginTarget(projectRoot, cfg, target, fetchOptions) {
         return getFetchVersion(projectRoot, pluginInfo, pkgJson.version);
     })
     .then(function(fetchVersion) {
-        // Fallback to pinned version if available
-        fetchVersion = fetchVersion || pkgJson.cordovaPlugins[id];
         return fetchVersion ? (id + '@' + fetchVersion) : target;
     });
 }
@@ -588,7 +586,7 @@ function getFetchVersion(projectRoot, pluginInfo, cordovaVersion) {
         });
     } else {
         // If we have no engine, we want to fall back to the default behavior
-        events.emit('verbose', 'No plugin engine info found or not using registry, falling back to latest or pinned version');
+        events.emit('verbose', 'No plugin engine info found or not using registry, falling back to latest version');
         return Q(null);
     }
 }
@@ -706,7 +704,7 @@ function determinePluginVersionToFetch(pluginInfo, pluginMap, platformMap, cordo
     }
 
     // No version of the plugin is satisfied. In this case, we fall back to
-    // fetching latest or pinned versions, but also output a warning
+    // fetching the latest version, but also output a warning
     var latestFailedReqs = versions.length > 0 ? getFailedRequirements(engine[versions[0]], pluginMap, platformMap, cordovaVersion) : [];
 
     // If the upper bound is greater than latest, we need to combine its engine
@@ -728,7 +726,7 @@ function determinePluginVersionToFetch(pluginInfo, pluginMap, platformMap, cordo
     }
 
     listUnmetRequirements(name, latestFailedReqs);
-    events.emit('warn', 'Current project does not satisfy the engine requirements specified by any version of ' + name + '. Fetching latest or pinned version of plugin anyway (may be incompatible)');
+    events.emit('warn', 'Current project does not satisfy the engine requirements specified by any version of ' + name + '. Fetching latest version of plugin anyway (may be incompatible)');
 
     // No constraints were satisfied
     return null;


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


[31/37] cordova-lib git commit: CB-10902 updated pinned platforms

Posted by st...@apache.org.
CB-10902 updated pinned platforms


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

Branch: refs/heads/common-1.1.x
Commit: 3502274a0028db36bc41f9f61257e3c6d24af7f5
Parents: c9b0423
Author: Steve Gill <st...@gmail.com>
Authored: Thu Mar 17 16:08:51 2016 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Thu Mar 17 16:08:51 2016 -0700

----------------------------------------------------------------------
 cordova-lib/src/platforms/platformsConfig.json | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/3502274a/cordova-lib/src/platforms/platformsConfig.json
----------------------------------------------------------------------
diff --git a/cordova-lib/src/platforms/platformsConfig.json b/cordova-lib/src/platforms/platformsConfig.json
index 8b4a649..f411f8b 100644
--- a/cordova-lib/src/platforms/platformsConfig.json
+++ b/cordova-lib/src/platforms/platformsConfig.json
@@ -4,7 +4,7 @@
         "parser_file": "../cordova/metadata/ios_parser",
         "handler_file": "../plugman/platforms/ios",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git",
-        "version": "~4.0.1",
+        "version": "~4.1.0",
         "apiCompatibleSince": "4.0.0",
         "deprecated": false
     },
@@ -13,7 +13,7 @@
         "parser_file": "../cordova/metadata/osx_parser",
         "handler_file": "../plugman/platforms/ios",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-osx.git",
-        "version": "~4.0.0",
+        "version": "~4.0.1",
         "apiCompatibleSince": "4.0.0",
         "deprecated": false
     },
@@ -21,7 +21,7 @@
         "parser_file": "../cordova/metadata/android_parser",
         "handler_file": "../plugman/platforms/android",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git",
-        "version": "~5.1.0",
+        "version": "~5.1.1",
         "apiCompatibleSince": "5.0.0",
         "deprecated": false
     },
@@ -30,7 +30,7 @@
         "parser_file": "../cordova/metadata/ubuntu_parser",
         "handler_file": "../plugman/platforms/ubuntu",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-ubuntu.git",
-        "version": "~4.3.2",
+        "version": "~4.3.3",
         "deprecated": false
     },
     "amazon-fireos": {
@@ -75,7 +75,7 @@
         "parser_file": "../cordova/metadata/windows_parser",
         "handler_file": "../plugman/platforms/windows",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git",
-        "version": "~4.3.0",
+        "version": "~4.3.1",
         "apiCompatibleSince": "4.3.0",
         "deprecated": false
     },
@@ -90,7 +90,7 @@
         "parser_file": "../cordova/metadata/browser_parser",
         "handler_file": "../plugman/platforms/browser",
         "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-browser.git",
-        "version": "~4.0.0",
+        "version": "~4.1.0",
         "deprecated": false
     }
 }


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


[08/37] cordova-lib git commit: CB-10519 Fixing rebase/merge issues

Posted by st...@apache.org.
CB-10519 Fixing rebase/merge issues


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

Branch: refs/heads/common-1.1.x
Commit: 3cef0823d7553b4885c12501609a976510f83f96
Parents: 4121b11
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Fri Feb 19 14:31:30 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Fri Feb 19 14:31:30 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/cordova/compile.js | 8 ++------
 cordova-lib/src/cordova/run.js     | 5 -----
 2 files changed, 2 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/3cef0823/cordova-lib/src/cordova/compile.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/compile.js b/cordova-lib/src/cordova/compile.js
index e540c14..6a5adfb 100644
--- a/cordova-lib/src/cordova/compile.js
+++ b/cordova-lib/src/cordova/compile.js
@@ -17,7 +17,8 @@
     under the License.
 */
 
-var cordova_util = require('./util'),
+var Q            = require('q'),
+    cordova_util = require('./util'),
     HooksRunner  = require('../hooks/HooksRunner'),
     promiseUtil  = require('../util/promise-util'),
     platform_lib = require('../platforms/platforms');
@@ -38,11 +39,6 @@ module.exports = function compile(options) {
             });
         }).then(function() {
             return hooksRunner.fire('after_compile', options);
-        }, function(error) {
-            events.emit('log', 'ERROR building one of the platforms: ' + error + '\nYou may not have the required environment or OS to build this project');
-            return Q.reject(error);
         });
-    }).then(function() {
-        return hooksRunner.fire('after_compile', options);
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/3cef0823/cordova-lib/src/cordova/run.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/run.js b/cordova-lib/src/cordova/run.js
index f2afeed..046b1da 100644
--- a/cordova-lib/src/cordova/run.js
+++ b/cordova-lib/src/cordova/run.js
@@ -43,11 +43,6 @@ module.exports = function run(options) {
             }));
         }).then(function() {
             return hooksRunner.fire('after_run', options);
-        }, function(error) {
-            events.emit('log', 'ERROR running one or more of the platforms: ' + error + '\nYou may not have the required environment or OS to run this project');
-
-            // CB-10567 bubble up `run` error, so the caller still could get rejected promise
-            return Q.reject(error);
         });
     });
 };


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


[35/37] cordova-lib git commit: CB-10911 Updated version and RELEASENOTES.md for release cordova-common@1.1.1

Posted by st...@apache.org.
CB-10911 Updated version and RELEASENOTES.md for release cordova-common@1.1.1


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

Branch: refs/heads/master
Commit: 80b70040bb7cc806d155a8955a5d2f432d509a40
Parents: 9c7dead
Author: Steve Gill <st...@gmail.com>
Authored: Fri Mar 18 17:52:03 2016 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Mar 18 17:52:03 2016 -0700

----------------------------------------------------------------------
 cordova-common/RELEASENOTES.md | 9 +++++++++
 cordova-common/package.json    | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/80b70040/cordova-common/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/cordova-common/RELEASENOTES.md b/cordova-common/RELEASENOTES.md
index e7db69c..806b6f2 100644
--- a/cordova-common/RELEASENOTES.md
+++ b/cordova-common/RELEASENOTES.md
@@ -20,6 +20,15 @@
 -->
 # Cordova-common Release Notes
 
+### 1.1.1 (Mar 18, 2016)
+* CB-10694 Update test to reflect merging of CB-9264 fix
+* CB-10694 Platform-specific configuration preferences don't override global settings
+* CB-9264 Duplicate entries in `config.xml`
+* CB-10791 Add `adjustLoggerLevel` to `cordova-common.CordovaLogger`
+* CB-10662 Add tests for `ConfigParser.getStaticResources`
+* CB-10622 fix target attribute being ignored for images in `config.xml`.
+* CB-10583 Protect plugin preferences from adding extra Array properties.
+
 ### 1.1.0 (Feb 16, 2016)
 * CB-10482 Remove references to windows8 from cordova-lib/cli
 * CB-10430 Adds forwardEvents method to easily connect two EventEmitters

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/80b70040/cordova-common/package.json
----------------------------------------------------------------------
diff --git a/cordova-common/package.json b/cordova-common/package.json
index e84b6a5..c38b6da 100644
--- a/cordova-common/package.json
+++ b/cordova-common/package.json
@@ -3,7 +3,7 @@
   "name": "cordova-common",
   "description": "Apache Cordova tools and platforms shared routines",
   "license": "Apache-2.0",
-  "version": "1.2.0-dev",
+  "version": "1.1.1",
   "repository": {
     "type": "git",
     "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"


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


[04/37] cordova-lib git commit: CB-10618 Do not call prepBuildFiles for cordova-android@>=5.2.0. This closes #389

Posted by st...@apache.org.
CB-10618 Do not call prepBuildFiles for cordova-android@>=5.2.0. This closes #389


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

Branch: refs/heads/common-1.1.x
Commit: 5da4364a8510f9ad83c0abbf8b21ef609e4d0e59
Parents: b792050
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Mon Feb 15 16:50:20 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Wed Feb 17 19:02:24 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/plugman/install.js   | 15 ++++++++++-----
 cordova-lib/src/plugman/uninstall.js | 10 ++++++++--
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/5da4364a/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index b7f0d88..53f37ef 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -83,7 +83,7 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
     // Split @Version from the plugin id if it exists.
     var splitVersion = id.split('@');
     //Check if a mapping exists for the plugin id
-    //if it does, convert id to new name id 
+    //if it does, convert id to new name id
     var newId = pluginMapper[splitVersion[0]];
     if(newId) {
         events.emit('warn', 'Notice: ' + id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
@@ -92,7 +92,7 @@ module.exports = function installPlugin(platform, project_dir, id, plugins_dir,
         } else {
             id = newId;
         }
-     }     
+     }
     return possiblyFetch(id, plugins_dir, options)
     .then(function(plugin_dir) {
         return runInstall(current_stack, platform, project_dir, plugin_dir, plugins_dir, options);
@@ -398,7 +398,7 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
         }
     ).fail(
         function (error) {
-            
+
             if(error === 'skip') {
                 events.emit('warn', 'Skipping \'' + pluginInfo.id + '\' for ' + platform);
             } else {
@@ -430,7 +430,7 @@ function installDependencies(install, dependencies, options) {
                 // Split @Version from the plugin id if it exists.
                 var splitVersion = dep.id.split('@');
                 //Check if a mapping exists for the plugin id
-                //if it does, convert id to new name id 
+                //if it does, convert id to new name id
                 var newId = pluginMapper[splitVersion[0]];
                 if(newId) {
                     events.emit('warn', 'Notice: ' + dep.id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
@@ -613,7 +613,12 @@ function handleInstall(actions, pluginInfo, platform, project_dir, plugins_dir,
             .addPlugin(pluginInfo.id, filtered_variables, options.is_top_level)
             .save();
 
-        if (platform == 'android' && semver.gte(options.platformVersion, '4.0.0-dev') &&
+        if (platform == 'android' &&
+                semver.gte(options.platformVersion, '4.0.0-dev') &&
+                // CB-10533 since 5.2.0-dev prepBuildFiles is now called internally by android platform and
+                // no more exported from build module
+                // TODO: This might be removed once we deprecate non-PlatformApi compatible platforms support
+                semver.lte(options.platformVersion, '5.2.0-dev') &&
                 pluginInfo.getFrameworks(platform).length > 0) {
 
             events.emit('verbose', 'Updating build files since android plugin contained <framework>');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/5da4364a/cordova-lib/src/plugman/uninstall.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/uninstall.js b/cordova-lib/src/plugman/uninstall.js
index a46b07b..bf136eb 100644
--- a/cordova-lib/src/plugman/uninstall.js
+++ b/cordova-lib/src/plugman/uninstall.js
@@ -267,7 +267,7 @@ function runUninstallPlatform(actions, platform, project_dir, plugin_dir, plugin
         promise = promiseutil.Q_chainmap(danglers, function(dangler) {
             var dependent_path = path.join(plugins_dir, dangler);
 
-            //try to convert ID if old-id path doesn't exist. 
+            //try to convert ID if old-id path doesn't exist.
             if (!fs.existsSync(dependent_path)) {
                 var splitVersion = dangler.split('@');
                 var newId = pluginMapper[splitVersion[0]];
@@ -334,8 +334,14 @@ function handleUninstall(actions, platform, pluginInfo, project_dir, www_dir, pl
             .removePlugin(pluginInfo.id, is_top_level)
             .save();
 
-        if (platform == 'android' && semver.gte(options.platformVersion, '4.0.0-dev') &&
+        if (platform == 'android' &&
+                semver.gte(options.platformVersion, '4.0.0-dev') &&
+                // CB-10533 since 5.2.0-dev prepBuildFiles is now called internally by android platform and
+                // no more exported from build module
+                // TODO: This might be removed once we deprecate non-PlatformApi compatible platforms support
+                semver.lte(options.platformVersion, '5.2.0-dev') &&
                 pluginInfo.getFrameworks(platform).length > 0) {
+
             events.emit('verbose', 'Updating build files since android plugin contained <framework>');
             var buildModule;
             try {


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


[36/37] cordova-lib git commit: CB-10911 Updated version and RELEASENOTES.md for release cordova-common@1.1.1

Posted by st...@apache.org.
CB-10911 Updated version and RELEASENOTES.md for release cordova-common@1.1.1


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

Branch: refs/heads/common-1.1.x
Commit: 80b70040bb7cc806d155a8955a5d2f432d509a40
Parents: 9c7dead
Author: Steve Gill <st...@gmail.com>
Authored: Fri Mar 18 17:52:03 2016 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Mar 18 17:52:03 2016 -0700

----------------------------------------------------------------------
 cordova-common/RELEASENOTES.md | 9 +++++++++
 cordova-common/package.json    | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/80b70040/cordova-common/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/cordova-common/RELEASENOTES.md b/cordova-common/RELEASENOTES.md
index e7db69c..806b6f2 100644
--- a/cordova-common/RELEASENOTES.md
+++ b/cordova-common/RELEASENOTES.md
@@ -20,6 +20,15 @@
 -->
 # Cordova-common Release Notes
 
+### 1.1.1 (Mar 18, 2016)
+* CB-10694 Update test to reflect merging of CB-9264 fix
+* CB-10694 Platform-specific configuration preferences don't override global settings
+* CB-9264 Duplicate entries in `config.xml`
+* CB-10791 Add `adjustLoggerLevel` to `cordova-common.CordovaLogger`
+* CB-10662 Add tests for `ConfigParser.getStaticResources`
+* CB-10622 fix target attribute being ignored for images in `config.xml`.
+* CB-10583 Protect plugin preferences from adding extra Array properties.
+
 ### 1.1.0 (Feb 16, 2016)
 * CB-10482 Remove references to windows8 from cordova-lib/cli
 * CB-10430 Adds forwardEvents method to easily connect two EventEmitters

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/80b70040/cordova-common/package.json
----------------------------------------------------------------------
diff --git a/cordova-common/package.json b/cordova-common/package.json
index e84b6a5..c38b6da 100644
--- a/cordova-common/package.json
+++ b/cordova-common/package.json
@@ -3,7 +3,7 @@
   "name": "cordova-common",
   "description": "Apache Cordova tools and platforms shared routines",
   "license": "Apache-2.0",
-  "version": "1.2.0-dev",
+  "version": "1.1.1",
   "repository": {
     "type": "git",
     "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"


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


[14/37] cordova-lib git commit: CB-10662 Add tests for ConfigParser.getStaticResources

Posted by st...@apache.org.
CB-10662 Add tests for ConfigParser.getStaticResources


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

Branch: refs/heads/common-1.1.x
Commit: cda2b72b81bf26670674b8965381ee4534bdc8e9
Parents: 84d4ea0
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Fri Feb 26 17:41:03 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Fri Feb 26 17:43:44 2016 +0300

----------------------------------------------------------------------
 .../spec/ConfigParser/ConfigParser.spec.js      | 49 ++++++++++++++++++++
 cordova-common/spec/fixtures/test-config.xml    |  7 +++
 2 files changed, 56 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cda2b72b/cordova-common/spec/ConfigParser/ConfigParser.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/ConfigParser/ConfigParser.spec.js b/cordova-common/spec/ConfigParser/ConfigParser.spec.js
index f4eace7..097fe61 100644
--- a/cordova-common/spec/ConfigParser/ConfigParser.spec.js
+++ b/cordova-common/spec/ConfigParser/ConfigParser.spec.js
@@ -228,5 +228,54 @@ describe('config.xml parser', function () {
                 expect(navigations.length).not.toEqual(0);
             });
         });
+        describe('static resources', function() {
+            var hasPlatformPropertyDefined = function (e) { return !!e.platform; };
+            var hasSrcPropertyDefined = function (e) { return !!e.src; };
+            var hasTargetPropertyDefined = function (e) { return !!e.target; };
+            var hasDensityPropertyDefined = function (e) { return !!e.density; };
+            var hasPlatformPropertyUndefined = function (e) { return !e.platform; };
+
+            it('should fetch shared resources if platform parameter is not specified', function() {
+                expect(cfg.getStaticResources(null, 'icon').length).toBe(2);
+                expect(cfg.getStaticResources(null, 'icon').every(hasPlatformPropertyUndefined)).toBeTruthy();
+            });
+
+            it('should fetch platform-specific resources along with shared if platform parameter is specified', function() {
+                expect(cfg.getStaticResources('android', 'icon').length).toBe(5);
+                expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyDefined)).toBeTruthy();
+                expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).length).toBe(3);
+                expect(cfg.getStaticResources('android', 'icon').some(hasPlatformPropertyUndefined)).toBeTruthy();
+            });
+
+            it('should parse resources\' attributes', function() {
+                expect(cfg.getStaticResources(null, 'icon').every(hasSrcPropertyDefined)).toBeTruthy();
+                expect(cfg.getStaticResources('windows', 'icon').filter(hasPlatformPropertyDefined).every(hasTargetPropertyDefined)).toBeTruthy();
+                expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy();
+                expect(cfg.getStaticResources('android', 'icon').filter(hasPlatformPropertyDefined).every(hasDensityPropertyDefined)).toBeTruthy();
+            });
+
+            it('should have defaultResource property', function() {
+                expect(cfg.getStaticResources(null, 'icon').defaultResource).toBeDefined();
+                expect(cfg.getStaticResources(null, 'icon').defaultResource.src).toBe('icon.png');
+            });
+
+            it('should have getDefault method returning defaultResource property', function() {
+                expect(cfg.getStaticResources(null, 'icon').defaultResource).toEqual(cfg.getStaticResources(null, 'icon').getDefault());
+            });
+
+            it('should have getBySize method returning resource with size specified or null', function() {
+                expect(cfg.getStaticResources('windows', 'icon').getBySize(128)).toBe(null);
+                expect(cfg.getStaticResources('windows', 'icon').getBySize(72)).toBeDefined();
+                expect(cfg.getStaticResources('windows', 'icon').getBySize(72).width).toBe(72);
+                expect(cfg.getStaticResources('windows', 'icon').getBySize(null, 48)).toBeDefined();
+                expect(cfg.getStaticResources('windows', 'icon').getBySize(null, 48).height).toBe(48);
+            });
+
+            it('should have getByDensity method returning resource with density specified or null', function() {
+                expect(cfg.getStaticResources('android', 'icon').getByDensity('hdpi')).toBe(null);
+                expect(cfg.getStaticResources('android', 'icon').getByDensity('mdpi')).toBeDefined();
+                expect(cfg.getStaticResources('android', 'icon').getByDensity('mdpi').src).toBe('logo-android.png');
+            });
+        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cda2b72b/cordova-common/spec/fixtures/test-config.xml
----------------------------------------------------------------------
diff --git a/cordova-common/spec/fixtures/test-config.xml b/cordova-common/spec/fixtures/test-config.xml
index 2f14f32..df47948 100644
--- a/cordova-common/spec/fixtures/test-config.xml
+++ b/cordova-common/spec/fixtures/test-config.xml
@@ -81,9 +81,16 @@
     <icon height="255" id="logo" src="logo.png" width="255" />
     <platform name="android">
         <icon density="mdpi" height="255" src="logo-android.png" width="255" />
+        <icon gap:density="mdpi" height="255" src="logo-android-gap.png" width="255" />
+        <icon cdv:density="mdpi" height="255" src="logo-android-cdv.png" width="255" />
         <preference name="android-minSdkVersion" value="10" />
         <preference name="orientation" value="landscape" />
     </platform>
+    <platform name="windows">
+        <icon src="res/windows/logo.scale-200.png" target="logo.png"/>
+        <icon src="res/windows/logo-small.scale-400.png" width="72" target="logo.png"/>
+        <icon src="res/windows/logo-small.scale-400_48.png" height="48" target="logo.png"/>
+    </platform>
     <plugin name="org.apache.cordova.pluginwithvars">
         <variable name="var" value="varvalue" />
     </plugin>


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


[19/37] cordova-lib git commit: CB-10679: New version choosing logic for plugin add

Posted by st...@apache.org.
CB-10679: New version choosing logic for plugin add

Adds support for plugins specifying their cordova
related dependencies in their package.json to
guide cordova-lib in choosing the correct version
of a plugin to fetch for the current project

This closes #363


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

Branch: refs/heads/common-1.1.x
Commit: 45a235fa73e5b23ed9fa44734449503976b999e3
Parents: 114de6c
Author: riknoll <ri...@gmail.com>
Authored: Fri Jan 15 13:35:26 2016 -0800
Committer: riknoll <ri...@gmail.com>
Committed: Mon Mar 7 13:37:17 2016 -0800

----------------------------------------------------------------------
 cordova-lib/spec-cordova/plugin.spec.js       | 157 +++++--
 cordova-lib/spec-cordova/plugin_fetch.spec.js | 522 +++++++++++++++++++++
 cordova-lib/spec-cordova/util.spec.js         |  19 +
 cordova-lib/src/cordova/platform.js           |  21 +-
 cordova-lib/src/cordova/plugin.js             | 324 +++++++++++--
 cordova-lib/src/cordova/util.js               |  20 +-
 cordova-lib/src/plugman/registry/registry.js  |  26 +-
 7 files changed, 985 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/45a235fa/cordova-lib/spec-cordova/plugin.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/plugin.spec.js b/cordova-lib/spec-cordova/plugin.spec.js
index b09fbff..11a1b16 100644
--- a/cordova-lib/spec-cordova/plugin.spec.js
+++ b/cordova-lib/spec-cordova/plugin.spec.js
@@ -19,9 +19,12 @@
 
 var helpers = require('./helpers'),
     path = require('path'),
+    Q = require('q'),
     shell = require('shelljs'),
     events = require('cordova-common').events,
-    cordova = require('../src/cordova/cordova');
+    cordova = require('../src/cordova/cordova'),
+    plugman = require('../src/plugman/plugman'),
+    registry = require('../src/plugman/registry/registry');
 
 var tmpDir = helpers.tmpDir('plugin_test');
 var project = path.join(tmpDir, 'project');
@@ -29,21 +32,66 @@ var pluginsDir = path.join(__dirname, 'fixtures', 'plugins');
 var pluginId = 'org.apache.cordova.fakeplugin1';
 var org_test_defaultvariables = 'org.test.defaultvariables';
 
+var results;
+
+
+// Runs: list, add, list
+function addPlugin(target, id, options) {
+    // Check there are no plugins yet.
+    return cordova.raw.plugin('list').then(function() {
+        expect(results).toMatch(/No plugins added/gi);
+    }).then(function() {
+        // Add a fake plugin from fixtures.
+        return cordova.raw.plugin('add', target, options);
+    }).then(function() {
+        expect(path.join(project, 'plugins', id, 'plugin.xml')).toExist();
+    }).then(function() {
+        return cordova.raw.plugin('ls');
+    }).then(function() {
+        expect(results).toContain(id);
+    });
+}
+
+// Runs: remove, list
+function removePlugin(id) {
+    return cordova.raw.plugin('rm', id)
+    .then(function() {
+        // The whole dir should be gone.
+        expect(path.join(project, 'plugins', id)).not.toExist();
+    }).then(function() {
+        return cordova.raw.plugin('ls');
+    }).then(function() {
+        expect(results).toMatch(/No plugins added/gi);
+    });
+}
+
+var errorHandler = {
+    errorCallback: function(error) {
+        // We want the error to be printed by jasmine
+        expect(error).toBeUndefined();
+    }
+};
+
+// We can't call add with a searchpath or else we will conflict with other tests
+// that use a searchpath. See loadLocalPlugins() in plugman/fetch.js for details.
+// The searchpath behavior gets tested in the plugman spec
+function mockPluginFetch(id, dir) {
+    spyOn(plugman.raw, 'fetch').andCallFake(function(target, pluginPath, fetchOptions) {
+        var dest = path.join(project, 'plugins', id);
+        var src = path.join(dir, 'plugin.xml');
+
+        shell.mkdir(dest);
+        shell.cp(src, dest);
+        return Q(dest);
+    });
+}
+
 describe('plugin end-to-end', function() {
-    var results;
+    events.on('results', function(res) { results = res; });
 
     beforeEach(function() {
         shell.rm('-rf', project);
-    });
-    afterEach(function() {
-        process.chdir(path.join(__dirname, '..'));  // Needed to rm the dir on Windows.
-        shell.rm('-rf', tmpDir);
-    });
 
-    // The flow tested is: ls, add, ls, rm, ls.
-    // Plugin dependencies are not tested as that should be corvered in plugman tests.
-    // TODO (kamrik): Test the 'plugin search' command.
-    it('should successfully run', function(done) {
         // cp then mv because we need to copy everything, but that means it'll copy the whole directory.
         // Using /* doesn't work because of hidden files.
         shell.cp('-R', path.join(__dirname, 'fixtures', 'base'), tmpDir);
@@ -52,40 +100,57 @@ describe('plugin end-to-end', function() {
         shell.cp('-R', path.join(__dirname, 'fixtures', 'platforms', helpers.testPlatform), path.join(project, 'platforms'));
         process.chdir(project);
 
-        events.on('results', function(res) { results = res; });
-
-        // Check there are no plugins yet.
-        cordova.raw.plugin('list').then(function() {
-            expect(results).toMatch(/No plugins added/gi);
-        }).then(function() {
-            // Add a fake plugin from fixtures.
-            return cordova.raw.plugin('add', path.join(pluginsDir, 'fake1'));
-        }).then(function() {
-           expect(path.join(project, 'plugins', pluginId, 'plugin.xml')).toExist();
-        }).then(function() {
-            return cordova.raw.plugin('ls');
-        }).then(function() {
-            expect(results).toContain(pluginId);
-        }).then(function() {
-            // And now remove it.
-            return cordova.raw.plugin('rm', pluginId);
-        }).then(function() {
-            // The whole dir should be gone.
-            expect(path.join(project, 'plugins', pluginId)).not.toExist();
-        }).then(function() {
-            return cordova.raw.plugin('ls');
-        }).then(function() {
-            expect(results).toMatch(/No plugins added/gi);
-        }).then(function() {
-            // Testing Default Variables plugin
-            return cordova.raw.plugin('add', path.join(pluginsDir, org_test_defaultvariables),{cli_variables: { REQUIRED:'yes', REQUIRED_ANDROID:'yes'}});
-         }).then(function() {
-            return cordova.raw.plugin('ls');
-        }).then(function() {
-            expect(results).toContain(org_test_defaultvariables);
-        }).fail(function(err) {
-            console.log(err.stack);
-            expect(err).toBeUndefined();
-        }).fin(done);
+        spyOn(errorHandler, 'errorCallback').andCallThrough();
+    });
+
+    afterEach(function() {
+        process.chdir(path.join(__dirname, '..'));  // Needed to rm the dir on Windows.
+        shell.rm('-rf', tmpDir);
+        expect(errorHandler.errorCallback).not.toHaveBeenCalled();
+    });
+
+    it('should successfully add and remove a plugin with no options', function(done) {
+        addPlugin(path.join(pluginsDir, 'fake1'), pluginId, {}, done)
+        .then(function() {
+            return removePlugin(pluginId);
+        })
+        .fail(errorHandler.errorCallback)
+        .fin(done);
+    });
+
+    it('should successfully add a plugin when specifying CLI variables', function(done) {
+        addPlugin(path.join(pluginsDir, org_test_defaultvariables), org_test_defaultvariables, {cli_variables: { REQUIRED:'yes', REQUIRED_ANDROID:'yes'}}, done)
+        .fail(errorHandler.errorCallback)
+        .fin(done);
+    });
+
+    it('should not check npm info when using the searchpath flag', function(done) {
+        mockPluginFetch(pluginId, path.join(pluginsDir, 'fake1'));
+
+        spyOn(registry, 'info');
+        addPlugin(pluginId, pluginId, {searchpath: pluginsDir}, done)
+        .then(function() {
+            expect(registry.info).not.toHaveBeenCalled();
+
+            var fetchOptions = plugman.raw.fetch.mostRecentCall.args[2];
+            expect(fetchOptions.searchpath).toBeDefined();
+        })
+        .fail(errorHandler.errorCallback)
+        .fin(done);
+    });
+
+    it('should not check npm info when using the noregistry flag', function(done) {
+        mockPluginFetch(pluginId, path.join(pluginsDir, 'fake1'));
+
+        spyOn(registry, 'info');
+        addPlugin(pluginId, pluginId, {noregistry:true}, done)
+        .then(function() {
+            expect(registry.info).not.toHaveBeenCalled();
+
+            var fetchOptions = plugman.raw.fetch.mostRecentCall.args[2];
+            expect(fetchOptions.noregistry).toBeTruthy();
+        })
+        .fail(errorHandler.errorCallback)
+        .fin(done);
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/45a235fa/cordova-lib/spec-cordova/plugin_fetch.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/plugin_fetch.spec.js b/cordova-lib/spec-cordova/plugin_fetch.spec.js
new file mode 100644
index 0000000..107b539
--- /dev/null
+++ b/cordova-lib/spec-cordova/plugin_fetch.spec.js
@@ -0,0 +1,522 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+
+var plugin  = require('../src/cordova/plugin'),
+    helpers = require('./helpers'),
+    path    = require('path'),
+    events = require('cordova-common').events,
+    shell   = require('shelljs');
+
+var testPluginVersions = [
+    '0.0.2',
+    '0.7.0',
+    '1.0.0',
+    '1.1.0',
+    '1.1.3',
+    '1.3.0',
+    '1.7.0',
+    '1.7.1',
+    '2.0.0-rc.1',
+    '2.0.0-rc.2',
+    '2.0.0',
+    '2.3.0'
+];
+
+var cordovaVersion = '3.4.2';
+
+var tempDir = helpers.tmpDir('plugin_fetch_spec');
+var project = path.join(tempDir, 'project');
+
+var getVersionErrorCallback;
+var warnings = [];
+
+// Used to extract the constraint, the installed version, and the required
+// semver range from a warning message
+var UNMET_REQ_REGEX = /\s+([^\s]+)[^\d]+(\d+\.\d+\.\d+) installed, (.+) required\)/;
+
+// We generate warnings when we don't fetch latest. Collect them to make sure we
+// are making the correct warnings
+events.on('warn', function(warning) {
+    warnings.push(warning);
+});
+
+// Tests a sample engine against the installed platforms/plugins in our test
+// project
+function testEngineWithProject(done, testEngine, testResult) {
+    plugin.getFetchVersion(project,
+        {
+            'version': '2.3.0',
+            'name': 'test-plugin',
+            'engines': { 'cordovaDependencies': testEngine },
+            'versions': testPluginVersions
+        }, cordovaVersion)
+    .then(function(toFetch) {
+        expect(toFetch).toBe(testResult);
+    })
+    .fail(getVersionErrorCallback)
+    .fin(done);
+}
+
+// Checks the warnings that were printed by the CLI to ensure that the code is
+// listing the correct reasons for failure. Checks against the global warnings
+// object which is reset before each test
+function checkUnmetRequirements(requirements) {
+    var reqWarnings = [];
+
+    warnings.forEach(function(warning) {
+        var extracted = UNMET_REQ_REGEX.exec(warning);
+        if (extracted) {
+            reqWarnings.push({
+                dependency: extracted[1],
+                installed: extracted[2],
+                required: extracted[3]
+            });
+        }
+    });
+
+    expect(reqWarnings.length).toEqual(requirements.length);
+
+    requirements.forEach(function(requirement) {
+        expect(reqWarnings).toContain(function(extractedWarning) {
+            return  extractedWarning.dependency === requirement.dependency.trim() &&
+                    extractedWarning.installed  === requirement.installed.trim() &&
+                    extractedWarning.required   === requirement.required.trim();
+        }, requirement);
+    });
+}
+
+// Helper functions for creating the requirements objects taken by
+// checkUnmetRequirements()
+function getPlatformRequirement(requirement) {
+    return {
+        dependency: 'cordova-android',
+        installed: '3.1.0',
+        required: requirement
+    };
+}
+
+function getCordovaRequirement(requirement) {
+    return {
+        dependency: 'cordova',
+        installed: cordovaVersion,
+        required: requirement
+    };
+}
+
+function getPluginRequirement(requirement) {
+    return {
+        dependency: 'ca.filmaj.AndroidPlugin',
+        installed: '4.2.0',
+        required: requirement
+    };
+}
+
+// Generates a callback that checks warning messages after the test is complete
+function getWarningCheckCallback(done, requirements) {
+    return function() {
+        checkUnmetRequirements(requirements);
+        expect(getVersionErrorCallback).not.toHaveBeenCalled();
+        done();
+    };
+}
+
+function createTestProject() {
+    // Get the base project
+    shell.cp('-R', path.join(__dirname, 'fixtures', 'base'), tempDir);
+    shell.mv(path.join(tempDir, 'base'), project);
+
+    // Copy a platform and a plugin to our sample project
+    shell.cp('-R',
+        path.join(__dirname, 'fixtures', 'platforms', helpers.testPlatform),
+        path.join(project, 'platforms'));
+    shell.cp('-R',
+        path.join(__dirname, 'fixtures', 'plugins', 'android'),
+        path.join(project, 'plugins'));
+}
+
+function removeTestProject() {
+    shell.rm('-rf', tempDir);
+}
+
+describe('plugin fetching version selection', function(done) {
+    createTestProject();
+
+    beforeEach(function() {
+        // Adding a matcher for checking the array of warning messages so that
+        // we can have meanigful error messages. Expected is passed because
+        // Jasmine will print it out if the matcher fails
+        this.addMatchers({
+            toContain: function(check, expected) {
+                for(var i = 0; i < this.actual.length; i++) {
+                    if (check(this.actual[i])) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+        });
+
+        warnings = [];
+        getVersionErrorCallback = jasmine.createSpy('unexpectedPluginFetchErrorCallback');
+    });
+
+    it('should handle a mix of upper bounds and single versions', function(done) {
+        var testEngine = {
+            '0.0.0' : { 'cordova-android': '1.0.0' },
+            '0.0.2' : { 'cordova-android': '>1.0.0' },
+            '<1.0.0': { 'cordova-android': '<2.0.0' },
+            '1.0.0' : { 'cordova-android': '>2.0.0' },
+            '1.7.0' : { 'cordova-android': '>4.0.0' },
+            '<2.3.0': { 'cordova-android': '<6.0.0' },
+            '2.3.0' : { 'cordova-android': '6.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('6.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.3.0');
+    });
+
+    it('should apply upper bound engine constraints when there are no unspecified constraints above the upper bound', function(done) {
+        var testEngine = {
+            '1.0.0' : { 'cordova-android': '>2.0.0' },
+            '1.7.0' : { 'cordova-android': '>4.0.0' },
+            '<2.3.0': {
+                'cordova-android': '<6.0.0',
+                'ca.filmaj.AndroidPlugin': '<1.0.0'
+            },
+            '2.3.0' : { 'cordova-android': '6.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('6.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, null);
+    });
+
+    it('should apply upper bound engine constraints when there are unspecified constraints above the upper bound', function(done) {
+        var testEngine = {
+            '0.0.0' : {},
+            '2.0.0' : { 'cordova-android': '~5.0.0' },
+            '<1.0.0': { 'cordova-android': '>5.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('~5.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.7.1');
+    });
+
+    it('should handle the case where there are no constraints for earliest releases', function(done) {
+        var testEngine = {
+            '1.0.0' : { 'cordova-android': '~5.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('~5.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '0.7.0');
+    });
+
+    it('should handle the case where the lowest version is unsatisfied', function(done) {
+        var testEngine = {
+            '0.0.2' : { 'cordova-android': '~5.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('~5.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, null);
+    });
+
+    it('should handle upperbounds if no single version constraints are given', function(done) {
+        var testEngine = {
+            '<1.0.0': { 'cordova-android': '<2.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, []);
+
+        testEngineWithProject(after, testEngine, '2.3.0');
+    });
+
+    it('should apply upper bounds greater than highest version', function(done) {
+        var testEngine = {
+            '0.0.0' : {},
+            '<5.0.0': { 'cordova-android': '<2.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('<2.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, null);
+    });
+
+    it('should treat empty constraints as satisfied', function(done) {
+        var testEngine = {
+            '1.0.0' : {},
+            '1.1.0' : { 'cordova-android': '>5.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('>5.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.0.0');
+    });
+
+    it('should ignore an empty cordovaDependencies entry', function(done) {
+        var testEngine = {};
+
+        var after = getWarningCheckCallback(done, []);
+
+        testEngineWithProject(after, testEngine, null);
+    });
+
+    it('should ignore a badly formatted semver range', function(done) {
+        var testEngine = {
+            '1.1.3' : { 'cordova-android': 'badSemverRange' }
+        };
+
+        var after = getWarningCheckCallback(done, []);
+
+        testEngineWithProject(after, testEngine, '2.3.0');
+    });
+
+    it('should respect unreleased versions in constraints', function(done) {
+        var testEngine = {
+            '1.0.0' : { 'cordova-android': '3.1.0' },
+            '1.1.2' : { 'cordova-android': '6.0.0' },
+            '1.3.0' : { 'cordova-android': '6.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('6.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.1.0');
+    });
+
+    it('should respect plugin constraints', function(done) {
+        var testEngine = {
+            '0.0.0' : { 'ca.filmaj.AndroidPlugin': '1.2.0' },
+            '1.1.3' : { 'ca.filmaj.AndroidPlugin': '<5.0.0 || >2.3.0' },
+            '2.3.0' : { 'ca.filmaj.AndroidPlugin': '6.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPluginRequirement('6.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '2.0.0');
+    });
+
+    it('should respect cordova constraints', function(done) {
+        var testEngine = {
+            '0.0.0' : { 'cordova': '>1.0.0' },
+            '1.1.3' : { 'cordova': '<3.0.0 || >4.0.0' },
+            '2.3.0' : { 'cordova': '6.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getCordovaRequirement('6.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.1.0');
+    });
+
+    it('should not include pre-release versions', function(done) {
+        var testEngine = {
+            '0.0.0' : {},
+            '2.0.0' : { 'cordova-android': '>5.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('>5.0.0')
+        ]);
+
+        // Should not return 2.0.0-rc.2
+        testEngineWithProject(after, testEngine, '1.7.1');
+    });
+
+    it('should not fail if there is no engine in the npm info', function(done) {
+        plugin.getFetchVersion(project, {
+                version: '2.3.0',
+                name: 'test-plugin',
+                versions: testPluginVersions
+            }, cordovaVersion)
+        .then(function(toFetch) {
+            expect(toFetch).toBe(null);
+        })
+        .fail(getVersionErrorCallback).fin(done);
+    });
+
+    it('should not fail if there is no cordovaDependencies in the engines', function(done) {
+        var after = getWarningCheckCallback(done, []);
+
+        plugin.getFetchVersion(project, {
+                version: '2.3.0',
+                name: 'test-plugin',
+                versions: testPluginVersions,
+                engines: {
+                    'node': '>7.0.0',
+                    'npm': '~2.0.0'
+                }
+            }, cordovaVersion)
+        .then(function(toFetch) {
+            expect(toFetch).toBe(null);
+        })
+        .fail(getVersionErrorCallback).fin(after);
+    });
+
+    it('should handle extra whitespace', function(done) {
+        var testEngine = {
+            '  1.0.0    '   : {},
+            '2.0.0   '      : { ' cordova-android': '~5.0.0   ' },
+            ' <  1.0.0\t'   : { ' cordova-android  ': ' > 5.0.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('~5.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.7.1');
+    });
+
+    it('should ignore badly typed version requirement entries', function(done) {
+        var testEngine = {
+            '1.1.0' : ['cordova', '5.0.0'],
+            '1.3.0' : undefined,
+            '1.7.0' : null
+        };
+
+        var after = getWarningCheckCallback(done, []);
+
+        testEngineWithProject(after, testEngine, '2.3.0');
+    });
+
+    it('should ignore badly typed constraint entries', function(done) {
+        var testEngine = {
+            '0.0.2' : { 'cordova': 1 },
+            '0.7.0' : { 'cordova': {}},
+            '1.0.0' : { 'cordova': undefined},
+            '1.1.3' : { 8        : '5.0.0'},
+            '1.3.0' : { 'cordova': [] },
+            '1.7.1' : { 'cordova': null }
+        };
+
+        var after = getWarningCheckCallback(done, []);
+
+        testEngineWithProject(after, testEngine, '2.3.0');
+    });
+
+    it('should ignore bad semver versions', function(done) {
+        var testEngine = {
+            '0.0.0'         : { 'cordova-android': '5.0.0' },
+            'notAVersion'   : { 'cordova-android': '3.1.0' },
+            '^1.1.2'        : { 'cordova-android': '3.1.0' },
+            '<=1.3.0'       : { 'cordova-android': '3.1.0' },
+            '1.0'           : { 'cordova-android': '3.1.0' },
+            2               : { 'cordova-android': '3.1.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('5.0.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, null);
+    });
+
+    it('should not fail if there are bad semver versions', function(done) {
+        var testEngine = {
+            'notAVersion'   : { 'cordova-android': '3.1.0' },
+            '^1.1.2'        : { 'cordova-android': '3.1.0' },
+            '<=1.3.0'       : { 'cordova-android': '3.1.0' },
+            '1.0.0'         : { 'cordova-android': '~3'    },   // Good semver
+            '2.0.0'         : { 'cordova-android': '5.1.0' },   // Good semver
+            '1.0'           : { 'cordova-android': '3.1.0' },
+            2               : { 'cordova-android': '3.1.0' }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('5.1.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.7.1');
+    });
+
+    it('should properly warn about multiple unmet requirements', function(done) {
+        var testEngine = {
+            '1.7.0' : {
+                'cordova-android'           : '>5.1.0',
+                'ca.filmaj.AndroidPlugin'   : '3.1.0',
+                'cordova'                   : '3.4.2'
+            }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('>5.1.0'),
+            getPluginRequirement('3.1.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.3.0');
+    });
+
+    it('should properly warn about both unmet latest and upper bound requirements', function(done) {
+        var testEngine = {
+            '1.7.0' : { 'cordova-android': '>5.1.0' },
+            '<5.0.0': {
+                'cordova-android'           : '>7.1.0',
+                'ca.filmaj.AndroidPlugin'   : '3.1.0'
+            }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('>5.1.0 AND >7.1.0'),
+            getPluginRequirement('3.1.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, null);
+    });
+
+    it('should not warn about versions past latest', function(done) {
+        var testEngine = {
+            '1.7.0' : { 'cordova-android': '>5.1.0' },
+            '7.0.0': {
+                'cordova-android'           : '>7.1.0',
+                'ca.filmaj.AndroidPlugin'   : '3.1.0'
+            }
+        };
+
+        var after = getWarningCheckCallback(done, [
+            getPlatformRequirement('>5.1.0')
+        ]);
+
+        testEngineWithProject(after, testEngine, '1.3.0');
+    });
+
+    it('clean up after plugin fetch spec', function() {
+        removeTestProject();
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/45a235fa/cordova-lib/spec-cordova/util.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/util.spec.js b/cordova-lib/spec-cordova/util.spec.js
index 8a678c8..314de3b 100644
--- a/cordova-lib/spec-cordova/util.spec.js
+++ b/cordova-lib/spec-cordova/util.spec.js
@@ -24,6 +24,7 @@ var shell = require('shelljs'),
     fs = require('fs'),
     util = require('../src/cordova/util'),
     events = require('../cordova-lib').events,
+    helpers = require('./helpers'),
     temp = path.join(__dirname, '..', 'temp');
 
 var cwd = process.cwd();
@@ -143,6 +144,24 @@ describe('util module', function() {
             expect(res.indexOf('atari')).toEqual(-1);
         });
     });
+    describe('getInstalledPlatformsWithVersions method', function() {
+        afterEach(function() {
+            shell.rm('-rf', temp);
+        });
+        it('should get the supported platforms in the cordova project dir along with their reported versions', function(done) {
+            var platforms = path.join(temp, 'platforms');
+            var android = path.join(platforms, 'android');
+
+            shell.mkdir('-p', android);
+
+            shell.cp('-R',
+                path.join(__dirname, 'fixtures', 'platforms', helpers.testPlatform), platforms);
+            util.getInstalledPlatformsWithVersions(temp)
+            .then(function(platformMap) {
+                expect(platformMap['android']).toBe('3.1.0');
+            }).fin(done);
+        });
+    });
     describe('findPlugins method', function() {
         afterEach(function() {
             shell.rm('-rf', temp);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/45a235fa/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index d130772..1b745be 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -492,26 +492,21 @@ function check(hooksRunner, projectRoot) {
 }
 
 function list(hooksRunner, projectRoot, opts) {
-    var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
     return hooksRunner.fire('before_platform_ls', opts)
     .then(function() {
-        // Acquire the version number of each platform we have installed, and output that too.
-        return Q.all(platforms_on_fs.map(function(p) {
-            return superspawn.maybeSpawn(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
-            .then(function(v) {
-                if (!v) return p;
-                return p + ' ' + v;
-            }, function(v) {
-                return p + ' broken';
-            });
-        }));
-    }).then(function(platformsText) {
+        return cordova_util.getInstalledPlatformsWithVersions(projectRoot);
+    }).then(function(platformMap) {
+        var platformsText = [];
+        for (var plat in platformMap) {
+            platformsText.push(platformMap[plat] ? plat + ' ' + platformMap[plat] : plat);
+        }
+
         platformsText = addDeprecatedInformationToPlatforms(platformsText);
         var results = 'Installed platforms:\n  ' + platformsText.sort().join('\n  ') + '\n';
         var available = Object.keys(platforms).filter(hostSupports);
 
         available = available.filter(function(p) {
-            return platforms_on_fs.indexOf(p) < 0; // Only those not already installed.
+            return !platformMap[p]; // Only those not already installed.
         });
 
         available = available.map(function (p){

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/45a235fa/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index 35819c3..c5ead29 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -31,10 +31,14 @@ var cordova_util  = require('./util'),
     pluginMapper  = require('cordova-registry-mapper').newToOld,
     events        = require('cordova-common').events,
     metadata      = require('../plugman/util/metadata'),
+    registry      = require('../plugman/registry/registry'),
     chainMap      = require('../util/promise-util').Q_chainmap,
     pkgJson       = require('../../package.json'),
     opener        = require('opener');
 
+// For upper bounds in cordovaDependencies
+var UPPER_BOUND_REGEX = /^<\d+\.\d+\.\d+$/;
+
 // Returns a promise.
 module.exports = function plugin(command, targets, opts) {
     // CB-10519 wrap function code into promise so throwing error
@@ -121,32 +125,7 @@ module.exports = function plugin(command, targets, opts) {
                                 target = target.substring(0, target.length - 1);
                             }
 
-                            var parts = target.split('@');
-                            var id = parts[0];
-                            var version = parts[1];
-
-                            // If no version is specified, retrieve the version (or source) from config.xml
-                            if (!version && !cordova_util.isUrl(id) && !cordova_util.isDirectory(id)) {
-                                events.emit('verbose', 'no version specified, retrieving version from config.xml');
-                                var ver = getVersionFromConfigFile(id, cfg);
-
-                                if (cordova_util.isUrl(ver) || cordova_util.isDirectory(ver)) {
-                                    target = ver;
-                                } else {
-                                    //if version exists from config.xml, use that
-                                    if(ver) {
-                                        target = ver ? (id + '@' + ver) : target;
-                                    } else {
-                                        //fetch pinned version from cordova-lib
-                                        var pinnedVer = pkgJson.cordovaPlugins[id];
-                                        target = pinnedVer ? (id + '@' + pinnedVer) : target;
-                                    }
-                                }
-                            }
-
                             // Fetch the plugin first.
-                            events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
-
                             var fetchOptions = {
                                 searchpath: searchPath,
                                 noregistry: opts.noregistry,
@@ -157,7 +136,12 @@ module.exports = function plugin(command, targets, opts) {
                                 is_top_level: true
                             };
 
-                            return plugman.raw.fetch(target, pluginPath, fetchOptions)
+                            return determinePluginTarget(projectRoot, cfg, target, fetchOptions)
+                            .then(function(resolvedTarget) {
+                                target = resolvedTarget;
+                                events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
+                                return plugman.raw.fetch(target, pluginPath, fetchOptions);
+                            })
                             .then(function (directory) {
                                 return pluginInfoProvider.get(directory);
                             });
@@ -305,6 +289,51 @@ module.exports = function plugin(command, targets, opts) {
     });
 };
 
+function determinePluginTarget(projectRoot, cfg, target, fetchOptions) {
+    var parts = target.split('@');
+    var id = parts[0];
+    var version = parts[1];
+
+    if (version || cordova_util.isUrl(id) || cordova_util.isDirectory(id)) {
+        return Q(target);
+    }
+
+    // If no version is specified, retrieve the version (or source) from config.xml
+    events.emit('verbose', 'No version specified, retrieving version from config.xml');
+    var ver = getVersionFromConfigFile(id, cfg);
+
+    if (cordova_util.isUrl(ver) || cordova_util.isDirectory(ver)) {
+        return Q(ver);
+    }
+
+    // If version exists in config.xml, use that
+    if (ver) {
+        return Q(id + '@' + ver);
+    }
+
+    // If no version is given at all and we are fetching from npm, we
+    // can attempt to use the Cordova dependencies the plugin lists in
+    // their package.json
+    var shouldUseNpmInfo = !fetchOptions.searchpath && !fetchOptions.noregistry;
+
+    if(shouldUseNpmInfo) {
+        events.emit('verbose', 'No version given in config.xml, attempting to use plugin engine info');
+    }
+
+    return (shouldUseNpmInfo ? registry.info([id]) : Q({}))
+    .then(function(pluginInfo) {
+        return getFetchVersion(projectRoot, pluginInfo, pkgJson.version);
+    })
+    .then(function(fetchVersion) {
+        // Fallback to pinned version if available
+        fetchVersion = fetchVersion || pkgJson.cordovaPlugins[id];
+        return fetchVersion ? (id + '@' + fetchVersion) : target;
+    });
+}
+
+// Exporting for testing purposes
+module.exports.getFetchVersion = getFetchVersion;
+
 function validatePluginId(pluginId, installedPlugins) {
     if (installedPlugins.indexOf(pluginId) >= 0) {
         return pluginId;
@@ -395,10 +424,7 @@ function list(projectRoot, hooksRunner, opts) {
     var pluginsList = [];
     return hooksRunner.fire('before_plugin_ls', opts)
     .then(function() {
-        var pluginsDir = path.join(projectRoot, 'plugins');
-        // TODO: This should list based off of platform.json, not directories within plugins/
-        var pluginInfoProvider = new PluginInfoProvider();
-        return pluginInfoProvider.getAllWithinSearchPath(pluginsDir);
+        return getInstalledPlugins(projectRoot);
     })
     .then(function(plugins) {
         if (plugins.length === 0) {
@@ -445,6 +471,13 @@ function list(projectRoot, hooksRunner, opts) {
     });
 }
 
+function getInstalledPlugins(projectRoot) {
+    var pluginsDir = path.join(projectRoot, 'plugins');
+    // TODO: This should list based off of platform.json, not directories within plugins/
+    var pluginInfoProvider = new PluginInfoProvider();
+    return pluginInfoProvider.getAllWithinSearchPath(pluginsDir);
+}
+
 function saveToConfigXmlOn(config_json, options){
     options = options || {};
     var autosave =  config_json.auto_save_plugins || false;
@@ -512,3 +545,234 @@ function versionString(version) {
 
     return null;
 }
+
+/**
+ * Gets the version of a plugin that should be fetched for a given project based
+ * on the plugin's engine information from NPM and the platforms/plugins installed
+ * in the project. The cordovaDependencies object in the package.json's engines
+ * entry takes the form of an object that maps plugin versions to a series of
+ * constraints and semver ranges. For example:
+ *
+ *     { plugin-version: { constraint: semver-range, ...}, ...}
+ *
+ * Constraint can be a plugin, platform, or cordova version. Plugin-version
+ * can be either a single version (e.g. 3.0.0) or an upper bound (e.g. <3.0.0)
+ *
+ * @param {string}  projectRoot     The path to the root directory of the project
+ * @param {object}  pluginInfo      The NPM info of the plugin to be fetched (e.g. the
+ *                                  result of calling `registry.info()`)
+ * @param {string}  cordovaVersion  The semver version of cordova-lib
+ *
+ * @return {Promise}                A promise that will resolve to either a string
+ *                                  if there is a version of the plugin that this
+ *                                  project satisfies or null if there is not
+ */
+function getFetchVersion(projectRoot, pluginInfo, cordovaVersion) {
+    // Figure out the project requirements
+    if (pluginInfo.engines && pluginInfo.engines.cordovaDependencies) {
+        var pluginList = getInstalledPlugins(projectRoot);
+        var pluginMap = {};
+
+        pluginList.forEach(function(plugin) {
+            pluginMap[plugin.id] = plugin.version;
+        });
+
+        return cordova_util.getInstalledPlatformsWithVersions(projectRoot)
+        .then(function(platformVersions) {
+            return determinePluginVersionToFetch(
+                pluginInfo,
+                pluginMap,
+                platformVersions,
+                cordovaVersion);
+        });
+    } else {
+        // If we have no engine, we want to fall back to the default behavior
+        events.emit('verbose', 'No plugin engine info found or not using registry, falling back to latest or pinned version');
+        return Q(null);
+    }
+}
+
+function findVersion(versions, version) {
+    var cleanedVersion = semver.clean(version);
+    for(var i = 0; i < versions.length; i++) {
+        if(semver.clean(versions[i]) === cleanedVersion) {
+            return versions[i];
+        }
+    }
+    return null;
+}
+
+/*
+ * The engine entry maps plugin versions to constraints like so:
+ *  {
+ *      '1.0.0' : { 'cordova': '<5.0.0' },
+ *      '<2.0.0': {
+ *          'cordova': '>=5.0.0',
+ *          'cordova-ios': '~5.0.0',
+ *          'cordova-plugin-camera': '~5.0.0'
+ *      },
+ *      '3.0.0' : { 'cordova-ios': '>5.0.0' }
+ *  }
+ *
+ * See cordova-spec/plugin_fetch.spec.js for test cases and examples
+ */
+function determinePluginVersionToFetch(pluginInfo, pluginMap, platformMap, cordovaVersion) {
+    var allVersions = pluginInfo.versions;
+    var engine = pluginInfo.engines.cordovaDependencies;
+    var name = pluginInfo.name;
+
+    // Filters out pre-release versions
+    var latest = semver.maxSatisfying(allVersions, '>=0.0.0');
+
+    var versions = [];
+    var upperBound = null;
+    var upperBoundRange = null;
+    var upperBoundExists = false;
+
+    for(var version in engine) {
+        if(semver.valid(semver.clean(version)) && !semver.gt(version, latest)) {
+            versions.push(version);
+        } else {
+            // Check if this is an upperbound; validRange() handles whitespace
+            var cleanedRange = semver.validRange(version);
+            if(cleanedRange && UPPER_BOUND_REGEX.exec(cleanedRange)) {
+                upperBoundExists = true;
+                // We only care about the highest upper bound that our project does not support
+                if(getFailedRequirements(engine[version], pluginMap, platformMap, cordovaVersion).length !== 0) {
+                    var maxMatchingUpperBound = cleanedRange.substring(1);
+                    if (maxMatchingUpperBound && (!upperBound || semver.gt(maxMatchingUpperBound, upperBound))) {
+                        upperBound = maxMatchingUpperBound;
+                        upperBoundRange = version;
+                    }
+                }
+            } else {
+                events.emit('verbose', 'Ignoring invalid version in ' + name + ' cordovaDependencies: ' + version + ' (must be a single version <= latest or an upper bound)');
+            }
+        }
+    }
+
+    // If there were no valid requirements, we fall back to old behavior
+    if(!upperBoundExists && versions.length === 0) {
+        events.emit('verbose', 'Ignoring ' + name + ' cordovaDependencies entry because it did not contain any valid plugin version entries');
+        return null;
+    }
+
+    // Handle the lower end of versions by giving them a satisfied engine
+    if(!findVersion(versions, '0.0.0')) {
+        versions.push('0.0.0');
+        engine['0.0.0'] = {};
+    }
+
+    // Add an entry after the upper bound to handle the versions above the
+    // upper bound but below the next entry. For example: 0.0.0, <1.0.0, 2.0.0
+    // needs a 1.0.0 entry that has the same engine as 0.0.0
+    if(upperBound && !findVersion(versions, upperBound) && !semver.gt(upperBound, latest)) {
+        versions.push(upperBound);
+        var below = semver.maxSatisfying(versions, upperBoundRange);
+
+        // Get the original entry without trimmed whitespace
+        below = below ? findVersion(versions, below) : null;
+        engine[upperBound] = below ? engine[below] : {};
+    }
+
+    // Sort in descending order; we want to start at latest and work back
+    versions.sort(semver.rcompare);
+
+    for(var i = 0; i < versions.length; i++) {
+        if(upperBound && semver.lt(versions[i], upperBound)) {
+            // Because we sorted in desc. order, if the upper bound we found
+            // applies to this version (and thus the ones below) we can just
+            // quit
+            break;
+        }
+
+        var range = i? ('>=' + versions[i] + ' <' + versions[i-1]) : ('>=' + versions[i]);
+        var maxMatchingVersion = semver.maxSatisfying(allVersions, range);
+
+        if (maxMatchingVersion && getFailedRequirements(engine[versions[i]], pluginMap, platformMap, cordovaVersion).length === 0) {
+
+            // Because we sorted in descending order, we can stop searching once
+            // we hit a satisfied constraint
+            if (maxMatchingVersion !== latest) {
+                var failedReqs = getFailedRequirements(engine[versions[0]], pluginMap, platformMap, cordovaVersion);
+
+                // Warn the user that we are not fetching latest
+                listUnmetRequirements(name, failedReqs);
+                events.emit('warn', 'Fetching highest version of ' + name + ' that this project supports: ' + maxMatchingVersion + ' (latest is ' + latest + ')');
+            }
+            return maxMatchingVersion;
+        }
+    }
+
+    // No version of the plugin is satisfied. In this case, we fall back to
+    // fetching latest or pinned versions, but also output a warning
+    var latestFailedReqs = versions.length > 0 ? getFailedRequirements(engine[versions[0]], pluginMap, platformMap, cordovaVersion) : [];
+
+    // If the upper bound is greater than latest, we need to combine its engine
+    // requirements with latest to print out in the warning
+    if(upperBound && semver.satisfies(latest, upperBoundRange)) {
+        var upperFailedReqs = getFailedRequirements(engine[upperBoundRange], pluginMap, platformMap, cordovaVersion);
+        upperFailedReqs.forEach(function(failedReq) {
+            for(var i = 0; i < latestFailedReqs.length; i++) {
+                if(latestFailedReqs[i].dependency === failedReq.dependency) {
+                    // Not going to overcomplicate things and actually merge the ranges
+                    latestFailedReqs[i].required += ' AND ' + failedReq.required;
+                    return;
+                }
+            }
+
+            // There is no req to merge it with
+            latestFailedReqs.push(failedReq);
+        });
+    }
+
+    listUnmetRequirements(name, latestFailedReqs);
+    events.emit('warn', 'Current project does not satisfy the engine requirements specified by any version of ' + name + '. Fetching latest or pinned version of plugin anyway (may be incompatible)');
+
+    // No constraints were satisfied
+    return null;
+}
+
+
+function getFailedRequirements(reqs, pluginMap, platformMap, cordovaVersion) {
+    var failed = [];
+
+    for (var req in reqs) {
+        if(reqs.hasOwnProperty(req) && typeof req === 'string' && semver.validRange(reqs[req])) {
+            var badInstalledVersion = null;
+            var trimmedReq = req.trim();
+
+            if(pluginMap[trimmedReq] && !semver.satisfies(pluginMap[trimmedReq], reqs[req])) {
+                badInstalledVersion = pluginMap[req];
+            } else if(trimmedReq === 'cordova' && !semver.satisfies(cordovaVersion, reqs[req])) {
+                badInstalledVersion = cordovaVersion;
+            } else if(trimmedReq.indexOf('cordova-') === 0) {
+                // Might be a platform constraint
+                var platform = trimmedReq.substring(8);
+                if(platformMap[platform] && !semver.satisfies(platformMap[platform], reqs[req])) {
+                    badInstalledVersion = platformMap[platform];
+                }
+            }
+
+            if(badInstalledVersion) {
+                failed.push({
+                    dependency: trimmedReq,
+                    installed: badInstalledVersion.trim(),
+                    required: reqs[req].trim()
+                });
+            }
+        } else {
+            events.emit('verbose', 'Ignoring invalid plugin dependency constraint ' + req + ':' + reqs[req]);
+        }
+    }
+
+    return failed;
+}
+
+function listUnmetRequirements(name, failedRequirements) {
+    events.emit('warn', 'Unmet project requirements for latest version of ' + name + ':');
+
+    failedRequirements.forEach(function(req) {
+        events.emit('warn', '    ' + req.dependency + ' (' + req.installed + ' installed, ' + req.required + ' required)');
+    });
+}

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/45a235fa/cordova-lib/src/cordova/util.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/util.js b/cordova-lib/src/cordova/util.js
index 2cba201..0f533f5 100644
--- a/cordova-lib/src/cordova/util.js
+++ b/cordova-lib/src/cordova/util.js
@@ -27,7 +27,8 @@ var fs            = require('fs'),
     npm           = require('npm'),
     nopt          = require('nopt'),
     Q             = require('q'),
-    semver        = require('semver');
+    semver        = require('semver'),
+    superspawn    = require('cordova-common').superspawn;
 
 // Global configuration paths
 var global_config_path = process.env['CORDOVA_HOME'];
@@ -63,6 +64,7 @@ exports.isDirectory = isDirectory;
 exports.isUrl = isUrl;
 exports.getLatestMatchingNpmVersion = getLatestMatchingNpmVersion;
 exports.getAvailableNpmVersions = getAvailableNpmVersions;
+exports.getInstalledPlatformsWithVersions = getInstalledPlatformsWithVersions;
 
 function isUrl(value) {
     var u = value && url.parse(value);
@@ -185,6 +187,22 @@ function listPlatforms(project_dir) {
     });
 }
 
+function getInstalledPlatformsWithVersions(project_dir) {
+    var result = {};
+    var platforms_on_fs = listPlatforms(project_dir);
+
+    return Q.all(platforms_on_fs.map(function(p) {
+        return superspawn.maybeSpawn(path.join(project_dir, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
+        .then(function(v) {
+            result[p] = v || null;
+        }, function(v) {
+            result[p] = 'broken';
+        });
+    })).then(function() {
+        return result;
+    });
+}
+
 // list the directories in the path, ignoring any files
 function findPlugins(pluginPath) {
     var plugins = [],

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/45a235fa/cordova-lib/src/plugman/registry/registry.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/registry/registry.js b/cordova-lib/src/plugman/registry/registry.js
index fd633ab..08562d8 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -89,20 +89,18 @@ module.exports = {
      */
     info: function(plugin) {
         plugin = plugin.shift();
-        return (Q.nbind(npm.load, npm))
-        .then(function() {
-            // Set cache timout limits to 0 to force npm to call the registry
-            // even when it has a recent .cache.json file.
-            npm.config.set('cache-min', 0);
-            npm.config.set('cache-max', 0);
-            return Q.ninvoke(npm.commands, 'view', [plugin], /* silent = */ true );
-        })
-        .then(function(info) {
-            // Plugin info should be accessed as info[version]. If a version
-            // specifier like >=x.y.z was used when calling npm view, info
-            // can contain several versions, but we take the first one here.
-            var version = Object.keys(info)[0];
-            return info[version];
+        return npmhelper.loadWithSettingsThenRestore({
+            'cache-min': 0,
+            'cache-max': 0
+        }, function() {
+            return Q.ninvoke(npm.commands, 'view', [plugin], /* silent = */ true )
+            .then(function(info) {
+                // Plugin info should be accessed as info[version]. If a version
+                // specifier like >=x.y.z was used when calling npm view, info
+                // can contain several versions, but we take the first one here.
+                var version = Object.keys(info)[0];
+                return info[version];
+            });
         });
     }
 };


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


[30/37] cordova-lib git commit: CB-10694 - Update test to reflect merging of CB-9264 fix (removal of duplicate entries)

Posted by st...@apache.org.
CB-10694 - Update test to reflect merging of CB-9264 fix (removal of duplicate entries)


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

Branch: refs/heads/common-1.1.x
Commit: c9b0423769005ca3591ebd90cfe77168148787e0
Parents: 4d4fbac
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Mar 16 16:45:04 2016 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Mar 16 16:45:04 2016 -0700

----------------------------------------------------------------------
 cordova-common/spec/util/xml-helpers.spec.js | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/c9b04237/cordova-common/spec/util/xml-helpers.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/util/xml-helpers.spec.js b/cordova-common/spec/util/xml-helpers.spec.js
index 2138f5c..b0083fd 100644
--- a/cordova-common/spec/util/xml-helpers.spec.js
+++ b/cordova-common/spec/util/xml-helpers.spec.js
@@ -304,9 +304,8 @@ describe('xml-helpers', function(){
             );
             xml_helpers.mergeXml(testXml, dstXml, 'ios');
             var testElements = dstXml.findall('preference[@name="Orientation"]');
-            expect(testElements.length).toEqual(2);
-            expect(testElements[0].attrib.value).toEqual('default');
-            expect(testElements[1].attrib.value).toEqual('all');
+            expect(testElements.length).toEqual(1);
+            expect(testElements[0].attrib.value).toEqual('all');
         });
     });
 });


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


[02/37] cordova-lib git commit: CB-10550 Fix plugin id mapper not enforced when a version is specified

Posted by st...@apache.org.
CB-10550 Fix plugin id mapper not enforced when a version is specified


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

Branch: refs/heads/common-1.1.x
Commit: 87d8e171a1f0eaa252d6d2510190b51bd56d48ae
Parents: 69178cf
Author: Byoungro So <by...@intel.com>
Authored: Sun Feb 14 12:52:10 2016 -0800
Committer: Tim Barham <ti...@microsoft.com>
Committed: Wed Feb 17 13:48:14 2016 +1000

----------------------------------------------------------------------
 cordova-lib/src/plugman/fetch.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/87d8e171/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index dc8e28c..8a48626 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -132,10 +132,14 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
                 ));
             }
             // If not found in local search path, fetch from the registry.
-            var newID = pluginMapperotn[plugin_src];
+            var splitVersion = plugin_src.split('@');
+            var newID = pluginMapperotn[splitVersion[0]];
             if(newID) {
-                events.emit('warn', 'Notice: ' + plugin_src + ' has been automatically converted to ' + newID + ' to be fetched from npm. This is due to our old plugins registry shutting down.');                
+                events.emit('warn', 'Notice: ' + splitVersion[0] + ' has been automatically converted to ' + newID + ' to be fetched from npm. This is due to our old plugins registry shutting down.');
                 plugin_src = newID;
+                if (splitVersion[1]) {
+                    plugin_src += '@'+splitVersion[1];
+                }
             } 
             return registry.fetch([plugin_src])
             .fail(function (error) {


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


[07/37] cordova-lib git commit: CB-10519 Wrap all sync calls inside of `cordova.raw` methods into promises

Posted by st...@apache.org.
CB-10519 Wrap all sync calls inside of `cordova.raw` methods into promises


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

Branch: refs/heads/common-1.1.x
Commit: 4121b11f050d8421ccd42a55ed21a0474039439a
Parents: b04db5f
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Wed Feb 10 15:45:19 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Fri Feb 19 14:06:11 2016 +0300

----------------------------------------------------------------------
 cordova-lib/spec-cordova/build.spec.js   |   6 +-
 cordova-lib/spec-cordova/compile.spec.js |  30 +-
 cordova-lib/spec-cordova/emulate.spec.js |  33 +-
 cordova-lib/spec-cordova/prepare.spec.js |   4 +-
 cordova-lib/src/cordova/build.js         |  29 +-
 cordova-lib/src/cordova/clean.js         |  31 +-
 cordova-lib/src/cordova/compile.js       |  89 ++---
 cordova-lib/src/cordova/emulate.js       |  38 +-
 cordova-lib/src/cordova/platform.js      | 121 +++----
 cordova-lib/src/cordova/plugin.js        | 480 +++++++++++++-------------
 cordova-lib/src/cordova/prepare.js       |  56 +--
 cordova-lib/src/cordova/requirements.js  |  30 +-
 cordova-lib/src/cordova/run.js           |  99 +++---
 cordova-lib/src/cordova/serve.js         |  41 +--
 14 files changed, 567 insertions(+), 520 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/spec-cordova/build.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/build.spec.js b/cordova-lib/spec-cordova/build.spec.js
index f5f1b2b..66f0869 100644
--- a/cordova-lib/spec-cordova/build.spec.js
+++ b/cordova-lib/spec-cordova/build.spec.js
@@ -40,7 +40,8 @@ describe('build command', function() {
     describe('failure', function() {
         it('should not run inside a project with no platforms', function(done) {
             list_platforms.andReturn([]);
-            Q().then(cordova.raw.build).then(function() {
+            cordova.raw.build()
+            .then(function() {
                 expect('this call').toBe('fail');
             }, function(err) {
                 expect(err.message).toEqual(
@@ -52,7 +53,8 @@ describe('build command', function() {
         it('should not run outside of a Cordova-based project', function(done) {
             is_cordova.andReturn(false);
 
-            Q().then(cordova.raw.build).then(function() {
+            cordova.raw.build()
+            .then(function() {
                 expect('this call').toBe('fail');
             }, function(err) {
                 expect(err.message).toEqual(

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/spec-cordova/compile.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/compile.spec.js b/cordova-lib/spec-cordova/compile.spec.js
index 7f4e8f6..9f4040f 100644
--- a/cordova-lib/spec-cordova/compile.spec.js
+++ b/cordova-lib/spec-cordova/compile.spec.js
@@ -26,16 +26,9 @@ var supported_platforms = Object.keys(platforms).filter(function(p) { return p !
 
 
 describe('compile command', function() {
-    var is_cordova, list_platforms, fire, result, cd_project_root, fail, platformApi, getPlatformApi;
+    var is_cordova, list_platforms, fire, cd_project_root, fail, platformApi, getPlatformApi;
     var project_dir = '/some/path';
 
-    function wrapper(f, post) {
-        runs(function() {
-            Q().then(f).then(function() { result = true; }, function(err) { result = err; });
-        });
-        waitsFor(function() { return result; }, 'promise never resolved', 500);
-        runs(post);
-    }
     beforeEach(function() {
         is_cordova = spyOn(util, 'isCordova').andReturn(project_dir);
         cd_project_root = spyOn(util, 'cdProjectRoot').andReturn(project_dir);
@@ -46,16 +39,29 @@ describe('compile command', function() {
         fail = function (err) { expect(err.stack).not.toBeDefined(); };
     });
     describe('failure', function() {
-        it('should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function() {
+        it('should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function(done) {
             list_platforms.andReturn([]);
-            wrapper(cordova.raw.compile, function() {
+            var success = jasmine.createSpy('success');
+            cordova.raw.compile()
+            .then(success, function(result) {
+                expect(result instanceof Error).toBe(true);
                 expect('' + result).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');
+            })
+            .fin(function() {
+                expect(success).not.toHaveBeenCalled();
+                done();
             });
         });
-        it('should not run outside of a Cordova-based project', function() {
+        it('should not run outside of a Cordova-based project', function(done) {
             is_cordova.andReturn(false);
-            wrapper(cordova.raw.compile, function() {
+            var success = jasmine.createSpy('success');
+            cordova.raw.compile()
+            .then(success, function(result) {
                 expect(result instanceof Error).toBe(true);
+            })
+            .fin(function() {
+                expect(success).not.toHaveBeenCalled();
+                done();
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/spec-cordova/emulate.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/emulate.spec.js b/cordova-lib/spec-cordova/emulate.spec.js
index 5cea968..3f9b093 100644
--- a/cordova-lib/spec-cordova/emulate.spec.js
+++ b/cordova-lib/spec-cordova/emulate.spec.js
@@ -25,18 +25,10 @@ var cordova = require('../src/cordova/cordova'),
 var supported_platforms = Object.keys(platforms).filter(function(p) { return p != 'www'; });
 
 describe('emulate command', function() {
-    var is_cordova, cd_project_root, list_platforms, fire, result, fail;
+    var is_cordova, cd_project_root, list_platforms, fire, fail;
     var project_dir = '/some/path';
     var prepare_spy, platformApi, getPlatformApi;
 
-    function wrapper(f, post) {
-        runs(function() {
-            Q().then(f).then(function() { result = true; }, function(err) { result = err; });
-        });
-        waitsFor(function() { return result; }, 'promise never resolved', 500);
-        runs(post);
-    }
-
     beforeEach(function() {
         is_cordova = spyOn(util, 'isCordova').andReturn(project_dir);
         cd_project_root = spyOn(util, 'cdProjectRoot').andReturn(project_dir);
@@ -48,16 +40,29 @@ describe('emulate command', function() {
         getPlatformApi = spyOn(platforms, 'getPlatformApi').andReturn(platformApi);
     });
     describe('failure', function() {
-        it('should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function() {
+        it('should not run inside a Cordova-based project with no added platforms by calling util.listPlatforms', function(done) {
             list_platforms.andReturn([]);
-            wrapper(cordova.raw.emulate, function() {
-                expect(''+ result).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');
+            var success = jasmine.createSpy('success');
+            cordova.raw.compile()
+            .then(success, function(result) {
+                expect(result instanceof Error).toBe(true);
+                expect('' + result).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');
+            })
+            .fin(function() {
+                expect(success).not.toHaveBeenCalled();
+                done();
             });
         });
-        it('should not run outside of a Cordova-based project', function() {
+        it('should not run outside of a Cordova-based project', function(done) {
             is_cordova.andReturn(false);
-            wrapper(cordova.raw.emulate, function() {
+            var success = jasmine.createSpy('success');
+            cordova.raw.compile()
+            .then(success, function(result) {
                 expect(result instanceof Error).toBe(true);
+            })
+            .fin(function() {
+                expect(success).not.toHaveBeenCalled();
+                done();
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/spec-cordova/prepare.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/prepare.spec.js b/cordova-lib/spec-cordova/prepare.spec.js
index e475dce..f01634f 100644
--- a/cordova-lib/spec-cordova/prepare.spec.js
+++ b/cordova-lib/spec-cordova/prepare.spec.js
@@ -95,7 +95,7 @@ describe('prepare command', function() {
         it('should not run outside of a cordova-based project by calling util.isCordova', function(done) {
             is_cordova.andReturn(false);
             cd_project_root.andCallThrough();  // undo spy here because prepare depends on cdprojectRoot for isCordova check
-            Q().then(prepare).then(function() {
+            prepare().then(function() {
                 expect('this call').toBe('fail');
             }, function(err) {
                 expect('' + err).toContain('Current working directory is not a Cordova-based project.');
@@ -103,7 +103,7 @@ describe('prepare command', function() {
         });
         it('should not run inside a cordova-based project with no platforms', function(done) {
             list_platforms.andReturn([]);
-            Q().then(prepare).then(function() {
+            prepare().then(function() {
                 expect('this call').toBe('fail');
             }, function(err) {
                 expect('' + err).toContain('No platforms added to this project. Please use `cordova platform add <platform>`.');

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/build.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/build.js b/cordova-lib/src/cordova/build.js
index d734d1a..fa3dca2 100644
--- a/cordova-lib/src/cordova/build.js
+++ b/cordova-lib/src/cordova/build.js
@@ -17,22 +17,25 @@
     under the License.
 */
 
-var cordovaUtil      = require('./util'),
-    HooksRunner           = require('../hooks/HooksRunner');
+var Q = require('q'),
+    cordovaUtil = require('./util'),
+    HooksRunner = require('../hooks/HooksRunner');
 
 // Returns a promise.
 module.exports = function build(options) {
-    var projectRoot = cordovaUtil.cdProjectRoot();
-    options = cordovaUtil.preProcessOptions(options);
+    return Q().then(function() {
+        var projectRoot = cordovaUtil.cdProjectRoot();
+        options = cordovaUtil.preProcessOptions(options);
 
-    // fire build hooks
-    var hooksRunner = new HooksRunner(projectRoot);
-    return hooksRunner.fire('before_build', options)
-    .then(function() {
-        return require('./cordova').raw.prepare(options);
-    }).then(function() {
-        return require('./cordova').raw.compile(options);
-    }).then(function() {
-        return hooksRunner.fire('after_build', options);
+        // fire build hooks
+        var hooksRunner = new HooksRunner(projectRoot);
+        return hooksRunner.fire('before_build', options)
+        .then(function() {
+            return require('./cordova').raw.prepare(options);
+        }).then(function() {
+            return require('./cordova').raw.compile(options);
+        }).then(function() {
+            return hooksRunner.fire('after_build', options);
+        });
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/clean.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/clean.js b/cordova-lib/src/cordova/clean.js
index b91b941..4ed8962 100644
--- a/cordova-lib/src/cordova/clean.js
+++ b/cordova-lib/src/cordova/clean.js
@@ -17,7 +17,8 @@
     under the License.
 */
 
-var cordova_util = require('./util'),
+var Q = require('q'),
+    cordova_util = require('./util'),
     HooksRunner  = require('../hooks/HooksRunner'),
     events       = require('cordova-common').events,
     chain        = require('../util/promise-util').Q_chainmap,
@@ -25,20 +26,22 @@ var cordova_util = require('./util'),
 
 // Returns a promise.
 module.exports = function clean(options) {
-    var projectRoot = cordova_util.cdProjectRoot();
-    options = cordova_util.preProcessOptions(options);
+    return Q().then(function() {
+        var projectRoot = cordova_util.cdProjectRoot();
+        options = cordova_util.preProcessOptions(options);
 
-    var hooksRunner = new HooksRunner(projectRoot);
-    return hooksRunner.fire('before_clean', options)
-    .then(function () {
-        return chain(options.platforms, function (platform) {
-            events.emit('verbose', 'Running cleanup for ' + platform + ' platform.');
-            return platform_lib
-                .getPlatformApi(platform)
-                .clean();
+        var hooksRunner = new HooksRunner(projectRoot);
+        return hooksRunner.fire('before_clean', options)
+        .then(function () {
+            return chain(options.platforms, function (platform) {
+                events.emit('verbose', 'Running cleanup for ' + platform + ' platform.');
+                return platform_lib
+                    .getPlatformApi(platform)
+                    .clean();
+            });
+        })
+        .then(function() {
+            return hooksRunner.fire('after_clean', options);
         });
-    })
-    .then(function() {
-        return hooksRunner.fire('after_clean', options);
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/compile.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/compile.js b/cordova-lib/src/cordova/compile.js
index 5834925..e540c14 100644
--- a/cordova-lib/src/cordova/compile.js
+++ b/cordova-lib/src/cordova/compile.js
@@ -1,41 +1,48 @@
-/**
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-*/
-
-var cordova_util = require('./util'),
-    HooksRunner  = require('../hooks/HooksRunner'),
-    promiseUtil  = require('../util/promise-util'),
-    platform_lib = require('../platforms/platforms');
-
-// Returns a promise.
-module.exports = function compile(options) {
-    var projectRoot = cordova_util.cdProjectRoot();
-    options = cordova_util.preProcessOptions(options);
-
-    var hooksRunner = new HooksRunner(projectRoot);
-    return hooksRunner.fire('before_compile', options)
-    .then(function () {
-        return promiseUtil.Q_chainmap(options.platforms, function (platform) {
-            return platform_lib
-                .getPlatformApi(platform)
-                .build(options.options);
-        });
-    }).then(function() {
-        return hooksRunner.fire('after_compile', options);
-    });
-};
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+
+var cordova_util = require('./util'),
+    HooksRunner  = require('../hooks/HooksRunner'),
+    promiseUtil  = require('../util/promise-util'),
+    platform_lib = require('../platforms/platforms');
+
+// Returns a promise.
+module.exports = function compile(options) {
+    return Q().then(function() {
+        var projectRoot = cordova_util.cdProjectRoot();
+        options = cordova_util.preProcessOptions(options);
+
+        var hooksRunner = new HooksRunner(projectRoot);
+        return hooksRunner.fire('before_compile', options)
+        .then(function () {
+            return promiseUtil.Q_chainmap(options.platforms, function (platform) {
+                return platform_lib
+                    .getPlatformApi(platform)
+                    .build(options.options);
+            });
+        }).then(function() {
+            return hooksRunner.fire('after_compile', options);
+        }, function(error) {
+            events.emit('log', 'ERROR building one of the platforms: ' + error + '\nYou may not have the required environment or OS to build this project');
+            return Q.reject(error);
+        });
+    }).then(function() {
+        return hooksRunner.fire('after_compile', options);
+    });
+};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/emulate.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/emulate.js b/cordova-lib/src/cordova/emulate.js
index 62810fc..b2ac92b 100644
--- a/cordova-lib/src/cordova/emulate.js
+++ b/cordova-lib/src/cordova/emulate.js
@@ -24,24 +24,26 @@ var cordova_util = require('./util'),
 
 // Returns a promise.
 module.exports = function emulate(options) {
-    var projectRoot = cordova_util.cdProjectRoot();
-    options = cordova_util.preProcessOptions(options);
-    options.options.device = false;
-    options.options.emulator = true;
+    return Q().then(function() {
+        var projectRoot = cordova_util.cdProjectRoot();
+        options = cordova_util.preProcessOptions(options);
+        options.options.device = false;
+        options.options.emulator = true;
 
-    var hooksRunner = new HooksRunner(projectRoot);
-    return hooksRunner.fire('before_emulate', options)
-    .then(function() {
-        // Run a prepare first!
-        return require('./cordova').raw.prepare(options);
-    }).then(function() {
-        // Deploy in parallel (output gets intermixed though...)
-        return Q.all(options.platforms.map(function(platform) {
-            return platform_lib
-                .getPlatformApi(platform)
-                .run(options.options);
-        }));
-    }).then(function() {
-        return hooksRunner.fire('after_emulate', options);
+        var hooksRunner = new HooksRunner(projectRoot);
+        return hooksRunner.fire('before_emulate', options)
+        .then(function() {
+            // Run a prepare first!
+            return require('./cordova').raw.prepare(options);
+        }).then(function() {
+            // Deploy in parallel (output gets intermixed though...)
+            return Q.all(options.platforms.map(function(platform) {
+                return platform_lib
+                    .getPlatformApi(platform)
+                    .run(options.options);
+            }));
+        }).then(function() {
+            return hooksRunner.fire('after_emulate', options);
+        });
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index 96c5f2f..2dff594 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -541,66 +541,69 @@ function addDeprecatedInformationToPlatforms(platformsList){
 // Returns a promise.
 module.exports = platform;
 function platform(command, targets, opts) {
-    var projectRoot = cordova_util.cdProjectRoot();
-    var msg;
-    var hooksRunner = new HooksRunner(projectRoot);
-
-    if (arguments.length === 0) command = 'ls';
-
-    // Verify that targets look like platforms. Examples:
-    // - android
-    // - android@3.5.0
-    // - ../path/to/dir/with/platform/files
-    // - https://github.com/apache/cordova-android.git
-    if (targets) {
-        if (!(targets instanceof Array)) targets = [targets];
-        targets.forEach(function (t) {
-            // Trim the @version part if it's there.
-            var p = t.split('@')[0];
-            // OK if it's one of known platform names.
-            if (p in platforms) return;
-            // Not a known platform name, check if its a real path.
-            var pPath = path.resolve(t);
-            if (fs.existsSync(pPath)) return;
-
-            var msg;
-        // If target looks like a url, we will try cloning it with git
-            if (/[~:/\\.]/.test(t)) {
-                return;
-            } else {
-        // Neither path, git-url nor platform name - throw.
-                msg = 'Platform "' + t +
-                '" not recognized as a core cordova platform. See `' +
-                cordova_util.binname + ' platform list`.'
-                ;
-            }
-            throw new CordovaError(msg);
-        });
-    } else if (command == 'add' || command == 'rm') {
-        msg = 'You need to qualify `add` or `remove` with one or more platforms!';
-        return Q.reject(new CordovaError(msg));
-    }
-
+    // CB-10519 wrap function code into promise so throwing error
+    // would result in promise rejection instead of uncaught exception
+    return Q().then(function() {
+        var msg;
+        var projectRoot = cordova_util.cdProjectRoot();
+        var hooksRunner = new HooksRunner(projectRoot);
+
+        if (arguments.length === 0) command = 'ls';
+
+        // Verify that targets look like platforms. Examples:
+        // - android
+        // - android@3.5.0
+        // - ../path/to/dir/with/platform/files
+        // - https://github.com/apache/cordova-android.git
+        if (targets) {
+            if (!(targets instanceof Array)) targets = [targets];
+            targets.forEach(function (t) {
+                // Trim the @version part if it's there.
+                var p = t.split('@')[0];
+                // OK if it's one of known platform names.
+                if (p in platforms) return;
+                // Not a known platform name, check if its a real path.
+                var pPath = path.resolve(t);
+                if (fs.existsSync(pPath)) return;
+
+                var msg;
+                // If target looks like a url, we will try cloning it with git
+                if (/[~:/\\.]/.test(t)) {
+                    return;
+                } else {
+                    // Neither path, git-url nor platform name - throw.
+                    msg = 'Platform "' + t +
+                    '" not recognized as a core cordova platform. See `' +
+                    cordova_util.binname + ' platform list`.'
+                    ;
+                }
+                throw new CordovaError(msg);
+            });
+        } else if (command == 'add' || command == 'rm') {
+            msg = 'You need to qualify `add` or `remove` with one or more platforms!';
+            return Q.reject(new CordovaError(msg));
+        }
 
-    opts = opts || {};
-    opts.platforms = targets;
-
-    switch (command) {
-        case 'add':
-            return add(hooksRunner, projectRoot, targets, opts);
-        case 'rm':
-        case 'remove':
-            return remove(hooksRunner, projectRoot, targets, opts);
-        case 'update':
-        case 'up':
-            return update(hooksRunner, projectRoot, targets, opts);
-        case 'check':
-            return check(hooksRunner, projectRoot);
-        case 'save':
-            return save(hooksRunner, projectRoot, opts);
-        default:
-            return list(hooksRunner, projectRoot, opts);
-    }
+        opts = opts || {};
+        opts.platforms = targets;
+
+        switch (command) {
+            case 'add':
+                return add(hooksRunner, projectRoot, targets, opts);
+            case 'rm':
+            case 'remove':
+                return remove(hooksRunner, projectRoot, targets, opts);
+            case 'update':
+            case 'up':
+                return update(hooksRunner, projectRoot, targets, opts);
+            case 'check':
+                return check(hooksRunner, projectRoot);
+            case 'save':
+                return save(hooksRunner, projectRoot, opts);
+            default:
+                return list(hooksRunner, projectRoot, opts);
+        }
+    });
 }
 
 // Used to prevent attempts of installing platforms that are not supported on

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index d35e7a2..35819c3 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -37,268 +37,272 @@ var cordova_util  = require('./util'),
 
 // Returns a promise.
 module.exports = function plugin(command, targets, opts) {
-    var projectRoot = cordova_util.cdProjectRoot();
-
-    // Dance with all the possible call signatures we've come up over the time. They can be:
-    // 1. plugin() -> list the plugins
-    // 2. plugin(command, Array of targets, maybe opts object)
-    // 3. plugin(command, target1, target2, target3 ... )
-    // The targets are not really targets, they can be a mixture of plugins and options to be passed to plugman.
-
-    command = command || 'ls';
-    targets = targets || [];
-    opts = opts || {};
-    if ( opts.length ) {
-        // This is the case with multiple targets as separate arguments and opts is not opts but another target.
-        targets = Array.prototype.slice.call(arguments, 1);
-        opts = {};
-    }
-    if ( !Array.isArray(targets) ) {
-        // This means we had a single target given as string.
-        targets = [targets];
-    }
-    opts.options = opts.options || [];
-    opts.plugins = [];
-
-    // TODO: Otherwise HooksRunner will be Object instead of function when run from tests - investigate why
-    var HooksRunner = require('../hooks/HooksRunner');
-    var hooksRunner = new HooksRunner(projectRoot);
-    var config_json = config.read(projectRoot);
-    var platformList = cordova_util.listPlatforms(projectRoot);
-
-    // Massage plugin name(s) / path(s)
-    var pluginPath = path.join(projectRoot, 'plugins');
-    var plugins = cordova_util.findPlugins(pluginPath);
-    if (!targets || !targets.length) {
-        if (command == 'add' || command == 'rm') {
-            return Q.reject(new CordovaError('You need to qualify `'+cordova_util.binname+' plugin add` or `'+cordova_util.binname+' plugin remove` with one or more plugins!'));
-        } else {
-            targets = [];
+    // CB-10519 wrap function code into promise so throwing error
+    // would result in promise rejection instead of uncaught exception
+    return Q().then(function () {
+        var projectRoot = cordova_util.cdProjectRoot();
+
+        // Dance with all the possible call signatures we've come up over the time. They can be:
+        // 1. plugin() -> list the plugins
+        // 2. plugin(command, Array of targets, maybe opts object)
+        // 3. plugin(command, target1, target2, target3 ... )
+        // The targets are not really targets, they can be a mixture of plugins and options to be passed to plugman.
+
+        command = command || 'ls';
+        targets = targets || [];
+        opts = opts || {};
+        if ( opts.length ) {
+            // This is the case with multiple targets as separate arguments and opts is not opts but another target.
+            targets = Array.prototype.slice.call(arguments, 1);
+            opts = {};
         }
-    }
-
-    //Split targets between plugins and options
-    //Assume everything after a token with a '-' is an option
-    var i;
-    for (i = 0; i < targets.length; i++) {
-        if (targets[i].match(/^-/)) {
-            opts.options = targets.slice(i);
-            break;
-        } else {
-            opts.plugins.push(targets[i]);
+        if ( !Array.isArray(targets) ) {
+            // This means we had a single target given as string.
+            targets = [targets];
         }
-    }
-
-    switch(command) {
-        case 'add':
-            if (!targets || !targets.length) {
-                return Q.reject(new CordovaError('No plugin specified. Please specify a plugin to add. See `'+cordova_util.binname+' plugin search`.'));
+        opts.options = opts.options || [];
+        opts.plugins = [];
+
+        // TODO: Otherwise HooksRunner will be Object instead of function when run from tests - investigate why
+        var HooksRunner = require('../hooks/HooksRunner');
+        var hooksRunner = new HooksRunner(projectRoot);
+        var config_json = config.read(projectRoot);
+        var platformList = cordova_util.listPlatforms(projectRoot);
+
+        // Massage plugin name(s) / path(s)
+        var pluginPath = path.join(projectRoot, 'plugins');
+        var plugins = cordova_util.findPlugins(pluginPath);
+        if (!targets || !targets.length) {
+            if (command == 'add' || command == 'rm') {
+                return Q.reject(new CordovaError('You need to qualify `'+cordova_util.binname+' plugin add` or `'+cordova_util.binname+' plugin remove` with one or more plugins!'));
+            } else {
+                targets = [];
             }
+        }
 
-            var xml = cordova_util.projectConfig(projectRoot);
-            var cfg = new ConfigParser(xml);
-            var searchPath = config_json.plugin_search_path || [];
-            if (typeof opts.searchpath == 'string') {
-                searchPath = opts.searchpath.split(path.delimiter).concat(searchPath);
-            } else if (opts.searchpath) {
-                searchPath = opts.searchpath.concat(searchPath);
-            }
-            // Blank it out to appease unit tests.
-            if (searchPath.length === 0) {
-                searchPath = undefined;
+        //Split targets between plugins and options
+        //Assume everything after a token with a '-' is an option
+        var i;
+        for (i = 0; i < targets.length; i++) {
+            if (targets[i].match(/^-/)) {
+                opts.options = targets.slice(i);
+                break;
+            } else {
+                opts.plugins.push(targets[i]);
             }
+        }
 
-            opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
-            return hooksRunner.fire('before_plugin_add', opts)
-            .then(function() {
-                var pluginInfoProvider = new PluginInfoProvider();
-                return opts.plugins.reduce(function(soFar, target) {
-                    return soFar.then(function() {
-                        if (target[target.length - 1] == path.sep) {
-                            target = target.substring(0, target.length - 1);
-                        }
+        switch(command) {
+            case 'add':
+                if (!targets || !targets.length) {
+                    return Q.reject(new CordovaError('No plugin specified. Please specify a plugin to add. See `'+cordova_util.binname+' plugin search`.'));
+                }
 
-                        var parts = target.split('@');
-                        var id = parts[0];
-                        var version = parts[1];
-
-                        // If no version is specified, retrieve the version (or source) from config.xml
-                        if (!version && !cordova_util.isUrl(id) && !cordova_util.isDirectory(id)) {
-                            events.emit('verbose', 'no version specified, retrieving version from config.xml');
-                            var ver = getVersionFromConfigFile(id, cfg);
-
-                            if (cordova_util.isUrl(ver) || cordova_util.isDirectory(ver)) {
-                                target = ver;
-                            } else {
-                                //if version exists from config.xml, use that
-                                if(ver) {
-                                    target = ver ? (id + '@' + ver) : target;
+                var xml = cordova_util.projectConfig(projectRoot);
+                var cfg = new ConfigParser(xml);
+                var searchPath = config_json.plugin_search_path || [];
+                if (typeof opts.searchpath == 'string') {
+                    searchPath = opts.searchpath.split(path.delimiter).concat(searchPath);
+                } else if (opts.searchpath) {
+                    searchPath = opts.searchpath.concat(searchPath);
+                }
+                // Blank it out to appease unit tests.
+                if (searchPath.length === 0) {
+                    searchPath = undefined;
+                }
+
+                opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
+                return hooksRunner.fire('before_plugin_add', opts)
+                .then(function() {
+                    var pluginInfoProvider = new PluginInfoProvider();
+                    return opts.plugins.reduce(function(soFar, target) {
+                        return soFar.then(function() {
+                            if (target[target.length - 1] == path.sep) {
+                                target = target.substring(0, target.length - 1);
+                            }
+
+                            var parts = target.split('@');
+                            var id = parts[0];
+                            var version = parts[1];
+
+                            // If no version is specified, retrieve the version (or source) from config.xml
+                            if (!version && !cordova_util.isUrl(id) && !cordova_util.isDirectory(id)) {
+                                events.emit('verbose', 'no version specified, retrieving version from config.xml');
+                                var ver = getVersionFromConfigFile(id, cfg);
+
+                                if (cordova_util.isUrl(ver) || cordova_util.isDirectory(ver)) {
+                                    target = ver;
                                 } else {
-                                    //fetch pinned version from cordova-lib
-                                    var pinnedVer = pkgJson.cordovaPlugins[id];
-                                    target = pinnedVer ? (id + '@' + pinnedVer) : target;
+                                    //if version exists from config.xml, use that
+                                    if(ver) {
+                                        target = ver ? (id + '@' + ver) : target;
+                                    } else {
+                                        //fetch pinned version from cordova-lib
+                                        var pinnedVer = pkgJson.cordovaPlugins[id];
+                                        target = pinnedVer ? (id + '@' + pinnedVer) : target;
+                                    }
                                 }
                             }
-                        }
-
-                        // Fetch the plugin first.
-                        events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
-
-                        var fetchOptions = {
-                            searchpath: searchPath,
-                            noregistry: opts.noregistry,
-                            nohooks: opts.nohooks,
-                            link: opts.link,
-                            pluginInfoProvider: pluginInfoProvider,
-                            variables: opts.cli_variables,
-                            is_top_level: true
-                        };
-
-                        return plugman.raw.fetch(target, pluginPath, fetchOptions)
-                        .then(function (directory) {
-                            return pluginInfoProvider.get(directory);
-                        });
-                    })
-                    .then(function(pluginInfo) {
-                        // Validate top-level required variables
-                        var pluginVariables = pluginInfo.getPreferences();
-                        var missingVariables = Object.keys(pluginVariables)
-                        .filter(function (variableName) {
-                            // discard variables with default value
-                            return !(pluginVariables[variableName] || opts.cli_variables[variableName]);
-                        });
 
-                        if (missingVariables.length) {
-                            shell.rm('-rf', pluginInfo.dir);
-                            var msg = 'Variable(s) missing (use: --variable ' + missingVariables.join('=value --variable ') + '=value).';
-                            return Q.reject(new CordovaError(msg));
-                        }
+                            // Fetch the plugin first.
+                            events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
 
-                        // Iterate (in serial!) over all platforms in the project and install the plugin.
-                        return chainMap(platformList, function (platform) {
-                            var platformRoot = path.join(projectRoot, 'platforms', platform),
-                            options = {
-                                cli_variables: opts.cli_variables || {},
-                                browserify: opts.browserify || false,
+                            var fetchOptions = {
                                 searchpath: searchPath,
                                 noregistry: opts.noregistry,
+                                nohooks: opts.nohooks,
                                 link: opts.link,
                                 pluginInfoProvider: pluginInfoProvider,
-                                // Set up platform to install asset files/js modules to <platform>/platform_www dir
-                                // instead of <platform>/www. This is required since on each prepare platform's www dir is changed
-                                // and files from 'platform_www' merged into 'www'. Thus we need to persist these
-                                // files platform_www directory, so they'll be applied to www on each prepare.
-                                usePlatformWww: true,
-                                nohooks: opts.nohooks
+                                variables: opts.cli_variables,
+                                is_top_level: true
                             };
 
-                            events.emit('verbose', 'Calling plugman.install on plugin "' + pluginInfo.dir + '" for platform "' + platform);
-                            return plugman.raw.install(platform, platformRoot, path.basename(pluginInfo.dir), pluginPath, options);
+                            return plugman.raw.fetch(target, pluginPath, fetchOptions)
+                            .then(function (directory) {
+                                return pluginInfoProvider.get(directory);
+                            });
                         })
-                        .thenResolve(pluginInfo);
-                    })
-                    .then(function(pluginInfo){
-                        // save to config.xml
-                        if(saveToConfigXmlOn(config_json, opts)){
-                            var src = parseSource(target, opts);
-                            var attributes = {
-                                name: pluginInfo.id,
-                                spec: src ? src : '~' + pluginInfo.version
-                            };
+                        .then(function(pluginInfo) {
+                            // Validate top-level required variables
+                            var pluginVariables = pluginInfo.getPreferences();
+                            var missingVariables = Object.keys(pluginVariables)
+                            .filter(function (variableName) {
+                                // discard variables with default value
+                                return !(pluginVariables[variableName] || opts.cli_variables[variableName]);
+                            });
+
+                            if (missingVariables.length) {
+                                shell.rm('-rf', pluginInfo.dir);
+                                var msg = 'Variable(s) missing (use: --variable ' + missingVariables.join('=value --variable ') + '=value).';
+                                return Q.reject(new CordovaError(msg));
+                            }
 
-                            cfg.removePlugin(pluginInfo.id);
-                            cfg.addPlugin(attributes, opts.cli_variables);
-                            cfg.write();
+                            // Iterate (in serial!) over all platforms in the project and install the plugin.
+                            return chainMap(platformList, function (platform) {
+                                var platformRoot = path.join(projectRoot, 'platforms', platform),
+                                options = {
+                                    cli_variables: opts.cli_variables || {},
+                                    browserify: opts.browserify || false,
+                                    searchpath: searchPath,
+                                    noregistry: opts.noregistry,
+                                    link: opts.link,
+                                    pluginInfoProvider: pluginInfoProvider,
+                                    // Set up platform to install asset files/js modules to <platform>/platform_www dir
+                                    // instead of <platform>/www. This is required since on each prepare platform's www dir is changed
+                                    // and files from 'platform_www' merged into 'www'. Thus we need to persist these
+                                    // files platform_www directory, so they'll be applied to www on each prepare.
+                                    usePlatformWww: true,
+                                    nohooks: opts.nohooks
+                                };
+
+                                events.emit('verbose', 'Calling plugman.install on plugin "' + pluginInfo.dir + '" for platform "' + platform);
+                                return plugman.raw.install(platform, platformRoot, path.basename(pluginInfo.dir), pluginPath, options);
+                            })
+                            .thenResolve(pluginInfo);
+                        })
+                        .then(function(pluginInfo){
+                            // save to config.xml
+                            if(saveToConfigXmlOn(config_json, opts)){
+                                var src = parseSource(target, opts);
+                                var attributes = {
+                                    name: pluginInfo.id,
+                                    spec: src ? src : '~' + pluginInfo.version
+                                };
+
+                                cfg.removePlugin(pluginInfo.id);
+                                cfg.addPlugin(attributes, opts.cli_variables);
+                                cfg.write();
+
+                                events.emit('results', 'Saved plugin info for "' + pluginInfo.id + '" to config.xml');
+                            }
+                        });
+                    }, Q()); // end Q.all
+                }).then(function() {
+                    // Need to require right here instead of doing this at the beginning of file
+                    // otherwise tests are failing without any real reason.
+                    return require('./prepare').preparePlatforms(platformList, projectRoot, opts);
+                }).then(function() {
+                    opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
+                    return hooksRunner.fire('after_plugin_add', opts);
+                });
+            case 'rm':
+            case 'remove':
+                if (!targets || !targets.length) {
+                    return Q.reject(new CordovaError('No plugin specified. Please specify a plugin to remove. See `'+cordova_util.binname+' plugin list`.'));
+                }
 
-                            events.emit('results', 'Saved plugin info for "' + pluginInfo.id + '" to config.xml');
-                        }
-                    });
-                }, Q()); // end Q.all
-            }).then(function() {
-                // Need to require right here instead of doing this at the beginning of file
-                // otherwise tests are failing without any real reason.
-                return require('./prepare').preparePlatforms(platformList, projectRoot, opts);
-            }).then(function() {
                 opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
-                return hooksRunner.fire('after_plugin_add', opts);
-            });
-        case 'rm':
-        case 'remove':
-            if (!targets || !targets.length) {
-                return Q.reject(new CordovaError('No plugin specified. Please specify a plugin to remove. See `'+cordova_util.binname+' plugin list`.'));
-            }
-
-            opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
-            return hooksRunner.fire('before_plugin_rm', opts)
-            .then(function() {
-                return opts.plugins.reduce(function(soFar, target) {
-                    var validatedPluginId = validatePluginId(target, plugins);
-                    if (!validatedPluginId) {
-                        return Q.reject(new CordovaError('Plugin "' + target + '" is not present in the project. See `' + cordova_util.binname + ' plugin list`.'));
+                return hooksRunner.fire('before_plugin_rm', opts)
+                .then(function() {
+                    return opts.plugins.reduce(function(soFar, target) {
+                        var validatedPluginId = validatePluginId(target, plugins);
+                        if (!validatedPluginId) {
+                            return Q.reject(new CordovaError('Plugin "' + target + '" is not present in the project. See `' + cordova_util.binname + ' plugin list`.'));
+                        }
+                        target = validatedPluginId;
+
+                        // Iterate over all installed platforms and uninstall.
+                        // If this is a web-only or dependency-only plugin, then
+                        // there may be nothing to do here except remove the
+                        // reference from the platform's plugin config JSON.
+                        return platformList.reduce(function(soFar, platform) {
+                            return soFar.then(function() {
+                                var platformRoot = path.join(projectRoot, 'platforms', platform);
+                                events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
+                                return plugman.raw.uninstall.uninstallPlatform(platform, platformRoot, target, pluginPath);
+                            });
+                        }, Q())
+                        .then(function() {
+                            // TODO: Should only uninstallPlugin when no platforms have it.
+                            return plugman.raw.uninstall.uninstallPlugin(target, pluginPath);
+                        }).then(function(){
+                            //remove plugin from config.xml
+                            if(saveToConfigXmlOn(config_json, opts)){
+                                var configPath = cordova_util.projectConfig(projectRoot);
+                                if(fs.existsSync(configPath)){//should not happen with real life but needed for tests
+                                    var configXml = new ConfigParser(configPath);
+                                    configXml.removePlugin(target);
+                                    configXml.write();
+                                    events.emit('results', 'config.xml entry for ' +target+ ' is removed');
+                                }
+                            }
+                        })
+                        .then(function(){
+                            // Remove plugin from fetch.json
+                            events.emit('verbose', 'Removing plugin ' + target + ' from fetch.json');
+                            metadata.remove_fetch_metadata(pluginPath, target);
+                        });
+                    }, Q());
+                }).then(function () {
+                    return require('./prepare').preparePlatforms(platformList, projectRoot, opts);
+                }).then(function() {
+                    opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
+                    return hooksRunner.fire('after_plugin_rm', opts);
+                });
+            case 'search':
+                return hooksRunner.fire('before_plugin_search', opts)
+                .then(function() {
+                    var link = 'http://cordova.apache.org/plugins/';
+                    if (opts.plugins.length > 0) {
+                        var keywords = (opts.plugins).join(' ');
+                        var query = link + '?q=' + encodeURI(keywords);
+                        opener(query);
+                    }
+                    else {
+                        opener(link);
                     }
-                    target = validatedPluginId;
 
-                    // Iterate over all installed platforms and uninstall.
-                    // If this is a web-only or dependency-only plugin, then
-                    // there may be nothing to do here except remove the
-                    // reference from the platform's plugin config JSON.
-                    return platformList.reduce(function(soFar, platform) {
-                        return soFar.then(function() {
-                            var platformRoot = path.join(projectRoot, 'platforms', platform);
-                            events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
-                            return plugman.raw.uninstall.uninstallPlatform(platform, platformRoot, target, pluginPath);
-                        });
-                    }, Q())
-                    .then(function() {
-                        // TODO: Should only uninstallPlugin when no platforms have it.
-                        return plugman.raw.uninstall.uninstallPlugin(target, pluginPath);
-                    }).then(function(){
-                        //remove plugin from config.xml
-                        if(saveToConfigXmlOn(config_json, opts)){
-                            var configPath = cordova_util.projectConfig(projectRoot);
-                            if(fs.existsSync(configPath)){//should not happen with real life but needed for tests
-                                var configXml = new ConfigParser(configPath);
-                                configXml.removePlugin(target);
-                                configXml.write();
-                                events.emit('results', 'config.xml entry for ' +target+ ' is removed');
-                            }
-                        }
-                    })
-                    .then(function(){
-                        // Remove plugin from fetch.json
-                        events.emit('verbose', 'Removing plugin ' + target + ' from fetch.json');
-                        metadata.remove_fetch_metadata(pluginPath, target);
-                    });
-                }, Q());
-            }).then(function () {
-                return require('./prepare').preparePlatforms(platformList, projectRoot, opts);
-            }).then(function() {
-                opts.cordova = { plugins: cordova_util.findPlugins(pluginPath) };
-                return hooksRunner.fire('after_plugin_rm', opts);
-            });
-        case 'search':
-            return hooksRunner.fire('before_plugin_search', opts)
-            .then(function() {
-                var link = 'http://cordova.apache.org/plugins/';
-                if (opts.plugins.length > 0) {
-                    var keywords = (opts.plugins).join(' ');
-                    var query = link + '?q=' + encodeURI(keywords);
-                    opener(query);
-                }
-                else {
-                    opener(link);
-                }
-                
-                return Q.resolve();
-            }).then(function() {
-                return hooksRunner.fire('after_plugin_search', opts);
-            });
-        case 'save':
-            // save the versions/folders/git-urls of currently installed plugins into config.xml
-            return save(projectRoot, opts);
-        default:
-            return list(projectRoot, hooksRunner);
-    }
+                    return Q.resolve();
+                }).then(function() {
+                    return hooksRunner.fire('after_plugin_search', opts);
+                });
+            case 'save':
+                // save the versions/folders/git-urls of currently installed plugins into config.xml
+                return save(projectRoot, opts);
+            default:
+                return list(projectRoot, hooksRunner);
+        }
+    });
 };
 
 function validatePluginId(pluginId, installedPlugins) {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/prepare.js b/cordova-lib/src/cordova/prepare.js
index 2eea9f5..194122e 100644
--- a/cordova-lib/src/cordova/prepare.js
+++ b/cordova-lib/src/cordova/prepare.js
@@ -34,34 +34,36 @@ var cordova_util      = require('./util'),
 // Returns a promise.
 exports = module.exports = prepare;
 function prepare(options) {
-    var projectRoot = cordova_util.cdProjectRoot();
-    var config_json = config.read(projectRoot);
-    options = options || { verbose: false, platforms: [], options: {} };
-
-    var hooksRunner = new HooksRunner(projectRoot);
-    return hooksRunner.fire('before_prepare', options)
-    .then(function(){
-        return restore.installPlatformsFromConfigXML(options.platforms, { searchpath : options.searchpath });
-    })
-    .then(function(){
-        options = cordova_util.preProcessOptions(options);
-        var paths = options.platforms.map(function(p) {
-            var platform_path = path.join(projectRoot, 'platforms', p);
-            return platforms.getPlatformApi(p, platform_path).getPlatformInfo().locations.www;
-        });
-        options.paths = paths;
-    }).then(function() {
-        options = cordova_util.preProcessOptions(options);
-        options.searchpath = options.searchpath || config_json.plugin_search_path;
-        // Iterate over each added platform
-        return preparePlatforms(options.platforms, projectRoot, options);
-    }).then(function() {
-        options.paths = options.platforms.map(function(platform) {
-            return platforms.getPlatformApi(platform).getPlatformInfo().locations.www;
+    return Q().then(function() {
+        var projectRoot = cordova_util.cdProjectRoot();
+        var config_json = config.read(projectRoot);
+        options = options || { verbose: false, platforms: [], options: {} };
+
+        var hooksRunner = new HooksRunner(projectRoot);
+        return hooksRunner.fire('before_prepare', options)
+        .then(function(){
+            return restore.installPlatformsFromConfigXML(options.platforms, { searchpath : options.searchpath });
+        })
+        .then(function(){
+            options = cordova_util.preProcessOptions(options);
+            var paths = options.platforms.map(function(p) {
+                var platform_path = path.join(projectRoot, 'platforms', p);
+                return platforms.getPlatformApi(p, platform_path).getPlatformInfo().locations.www;
+            });
+            options.paths = paths;
+        }).then(function() {
+            options = cordova_util.preProcessOptions(options);
+            options.searchpath = options.searchpath || config_json.plugin_search_path;
+            // Iterate over each added platform
+            return preparePlatforms(options.platforms, projectRoot, options);
+        }).then(function() {
+            options.paths = options.platforms.map(function(platform) {
+                return platforms.getPlatformApi(platform).getPlatformInfo().locations.www;
+            });
+            return hooksRunner.fire('after_prepare', options);
+        }).then(function () {
+            return restore.installPluginsFromConfigXML(options);
         });
-        return hooksRunner.fire('after_prepare', options);
-    }).then(function () {
-        return restore.installPluginsFromConfigXML(options);
     });
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/requirements.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/requirements.js b/cordova-lib/src/cordova/requirements.js
index 3304636..0d8d543 100644
--- a/cordova-lib/src/cordova/requirements.js
+++ b/cordova-lib/src/cordova/requirements.js
@@ -32,20 +32,22 @@ var knownPlatforms = require('../platforms/platforms');
  *   requirements check results for each platform.
  */
 module.exports = function check_reqs(platforms) {
-    platforms = cordova_util.preProcessOptions(platforms).platforms;
+    return Q().then(function() {
+        var platforms = cordova_util.preProcessOptions(platforms).platforms;
 
-    return Q.allSettled(platforms.map(function (platform) {
-        return knownPlatforms.getPlatformApi(platform).requirements();
-    }))
-    .then(function (settledChecks) {
-        var res = {};
-        settledChecks.reduce(function (result, settledCheck, idx) {
-            var platformName = platforms[idx];
-            result[platformName] = settledCheck.state === 'fulfilled' ?
-                settledCheck.value :
-                new CordovaError(settledCheck.reason);
-            return result;
-        }, res);
-        return res;
+        return Q.allSettled(platforms.map(function (platform) {
+            return knownPlatforms.getPlatformApi(platform).requirements();
+        }))
+        .then(function (settledChecks) {
+            var res = {};
+            settledChecks.reduce(function (result, settledCheck, idx) {
+                var platformName = platforms[idx];
+                result[platformName] = settledCheck.state === 'fulfilled' ?
+                    settledCheck.value :
+                    new CordovaError(settledCheck.reason);
+                return result;
+            }, res);
+            return res;
+        });
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/run.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/run.js b/cordova-lib/src/cordova/run.js
index fcfc9c6..f2afeed 100644
--- a/cordova-lib/src/cordova/run.js
+++ b/cordova-lib/src/cordova/run.js
@@ -1,46 +1,53 @@
-/**
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-*/
-
-var cordova_util = require('./util'),
-    HooksRunner  = require('../hooks/HooksRunner'),
-    Q            = require('q'),
-    platform_lib = require('../platforms/platforms');
-
-
-// Returns a promise.
-module.exports = function run(options) {
-    var projectRoot = cordova_util.cdProjectRoot();
-    options = cordova_util.preProcessOptions(options);
-
-    var hooksRunner = new HooksRunner(projectRoot);
-    return hooksRunner.fire('before_run', options)
-    .then(function() {
-        // Run a prepare first, then shell out to run
-        return require('./cordova').raw.prepare(options);
-    }).then(function() {
-        // Deploy in parallel (output gets intermixed though...)
-        return Q.all(options.platforms.map(function(platform) {
-            return platform_lib
-                .getPlatformApi(platform)
-                .run(options.options);
-        }));
-    }).then(function() {
-        return hooksRunner.fire('after_run', options);
-    });
-};
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+
+var cordova_util = require('./util'),
+    HooksRunner  = require('../hooks/HooksRunner'),
+    Q            = require('q'),
+    platform_lib = require('../platforms/platforms');
+
+
+// Returns a promise.
+module.exports = function run(options) {
+    return Q().then(function() {
+        var projectRoot = cordova_util.cdProjectRoot();
+        options = cordova_util.preProcessOptions(options);
+
+        var hooksRunner = new HooksRunner(projectRoot);
+        return hooksRunner.fire('before_run', options)
+        .then(function() {
+            // Run a prepare first, then shell out to run
+            return require('./cordova').raw.prepare(options);
+        }).then(function() {
+            // Deploy in parallel (output gets intermixed though...)
+            return Q.all(options.platforms.map(function(platform) {
+                return platform_lib
+                    .getPlatformApi(platform)
+                    .run(options.options);
+            }));
+        }).then(function() {
+            return hooksRunner.fire('after_run', options);
+        }, function(error) {
+            events.emit('log', 'ERROR running one or more of the platforms: ' + error + '\nYou may not have the required environment or OS to run this project');
+
+            // CB-10567 bubble up `run` error, so the caller still could get rejected promise
+            return Q.reject(error);
+        });
+    });
+};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4121b11f/cordova-lib/src/cordova/serve.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/serve.js b/cordova-lib/src/cordova/serve.js
index 59eb3e9..e24e990 100644
--- a/cordova-lib/src/cordova/serve.js
+++ b/cordova-lib/src/cordova/serve.js
@@ -112,29 +112,30 @@ function calculateMd5(fileName) {
 }
 
 module.exports = function server(port, opts) {
-    var d = Q.defer();
-    projectRoot = cordova_util.cdProjectRoot();
     port = +port || 8000;
 
-    var hooksRunner = new HooksRunner(projectRoot);
-    hooksRunner.fire('before_serve', opts).then(function () {
-        // Run a prepare first!
-        return require('./cordova').raw.prepare([]);
-    }).then(function () {
-        var server = serve();
-
-        installedPlatforms = cordova_util.listPlatforms(projectRoot);
-        installedPlatforms.forEach(function (platform) {
-            var locations = platforms.getPlatformApi(platform).getPlatformInfo().locations;
-            server.app.use('/' + platform + '/www', serve.static(locations.www));
-            server.app.get('/' + platform + '/*', getPlatformHandler(platform, locations.www, locations.configXml));
-        });
-        server.app.get('*', handleRoot);
+    return Q.promise(function(resolve) {
+        projectRoot = cordova_util.cdProjectRoot();
+
+        var hooksRunner = new HooksRunner(projectRoot);
+        hooksRunner.fire('before_serve', opts).then(function () {
+            // Run a prepare first!
+            return require('./cordova').raw.prepare([]);
+        }).then(function () {
+            var server = serve();
+
+            installedPlatforms = cordova_util.listPlatforms(projectRoot);
+            installedPlatforms.forEach(function (platform) {
+                var locations = platforms.getPlatformApi(platform).getPlatformInfo().locations;
+                server.app.use('/' + platform + '/www', serve.static(locations.www));
+                server.app.get('/' + platform + '/*', getPlatformHandler(platform, locations.www, locations.configXml));
+            });
+            server.app.get('*', handleRoot);
 
-        server.launchServer({port: port, events: events});
-        hooksRunner.fire('after_serve', opts).then(function () {
-            d.resolve(server.server);
+            server.launchServer({port: port, events: events});
+            hooksRunner.fire('after_serve', opts).then(function () {
+                resolve(server.server);
+            });
         });
     });
-    return d.promise;
 };


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


[06/37] cordova-lib git commit: CB-10641 Adds tests for order of operations in platform add

Posted by st...@apache.org.
CB-10641 Adds tests for order of operations in platform add


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

Branch: refs/heads/common-1.1.x
Commit: b04db5feaf5516836c8a157cc3331b75d6dca0eb
Parents: 3b9face
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Thu Feb 18 13:08:47 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Thu Feb 18 13:09:02 2016 +0300

----------------------------------------------------------------------
 cordova-lib/spec-cordova/platform.spec.js | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b04db5fe/cordova-lib/spec-cordova/platform.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/platform.spec.js b/cordova-lib/spec-cordova/platform.spec.js
index de3631a..2c99b4a 100644
--- a/cordova-lib/spec-cordova/platform.spec.js
+++ b/cordova-lib/spec-cordova/platform.spec.js
@@ -26,6 +26,7 @@ var helpers = require('./helpers'),
     Q = require('q'),
     events = require('cordova-common').events,
     cordova = require('../src/cordova/cordova'),
+    plugman = require('../src/plugman/plugman'),
     rewire = require('rewire'),
     platform = rewire('../src/cordova/platform.js');
 
@@ -132,9 +133,6 @@ describe('platform end-to-end', function () {
         .then(function() {
             return cordova.raw.platform('add', [helpers.testPlatform]);
         })
-        .then(function () {
-            return cordova.raw.prepare([helpers.testPlatform]);
-        })
         .then(function() {
             // Check the platform add was successful.
             expect(path.join(project, 'platforms', helpers.testPlatform)).toExist();
@@ -146,6 +144,24 @@ describe('platform end-to-end', function () {
         })
         .fin(done);
     });
+
+    it('should call prepare after plugins were installed into platform', function(done) {
+        var order = '';
+        var fail = jasmine.createSpy(fail);
+        spyOn(plugman.raw, 'install').andCallFake(function() { order += 'I'; });
+        spyOn(cordova.raw, 'prepare').andCallFake(function() { order += 'P'; });
+
+        cordova.raw.plugin('add', path.join(pluginsDir, 'test'))
+        .then(function() {
+            return cordova.raw.platform('add', [helpers.testPlatform]);
+        })
+        .fail(fail)
+        .fin(function() {
+            expect(order).toBe('IP'); // Install first, then prepare
+            expect(fail).not.toHaveBeenCalled();
+            done();
+        });
+    });
 });
 
 describe('add function', function () {


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


[22/37] cordova-lib git commit: CB-10679: Improving version choosing logic test coverage

Posted by st...@apache.org.
CB-10679: Improving version choosing logic test coverage

This closes #406


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

Branch: refs/heads/common-1.1.x
Commit: 317cfdb374b9dfa215de77c617db0c373dc098c6
Parents: e740deb
Author: riknoll <ri...@gmail.com>
Authored: Mon Mar 7 16:10:22 2016 -0800
Committer: riknoll <ri...@gmail.com>
Committed: Wed Mar 9 09:39:48 2016 -0800

----------------------------------------------------------------------
 .../plugins/cordova-lib-test-plugin/LICENSE     | 202 +++++++++++++++++++
 .../plugins/cordova-lib-test-plugin/NOTICE      |   5 +
 .../cordova-lib-test-plugin/package.json        |  28 +++
 .../plugins/cordova-lib-test-plugin/plugin.xml  |   4 +
 cordova-lib/spec-cordova/plugin.spec.js         |  45 ++++-
 5 files changed, 280 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/317cfdb3/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/LICENSE
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/LICENSE b/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/LICENSE
new file mode 100644
index 0000000..9b5e401
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/317cfdb3/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/NOTICE
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/NOTICE b/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/NOTICE
new file mode 100644
index 0000000..27bc4a0
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/NOTICE
@@ -0,0 +1,5 @@
+Apache Cordova
+Copyright 2012 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/317cfdb3/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/package.json b/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/package.json
new file mode 100644
index 0000000..1c64679
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/package.json
@@ -0,0 +1,28 @@
+{
+  "name": "cordova-lib-test-plugin",
+  "version": "1.3.0",
+  "description": "Empty plugin used as part of the tests in cordova-lib",
+  "cordova": {
+    "id": "cordova-lib-test-plugin",
+    "platforms": []
+  },
+  "repository": {
+    "type": "git",
+    "url": "git://git-wip-us.apache.org/repos/asf/cordova-lib.git"
+  },
+  "author": "Apache Software Foundation",
+  "license": "Apache-2.0",
+  "engines": {
+    "cordovaDependencies": {
+      "0.0.0": {
+        "cordova-android": "<2.1.0"
+      },
+      "1.1.2": {
+        "cordova-android": ">=2.1.0 <4.0.0"
+      },
+      "1.3.0": {
+        "cordova-android": "4.0.0"
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/317cfdb3/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/plugin.xml b/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/plugin.xml
new file mode 100644
index 0000000..c2748bf
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/plugins/cordova-lib-test-plugin/plugin.xml
@@ -0,0 +1,4 @@
+<?xml version='1.0' encoding='utf-8'?>
+<plugin id="cordova-lib-test-plugin" version="0.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+    <name>cordova-lib-test-plugin</name>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/317cfdb3/cordova-lib/spec-cordova/plugin.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/plugin.spec.js b/cordova-lib/spec-cordova/plugin.spec.js
index 11a1b16..c8a0446 100644
--- a/cordova-lib/spec-cordova/plugin.spec.js
+++ b/cordova-lib/spec-cordova/plugin.spec.js
@@ -29,9 +29,21 @@ var helpers = require('./helpers'),
 var tmpDir = helpers.tmpDir('plugin_test');
 var project = path.join(tmpDir, 'project');
 var pluginsDir = path.join(__dirname, 'fixtures', 'plugins');
+
 var pluginId = 'org.apache.cordova.fakeplugin1';
 var org_test_defaultvariables = 'org.test.defaultvariables';
 
+// This plugin is published to npm and defines cordovaDependencies
+// in its package.json. Based on the dependencies and the version of
+// cordova-android installed in our test project, the CLI should
+// select version 1.1.2 of the plugin. We don't actually fetch from
+// npm, but we do check the npm info.
+var npmInfoTestPlugin = 'cordova-lib-test-plugin';
+var npmInfoTestPluginVersion = '1.1.2';
+
+var testGitPluginRepository = 'https://github.com/apache/cordova-plugin-device.git';
+var testGitPluginId = 'cordova-plugin-device';
+
 var results;
 
 
@@ -125,10 +137,10 @@ describe('plugin end-to-end', function() {
     });
 
     it('should not check npm info when using the searchpath flag', function(done) {
-        mockPluginFetch(pluginId, path.join(pluginsDir, 'fake1'));
+        mockPluginFetch(npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
 
         spyOn(registry, 'info');
-        addPlugin(pluginId, pluginId, {searchpath: pluginsDir}, done)
+        addPlugin(npmInfoTestPlugin, npmInfoTestPlugin, {searchpath: pluginsDir}, done)
         .then(function() {
             expect(registry.info).not.toHaveBeenCalled();
 
@@ -140,10 +152,10 @@ describe('plugin end-to-end', function() {
     });
 
     it('should not check npm info when using the noregistry flag', function(done) {
-        mockPluginFetch(pluginId, path.join(pluginsDir, 'fake1'));
+        mockPluginFetch(npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
 
         spyOn(registry, 'info');
-        addPlugin(pluginId, pluginId, {noregistry:true}, done)
+        addPlugin(npmInfoTestPlugin, npmInfoTestPlugin, {noregistry:true}, done)
         .then(function() {
             expect(registry.info).not.toHaveBeenCalled();
 
@@ -153,4 +165,29 @@ describe('plugin end-to-end', function() {
         .fail(errorHandler.errorCallback)
         .fin(done);
     });
+
+    it('should not check npm info when fetching from a Git repository', function(done) {
+        spyOn(registry, 'info');
+        addPlugin(testGitPluginRepository, testGitPluginId, {}, done)
+        .then(function() {
+            expect(registry.info).not.toHaveBeenCalled();
+        })
+        .fail(errorHandler.errorCallback)
+        .fin(done);
+    });
+
+    it('should select the plugin version based on npm info when fetching from npm', function(done) {
+        mockPluginFetch(npmInfoTestPlugin, path.join(pluginsDir, npmInfoTestPlugin));
+
+        spyOn(registry, 'info').andCallThrough();
+        addPlugin(npmInfoTestPlugin, npmInfoTestPlugin, {}, done)
+        .then(function() {
+            expect(registry.info).toHaveBeenCalled();
+
+            var fetchTarget = plugman.raw.fetch.mostRecentCall.args[0];
+            expect(fetchTarget).toEqual(npmInfoTestPlugin + '@' + npmInfoTestPluginVersion);
+        })
+        .fail(errorHandler.errorCallback)
+        .fin(done);
+    });
 });


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


[37/37] cordova-lib git commit: CB-10911 Incremented package version to -dev

Posted by st...@apache.org.
CB-10911 Incremented package version to -dev


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

Branch: refs/heads/master
Commit: 9f630271d9c02824c0031ea4cdc0e4955b53d9e2
Parents: 80b7004
Author: Steve Gill <st...@gmail.com>
Authored: Fri Mar 18 17:56:17 2016 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Mar 18 17:56:17 2016 -0700

----------------------------------------------------------------------
 cordova-common/package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9f630271/cordova-common/package.json
----------------------------------------------------------------------
diff --git a/cordova-common/package.json b/cordova-common/package.json
index c38b6da..20c4916 100644
--- a/cordova-common/package.json
+++ b/cordova-common/package.json
@@ -3,7 +3,7 @@
   "name": "cordova-common",
   "description": "Apache Cordova tools and platforms shared routines",
   "license": "Apache-2.0",
-  "version": "1.1.1",
+  "version": "1.1.2-dev",
   "repository": {
     "type": "git",
     "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"


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


[33/37] cordova-lib git commit: updated cordova-common dependency to 1.1.x

Posted by st...@apache.org.
updated cordova-common dependency to 1.1.x


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

Branch: refs/heads/common-1.1.x
Commit: 31b58d0c34e4aa9cf091c067bc846701a04f4e56
Parents: f0d5a3e
Author: Steve Gill <st...@gmail.com>
Authored: Fri Mar 18 12:42:17 2016 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Mar 18 12:42:17 2016 -0700

----------------------------------------------------------------------
 cordova-lib/package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/31b58d0c/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 73638bb..193c226 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -19,7 +19,7 @@
   "dependencies": {
     "aliasify": "^1.7.2",
     "cordova-app-hello-world": "3.10.0",
-    "cordova-common": "1.0.x",
+    "cordova-common": "1.1.x",
     "cordova-js": "4.1.4",
     "cordova-registry-mapper": "1.x",
     "cordova-serve": "^1.0.0",


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


[11/37] cordova-lib git commit: CB-10583 Protect plugin preferences from adding extra Array properties. This closes #400

Posted by st...@apache.org.
CB-10583 Protect plugin preferences from adding extra Array properties. This closes #400


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

Branch: refs/heads/common-1.1.x
Commit: d437ae1e4240fcb7a98d2833df5d1597ec7f59a8
Parents: bfea262
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Thu Feb 25 11:45:22 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Thu Feb 25 17:38:15 2016 +0300

----------------------------------------------------------------------
 cordova-common/src/PluginInfo/PluginInfo.js | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d437ae1e/cordova-common/src/PluginInfo/PluginInfo.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/PluginInfo/PluginInfo.js b/cordova-common/src/PluginInfo/PluginInfo.js
index 2554a3c..e1a1b31 100644
--- a/cordova-common/src/PluginInfo/PluginInfo.js
+++ b/cordova-common/src/PluginInfo/PluginInfo.js
@@ -43,18 +43,14 @@ function PluginInfo(dirname) {
     // <preference> tag
     // Example: <preference name="API_KEY" />
     // Used to require a variable to be specified via --variable when installing the plugin.
+    // returns { key : default | null}
     self.getPreferences = getPreferences;
     function getPreferences(platform) {
-        var arprefs = _getTags(self._et, 'preference', platform, _parsePreference);
-
-        var prefs= {};
-        for(var i in arprefs)
-        {
-            var pref=arprefs[i];
-            prefs[pref.preference]=pref.default;
-        }
-        // returns { key : default | null}
-        return prefs;
+        return _getTags(self._et, 'preference', platform, _parsePreference)
+        .reduce(function (preferences, pref) {
+            preferences[pref.preference] = pref.default;
+            return preferences;
+        }, {});
     }
 
     function _parsePreference(prefTag) {


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


[03/37] cordova-lib git commit: CB-10518 Correct log level and error messages for some cordova errors

Posted by st...@apache.org.
CB-10518 Correct log level and error messages for some cordova errors

This closes #383


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

Branch: refs/heads/common-1.1.x
Commit: b7920505e56e4371b868bc5f0a3f852d4249fe31
Parents: 87d8e17
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Tue Feb 16 16:20:31 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Wed Feb 17 11:54:49 2016 +0300

----------------------------------------------------------------------
 cordova-lib/src/cordova/compile.js    | 5 -----
 cordova-lib/src/cordova/create.js     | 7 +++----
 cordova-lib/src/cordova/run.js        | 6 ------
 cordova-lib/src/cordova/targets.js    | 5 +++--
 cordova-lib/src/hooks/HooksRunner.js  | 4 ++--
 cordova-lib/src/plugman/browserify.js | 8 ++++----
 cordova-lib/src/util/unpack.js        | 6 +++---
 7 files changed, 15 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b7920505/cordova-lib/src/cordova/compile.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/compile.js b/cordova-lib/src/cordova/compile.js
index 7bdabb4..5834925 100644
--- a/cordova-lib/src/cordova/compile.js
+++ b/cordova-lib/src/cordova/compile.js
@@ -19,8 +19,6 @@
 
 var cordova_util = require('./util'),
     HooksRunner  = require('../hooks/HooksRunner'),
-    events       = require('cordova-common').events,
-    Q            = require('q'),
     promiseUtil  = require('../util/promise-util'),
     platform_lib = require('../platforms/platforms');
 
@@ -39,8 +37,5 @@ module.exports = function compile(options) {
         });
     }).then(function() {
         return hooksRunner.fire('after_compile', options);
-    }, function(error) {
-        events.emit('log', 'ERROR building one of the platforms: ' + error + '\nYou may not have the required environment or OS to build this project');
-        return Q.reject(error);
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b7920505/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index 3ad96aa..5d8cef7 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -191,8 +191,7 @@ function create(dir, optionalId, optionalName, cfg) {
 
                 return remoteLoad.gitClone(gitURL, branch).fail(
                     function(err) {
-                        events.emit('verbose', err);
-                        return Q.reject('Failed to retrieve '+ cfg.lib.www.url + ' using git.');
+                        return Q.reject(new CordovaError('Failed to retrieve '+ cfg.lib.www.url + ' using git: ' + err.message));
                     }
                 );
             } else if (isNPM) {
@@ -210,8 +209,8 @@ function create(dir, optionalId, optionalName, cfg) {
 
                 return remoteLoad.npmFetch(packageName, packageVersion).fail(
                     function(err) {
-                        events.emit('verbose', err);
-                        return Q.reject('Failed to retrieve '+ cfg.lib.www.url + ' using npm.');
+                        events.emit('warn', err.message);
+                        return Q.reject(new CordovaError('Failed to retrieve '+ cfg.lib.www.url + ' using npm: ' + err.message));
                     }
                 );
             } else {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b7920505/cordova-lib/src/cordova/run.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/run.js b/cordova-lib/src/cordova/run.js
index 6c6e10d..fcfc9c6 100644
--- a/cordova-lib/src/cordova/run.js
+++ b/cordova-lib/src/cordova/run.js
@@ -19,7 +19,6 @@
 
 var cordova_util = require('./util'),
     HooksRunner  = require('../hooks/HooksRunner'),
-    events       = require('cordova-common').events,
     Q            = require('q'),
     platform_lib = require('../platforms/platforms');
 
@@ -43,10 +42,5 @@ module.exports = function run(options) {
         }));
     }).then(function() {
         return hooksRunner.fire('after_run', options);
-    }, function(error) {
-        events.emit('log', 'ERROR running one or more of the platforms: ' + error + '\nYou may not have the required environment or OS to run this project');
-
-        // CB-10567 bubble up `run` error, so the caller still could get rejected promise
-        return Q.reject(error);
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b7920505/cordova-lib/src/cordova/targets.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/targets.js b/cordova-lib/src/cordova/targets.js
index f7e1d73..0ba8d58 100644
--- a/cordova-lib/src/cordova/targets.js
+++ b/cordova-lib/src/cordova/targets.js
@@ -25,9 +25,10 @@ var cordova_util = require('./util'),
 
 function handleError(error) {
     if (error.code === 'ENOENT') {
-        events.emit('log', 'Platform does not support ' + this.script);
+        events.emit('warn', 'Platform does not support ' + this.script);
     } else {
-        events.emit('log', 'An unexpected error has occured');
+        events.emit('warn', 'An unexpected error has occured while running ' + this.script +
+            ' with code ' + error.code + ': ' + error);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b7920505/cordova-lib/src/hooks/HooksRunner.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/hooks/HooksRunner.js b/cordova-lib/src/hooks/HooksRunner.js
index eea1a59..299b775 100644
--- a/cordova-lib/src/hooks/HooksRunner.js
+++ b/cordova-lib/src/hooks/HooksRunner.js
@@ -85,7 +85,7 @@ HooksRunner.prototype.prepareOptions = function(opts) {
     try {
         opts.cordova.version = opts.cordova.version || require('../../package').version;
     } catch(ex) {
-        events.emit('error', 'HooksRunner could not load package.json: ' + ex.message);
+        events.emit('warn', 'HooksRunner could not load package.json: ' + ex.message);
     }
 
     return opts;
@@ -263,4 +263,4 @@ function isHookDisabled(opts, hook) {
     }
     return false;
 }
- 
+

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b7920505/cordova-lib/src/plugman/browserify.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/browserify.js b/cordova-lib/src/plugman/browserify.js
index 3d2b278..fd7d832 100644
--- a/cordova-lib/src/plugman/browserify.js
+++ b/cordova-lib/src/plugman/browserify.js
@@ -54,8 +54,8 @@ function generateFinalBundle(platform, libraryRelease, outReleaseFile, commitId,
     });
 
     outReleaseFileStream.on('error', function(err) {
-        events.emit('log', 'error while generating cordova.js');
-        deferred.reject();
+        events.emit('warn', 'error while generating cordova.js');
+        deferred.reject(err);
     });
     return deferred.promise;
 }
@@ -74,8 +74,8 @@ function getPlatformVersion(cId, project_dir) {
     var versionPath = path.join(project_dir, '/cordova/version');
     childProcess.exec('"' + versionPath + '"', function(err, stdout, stderr) {
         if (err) {
-            events.emit('log', 'Error running platform version script');
-            events.emit('log', err);
+            err.message = 'Failed to get platform version (will use \'N/A\' instead).\n' + err.message;
+            events.emit('warn', err);
             deferred.resolve('N/A');
         } else {
             deferred.resolve(stdout.trim());

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b7920505/cordova-lib/src/util/unpack.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/util/unpack.js b/cordova-lib/src/util/unpack.js
index 637f10b..f0ec451 100644
--- a/cordova-lib/src/util/unpack.js
+++ b/cordova-lib/src/util/unpack.js
@@ -35,17 +35,17 @@ function unpackTgz(package_tgz, unpackTarget) {
 
         fs.createReadStream(package_tgz)
         .on('error', function (err) {
-            events.emit('verbose', 'Unable to open tarball ' + package_tgz + ': ' + err);
+            events.emit('warn', 'Unable to open tarball ' + package_tgz + ': ' + err);
             reject(err);
         })
         .pipe(zlib.createUnzip())
         .on('error', function (err) {
-            events.emit('verbose', 'Error during unzip for ' + package_tgz + ': ' + err);
+            events.emit('warn', 'Error during unzip for ' + package_tgz + ': ' + err);
             reject(err);
         })
         .pipe(tar.Extract(extractOpts))
         .on('error', function(err) {
-            events.emit('verbose', 'Error during untar for ' + package_tgz + ': ' + err);
+            events.emit('warn', 'Error during untar for ' + package_tgz + ': ' + err);
             reject(err);
         })
         .on('end', resolve);


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


[27/37] cordova-lib git commit: CB-10694 - Platform-specific configuration preferences don't override global settings

Posted by st...@apache.org.
CB-10694 - Platform-specific configuration preferences don't override global settings

Includes jasmine test.


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

Branch: refs/heads/common-1.1.x
Commit: 11d1380537da46639c6dbbe8d32bcd3fa03e9ad8
Parents: 186eea0
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Mar 16 10:42:23 2016 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Mar 16 11:18:31 2016 -0700

----------------------------------------------------------------------
 cordova-common/spec/util/xml-helpers.spec.js | 21 +++++++++++++++++++++
 cordova-common/src/util/xml-helpers.js       |  6 +++---
 2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/11d13805/cordova-common/spec/util/xml-helpers.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/util/xml-helpers.spec.js b/cordova-common/spec/util/xml-helpers.spec.js
index 8cc46ca..59b760a 100644
--- a/cordova-common/spec/util/xml-helpers.spec.js
+++ b/cordova-common/spec/util/xml-helpers.spec.js
@@ -267,5 +267,26 @@ describe('xml-helpers', function(){
             expect(testElements.length).toEqual(2);
 
         });
+        
+        it('should merge preferences, with platform preferences written last', function () {
+            var testXml = et.XML(
+                '<?xml version="1.0" encoding="UTF-8"?>\n' +
+                '<widget xmlns     = "http://www.w3.org/ns/widgets"\n' +
+                '        xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
+                '        id        = "io.cordova.hellocordova"\n' +
+                '        version   = "0.0.1">\n' +
+                '    <preference name="Orientation" value="default" />\n' +
+                '    <platform name="ios">\n' +
+                '        <preference name="Orientation" value="all" />\n' +
+                '    </platform>\n' +
+                '</widget>\n'
+            );
+            xml_helpers.mergeXml(testXml, dstXml, 'ios');
+            var testElements = dstXml.findall('preference[@name="Orientation"]');
+            expect(testElements.length).toEqual(2);
+            expect(testElements[0].attrib.value).toEqual('default');
+            expect(testElements[1].attrib.value).toEqual('all');
+        });
+        
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/11d13805/cordova-common/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/util/xml-helpers.js b/cordova-common/src/util/xml-helpers.js
index 8b02989..487a763 100644
--- a/cordova-common/src/util/xml-helpers.js
+++ b/cordova-common/src/util/xml-helpers.js
@@ -209,6 +209,9 @@ function mergeXml(src, dest, platform, clobber) {
     if (src.text && (clobber || !dest.text)) {
         dest.text = src.text;
     }
+    //Handle children
+    src.getchildren().forEach(mergeChild);
+
     //Handle platform
     if (platform) {
         src.findall('platform[@name="' + platform + '"]').forEach(function (platformElement) {
@@ -216,9 +219,6 @@ function mergeXml(src, dest, platform, clobber) {
         });
     }
 
-    //Handle children
-    src.getchildren().forEach(mergeChild);
-
     function mergeChild (srcChild) {
         var srcTag = srcChild.tag,
             destChild = new et.Element(srcTag),


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


[23/37] cordova-lib git commit: CB-10791 Add adjustLoggerLevel to cordova-common.CordovaLogger

Posted by st...@apache.org.
CB-10791 Add adjustLoggerLevel to cordova-common.CordovaLogger

Adds corresponding tests


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

Branch: refs/heads/common-1.1.x
Commit: 0386ac2cd76671001ce3d566148522cfd8de614a
Parents: 317cfdb
Author: daserge <v-...@microsoft.com>
Authored: Wed Mar 9 22:20:01 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Thu Mar 10 12:36:00 2016 +0300

----------------------------------------------------------------------
 cordova-common/spec/CordovaLogger.spec.js | 28 ++++++++++++++++++++++++++
 cordova-common/src/CordovaLogger.js       | 17 ++++++++++++++++
 2 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0386ac2c/cordova-common/spec/CordovaLogger.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/CordovaLogger.spec.js b/cordova-common/spec/CordovaLogger.spec.js
index fd96488..5c27db1 100644
--- a/cordova-common/spec/CordovaLogger.spec.js
+++ b/cordova-common/spec/CordovaLogger.spec.js
@@ -160,5 +160,33 @@ describe('CordovaLogger class', function() {
                 expect(logger.stderrCursor.write.calls[0].args[0]).toBe('Error: error_message');
             });
         });
+
+        describe('adjustLevel method', function () {
+            it('should properly adjust log level', function () {
+                var resetLogLevel = function() {
+                    logger.setLevel('normal');
+                };
+
+                resetLogLevel();
+                expect(logger.adjustLevel({verbose: true}).logLevel).toEqual('verbose');
+
+                resetLogLevel();
+                expect(logger.adjustLevel(['--verbose']).logLevel).toEqual('verbose');
+
+                resetLogLevel();
+                expect(logger.adjustLevel({silent: true}).logLevel).toEqual('error');
+
+                resetLogLevel();
+                expect(logger.adjustLevel(['--silent']).logLevel).toEqual('error');
+
+                resetLogLevel();
+                expect(logger.adjustLevel({verbose: true, silent: true}).logLevel).toEqual('verbose');
+
+                resetLogLevel();
+                expect(logger.adjustLevel(['--verbose', '--silent']).logLevel).toEqual('verbose');
+
+                resetLogLevel();
+            });
+        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0386ac2c/cordova-common/src/CordovaLogger.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/CordovaLogger.js b/cordova-common/src/CordovaLogger.js
index 38bfe69..0a4a49c 100644
--- a/cordova-common/src/CordovaLogger.js
+++ b/cordova-common/src/CordovaLogger.js
@@ -153,6 +153,23 @@ CordovaLogger.prototype.setLevel = function (logLevel) {
 };
 
 /**
+ * Adjusts the current logger level according to the passed options.
+ *
+ * @param   {Object|Array}  opts  An object or args array with options
+ *
+ * @return  {CordovaLogger}     Current instance, to allow calls chaining.
+ */
+CordovaLogger.prototype.adjustLevel = function (opts) {
+    if (opts.verbose || (Array.isArray(opts) && opts.indexOf('--verbose') !== -1)) {
+        this.setLevel('verbose');
+    } else if (opts.silent || (Array.isArray(opts) && opts.indexOf('--silent') !== -1)) {
+        this.setLevel('error');
+    }
+
+    return this;
+};
+
+/**
  * Attaches logger to EventEmitter instance provided.
  *
  * @param   {EventEmitter}  eventEmitter  An EventEmitter instance to attach


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