[CB-3798] Provide support for optional localized node/npm/bb-tools -Several script updates to provide support for optional localized binaries [node/npm/bbtools] -Added support for overridable global CORDOVA_NODE env variable to point to node installation -Added support for overridable global CORDOVA_BBTOOLS env variable to point to bbndk tools -Run plugman via JS and not command-line
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/7b933463 Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/7b933463 Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/7b933463 Branch: refs/heads/master Commit: 7b9334636790e1efa76071310b5086a80555397f Parents: db0aa17 Author: jkeshavarzi <[email protected]> Authored: Tue Jul 16 18:37:04 2013 -0400 Committer: Bryan Higgins <[email protected]> Committed: Tue Jul 30 10:02:05 2013 -0400 ---------------------------------------------------------------------- blackberry10/bin/check_reqs | 26 ++++---- blackberry10/bin/check_reqs.bat | 56 +++--------------- blackberry10/bin/create | 24 +++++--- blackberry10/bin/create.bat | 12 ++-- blackberry10/bin/create.js | 39 +++++++++++- blackberry10/bin/init | 53 +++++++++++++++++ blackberry10/bin/init.bat | 62 ++++++++++++++++++++ blackberry10/bin/target | 4 +- blackberry10/bin/target.bat | 4 +- .../bin/templates/project/cordova/build | 3 +- .../bin/templates/project/cordova/build.bat | 4 +- .../bin/templates/project/cordova/clean | 3 +- .../bin/templates/project/cordova/clean.bat | 4 +- .../project/cordova/lib/debugtoken-helper.js | 18 +++--- .../templates/project/cordova/lib/list-devices | 6 +- .../project/cordova/lib/list-devices.bat | 4 +- .../project/cordova/lib/list-emulator-images | 3 +- .../cordova/lib/list-emulator-images.bat | 4 +- .../project/cordova/lib/list-started-emulators | 3 +- .../cordova/lib/list-started-emulators.bat | 4 +- .../project/cordova/lib/native-packager.js | 2 +- .../project/cordova/lib/plugin-wrapper.js | 21 +++++++ .../bin/templates/project/cordova/lib/plugin.js | 27 +++------ .../bin/templates/project/cordova/lib/run | 4 +- .../project/cordova/lib/signing-helper.js | 2 +- .../project/cordova/lib/target-utils.js | 7 ++- .../bin/templates/project/cordova/plugin | 25 +------- .../bin/templates/project/cordova/plugin.bat | 4 +- blackberry10/bin/templates/project/cordova/run | 3 +- .../bin/templates/project/cordova/run.bat | 4 +- .../bin/templates/project/cordova/version | 3 +- .../bin/templates/project/cordova/version.bat | 4 +- blackberry10/package.json | 2 +- 33 files changed, 284 insertions(+), 160 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/check_reqs ---------------------------------------------------------------------- diff --git a/blackberry10/bin/check_reqs b/blackberry10/bin/check_reqs index a813293..d69ee77 100755 --- a/blackberry10/bin/check_reqs +++ b/blackberry10/bin/check_reqs @@ -18,33 +18,35 @@ # #!/bin/sh -NODE=$(command -v node) -NPM=$(command -v npm) +source $(dirname "$0")/init + +NODE="$CORDOVA_NODE/node" +NPM="$CORDOVA_NODE/npm" JAVA=$(command -v java) -PACKAGER=$(command -v blackberry-nativepackager) -DEPLOYER=$(command -v blackberry-deploy) -SIGNER=$(command -v blackberry-signer) +PACKAGER="$CORDOVA_BBTOOLS/blackberry-nativepackager" +DEPLOYER="$CORDOVA_BBTOOLS/blackberry-deploy" +SIGNER="$CORDOVA_BBTOOLS/blackberry-signer" -if [ -z "$NODE" ]; then +if [ ! -x "$NODE" ]; then echo node cannot be found on the path. Aborting. EXIT_CODE=1 -elif [ -z "$NPM" ]; then +elif [ ! -x "$NPM" ]; then echo npm cannot be found on the path. Aborting. EXIT_CODE=1 -elif [ -z "$JAVA" ]; then +elif [ ! -x "$JAVA" ]; then echo java cannot be found on the path. Aborting. EXIT_CODE=1 -elif [ -z "$PACKAGER" ]; then +elif [ ! -x "$PACKAGER" ]; then echo blackberry-nativepackager cannot be found on the path. Aborting. EXIT_CODE=1 -elif [ -z "$DEPLOYER" ]; then +elif [ ! -x "$DEPLOYER" ]; then echo blackberry-deploy cannot be found on the path. Aborting. EXIT_CODE=1 -elif [ -z "$SIGNER" ]; then +elif [ ! -x "$SIGNER" ]; then echo blackberry-signer cannot be found on the path. Aborting. EXIT_CODE=1 else - node "$( dirname "$0" )/check_reqs.js" "$@" + "$NODE" "$( dirname "$0" )/check_reqs.js" "$@" EXIT_CODE=0 fi http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/check_reqs.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/check_reqs.bat b/blackberry10/bin/check_reqs.bat index b7173f7..e08ada7 100755 --- a/blackberry10/bin/check_reqs.bat +++ b/blackberry10/bin/check_reqs.bat @@ -17,43 +17,7 @@ goto comment specific language governing permissions and limitations under the License. :comment - -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 - ) -) - -set FOUNDPACKAGER= -for %%X in (blackberry-nativepackager.bat) do ( - if not defined FOUNDPACKAGER ( - set FOUNDPACKAGER=%%~$PATH:X - ) -) - -set FOUNDDEPLOYER= -for %%X in (blackberry-deploy.bat) do ( - if not defined FOUNDDEPLOYER ( - set FOUNDDEPLOYER=%%~$PATH:X - ) -) - -set FOUNDSIGNER= -for %%X in (blackberry-signer.bat) do ( - if not defined FOUNDSIGNER ( - set FOUNDSIGNER=%%~$PATH:X - ) -) +call "%~dp0init" set FOUNDJAVA= for %%e in (%PATHEXT%) do ( @@ -63,31 +27,29 @@ for %%e in (%PATHEXT%) do ( ) ) ) - - -if not defined FOUNDNODE ( - echo npm cannot be found on the path. Aborting. +if not exist "%CORDOVA_NODE%\node.exe" ( + echo node cannot be found on the path. Aborting. exit /b 1 ) -if not defined FOUNDNPM ( - echo node cannot be found on the path. Aborting. +if not exist "%CORDOVA_NODE%\npm" ( + echo npm cannot be found on the path. Aborting. exit /b 1 ) if not defined FOUNDJAVA ( echo java cannot be found on the path. Aborting. exit /b 1 ) -if not defined FOUNDPACKAGER ( +if not exist "%CORDOVA_BBTOOLS%\blackberry-nativepackager" ( echo blackberry-nativepackager cannot be found on the path. Aborting. exit /b 1 ) -if not defined FOUNDDEPLOYER ( +if not exist "%CORDOVA_BBTOOLS%\blackberry-deploy" ( echo blackberry-deploy cannot be found on the path. Aborting. exit /b 1 ) -if not defined FOUNDSIGNER ( +if not exist "%CORDOVA_BBTOOLS%\blackberry-signer" ( echo blackberry-signer cannot be found on the path. Aborting. exit /b 1 ) [email protected] "%~dp0\check_reqs.js" %* +"%CORDOVA_NODE%\node" "%~dp0\check_reqs.js" %* http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/create ---------------------------------------------------------------------- diff --git a/blackberry10/bin/create b/blackberry10/bin/create index 4ba2665..d44e377 100755 --- a/blackberry10/bin/create +++ b/blackberry10/bin/create @@ -23,8 +23,11 @@ # #!/bin/sh +source $(dirname "$0")/init + CURRENT_DIR=$(pwd) -BIN_DIR=$(dirname "$0") +BIN_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +NPM_PACKAGE_JSON="$BIN_DIR"/../package.json #Run check_reqs before doing anything and exit if there's an error "$BIN_DIR"/check_reqs @@ -33,13 +36,16 @@ if [ ${?} -ne 0 ]; then fi #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 [ -e $NPM_PACKAGE_JSON ]; then + cd "$BIN_DIR"/.. + #Removed sudo usage so that node modules are not ownder by root + "$CORDOVA_NODE/npm" install + cd "$CURRENT_DIR" -if ! [ $? -eq 0 ]; then - echo "NPM install failed. Aborting." -else - node "$BIN_DIR"/create.js "$@" + if ! [ $? -eq 0 ]; then + echo "NPM install failed. Aborting." + exit 1 + fi fi + +"$CORDOVA_NODE/node" "$BIN_DIR"/create.js "$@" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/create.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/create.bat b/blackberry10/bin/create.bat index ed595ab..dd83988 100644 --- a/blackberry10/bin/create.bat +++ b/blackberry10/bin/create.bat @@ -17,15 +17,17 @@ goto comment specific language governing permissions and limitations under the License. :comment - set BIN_DIR=%~dp0 +call "%BIN_DIR%init" call "%BIN_DIR%check_reqs" if "%ERRORLEVEL%" == "1" exit /B 1 -pushd %BIN_DIR%.. -call npm install -popd +if exist "%BIN_DIR%..\package.json" ( + pushd %BIN_DIR%.. + call "%CORDOVA_NODE%\npm" install + popd +) -node.exe "%BIN_DIR%create.js" %* +"%CORDOVA_NODE%\node" "%BIN_DIR%create.js" %* http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/create.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js index d9f895e..26a9109 100644 --- a/blackberry10/bin/create.js +++ b/blackberry10/bin/create.js @@ -112,18 +112,54 @@ function copyJavascript() { } function copyFilesToProject() { - var nodeModulesDest = path.join(project_path, "cordova", "node_modules"); + var nodeModulesDest = path.join(project_path, "cordova", "node_modules"), + bbtoolsBinDest = path.join(project_path, "cordova", "dependencies", "bb-tools", "bin"), + bbtoolsLibDest = path.join(project_path, "cordova", "dependencies", "bb-tools", "lib"), + bbNativePackager = "blackberry-nativepackager", + bbSigner = "blackberry-signer", + bbDeploy = "blackberry-deploy"; // create project using template directory wrench.mkdirSyncRecursive(project_path, 0777); wrench.copyDirSyncRecursive(TEMPLATE_PROJECT_DIR, project_path); + //copy dependencies folder if exists + if (fs.existsSync(path.join(BIN_DIR, "dependencies"))) { + //Copy node binaries + wrench.mkdirSyncRecursive(path.join(project_path, "cordova", "dependencies", "node"), 0755); + wrench.copyDirSyncRecursive(path.join(BIN_DIR, "dependencies", "node"), path.join(project_path, "cordova", "dependencies", "node")); + + //Copy bb-tools bin files + wrench.mkdirSyncRecursive(bbtoolsBinDest, 0755); + + if (utils.isWindows()) { + bbNativePackager += ".bat"; + bbSigner += ".bat"; + bbDeploy += ".bat"; + } + + utils.copyFile(path.join(BIN_DIR, "dependencies", "bb-tools", "bin", bbNativePackager), bbtoolsBinDest); + utils.copyFile(path.join(BIN_DIR, "dependencies", "bb-tools", "bin", bbSigner), bbtoolsBinDest); + utils.copyFile(path.join(BIN_DIR, "dependencies", "bb-tools", "bin", bbDeploy), bbtoolsBinDest); + + //copy bb-tools lib folder + wrench.mkdirSyncRecursive(bbtoolsLibDest, 0755); + wrench.copyDirSyncRecursive(path.join(BIN_DIR, "dependencies", "bb-tools", "lib"), bbtoolsLibDest); + } + // copy repo level target tool to project utils.copyFile(path.join(BIN_DIR, "target"), path.join(project_path, "cordova")); utils.copyFile(path.join(BIN_DIR, "target.bat"), path.join(project_path, "cordova")); utils.copyFile(path.join(BIN_DIR, "lib", "target.js"), path.join(project_path, "cordova", "lib")); utils.copyFile(path.join(BIN_DIR, "lib", "utils.js"), path.join(project_path, "cordova", "lib")); + // copy repo level init script to project + if (utils.isWindows()) { + utils.copyFile(path.join(BIN_DIR, "init.bat"), path.join(project_path, "cordova")); + } else { + utils.copyFile(path.join(BIN_DIR, "init"), path.join(project_path, "cordova")); + } + // change file permission for cordova scripts because ant copy doesn't preserve file permissions wrench.chmodSyncRecursive(path.join(project_path,"cordova"), 0700); @@ -133,6 +169,7 @@ function copyFilesToProject() { //copy node modules to cordova build directory wrench.mkdirSyncRecursive(nodeModulesDest, 0777); wrench.copyDirSyncRecursive(MODULES_PROJECT_DIR, nodeModulesDest); + //change permissions of plugman fs.chmodSync(path.join(nodeModulesDest, "plugman", "main.js"), 0755); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/init ---------------------------------------------------------------------- diff --git a/blackberry10/bin/init b/blackberry10/bin/init new file mode 100755 index 0000000..78b5ea9 --- /dev/null +++ b/blackberry10/bin/init @@ -0,0 +1,53 @@ +#! /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 +CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +LOCAL_NODE_BIN=$CURRENT_DIR/dependencies/node/bin +LOCAL_BBTOOLS=$CURRENT_DIR/dependencies/bb-tools/bin + +if [ -z "$CORDOVA_NODE" ]; then + if [ -x "$LOCAL_NODE_BIN" ]; then + #set CORDOVA_NODE to local node version, if exists + CORDOVA_NODE=$LOCAL_NODE_BIN + else + #set CORDOVA_NODE to whichever node is on path, if exists + NODE_PATH=$(command -v node) + if [ ! -z "$NODE_PATH" ]; then + CORDOVA_NODE=$(dirname $NODE_PATH) + fi + fi + + export CORDOVA_NODE=$CORDOVA_NODE +fi + +if [ -z "$CORDOVA_BBTOOLS" ]; then + if [ -x "$LOCAL_BBTOOLS" ]; then + #set CORDOVA_BBTOOLS to local bbtools, if exists + CORDOVA_BBTOOLS=$LOCAL_BBTOOLS + else + #set CORDOVA_BBTOOLS to whichever bbtools is on path, if exists + BBTOOLS_PATH=$(command -v blackberry-nativepackager) + if [ ! -z "$BBTOOLS_PATH" ]; then + CORDOVA_BBTOOLS=$(dirname $BBTOOLS_PATH) + fi + fi + + export CORDOVA_BBTOOLS=$CORDOVA_BBTOOLS +fi + http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/init.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/init.bat b/blackberry10/bin/init.bat new file mode 100644 index 0000000..79020e2 --- /dev/null +++ b/blackberry10/bin/init.bat @@ -0,0 +1,62 @@ +@ECHO OFF +goto comment + 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. +:comment + +set LOCAL_NODE_BINARY=%~dp0dependencies\node\bin +set LOCAL_BBTOOLS_BINARY=%~dp0dependencies\bb-tools\bin + + + +if defined %CORDOVA_NODE% { goto bbtools } + +if exist "%LOCAL_NODE_BINARY%" ( + set CORDOVA_NODE=%LOCAL_NODE_BINARY% +) else ( + for %%e in (%PATHEXT%) do ( + for %%X in (node%%e) do ( + if not defined FOUNDNODE ( + set FOUNDNODE=%%~$PATH:X + ) + ) + ) + + if defined FOUNDNODE ( + for %%F in ("%FOUNDNODE%") do set CORDOVA_NODE=%%~dpF + ) +) + +:bbtools + +if defined %CORDOVA_BBTOOLS% { exit /B } + +if exist "%LOCAL_BBTOOLS_BINARY%" ( + set CORDOVA_BBTOOLS=%LOCAL_BBTOOLS_BINARY% +) else ( + for %%e in (%PATHEXT%) do ( + for %%X in (blackberry-nativepackager%%e) do ( + if not defined FOUNDBBTOOLS ( + set FOUNDBBTOOLS=%%~$PATH:X + ) + ) + ) + + if defined FOUNDBBTOOLS ( + for %%F in ("%FOUNDBBTOOLS%") do set CORDOVA_BBTOOLS=%%~dpF + ) +) http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/target ---------------------------------------------------------------------- diff --git a/blackberry10/bin/target b/blackberry10/bin/target index 4e676d2..e323cfb 100755 --- a/blackberry10/bin/target +++ b/blackberry10/bin/target @@ -1,3 +1,3 @@ #!/bin/sh - -node "$( dirname "$0")/lib/target" "$@" +source $(dirname "$0")/init +"$CORDOVA_NODE/node" "$( dirname "$0")/lib/target" "$@" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/target.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/target.bat b/blackberry10/bin/target.bat index 3c05c97..9948a28 100755 --- a/blackberry10/bin/target.bat +++ b/blackberry10/bin/target.bat @@ -17,5 +17,5 @@ goto comment specific language governing permissions and limitations under the License. :comment - [email protected] %~dps0\lib\target %* +call "%~dp0init" +"%CORDOVA_NODE%\node.exe" "%~dps0\lib\target" %* http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/build ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/build b/blackberry10/bin/templates/project/cordova/build index ade60b0..b082f38 100755 --- a/blackberry10/bin/templates/project/cordova/build +++ b/blackberry10/bin/templates/project/cordova/build @@ -1,5 +1,6 @@ #!/bin/sh +source $(dirname "$0")/init #package app -node "$(dirname "$0")/lib/build" "$@" +"$CORDOVA_NODE/node" "$(dirname "$0")/lib/build" "$@" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/build.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/build.bat b/blackberry10/bin/templates/project/cordova/build.bat index 191e448..9f8773c 100755 --- a/blackberry10/bin/templates/project/cordova/build.bat +++ b/blackberry10/bin/templates/project/cordova/build.bat @@ -17,5 +17,5 @@ goto comment specific language governing permissions and limitations under the License. :comment - [email protected] %~dps0\lib\build %* +call "%~dp0init" +"%CORDOVA_NODE%\node.exe" "%~dps0\lib\build" %* http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/clean ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/clean b/blackberry10/bin/templates/project/cordova/clean index abe96ea..94d0aba 100755 --- a/blackberry10/bin/templates/project/cordova/clean +++ b/blackberry10/bin/templates/project/cordova/clean @@ -1,3 +1,4 @@ #!/bin/sh +source $(dirname "$0")/init -node "$(dirname "$0")/lib/clean" +"$CORDOVA_NODE/node" "$(dirname "$0")/lib/clean" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/clean.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/clean.bat b/blackberry10/bin/templates/project/cordova/clean.bat index d613d87..091c3ce 100755 --- a/blackberry10/bin/templates/project/cordova/clean.bat +++ b/blackberry10/bin/templates/project/cordova/clean.bat @@ -17,5 +17,5 @@ goto comment specific language governing permissions and limitations under the License. :comment - [email protected] %~dps0\lib\clean %* +call "%~dp0init" +"%CORDOVA_NODE%\node.exe" "%~dps0\lib\clean" %* http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js b/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js index 4287df7..bbdb048 100755 --- a/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js +++ b/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js @@ -99,22 +99,23 @@ function generateDeployTokenOptions(target) { } function execNativeScript(script, options, callback) { - var process; + var cp; + script = path.join(process.env.CORDOVA_BBTOOLS, script); if (pkgrUtils.isWindows()) { script += ".bat"; } - process = childProcess.spawn(script, options, { + cp = childProcess.spawn(script, options, { "cwd" : workingDir, - "env" : process ? process.env : undefined + "env" : process.env }); - process.stdout.on("data", pkgrUtils.handleProcessOutput); + cp.stdout.on("data", pkgrUtils.handleProcessOutput); - process.stderr.on("data", pkgrUtils.handleProcessOutput); + cp.stderr.on("data", pkgrUtils.handleProcessOutput); - process.on("exit", function (code) { + cp.on("exit", function (code) { if (callback && typeof callback === "function") { callback(code); } @@ -243,8 +244,7 @@ self.deployToken = function (projectProperties, target, callback) { }; self.checkDebugToken = function (pin, callback) { - var process, - script = "blackberry-nativepackager", + var script = path.join(process.env.CORDOVA_BBTOOLS, "blackberry-nativepackager"), nativePackager; if (!callback || typeof callback !== "function") { @@ -262,7 +262,7 @@ self.checkDebugToken = function (pin, callback) { nativePackager = childProcess.exec(path.normalize(script +" -listManifest " + debugTokenDir), { "cwd": workingDir, - "env": process ? process.env : undefined + "env": process.env }, function (error, stdout, stderr) { callback(isDebugTokenValid(pin, stdout)); }); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/list-devices ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/list-devices b/blackberry10/bin/templates/project/cordova/lib/list-devices index c1644ad..7c7b623 100755 --- a/blackberry10/bin/templates/project/cordova/lib/list-devices +++ b/blackberry10/bin/templates/project/cordova/lib/list-devices @@ -20,7 +20,5 @@ set -e -CURRENT_DIR=$(pwd) -BIN_DIR=$(dirname "$0") - -node list-devices.js +source $(dirname "$0")/../init +"$CORDOVA_NODE/node" "$(dirname "$0")/list-devices.js" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/list-devices.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/list-devices.bat b/blackberry10/bin/templates/project/cordova/lib/list-devices.bat index 7449ee5..ce34293 100644 --- a/blackberry10/bin/templates/project/cordova/lib/list-devices.bat +++ b/blackberry10/bin/templates/project/cordova/lib/list-devices.bat @@ -16,5 +16,5 @@ :: under the License. @ECHO OFF - [email protected] list-devices.js +call "%~dp0..\init" +"%CORDOVA_NODE%\node.exe" "%~dps0\list-devices.js" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/list-emulator-images ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/list-emulator-images b/blackberry10/bin/templates/project/cordova/lib/list-emulator-images index 8c63826..1cac650 100755 --- a/blackberry10/bin/templates/project/cordova/lib/list-emulator-images +++ b/blackberry10/bin/templates/project/cordova/lib/list-emulator-images @@ -20,4 +20,5 @@ set -e -node list-emulator-images.js +source $(dirname "$0")/../init +"$CORDOVA_NODE/node" "$(dirname "$0")/list-emulator-images.js" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/list-emulator-images.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/list-emulator-images.bat b/blackberry10/bin/templates/project/cordova/lib/list-emulator-images.bat index 2e3523e..0726be5 100644 --- a/blackberry10/bin/templates/project/cordova/lib/list-emulator-images.bat +++ b/blackberry10/bin/templates/project/cordova/lib/list-emulator-images.bat @@ -16,5 +16,5 @@ :: under the License. @ECHO OFF - [email protected] list-emulator-images.js +call "%~dp0..\init" +"%CORDOVA_NODE%\node.exe" "%~dps0\list-emulator-images.js" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/list-started-emulators ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/list-started-emulators b/blackberry10/bin/templates/project/cordova/lib/list-started-emulators index e000620..3d4b286 100755 --- a/blackberry10/bin/templates/project/cordova/lib/list-started-emulators +++ b/blackberry10/bin/templates/project/cordova/lib/list-started-emulators @@ -20,4 +20,5 @@ set -e -node list-started-emulators.js +source $(dirname "$0")/../init +"$CORDOVA_NODE/node" "$(dirname "$0")/list-started-emulators.js" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/list-started-emulators.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/list-started-emulators.bat b/blackberry10/bin/templates/project/cordova/lib/list-started-emulators.bat index 95bd584..052dee3 100644 --- a/blackberry10/bin/templates/project/cordova/lib/list-started-emulators.bat +++ b/blackberry10/bin/templates/project/cordova/lib/list-started-emulators.bat @@ -16,5 +16,5 @@ :: under the License. @ECHO OFF - [email protected] list-started-emulators.js +call "%~dp0..\init" +"%CORDOVA_NODE%\node.exe" "%~dps0\list-started-emulators.js" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/native-packager.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/native-packager.js b/blackberry10/bin/templates/project/cordova/lib/native-packager.js index a35b5ba..e4aa81b 100644 --- a/blackberry10/bin/templates/project/cordova/lib/native-packager.js +++ b/blackberry10/bin/templates/project/cordova/lib/native-packager.js @@ -246,7 +246,7 @@ function generateOptionsFile(session, target, config) { } function execNativePackager(session, callback) { - var script = "blackberry-nativepackager", + var script = path.join(process.env.CORDOVA_BBTOOLS, "blackberry-nativepackager"), cwd = session.sourceDir, nativePkgr; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/plugin-wrapper.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/plugin-wrapper.js b/blackberry10/bin/templates/project/cordova/lib/plugin-wrapper.js new file mode 100755 index 0000000..d14f0ae --- /dev/null +++ b/blackberry10/bin/templates/project/cordova/lib/plugin-wrapper.js @@ -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. + */ + +require(require("path").join(__dirname, "plugin.js")).cli(); + http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/plugin.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/plugin.js b/blackberry10/bin/templates/project/cordova/lib/plugin.js index e6a0b37..13c547b 100644 --- a/blackberry10/bin/templates/project/cordova/lib/plugin.js +++ b/blackberry10/bin/templates/project/cordova/lib/plugin.js @@ -21,9 +21,9 @@ var path = require("path"), wrench = require("wrench"), fs = require('fs'), et = require('elementtree'), - escapeStringForShell = require("./packager-utils").escapeStringForShell, + plugman = require('plugman'), PROJECT_ROOT = path.join(__dirname, "..", ".."), - PLUGMAN = escapeStringForShell(path.join(PROJECT_ROOT, "cordova", "node_modules", "plugman", "main.js")), + PLUGMAN = 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 = { @@ -35,41 +35,32 @@ var path = require("path"), return argumentor; }, setAction: function () { - this.args.push("--" + this.action); + this.args.action = this.action; return argumentor; }, setPlatform: function () { - this.args.push("--platform"); - this.args.push("blackberry10"); + this.args.platform = "blackberry10"; return argumentor; }, setProject: function () { - this.args.push("--project"); - this.args.push(escapeStringForShell(PROJECT_ROOT)); + this.args.project = 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(escapeStringForShell(pluginWithoutTrailingSlash)); + this.args.plugin = pluginWithoutTrailingSlash; return argumentor; }, setPluginsDir: function (isGlobal) { - this.args.push("--plugins_dir"); if (isGlobal) { - this.args.push(escapeStringForShell(GLOBAL_PLUGIN_PATH)); + this.args.pluginDir = GLOBAL_PLUGIN_PATH; } else { - this.args.push(escapeStringForShell(LOCAL_PLUGIN_PATH)); + this.args.pluginDir = LOCAL_PLUGIN_PATH; } return argumentor; }, run: function () { - var cmd = ""; - if (require('os').type().toLowerCase().indexOf("windows") >= 0) { - cmd += "@node.exe "; - } - cmd += PLUGMAN + " " + this.args.join(" "); - return shell.exec(cmd, {silent: false}); + plugman.install(this.args.platform, this.args.project, this.args.plugin, this.args.pluginDir, {}); } }, plugmanInterface= { http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/run ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/run b/blackberry10/bin/templates/project/cordova/lib/run index 0d57afd..8429db2 100755 --- a/blackberry10/bin/templates/project/cordova/lib/run +++ b/blackberry10/bin/templates/project/cordova/lib/run @@ -72,7 +72,7 @@ function generateOptions(uninstall) { } function execNativeDeploy(optionsArray, callback) { - var script = "blackberry-deploy", + var script = path.join(process.env.CORDOVA_BBTOOLS, "blackberry-deploy"), nativeDeploy; options = optionsArray.join(" "); @@ -150,7 +150,7 @@ function checkTarget() { } function uninstall() { - var script = "/bin/blackberry-deploy", + var script = path.join(process.env.CORDOVA_BBTOOLS, "blackberry-deploy"), nativeDeploy; if (pkgrUtils.isWindows()) { http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/signing-helper.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/signing-helper.js b/blackberry10/bin/templates/project/cordova/lib/signing-helper.js index b7cdd9b..c4074af 100644 --- a/blackberry10/bin/templates/project/cordova/lib/signing-helper.js +++ b/blackberry10/bin/templates/project/cordova/lib/signing-helper.js @@ -61,7 +61,7 @@ function getDefaultPath(file) { } function execSigner(session, target, callback) { - var script = "blackberry-signer", + var script = path.join(process.env.CORDOVA_BBTOOLS, "blackberry-signer"), signer, params = session.getParams("blackberry-signer"), args = []; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/lib/target-utils.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/target-utils.js b/blackberry10/bin/templates/project/cordova/lib/target-utils.js index 50091a4..b82f958 100644 --- a/blackberry10/bin/templates/project/cordova/lib/target-utils.js +++ b/blackberry10/bin/templates/project/cordova/lib/target-utils.js @@ -16,6 +16,7 @@ var _self, exec = require('child_process').exec, + path = require('path'), bb10_utils = require('./utils'), blackberryProperties = bb10_utils.getProperties(); @@ -55,13 +56,15 @@ _self = { } else { count++; } - } + } } complete(); }, checkConnection: function(ip, type, callback) { - exec('blackberry-deploy -test ' + ip, function(error, stdout, stderr) { + var script = path.join(process.env.CORDOVA_BBTOOLS, 'blackberry-deploy'); + + exec(script + ' -test ' + ip, function(error, stdout, stderr) { // error code 3 corresponds to a connected device, null corresponds to connected sim callback((type === 'simulator' && error === null) || (type == 'device' && error.code === 3)); }); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/plugin ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/plugin b/blackberry10/bin/templates/project/cordova/plugin index 010649b..bbecb55 100755 --- a/blackberry10/bin/templates/project/cordova/plugin +++ b/blackberry10/bin/templates/project/cordova/plugin @@ -1,23 +1,4 @@ -#!/usr/bin/env node - -/** - * 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. - */ - -require(require("path").join(__dirname, "lib", "plugin.js")).cli(); +#!/bin/sh +source $(dirname "$0")/init +"$CORDOVA_NODE/node" "$(dirname "$0")/lib/plugin-wrapper" "$@" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/plugin.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/plugin.bat b/blackberry10/bin/templates/project/cordova/plugin.bat index 8a53da1..3080228 100755 --- a/blackberry10/bin/templates/project/cordova/plugin.bat +++ b/blackberry10/bin/templates/project/cordova/plugin.bat @@ -17,5 +17,5 @@ goto comment specific language governing permissions and limitations under the License. :comment - [email protected] %~dps0\plugin %* +call "%~dp0init" +"%CORDOVA_NODE%\node.exe" "%~dps0\lib\plugin-wrapper" %* http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/run ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/run b/blackberry10/bin/templates/project/cordova/run index c6ccacf..24e26e6 100755 --- a/blackberry10/bin/templates/project/cordova/run +++ b/blackberry10/bin/templates/project/cordova/run @@ -1,3 +1,4 @@ #!/bin/sh +source $(dirname "$0")/init -node "$( dirname "$0")/lib/run" "$@" +"$CORDOVA_NODE/node" "$( dirname "$0")/lib/run" "$@" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/run.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/run.bat b/blackberry10/bin/templates/project/cordova/run.bat index 32b6cc3..401086f 100755 --- a/blackberry10/bin/templates/project/cordova/run.bat +++ b/blackberry10/bin/templates/project/cordova/run.bat @@ -17,5 +17,5 @@ goto comment specific language governing permissions and limitations under the License. :comment - [email protected] %~dps0\lib\run %* +call "%~dp0init" +"%CORDOVA_NODE%\node.exe" "%~dps0\lib\run" %* http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/version ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/version b/blackberry10/bin/templates/project/cordova/version index bc03aee..62ed952 100755 --- a/blackberry10/bin/templates/project/cordova/version +++ b/blackberry10/bin/templates/project/cordova/version @@ -1,5 +1,6 @@ #!/bin/sh +source $(dirname "$0")/init # Prints cordova version number -node "$(dirname "$0")/lib/version" "$@" +"$CORDOVA_NODE/node" "$(dirname "$0")/lib/version" "$@" http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/bin/templates/project/cordova/version.bat ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/version.bat b/blackberry10/bin/templates/project/cordova/version.bat index 77fe0e1..253f8da 100755 --- a/blackberry10/bin/templates/project/cordova/version.bat +++ b/blackberry10/bin/templates/project/cordova/version.bat @@ -17,5 +17,5 @@ goto comment specific language governing permissions and limitations under the License. :comment - [email protected] %~dps0\lib\version %* +call "%~dp0init" +"%CORDOVA_NODE%\node.exe" "%~dps0\lib\version" %* http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7b933463/blackberry10/package.json ---------------------------------------------------------------------- diff --git a/blackberry10/package.json b/blackberry10/package.json index feae5eb..751fb97 100644 --- a/blackberry10/package.json +++ b/blackberry10/package.json @@ -26,7 +26,7 @@ "validator": "0.4.1", "wrench": "1.3.9", "shelljs":"0.1.3", - "elementtree": "0.1.x", + "elementtree": "0.1.5", "plugman": "0.9.10" }, "devDependencies": {
