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 2015/10/31 01:08:36 UTC

[1/3] cordova-lib git commit: Fix create argument prerequisite check

Repository: cordova-lib
Updated Branches:
  refs/heads/5.4.x [created] 1ce6a5a24


Fix create argument prerequisite check

Store argument.length from create before return call
Update returns prerequisite checks to use the previously stored arg length. This closes #337


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

Branch: refs/heads/5.4.x
Commit: 40ecced7ae5fe57ef615d9941af1caee59800676
Parents: 95c70c6
Author: Toni <Zo...@users.noreply.github.com>
Authored: Thu Oct 29 18:05:04 2015 -0400
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Oct 30 16:43:17 2015 -0700

----------------------------------------------------------------------
 cordova-lib/src/cordova/create.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/40ecced7/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index 1eded17..1f5e010 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -39,13 +39,15 @@ var path          = require('path'),
 // Returns a promise.
 module.exports = create;
 function create(dir, optionalId, optionalName, cfg) {
+    var argumentCount = arguments.length;
+    
     return Q.fcall(function() {
         // Lets check prerequisites first
 
-        if (arguments.length == 3) {
+        if (argumentCount == 3) {
           cfg = optionalName;
           optionalName = undefined;
-        } else if (arguments.length == 2) {
+        } else if (argumentCount == 2) {
           cfg = optionalId;
           optionalId = undefined;
           optionalName = undefined;


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


[2/3] cordova-lib git commit: CB-9834 Introduce compat map for hook requires

Posted by st...@apache.org.
CB-9834 Introduce compat map for hook requires


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

Branch: refs/heads/5.4.x
Commit: 38809af4f5ac6982b0b16c1a1ce89741197ea160
Parents: 40ecced
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Tue Oct 27 15:20:10 2015 +0300
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Oct 30 16:43:21 2015 -0700

----------------------------------------------------------------------
 cordova-lib/src/hooks/Context.js | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/38809af4/cordova-lib/src/hooks/Context.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/hooks/Context.js b/cordova-lib/src/hooks/Context.js
index a0b6cfd..ed7f8a7 100644
--- a/cordova-lib/src/hooks/Context.js
+++ b/cordova-lib/src/hooks/Context.js
@@ -17,6 +17,9 @@
  under the License.
  */
 
+var path = require('path');
+var events = require('cordova-common').events;
+
 /**
  * Creates hook script context
  * @constructor
@@ -39,13 +42,39 @@ function Context(hook, opts) {
     this.cordova = require('../cordova/cordova');
 }
 
+// As per CB-9834 we need to maintain backward compatibility and provide a compat layer
+// for plugins that still require modules, factored to cordova-common.
+var compatMap = {
+    '../configparser/ConfigParser': function () {
+        return require('cordova-common').ConfigParser;
+    },
+    '../util/xml-helpers': function () {
+        return require('cordova-common').xmlHelpers;
+    }
+};
 
 /**
  * Returns a required module
- * @param {String} path Module path
+ * @param {String} modulePath Module path
  * @returns {Object} */
-Context.prototype.requireCordovaModule = function (path) {
-    return require(path);
+Context.prototype.requireCordovaModule = function (modulePath) {
+    // There is a very common mistake, when hook requires some cordova functionality
+    // using 'cordova-lib/...' path.
+    // This path will be resolved only when running cordova from 'normal' installation
+    // (without symlinked modules). If cordova-lib linked to cordova-cli this path is
+    // never resolved, so hook fails with 'Error: Cannot find module 'cordova-lib''
+    var resolvedPath = path.resolve(__dirname, modulePath.replace(/^cordova-lib/, '../../../cordova-lib'));
+    var relativePath = path.relative(__dirname, resolvedPath).replace(/\\/g, '/');
+    events.emit('verbose', 'Resolving module name for ' + modulePath + ' => ' + relativePath);
+
+    var compatRequire = compatMap[relativePath];
+    if (compatRequire) {
+        events.emit('warn', 'The module "' + path.basename(relativePath) + '" has been factored ' +
+            'into "cordova-common". Consider update your plugin hooks.');
+        return compatRequire();
+    }
+
+    return require(relativePath);
 };
 
 module.exports = Context;


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


[3/3] cordova-lib git commit: added CB-9834 to Releasenotes for 5.4.0

Posted by st...@apache.org.
added CB-9834 to Releasenotes for 5.4.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/1ce6a5a2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/1ce6a5a2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/1ce6a5a2

Branch: refs/heads/5.4.x
Commit: 1ce6a5a24f52665ef3c992e9850e125bed7dadf5
Parents: 38809af
Author: Steve Gill <st...@gmail.com>
Authored: Fri Oct 30 16:46:58 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Oct 30 16:47:14 2015 -0700

----------------------------------------------------------------------
 cordova-lib/RELEASENOTES.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/1ce6a5a2/cordova-lib/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/cordova-lib/RELEASENOTES.md b/cordova-lib/RELEASENOTES.md
index b4eca20..7635d31 100644
--- a/cordova-lib/RELEASENOTES.md
+++ b/cordova-lib/RELEASENOTES.md
@@ -21,6 +21,7 @@
 # Cordova-lib Release Notes
 
 ### 5.4.0 (Oct 30, 2015)
+* CB-9834 Introduce compat map for hook requires
 * CB-9902 Fix broken `cordova run --list`
 * CB-9872 Fixed save.spec.11 failure
 * CB-9800 Fixing contribute link.


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