You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2014/01/09 15:17:43 UTC

webworks commit: CB-5741 Send single command for uninstall / install

Updated Branches:
  refs/heads/master 048fda118 -> 86e654ca0


CB-5741 Send single command for uninstall / install

- Fixes issues with app name / icon persisting in navigator during re-deploy


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

Branch: refs/heads/master
Commit: 86e654ca0d2f5d5fa3048dfca08a5b9dd7b56867
Parents: 048fda1
Author: Kristoffer Flores <kf...@blackberry.com>
Authored: Tue Jan 7 14:00:13 2014 -0500
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Thu Jan 9 09:19:33 2014 -0500

----------------------------------------------------------------------
 .../templates/project/cordova/lib/run-utils.js  | 62 ++++++--------------
 .../bin/templates/project/cordova/lib/run.js    |  6 +-
 2 files changed, 19 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/86e654ca/blackberry10/bin/templates/project/cordova/lib/run-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/run-utils.js b/blackberry10/bin/templates/project/cordova/lib/run-utils.js
index 5f74615..82bb436 100644
--- a/blackberry10/bin/templates/project/cordova/lib/run-utils.js
+++ b/blackberry10/bin/templates/project/cordova/lib/run-utils.js
@@ -183,7 +183,7 @@ function handleDebugToken(options, deployTarget, allDone) {
     }
 }
 
-function generateDeployOptions(options, deployTarget, uninstall) {
+function generateDeployOptions(options, deployTarget) {
     var deployOptions = [],
         barPath = pkgrUtils.escapeStringForShell(
             path.normalize(__dirname + "/../../build/" +
@@ -200,20 +200,14 @@ function generateDeployOptions(options, deployTarget, uninstall) {
 
     deployOptions.push("-package");
     deployOptions.push(barPath);
+    deployOptions.push("-uninstallApp");
+    deployOptions.push("-installApp");
 
-    if (uninstall) {
-        deployOptions.push("-uninstallApp");
-        return deployOptions;
-    } else {
-
-        deployOptions.push("-installApp");
-
-        if (options.launch) {
-            deployOptions.push("-launchApp");
-        }
-
-        return deployOptions;
+    if (options.launch) {
+        deployOptions.push("-launchApp");
     }
+
+    return deployOptions;
 }
 
 function execNativeDeploy(deployOptions, callback) {
@@ -236,16 +230,11 @@ _self = {
             ], callback
         );
     },
-    //options looking for are: (launch) Function returns (error || null)
-    deployToTarget : function (options, deployTarget, callback) {
-        execNativeDeploy(generateDeployOptions(options, deployTarget, false));
-    },
 
-    //options looking for are: (uninstall) Function returns (error || null)
-    uninstall : function (options, deployTarget, allDone) {
+    //Function returns (error || null)
+    install : function (options, deployTarget, allDone) {
         var script = path.join(process.env.CORDOVA_BBTOOLS, "blackberry-deploy"),
             args = [
-                "-listInstalledApps",
                 "-device",
                 deployTarget.ip
             ],
@@ -253,34 +242,18 @@ _self = {
             installedAppsOutput,
             runTasks = [];
 
-        if (options.uninstall) {
-            if (deployTarget.password) {
-                args.push("-password", deployTarget.password);
-            }
-            runTasks = [
-                utils.exec.bind(this, script, args, { "cwd": projectRootDir, _customOptions: {silent: true}}),
-                function listInstalledAppsOutput(stdout, stderr, done) {
-                    installedAppsOutput = stdout;
-                    fs.readFile(path.join(__dirname + "/../../www/", "config.xml"), done);
-                },
-                function configXMLOutput(result, done) {
-                    var parser = new xml2js.Parser();
-                    parser.parseString(result, done);
-                },
-                function parsedConfigXMLOutput(result, done) {
-                    if (installedAppsOutput.indexOf(result['@'].id) !== -1) {
-                        var deployOptions = generateDeployOptions(options, deployTarget, true);
-                        execNativeDeploy(deployOptions, done);
-                    } else {
-                        done();
-                    }
-                }
-            ];
+        if (deployTarget.password) {
+            args.push("-password", deployTarget.password);
         }
+        runTasks = [
+            function uninstallInstallLaunchApp (result, done) {
+                var deployOptions = generateDeployOptions(options, deployTarget);
+                execNativeDeploy(deployOptions, done);
+            }
+        ];
 
         async.waterfall(runTasks,
             function (err, results) {
-                //Absorb error for uninstallation
                 allDone(null, deployTarget);
             }
         );
@@ -296,7 +269,6 @@ _self = {
         } else {
             allDone("No build file exists, please run: build [--debug] [--release] [-k | --keystorepass] [-b | --buildId <number>] [-p | --params <json>] [-ll | --loglevel <level>] ");
         }
-
     },
 
     //No options needed within function Function returns (error || options, targetName)

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/86e654ca/blackberry10/bin/templates/project/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/run.js b/blackberry10/bin/templates/project/cordova/lib/run.js
index 4b4bcba..f60cd14 100755
--- a/blackberry10/bin/templates/project/cordova/lib/run.js
+++ b/blackberry10/bin/templates/project/cordova/lib/run.js
@@ -33,8 +33,7 @@ function install(deployTarget, done) {
         installTasks.push(utils.exec.bind(this, buildCmd, buildArgs, {"cwd": projectRootDir}));
     }
 
-    installTasks.push(runUtils.uninstall.bind(this, options, deployTarget),
-                      runUtils.deployToTarget.bind(this, options, deployTarget));
+    installTasks.push(runUtils.install.bind(this, options, deployTarget));
 
     async.series(installTasks, done);
 }
@@ -47,10 +46,9 @@ options
     .option('--devicepass <password>', 'device password')
     .option('--target <id>', 'specifies the target to run the application')
     .option('--query', 'query on the commandline when a password is needed')
-    .option('--no-uninstall', 'does not uninstall application from device')
     .option('--no-launch', 'do not launch the application on device')
     .option('--no-build', 'deploy the pre-built bar file and skip building')
-    .on('--help', function () {
+    .on('--help', function() {
         console.log('  Examples:');
         console.log('');
         console.log("  Deploying to a predefined target");