You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/06/13 00:02:11 UTC

[1/8] webworks commit: [CB-3604] target and create script mods for repo level target script

Updated Branches:
  refs/heads/CB-3604 be2970ef6 -> 7efef0c8a
  refs/heads/master ad135dd97 -> 773001d33


[CB-3604] target and create script mods for repo level target script

create script copies target script and repo level targets.json to project level to support
1. additional targets added at project level without presence of repo
2. prevent breakage due to moving repo
3. allow easy migration of project to another location or system without breakage


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

Branch: refs/heads/CB-3604
Commit: 4e8040dc2a79b10dff7d03da8d52581aef69d188
Parents: be2970e
Author: lorinbeer <lo...@adobe.com>
Authored: Tue Jun 11 09:26:20 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Tue Jun 11 09:26:20 2013 -0700

----------------------------------------------------------------------
 blackberry10/bin/create.js     | 7 +++++++
 blackberry10/bin/lib/target.js | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/4e8040dc/blackberry10/bin/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js
index b454d37..6264e87 100644
--- a/blackberry10/bin/create.js
+++ b/blackberry10/bin/create.js
@@ -38,6 +38,7 @@ var build,
     MODULES_PROJECT_DIR = path.join(__dirname, "..", "node_modules"),
     BOOTSTRAP_PROJECT_DIR = path.join(__dirname, "..", "framework", "bootstrap"),
     FRAMEWORK_LIB_PROJECT_DIR = path.join(__dirname, "..", "framework", "lib"),
+    BIN_DIR = path.join(__dirname),
     BUILD_DIR = path.join(__dirname, "build"),
     CORDOVA_JS_SRC = path.join(__dirname, "..", "javascript", "cordova.blackberry10.js"),
     update_dir = path.join(project_path, "lib", "cordova." + version),
@@ -117,6 +118,12 @@ function copyFilesToProject() {
     wrench.mkdirSyncRecursive(project_path, 0777);
     wrench.copyDirSyncRecursive(TEMPLATE_PROJECT_DIR, project_path);
 
+    // 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", "targets.json"), path.join(project_path, "cordova", "lib"));
+
     // change file permission for cordova scripts because ant copy doesn't preserve file permissions
     wrench.chmodSyncRecursive(path.join(project_path,"cordova"), 0700);
 

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/4e8040dc/blackberry10/bin/lib/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/target.js b/blackberry10/bin/lib/target.js
index d66d5ec..b099c3e 100644
--- a/blackberry10/bin/lib/target.js
+++ b/blackberry10/bin/lib/target.js
@@ -16,7 +16,7 @@
  */
 
 var path = require('path'),
-    propertiesFile = './targets.json',
+    propertiesFile = path.join(__dirname,'targets.json'),
     properties = require(propertiesFile),
     fs = require('fs'),
     commander = require('commander'),


[4/8] webworks commit: [CB-3604] target script changed from project level to repo level script

Posted by lo...@apache.org.
[CB-3604] target script changed from project level to repo level script


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

Branch: refs/heads/master
Commit: 554bd506171eb69913a05974a26e74dd8a7ebc82
Parents: ad135dd
Author: lorinbeer <lo...@adobe.com>
Authored: Fri Jun 7 14:29:37 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Wed Jun 12 15:01:44 2013 -0700

----------------------------------------------------------------------
 blackberry10/bin/lib/target.js    | 209 +++++++++++++++++++++++++++++++++
 blackberry10/bin/lib/targets.json |   5 +
 blackberry10/bin/target           |   3 +
 blackberry10/bin/target.bat       |  21 ++++
 4 files changed, 238 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/554bd506/blackberry10/bin/lib/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/target.js b/blackberry10/bin/lib/target.js
new file mode 100644
index 0000000..d66d5ec
--- /dev/null
+++ b/blackberry10/bin/lib/target.js
@@ -0,0 +1,209 @@
+#!/usr/bin/env node
+/*
+ *  Copyright 2013 Research In Motion Limited.
+ *
+ * Licensed 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 path = require('path'),
+    propertiesFile = './targets.json',
+    properties = require(propertiesFile),
+    fs = require('fs'),
+    commander = require('commander'),
+    command,
+    name,
+    ip,
+    type,
+    password,
+    pin,
+    pinRegex = new RegExp("[0-9A-Fa-f]{8}");
+
+function writeProjectFile(contents, file) {
+    fs.writeFile(file, contents, 'utf-8', function (err) {
+        if (err) console.log("Error updating project.json :(\n" + err);
+        process.exit();
+    });
+}
+
+function isValidIp(ip) {
+    var num,
+        result = true,
+        ipArray;
+
+    if (typeof ip !== 'string') {
+        console.log("IP is required");
+        console.log(commander.helpInformation());
+        process.exit(2); 
+    } else {
+        ipArray = ip.split('.');
+        if (ipArray.length !== 4) {
+            result = false;
+        }
+        ipArray.forEach(function (quadrant) {
+            num = Number(quadrant);
+            if (isNaN(num) || (num < 0) || (num > 255)) {
+                result = false;
+            }
+        });
+    }
+    return result;
+}
+
+function isValidType(type) {
+    var result = true;
+
+    if (typeof type !== 'string') {
+        console.log("target type is required");
+        console.log(commander.helpInformation());
+        process.exit(2); 
+    }
+    else if (!(type === 'device' || type === 'simulator')) {
+        result = false;
+    }
+    return result;
+}
+
+function isValidPin(pin) {
+    var result = true;
+    if (typeof pin !== 'undefined' && !pinRegex.test(pin)) {
+        result = false;
+    }
+    return result;
+}
+
+commander
+    .usage('[command] [params]')
+    .option('-p, --password <password>', 'Specifies password for this target')
+    .option('--pin <devicepin>', 'Specifies PIN for this device')
+    .option('-t, --type <device | simulator>', 'Specifies the target type');
+
+commander
+    .on('--help', function () {
+        console.log('   Synopsis:');
+        console.log('   $ target');
+        console.log('   $ target add <name> <ip> [-t | --type <device | simulator>] [-p | --password <password>] [--pin <devicepin>]');
+        console.log('   $ target remove <name>');
+        console.log('   $ target default [name]');
+        console.log(' ');
+    });
+
+commander
+    .command('add')
+    .description("Add specified target")
+    .action(function () {
+        if (commander.args.length === 1) {
+            console.log("Target details not specified");
+            console.log(commander.helpInformation());
+            process.exit(2); 
+        }
+        name = commander.args[0];
+        ip = commander.args[1];
+        type = commander.type ? commander.type : "device";
+        if (commander.password && typeof commander.password === 'string') {
+            password = commander.password;
+        }
+        if (commander.pin && typeof commander.pin === 'string') {
+            pin = commander.pin;
+        }
+        if (!isValidIp(ip)) {
+            console.log("Invalid IP: " + ip);
+            console.log(commander.helpInformation());
+            process.exit(2); 
+        }
+        if (!isValidType(type)) {
+            console.log("Invalid target type: " + type);
+            console.log(commander.helpInformation());
+            process.exit(2); 
+        }
+        if (!isValidPin(pin)) {
+            console.log("Invalid PIN: " + pin);
+            console.log(commander.helpInformation());
+            process.exit(2); 
+        }
+        if (properties.targets.hasOwnProperty(name)) {
+            console.log("Overwriting target: " + name);
+        }
+        properties.targets[name] = {"ip": ip, "type": type, "password": password, "pin": pin};
+    });
+
+commander
+    .command('remove')
+    .description("Remove specified target")
+    .action(function () {
+        if (commander.args.length === 1) {
+            console.log('No target specified');
+            console.log(commander.helpInformation());
+            process.exit(2); 
+        }
+        name = commander.args[0];
+        if (!properties.targets.hasOwnProperty(name)) {
+            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");
+            properties.defaultTarget = "";
+        }
+        delete properties.targets[name];
+    });
+
+commander
+    .command('default')
+    .description("Get or set default target")
+    .action(function () {
+        if (commander.args.length === 1) {
+            console.log(properties.defaultTarget);
+            process.exit();
+        }
+        name = commander.args[0];
+        if (properties.targets.hasOwnProperty(name)) {
+            properties.defaultTarget = name;
+        } else {
+            console.log("Target '" + name + "' not found");
+            console.log(commander.helpInformation());
+            process.exit(2); 
+        }
+    });
+
+commander
+    .command('*')
+    .action(function () {
+        console.log('Unrecognized command');
+        console.log(commander.helpInformation());
+        process.exit(2);
+    });
+
+
+try {
+    commander.parse(process.argv);
+
+    if (commander.args.length === 0) {
+        Object.keys(properties.targets).forEach(function (target) {
+            if (target === properties.defaultTarget) {
+                console.log('* ' + target);
+            } else {
+                console.log('  ' + target);
+            }
+        });
+        process.exit();
+    }
+    if (Object.keys(properties.targets).length === 1) {
+        properties.defaultTarget = Object.keys(properties.targets)[0];
+    }
+
+    writeProjectFile(JSON.stringify(properties, null, 4) + "\n", propertiesFile);
+} catch (e) {
+    console.log(e);
+    process.exit();
+}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/554bd506/blackberry10/bin/lib/targets.json
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/targets.json b/blackberry10/bin/lib/targets.json
new file mode 100644
index 0000000..85d0113
--- /dev/null
+++ b/blackberry10/bin/lib/targets.json
@@ -0,0 +1,5 @@
+{
+    "defaultTarget": "bb10",
+    "targets": {
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/554bd506/blackberry10/bin/target
----------------------------------------------------------------------
diff --git a/blackberry10/bin/target b/blackberry10/bin/target
new file mode 100755
index 0000000..4e676d2
--- /dev/null
+++ b/blackberry10/bin/target
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+node "$( dirname "$0")/lib/target" "$@"

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/554bd506/blackberry10/bin/target.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/target.bat b/blackberry10/bin/target.bat
new file mode 100755
index 0000000..3c05c97
--- /dev/null
+++ b/blackberry10/bin/target.bat
@@ -0,0 +1,21 @@
+@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
+
+@node.exe %~dps0\lib\target %*


[6/8] webworks commit: [CB-3604] target and create script mods for repo level target script

Posted by lo...@apache.org.
[CB-3604] target and create script mods for repo level target script

create script copies target script and repo level targets.json to project level to support
1. additional targets added at project level without presence of repo
2. prevent breakage due to moving repo
3. allow easy migration of project to another location or system without breakage


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

Branch: refs/heads/master
Commit: b992822898edc5a61c4df60437a29ad141e18847
Parents: 8060b52
Author: lorinbeer <lo...@adobe.com>
Authored: Tue Jun 11 09:26:20 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Wed Jun 12 15:01:58 2013 -0700

----------------------------------------------------------------------
 blackberry10/bin/create.js     | 7 +++++++
 blackberry10/bin/lib/target.js | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b9928228/blackberry10/bin/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js
index b454d37..6264e87 100644
--- a/blackberry10/bin/create.js
+++ b/blackberry10/bin/create.js
@@ -38,6 +38,7 @@ var build,
     MODULES_PROJECT_DIR = path.join(__dirname, "..", "node_modules"),
     BOOTSTRAP_PROJECT_DIR = path.join(__dirname, "..", "framework", "bootstrap"),
     FRAMEWORK_LIB_PROJECT_DIR = path.join(__dirname, "..", "framework", "lib"),
+    BIN_DIR = path.join(__dirname),
     BUILD_DIR = path.join(__dirname, "build"),
     CORDOVA_JS_SRC = path.join(__dirname, "..", "javascript", "cordova.blackberry10.js"),
     update_dir = path.join(project_path, "lib", "cordova." + version),
@@ -117,6 +118,12 @@ function copyFilesToProject() {
     wrench.mkdirSyncRecursive(project_path, 0777);
     wrench.copyDirSyncRecursive(TEMPLATE_PROJECT_DIR, project_path);
 
+    // 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", "targets.json"), path.join(project_path, "cordova", "lib"));
+
     // change file permission for cordova scripts because ant copy doesn't preserve file permissions
     wrench.chmodSyncRecursive(path.join(project_path,"cordova"), 0700);
 

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b9928228/blackberry10/bin/lib/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/target.js b/blackberry10/bin/lib/target.js
index d66d5ec..b099c3e 100644
--- a/blackberry10/bin/lib/target.js
+++ b/blackberry10/bin/lib/target.js
@@ -16,7 +16,7 @@
  */
 
 var path = require('path'),
-    propertiesFile = './targets.json',
+    propertiesFile = path.join(__dirname,'targets.json'),
     properties = require(propertiesFile),
     fs = require('fs'),
     commander = require('commander'),


[2/8] webworks commit: minor fix to plugin syntax, list to ls

Posted by lo...@apache.org.
minor fix to plugin syntax, list to ls


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

Branch: refs/heads/CB-3604
Commit: 71b36016bf141b1f1c0f3b45dadb07c887257a48
Parents: 4e8040d
Author: lorinbeer <lo...@adobe.com>
Authored: Tue Jun 11 11:32:48 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Tue Jun 11 11:32:48 2013 -0700

----------------------------------------------------------------------
 blackberry10/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/71b36016/blackberry10/README.md
----------------------------------------------------------------------
diff --git a/blackberry10/README.md b/blackberry10/README.md
index 7430e96..0129ecf 100644
--- a/blackberry10/README.md
+++ b/blackberry10/README.md
@@ -96,5 +96,5 @@ Now the plugin can be installed by name:
 
 Plugins hosted remotely can be installed by name without using fetch. To see a list of available remote plugins use:
 
-`<path to project>/cordova/plugin list`
+`<path to project>/cordova/plugin ls`
 


[7/8] webworks commit: minor fix to plugin syntax, list to ls

Posted by lo...@apache.org.
minor fix to plugin syntax, list to ls


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

Branch: refs/heads/master
Commit: 25bad0d3e78403589b8753c90f95c54ba0e2e45d
Parents: b992822
Author: lorinbeer <lo...@adobe.com>
Authored: Tue Jun 11 11:32:48 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Wed Jun 12 15:02:03 2013 -0700

----------------------------------------------------------------------
 blackberry10/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/25bad0d3/blackberry10/README.md
----------------------------------------------------------------------
diff --git a/blackberry10/README.md b/blackberry10/README.md
index 7430e96..0129ecf 100644
--- a/blackberry10/README.md
+++ b/blackberry10/README.md
@@ -96,5 +96,5 @@ Now the plugin can be installed by name:
 
 Plugins hosted remotely can be installed by name without using fetch. To see a list of available remote plugins use:
 
-`<path to project>/cordova/plugin list`
+`<path to project>/cordova/plugin ls`
 


[3/8] webworks commit: [CB-3604] build and run project level scripts updated to use targets.json

Posted by lo...@apache.org.
[CB-3604] build and run project level scripts updated to use targets.json


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

Branch: refs/heads/CB-3604
Commit: 7efef0c8aee3299d966ae7d241c75f007f994eb5
Parents: 71b3601
Author: lorinbeer <lo...@adobe.com>
Authored: Wed Jun 12 14:59:00 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Wed Jun 12 14:59:00 2013 -0700

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/build     | 16 ++++++------
 .../bin/templates/project/cordova/lib/run       | 27 ++++++++++----------
 2 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7efef0c8/blackberry10/bin/templates/project/cordova/lib/build
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/build b/blackberry10/bin/templates/project/cordova/lib/build
index 5e15425..8843457 100755
--- a/blackberry10/bin/templates/project/cordova/lib/build
+++ b/blackberry10/bin/templates/project/cordova/lib/build
@@ -18,13 +18,13 @@
 
 var path = require("path"),
     command = require("commander"),
-    projectProperties = require("../../project.json"),
+    targets = require(path.join(__dirname,"targets.json")),
     bbwpArgv = [
-        process.argv[0],
-        path.resolve(path.join(__dirname, process.argv[1])),
-        path.resolve(path.join(__dirname, "..", "..", "www")),
-        "-o",
-        path.resolve(path.join(__dirname, "..", "..", "build"))
+    process.argv[0],
+    path.resolve(path.join(__dirname, process.argv[1])),
+    path.resolve(path.join(__dirname, "..", "..", "www")),
+    "-o",
+    path.resolve(path.join(__dirname, "..", "..", "build"))
     ],
     jWorkflow = require("jWorkflow"),
     childProcess = require("child_process"),
@@ -50,9 +50,9 @@ function doReleaseBuild() {
     if (command["keystorepass"]) {
         bbwpArgv.push("--password");
         bbwpArgv.push(command["keystorepass"]);
-    } else if (projectProperties.keystorepass) {
+    } else if (targets.keystorepass) {
         bbwpArgv.push("--password");
-        bbwpArgv.push( projectProperties.keystorepass);
+        bbwpArgv.push(targets.keystorepass);
     } else {
         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()); 

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/7efef0c8/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 d4430f9..791dabe 100755
--- a/blackberry10/bin/templates/project/cordova/lib/run
+++ b/blackberry10/bin/templates/project/cordova/lib/run
@@ -25,7 +25,8 @@ var childProcess = require("child_process"),
     localize = require("./localize"),
     pkgrUtils = require("./packager-utils"),
     debugTokenHelper = require("./debugtoken-helper"),
-    properties = require('../../project.json'),
+    targets = require(path.join(__dirname,'targets.json')),
+    projectProperties = require(path.join(__dirname,'..','..','project.json')),
     program = require('commander'),
     xml2js = require('xml2js'),
     jWorkflow = require("jWorkflow"),
@@ -41,7 +42,7 @@ var childProcess = require("child_process"),
 
 function generateOptions(uninstall) {
     var options = [];
-        barPath = pkgrUtils.escapeStringForShell(path.normalize(__dirname + "/../../build/" + properties.targets[target].type + "/" + properties.barName + ".bar"));
+        barPath = pkgrUtils.escapeStringForShell(path.normalize(__dirname + "/../../build/" + targets.targets[target].type + "/" + projectProperties.barName + ".bar"));
 
     options.push("-device");
     options.push(ip);
@@ -104,20 +105,20 @@ function checkTarget() {
         console.log(program.helpInformation());
         return false;
     }
-    if (!properties.targets[target]) {
+    if (!targets.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>]");
         console.log(program.helpInformation());
         return false;
     }
-    if (properties.targets[target].ip) {
-       ip = properties.targets[target].ip;
+    if (targets.targets[target].ip) {
+       ip = targets.targets[target].ip;
     } else {
         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;
+    if (targets.targets[target].password) {
+       password = targets.targets[target].password;
     }
     return true;
 }
@@ -168,8 +169,8 @@ function checkDebugtoken(previous, baton) {
     baton.take();
 
     // if target has no pin, skip the debug token feature
-    if (properties.targets[target].pin) {
-        debugTokenHelper.checkDebugToken(properties.targets[target].pin, function (valid) {
+    if (targets.targets[target].pin) {
+        debugTokenHelper.checkDebugToken(targets.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
@@ -186,12 +187,12 @@ function checkDebugtoken(previous, baton) {
 }
 
 function createDebugToken(previous, baton) {
-    var keystorepass = program["keystorepass"] ? program["keystorepass"] : properties.keystorepass;
+    var keystorepass = program["keystorepass"] ? program["keystorepass"] : targets.keystorepass;
 
     baton.take();
 
     if (needCreateDebugToken) {
-        debugTokenHelper.createToken(properties, "all", keystorepass, function (code) {
+        debugTokenHelper.createToken(targets, "all", keystorepass, function (code) {
             if (code === 0) {
                 // Deploy the debug token if created
                 needDeployDebugToken = true;
@@ -209,7 +210,7 @@ function deployDebugToken(previous, baton) {
 
     // 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 () {
+        debugTokenHelper.deployToken(targets, target, function () {
             baton.pass();
         });
     } else {
@@ -276,7 +277,7 @@ function exec() {
     }
 
     program.parse(process.argv);
-    target = program.args[0] ? program.args[0] : properties.defaultTarget;
+    target = program.args[0] ? program.args[0] : targets.defaultTarget;
 
     if (checkTarget()) {
         if (program.build) {


[8/8] webworks commit: [CB-3604] build and run project level scripts updated to use targets.json

Posted by lo...@apache.org.
[CB-3604] build and run project level scripts updated to use targets.json


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

Branch: refs/heads/master
Commit: 773001d33a13c7d5aa97c145209369b8fef38d14
Parents: 25bad0d
Author: lorinbeer <lo...@adobe.com>
Authored: Wed Jun 12 14:59:00 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Wed Jun 12 15:02:07 2013 -0700

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/build     | 16 ++++++------
 .../bin/templates/project/cordova/lib/run       | 27 ++++++++++----------
 2 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/773001d3/blackberry10/bin/templates/project/cordova/lib/build
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/build b/blackberry10/bin/templates/project/cordova/lib/build
index 5e15425..8843457 100755
--- a/blackberry10/bin/templates/project/cordova/lib/build
+++ b/blackberry10/bin/templates/project/cordova/lib/build
@@ -18,13 +18,13 @@
 
 var path = require("path"),
     command = require("commander"),
-    projectProperties = require("../../project.json"),
+    targets = require(path.join(__dirname,"targets.json")),
     bbwpArgv = [
-        process.argv[0],
-        path.resolve(path.join(__dirname, process.argv[1])),
-        path.resolve(path.join(__dirname, "..", "..", "www")),
-        "-o",
-        path.resolve(path.join(__dirname, "..", "..", "build"))
+    process.argv[0],
+    path.resolve(path.join(__dirname, process.argv[1])),
+    path.resolve(path.join(__dirname, "..", "..", "www")),
+    "-o",
+    path.resolve(path.join(__dirname, "..", "..", "build"))
     ],
     jWorkflow = require("jWorkflow"),
     childProcess = require("child_process"),
@@ -50,9 +50,9 @@ function doReleaseBuild() {
     if (command["keystorepass"]) {
         bbwpArgv.push("--password");
         bbwpArgv.push(command["keystorepass"]);
-    } else if (projectProperties.keystorepass) {
+    } else if (targets.keystorepass) {
         bbwpArgv.push("--password");
-        bbwpArgv.push( projectProperties.keystorepass);
+        bbwpArgv.push(targets.keystorepass);
     } else {
         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()); 

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/773001d3/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 d4430f9..791dabe 100755
--- a/blackberry10/bin/templates/project/cordova/lib/run
+++ b/blackberry10/bin/templates/project/cordova/lib/run
@@ -25,7 +25,8 @@ var childProcess = require("child_process"),
     localize = require("./localize"),
     pkgrUtils = require("./packager-utils"),
     debugTokenHelper = require("./debugtoken-helper"),
-    properties = require('../../project.json'),
+    targets = require(path.join(__dirname,'targets.json')),
+    projectProperties = require(path.join(__dirname,'..','..','project.json')),
     program = require('commander'),
     xml2js = require('xml2js'),
     jWorkflow = require("jWorkflow"),
@@ -41,7 +42,7 @@ var childProcess = require("child_process"),
 
 function generateOptions(uninstall) {
     var options = [];
-        barPath = pkgrUtils.escapeStringForShell(path.normalize(__dirname + "/../../build/" + properties.targets[target].type + "/" + properties.barName + ".bar"));
+        barPath = pkgrUtils.escapeStringForShell(path.normalize(__dirname + "/../../build/" + targets.targets[target].type + "/" + projectProperties.barName + ".bar"));
 
     options.push("-device");
     options.push(ip);
@@ -104,20 +105,20 @@ function checkTarget() {
         console.log(program.helpInformation());
         return false;
     }
-    if (!properties.targets[target]) {
+    if (!targets.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>]");
         console.log(program.helpInformation());
         return false;
     }
-    if (properties.targets[target].ip) {
-       ip = properties.targets[target].ip;
+    if (targets.targets[target].ip) {
+       ip = targets.targets[target].ip;
     } else {
         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;
+    if (targets.targets[target].password) {
+       password = targets.targets[target].password;
     }
     return true;
 }
@@ -168,8 +169,8 @@ function checkDebugtoken(previous, baton) {
     baton.take();
 
     // if target has no pin, skip the debug token feature
-    if (properties.targets[target].pin) {
-        debugTokenHelper.checkDebugToken(properties.targets[target].pin, function (valid) {
+    if (targets.targets[target].pin) {
+        debugTokenHelper.checkDebugToken(targets.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
@@ -186,12 +187,12 @@ function checkDebugtoken(previous, baton) {
 }
 
 function createDebugToken(previous, baton) {
-    var keystorepass = program["keystorepass"] ? program["keystorepass"] : properties.keystorepass;
+    var keystorepass = program["keystorepass"] ? program["keystorepass"] : targets.keystorepass;
 
     baton.take();
 
     if (needCreateDebugToken) {
-        debugTokenHelper.createToken(properties, "all", keystorepass, function (code) {
+        debugTokenHelper.createToken(targets, "all", keystorepass, function (code) {
             if (code === 0) {
                 // Deploy the debug token if created
                 needDeployDebugToken = true;
@@ -209,7 +210,7 @@ function deployDebugToken(previous, baton) {
 
     // 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 () {
+        debugTokenHelper.deployToken(targets, target, function () {
             baton.pass();
         });
     } else {
@@ -276,7 +277,7 @@ function exec() {
     }
 
     program.parse(process.argv);
-    target = program.args[0] ? program.args[0] : properties.defaultTarget;
+    target = program.args[0] ? program.args[0] : targets.defaultTarget;
 
     if (checkTarget()) {
         if (program.build) {


[5/8] webworks commit: [CB-3604] removed project level target scripts

Posted by lo...@apache.org.
[CB-3604] removed project level target scripts


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

Branch: refs/heads/master
Commit: 8060b52a9d78c74baab3d835318e892f0033d630
Parents: 554bd50
Author: lorinbeer <lo...@adobe.com>
Authored: Fri Jun 7 14:44:52 2013 -0700
Committer: lorinbeer <lo...@adobe.com>
Committed: Wed Jun 12 15:01:52 2013 -0700

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/target    | 209 -------------------
 .../bin/templates/project/cordova/target        |   3 -
 .../bin/templates/project/cordova/target.bat    |  21 --
 3 files changed, 233 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/8060b52a/blackberry10/bin/templates/project/cordova/lib/target
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/target b/blackberry10/bin/templates/project/cordova/lib/target
deleted file mode 100644
index 0a5746b..0000000
--- a/blackberry10/bin/templates/project/cordova/lib/target
+++ /dev/null
@@ -1,209 +0,0 @@
-#!/usr/bin/env node
-/*
- *  Copyright 2013 Research In Motion Limited.
- *
- * Licensed 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 path = require('path'),
-    propertiesFile = path.resolve(path.join(__dirname, '..', '..', 'project.json')),
-    properties = require(propertiesFile),
-    fs = require('fs'),
-    commander = require('commander'),
-    command,
-    name,
-    ip,
-    type,
-    password,
-    pin,
-    pinRegex = new RegExp("[0-9A-Fa-f]{8}");
-
-function writeProjectFile(contents, file) {
-    fs.writeFile(file, contents, 'utf-8', function (err) {
-        if (err) console.log("Error updating project.json :(\n" + err);
-        process.exit();
-    });
-}
-
-function isValidIp(ip) {
-    var num,
-        result = true,
-        ipArray;
-
-    if (typeof ip !== 'string') {
-        console.log("IP is required");
-        console.log(commander.helpInformation());
-        process.exit(2); 
-    } else {
-        ipArray = ip.split('.');
-        if (ipArray.length !== 4) {
-            result = false;
-        }
-        ipArray.forEach(function (quadrant) {
-            num = Number(quadrant);
-            if (isNaN(num) || (num < 0) || (num > 255)) {
-                result = false;
-            }
-        });
-    }
-    return result;
-}
-
-function isValidType(type) {
-    var result = true;
-
-    if (typeof type !== 'string') {
-        console.log("target type is required");
-        console.log(commander.helpInformation());
-        process.exit(2); 
-    }
-    else if (!(type === 'device' || type === 'simulator')) {
-        result = false;
-    }
-    return result;
-}
-
-function isValidPin(pin) {
-    var result = true;
-    if (typeof pin !== 'undefined' && !pinRegex.test(pin)) {
-        result = false;
-    }
-    return result;
-}
-
-commander
-    .usage('[command] [params]')
-    .option('-p, --password <password>', 'Specifies password for this target')
-    .option('--pin <devicepin>', 'Specifies PIN for this device')
-    .option('-t, --type <device | simulator>', 'Specifies the target type');
-
-commander
-    .on('--help', function () {
-        console.log('   Synopsis:');
-        console.log('   $ target');
-        console.log('   $ target add <name> <ip> [-t | --type <device | simulator>] [-p | --password <password>] [--pin <devicepin>]');
-        console.log('   $ target remove <name>');
-        console.log('   $ target default [name]');
-        console.log(' ');
-    });
-
-commander
-    .command('add')
-    .description("Add specified target")
-    .action(function () {
-        if (commander.args.length === 1) {
-            console.log("Target details not specified");
-            console.log(commander.helpInformation());
-            process.exit(2); 
-        }
-        name = commander.args[0];
-        ip = commander.args[1];
-        type = commander.type ? commander.type : "device";
-        if (commander.password && typeof commander.password === 'string') {
-            password = commander.password;
-        }
-        if (commander.pin && typeof commander.pin === 'string') {
-            pin = commander.pin;
-        }
-        if (!isValidIp(ip)) {
-            console.log("Invalid IP: " + ip);
-            console.log(commander.helpInformation());
-            process.exit(2); 
-        }
-        if (!isValidType(type)) {
-            console.log("Invalid target type: " + type);
-            console.log(commander.helpInformation());
-            process.exit(2); 
-        }
-        if (!isValidPin(pin)) {
-            console.log("Invalid PIN: " + pin);
-            console.log(commander.helpInformation());
-            process.exit(2); 
-        }
-        if (properties.targets.hasOwnProperty(name)) {
-            console.log("Overwriting target: " + name);
-        }
-        properties.targets[name] = {"ip": ip, "type": type, "password": password, "pin": pin};
-    });
-
-commander
-    .command('remove')
-    .description("Remove specified target")
-    .action(function () {
-        if (commander.args.length === 1) {
-            console.log('No target specified');
-            console.log(commander.helpInformation());
-            process.exit(2); 
-        }
-        name = commander.args[0];
-        if (!properties.targets.hasOwnProperty(name)) {
-            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");
-            properties.defaultTarget = "";
-        }
-        delete properties.targets[name];
-    });
-
-commander
-    .command('default')
-    .description("Get or set default target")
-    .action(function () {
-        if (commander.args.length === 1) {
-            console.log(properties.defaultTarget);
-            process.exit();
-        }
-        name = commander.args[0];
-        if (properties.targets.hasOwnProperty(name)) {
-            properties.defaultTarget = name;
-        } else {
-            console.log("Target '" + name + "' not found");
-            console.log(commander.helpInformation());
-            process.exit(2); 
-        }
-    });
-
-commander
-    .command('*')
-    .action(function () {
-        console.log('Unrecognized command');
-        console.log(commander.helpInformation());
-        process.exit(2);
-    });
-
-
-try {
-    commander.parse(process.argv);
-
-    if (commander.args.length === 0) {
-        Object.keys(properties.targets).forEach(function (target) {
-            if (target === properties.defaultTarget) {
-                console.log('* ' + target);
-            } else {
-                console.log('  ' + target);
-            }
-        });
-        process.exit();
-    }
-    if (Object.keys(properties.targets).length === 1) {
-        properties.defaultTarget = Object.keys(properties.targets)[0];
-    }
-
-    writeProjectFile(JSON.stringify(properties, null, 4) + "\n", propertiesFile);
-} catch (e) {
-    console.log(e);
-    process.exit();
-}

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/8060b52a/blackberry10/bin/templates/project/cordova/target
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/target b/blackberry10/bin/templates/project/cordova/target
deleted file mode 100755
index 4e676d2..0000000
--- a/blackberry10/bin/templates/project/cordova/target
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-node "$( dirname "$0")/lib/target" "$@"

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/8060b52a/blackberry10/bin/templates/project/cordova/target.bat
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/target.bat b/blackberry10/bin/templates/project/cordova/target.bat
deleted file mode 100755
index 3c05c97..0000000
--- a/blackberry10/bin/templates/project/cordova/target.bat
+++ /dev/null
@@ -1,21 +0,0 @@
-@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
-
-@node.exe %~dps0\lib\target %*