You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/06/06 21:26:36 UTC

[1/3] git commit: Re-enabled BB10 platform support and updated bb10 lib to cordova 2.8.0 tag.

Updated Branches:
  refs/heads/master2 6dd7ac5de -> b445b87f9


Re-enabled BB10 platform support and updated bb10 lib to cordova 2.8.0 tag.


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

Branch: refs/heads/master2
Commit: fb849dd23abe9aff52983c020cc58d7f79cf7635
Parents: 6dd7ac5
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 6 10:11:40 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 10:11:40 2013 -0700

----------------------------------------------------------------------
 lib/cordova-blackberry/README.md                   |   12 +-
 lib/cordova-blackberry/VERSION                     |    2 +-
 lib/cordova-blackberry/bin/check_reqs              |   57 ++--
 lib/cordova-blackberry/bin/check_reqs.bat          |   27 ++-
 lib/cordova-blackberry/bin/check_reqs.js           |   38 +++
 lib/cordova-blackberry/bin/create                  |   16 +-
 lib/cordova-blackberry/bin/create.bat              |    8 +-
 lib/cordova-blackberry/bin/create.js               |   38 ++-
 .../bin/templates/project/cordova/build            |    2 +-
 .../bin/templates/project/cordova/build.bat        |    2 +-
 .../bin/templates/project/cordova/clean            |    2 +-
 .../bin/templates/project/cordova/clean.bat        |    2 +-
 .../bin/templates/project/cordova/lib/build        |  140 ++++------
 .../project/cordova/lib/debugtoken-helper.js       |   70 +++++
 .../templates/project/cordova/lib/install-device   |   24 ++
 .../project/cordova/lib/install-device.bat         |   21 ++
 .../bin/templates/project/cordova/lib/list-devices |   24 ++
 .../templates/project/cordova/lib/list-devices.bat |   21 ++
 .../project/cordova/lib/list-emulator-images       |   24 ++
 .../project/cordova/lib/list-emulator-images.bat   |   21 ++
 .../bin/templates/project/cordova/lib/localize.js  |    7 +-
 .../bin/templates/project/cordova/lib/log          |   24 ++
 .../bin/templates/project/cordova/lib/log.bat      |   21 ++
 .../project/cordova/lib/packager-utils.js          |   25 ++-
 .../project/cordova/lib/packager-validator.js      |    3 -
 .../bin/templates/project/cordova/lib/plugin.js    |   15 +-
 .../bin/templates/project/cordova/lib/run          |  213 ++++++++++----
 .../templates/project/cordova/lib/start-emulator   |   54 ++++
 .../project/cordova/lib/start-emulator.bat         |   21 ++
 .../bin/templates/project/cordova/lib/target       |   40 ++-
 .../bin/templates/project/cordova/plugin.bat       |    2 +-
 .../bin/templates/project/cordova/run              |    2 +-
 .../bin/templates/project/cordova/run.bat          |    2 +-
 .../bin/templates/project/cordova/target           |    2 +-
 .../bin/templates/project/cordova/target.bat       |    2 +-
 .../bin/templates/project/project.json             |    1 -
 .../bin/templates/project/www/VERSION              |    2 +-
 .../bin/templates/project/www/config.xml           |    2 +-
 .../bin/templates/project/www/index.html           |    2 +-
 .../www/res/screen/blackberry/screen-225.png       |  Bin 0 -> 16776 bytes
 .../javascript/cordova.blackberry10.js             |   11 +-
 lib/cordova-blackberry/package.json                |   10 +-
 platforms.js                                       |    4 +-
 43 files changed, 768 insertions(+), 248 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/README.md
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/README.md b/lib/cordova-blackberry/README.md
index a19b87a..7430e96 100644
--- a/lib/cordova-blackberry/README.md
+++ b/lib/cordova-blackberry/README.md
@@ -22,6 +22,10 @@ Install node.js:
 
 [http://nodejs.org/](http://nodejs.org/)
 
+Ensure npm is installed:
+
+More recent versions of Nodejs will come with npm included.
+
 ## Getting Started
 
 Create a new project:
@@ -32,7 +36,7 @@ Create a new project:
 
 A target is a device or simulator which will run the app.
 
-This command will add a new target: 
+This command will add a new target:
 
 `<path to project>/cordova/target add <name> <ip> <device | simulator> [-p | --password <password>] [--pin <devicepin>]`
 
@@ -60,10 +64,10 @@ Here is the build script syntax:
 
 Commands:
 
-    release [options] 
+    release [options]
         Build in release mode. This will sign the resulting bar.
-    
-    debug [options] 
+
+    debug [options]
         Build in debug mode.
 
   Options:

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/VERSION b/lib/cordova-blackberry/VERSION
index 38f8e88..834f262 100644
--- a/lib/cordova-blackberry/VERSION
+++ b/lib/cordova-blackberry/VERSION
@@ -1 +1 @@
-dev
+2.8.0

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/check_reqs
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/check_reqs b/lib/cordova-blackberry/bin/check_reqs
index 9a8e9ee..9c2545c 100755
--- a/lib/cordova-blackberry/bin/check_reqs
+++ b/lib/cordova-blackberry/bin/check_reqs
@@ -1,28 +1,31 @@
-#!/usr/bin/env node
+#! /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.
+#
+#!/bin/sh
+if command -v node >/dev/null 2>&1; then
+    if command -v npm >/dev/null 2>&1; then
+        node "$( dirname "$0" )/check_reqs.js" "$@"
+    else
+        echo "npm cannot be found on the path. Aborting."
+        exit 1
+    fi
+else
+    echo "Node cannot be found on the path. Aborting."
+    exit 1
+fi
 
-/**
- * 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.
- */
-
-var qnxHost = process.env.QNX_HOST;
-
-if (typeof qnxHost !== "undefined" && typeof process.env.QNX_TARGET !== "undefined" && process.env.PATH.indexOf(qnxHost) !== -1) {
-    process.exit(0);
-} else {
-    process.exit(-1);
-}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/check_reqs.bat b/lib/cordova-blackberry/bin/check_reqs.bat
index ed05fac..faef279 100755
--- a/lib/cordova-blackberry/bin/check_reqs.bat
+++ b/lib/cordova-blackberry/bin/check_reqs.bat
@@ -18,4 +18,29 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\check_reqs %*
+set FOUNDNODE=
+for %%e in (%PATHEXT%) do (
+  for %%X in (node%%e) do (
+    if not defined FOUNDNODE (
+      set FOUNDNODE=%%~$PATH:X
+    )
+  )
+)
+
+set FOUNDNPM=
+for %%X in (npm) do (
+  if not defined FOUNDNPM (
+    set FOUNDNPM=%%~$PATH:X
+  )
+)
+
+if not defined FOUNDNODE (
+  echo "npm cannot be found on the path. Aborting."
+  exit /b 1
+)
+if not defined FOUNDNPM (
+  echo "Node cannot be found on the path. Aborting."
+  exit /b 1
+)
+
+@node.exe "%~dp0\check_reqs.js" %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/check_reqs.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/check_reqs.js b/lib/cordova-blackberry/bin/check_reqs.js
new file mode 100644
index 0000000..081a0e0
--- /dev/null
+++ b/lib/cordova-blackberry/bin/check_reqs.js
@@ -0,0 +1,38 @@
+/**
+ * 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.
+ */
+
+var MIN_NODE_VER = "0.9.9",
+    qnxHost = process.env.QNX_HOST;
+
+function isNodeNewerThanMin () {
+    //Current version is stored as a String in format "X.X.X"
+    //Must be newer than "0.9.9"
+    var currentVer = process.versions.node.split(".").map(function (verNumStr) { return parseInt(verNumStr, 10);});
+    return (currentVer[0] > 0 || currentVer[1] > 9 || currentVer[1] === 9 && currentVer[2] >= 9);
+}
+
+if (typeof qnxHost === "undefined" || typeof process.env.QNX_TARGET === "undefined" || process.env.PATH.indexOf(qnxHost) === -1) {
+    console.log("BBNDK has not been setup. Please run the appropriate shell script. Aborting.");
+    process.exit(1);
+} else if (!isNodeNewerThanMin()) {
+    console.log("Node version '" + process.versions.node + "' is not new enough. Please upgrade to " + MIN_NODE_VER + " or newer. Aborting.");
+    process.exit(1);
+}
+
+process.exit(0);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/create
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/create b/lib/cordova-blackberry/bin/create
index 87ce4c3..b8b2b89 100755
--- a/lib/cordova-blackberry/bin/create
+++ b/lib/cordova-blackberry/bin/create
@@ -22,4 +22,18 @@
 #   ./create [path package appname]
 #
 #!/bin/sh
-node $( dirname "$0" )"/create.js" "$@"
+
+CURRENT_DIR=$(pwd)
+BIN_DIR=$(dirname "$0")
+
+#Run npm install every time (even if node_modules folder is present) to cover platform upgrade
+cd "$BIN_DIR"/..
+#Removed sudo usage so that node modules are not ownder by root
+npm install
+cd "$CURRENT_DIR"
+
+if ! [ $? -eq 0 ]; then
+  echo "NPM install failed. Aborting."
+else
+  node "$BIN_DIR"/create.js "$@"
+fi

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/create.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/create.bat b/lib/cordova-blackberry/bin/create.bat
index 7b15594..a8f7bab 100644
--- a/lib/cordova-blackberry/bin/create.bat
+++ b/lib/cordova-blackberry/bin/create.bat
@@ -18,4 +18,10 @@ goto comment
        under the License.
 :comment
 
-node.exe %~dp0\create.js %*
+set BIN_DIR=%~dp0
+
+pushd %BIN_DIR%..
+call npm install
+popd
+
+node.exe "%BIN_DIR%create.js" %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/create.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/create.js b/lib/cordova-blackberry/bin/create.js
index 253c093..b454d37 100644
--- a/lib/cordova-blackberry/bin/create.js
+++ b/lib/cordova-blackberry/bin/create.js
@@ -30,7 +30,7 @@ var build,
     wrench = require("wrench"),
     utils = require(path.join(__dirname, 'lib/utils')),
     version = getVersion(),
-    project_path = path.resolve(process.argv[2]),
+    project_path = validateProjectPath(),
     app_id = process.argv[3],
     bar_name = process.argv[4],
     TARGETS = ["device", "simulator"],
@@ -43,7 +43,7 @@ var build,
     update_dir = path.join(project_path, "lib", "cordova." + version),
     native_dir = path.join(project_path, "native"),
     js_path = "javascript",
-    js_basename = "cordova-" + version + ".js";
+    js_basename = "cordova.js";
 
 function getVersion() {
     var version = fs.readFileSync(path.join(__dirname,  "..", "VERSION"));
@@ -67,18 +67,32 @@ function validBarName(barName) {
     return (typeof barName === "undefined") || barNameRegex.test(barName);
 }
 
-function validate() {
-    if (!project_path) {
-        throw "You must give a project PATH";
+function validateProjectPath() {
+    if (!process.argv[2]) {
+        console.log("You must give a project PATH");
+        help();
+        process.exit(2); 
+        return "";
+    } else {
+        return path.resolve(process.argv[2]);
     }
+}
+
+function validate() {
     if (fs.existsSync(project_path)) {
-        throw "The project path must be an empty directory";
+        console.log("The project path must be an empty directory");
+        help();
+        process.exit(2);
     }
     if (!validPackageName(app_id)) {
-        throw "App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters";
+        console.log("App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters");
+        help();
+        process.exit(2);
     }
     if (!validBarName(bar_name)) {
-        throw "BAR filename can only contain alpha-numeric, '.', '-' and '_' characters";
+        console.log("BAR filename can only contain alpha-numeric, '.', '-' and '_' characters");
+        help();
+        process.exit(2);
     }
 }
 
@@ -150,14 +164,18 @@ function updateProject() {
 }
 
 function installPlugins() {
-    var pluginScript = path.resolve(__dirname, "..", path.join(project_path, "cordova", "lib", "plugin.js"));
+    var pluginScript = path.join(project_path, "cordova", "lib", "plugin.js");
     require(pluginScript).add(path.join(__dirname, "..", "plugins"));
 }
 
-if ( process.argv[2] === "-h" || process.argv[2] === "--help" ) {
+function help() {
     console.log("\nUsage: create <project path> [package name [BAR filename]] \n");
     console.log("Options: \n");
     console.log("   -h, --help      output usage information \n");
+}
+
+if ( process.argv[2] === "-h" || process.argv[2] === "--help" ) {
+    help();
 } else {
     try {
         validate();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/build
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/build b/lib/cordova-blackberry/bin/templates/project/cordova/build
index c1e6f63..ade60b0 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/build
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/build
@@ -1,5 +1,5 @@
 #!/bin/sh
 
 #package app
-node $(dirname "$0")"/lib/build" "$@"
+node "$(dirname "$0")/lib/build" "$@"
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/build.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/build.bat b/lib/cordova-blackberry/bin/templates/project/cordova/build.bat
index 186bbba..191e448 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/build.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/build.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\lib\build %*
+@node.exe %~dps0\lib\build %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/clean
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/clean b/lib/cordova-blackberry/bin/templates/project/cordova/clean
index 54d888c..abe96ea 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/clean
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/clean
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-node $(dirname "$0")"/lib/clean"
+node "$(dirname "$0")/lib/clean"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat b/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat
index 636862f..d613d87 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\lib\clean %*
+@node.exe %~dps0\lib\clean %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/build
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/build b/lib/cordova-blackberry/bin/templates/project/cordova/lib/build
index 3fb3432..5e15425 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/build
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/build
@@ -18,11 +18,7 @@
 
 var path = require("path"),
     command = require("commander"),
-    jWorkflow = require("jWorkflow"),
-    localize = require("./localize"),
-    logger = require("./logger"),
     projectProperties = require("../../project.json"),
-    debugTokenHelper = require("./debugtoken-helper"),
     bbwpArgv = [
         process.argv[0],
         path.resolve(path.join(__dirname, process.argv[1])),
@@ -30,12 +26,10 @@ var path = require("path"),
         "-o",
         path.resolve(path.join(__dirname, "..", "..", "build"))
     ],
-    built = false,
-    debugtoken = false;
-
-function getTarget() {
-    return typeof command.args[0] === "string" ? command.args[0] : undefined;
-}
+    jWorkflow = require("jWorkflow"),
+    childProcess = require("child_process"),
+    pkgrUtils = require("./packager-utils"),
+    commandStr;
 
 function copyArgIfExists(arg) {
     if (command[arg]) {
@@ -44,49 +38,14 @@ function copyArgIfExists(arg) {
     }
 }
 
-function createDebugtoken(previous, baton) {
-    var keystorepass = command["keystorepass"] ? command["keystorepass"] : projectProperties.keystorepass;
-    baton.take();
-    logger.info(localize.translate("PROGRESS_WILL_CREATE_DEBUG_TOKEN"));
-    debugTokenHelper.createToken(projectProperties, getTarget(), keystorepass, function (code) {
-        if (code === 0) {
-            debugtoken = true;
-        }
-
-        baton.pass();
-    });
-}
-
-function deployDebugToken(previous, baton) {
-    baton.take();
-
-    // If in debug build and debug token was created, deploy the debug token and wait until the deployment is finished
-    if (debugtoken) {
-        logger.info(localize.translate("PROGRESS_WILL_DEPLOY_DEBUG_TOKEN"));
-        debugTokenHelper.deployToken(projectProperties, getTarget(), function () {
-            baton.pass();
-        });
-    } else {
-        baton.pass();
-    }
-}
-
 function doDebugBuild() {
-    built = true;
-
     //build in debug mode by default
     bbwpArgv.push("-d");
 
-    // In debug build, it needs to create debug token first
-    jWorkflow.order(createDebugtoken)
-             .andThen(deployDebugToken)
-             .andThen(build)
-             .start();
+    build();
 }
 
 function doReleaseBuild() {
-    built = true;
-
     //Note: Packager refers to signing password as "password" not "keystorepass"
     if (command["keystorepass"]) {
         bbwpArgv.push("--password");
@@ -95,7 +54,9 @@ function doReleaseBuild() {
         bbwpArgv.push("--password");
         bbwpArgv.push( projectProperties.keystorepass);
     } else {
-        throw "No signing password provided. Please use --keystorepass via command-line or enter a value for keystorepass in project.json";
+        console.log("No signing password provided. Please use --keystorepass via command-line or enter a value for keystorepass in project.json");
+        console.log(command.helpInformation()); 
+        process.exit(2);
     }
 
     copyArgIfExists("buildId");
@@ -107,68 +68,71 @@ function build() {
     copyArgIfExists("params");
     copyArgIfExists("loglevel");
 
-    //Overrite process.argv, before calling packager
+    //Overwrite process.argv, before calling packager
     process.argv = bbwpArgv;
 
     //Delete cached commander object. It will conflict with the packagers commander
     delete require.cache[require.resolve("commander")];
     delete require.cache[require.resolve("commander/lib/commander")];
 
-    //Package app. If successfull call run
-    require("./packager").start(run);
+    require("./packager").start(function() {});
 }
 
-function run() {
-    var target = getTarget();
+function postClean() {
+    if (command.release) {
+        doReleaseBuild();
+    } else {
+        doDebugBuild();
+    }
+}
 
-    //Overrite process.argv, before calling run
-    process.argv = [
-        process.argv[0],
-        process.argv[1],
-    ];
+function clean(previous, baton) {
+    var cleanScript,
+        execName = "./clean";
 
-    if (target) {
-        process.argv.push(target);
-    }
+    if (pkgrUtils.isWindows()) {
+        execName = "clean";
+    } 
 
-    //deploy app
-    require("./run");
-}
+    baton.take();
 
-command
-    .usage('command [<target>] [-k | --keystorepass] [-b | --buildId <number>] [-p | --params <json>] [-ll | --loglevel <level>]')
-    .option('-k, --keystorepass <password>', 'Signing key password')
-    .option('-b, --buildId <num>', 'Specifies the build number for signing (typically incremented from previous signing).')
-    .option('-p, --params <params JSON file>', 'Specifies additional parameters to pass to downstream tools.')
-    .option('-ll, --loglevel <loglevel>', 'set the logging level (error, warn, verbose)');
+    cleanScript = childProcess.exec(execName, {
+        "cwd": path.normalize(__dirname + "/.."),
+        "env": process.env
+    });
 
-command
-    .command('release')
-    .usage('[<target>] [-k | --keystorepass] [-b | --buildId <number>] [-p | --params <json>] [-ll | --loglevel <level>]')
-    .description('    Build in release mode. This will sign the resulting bar.')
-    .option('-k, --keystorepass <password>', 'Signing key password')
-    .option('-b, --buildId <num>', 'Specifies the build number for signing (typically incremented from previous signing).')
-    .option('-p, --params <params JSON file>', 'Specifies additional parameters to pass to downstream tools.')
-    .option('-ll, --loglevel <loglevel>', 'set the logging level (error, warn, verbose)')
-    .action(doReleaseBuild);
+    cleanScript.stdout.on("data", pkgrUtils.handleProcessOutput);
+    cleanScript.stderr.on("data", pkgrUtils.handleProcessOutput);
+
+    cleanScript.on("exit", function (code) {
+        baton.pass();
+    });
+}
 
 command
-    .command('debug')
-    .usage('[<target>] [-p | --params <json>] [-ll | --loglevel <level>]')
-    .description('    Build in debug mode.')
-    .option('-p, --params <params JSON file>', 'Specifies additional parameters to pass to downstream tools.')
-    .option('-ll, --loglevel <loglevel>', 'set the logging level (error, warn, verbose)')
-    .action(doDebugBuild);
+    .usage('[--debug] [--release] [-k | --keystorepass] [-b | --buildId <number>] [-p | --params <json>] [-ll | --loglevel <level>]')
+    .option('--debug', 'build in debug mode.')
+    .option('--release', 'build in release mode. This will sign the resulting bar.')
+    .option('-k, --keystorepass <password>', 'signing key password')
+    .option('-b, --buildId <num>', 'specifies the build number for signing (typically incremented from previous signing).')
+    .option('-p, --params <params JSON file>', 'specifies additional parameters to pass to downstream tools.')
+    .option('-ll, --loglevel <loglevel>', 'set the logging level (error, warn, verbose)');
 
 try {
     command.parse(process.argv);
 
-    //if we get here and haven't built yet then no mode was provided [debug, release], default to debug mode
-    if (!built) {
-        doDebugBuild();
+    if (command.debug && command.release) {
+        console.log("Invalid build command: cannot specify both debug and release parameters.");
+        console.log(command.helpInformation());
+        process.exit(2);
     }
+
+    // Implicitly call clean first
+    jWorkflow.order(clean)
+             .andThen(postClean)
+             .start();
 } catch (e) {
     console.log(e);
-    process.exit();
+    process.exit(2);
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js
index 791973c..f1a4220 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js
@@ -28,6 +28,44 @@ var childProcess = require("child_process"),
     deployCallback,
     self = {};
 
+function isDebugTokenValid(pin, data) {
+    var manifests,
+        i,
+        l,
+        expiry = null,
+        pin,
+        devices = [],
+        line,
+        now = new Date();
+
+    if (!data) {
+        return false;
+    }
+
+    manifests = data.toString().replace(/[\r]/g, '').split('\n');
+
+    for (i=0, l=manifests.length; i<l; i++) {
+        if (manifests[i].indexOf("Debug-Token-Expiry-Date: ") >= 0) {
+            // Parse the expiry date
+            line = manifests[i].substring("Debug-Token-Expiry-Date: ".length);
+            expiry = new Date(line.substring(0, line.indexOf("T")) + " " + line.substring(line.indexOf("T") + 1, line.length -1) + " UTC");
+        } else if (manifests[i].indexOf("Debug-Token-Device-Id: ") >= 0) {
+            line = manifests[i].substring("Debug-Token-Device-Id: ".length);
+            devices = line.split(",");
+        }
+    }
+
+    if (expiry && expiry > now) {
+        for (i=0, l=devices.length; i<l; i++) {
+            if (parseInt(devices[i]) === parseInt(pin, 16)) {
+                return true; // The debug token is valid if not expired and device pin is included
+            }
+        }
+    }
+
+    return false;
+}
+
 function generateCreateTokenOptions(pins, password) {
     var options = [],
         i;
@@ -208,4 +246,36 @@ self.deployToken = function (projectProperties, target, callback) {
     deployTokenToTargetsRecursively();
 };
 
+self.checkDebugToken = function (pin, callback) {
+    var process,
+        script = "/bin/blackberry-nativepackager",
+        nativePackager;
+
+    if (!callback || typeof callback !== "function") {
+        return;
+    }
+
+    if (!fs.existsSync(debugTokenDir)) {
+        callback(false);
+        return;
+    }
+
+    if (pkgrUtils.isWindows()) {
+        script += ".bat";
+    }
+
+    if (fs.existsSync(conf.DEPENDENCIES_TOOLS)) {
+        nativePackager = childProcess.exec(path.normalize(conf.DEPENDENCIES_TOOLS + script +" -listManifest " + debugTokenDir), {
+            "cwd": workingDir,
+            "env": process ? process.env : undefined
+        }, function (error, stdout, stderr) {
+            callback(isDebugTokenValid(pin, stdout));
+        });
+    } else {
+        throw localize.translate("EXCEPTION_MISSING_TOOLS");
+    }
+
+    return;
+};
+
 module.exports = self;

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device b/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device
new file mode 100755
index 0000000..b9f38d3
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+set -e
+
+echo 'BlackBerry10: Not able to install to connected devices through command-line at this time.'
+exit 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device.bat
new file mode 100644
index 0000000..965417e
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device.bat
@@ -0,0 +1,21 @@
+:: 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 OFF
+
+ECHO echo 'BlackBerry10: Not able to install to connected devices through command-line at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices
new file mode 100755
index 0000000..09d3cec
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+set -e
+
+echo 'BlackBerry10: Not able to list connected devices through command-line at this time.'
+exit 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices.bat
new file mode 100644
index 0000000..d0da1c6
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices.bat
@@ -0,0 +1,21 @@
+:: 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 OFF
+
+ECHO echo 'BlackBerry10: Not able to list connected devices through command-line at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images
new file mode 100755
index 0000000..f065a7a
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+set -e
+
+echo 'BlackBerry10: Not able to list valid emulator images through command-line at this time.'
+exit 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images.bat
new file mode 100644
index 0000000..60baaaf
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images.bat
@@ -0,0 +1,21 @@
+:: 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 OFF
+
+ECHO echo 'BlackBerry10: Not able to list valid emulator images through command-line at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js
index 04e89ac..4990a93 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js
@@ -172,11 +172,8 @@ var Localize = require("localize"),
         "WARNING_WEBSECURITY_DISABLED": {
             "en": "You have disabled all web security in this WebWorks application"
         },
-        "PROGRESS_WILL_CREATE_DEBUG_TOKEN": {
-            "en": "Will create debug token"
-        },
-        "PROGRESS_WILL_DEPLOY_DEBUG_TOKEN": {
-            "en": "Will deploy debug token"
+        "PROGRESS_DEBUG_TOKEN_IS_VALID": {
+            "en": "The existing debug token is valid"
         },
         "WARN_TARGET_NOT_EXIST": {
             "en": "The target \"$[1]\" does not exist"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/log
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/log b/lib/cordova-blackberry/bin/templates/project/cordova/lib/log
new file mode 100755
index 0000000..1b34649
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/log
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+set -e
+
+echo 'BlackBerry10: logging not supported at this time.'
+exit 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/log.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/log.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/log.bat
new file mode 100644
index 0000000..ef5f6d9
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/log.bat
@@ -0,0 +1,21 @@
+:: 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 OFF
+
+ECHO echo 'BlackBerry10: logging not supported at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js
index 09465e8..8bc3acf 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js
@@ -49,12 +49,12 @@ _self = {
 
         fs.writeFileSync(path.join(fileLocation, fileName), fileData);
     },
-    
+
     copyFile: function (srcFile, destDir, baseDir) {
         var filename = path.basename(srcFile),
             fileBuffer = fs.readFileSync(srcFile),
             fileLocation;
-        
+
         //if a base directory was provided, determine
         //folder structure from the relative path of the base folder
         if (baseDir && srcFile.indexOf(baseDir) === 0) {
@@ -65,27 +65,27 @@ _self = {
             fs.writeFileSync(path.join(destDir, filename), fileBuffer);
         }
     },
-    
+
     listFiles: function (directory, filter) {
         var files = wrench.readdirSyncRecursive(directory),
             filteredFiles = [];
-        
+
         files.forEach(function (file) {
             //On mac wrench.readdirSyncRecursive does not return absolute paths, so resolve one.
             file = path.resolve(directory, file);
-        
+
             if (filter(file)) {
                 filteredFiles.push(file);
             }
         });
-        
+
         return filteredFiles;
     },
 
     isWindows: function () {
         return os.type().toLowerCase().indexOf("windows") >= 0;
     },
-    
+
     isArray: function (obj) {
         return obj.constructor.toString().indexOf("Array") !== -1;
     },
@@ -97,7 +97,7 @@ _self = {
         }
         return true;
     },
-    
+
     toBoolean: function (myString, defaultVal) {
         // if defaultVal is not passed, default value is undefined
         return myString === "true" ? true : myString === "false" ? false : defaultVal;
@@ -170,7 +170,16 @@ _self = {
                 logger.info(msg);
             }
         }
+    },
+
+    escapeStringForShell: function (str) {
+        if (require('os').type().toLowerCase().indexOf("windows") >= 0) {
+            return "\"" + str + "\"";
+        } else {
+            return str.replace(/(["\s'$`\\])/g,'\\$1');
+        }
     }
+
 };
 
 module.exports = _self;

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js
index 507b9f2..d85c0db 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js
@@ -81,9 +81,6 @@ _self = {
         if (commandLinebuildId && !keysPassword) {
             //if --buildId was provided with NO password, throw error
             throw localize.translate("EXCEPTION_MISSING_SIGNING_PASSWORD");
-        } else if (buildId && !keysPassword) {
-            //if a buildId was provided in config.xml with NO password, throw warning
-            logger.warn(localize.translate("WARNING_SIGNING_PASSWORD_EXPECTED"));
         }
 
         //if --appdesc was provided, but the file is not existing, throw an error

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js
index 1f11481..7e1412c 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js
@@ -22,8 +22,9 @@ var path = require("path"),
     wrench = require("wrench"),
     fs = require('fs'),
     et   = require('elementtree'),
+    escapeStringForShell = require("./packager-utils").escapeStringForShell,
     PROJECT_ROOT = path.join(__dirname, "..", ".."),
-    PLUGMAN = path.join(PROJECT_ROOT, "cordova", "node_modules", "plugman", "main.js"),
+    PLUGMAN = escapeStringForShell(path.join(PROJECT_ROOT, "cordova", "node_modules", "plugman", "main.js")),
     GLOBAL_PLUGIN_PATH = require(path.join(PROJECT_ROOT, "project.json")).globalFetchDir,
     LOCAL_PLUGIN_PATH = path.join(PROJECT_ROOT, "plugins"),
     argumentor = {
@@ -45,26 +46,26 @@ var path = require("path"),
         },
         setProject: function () {
             this.args.push("--project");
-            this.args.push(PROJECT_ROOT);
+            this.args.push(escapeStringForShell(PROJECT_ROOT));
             return argumentor;
         },
         setPlugin: function () {
             var pluginWithoutTrailingSlash = this.plugin.charAt(this.plugin.length - 1) === "/" ? this.plugin.slice(0, -1) : this.plugin;
             this.args.push("--plugin");
-            this.args.push(pluginWithoutTrailingSlash);
+            this.args.push(escapeStringForShell(pluginWithoutTrailingSlash));
             return argumentor;
         },
         setPluginsDir: function (isGlobal) {
             this.args.push("--plugins_dir");
             if (isGlobal) {
-                this.args.push(GLOBAL_PLUGIN_PATH);
+                this.args.push(escapeStringForShell(GLOBAL_PLUGIN_PATH));
             } else {
-                this.args.push(LOCAL_PLUGIN_PATH);
+                this.args.push(escapeStringForShell(LOCAL_PLUGIN_PATH));
             }
             return argumentor;
         },
         run: function () {
-            var cmd = "";           
+            var cmd = "";
             if (require('os').type().toLowerCase().indexOf("windows") >= 0) {
                 cmd += "@node.exe ";
             }
@@ -104,6 +105,7 @@ function addPlugin (pluginPath) {
         plugin = path.resolve(GLOBAL_PLUGIN_PATH, plugin);
         if (!fs.existsSync(plugin)) {
             console.log("Input ", pluginPath || argumentor.plugin, " cannot be resolved as a plugin");
+            listHelp();
             process.exit(1);
         }
     }
@@ -119,6 +121,7 @@ function addPlugin (pluginPath) {
 
     if (!pluginDirs.length) {
         console.log("No plugins could be found given the input " + pluginPath || argumentor.plugin);
+        listHelp();
         process.exit(1);
     } else {
         pluginDirs.forEach(function (pluginDir) {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/run
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/run b/lib/cordova-blackberry/bin/templates/project/cordova/lib/run
index d6b4b9c..d4430f9 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/run
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/run
@@ -24,20 +24,24 @@ var childProcess = require("child_process"),
     conf = require("./conf"),
     localize = require("./localize"),
     pkgrUtils = require("./packager-utils"),
+    debugTokenHelper = require("./debugtoken-helper"),
     properties = require('../../project.json'),
     program = require('commander'),
     xml2js = require('xml2js'),
+    jWorkflow = require("jWorkflow"),
+    logger = require("./logger"),
+    pin,
+    needCreateDebugToken = false,
+    needDeployDebugToken = false,
+    commandStr,
     target,
     ip,
     password,
-    workingdir,
-    barPath;
+    workingdir = path.normalize(__dirname + "/..");
 
 function generateOptions(uninstall) {
     var options = [];
-
-    workingdir = path.normalize(__dirname + "/.."),
-    barPath = path.normalize(__dirname + "/../../build/" + properties.targets[target].type + "/" + properties.barName + ".bar");
+        barPath = pkgrUtils.escapeStringForShell(path.normalize(__dirname + "/../../build/" + properties.targets[target].type + "/" + properties.barName + ".bar"));
 
     options.push("-device");
     options.push(ip);
@@ -96,49 +100,29 @@ function execNativeDeploy(optionsArray, callback) {
 
 function checkTarget() {
     if (!target) {
-        console.log("No target exists, to add that target please run target add <name> <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]\n");
+        console.log("No target exists, to add that target please run target add <name> <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]");
+        console.log(program.helpInformation());
         return false;
     }
     if (!properties.targets[target]) {
-        console.log("The target \""+target+"\" does not exist, to add that target please run target add "+target+" <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]\n");
+        console.log("The target \""+target+"\" does not exist, to add that target please run target add "+target+" <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]");
+        console.log(program.helpInformation());
         return false;
     }
     if (properties.targets[target].ip) {
-       ip = properties.targets[target].ip; 
+       ip = properties.targets[target].ip;
     } else {
-        console.log("IP is not defined in target \""+target+"\"\n");
+        console.log("IP is not defined in target \""+target+"\"");
+        console.log(program.helpInformation());
         return false;
     }
     if (properties.targets[target].password) {
        password = properties.targets[target].password;
-    } 
-    return true;
-
-}
-
-function deployAll(keys) {
-    target = keys[0];
-
-    if (target) {
-        if (checkTarget()) {
-            var options = generateOptions();
-            if (program.uninstall) {
-                uninstall(
-                    function() {
-                        keys.shift();
-                        deployAll(keys);
-                });
-            } else {
-                execNativeDeploy(options,
-                    function() {
-                        deployAll(keys);
-                });
-            }
-        }
     }
+    return true;
 }
 
-function uninstall(callback) {
+function uninstall() {
     var script = "/bin/blackberry-deploy",
         nativeDeploy;
 
@@ -158,12 +142,10 @@ function uninstall(callback) {
                         var options = generateOptions(true);
                         execNativeDeploy(options,
                             function(){
-                                options = generateOptions(false);
-                                execNativeDeploy(options, callback);
+                                deploy();
                         });
                     } else {
-                        options = generateOptions(false);
-                        execNativeDeploy(options, callback);
+                        deploy();
                     }
                 });
             });
@@ -171,34 +153,143 @@ function uninstall(callback) {
     }
 }
 
-function exec(callback) {
-    program
-        .usage('command [<target>] [--no-launch] [--no-uninstall]')
-        .option('--no-uninstall', 'does not uninstall app from device')
-        .option('--no-launch', 'do not launch the app on device')
+function deploy() {
+    options = generateOptions(false);
+    execNativeDeploy(options, function (code) {
+        if (code) {
+            process.exit(2);
+        } else {
+            process.exit(0);
+        }
+    });
+}
 
-    program
-        .command('all')
-        .usage('all [--no-launch] [--no-uninstall]')
-        .description('    Deploy the app on all targets')
-        .option('--no-uninstall', 'does not uninstall app from device')
-        .option('--no-launch', 'do not launch the app on device')
-    
-    program.parse(process.argv);
-    target = program.args[0] ? program.args[0] : properties.defaultTarget
+function checkDebugtoken(previous, baton) {
+    baton.take();
 
-    if (target === "all") {
-        deployAll(Object.keys(properties.targets));
-    } else {
-        if (checkTarget()) {
-            if (program.uninstall) {
-                uninstall(callback);
+    // if target has no pin, skip the debug token feature
+    if (properties.targets[target].pin) {
+        debugTokenHelper.checkDebugToken(properties.targets[target].pin, function (valid) {
+            // If the debug token is not valid, we need create new debug token
+            if (valid) {
+                // No need to create the debug token
+                logger.info(localize.translate("PROGRESS_DEBUG_TOKEN_IS_VALID"));
+                needDeployDebugToken = true;
             } else {
-                options = generateOptions(false);
-                execNativeDeploy(options, callback)
+                needCreateDebugToken = true;
             }
+            baton.pass();
+        });
+    } else {
+        baton.pass();
+    }
+}
+
+function createDebugToken(previous, baton) {
+    var keystorepass = program["keystorepass"] ? program["keystorepass"] : properties.keystorepass;
+
+    baton.take();
+
+    if (needCreateDebugToken) {
+        debugTokenHelper.createToken(properties, "all", keystorepass, function (code) {
+            if (code === 0) {
+                // Deploy the debug token if created
+                needDeployDebugToken = true;
+            }
+
+            baton.pass();
+        });
+    } else {
+            baton.pass();
+    }
+}
+
+function deployDebugToken(previous, baton) {
+    baton.take();
+
+    // If in debug build and debug token was created, deploy the debug token and wait until the deployment is finished
+    if (needDeployDebugToken) {
+        debugTokenHelper.deployToken(properties, target, function () {
+            baton.pass();
+        });
+    } else {
+        baton.pass();
+    }
+}
+
+function handleBuildOutput(data) {
+    var msg = data.toString().replace(/[\n\r]/g, '');
+    console.log(msg);
+}
+
+function build(previous, baton) {
+    var nativeDeploy,
+        execName = "./build";
+
+    baton.take();
+
+    if (pkgrUtils.isWindows()) {
+        execName = "build";
+    } 
+
+    nativeDeploy = childProcess.exec(execName, {
+        "cwd": path.normalize(__dirname + "/.."),
+        "env": process.env
+    });
+
+    nativeDeploy.stdout.on("data", handleBuildOutput);
+
+    nativeDeploy.stderr.on("data", handleBuildOutput);
+
+    nativeDeploy.on("exit", function (code) {
+        // If error happened during building the bar, exit
+        if (code === 2) {
+            process.exit(2);
+        }
+
+        baton.pass();
+    });
+}
+
+function postBuild() {
+    if (program.uninstall) {
+        uninstall();
+    } else {
+        deploy();
+    }
+}
+
+function exec() {
+    program
+        .usage('[--target=<id>] [-k | --keystorepass] [--no-launch] [--no-uninstall] [--no-build]')
+        .option('-k, --keystorepass <password>', 'the password of signing key; needed for creating debug token')
+        .option('--target', 'specifies the target to run the application')
+        .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');
+
+    commandStr = typeof process.argv[2] === "string" ? process.argv[2] : undefined;
+    if (commandStr && commandStr.indexOf("--target=") === 0) {
+        // Convert "--target=<id>" into "--target id"
+        process.argv[2] = "--target";
+        process.argv.splice(3, 0, commandStr.substring("--target=".length));
+    }
+
+    program.parse(process.argv);
+    target = program.args[0] ? program.args[0] : properties.defaultTarget;
+
+    if (checkTarget()) {
+        if (program.build) {
+            jWorkflow.order(checkDebugtoken)
+                     .andThen(createDebugToken)
+                     .andThen(deployDebugToken)
+                     .andThen(build)
+                     .andThen(postBuild)
+                     .start();
+        } else {
+            postBuild();
         }
     }
 }
 
-exec(null);
\ No newline at end of file
+exec();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator b/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator
new file mode 100755
index 0000000..cfb96a8
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+# support for this script on BB10 is dependent on vmware tools being on the path, or in the default install directory
+# Valid values for "--target": path to 'vmwarevm' file
+
+VMWARE_DEFAULT_PATH=/Applications/VMware\ Fusion.app/Contents/Library
+VMWARE_TOOL=vmrun
+OS_NAME=`uname`
+
+if [ "$1" = "" -o ! -e "$1" ]
+then
+    echo "BlackBerry10: must provide path to valid vmwarevm image"
+    exit 2
+fi
+
+if [ "$OS_NAME" = "Darwin" ]; then
+    if [ "`which vmrun`" = "" ]; then
+        echo "BlackBerry10: VMware Fusion 'vmrun' tool not found on path, trying default install path"
+        runpath=$VMWARE_DEFAULT_PATH/$VMWARE_TOOL
+    else
+        runpath=`which vmrun`
+    fi
+    
+    if [ -x "$runpath" ]; then
+        echo $runpath start $1
+        `$"$runpath" start "$1" > /dev/null`
+
+        exit 0 
+    else
+        echo "BlackBerry10: could not find VMware Fusion 'vmrun' tool"
+        exit 1 
+    fi
+else
+    echo "BlackBerry10: currently only supports installing to emulator on OS X"
+    exit 1
+fi

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator.bat
new file mode 100644
index 0000000..6671abb
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator.bat
@@ -0,0 +1,21 @@
+:: 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 OFF
+
+ECHO echo 'BlackBerry10: Not able to start emulator images on windows command-line at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/lib/target
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/target b/lib/cordova-blackberry/bin/templates/project/cordova/lib/target
index c21e6c7..0a5746b 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/target
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/target
@@ -41,7 +41,9 @@ function isValidIp(ip) {
         ipArray;
 
     if (typeof ip !== 'string') {
-        throw "IP is required";
+        console.log("IP is required");
+        console.log(commander.helpInformation());
+        process.exit(2); 
     } else {
         ipArray = ip.split('.');
         if (ipArray.length !== 4) {
@@ -61,7 +63,9 @@ function isValidType(type) {
     var result = true;
 
     if (typeof type !== 'string') {
-        throw "target type is required";
+        console.log("target type is required");
+        console.log(commander.helpInformation());
+        process.exit(2); 
     }
     else if (!(type === 'device' || type === 'simulator')) {
         result = false;
@@ -98,7 +102,9 @@ commander
     .description("Add specified target")
     .action(function () {
         if (commander.args.length === 1) {
-            throw "Target details not specified";
+            console.log("Target details not specified");
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         name = commander.args[0];
         ip = commander.args[1];
@@ -110,13 +116,19 @@ commander
             pin = commander.pin;
         }
         if (!isValidIp(ip)) {
-            throw "Invalid IP: " + ip;
+            console.log("Invalid IP: " + ip);
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         if (!isValidType(type)) {
-            throw "Invalid target type: " + type;
+            console.log("Invalid target type: " + type);
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         if (!isValidPin(pin)) {
-            throw "Invalid PIN: " + pin;
+            console.log("Invalid PIN: " + pin);
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         if (properties.targets.hasOwnProperty(name)) {
             console.log("Overwriting target: " + name);
@@ -129,11 +141,15 @@ commander
     .description("Remove specified target")
     .action(function () {
         if (commander.args.length === 1) {
-            throw 'No target specified';
+            console.log('No target specified');
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         name = commander.args[0];
         if (!properties.targets.hasOwnProperty(name)) {
-            throw "Target: '" + name + "' not found";
+            console.log("Target: '" + name + "' not found");
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         if (name === properties.defaultTarget) {
             console.log("Deleting default target, please set a new default target");
@@ -154,14 +170,18 @@ commander
         if (properties.targets.hasOwnProperty(name)) {
             properties.defaultTarget = name;
         } else {
-            throw "Target '" + name + "' not found";
+            console.log("Target '" + name + "' not found");
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
     });
 
 commander
     .command('*')
     .action(function () {
-        throw 'Unrecognized command';
+        console.log('Unrecognized command');
+        console.log(commander.helpInformation());
+        process.exit(2);
     });
 
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat b/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat
index 54245e0..8a53da1 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\plugin %*
+@node.exe %~dps0\plugin %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/run
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/run b/lib/cordova-blackberry/bin/templates/project/cordova/run
index 44d3334..c6ccacf 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/run
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/run
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-node $( dirname "$0")"/lib/run" "$@"
+node "$( dirname "$0")/lib/run" "$@"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/run.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/run.bat b/lib/cordova-blackberry/bin/templates/project/cordova/run.bat
index 0f5da0a..32b6cc3 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/run.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/run.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\lib\run %*
+@node.exe %~dps0\lib\run %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/target
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/target b/lib/cordova-blackberry/bin/templates/project/cordova/target
index 6a28219..4e676d2 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/target
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/target
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-node $( dirname "$0")"/lib/target" "$@"
+node "$( dirname "$0")/lib/target" "$@"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/cordova/target.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/target.bat b/lib/cordova-blackberry/bin/templates/project/cordova/target.bat
index 545b79e..3c05c97 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/target.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/target.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\lib\target %*
+@node.exe %~dps0\lib\target %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/project.json
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/project.json b/lib/cordova-blackberry/bin/templates/project/project.json
index 97bbb24..97390ae 100644
--- a/lib/cordova-blackberry/bin/templates/project/project.json
+++ b/lib/cordova-blackberry/bin/templates/project/project.json
@@ -1,6 +1,5 @@
 {
     "barName": "cordova-BB10-app",
-    "keystorepass": "password",
     "defaultTarget": "",
     "targets": {}
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/www/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/VERSION b/lib/cordova-blackberry/bin/templates/project/www/VERSION
index 38f8e88..834f262 100644
--- a/lib/cordova-blackberry/bin/templates/project/www/VERSION
+++ b/lib/cordova-blackberry/bin/templates/project/www/VERSION
@@ -1 +1 @@
-dev
+2.8.0

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/www/config.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/config.xml b/lib/cordova-blackberry/bin/templates/project/www/config.xml
index 3edc941..a645139 100644
--- a/lib/cordova-blackberry/bin/templates/project/www/config.xml
+++ b/lib/cordova-blackberry/bin/templates/project/www/config.xml
@@ -24,7 +24,7 @@
 
 <widget xmlns="http://www.w3.org/ns/widgets"
         xmlns:rim="http://www.blackberry.com/ns/widgets"
-	version="1.0.0" id="default.app.id">
+	version="1.0.0.1" id="default.app.id">
 
   <name>Webworks Application</name>
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/www/index.html
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/index.html b/lib/cordova-blackberry/bin/templates/project/www/index.html
index ce767eb..e84fbd7 100644
--- a/lib/cordova-blackberry/bin/templates/project/www/index.html
+++ b/lib/cordova-blackberry/bin/templates/project/www/index.html
@@ -33,7 +33,7 @@
                 <p class="event received">Device is Ready</p>
             </div>
         </div>
-        <script type="text/javascript" src="cordova-dev.js"></script>
+        <script type="text/javascript" src="cordova.js"></script>
         <script type="text/javascript" src="js/index.js"></script>
         <script type="text/javascript">
             app.initialize();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/bin/templates/project/www/res/screen/blackberry/screen-225.png
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/res/screen/blackberry/screen-225.png b/lib/cordova-blackberry/bin/templates/project/www/res/screen/blackberry/screen-225.png
new file mode 100644
index 0000000..29873e9
Binary files /dev/null and b/lib/cordova-blackberry/bin/templates/project/www/res/screen/blackberry/screen-225.png differ

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/javascript/cordova.blackberry10.js b/lib/cordova-blackberry/javascript/cordova.blackberry10.js
index ebe8a46..e97f404 100644
--- a/lib/cordova-blackberry/javascript/cordova.blackberry10.js
+++ b/lib/cordova-blackberry/javascript/cordova.blackberry10.js
@@ -1,5 +1,5 @@
 // Platform: blackberry10
-// 2.7.0rc1-73-g0bca505
+// 2.8.0-0-g6208c95
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -19,7 +19,7 @@
  under the License.
 */
 ;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-73-g0bca505';
+var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
 // file: lib/scripts/require.js
 
 var require,
@@ -5023,7 +5023,6 @@ function Device() {
     this.available = false;
     this.platform = null;
     this.version = null;
-    this.name = null;
     this.uuid = null;
     this.cordova = null;
     this.model = null;
@@ -5039,7 +5038,6 @@ function Device() {
             me.available = true;
             me.platform = info.platform;
             me.version = info.version;
-            me.name = info.name;
             me.uuid = info.uuid;
             me.cordova = buildLabel;
             me.model = info.model;
@@ -6583,6 +6581,11 @@ window.cordova = require('cordova');
 // file: lib/scripts/bootstrap.js
 
 (function (context) {
+    if (context._cordovaJsLoaded) {
+        throw new Error('cordova.js included multiple times.');
+    }
+    context._cordovaJsLoaded = true;
+
     var channel = require('cordova/channel');
     var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/fb849dd2/lib/cordova-blackberry/package.json
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/package.json b/lib/cordova-blackberry/package.json
index a879ba3..d1f25f7 100644
--- a/lib/cordova-blackberry/package.json
+++ b/lib/cordova-blackberry/package.json
@@ -11,11 +11,13 @@
     "type": "Apache 2.0",
     "url": "http://www.apache.org/licenses/LICENSE-2.0"
   }],
+  "engines": {
+    "node": ">=0.9.9"
+  },
   "scripts": {
     "test": "./node_modules/jake/bin/cli.js"
   },
   "dependencies": {
-    "jasmine-node": "1.0.7",
     "jWorkflow": "0.8.0",
     "commander": "0.5.2",
     "localize": "*0.4.2",
@@ -28,6 +30,8 @@
     "plugman": "0.7.7"
   },
   "devDependencies": {
-    "jake":"*"
-  }
+    "jake":"*",
+    "jasmine-node": "1.0.7"
+  },
+  "readmeFilename": "README.md"
 }

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


[3/3] git commit: npm version 2.8.10. [CB-3624] Re-added support for BB10.

Posted by fi...@apache.org.
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 <ma...@gmail.com>
Authored: Thu Jun 6 12:26:26 2013 -0700
Committer: Fil Maj <ma...@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;
+                }
             });
         }
     });


[2/3] git commit: updated SDK locations and minimum setup in README

Posted by fi...@apache.org.
updated SDK locations and minimum setup in README


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

Branch: refs/heads/master2
Commit: 437af2061a261f6f9d58eb2f9990f83dcfa92e74
Parents: fb849dd
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 6 10:36:08 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 10:36:08 2013 -0700

----------------------------------------------------------------------
 README.md |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/437af206/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 2ea3da4..763f61b 100644
--- a/README.md
+++ b/README.md
@@ -8,13 +8,13 @@
 
 * [nodejs](http://nodejs.org/)
 * SDKs for every platform you wish to support
-  - [BlackBerry WebWorks SDK](http://developer.blackberry.com)
-  - [iOS SDK](http://developer.apple.com) with the latest Xcode and Xcode Command Line Tools
+  - BlackBerry 10: [BlackBerry 10 WebWorks SDK](http://developer.blackberry.com/html5/download/) as well as the [BlackBerry 10 NDK](http://developer.blackberry.com/native/download/). You will also need to have the NDK environment variables on your path by running `bb10ndk/bbndk-env.sh`.
+  - iOS: [iOS SDK](http://developer.apple.com) with the latest Xcode and Xcode Command Line Tools
   - [Android SDK](http://developer.android.com) - **NOTE** This tool
     will not work unless you have the absolute latest updates for all
     Android SDK components. Also you will need the SDK's `tools` and `platform-tools` directories on your __system path__ otherwise Android support will fail.
 
-cordova-cli has been tested on Mas OS X and Linux.
+cordova-cli has been tested on Mas OS X, Linux, Windows 7 and Windows 8.
 
 # Install