cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [3/3] git commit: npm version 2.8.10. [CB-3624] Re-added support for BB10.
Date Thu, 06 Jun 2013 19:26:38 GMT
npm version 2.8.10. [CB-3624] Re-added support for BB10.


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

Branch: refs/heads/master2
Commit: b445b87f9dac418553d7db3387470f3c29b0d6f9
Parents: 437af20
Author: Fil Maj <maj.fil@gmail.com>
Authored: Thu Jun 6 12:26:26 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Thu Jun 6 12:26:26 2013 -0700

----------------------------------------------------------------------
 bin/cordova                                        |    1 +
 package.json                                       |    2 +-
 platforms.js                                       |    2 +-
 spec/cordova-cli/platform.spec.js                  |   38 +++---
 spec/platform-script/blackberry/blackberry.spec.js |   16 ++-
 .../blackberry/blackberry_parser.spec.js           |    5 +-
 src/emulate.js                                     |   23 +++-
 src/metadata/blackberry_parser.js                  |  113 +++++++++++----
 src/prepare.js                                     |    9 +-
 src/run.js                                         |   20 +++-
 10 files changed, 156 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/bin/cordova
----------------------------------------------------------------------
diff --git a/bin/cordova b/bin/cordova
index 17b3569..fc47ad1 100755
--- a/bin/cordova
+++ b/bin/cordova
@@ -22,6 +22,7 @@ process.on('uncaughtException', function(err){
 if (verbose) {
     cordova.on('log', console.log);
     cordova.on('warn', console.warn);
+    process.on('uncaughtException', function(err) { console.error(err.stack) });
 }
 
 if (version) {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index db47513..103ba49 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.9",
+  "version": "2.8.10",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/platforms.js
----------------------------------------------------------------------
diff --git a/platforms.js b/platforms.js
index 1854695..d41abd3 100644
--- a/platforms.js
+++ b/platforms.js
@@ -35,7 +35,7 @@ module.exports = {
         url    : 'https://git-wip-us.apache.org/repos/asf/cordova-wp8.git'
     },
     blackberry : {
-        parser : require('./metadata/blackberry_parser'),
+        parser : require('./src/metadata/blackberry_parser'),
         url    : 'https://git-wip-us.apache.org/repos/asf/cordova-blackberry.git'
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/spec/cordova-cli/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/platform.spec.js b/spec/cordova-cli/platform.spec.js
index 61a6e7e..301ec4b 100644
--- a/spec/cordova-cli/platform.spec.js
+++ b/spec/cordova-cli/platform.spec.js
@@ -69,7 +69,8 @@ describe('platform command', function() {
 
     describe('`ls`', function() { 
         beforeEach(function() {
-            process.chdir(cordova_project);
+            cordova.create(tempDir);
+            process.chdir(tempDir);
         });
 
         afterEach(function() {
@@ -77,19 +78,14 @@ describe('platform command', function() {
         });
 
         it('should list out no platforms for a fresh project', function() {
-            shell.mv('-f', path.join(cordova_project, 'platforms', '*'), tempDir);
-            this.after(function() {
-                shell.mv('-f', path.join(tempDir, '*'), path.join(cordova_project, 'platforms'));
-            });
+            shell.rm('-rf', path.join(tempDir, 'platforms', '*'));
             expect(cordova.platform('list').length).toEqual(0);
         });
 
-        // TODO: false test as environment where these tests are running may or may not have
the specific platform's project built for it. if user does not have the appropriate sdk installed,
this will fail.
-        xit('should list out added platforms in a project', function() {
-            process.chdir(tempDir);
-            cordova.create(tempDir);
-            shell.cp('-Rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir,
'platforms'));
-            shell.cp('-Rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir,
'platforms'));
+        it('should list out added platforms in a project', function() {
+            var platforms = path.join(tempDir, 'platforms');
+            shell.mkdir(path.join(platforms, 'android'));
+            shell.mkdir(path.join(platforms, 'ios'));
             expect(cordova.platform('list').length).toEqual(2);
         });
     });
@@ -118,26 +114,28 @@ describe('platform command', function() {
     });
 
     describe('`remove`',function() {
-        var num_platforms = fs.readdirSync(path.join(cordova_project, 'platforms')).length;

         beforeEach(function() {
-            process.chdir(cordova_project);
-            shell.cp('-rf', path.join(cordova_project, 'platforms' ,'*'), tempDir);
+            cordova.create(tempDir);
+            process.chdir(tempDir);
         });
 
         afterEach(function() {
             process.chdir(cwd);
-            shell.cp('-rf', path.join(tempDir, '*'), path.join(cordova_project, 'platforms'));

         });
 
         it('should remove a supported and added platform', function() {
+            shell.mkdir(path.join(tempDir, 'platforms', 'android'));
+            shell.mkdir(path.join(tempDir, 'platforms', 'ios'));
             cordova.platform('remove', 'android');
-            expect(cordova.platform('ls').length).toEqual(num_platforms - 1);
+            expect(cordova.platform('ls').length).toEqual(1);
         });
-        // TODO: fails if environemtn not configured for the specified paltforms.
-        // need to rethink this.
-        xit('should be able to remove multiple platforms', function() {
+
+        it('should be able to remove multiple platforms', function() {
+            shell.mkdir(path.join(tempDir, 'platforms', 'android'));
+            shell.mkdir(path.join(tempDir, 'platforms', 'blackberry'));
+            shell.mkdir(path.join(tempDir, 'platforms', 'ios'));
             cordova.platform('remove', ['android','blackberry']);
-            expect(cordova.platform('ls').length).toEqual(num_platforms - 2);
+            expect(cordova.platform('ls').length).toEqual(1);
         });
     });
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/spec/platform-script/blackberry/blackberry.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/blackberry/blackberry.spec.js b/spec/platform-script/blackberry/blackberry.spec.js
index ff997c1..bb59973 100644
--- a/spec/platform-script/blackberry/blackberry.spec.js
+++ b/spec/platform-script/blackberry/blackberry.spec.js
@@ -23,8 +23,7 @@ describe('Test:', function() {
         };
         var fake_create = function(a_path) {
             shell.mkdir('-p', path.join(a_path, 'www'));
-            fs.writeFileSync(path.join(a_path, 'project.properties'), 'hi', 'utf-8');
-            fs.writeFileSync(path.join(a_path, 'build.xml'), 'hi', 'utf-8');
+            fs.writeFileSync(path.join(a_path, 'project.json'), 'hi', 'utf-8');
             shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry', 'www',
'config.xml'), path.join(a_path, 'www'));
             sh.mostRecentCall.args[2](0, '');
         };
@@ -61,6 +60,9 @@ describe('Test:', function() {
     describe('\'emulate blackberry\'', function() {
         beforeEach(function() {
             process.chdir(tempDir);
+            spyOn(blackberry_parser.prototype, 'get_cordova_config').andReturn({
+                signing_password:'pwd'
+            });
         });
         afterEach(function() {
             process.chdir(cwd);
@@ -68,13 +70,14 @@ describe('Test:', function() {
         shell.rm('-rf', tempDir);
         cordova.create(tempDir);
         shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir,
'platforms'));
-        it('should shell out to ant command on blackberry', function() {
+        it('should shell out to run command with a specific target', function() {
             var proj_spy = spyOn(blackberry_parser.prototype, 'update_project');
+            spyOn(blackberry_parser.prototype, 'get_all_targets').andReturn([{name:'fakesim',type:'simulator'}]);
             var s = spyOn(require('shelljs'), 'exec');
             cordova.emulate('blackberry');
             proj_spy.mostRecentCall.args[1](); // update_project fake
             expect(s).toHaveBeenCalled();
-            var emulate_cmd = 'ant -f .*build\.xml" qnx load-simulator';
+            var emulate_cmd = 'cordova.run" --target=fakesim -k pwd$';
             expect(s.mostRecentCall.args[0]).toMatch(emulate_cmd);
         });
         it('should call blackberry_parser\'s update_project', function() {
@@ -96,10 +99,9 @@ describe('Test:', function() {
         cordova.create(tempDir);
         shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir,
'platforms'));
         it('should shell out to build command', function() {
-            var build_cmd = 'build.xml" qnx load-device';
             var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
             cordova.compile('blackberry');
-            expect(s.mostRecentCall.args[0]).toContain(build_cmd);
+            expect(s.mostRecentCall.args[0]).toMatch(/blackberry.cordova.build"$/gi);
         });
     });
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/spec/platform-script/blackberry/blackberry_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/blackberry/blackberry_parser.spec.js b/spec/platform-script/blackberry/blackberry_parser.spec.js
index 0ed2f2c..ec836e4 100644
--- a/spec/platform-script/blackberry/blackberry_parser.spec.js
+++ b/spec/platform-script/blackberry/blackberry_parser.spec.js
@@ -1,4 +1,3 @@
-
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -204,7 +203,7 @@ describe('blackberry project parser', function() {
                     expect(spyEnv).not.toHaveBeenCalled();
                 });
                 it('should write out project properties', function(done) {
-                    var spyProps = spyOn(parser, 'write_project_properties');
+                    var spyProps = spyOn(parser, 'write_blackberry_environment');
                     parser.update_project(config, function() { 
                         expect(spyProps).toHaveBeenCalled();
                         done();
@@ -229,7 +228,7 @@ describe('blackberry project parser', function() {
                     expect(spyEnv).toHaveBeenCalled();
                 });
                 it('should write out project properties', function(done) {
-                    var spyProps = spyOn(parser, 'write_project_properties');
+                    var spyProps = spyOn(parser, 'write_blackberry_environment');
                     var promptSpy = spyOn(require('prompt'), 'get');
                     parser.update_project(config, function() {
                         expect(spyProps).toHaveBeenCalled();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index a6460c9..2d902b2 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -30,8 +30,20 @@ var cordova_util      = require('./util'),
     hooker            = require('../src/hooker'),
     util              = require('util');
 
-function shell_out_to_emulate(root, platform, callback) {
+function shell_out_to_emulate(root, platform, done) {
     var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" --debug
--emulator';
+    // TODO: inconsistent API for BB10 run command
+    if (platform == 'blackberry') {
+        var bb_project = path.join(root, 'platforms', 'blackberry')
+        var project = new platforms.blackberry.parser(bb_project);
+        if (project.has_simulator_target()) {
+            var bb_config = project.get_cordova_config();
+            var sim = project.get_simulator_targets()[0].name;
+            cmd = '"' + path.join(bb_project, 'cordova', 'run') + '" --target=' + sim + '
-k ' + bb_config.signing_password;
+        } else {
+            throw new Error('No BlackBerry simulator targets defined. If you want to run
emulate with BB10, please add a simulator target. For more information run "' + path.join(bb_project,
'cordova', 'target') + '" -h');
+        }
+    }
     events.emit('log', 'Running on emulator for platform "' + platform + '" via command "'
+ cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
         events.emit('log', output);
@@ -39,7 +51,7 @@ function shell_out_to_emulate(root, platform, callback) {
             throw new Error('An error occurred while emulating/deploying the ' + platform
+ ' project.' + output);
         } else {
             events.emit('log', 'Platform "' + platform + '" deployed to emulator.');
-            callback();
+            done();
         }
     });
 }
@@ -97,7 +109,12 @@ module.exports = function emulate (platformList, callback) {
             else throw err;
         } else {
             platformList.forEach(function(platform) {
-                shell_out_to_emulate(projectRoot, platform, end);
+                try {
+                    shell_out_to_emulate(projectRoot, platform, end);
+                } catch(e) {
+                    if (callback) callback(e);
+                    else throw e;
+                }
             });
         }
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index e3c6f87..9144d13 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -26,8 +26,8 @@ var fs            = require('fs'),
     config_parser = require('../config_parser');
 
 module.exports = function blackberry_parser(project) {
-    if (!fs.existsSync(path.join(project, 'project.properties')) || !fs.existsSync(path.join(project,
'build.xml'))) {
-        throw new Error('The provided path "' + project + '" is not a Cordova BlackBerry
WebWorks project.');
+    if (!fs.existsSync(path.join(project, 'project.json')) || !fs.existsSync(path.join(project,
'www'))) {
+        throw new Error('The provided path "' + project + '" is not a Cordova BlackBerry10
WebWorks project.');
     }
     this.path = project;
     this.config_path = path.join(this.path, 'www', 'config.xml');
@@ -35,8 +35,11 @@ module.exports = function blackberry_parser(project) {
 };
 
 module.exports.check_requirements = function(callback) {
-    // TODO: below, we ask for users to fill out SDK paths, etc. into config.json. Android
requires the sdk path be on the PATH. Which to choose? 
-    callback(false);
+    if (process.env && process.env.QNX_HOST) {
+        callback(false);
+    } else {
+        callback('The BB10NDK environment variable QNX_HOST is missing. Make sure you run
`source <path to bb10ndk>/bbndk-env.sh`. Even better, add `source`ing that script to
your .bash_profile or equivalent so you don\'t have to do it manually every time.');
+    }
 };
 
 module.exports.prototype = {
@@ -81,16 +84,13 @@ module.exports.prototype = {
         var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
         if (dot.blackberry === undefined || dot.blackberry.qnx === undefined) {
-            events.emit('warn', 'WARNING! Missing BlackBerry configuration file.');
+            events.emit('warn', 'WARNING! Missing BlackBerry 10 configuration file, prompting
for information...');
             this.get_blackberry_environment(function() {
-                // Update project.properties
-                self.write_project_properties();
-
+                self.write_blackberry_environment();
                 if (callback) callback();
             });
         } else {
-            // Write out config stuff to project.properties file
-            this.write_project_properties();
+            self.write_blackberry_environment();
             if (callback) callback();
         }
     },
@@ -120,7 +120,7 @@ module.exports.prototype = {
         shell.cp('-rf', www, this.path);
 
         // add cordova.js
-        shell.cp('-f', path.join(util.libDirectory, 'cordova-blackberry', 'javascript', 'cordova.blackberry.js'),
path.join(this.www_dir(), 'cordova.js'));
+        shell.cp('-f', path.join(util.libDirectory, 'cordova-blackberry', 'javascript', 'cordova.blackberry10.js'),
path.join(this.www_dir(), 'cordova.js'));
 
         // add webworks ext directories
         shell.cp('-rf', path.join(util.libDirectory, 'cordova-blackberry', 'framework', 'ext*'),
this.www_dir());
@@ -152,24 +152,11 @@ module.exports.prototype = {
             shell.cp('-rf', staging, this.www_dir());
         }
     },
-
-    write_project_properties:function() {
+    get_cordova_config:function() {
         var projectRoot = util.isCordova(this.path);
-
-        var projFile = path.join(this.path, 'project.properties');
-        var props = fs.readFileSync(projFile, 'utf-8');
-
         var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
-
-        props = props.replace(/qnx\.bbwp\.dir=.*\n/, 'qnx.bbwp.dir=' + dot.blackberry.qnx.bbwp
+ '\n');
-        props = props.replace(/qnx\.sigtool\.password=.*\n/, 'qnx.sigtool.password=' + dot.blackberry.qnx.signing_password
+ '\n');
-        props = props.replace(/qnx\.device\.ip=.*\n/, 'qnx.device.ip=' + dot.blackberry.qnx.device_ip
+ '\n');
-        props = props.replace(/qnx\.device\.password=.*\n/, 'qnx.device.password=' + dot.blackberry.qnx.device_password
+ '\n');
-        props = props.replace(/qnx\.sim\.ip=.*\n/, 'qnx.sim.ip=' + dot.blackberry.qnx.sim_ip
+ '\n');
-        props = props.replace(/qnx\.sim\.password=.*\n/, 'qnx.sim.password=' + dot.blackberry.qnx.sim_password
+ '\n');
-        fs.writeFileSync(projFile, props, 'utf-8');
-        events.emit('log', 'Wrote out BlackBerry 10 configuration file to "' + projFile +
'"');
+        return dot.blackberry.qnx;
     },
     get_blackberry_environment:function(callback) {
         var projectRoot = util.isCordova(this.path);
@@ -179,21 +166,26 @@ module.exports.prototype = {
         events.emit('log', 'Prompting for BlackBerry 10 configuration information...');
         prompt.start();
         prompt.get([{
-            name:'bbwp',
-            required:true,
-            description:'Enter the full path to your BB10 bbwp executable'
-        },{
             name:'signing_password',
             required:true,
-            description:'Enter your BlackBerry signing password',
+            description:'Enter your BlackBerry 10 signing/keystore password',
             hidden:true
         },{
+            name:'device_name',
+            description:'Enter a name for your BB10 device'
+        },{
             name:'device_ip',
             description:'Enter the IP to your BB10 device'
         },{
             name:'device_password',
             description:'Enter the password for your BB10 device'
         },{
+            name:'device_pin',
+            description:'Enter the PIN for your BB10 device (under Settings->About->Hardware)'
+        },{
+            name:'sim_name',
+            description:'Enter a name for your BB10 simulator'
+        },{
             name:'sim_ip',
             description:'Enter the IP to your BB10 simulator'
         },{
@@ -208,16 +200,73 @@ module.exports.prototype = {
                 // Write out .cordova/config.json file
                 if (dot.blackberry === undefined) dot.blackberry = {};
                 if (dot.blackberry.qnx === undefined) dot.blackberry.qnx = {};
-                dot.blackberry.qnx.bbwp = results.bbwp;
                 dot.blackberry.qnx.signing_password = results.signing_password;
                 dot.blackberry.qnx.device_ip = results.device_ip;
+                dot.blackberry.qnx.device_name = results.device_name;
                 dot.blackberry.qnx.device_password = results.device_password;
+                dot.blackberry.qnx.device_pin = results.device_pin;
                 dot.blackberry.qnx.sim_ip = results.sim_ip;
+                dot.blackberry.qnx.sim_name = results.sim_name;
                 dot.blackberry.qnx.sim_password = results.sim_password;
                 fs.writeFileSync(dotFile, JSON.stringify(dot), 'utf-8');
                 events.emit('log', 'Wrote out BlackBerry 10 configuration file to "' + dotFile
+ '"');
                 if (callback) callback();
             }
         });
+    },
+    write_blackberry_environment:function() {
+        var projectRoot = util.isCordova(this.path);
+        // Write it out to project.json as well
+        var project_json_file = path.join(projectRoot, 'platforms', 'blackberry', 'project.json');
+        var proj_json = JSON.parse(fs.readFileSync(project_json_file,'utf-8'));
+
+        // write out stuff to the project.json if user specified it
+        var bb_config = this.get_cordova_config();
+        if (bb_config.device_name && bb_config.device_ip && bb_config.device_password
&& bb_config.device_pin) {
+            proj_json.targets[bb_config.device_name] = {
+                ip:bb_config.device_ip,
+                type:"device",
+                password:bb_config.device_password,
+                pin:bb_config.device_pin
+            };
+            proj_json.defaultTarget = bb_config.device_name;
+            events.emit('log', 'Wrote out BlackBerry 10 device information to ' + project_json_file);
+        }
+        if (bb_config.sim_name && bb_config.sim_ip && bb_config.sim_password)
{
+            proj_json.targets[bb_config.sim_name] = {
+                ip:bb_config.sim_ip,
+                type:"simulator",
+                password:bb_config.sim_password
+            };
+            events.emit('log', 'Wrote out BlackBerry 10 simulator information to ' + project_json_file);
+        }
+        fs.writeFileSync(project_json_file, JSON.stringify(proj_json), 'utf-8');
+    },
+    get_all_targets:function() {
+        var json_file = path.join(this.path, 'project.json');
+        var json = JSON.parse(fs.readFileSync(json_file, 'utf-8'));
+        var targets = [];
+        Object.keys(json.targets).forEach(function(target) {
+            var t = json.targets[target];
+            t.name = target;
+            targets.push(t);
+        });
+        return targets;
+    },
+    get_device_targets:function() {
+        return this.get_all_targets().filter(function(t) {
+            return t.type == 'device';
+        });
+    },
+    get_simulator_targets:function() {
+        return this.get_all_targets().filter(function(t) {
+            return t.type == 'simulator';
+        });
+    },
+    has_device_target:function() {
+        return this.get_device_targets().length > 0;
+    },
+    has_simulator_target:function() {
+        return this.get_simulator_targets().length > 0;
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 9911000..d1fbce7 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -85,18 +85,17 @@ module.exports = function prepare(platformList, callback) {
             // Call plugman --prepare for this platform. sets up js-modules appropriately.
             var plugins_dir = path.join(projectRoot, 'plugins');
             events.emit('log', 'Calling plugman.prepare for platform "' + platform + '"');
-            plugman.prepare(platformPath, platform, plugins_dir);
-
+            plugman.prepare(platformPath, (platform=='blackberry'?'blackberry10':platform),
plugins_dir);
             // Make sure that config changes for each existing plugin is in place
             var plugins = cordova_util.findPlugins(plugins_dir);
-            var platform_json = plugman.config_changes.get_platform_json(plugins_dir, platform);
+            var platform_json = plugman.config_changes.get_platform_json(plugins_dir, (platform=='blackberry'?'blackberry10':platform));
             plugins && plugins.forEach(function(plugin_id) {
                 if (platform_json.installed_plugins[plugin_id]) {
                     events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed
correctly...');
-                    plugman.config_changes.add_plugin_changes(platform, platformPath, plugins_dir,
plugin_id, /* variables for plugin */ platform_json.installed_plugins[plugin_id], /* top level
plugin? */ true, /* should increment config munge? cordova-cli never should, only plugman
*/ false);
+                    plugman.config_changes.add_plugin_changes((platform=='blackberry'?'blackberry10':platform),
platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.installed_plugins[plugin_id],
/* top level plugin? */ true, /* should increment config munge? cordova-cli never should,
only plugman */ false);
                 } else if (platform_json.dependent_plugins[plugin_id]) {
                     events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed
correctly...');
-                    plugman.config_changes.add_plugin_changes(platform, platformPath, plugins_dir,
plugin_id, /* variables for plugin */ platform_json.dependent_plugins[plugin_id], /* top level
plugin? */ false, /* should increment config munge? cordova-cli never should, only plugman
*/ false);
+                    plugman.config_changes.add_plugin_changes((platform=='blackberry'?'blackberry10':platform),
platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.dependent_plugins[plugin_id],
/* top level plugin? */ false, /* should increment config munge? cordova-cli never should,
only plugman */ false);
                 }
                 events.emit('log', 'Plugin "' + plugin_id + '" is good to go.');
             });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b445b87f/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
index 63af0a3..ff7ea17 100644
--- a/src/run.js
+++ b/src/run.js
@@ -23,11 +23,24 @@ var cordova_util      = require('./util'),
     shell             = require('shelljs'),
     et                = require('elementtree'),
     hooker            = require('./hooker'),
+    platforms         = require('./../platforms'),
     events            = require('./events'),
     n                 = require('ncallbacks');
 
 function shell_out_to_run(projectRoot, platform, callback) {
     var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '"
--debug --device';
+    // TODO: inconsistent API for BB10 run command
+    if (platform == 'blackberry') {
+        var bb_project = path.join(projectRoot, 'platforms', 'blackberry')
+        var project = new platforms.blackberry.parser(bb_project);
+        if (project.has_device_target()) {
+            var bb_config = project.get_cordova_config();
+            var device = project.get_device_targets()[0].name;
+            cmd = '"' + path.join(bb_project, 'cordova', 'run') + '" --target=' + device
+ ' -k ' + bb_config.signing_password;
+        } else {
+            throw new Error('No BlackBerry device targets defined. If you want to run `run`
with BB10, please add a device target. For more information run "' + path.join(bb_project,
'cordova', 'target') + '" -h');
+        }
+    }
 
     events.emit('log', 'Running app on platform "' + platform + '" with command "' + cmd
+ '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
@@ -94,7 +107,12 @@ module.exports = function run(platformList, callback) {
             else throw err;
         } else {
             platformList.forEach(function(platform) {
-                shell_out_to_run(projectRoot, platform, end);
+                try {
+                    shell_out_to_run(projectRoot, platform, end);
+                } catch(e) {
+                    if (callback) callback(e);
+                    else throw e;
+                }
             });
         }
     });


Mime
View raw message