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:35 UTC
[01/17] git commit: [CB-4036] - added test file for checking engine
and versions
Updated Branches:
refs/heads/master 2ea4ddd99 -> 6e76e3a5b
[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/59ff79e0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/59ff79e0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/59ff79e0
Branch: refs/heads/master
Commit: 59ff79e015acf92a2786edab61615a4e4045b966
Parents: 42056f9
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Jul 25 15:00:20 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:15 2013 -0700
----------------------------------------------------------------------
spec/engine.spec.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/59ff79e0/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');
+ });
+ */
+ });
+
+});
[10/17] git commit: [CB-4036] Forgot updated default-engines file
Posted by ti...@apache.org.
[CB-4036] Forgot updated default-engines file
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/c23d328b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/c23d328b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/c23d328b
Branch: refs/heads/master
Commit: c23d328b43d1760e8046e3ce523990fb242f988e
Parents: d1db04a
Author: Tim Kim <ti...@adobe.com>
Authored: Fri Aug 23 15:28:58 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:17 2013 -0700
----------------------------------------------------------------------
src/util/default-engines.js | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c23d328b/src/util/default-engines.js
----------------------------------------------------------------------
diff --git a/src/util/default-engines.js b/src/util/default-engines.js
index cdfdfde..ce5f454 100644
--- a/src/util/default-engines.js
+++ b/src/util/default-engines.js
@@ -1,9 +1,5 @@
var path = require('path');
-// wondering how to nicely store paths here...
-// 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 = function(project_dir){
return {
'cordova':
@@ -24,22 +20,15 @@ module.exports = function(project_dir){
'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
+ // TODO: these scripts have not been made!
'apple-xcode' :
- { 'platform':'ios', 'scriptSrc': '' },
+ { 'platform':'ios', 'scriptSrc': path.join(project_dir,'cordova','apple-xcode-version') },
'apple-ios' :
- { 'platform':'ios', 'scriptSrc': '' },
+ { 'platform':'ios', 'scriptSrc': path.join(project_dir,'cordova','apple-ios-version') },
'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': '' },
+ { 'platform':'blackberry10', 'scriptSrc': path.join(project_dir,'blackberry-webworks-version') },
'android-sdk' :
// will have to parse string output from android list targets
- { 'platform':'android', 'scriptSrc': '' }
+ { 'platform':'android', 'scriptSrc': path.join(project_dir,'cordova','android-sdk-version') }
}
};
[05/17] 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/d6ac5779
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/d6ac5779
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/d6ac5779
Branch: refs/heads/master
Commit: d6ac5779f7c6a3bb76c8f8c4fee2f6f57d9e3401
Parents: 59ff79e
Author: Tim Kim <ti...@adobe.com>
Authored: Wed Jul 31 16:54:12 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:16 2013 -0700
----------------------------------------------------------------------
src/install.js | 168 ++++++++++++++++++++++++++++++++--------------------
1 file changed, 104 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d6ac5779/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') || [];
[07/17] git commit: [CB-4490 & CB-4036] - added check for
cordova-plugman and made a util function
Posted by ti...@apache.org.
[CB-4490 & CB-4036] - added check for cordova-plugman and made a util function
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/c06a07ef
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/c06a07ef
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/c06a07ef
Branch: refs/heads/master
Commit: c06a07ef550e845bdbf396714357d0fcf312c19a
Parents: faccfd5
Author: Tim Kim <ti...@adobe.com>
Authored: Tue Aug 13 15:11:50 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:16 2013 -0700
----------------------------------------------------------------------
spec/plugins/EnginePlugin/plugin.xml | 1 +
src/install.js | 26 +++++++++++++++-----------
src/util/default-engines.js | 13 ++++++++++++-
3 files changed, 28 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c06a07ef/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index fe875a3..169e8d1 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -25,6 +25,7 @@
<engines>
<engine name="cordova" version=">=2.3.0" platform="*" />
+ <engine name="cordova-plugman" version=">=0.10.0" platform="*" />
</engines>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c06a07ef/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index accc25a..4e88b80 100644
--- a/src/install.js
+++ b/src/install.js
@@ -77,6 +77,15 @@ function checkMinimumReq(engines, callback) {
});
}
+function cleanVersionRC(version){
+ var out = version.trim();
+ var rc_index = out.indexOf('rc');
+ if (rc_index > -1) {
+ out = out.substr(0, rc_index) + '-' + out.substr(rc_index);
+ }
+ return out;
+}
+
// exec engine scripts in order to get the current engine version
function callEngineScripts(engines) {
var engineScript;
@@ -86,18 +95,14 @@ function callEngineScripts(engines) {
if(fs.existsSync(engine.scriptTarget)){
fs.chmodSync(engine.scriptTarget, '755');
engineScript = shell.exec(engine.scriptTarget, {silent: true});
-
if (engineScript.code === 0) {
- engineScriptVersion = engineScript.output.trim();
- var rc_index = engineScriptVersion.indexOf('rc');
- if (rc_index > -1) {
- engineScriptVersion = engineScriptVersion.substr(0, rc_index) + '-' + engineScriptVersion.substr(rc_index);
- }
-
+ engineScriptVersion = cleanVersionRC(engineScript.output)
}else{
engineScriptVersion = null;
require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' script failed (has a '+ engine.scriptTarget +' script, but something went wrong executing it), continuing anyways.');
- }
+ }
+ }else if(engine.minVersion){
+ engineScriptVersion = cleanVersionRC(engine.minVersion)
}else{
engineScriptVersion = null;
require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' not detected (lacks a '+ engine.scriptTarget +' script), continuing.');
@@ -114,14 +119,13 @@ function getEngines(pluginElement, platform, project_dir){
var defaultEngines = require('./util/default-engines');
var uncheckedEngines = [];
var tempEngine;
-
// load in all known defaults and compare
engines.forEach(function(engine){
// this may need some changes - what to do for default platforms - why need to specify platforms?
if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
if(defaultEngines[engine.attrib["name"]]){
- defaultEngines[engine.attrib["name"]].minVersion = engine.attrib["version"];
- defaultEngines[engine.attrib["name"]].scriptTarget = path.join(project_dir, defaultEngines[engine.attrib["name"]].scriptTarget);
+ defaultEngines[engine.attrib["name"]].minVersion = defaultEngines[engine.attrib["name"]].minVersion ? defaultEngines[engine.attrib["name"]].minVersion : engine.attrib["version"];
+ defaultEngines[engine.attrib["name"]].scriptTarget = defaultEngines[engine.attrib["name"]].scriptTarget ? path.join(project_dir, defaultEngines[engine.attrib["name"]].scriptTarget) : null;
uncheckedEngines.push(defaultEngines[engine.attrib["name"]]);
}else{
// check for other engines
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/c06a07ef/src/util/default-engines.js
----------------------------------------------------------------------
diff --git a/src/util/default-engines.js b/src/util/default-engines.js
index 4499df6..e1a26d1 100644
--- a/src/util/default-engines.js
+++ b/src/util/default-engines.js
@@ -7,8 +7,9 @@ var path = require('path');
module.exports = {
'cordova':
{ 'platform':'*', 'scriptTarget': path.join('cordova','version') },
+ // no location needed for plugman as this should be the calling process
'cordova-plugman':
- { 'platform':'*', 'scriptTarget': '' },
+ { 'platform':'*', 'minVersion': process.version },
'cordova-android':
{ 'platform':'android', 'scriptTarget': '' },
'cordova-ios':
@@ -21,12 +22,22 @@ module.exports = {
{ 'platform':'wp8', 'scriptTarget': '' },
'cordova-windows8':
{ 'platform':'windows8', 'scriptTarget': '' },
+
+ // 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', 'scriptTarget': '' },
'apple-ios' :
{ 'platform':'ios', 'scriptTarget': '' },
'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', 'scriptTarget': '' },
'android-sdk' :
+ // will have to parse string output from android list targets
{ 'platform':'android', 'scriptTarget': '' }
};
[13/17] git commit: [CB-4036] - fixed up how plugin install handles
the dev flag for repos as well as cleaned up some errors
Posted by ti...@apache.org.
[CB-4036] - fixed up how plugin install handles the dev flag for repos as well as cleaned up some errors
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/0414fe4a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/0414fe4a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/0414fe4a
Branch: refs/heads/master
Commit: 0414fe4a332dc38b4ea632e43c90bb1bb36a4f29
Parents: c06a07e
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Aug 15 17:13:03 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:17 2013 -0700
----------------------------------------------------------------------
spec/plugins/EnginePlugin/plugin.xml | 1 +
src/install.js | 58 +++++++++++++++++++------------
src/util/default-engines.js | 14 ++++----
3 files changed, 44 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0414fe4a/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index 169e8d1..72bf190 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -26,6 +26,7 @@
<engines>
<engine name="cordova" version=">=2.3.0" platform="*" />
<engine name="cordova-plugman" version=">=0.10.0" platform="*" />
+ <engine name="cordova-android" version=">=3.1.0" platform="*" />
</engines>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0414fe4a/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 4e88b80..59334dc 100644
--- a/src/install.js
+++ b/src/install.js
@@ -66,8 +66,8 @@ function possiblyFetch(actions, platform, project_dir, id, plugins_dir, options,
}
function checkMinimumReq(engines, callback) {
- engines.forEach(function(engine){
- if(engine.currentVersion == 'dev' || semver.satisfies(engine.currentVersion, engine.minVersion || engine.currentVersion == null)){
+ engines.forEach(function(engine){
+ if(semver.satisfies(engine.currentVersion, engine.minVersion || engine.currentVersion == null)){
// engine ok!
}else{
var err = new Error('Plugin doesn\'t support this project\'s '+engine.name+' version. '+engine.name+': ' + engine.currentVersion + ', failed version requirement: ' + engine.minVersion);
@@ -77,12 +77,19 @@ function checkMinimumReq(engines, callback) {
});
}
-function cleanVersionRC(version){
+function cleanVersionOutput(version, platform){
var out = version.trim();
var rc_index = out.indexOf('rc');
+ var dev_index = out.indexOf('dev');
if (rc_index > -1) {
out = out.substr(0, rc_index) + '-' + out.substr(rc_index);
- }
+ }
+
+ // strip out the -dev and put a warning about using the dev branch
+ if (dev_index > -1) {
+ out = out.substr(0, dev_index-1);
+ require('../plugman').emit('log', 'Cordova-'+platform+' has been detected as using a development branch. Attemping to install as Cordova-'+platform+' '+out);
+ }
return out;
}
@@ -96,13 +103,13 @@ function callEngineScripts(engines) {
fs.chmodSync(engine.scriptTarget, '755');
engineScript = shell.exec(engine.scriptTarget, {silent: true});
if (engineScript.code === 0) {
- engineScriptVersion = cleanVersionRC(engineScript.output)
+ engineScriptVersion = cleanVersionOutput(engineScript.output, engine.platform)
}else{
engineScriptVersion = null;
require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' script failed (has a '+ engine.scriptTarget +' script, but something went wrong executing it), continuing anyways.');
}
- }else if(engine.minVersion){
- engineScriptVersion = cleanVersionRC(engine.minVersion)
+ }else if(engine.currentVersion){
+ engineScriptVersion = cleanVersionOutput(engine.currentVersion, engine.platform)
}else{
engineScriptVersion = null;
require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' not detected (lacks a '+ engine.scriptTarget +' script), continuing.');
@@ -119,22 +126,37 @@ function getEngines(pluginElement, platform, project_dir){
var defaultEngines = require('./util/default-engines');
var uncheckedEngines = [];
var tempEngine;
- // load in all known defaults and compare
+ var cordovaEngineIndex;
+ var cordovaPlatformEngineIndex;
+
+ var theName;
+ // load in known defaults and update when necessary
engines.forEach(function(engine){
- // this may need some changes - what to do for default platforms - why need to specify platforms?
if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
- if(defaultEngines[engine.attrib["name"]]){
- defaultEngines[engine.attrib["name"]].minVersion = defaultEngines[engine.attrib["name"]].minVersion ? defaultEngines[engine.attrib["name"]].minVersion : engine.attrib["version"];
- defaultEngines[engine.attrib["name"]].scriptTarget = defaultEngines[engine.attrib["name"]].scriptTarget ? path.join(project_dir, defaultEngines[engine.attrib["name"]].scriptTarget) : null;
- uncheckedEngines.push(defaultEngines[engine.attrib["name"]]);
+ theName = engine.attrib["name"];
+ if(defaultEngines[theName]){
+ defaultEngines[theName].minVersion = defaultEngines[theName].minVersion ? defaultEngines[theName].minVersion : engine.attrib["version"];
+ defaultEngines[theName].currentVersion = defaultEngines[theName].currentVersion ? defaultEngines[theName].currentVersion : null;
+ defaultEngines[theName].scriptTarget = defaultEngines[theName].scriptTarget ? path.join(project_dir, defaultEngines[theName].scriptTarget) : null;
+ defaultEngines[theName].name = theName;
+
+ // set the indices so we can pop the cordova engine when needed
+ if(theName==='cordova') cordovaEngineIndex = uncheckedEngines.length;
+ if(theName==='cordova-'+platform) cordovaPlatformEngineIndex = uncheckedEngines.length;
+
+ uncheckedEngines.push(defaultEngines[theName]);
+
}else{
// check for other engines
tempEngine = {};
- tempEngine[engine.attrib["name"]] = { 'platform': engine.attrib["platform"], 'scriptTarget':path.join(project_dir,engine.attrib["scriptTarget"]), 'minVersion' : engine.attrib["version"]};
+ tempEngine[theName] = { 'platform': engine.attrib["platform"], 'scriptTarget':path.join(project_dir,engine.attrib["scriptTarget"]), 'minVersion' : engine.attrib["version"]};
uncheckedEngines.push(tempEngine);
}
}
});
+
+ // make sure we check for platform req's and not just cordova reqs
+ if(cordovaEngineIndex && cordovaPlatformEngineIndex) uncheckedEngines.pop(cordovaEngineIndex);
return uncheckedEngines;
}
@@ -167,14 +189,6 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
if (callback) callback();
return;
}
-
- //var versionPath = path.join(project_dir, 'cordova', 'version');
- // windows8, wp7, wp8 all use a .bat file
- /*
- if (platform === "windows8" || platform === "wp7" || platform === "wp8") {
- versionPath += ".bat";
- }
- */
var theEngines = getEngines(plugin_et, platform, project_dir);
theEngines = callEngineScripts(theEngines);
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0414fe4a/src/util/default-engines.js
----------------------------------------------------------------------
diff --git a/src/util/default-engines.js b/src/util/default-engines.js
index e1a26d1..b041951 100644
--- a/src/util/default-engines.js
+++ b/src/util/default-engines.js
@@ -9,19 +9,19 @@ module.exports = {
{ 'platform':'*', 'scriptTarget': path.join('cordova','version') },
// no location needed for plugman as this should be the calling process
'cordova-plugman':
- { 'platform':'*', 'minVersion': process.version },
+ { 'platform':'*', 'currentVersion': process.version },
'cordova-android':
- { 'platform':'android', 'scriptTarget': '' },
+ { 'platform':'android', 'scriptTarget': path.join('cordova','version') },
'cordova-ios':
- { 'platform':'ios', 'scriptTarget': '' },
+ { 'platform':'ios', 'scriptTarget': path.join('cordova','version') },
'cordova-blackberry10':
- { 'platform':'blackberry10', 'scriptTarget': '' },
+ { 'platform':'blackberry10', 'scriptTarget': path.join('cordova','version') },
'cordova-wp7':
- { 'platform':'wp7', 'scriptTarget': '' },
+ { 'platform':'wp7', 'scriptTarget': path.join('cordova','version') },
'cordova-wp8':
- { 'platform':'wp8', 'scriptTarget': '' },
+ { 'platform':'wp8', 'scriptTarget': path.join('cordova','version') },
'cordova-windows8':
- { 'platform':'windows8', 'scriptTarget': '' },
+ { 'platform':'windows8', 'scriptTarget': 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
[04/17] 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/5504bc2e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/5504bc2e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/5504bc2e
Branch: refs/heads/master
Commit: 5504bc2ef4b68c70e02189940232234df898bbdc
Parents: d6ac577
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Aug 1 14:18:59 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:16 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/5504bc2e/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/5504bc2e/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/5504bc2e/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);
[17/17] git commit: [CB-4036] - forgot to add test file
Posted by ti...@apache.org.
[CB-4036] - forgot to add test file
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/6e76e3a5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/6e76e3a5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/6e76e3a5
Branch: refs/heads/master
Commit: 6e76e3a5bfdc4407aa6b32b53188e8c3a54f7be0
Parents: 2e03e73
Author: Tim Kim <ti...@adobe.com>
Authored: Mon Aug 26 16:32:44 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:18 2013 -0700
----------------------------------------------------------------------
spec/plugins/EnginePlugin/megaBoringVersion | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6e76e3a5/spec/plugins/EnginePlugin/megaBoringVersion
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/megaBoringVersion b/spec/plugins/EnginePlugin/megaBoringVersion
new file mode 100755
index 0000000..cbf7911
--- /dev/null
+++ b/spec/plugins/EnginePlugin/megaBoringVersion
@@ -0,0 +1,23 @@
+#! /bin/sh
+
+#
+# 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.
+#
+
+echo 4.0.0
+exit 0
\ No newline at end of file
[12/17] git commit: [CB-4036] - added more tests and fixed up some
logic
Posted by ti...@apache.org.
[CB-4036] - added more tests and fixed up some logic
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/9d6b99ea
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/9d6b99ea
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/9d6b99ea
Branch: refs/heads/master
Commit: 9d6b99ea3512b6cb326ecd3e7365750e0407eb23
Parents: 0414fe4
Author: Tim Kim <ti...@adobe.com>
Authored: Wed Aug 21 15:10:18 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:17 2013 -0700
----------------------------------------------------------------------
spec/install.spec.js | 18 ++++++++
spec/plugins/EnginePlugin/plugin.xml | 5 +--
spec/plugins/EnginePluginAndroid/plugin.xml | 31 +++++++++++++
src/install.js | 56 +++++++++++-------------
src/util/default-engines.js | 22 +++++-----
5 files changed, 87 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9d6b99ea/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index f3f2e51..22740ef 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -74,6 +74,17 @@ 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() {
+ 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 plugmans version', function() {
+ var spy = spyOn(semver, 'satisfies').andReturn(true);
+ install('android', temp, 'engineplugin', plugins_dir, {});
+ expect(spy).toHaveBeenCalledWith(null,'>=0.10.0');
+ });
it('should queue up actions as appropriate for that plugin and call process on the action stack', function() {
install('android', temp, dummyplugin, plugins_dir, {});
expect(actions_push.calls.length).toEqual(3);
@@ -135,5 +146,12 @@ describe('install', function() {
install('android', temp, 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git', plugins_dir, {});
}).toThrow('"git" command line tool is not installed: make sure it is accessible on your PATH.');
});
+ it('should throw if plugin version is less than the minimum requirement', function(){
+ var spy = spyOn(semver, 'satisfies').andReturn(false);
+ exec.andReturn({code:0,output:"0.0.1"});
+ expect(function() {
+ install('android', temp, 'engineplugin', plugins_dir, {});
+ }).toThrow('Plugin doesn\'t support this project\'s cordova version. cordova: 0.0.1, failed version requirement: >=2.3.0');
+ });
});
});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9d6b99ea/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index 72bf190..4d9332f 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -24,9 +24,8 @@
<name>Engine Choo Choo</name>
<engines>
- <engine name="cordova" version=">=2.3.0" platform="*" />
- <engine name="cordova-plugman" version=">=0.10.0" platform="*" />
- <engine name="cordova-android" version=">=3.1.0" platform="*" />
+ <engine name="cordova" version=">=2.3.0"/>
+ <engine name="cordova-plugman" version=">=0.10.0" />
</engines>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9d6b99ea/spec/plugins/EnginePluginAndroid/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePluginAndroid/plugin.xml b/spec/plugins/EnginePluginAndroid/plugin.xml
new file mode 100644
index 0000000..894bd02
--- /dev/null
+++ b/spec/plugins/EnginePluginAndroid/plugin.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+ xmlns="http://www.phonegap.com/ns/plugins/1.0"
+ id="com.cordova.engine"
+ version="1.0.0">
+
+ <name>Engine Choo Choo</name>
+
+ <engines>
+ <engine name="cordova" version=">=3.0.0"/>
+ <engine name="cordova-android" version=">=3.1.0"/>
+ </engines>
+
+</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9d6b99ea/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 59334dc..cfaead9 100644
--- a/src/install.js
+++ b/src/install.js
@@ -99,20 +99,20 @@ function callEngineScripts(engines) {
var engineScriptVersion;
engines.forEach(function(engine){
- if(fs.existsSync(engine.scriptTarget)){
- fs.chmodSync(engine.scriptTarget, '755');
- engineScript = shell.exec(engine.scriptTarget, {silent: true});
+ if(fs.existsSync(engine.scriptSrc)){
+ fs.chmodSync(engine.scriptSrc, '755');
+ engineScript = shell.exec(engine.scriptSrc, {silent: true});
if (engineScript.code === 0) {
engineScriptVersion = cleanVersionOutput(engineScript.output, engine.platform)
}else{
engineScriptVersion = null;
- require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' script failed (has a '+ engine.scriptTarget +' script, but something went wrong executing it), continuing anyways.');
+ require('../plugman').emit('log', 'Cordova project '+ engine.scriptSrc +' script failed (has a '+ engine.scriptSrc +' script, but something went wrong executing it), continuing anyways.');
}
}else if(engine.currentVersion){
engineScriptVersion = cleanVersionOutput(engine.currentVersion, engine.platform)
}else{
engineScriptVersion = null;
- require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' not detected (lacks a '+ engine.scriptTarget +' script), continuing.');
+ require('../plugman').emit('log', 'Cordova project '+ engine.scriptSrc +' not detected (lacks a '+ engine.scriptSrc +' script), continuing.');
}
engine.currentVersion = engineScriptVersion;
});
@@ -125,34 +125,28 @@ function getEngines(pluginElement, platform, project_dir){
var engines = pluginElement.findall('engines/engine');
var defaultEngines = require('./util/default-engines');
var uncheckedEngines = [];
- var tempEngine;
- var cordovaEngineIndex;
- var cordovaPlatformEngineIndex;
-
- var theName;
+ var tempEngine, cordovaEngineIndex, cordovaPlatformEngineIndex, theName;
// load in known defaults and update when necessary
engines.forEach(function(engine){
- if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
- theName = engine.attrib["name"];
- if(defaultEngines[theName]){
- defaultEngines[theName].minVersion = defaultEngines[theName].minVersion ? defaultEngines[theName].minVersion : engine.attrib["version"];
- defaultEngines[theName].currentVersion = defaultEngines[theName].currentVersion ? defaultEngines[theName].currentVersion : null;
- defaultEngines[theName].scriptTarget = defaultEngines[theName].scriptTarget ? path.join(project_dir, defaultEngines[theName].scriptTarget) : null;
- defaultEngines[theName].name = theName;
-
- // set the indices so we can pop the cordova engine when needed
- if(theName==='cordova') cordovaEngineIndex = uncheckedEngines.length;
- if(theName==='cordova-'+platform) cordovaPlatformEngineIndex = uncheckedEngines.length;
-
- uncheckedEngines.push(defaultEngines[theName]);
-
- }else{
- // check for other engines
- tempEngine = {};
- tempEngine[theName] = { 'platform': engine.attrib["platform"], 'scriptTarget':path.join(project_dir,engine.attrib["scriptTarget"]), 'minVersion' : engine.attrib["version"]};
- uncheckedEngines.push(tempEngine);
- }
- }
+ theName = engine.attrib["name"];
+ 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].name = theName;
+
+ // set the indices so we can pop the cordova engine when needed
+ if(theName==='cordova') cordovaEngineIndex = uncheckedEngines.length;
+ if(theName==='cordova-'+platform) cordovaPlatformEngineIndex = uncheckedEngines.length;
+
+ uncheckedEngines.push(defaultEngines[theName]);
+
+ }else if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
+ // check for other engines
+ tempEngine = {};
+ tempEngine[theName] = { 'platform': engine.attrib["platform"], 'scriptSrc':engine.attrib["scriptSrc"], 'minVersion' : engine.attrib["version"]};
+ uncheckedEngines.push(tempEngine);
+ }
});
// make sure we check for platform req's and not just cordova reqs
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9d6b99ea/src/util/default-engines.js
----------------------------------------------------------------------
diff --git a/src/util/default-engines.js b/src/util/default-engines.js
index b041951..0ab9b4f 100644
--- a/src/util/default-engines.js
+++ b/src/util/default-engines.js
@@ -6,38 +6,38 @@ var path = require('path');
module.exports = {
'cordova':
- { 'platform':'*', 'scriptTarget': path.join('cordova','version') },
+ { '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', 'scriptTarget': path.join('cordova','version') },
+ { 'platform':'android', 'scriptSrc': path.join('cordova','version') },
'cordova-ios':
- { 'platform':'ios', 'scriptTarget': path.join('cordova','version') },
+ { 'platform':'ios', 'scriptSrc': path.join('cordova','version') },
'cordova-blackberry10':
- { 'platform':'blackberry10', 'scriptTarget': path.join('cordova','version') },
+ { 'platform':'blackberry10', 'scriptSrc': path.join('cordova','version') },
'cordova-wp7':
- { 'platform':'wp7', 'scriptTarget': path.join('cordova','version') },
+ { 'platform':'wp7', 'scriptSrc': path.join('cordova','version') },
'cordova-wp8':
- { 'platform':'wp8', 'scriptTarget': path.join('cordova','version') },
+ { 'platform':'wp8', 'scriptSrc': path.join('cordova','version') },
'cordova-windows8':
- { 'platform':'windows8', 'scriptTarget': path.join('cordova','version') },
+ { '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', 'scriptTarget': '' },
+ { 'platform':'ios', 'scriptSrc': '' },
'apple-ios' :
- { 'platform':'ios', 'scriptTarget': '' },
+ { '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', 'scriptTarget': '' },
+ { 'platform':'blackberry10', 'scriptSrc': '' },
'android-sdk' :
// will have to parse string output from android list targets
- { 'platform':'android', 'scriptTarget': '' }
+ { 'platform':'android', 'scriptSrc': '' }
};
[03/17] git commit: [CB-4036] - another pass at the engine/platform
check problem
Posted by ti...@apache.org.
[CB-4036] - another pass at the engine/platform check problem
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/078f9bfb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/078f9bfb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/078f9bfb
Branch: refs/heads/master
Commit: 078f9bfb01e5bec8b6c1a7bf5076918e5f6b3cfd
Parents: eadd4ce
Author: Tim Kim <ti...@adobe.com>
Authored: Wed Aug 7 15:03:54 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:16 2013 -0700
----------------------------------------------------------------------
spec/plugins/EnginePlugin/plugin.xml | 2 +-
src/install.js | 159 ++++++++++++------------------
src/util/default-engines.js | 32 ++++++
3 files changed, 97 insertions(+), 96 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/078f9bfb/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index 62233e3..fe875a3 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -24,7 +24,7 @@
<name>Engine Choo Choo</name>
<engines>
- <engine name="cordova" version=">=2.3.0" />
+ <engine name="cordova" version=">=2.3.0" platform="*" />
</engines>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/078f9bfb/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index d54ed1d..fee217e 100644
--- a/src/install.js
+++ b/src/install.js
@@ -65,104 +65,74 @@ 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)){
+function checkMinimumReq(engines, callback) {
+ engines.forEach(function(engine){
+ if(engine.currentVersion == 'dev' || semver.satisfies(engine.currentVersion, engine.minVersion || engine.currentVersion == null)){
// 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);
+ }else{
+ var err = new Error('Plugin doesn\'t support this project\'s '+engine.name+' version. '+engine.name+': ' + engine.currentVersion + ', failed version requirement: ' + engine.minVersion);
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;
-
- if (fs.existsSync(versionPath)) {
- fs.chmodSync(versionPath, '755');
- var versionScript = shell.exec(versionPath, {silent: true});
- if (versionScript.code === 0) {
- cordovaVersion = versionScript.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.');
- }
+// exec engine scripts in order to get the current engine version
+function callEngineScripts(engines) {
+ var engineScript;
+ var engineScriptVersion;
- 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:
- // { min_os_version: "5.0.0" , min_sdk_version: "1.0.0" }
- platformInfo = platformScript.output;
+ engines.forEach(function(engine){
+ if(fs.exists(engine.scriptTarget)){
+ fs.chmodSync(engine.scriptTarget, '755');
+ engineScript = shell.exec(versionPath, {silent: true});
+
+ if (engineScript.code === 0) {
+ engineScriptVersion = engineScript.output.trim();
+ var rc_index = engineScriptVersion.indexOf('rc');
+ if (rc_index > -1) {
+ engineScriptVersion = engineScriptVersion.substr(0, rc_index) + '-' + engineScriptVersion.substr(rc_index);
+ }
+
+ }else{
+ engineScriptVersion = null;
+ require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' script failed (has a '+ engine.scriptTarget +' script, but something went wrong executing it), continuing anyways.');
+ }
}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.');
- }
+ engineScriptVersion = null;
+ require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' not detected (lacks a '+ engine.scriptTarget +' script), continuing.');
+ }
+ engine.currentVersion = engineScriptVersion;
+
+ });
- return { 'cordovaVersion' : cordovaVersion, 'platformInfo' : platformInfo };
+ return engines;
}
-function getMinReq(pluginElement, platform){
-
- var cordovaMinVersion, platformMinOS, platformMinSDK;
-
+// return only the engines we care about/need
+function getEngines(pluginElement, platform, project_dir){
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
- }
- });
-
-
- // 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
-
- 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 };
+ var defaultEngines = require('./util/default-engines');
+ var uncheckedEngines = [];
+ var tempEngine;
+
+ // load in all known defaults and compare
+ engines.forEach(function(engine){
+ // this may need some changes - what to do for default platforms - why need to specify platforms?
+ if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
+ if(defaultEngines[engine.attrib["name"]]){
+ defaultEngines[engine.attrib["name"]].minVersion = defaultEngines[engine.attrib["version"]];
+ defaultEngines[engine.attrib["name"]].scriptTarget = path.join(project_dir, defaultEngines[engine.attrib["name"]].scriptTarget);
+ uncheckedEngines.push(defaultEngines[engine.attrib["name"]]);
+ }else{
+ // check for other engines
+ tempEngine = {};
+ tempEngine[engine.attrib["name"]] = { 'platform': engine.attrib["platform"], 'scriptTarget':path.join(project_dir,engine.attrib["scriptTarget"]), 'minVersion' : engine.attrib["version"]};
+ uncheckedEngines.push(tempEngine);
+ }
+ }
+ });
+ return uncheckedEngines;
}
@@ -194,19 +164,18 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
if (callback) callback();
return;
}
-
- var versionPath = path.join(project_dir, 'cordova', 'version');
+
+ //var versionPath = path.join(project_dir, 'cordova', 'version');
// windows8, wp7, wp8 all use a .bat file
+ /*
if (platform === "windows8" || platform === "wp7" || platform === "wp8") {
versionPath += ".bat";
}
-
- var platformPath = path.join(project_dir, 'cordova', 'platformReq');
-
- var currentProjectInfo = getCurrentProjectVersion(versionPath, platformPath);
- var minRequirements = getMinReq(plugin_et, platform);
+ */
- checkMinimumReq(currentProjectInfo, minRequirements, platform, callback);
+ var theEngines = getEngines(plugin_et, platform, project_dir);
+ theEngines = callEngineScripts(theEngines);
+ checkMinimumReq(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/078f9bfb/src/util/default-engines.js
----------------------------------------------------------------------
diff --git a/src/util/default-engines.js b/src/util/default-engines.js
new file mode 100644
index 0000000..4499df6
--- /dev/null
+++ b/src/util/default-engines.js
@@ -0,0 +1,32 @@
+var path = require('path');
+
+// wondering how to nicely store paths here...
+// 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':'*', 'scriptTarget': path.join('cordova','version') },
+ 'cordova-plugman':
+ { 'platform':'*', 'scriptTarget': '' },
+ 'cordova-android':
+ { 'platform':'android', 'scriptTarget': '' },
+ 'cordova-ios':
+ { 'platform':'ios', 'scriptTarget': '' },
+ 'cordova-blackberry10':
+ { 'platform':'blackberry10', 'scriptTarget': '' },
+ 'cordova-wp7':
+ { 'platform':'wp7', 'scriptTarget': '' },
+ 'cordova-wp8':
+ { 'platform':'wp8', 'scriptTarget': '' },
+ 'cordova-windows8':
+ { 'platform':'windows8', 'scriptTarget': '' },
+ 'apple-xcode' :
+ { 'platform':'ios', 'scriptTarget': '' },
+ 'apple-ios' :
+ { 'platform':'ios', 'scriptTarget': '' },
+ 'blackberry-webworks' :
+ { 'platform':'blackberry10', 'scriptTarget': '' },
+ 'android-sdk' :
+ { 'platform':'android', 'scriptTarget': '' }
+};
[14/17] git commit: [CB-3646] - fixed custom engine src script not
being properly set
Posted by ti...@apache.org.
[CB-3646] - fixed custom engine src script not being properly set
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/d83ce8e6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/d83ce8e6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/d83ce8e6
Branch: refs/heads/master
Commit: d83ce8e61de543542eba928cdf4cb268fdea810c
Parents: 8ed4394
Author: Tim Kim <ti...@adobe.com>
Authored: Mon Aug 26 14:51:41 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:18 2013 -0700
----------------------------------------------------------------------
spec/install.spec.js | 2 +-
spec/plugins/EnginePlugin/megaFunVersion | 23 +++++++++++++++++++++++
spec/plugins/EnginePlugin/plugin.xml | 2 +-
src/install.js | 8 ++++----
4 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d83ce8e6/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index 325c8e8..ccee749 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -94,7 +94,7 @@ describe('install', function() {
it('should check custom engine version', function() {
var spy = spyOn(semver, 'satisfies').andReturn(true);
install('android', temp, 'engineplugin', plugins_dir, {});
- expect(spy).toHaveBeenCalledWith(null,'>=100');
+ expect(spy).toHaveBeenCalledWith(null,'>=1.0.0');
});
it('should queue up actions as appropriate for that plugin and call process on the action stack', function() {
install('android', temp, dummyplugin, plugins_dir, {});
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d83ce8e6/spec/plugins/EnginePlugin/megaFunVersion
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/megaFunVersion b/spec/plugins/EnginePlugin/megaFunVersion
new file mode 100755
index 0000000..1e4c706
--- /dev/null
+++ b/spec/plugins/EnginePlugin/megaFunVersion
@@ -0,0 +1,23 @@
+#! /bin/sh
+
+#
+# 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.
+#
+
+echo 1.0.0
+exit 0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d83ce8e6/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index aef8225..a855d1b 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -26,7 +26,7 @@
<engines>
<engine name="cordova" version=">=2.3.0"/>
<engine name="cordova-plugman" version=">=0.10.0" />
- <engine name="mega-fun-plugin" version=">=100" scriptSrc="megaFunVesion" platform="*" />
+ <engine name="mega-fun-plugin" version=">=1.0.0" scriptSrc="megaFunVersion" platform="*" />
</engines>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/d83ce8e6/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 92d7d9d..13599e5 100644
--- a/src/install.js
+++ b/src/install.js
@@ -67,7 +67,7 @@ function possiblyFetch(actions, platform, project_dir, id, plugins_dir, options,
function checkEngines(engines, callback) {
engines.forEach(function(engine){
- if(semver.satisfies(engine.currentVersion, engine.minVersion || engine.currentVersion == null)){
+ if(semver.satisfies(engine.currentVersion, engine.minVersion) || engine.currentVersion == null){
// engine ok!
}else{
var err = new Error('Plugin doesn\'t support this project\'s '+engine.name+' version. '+engine.name+': ' + engine.currentVersion + ', failed version requirement: ' + engine.minVersion);
@@ -121,7 +121,7 @@ function callEngineScripts(engines) {
}
// return only the engines we care about/need
-function getEngines(pluginElement, platform, project_dir){
+function getEngines(pluginElement, platform, project_dir, plugin_dir){
var engines = pluginElement.findall('engines/engine');
var defaultEngines = require('./util/default-engines')(project_dir);
var uncheckedEngines = [];
@@ -143,7 +143,7 @@ function getEngines(pluginElement, platform, project_dir){
uncheckedEngines.push(defaultEngines[theName]);
// check for other engines
}else if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
- uncheckedEngines.push({ 'name': theName, 'platform': engine.attrib["platform"], 'scriptSrc':engine.attrib["scriptSrc"], 'minVersion' : engine.attrib["version"]});
+ uncheckedEngines.push({ 'name': theName, 'platform': engine.attrib["platform"], 'scriptSrc':path.resolve(plugin_dir, engine.attrib["scriptSrc"]), 'minVersion' : engine.attrib["version"]});
}
});
@@ -182,7 +182,7 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir, opt
return;
}
- var theEngines = getEngines(plugin_et, platform, project_dir);
+ var theEngines = getEngines(plugin_et, platform, project_dir, plugin_dir);
theEngines = callEngineScripts(theEngines);
checkEngines(theEngines, callback);
[02/17] git commit: [CB-4036] - first pass for adding version script
Posted by ti...@apache.org.
[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/42056f9a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/42056f9a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/42056f9a
Branch: refs/heads/master
Commit: 42056f9a79f57956f03820efd3d18ee6b9e62758
Parents: 2ea4ddd
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Jul 25 14:56:23 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:15 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/42056f9a/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/42056f9a/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'));
[16/17] git commit: [CB-4036] - fix for handling current state of
platform branches with version listed as dev
Posted by ti...@apache.org.
[CB-4036] - fix for handling current state of platform branches with version listed as dev
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/0da4b356
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/0da4b356
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/0da4b356
Branch: refs/heads/master
Commit: 0da4b356eecc7c724dcc6c5eda02184b5f812939
Parents: d83ce8e
Author: Tim Kim <ti...@adobe.com>
Authored: Mon Aug 26 15:58:43 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:18 2013 -0700
----------------------------------------------------------------------
src/install.js | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/0da4b356/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 13599e5..9934d82 100644
--- a/src/install.js
+++ b/src/install.js
@@ -77,7 +77,7 @@ function checkEngines(engines, callback) {
});
}
-function cleanVersionOutput(version, platform){
+function cleanVersionOutput(version, name){
var out = version.trim();
var rc_index = out.indexOf('rc');
var dev_index = out.indexOf('dev');
@@ -87,8 +87,13 @@ function cleanVersionOutput(version, platform){
// strip out the -dev and put a warning about using the dev branch
if (dev_index > -1) {
- out = out.substr(0, dev_index-1);
- require('../plugman').emit('log', 'Cordova-'+platform+' has been detected as using a development branch. Attemping to install as Cordova-'+platform+' '+out);
+ // some platform still lists dev branches as just dev, set to null and continue
+ if(out=="dev"){
+ out = null;
+ }else{
+ out = out.substr(0, dev_index-1);
+ }
+ require('../plugman').emit('log', name+' has been detected as using a development branch. Attemping to install anyways.');
}
return out;
}
@@ -97,19 +102,19 @@ function cleanVersionOutput(version, platform){
function callEngineScripts(engines) {
var engineScript;
var engineScriptVersion;
-
+
engines.forEach(function(engine){
if(fs.existsSync(engine.scriptSrc)){
fs.chmodSync(engine.scriptSrc, '755');
engineScript = shell.exec(engine.scriptSrc, {silent: true});
if (engineScript.code === 0) {
- engineScriptVersion = cleanVersionOutput(engineScript.output, engine.platform)
+ engineScriptVersion = cleanVersionOutput(engineScript.output, engine.name)
}else{
engineScriptVersion = null;
require('../plugman').emit('log', 'Cordova project '+ engine.scriptSrc +' script failed (has a '+ engine.scriptSrc +' script, but something went wrong executing it), continuing anyways.');
}
}else if(engine.currentVersion){
- engineScriptVersion = cleanVersionOutput(engine.currentVersion, engine.platform)
+ engineScriptVersion = cleanVersionOutput(engine.currentVersion, engine.name)
}else{
engineScriptVersion = null;
require('../plugman').emit('log', 'Cordova project '+ engine.scriptSrc +' not detected (lacks a '+ engine.scriptSrc +' script), continuing.');
[08/17] git commit: [CB-4036] - fixed up some small errors
Posted by ti...@apache.org.
[CB-4036] - fixed up some small errors
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/faccfd55
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/faccfd55
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/faccfd55
Branch: refs/heads/master
Commit: faccfd55009b98306fb1ff63678817088849a8b3
Parents: 078f9bf
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Aug 8 13:50:18 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:16 2013 -0700
----------------------------------------------------------------------
src/install.js | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/faccfd55/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index fee217e..accc25a 100644
--- a/src/install.js
+++ b/src/install.js
@@ -83,9 +83,9 @@ function callEngineScripts(engines) {
var engineScriptVersion;
engines.forEach(function(engine){
- if(fs.exists(engine.scriptTarget)){
+ if(fs.existsSync(engine.scriptTarget)){
fs.chmodSync(engine.scriptTarget, '755');
- engineScript = shell.exec(versionPath, {silent: true});
+ engineScript = shell.exec(engine.scriptTarget, {silent: true});
if (engineScript.code === 0) {
engineScriptVersion = engineScript.output.trim();
@@ -103,7 +103,6 @@ function callEngineScripts(engines) {
require('../plugman').emit('log', 'Cordova project '+ engine.scriptTarget +' not detected (lacks a '+ engine.scriptTarget +' script), continuing.');
}
engine.currentVersion = engineScriptVersion;
-
});
return engines;
@@ -121,7 +120,7 @@ function getEngines(pluginElement, platform, project_dir){
// this may need some changes - what to do for default platforms - why need to specify platforms?
if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
if(defaultEngines[engine.attrib["name"]]){
- defaultEngines[engine.attrib["name"]].minVersion = defaultEngines[engine.attrib["version"]];
+ defaultEngines[engine.attrib["name"]].minVersion = engine.attrib["version"];
defaultEngines[engine.attrib["name"]].scriptTarget = path.join(project_dir, defaultEngines[engine.attrib["name"]].scriptTarget);
uncheckedEngines.push(defaultEngines[engine.attrib["name"]]);
}else{
[09/17] git commit: [CB-4036] - fixed up the default engines and
added some tests
Posted by ti...@apache.org.
[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': '' }
+ }
};
[15/17] git commit: [CB-4036] - added ability to list multiple
platforms in plugin.xml
Posted by ti...@apache.org.
[CB-4036] - added ability to list multiple platforms in plugin.xml
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/2e03e732
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/2e03e732
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/2e03e732
Branch: refs/heads/master
Commit: 2e03e73225c91c9125c1687521706d22bdb2c528
Parents: 0da4b35
Author: Tim Kim <ti...@adobe.com>
Authored: Mon Aug 26 16:30:43 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:18 2013 -0700
----------------------------------------------------------------------
spec/install.spec.js | 10 +++++++++
spec/plugins/EnginePlugin/plugin.xml | 1 +
src/install.js | 36 +++++++++++++++++++------------
3 files changed, 33 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2e03e732/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index ccee749..04fd7c2 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -96,6 +96,16 @@ describe('install', function() {
install('android', temp, 'engineplugin', plugins_dir, {});
expect(spy).toHaveBeenCalledWith(null,'>=1.0.0');
});
+ it('should check custom engine version that supports multiple platforms', function() {
+ var spy = spyOn(semver, 'satisfies').andReturn(true);
+ install('android', temp, 'engineplugin', plugins_dir, {});
+ expect(spy).toHaveBeenCalledWith(null,'>=3.0.0');
+ });
+ it('should not check custom engine version that is not supported for platform', function() {
+ var spy = spyOn(semver, 'satisfies').andReturn(true);
+ install('blackberry10', temp, 'engineplugin', plugins_dir, {});
+ expect(spy).not.toHaveBeenCalledWith(null,'>=3.0.0');
+ });
it('should queue up actions as appropriate for that plugin and call process on the action stack', function() {
install('android', temp, dummyplugin, plugins_dir, {});
expect(actions_push.calls.length).toEqual(3);
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2e03e732/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index a855d1b..a58f19e 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -27,6 +27,7 @@
<engine name="cordova" version=">=2.3.0"/>
<engine name="cordova-plugman" version=">=0.10.0" />
<engine name="mega-fun-plugin" version=">=1.0.0" scriptSrc="megaFunVersion" platform="*" />
+ <engine name="mega-boring-plugin" version=">=3.0.0" scriptSrc="megaBoringVersion" platform="ios|android" />
</engines>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2e03e732/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 9934d82..1959f07 100644
--- a/src/install.js
+++ b/src/install.js
@@ -130,25 +130,33 @@ function getEngines(pluginElement, platform, project_dir, plugin_dir){
var engines = pluginElement.findall('engines/engine');
var defaultEngines = require('./util/default-engines')(project_dir);
var uncheckedEngines = [];
- var cordovaEngineIndex, cordovaPlatformEngineIndex, theName;
+ var cordovaEngineIndex, cordovaPlatformEngineIndex, theName, platformIndex, defaultPlatformIndex;
// load in known defaults and update when necessary
engines.forEach(function(engine){
theName = engine.attrib["name"];
+
// check to see if the engine is listed as a default engine
- 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 ? defaultEngines[theName].scriptSrc : null;
- defaultEngines[theName].name = theName;
-
- // set the indices so we can pop the cordova engine when needed
- if(theName==='cordova') cordovaEngineIndex = uncheckedEngines.length;
- if(theName==='cordova-'+platform) cordovaPlatformEngineIndex = uncheckedEngines.length;
-
- uncheckedEngines.push(defaultEngines[theName]);
+ if(defaultEngines[theName]){
+ // make sure engine is for platform we are installing on
+ defaultPlatformIndex = defaultEngines[theName].platform.indexOf(platform);
+ if(defaultPlatformIndex > -1 || 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 ? defaultEngines[theName].scriptSrc : null;
+ defaultEngines[theName].name = theName;
+
+ // set the indices so we can pop the cordova engine when needed
+ if(theName==='cordova') cordovaEngineIndex = uncheckedEngines.length;
+ if(theName==='cordova-'+platform) cordovaPlatformEngineIndex = uncheckedEngines.length;
+
+ uncheckedEngines.push(defaultEngines[theName]);
+ }
// check for other engines
- }else if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
- uncheckedEngines.push({ 'name': theName, 'platform': engine.attrib["platform"], 'scriptSrc':path.resolve(plugin_dir, engine.attrib["scriptSrc"]), 'minVersion' : engine.attrib["version"]});
+ }else{
+ platformIndex = engine.attrib["platform"].indexOf(platform);
+ if(platformIndex > -1 || engine.attrib["platform"] === '*'){
+ uncheckedEngines.push({ 'name': theName, 'platform': engine.attrib["platform"], 'scriptSrc':path.resolve(plugin_dir, engine.attrib["scriptSrc"]), 'minVersion' : engine.attrib["version"]});
+ }
}
});
[06/17] 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/eadd4ce0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/eadd4ce0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/eadd4ce0
Branch: refs/heads/master
Commit: eadd4ce05f86c05be001e95385a05238e0b5a37d
Parents: 5504bc2
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Aug 1 15:08:41 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:16 2013 -0700
----------------------------------------------------------------------
src/install.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/eadd4ce0/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
[11/17] git commit: [CB-4036] - fixed custom engine loading and added
test
Posted by ti...@apache.org.
[CB-4036] - fixed custom engine loading and added test
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/8ed43948
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/8ed43948
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/8ed43948
Branch: refs/heads/master
Commit: 8ed43948e7877e89111ae2ab63f4520485fae24c
Parents: c23d328
Author: Tim Kim <ti...@adobe.com>
Authored: Fri Aug 23 16:05:44 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Mon Aug 26 16:47:17 2013 -0700
----------------------------------------------------------------------
spec/install.spec.js | 5 +++++
spec/plugins/EnginePlugin/plugin.xml | 1 +
src/install.js | 10 ++++------
3 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/8ed43948/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index 97e8f1d..325c8e8 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -91,6 +91,11 @@ describe('install', function() {
install('android', temp, 'engineplugin', plugins_dir, {});
expect(spy).toHaveBeenCalledWith(null,'>=0.10.0');
});
+ it('should check custom engine version', function() {
+ var spy = spyOn(semver, 'satisfies').andReturn(true);
+ install('android', temp, 'engineplugin', plugins_dir, {});
+ expect(spy).toHaveBeenCalledWith(null,'>=100');
+ });
it('should queue up actions as appropriate for that plugin and call process on the action stack', function() {
install('android', temp, dummyplugin, plugins_dir, {});
expect(actions_push.calls.length).toEqual(3);
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/8ed43948/spec/plugins/EnginePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/EnginePlugin/plugin.xml b/spec/plugins/EnginePlugin/plugin.xml
index 4d9332f..aef8225 100644
--- a/spec/plugins/EnginePlugin/plugin.xml
+++ b/spec/plugins/EnginePlugin/plugin.xml
@@ -26,6 +26,7 @@
<engines>
<engine name="cordova" version=">=2.3.0"/>
<engine name="cordova-plugman" version=">=0.10.0" />
+ <engine name="mega-fun-plugin" version=">=100" scriptSrc="megaFunVesion" platform="*" />
</engines>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/8ed43948/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index bb3a2e2..92d7d9d 100644
--- a/src/install.js
+++ b/src/install.js
@@ -125,10 +125,11 @@ function getEngines(pluginElement, platform, project_dir){
var engines = pluginElement.findall('engines/engine');
var defaultEngines = require('./util/default-engines')(project_dir);
var uncheckedEngines = [];
- var tempEngine, cordovaEngineIndex, cordovaPlatformEngineIndex, theName;
+ var cordovaEngineIndex, cordovaPlatformEngineIndex, theName;
// load in known defaults and update when necessary
engines.forEach(function(engine){
theName = engine.attrib["name"];
+ // check to see if the engine is listed as a default engine
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;
@@ -140,12 +141,9 @@ function getEngines(pluginElement, platform, project_dir){
if(theName==='cordova-'+platform) cordovaPlatformEngineIndex = uncheckedEngines.length;
uncheckedEngines.push(defaultEngines[theName]);
-
+ // check for other engines
}else if(engine.attrib["platform"] === platform || engine.attrib["platform"] === '*'){
- // check for other engines
- tempEngine = {};
- tempEngine[theName] = { 'platform': engine.attrib["platform"], 'scriptSrc':engine.attrib["scriptSrc"], 'minVersion' : engine.attrib["version"]};
- uncheckedEngines.push(tempEngine);
+ uncheckedEngines.push({ 'name': theName, 'platform': engine.attrib["platform"], 'scriptSrc':engine.attrib["scriptSrc"], 'minVersion' : engine.attrib["version"]});
}
});