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/27 01:47:43 UTC

[09/17] git commit: [CB-4036] - fixed up the default engines and added some tests

[CB-4036] - fixed up the default engines and added some 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/d1db04ae
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/d1db04ae
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/d1db04ae

Branch: refs/heads/master
Commit: d1db04ae822b37e47a99560bb96e0a068cfb5f27
Parents: 9d6b99e
Author: Tim Kim <ti...@adobe.com>
Authored: Fri Aug 23 15:26:06 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:17 2013 -0700

----------------------------------------------------------------------
 spec/install.spec.js                        |  8 ++-
 spec/plugins/EnginePluginAndroid/plugin.xml |  1 +
 src/install.js                              |  8 +--
 src/util/default-engines.js                 | 74 ++++++++++++------------
 4 files changed, 50 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d1db04ae/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index 22740ef..97e8f1d 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -74,12 +74,18 @@ describe('install', function() {
             install('android', temp, 'engineplugin', plugins_dir, {});
             expect(spy).toHaveBeenCalledWith('3.0.0-rc1','>=2.3.0');
         });
-        it('should check specific platform version if specified', function() {
+        it('should check specific platform version over cordova version if specified', function() {
             var spy = spyOn(semver, 'satisfies').andReturn(true);
             exec.andReturn({code:0,output:"3.1.0"});
             install('android', temp, 'enginepluginAndroid', plugins_dir, {});
             expect(spy).toHaveBeenCalledWith('3.1.0','>=3.1.0');
         });
+        it('should check platform sdk version if specified', function() {
+            var spy = spyOn(semver, 'satisfies').andReturn(true);
+            exec.andReturn({code:0,output:"4.3"});
+            install('android', temp, 'enginepluginAndroid', plugins_dir, {});
+            expect(spy).toHaveBeenCalledWith('4.3','>=4.3');
+        });
         it('should check plugmans version', function() {
             var spy = spyOn(semver, 'satisfies').andReturn(true);
             install('android', temp, 'engineplugin', plugins_dir, {});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d1db04ae/spec/plugins/EnginePluginAndroid/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePluginAndroid/plugin.xml b/spec/plugins/EnginePluginAndroid/plugin.xml
index 894bd02..7ada4ae 100644
--- a/spec/plugins/EnginePluginAndroid/plugin.xml
+++ b/spec/plugins/EnginePluginAndroid/plugin.xml
@@ -26,6 +26,7 @@
     <engines>
         <engine name="cordova" version=">=3.0.0"/>
         <engine name="cordova-android" version=">=3.1.0"/>
+        <engine name="android-sdk" version=">=4.3"/>
     </engines>
     
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d1db04ae/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index cfaead9..bb3a2e2 100644
--- a/src/install.js
+++ b/src/install.js
@@ -65,7 +65,7 @@ function possiblyFetch(actions, platform, project_dir, id, plugins_dir, options,
     }
 }
 
-function checkMinimumReq(engines, callback) {
+function checkEngines(engines, callback) {
     engines.forEach(function(engine){    
         if(semver.satisfies(engine.currentVersion, engine.minVersion || engine.currentVersion == null)){
             // engine ok!
@@ -123,7 +123,7 @@ function callEngineScripts(engines) {
 // return only the engines we care about/need
 function getEngines(pluginElement, platform, project_dir){
     var engines = pluginElement.findall('engines/engine');
-    var defaultEngines = require('./util/default-engines');
+    var defaultEngines = require('./util/default-engines')(project_dir);
     var uncheckedEngines = [];
     var tempEngine, cordovaEngineIndex, cordovaPlatformEngineIndex, theName;
     // load in known defaults and update when necessary
@@ -132,7 +132,7 @@ function getEngines(pluginElement, platform, project_dir){
         if(defaultEngines[theName] && (defaultEngines[theName].platform === platform || defaultEngines[theName].platform === '*')){
             defaultEngines[theName].minVersion = defaultEngines[theName].minVersion ? defaultEngines[theName].minVersion : engine.attrib["version"];
             defaultEngines[theName].currentVersion = defaultEngines[theName].currentVersion ? defaultEngines[theName].currentVersion : null;
-            defaultEngines[theName].scriptSrc = defaultEngines[theName].scriptSrc ? path.join(project_dir, defaultEngines[theName].scriptSrc) : null;
+            defaultEngines[theName].scriptSrc = defaultEngines[theName].scriptSrc ? defaultEngines[theName].scriptSrc : null;
             defaultEngines[theName].name = theName;
             
             // set the indices so we can pop the cordova engine when needed
@@ -186,7 +186,7 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
     
     var theEngines = getEngines(plugin_et, platform, project_dir);
     theEngines = callEngineScripts(theEngines);
-    checkMinimumReq(theEngines, callback);
+    checkEngines(theEngines, callback);
     
     // checking preferences, if certain variables are not provided, we should throw.
     prefs = plugin_et.findall('./preference') || [];

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d1db04ae/src/util/default-engines.js
----------------------------------------------------------------------
diff --git a/src/util/default-engines.js b/src/util/default-engines.js
index 0ab9b4f..cdfdfde 100644
--- a/src/util/default-engines.js
+++ b/src/util/default-engines.js
@@ -4,40 +4,42 @@ var path = require('path');
 // it'd be nice to just point to this file and get the correct path
 // since these scripts should ideally be accessed from the cordova project folder
 
-module.exports = {
-    'cordova': 
-        { 'platform':'*', 'scriptSrc': path.join('cordova','version') },   
-    // no location needed for plugman as this should be the calling process
-    'cordova-plugman': 
-        { 'platform':'*', 'currentVersion': process.version },
-    'cordova-android': 
-        { 'platform':'android', 'scriptSrc': path.join('cordova','version') },
-    'cordova-ios': 
-        { 'platform':'ios', 'scriptSrc': path.join('cordova','version') },
-    'cordova-blackberry10': 
-        { 'platform':'blackberry10', 'scriptSrc': path.join('cordova','version') },
-    'cordova-wp7': 
-        { 'platform':'wp7', 'scriptSrc': path.join('cordova','version') },
-    'cordova-wp8': 
-        { 'platform':'wp8', 'scriptSrc': path.join('cordova','version') },
-    'cordova-windows8': 
-        { 'platform':'windows8', 'scriptSrc': path.join('cordova','version') },
-    
-    // ideally these sdk versions will be known via a script
-    // that calls the sdk's version command - the idea would be that
-    // these version scripts output all in the same way and parse
-    // the appropriate blob of info returned from the sdk version command
-    'apple-xcode' : 
-        { 'platform':'ios', 'scriptSrc': '' },
-    'apple-ios' : 
-        { 'platform':'ios', 'scriptSrc': '' },
-    'blackberry-webworks' : 
-        // use path to sdk/Framework/lib/webworks-info.js 
-        // will export as version number
-        // currently though, all versions of webworks sdk should be good to go 
-        // so this is technically *not* needed right now
-        { 'platform':'blackberry10', 'scriptSrc': '' },
-    'android-sdk' : 
-        // will have to parse string output from android list targets
-        { 'platform':'android', 'scriptSrc': '' }
+module.exports = function(project_dir){
+    return {
+        'cordova': 
+            { 'platform':'*', 'scriptSrc': path.join(project_dir,'cordova','version') },   
+        // no location needed for plugman as this should be the calling process
+        'cordova-plugman': 
+            { 'platform':'*', 'currentVersion': process.version },
+        'cordova-android': 
+            { 'platform':'android', 'scriptSrc': path.join(project_dir,'cordova','version') },
+        'cordova-ios': 
+            { 'platform':'ios', 'scriptSrc': path.join(project_dir,'cordova','version') },
+        'cordova-blackberry10': 
+            { 'platform':'blackberry10', 'scriptSrc': path.join(project_dir,'cordova','version') },
+        'cordova-wp7': 
+            { 'platform':'wp7', 'scriptSrc': path.join(project_dir,'cordova','version') },
+        'cordova-wp8': 
+            { 'platform':'wp8', 'scriptSrc': path.join(project_dir,'cordova','version') },
+        'cordova-windows8': 
+            { 'platform':'windows8', 'scriptSrc': path.join(project_dir,'cordova','version') },
+        
+        // ideally these sdk versions will be known via a script
+        // that calls the sdk's version command - the idea would be that
+        // these version scripts output all in the same way and parse
+        // the appropriate blob of info returned from the sdk version command
+        'apple-xcode' : 
+            { 'platform':'ios', 'scriptSrc': '' },
+        'apple-ios' : 
+            { 'platform':'ios', 'scriptSrc': '' },
+        'blackberry-webworks' : 
+            // use path to sdk/Framework/lib/webworks-info.js 
+            // will export as version number
+            // currently though, all versions of webworks sdk should be good to go 
+            // so this is technically *not* needed right now
+            { 'platform':'blackberry10', 'scriptSrc': '' },
+        'android-sdk' : 
+            // will have to parse string output from android list targets
+            { 'platform':'android', 'scriptSrc': '' }
+    }
 };