You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2013/08/02 00:27:00 UTC

[1/5] git commit: [CB-4036] - first pass for adding version script

Updated Branches:
  refs/heads/versionCheck [created] f716822be


[CB-4036] - first pass for adding version script


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

Branch: refs/heads/versionCheck
Commit: 5607ff8f360f36e79367f5f93a659fff0a1c9183
Parents: 13b6232
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Jul 25 14:56:23 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Thu Aug 1 14:37:48 2013 -0700

----------------------------------------------------------------------
 spec/plugins/EnginePlugin/plugin.xml | 10 +++++++---
 src/install.js                       | 29 +++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/5607ff8f/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index 62233e3..c29bb8c 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -23,8 +23,12 @@
 
     <name>Engine Choo Choo</name>
 
-    <engines>
-        <engine name="cordova" version=">=2.3.0" />
-    </engines>
+
+    
     
+    <platform name="android" min-sdk-version="1.0.1" min-os-version="9.2.1" />
+    <platform name="blackberry10" min-sdk-version="0.0.1" min-os-version="0.0.1" />
+    <platform name="ios" min-sdk-version="5.1" min-os-version="10.1" />
+    <platform name="wp7" min-sdk-version="0.0.1"/>
+    <platform name="wp8"  min-os-version="0.0.1"/>
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/5607ff8f/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 556ac7e..381b6fe 100644
--- a/src/install.js
+++ b/src/install.js
@@ -134,6 +134,35 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
         require('../plugman').emit('log', 'Cordova project version not detected (lacks a ./cordova/version script), continuing.');
     }
 
+    // check platform requirements - min sdks/min os version etc
+    var platformMinReqScript = { code: 0, output: { min_os_version: "5.0.0" , min_sdk_version: "1.0.0" } }; // place holder for now until we have an actual script    
+    if(platformMinReqScript.code === 0){
+        var platformMinOS = plugin_et.findall('./platform[@name="'+platform+'"][@min-os-version]')[0].attrib["min-os-version"];
+        var platformMinSDK = plugin_et.findall('./platform[@name="'+platform+'"][@min-sdk-version]')[0].attrib["min-sdk-version"];    
+
+        if( platformMinReqScript.output.min_os_version ) {
+            if(semver.satisfies(platformMinReqScript.output.min_os_version, platformMinOS)){
+                // min-os version ok
+            } else {
+                var err = new Error('Plugin doesn\'t support ' + platform + '  minimum os version.  ' + platform + '  minimum os version: ' + platformMinReqScript.output.min_os_version + ', failed version requirement: ' + platformMinOS);
+                if (callback) return callback(err);
+                else throw err;
+            }            
+        }
+
+        if(platformMinReqScript.output.min_sdk_version) {
+            if(semver.satisfies(platformMinReqScript.output.min_sdk_version, platformMinSDK)){
+                // min-sdk version ok
+            } else {
+                var err = new Error('Plugin doesn\'t support ' + platform + '  minimum sdk version.  ' + platform + '  minimum sdk version: ' + platformMinReqScript.output.min_sdk_version+ ', failed version requirement: ' + platformMinSDK);
+                if (callback) return callback(err);
+                else throw err;
+            }                        
+        }
+    } else {
+        require('../plugman').emit('log', 'Cordova project minimum sdk or os version not detected (lacks a ./cordova/sdkRequirement script), continuing.');
+    }
+    
     // checking preferences, if certain variables are not provided, we should throw.
     prefs = plugin_et.findall('./preference') || [];
     prefs = prefs.concat(plugin_et.findall('./platform[@name="'+platform+'"]/preference'));


[2/5] git commit: [CB-4036] - added test file for checking engine and versions

Posted by ti...@apache.org.
[CB-4036] - added test file for checking engine and versions


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

Branch: refs/heads/versionCheck
Commit: 7b4fd7764f2ab8456de4ff012396502cbbb72d3e
Parents: 5607ff8
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Jul 25 15:00:20 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Thu Aug 1 14:37:49 2013 -0700

----------------------------------------------------------------------
 spec/engine.spec.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/7b4fd776/spec/engine.spec.js
----------------------------------------------------------------------
diff --git a/spec/engine.spec.js b/spec/engine.spec.js
new file mode 100644
index 0000000..89a7f9e
--- /dev/null
+++ b/spec/engine.spec.js
@@ -0,0 +1,55 @@
+var install = require('../src/install'),
+    actions = require('../src/util/action-stack'),
+    config_changes = require('../src/util/config-changes'),
+    xml_helpers = require('../src/util/xml-helpers'),
+    plugman = require('../plugman'),
+    fs      = require('fs'),
+    os      = require('osenv'),
+    path    = require('path'),
+    shell   = require('shelljs'),
+    semver  = require('semver'),
+    temp    = __dirname,
+    dummyplugin = 'DummyPlugin',
+    dummy_id = 'com.phonegap.plugins.dummyplugin',
+    variableplugin = 'VariablePlugin',
+    engineplugin = 'EnginePlugin',
+    childplugin = 'ChildBrowser',
+    plugins_dir = path.join(temp, 'plugins');
+
+describe('install', function() {
+    var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, mkdir;
+    beforeEach(function() {
+        proc = spyOn(actions.prototype, 'process').andCallFake(function(platform, proj, cb) {
+            cb();
+        });
+        mkdir = spyOn(shell, 'mkdir');
+        actions_push = spyOn(actions.prototype, 'push');
+        c_a = spyOn(actions.prototype, 'createAction');
+        prepare = spyOn(plugman, 'prepare');
+        exec = spyOn(shell, 'exec').andReturn({code:1});
+        chmod = spyOn(fs, 'chmodSync');
+        exists = spyOn(fs, 'existsSync').andReturn(true);
+        get_json = spyOn(config_changes, 'get_platform_json').andReturn({
+            installed_plugins:{},
+            dependent_plugins:{}
+        });
+        add_to_queue = spyOn(config_changes, 'add_installed_plugin_to_prepare_queue');
+    });
+    describe('success', function() {
+        it('should check version if plugin has engine tag', function(){
+            var spy = spyOn(semver, 'satisfies').andReturn(true);
+            install('android', temp, 'engineplugin', plugins_dir, {});
+            expect(spy).toHaveBeenCalledWith('5.0.0','9.2.1');
+        });
+        
+        /*
+        it('should check version and munge it a little if it has "rc" in it so it plays nice with semver (introduce a dash in it)', function() {
+            var spy = spyOn(semver, 'satisfies').andReturn(true);
+            exec.andReturn({code:0,output:"3.0.0rc1"});
+            install('android', temp, 'engineplugin', plugins_dir, {});
+            expect(spy).toHaveBeenCalledWith('3.0.0-rc1','>=2.3.0');
+        });
+        */
+    });
+
+});


[3/5] git commit: [CB-4036] - refactored the engine/version checks for easier testing

Posted by ti...@apache.org.
[CB-4036] - refactored the engine/version checks for easier testing


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

Branch: refs/heads/versionCheck
Commit: 6a67037b98edba15519086b084fb39f6c01e52c8
Parents: 7b4fd77
Author: Tim Kim <ti...@adobe.com>
Authored: Wed Jul 31 16:54:12 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Thu Aug 1 14:57:13 2013 -0700

----------------------------------------------------------------------
 src/install.js | 168 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 104 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6a67037b/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 381b6fe..a02e8f6 100644
--- a/src/install.js
+++ b/src/install.js
@@ -65,6 +65,102 @@ function possiblyFetch(actions, platform, project_dir, id, plugins_dir, options,
     }
 }
 
+function checkMinimumReq(currentProjectInfo, minRequirements, platform, callback) {
+    if(currentProjectInfo.cordovaVersion) {
+        if(currentProjectInfo.cordovaVersion == 'dev' || semver.satisfies(currentProjectInfo.cordovaVersion, minRequirements.cordovaMinVersion)){
+            // engine ok!
+        } else {
+            var err = new Error('Plugin doesn\'t support this project\'s Cordova version. Project version: ' + currentProjectInfo.cordovaVersion + ', failed version requirement: ' + minRequirements.cordovaMinVersion);
+            if (callback) return callback(err);
+            else throw err;
+        }   
+    }
+    
+    if(currentProjectInfo.min_os_version) {
+        if(semver.satisfies(currentProjectInfo.min_os_version, minRequirements.platformMinOS)) {
+            // min-os version ok
+        } else {
+            var err = new Error('Plugin doesn\'t support ' + platform + '  minimum os version.  ' + platform + '  minimum os version: ' + currentProjectInfo.min_os_version + ', failed version requirement: ' + minRequirements.platformMinOS);
+            if (callback) return callback(err);
+            else throw err;
+        }            
+    }
+
+    if(currentProjectInfo.min_sdk_version) {
+        if(semver.satisfies(currentProjectInfo.min_sdk_version, minRequirements.platformMinSDK)) {
+            // min-sdk version ok
+        } else {
+            var err = new Error('Plugin doesn\'t support ' + platform + '  minimum sdk version.  ' + platform + '  minimum sdk version: ' + currentProjectInfo.min_sdk_version + ', failed version requirement: ' + minRequirements.platformMinSDK);
+            if (callback) return callback(err);
+            else throw err;
+        }                        
+    }     
+}
+
+// use the project level cordova scripts to get the current cordova version and platform information
+function getCurrentProjectVersion(versionPath, platformPath) {
+    // need to think about a more graceful way of handling when these scripts break or when they are not detected
+    // setting version/platform to null if they do fail or do not exist and then just continuing
+    
+    var cordovaVersion, platformInfo;
+    
+    fs.chmodSync(versionPath, '755');
+    fs.chmodSync(platformPath, '755');
+
+    if (fs.existsSync(versionPath)) {   
+        var versionScript = shell.exec(versionPath, {silent: true});
+        if (versionScript.code === 0) {
+            cordovaVersion = cordovaVersion.output.trim();
+            var rc_index = cordovaVersion.indexOf('rc');
+            if (rc_index > -1) {
+                cordovaVersion = cordovaVersion.substr(0, rc_index) + '-' + cordovaVersion.substr(rc_index);
+            }
+        }else{
+            cordovaVersion = null;
+            require('../plugman').emit('log', 'Cordova project version script failed (has a ./cordova/version script, but something went wrong executing it), continuing anyways.');
+        }
+    }else{
+        cordovaVersion = null;
+        require('../plugman').emit('log', 'Cordova project version not detected (lacks a ./cordova/version script), continuing.');
+    }  
+    
+    if (fs.existsSync(platformPath)) {   
+        var platformScript = shell.exec(platformPath, {silent: true});
+        if (platformScript.code === 0) {
+            // thinking platformScript.output would be a JSON string like:
+            // { min_os_version: "5.0.0" , min_sdk_version: "1.0.0" }
+            platformInfo = platformScript.output;
+        }else{
+            platformInfo =  null;
+            require('../plugman').emit('log', 'Cordova project platformReq script failed (has a ./cordova/platformReq script, but something went wrong executing it), continuing anyways.');
+        }
+    }else{  
+        platformInfo =  null;
+        require('../plugman').emit('log', 'Cordova project version not detected (lacks a ./cordova/version script), continuing.');
+    }     
+    
+    return { 'cordovaVersion' : cordovaVersion, 'platformInfo' : platformInfo };
+}
+
+function getMinReq(pluginElement){
+    var cordovaMinVersion, platformMinOS, platformMinSDK;
+    
+    var engines = pluginElement.findall('engines/engine');
+    engines.forEach(function(engine){
+                if(engine.attrib["name"].toLowerCase() === "cordova"){
+                    cordovaMinVersion = engine.attrib["version"];
+                }else{
+                    // check for other engines - if found, shove the info into return statement 
+                }
+            });
+            
+    platformMinOS = plugin_et.findall('./platform[@name="'+platform+'"][@min-os-version]')[0].attrib["min-os-version"];
+    platformMinSDK = plugin_et.findall('./platform[@name="'+platform+'"][@min-sdk-version]')[0].attrib["min-sdk-version"];
+    
+    return { 'cordovaMinVersion': cordovaMinVersion, 'platformMinOS' : platformMinOS, 'platformMinSDK' : platformMinSDK };
+}
+
+
 // possible options: cli_variables, www_dir, is_top_level
 function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, options, callback) {
     var xml_path     = path.join(plugin_dir, 'plugin.xml')
@@ -93,75 +189,19 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
         if (callback) callback();
         return;
     }
-
-    // checking engine
-    // will there be a case for multiple engine support?
+    
     var versionPath = path.join(project_dir, 'cordova', 'version');
     // windows8, wp7, wp8 all use a .bat file
-    if (!fs.existsSync(versionPath)) {
+    if (platform === "windows8" || platform === "wp7" || platform === "wp8") {
         versionPath += ".bat";
     }
-    if (fs.existsSync(versionPath)) {
-        // need to rethink this so I don't have to chmod anything
-        fs.chmodSync(versionPath, '755');
-        var versionScript = shell.exec(versionPath, {silent: true});
-        // Only check cordova version if the version script was successful.
-        if (versionScript.code === 0) {
-            var current_version = versionScript.output.trim();
-            var rc_index = current_version.indexOf('rc');
-            if (rc_index > -1) {
-                current_version = current_version.substr(0, rc_index) + '-' + current_version.substr(rc_index);
-            }
-            var engines = plugin_et.findall('engines/engine');
-            engines.forEach(function(engine){
-                if(engine.attrib["name"].toLowerCase() === "cordova"){
-                    var engineVersion = engine.attrib["version"];
-                    // clean only versionScript.output since semver.clean strips out
-                    // the gt and lt operators
-                    if(current_version == 'dev' || semver.satisfies(current_version, engineVersion)){
-                        // engine ok!
-                    } else {
-                        var err = new Error('Plugin doesn\'t support this project\'s Cordova version. Project version: ' + current_version + ', failed version requirement: ' + engineVersion);
-                        if (callback) return callback(err);
-                        else throw err;
-                    }
-                } else {
-                    // check for other engines? worklight phonegap etc
-                }
-            });
-        }
-    } else {
-        require('../plugman').emit('log', 'Cordova project version not detected (lacks a ./cordova/version script), continuing.');
-    }
-
-    // check platform requirements - min sdks/min os version etc
-    var platformMinReqScript = { code: 0, output: { min_os_version: "5.0.0" , min_sdk_version: "1.0.0" } }; // place holder for now until we have an actual script    
-    if(platformMinReqScript.code === 0){
-        var platformMinOS = plugin_et.findall('./platform[@name="'+platform+'"][@min-os-version]')[0].attrib["min-os-version"];
-        var platformMinSDK = plugin_et.findall('./platform[@name="'+platform+'"][@min-sdk-version]')[0].attrib["min-sdk-version"];    
-
-        if( platformMinReqScript.output.min_os_version ) {
-            if(semver.satisfies(platformMinReqScript.output.min_os_version, platformMinOS)){
-                // min-os version ok
-            } else {
-                var err = new Error('Plugin doesn\'t support ' + platform + '  minimum os version.  ' + platform + '  minimum os version: ' + platformMinReqScript.output.min_os_version + ', failed version requirement: ' + platformMinOS);
-                if (callback) return callback(err);
-                else throw err;
-            }            
-        }
 
-        if(platformMinReqScript.output.min_sdk_version) {
-            if(semver.satisfies(platformMinReqScript.output.min_sdk_version, platformMinSDK)){
-                // min-sdk version ok
-            } else {
-                var err = new Error('Plugin doesn\'t support ' + platform + '  minimum sdk version.  ' + platform + '  minimum sdk version: ' + platformMinReqScript.output.min_sdk_version+ ', failed version requirement: ' + platformMinSDK);
-                if (callback) return callback(err);
-                else throw err;
-            }                        
-        }
-    } else {
-        require('../plugman').emit('log', 'Cordova project minimum sdk or os version not detected (lacks a ./cordova/sdkRequirement script), continuing.');
-    }
+    var platformPath = path.join(project_dir, 'cordova', 'platformReq');
+    
+    var currentProjectInfo = getCurrentProjectVersion(versionPath, platformPath);
+    var minRequirements = getMinReq(plugin_et);
+    
+    checkMinimumReq(currentProjectInfo, minRequirements, platform, callback);
     
     // checking preferences, if certain variables are not provided, we should throw.
     prefs = plugin_et.findall('./preference') || [];


[4/5] git commit: [CB-4036] - fixed up some failing tests

Posted by ti...@apache.org.
[CB-4036] - fixed up some failing tests


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

Branch: refs/heads/versionCheck
Commit: c68da5be2d385b46b7d4e2b5d3dd3bb71918fc31
Parents: 6a67037
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Aug 1 14:18:59 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Thu Aug 1 14:57:13 2013 -0700

----------------------------------------------------------------------
 spec/engine.spec.js                  | 55 -------------------------------
 spec/plugins/EnginePlugin/plugin.xml | 10 ++----
 src/install.js                       | 17 ++++++----
 3 files changed, 14 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c68da5be/spec/engine.spec.js
----------------------------------------------------------------------
diff --git a/spec/engine.spec.js b/spec/engine.spec.js
deleted file mode 100644
index 89a7f9e..0000000
--- a/spec/engine.spec.js
+++ /dev/null
@@ -1,55 +0,0 @@
-var install = require('../src/install'),
-    actions = require('../src/util/action-stack'),
-    config_changes = require('../src/util/config-changes'),
-    xml_helpers = require('../src/util/xml-helpers'),
-    plugman = require('../plugman'),
-    fs      = require('fs'),
-    os      = require('osenv'),
-    path    = require('path'),
-    shell   = require('shelljs'),
-    semver  = require('semver'),
-    temp    = __dirname,
-    dummyplugin = 'DummyPlugin',
-    dummy_id = 'com.phonegap.plugins.dummyplugin',
-    variableplugin = 'VariablePlugin',
-    engineplugin = 'EnginePlugin',
-    childplugin = 'ChildBrowser',
-    plugins_dir = path.join(temp, 'plugins');
-
-describe('install', function() {
-    var exists, get_json, chmod, exec, proc, add_to_queue, prepare, actions_push, c_a, mkdir;
-    beforeEach(function() {
-        proc = spyOn(actions.prototype, 'process').andCallFake(function(platform, proj, cb) {
-            cb();
-        });
-        mkdir = spyOn(shell, 'mkdir');
-        actions_push = spyOn(actions.prototype, 'push');
-        c_a = spyOn(actions.prototype, 'createAction');
-        prepare = spyOn(plugman, 'prepare');
-        exec = spyOn(shell, 'exec').andReturn({code:1});
-        chmod = spyOn(fs, 'chmodSync');
-        exists = spyOn(fs, 'existsSync').andReturn(true);
-        get_json = spyOn(config_changes, 'get_platform_json').andReturn({
-            installed_plugins:{},
-            dependent_plugins:{}
-        });
-        add_to_queue = spyOn(config_changes, 'add_installed_plugin_to_prepare_queue');
-    });
-    describe('success', function() {
-        it('should check version if plugin has engine tag', function(){
-            var spy = spyOn(semver, 'satisfies').andReturn(true);
-            install('android', temp, 'engineplugin', plugins_dir, {});
-            expect(spy).toHaveBeenCalledWith('5.0.0','9.2.1');
-        });
-        
-        /*
-        it('should check version and munge it a little if it has "rc" in it so it plays nice with semver (introduce a dash in it)', function() {
-            var spy = spyOn(semver, 'satisfies').andReturn(true);
-            exec.andReturn({code:0,output:"3.0.0rc1"});
-            install('android', temp, 'engineplugin', plugins_dir, {});
-            expect(spy).toHaveBeenCalledWith('3.0.0-rc1','>=2.3.0');
-        });
-        */
-    });
-
-});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c68da5be/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index c29bb8c..62233e3 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -23,12 +23,8 @@
 
     <name>Engine Choo Choo</name>
 
-
-    
+    <engines>
+        <engine name="cordova" version=">=2.3.0" />
+    </engines>
     
-    <platform name="android" min-sdk-version="1.0.1" min-os-version="9.2.1" />
-    <platform name="blackberry10" min-sdk-version="0.0.1" min-os-version="0.0.1" />
-    <platform name="ios" min-sdk-version="5.1" min-os-version="10.1" />
-    <platform name="wp7" min-sdk-version="0.0.1"/>
-    <platform name="wp8"  min-os-version="0.0.1"/>
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c68da5be/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index a02e8f6..7ef27ad 100644
--- a/src/install.js
+++ b/src/install.js
@@ -110,7 +110,7 @@ function getCurrentProjectVersion(versionPath, platformPath) {
     if (fs.existsSync(versionPath)) {   
         var versionScript = shell.exec(versionPath, {silent: true});
         if (versionScript.code === 0) {
-            cordovaVersion = cordovaVersion.output.trim();
+            cordovaVersion = versionScript.output.trim();
             var rc_index = cordovaVersion.indexOf('rc');
             if (rc_index > -1) {
                 cordovaVersion = cordovaVersion.substr(0, rc_index) + '-' + cordovaVersion.substr(rc_index);
@@ -142,7 +142,8 @@ function getCurrentProjectVersion(versionPath, platformPath) {
     return { 'cordovaVersion' : cordovaVersion, 'platformInfo' : platformInfo };
 }
 
-function getMinReq(pluginElement){
+function getMinReq(pluginElement, platform){
+
     var cordovaMinVersion, platformMinOS, platformMinSDK;
     
     var engines = pluginElement.findall('engines/engine');
@@ -153,9 +154,13 @@ function getMinReq(pluginElement){
                     // check for other engines - if found, shove the info into return statement 
                 }
             });
-            
-    platformMinOS = plugin_et.findall('./platform[@name="'+platform+'"][@min-os-version]')[0].attrib["min-os-version"];
-    platformMinSDK = plugin_et.findall('./platform[@name="'+platform+'"][@min-sdk-version]')[0].attrib["min-sdk-version"];
+    
+    
+    platformMinOS = pluginElement.findall('./platform[@name="'+platform+'"][@min-os-version]');
+    platformMinOS = platformMinOS[0] ? platformMinOS[0].attrib["min-os-version"] : null
+
+    platformMinSDK = pluginElement.findall('./platform[@name="'+platform+'"][@min-sdk-version]');
+    platformMinSDK = platformMinSDK[0] ? platformMinSDK[0].attrib["min-sdk-version"] : null;
     
     return { 'cordovaMinVersion': cordovaMinVersion, 'platformMinOS' : platformMinOS, 'platformMinSDK' : platformMinSDK };
 }
@@ -199,7 +204,7 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
     var platformPath = path.join(project_dir, 'cordova', 'platformReq');
     
     var currentProjectInfo = getCurrentProjectVersion(versionPath, platformPath);
-    var minRequirements = getMinReq(plugin_et);
+    var minRequirements = getMinReq(plugin_et, platform);
     
     checkMinimumReq(currentProjectInfo, minRequirements, platform, callback);
     


[5/5] git commit: [CB-4036] - synching up with master and fixed failing tests

Posted by ti...@apache.org.
[CB-4036] - synching up with master and fixed failing tests


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

Branch: refs/heads/versionCheck
Commit: f716822be87f5e765a8495a62696feabdd99af6e
Parents: c68da5b
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Aug 1 15:08:41 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Thu Aug 1 15:08:41 2013 -0700

----------------------------------------------------------------------
 src/install.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/f716822b/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 7ef27ad..d54ed1d 100644
--- a/src/install.js
+++ b/src/install.js
@@ -103,11 +103,9 @@ function getCurrentProjectVersion(versionPath, platformPath) {
     // setting version/platform to null if they do fail or do not exist and then just continuing
     
     var cordovaVersion, platformInfo;
-    
-    fs.chmodSync(versionPath, '755');
-    fs.chmodSync(platformPath, '755');
 
     if (fs.existsSync(versionPath)) {   
+        fs.chmodSync(versionPath, '755');
         var versionScript = shell.exec(versionPath, {silent: true});
         if (versionScript.code === 0) {
             cordovaVersion = versionScript.output.trim();
@@ -125,6 +123,7 @@ function getCurrentProjectVersion(versionPath, platformPath) {
     }  
     
     if (fs.existsSync(platformPath)) {   
+        fs.chmodSync(platformPath, '755');
         var platformScript = shell.exec(platformPath, {silent: true});
         if (platformScript.code === 0) {
             // thinking platformScript.output would be a JSON string like:
@@ -156,6 +155,7 @@ function getMinReq(pluginElement, platform){
             });
     
     
+    // these elements are still in flux - most likely to change when the platforms start implementing these scripts
     platformMinOS = pluginElement.findall('./platform[@name="'+platform+'"][@min-os-version]');
     platformMinOS = platformMinOS[0] ? platformMinOS[0].attrib["min-os-version"] : null