cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alsoro...@apache.org
Subject cordova-paramedic git commit: Added --cli argument
Date Thu, 26 Jan 2017 12:11:27 GMT
Repository: cordova-paramedic
Updated Branches:
  refs/heads/master 6991af657 -> e9c056c2c


Added --cli argument


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

Branch: refs/heads/master
Commit: e9c056c2c2563814a3b6dacc06fbd681bc9cffb7
Parents: 6991af6
Author: Alexander Sorokin <alexander.sorokin@akvelon.com>
Authored: Thu Jan 26 14:36:59 2017 +0300
Committer: Alexander Sorokin <alexander.sorokin@akvelon.com>
Committed: Thu Jan 26 15:06:54 2017 +0300

----------------------------------------------------------------------
 lib/ParamedicConfig.js        | 27 +++++++++++++++++++++++---
 lib/ParamedicTargetChooser.js |  7 ++++---
 lib/PluginsManager.js         |  4 ++--
 lib/appium/AppiumRunner.js    |  4 ++--
 lib/paramedic.js              | 38 +++++++++++++++++++++++++------------
 lib/utils/utilities.js        |  6 +++---
 main.js                       | 39 +++++++++++++++++++++++---------------
 7 files changed, 85 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/e9c056c2/lib/ParamedicConfig.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicConfig.js b/lib/ParamedicConfig.js
index d8a05b9..98546a7 100644
--- a/lib/ParamedicConfig.js
+++ b/lib/ParamedicConfig.js
@@ -27,6 +27,7 @@ var DEFAULT_SAUCE_PLATFORM_VERSION_IOS     = '9.3';
 var DEFAULT_SAUCE_APPIUM_VERSION           = '1.5.3';
 var DEFAULT_BUILD_NAME                     = 'Paramedic sauce test';
 var BROWSERIFY_ARG                         = '--browserify ';
+var DEFAULT_CLI                            = 'cordova'; // use globally installed cordova
by default
 
 var util = require('./utils').utilities;
 
@@ -69,6 +70,7 @@ ParamedicConfig.parseFromArguments = function (argv) {
         ci:                   argv.ci,
         target:               argv.target,
         fileTransferServer:   argv.fileTransferServer,
+        cli:                  argv.cli,
     });
 };
 
@@ -113,9 +115,17 @@ ParamedicConfig.prototype.setAction = function (action) {
 };
 
 ParamedicConfig.prototype.getArgs = function () {
-    return this._config.args;
+    if (this._config.args) {
+        return this._config.args;
+    } else {
+        return '';
+    }
 };
 
+ParamedicConfig.prototype.setArgs = function (args) {
+    this._config.args = args;
+}
+
 ParamedicConfig.prototype.getPlatformId = function () {
     return this._config.platform.split('@')[0];
 };
@@ -217,12 +227,12 @@ ParamedicConfig.prototype.setSkipAppiumTests = function (skipAppiumTests)
{
 };
 
 ParamedicConfig.prototype.isBrowserify = function () {
-    return this._config.args.indexOf(BROWSERIFY_ARG) >= 0;
+    return this.getArgs().indexOf(BROWSERIFY_ARG) >= 0;
 }
 
 ParamedicConfig.prototype.setBrowserify = function (browserify) {
     if (browserify) {
-        this._config.args = BROWSERIFY_ARG + this._config.args;
+        this.setArgs(BROWSERIFY_ARG + this.getArgs());
     } else {
         this._config.args = this._config.args.replace(BROWSERIFY_ARG, '');
     }
@@ -279,4 +289,15 @@ ParamedicConfig.prototype.setFileTransferServer = function (server) {
     this._config.fileTransferServer = server;
 }
 
+ParamedicConfig.prototype.getCli = function () {
+    if (this._config.cli) {
+        return this._config.cli;
+    }
+    return DEFAULT_CLI;
+}
+
+ParamedicConfig.prototype.setCli = function (cli) {
+    this._config.cli = cli;
+}
+
 module.exports = ParamedicConfig;

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/e9c056c2/lib/ParamedicTargetChooser.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicTargetChooser.js b/lib/ParamedicTargetChooser.js
index a343411..35e198a 100644
--- a/lib/ParamedicTargetChooser.js
+++ b/lib/ParamedicTargetChooser.js
@@ -27,9 +27,10 @@ var ParamedicKill = require('./ParamedicKill');
 var ANDROID_RETRY_TIMES = 3;
 var ANDROID_TIME_OUT    = 300000; //5 Minutes
 
-function ParamedicTargetChooser(appPath, platform) {
+function ParamedicTargetChooser(appPath, config) {
     this.appPath = appPath;
-    this.platform = platform;
+    this.platform = config.getPlatformId();
+    this.cli = config.getCli();
 }
 
 ParamedicTargetChooser.prototype.chooseTarget = function (emulator, target) {
@@ -94,7 +95,7 @@ ParamedicTargetChooser.prototype.startAnAndroidEmulator = function (target)
{
 
 ParamedicTargetChooser.prototype.chooseTargetForWindows = function (emulator, target) {
     logger.info('cordova-paramedic: Choosing Target for Windows');
-    var windowsCommand = 'cordova run --list --emulator';
+    var windowsCommand = this.cli + ' run --list --emulator';
 
     logger.info('cordova-paramedic: Running command: ' + windowsCommand);
     var devicesResult = shelljs.exec(windowsCommand, {silent: true, async: false});

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/e9c056c2/lib/PluginsManager.js
----------------------------------------------------------------------
diff --git a/lib/PluginsManager.js b/lib/PluginsManager.js
index df966f6..c497bce 100644
--- a/lib/PluginsManager.js
+++ b/lib/PluginsManager.js
@@ -79,7 +79,7 @@ PluginsManager.prototype.installSinglePlugin = function (plugin) {
     logger.normal('cordova-paramedic: installing ' + plugin);
     // var pluginPath = path.resolve(this.storedCWD, plugin);
 
-    var plugAddCmd = exec('cordova plugin add ' + plugin);
+    var plugAddCmd = exec(this.config.getCli() + ' plugin add ' + plugin);
     if (plugAddCmd.code !== 0) {
         logger.error('Failed to install plugin : ' + plugin);
         throw new Error('Failed to install plugin : ' + plugin);
@@ -88,7 +88,7 @@ PluginsManager.prototype.installSinglePlugin = function (plugin) {
 
 PluginsManager.prototype.showPluginsVersions = function () {
     logger.verbose('cordova-paramedic: versions of installed plugins: ');
-    exec('cordova plugins');
+    exec(this.config.getCli() + ' plugins');
 };
 
 module.exports = PluginsManager;

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/e9c056c2/lib/appium/AppiumRunner.js
----------------------------------------------------------------------
diff --git a/lib/appium/AppiumRunner.js b/lib/appium/AppiumRunner.js
index 1415e2f..760a352 100644
--- a/lib/appium/AppiumRunner.js
+++ b/lib/appium/AppiumRunner.js
@@ -418,7 +418,7 @@ AppiumRunner.prototype.prepareApp = function () {
     var fullAppPath = getFullAppPath(self.options.appPath);
     var deviceString = self.options.device ? ' --device' : '';
     var browserifyString = self.options.browserify ? ' --browserify' : '';
-    var buildCommand = 'cordova build ' + self.options.platform + deviceString + browserifyString;
+    var buildCommand = self.options.cli + ' build ' + self.options.platform + deviceString
+ browserifyString;
 
     // remove medic.json and (re)build
     shell.rm(path.join(fullAppPath, 'www', 'medic.json'));
@@ -438,7 +438,7 @@ AppiumRunner.prototype.prepareApp = function () {
         permitAccess(fullAppPath, '*');
         // add cordova-save-image-gallery plugin from npm to enable
         // Appium tests for camera plugin to save test image to the gallery
-        runCommand('cordova plugin add cordova-save-image-gallery', fullAppPath);
+        runCommand(self.options.cli + ' plugin add cordova-save-image-gallery', fullAppPath);
 
         // rebuild the app
         logger.normal('paramedic-appium: Building the app...');

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/e9c056c2/lib/paramedic.js
----------------------------------------------------------------------
diff --git a/lib/paramedic.js b/lib/paramedic.js
index 325e083..9104940 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -64,11 +64,7 @@ ParamedicRunner.prototype.run = function () {
     var self = this;
     var isTestPassed = false;
 
-    this.checkSauceRequirements();
-
-    if (!self.config.runMainTests() && !self.config.runAppiumTests()) {
-        throw new Error('No tests to run: both --skipAppiumTests and --skipMainTests are
used');
-    }
+    self.checkConfig();
 
     return Q().then(function () {
         self.createTempProject();
@@ -117,11 +113,28 @@ ParamedicRunner.prototype.run = function () {
     });
 };
 
+ParamedicRunner.prototype.checkConfig = function () {
+    this.checkSauceRequirements();
+    if (!this.config.runMainTests() && !this.config.runAppiumTests()) {
+        throw new Error('No tests to run: both --skipAppiumTests and --skipMainTests are
used');
+    }
+    checkCli: {
+        if (!(this.config.getCli() === 'cordova') && !(this.config.getCli() === 'phonegap'))
{
+            if (path.isAbsolute(this.config.getCli())) {
+                break checkCli;
+            }
+            var cliAbsolutePath = path.resolve(this.config.getCli());
+            this.config.setCli(cliAbsolutePath);
+        }
+    }
+    logger.info('cordova-paramedic: Will use the following cli: ' + this.config.getCli());
+};
+
 ParamedicRunner.prototype.createTempProject = function () {
     this.tempFolder = tmp.dirSync();
     tmp.setGracefulCleanup();
     logger.info('cordova-paramedic: creating temp project at ' + this.tempFolder.name);
-    exec('cordova create ' + this.tempFolder.name);
+    exec(this.config.getCli() + ' create ' + this.tempFolder.name);
 };
 
 ParamedicRunner.prototype.prepareProjectToRunTests = function () {
@@ -167,7 +180,7 @@ ParamedicRunner.prototype.installPlatform = function () {
     var platform = this.config.getPlatform();
     logger.info('cordova-paramedic: adding platform ' + platform);
 
-    return execPromise('cordova platform add ' + platform)
+    return execPromise(this.config.getCli() + ' platform add ' + platform)
     .then(function () {
         logger.info('cordova-paramedic: successfully finished adding platform ' + platform);
     });
@@ -177,7 +190,7 @@ ParamedicRunner.prototype.checkPlatformRequirements = function () {
     var platformId = this.config.getPlatformId();
 
     logger.normal('cordova-paramedic: checking requirements for platform ' + platformId);
-    return execPromise('cordova requirements ' + platformId)
+    return execPromise(this.config.getCli() + ' requirements ' + platformId)
     .then(function () {
         logger.info('cordova-paramedic: successfully finished checking requirements for platform
' + platformId);
     });
@@ -328,7 +341,8 @@ ParamedicRunner.prototype.runAppiumTests = function (useSauce) {
         output: self.config.getOutputDir(),
         verbose: self.config.isVerbose(),
         sauce: useSauce,
-        browserify: self.config.isBrowserify
+        browserify: self.config.isBrowserify,
+        cli: self.config.getCli(),
     };
     if (useSauce) {
         options.sauceAppPath = 'sauce-storage:' + this.getAppName();
@@ -411,8 +425,8 @@ ParamedicRunner.prototype.waitForTests = function () {
 
 ParamedicRunner.prototype.getCommandForStartingTests = function () {
     var self = this;
-    var cmd  = 'cordova ' + this.config.getAction() + ' ' + this.config.getPlatformId();
-    var paramedicTargetChooser = new ParamedicTargetChooser(this.tempFolder.name, this.config.getPlatformId());
+    var cmd  = self.config.getCli() + ' ' + this.config.getAction() + ' ' + this.config.getPlatformId();
+    var paramedicTargetChooser = new ParamedicTargetChooser(this.tempFolder.name, this.config);
 
     if(self.config.getAction() === 'build' || (self.config.getPlatformId() === 'windows'
&& self.config.getArgs().indexOf('appx=8.1-phone') < 0)) {
         //The app is to be run as a store app or just build. So no need to choose a target.
@@ -449,7 +463,7 @@ ParamedicRunner.prototype.getCommandForStartingTests = function () {
 
 ParamedicRunner.prototype.getCommandForBuilding = function () {
     var browserifyArg = this.config.isBrowserify() ? ' --browserify' : '';
-    var cmd = 'cordova build ' + this.config.getPlatformId() + browserifyArg;
+    var cmd = this.config.getCli() + ' build ' + this.config.getPlatformId() + browserifyArg;
 
     return cmd;
 };

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/e9c056c2/lib/utils/utilities.js
----------------------------------------------------------------------
diff --git a/lib/utils/utilities.js b/lib/utils/utilities.js
index e91279f..edf4b20 100644
--- a/lib/utils/utilities.js
+++ b/lib/utils/utilities.js
@@ -61,12 +61,12 @@ function getSimulatorsFolder() {
     return simulatorsFolderPath;
 }
 
-function getSimulatorModelId(target) {
+function getSimulatorModelId(cli, target) {
     var findSimCommand;
     if (target) {
-        findSimCommand = 'cordova run --list --emulator | grep ' + target + ' | tail -n1';
+        findSimCommand = cli + ' run --list --emulator | grep ' + target + ' | tail -n1';
     } else {
-        findSimCommand = 'cordova run --list --emulator | grep ^iPhone | tail -n1';
+        findSimCommand = cli + ' run --list --emulator | grep ^iPhone | tail -n1';
     }
 
     logger.info('running:');

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/e9c056c2/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index 172abbe..276a813 100755
--- a/main.js
+++ b/main.js
@@ -38,27 +38,28 @@ var USAGE           = "Error missing args. \n" +
     "`MSECS` : (optional) time in millisecs to wait for tests to pass|fail \n" +
               "\t(defaults to 10 minutes) \n" +
     "`PORTNUM` : (optional) ports to find available and use for posting results from emulator
back to paramedic server(default is from 8008 to 8009)\n" +
-    "--target : (optional) target to deploy to\n" +
-    "--justbuild : (optional) just builds the project, without running the tests \n" +
     "--browserify : (optional) plugins are browserified into cordova.js \n" +
-    "--verbose : (optional) verbose mode. Display more information output\n" +
-    "--useTunnel: (optional) use tunneling instead of local address. default is false\n"
+
-    "--config : (optional) read configuration from paramedic configuration file\n" +
-    "--outputDir : (optional) path to save Junit results file & Device logs\n" +
+    "--buildName : (optional) Build name to show in Saucelabs dashboard\n" +
+    "--ci : (optional) Skip tests that require user interaction\n" +
     "--cleanUpAfterRun : (optional) cleans up the application after the run\n" +
+    "--cli : (optional) A path to Cordova CLI\n" +
+    "--config : (optional) read configuration from paramedic configuration file\n" +
+    "--fileTransferServer : (optional) (cordova-plugin-file-transfer only) A server address
tests should connect to\n" +
+    "--justbuild : (optional) just builds the project, without running the tests \n" +
     "--logMins : (optional) Windows only - specifies number of minutes to get logs\n" +
-    "--tccDb : (optional) iOS only - specifies the path for the TCC.db file to be copied.\n"
+
-    "--shouldUseSauce : (optional) run tests on Saucelabs\n" +
-    "--buildName : (optional) Build name to show in Saucelabs dashboard\n" +
-    "--sauceUser : (optional) Saucelabs username\n" +
-    "--sauceKey : (optional) Saucelabs access key\n" +
+    "--outputDir : (optional) path to save Junit results file & Device logs\n" +
+    "--sauceAppiumVersion : (optional) Appium version to use when running on Saucelabs. For
example, \"1.5.3\"\n" +
     "--sauceDeviceName : (optional) Name of the SauceLabs emulator. For example, \"iPhone
Simulator\"\n" +
+    "--sauceKey : (optional) Saucelabs access key\n" +
     "--saucePlatformVersion : (optional) Platform version of the SauceLabs emulator. For
example, \"9.3\"\n" +
-    "--sauceAppiumVersion : (optional) Appium version to use when running on Saucelabs. For
example, \"1.5.3\"\n" +
-    "--skipMainTests : (optional) Do not run main (cordova-test-framework) tests\n" +
+    "--sauceUser : (optional) Saucelabs username\n" +
+    "--shouldUseSauce : (optional) run tests on Sauce Labs\n" +
     "--skipAppiumTests : (optional) Do not run Appium tests\n" +
-    "--ci : (optional) Skip tests that require user interaction\n" +
-    "--fileTransferServer : (optional) (cordova-plugin-file-transfer only) A server address
tests should connect to\n" +
+    "--skipMainTests : (optional) Do not run main (cordova-test-framework) tests\n" +
+    "--target : (optional) target to deploy to\n" +
+    "--tccDb : (optional) iOS only - specifies the path for the TCC.db file to be copied.\n"
+
+    "--useTunnel: (optional) use tunneling instead of local address. default is false\n"
+
+    "--verbose : (optional) verbose mode. Display more information output\n" +
     "";
 
 var argv = parseArgs(process.argv.slice(2));
@@ -161,6 +162,14 @@ if (pathToParamedicConfig || // --config
         paramedicConfig.setBrowserify(true);
     }
 
+    if (argv.cli) {
+        paramedicConfig.setCli(argv.cli);
+    }
+
+    if (argv.args) {
+        paramedicConfig.setArgs(argv.args);
+    }
+
     paramedic.run(paramedicConfig)
     .catch(function (error) {
         if (error && error.stack) {


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


Mime
View raw message