cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject webworks commit: [CB-3380] Updates scripts to work better with Node dependency - check_reqs now completes preliminary work in bash/batch ensuring completion without node installed - create now calls npm install first
Date Tue, 04 Jun 2013 17:59:21 GMT
Updated Branches:
  refs/heads/master e4e444d7b -> 373edcab8


[CB-3380] Updates scripts to work better with Node dependency
- check_reqs now completes preliminary work in bash/batch ensuring
  completion without node installed
- create now calls npm install first

Revewied by Bryan Higgins <bhiggins@blackberry.com>


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

Branch: refs/heads/master
Commit: 373edcab82d5d643bf50b75c3a38a77a3f30a65b
Parents: e4e444d
Author: Jeffrey Heifetz <jheifetz@blackberry.com>
Authored: Fri May 31 15:06:55 2013 -0400
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Tue Jun 4 14:01:29 2013 -0400

----------------------------------------------------------------------
 blackberry10/README.md          |   12 +++++--
 blackberry10/bin/check_reqs     |   57 ++++++++++++++++++----------------
 blackberry10/bin/check_reqs.bat |   27 +++++++++++++++-
 blackberry10/bin/check_reqs.js  |   38 ++++++++++++++++++++++
 blackberry10/bin/create         |   19 ++++++++---
 blackberry10/bin/create.bat     |    8 ++++-
 blackberry10/package.json       |   10 ++++--
 7 files changed, 129 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/373edcab/blackberry10/README.md
----------------------------------------------------------------------
diff --git a/blackberry10/README.md b/blackberry10/README.md
index a19b87a..7430e96 100644
--- a/blackberry10/README.md
+++ b/blackberry10/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-blackberry/blob/373edcab/blackberry10/bin/check_reqs
----------------------------------------------------------------------
diff --git a/blackberry10/bin/check_reqs b/blackberry10/bin/check_reqs
index 9a8e9ee..3f8a44f 100755
--- a/blackberry10/bin/check_reqs
+++ b/blackberry10/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-blackberry/blob/373edcab/blackberry10/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/check_reqs.bat b/blackberry10/bin/check_reqs.bat
index ed05fac..faef279 100755
--- a/blackberry10/bin/check_reqs.bat
+++ b/blackberry10/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-blackberry/blob/373edcab/blackberry10/bin/check_reqs.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/check_reqs.js b/blackberry10/bin/check_reqs.js
new file mode 100644
index 0000000..081a0e0
--- /dev/null
+++ b/blackberry10/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-blackberry/blob/373edcab/blackberry10/bin/create
----------------------------------------------------------------------
diff --git a/blackberry10/bin/create b/blackberry10/bin/create
index 990705b..9684032 100755
--- a/blackberry10/bin/create
+++ b/blackberry10/bin/create
@@ -23,10 +23,17 @@
 #
 #!/bin/sh
 
-if ! [ -d ../node_modules ] ; then
-    echo "node dependencies not found. Executing 'sudo npm install'"
-    echo "this will require your system password"
-    sudo npm install
-fi
+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
 
-node $( dirname "$0" )"/create.js" "$@"
+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-blackberry/blob/373edcab/blackberry10/bin/create.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/create.bat b/blackberry10/bin/create.bat
index 7b15594..a8f7bab 100644
--- a/blackberry10/bin/create.bat
+++ b/blackberry10/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-blackberry/blob/373edcab/blackberry10/package.json
----------------------------------------------------------------------
diff --git a/blackberry10/package.json b/blackberry10/package.json
index a879ba3..d1f25f7 100644
--- a/blackberry10/package.json
+++ b/blackberry10/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"
 }


Mime
View raw message