cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lorinb...@apache.org
Subject [01/50] [abbrv] webworks commit: Renamed target.js to target due to help command issue
Date Tue, 07 May 2013 15:13:48 GMT
Updated Branches:
  refs/heads/future [created] 42b066f65


Renamed target.js to target due to help command issue

Reviewed by: Hasan Ahmad <haahmad@blackberry.com>
Tested by: Tracy Li <tli@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/a12a25cb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/a12a25cb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/a12a25cb

Branch: refs/heads/future
Commit: a12a25cb2d18097eddb7e49dd89ce3c6c3d148da
Parents: 62a8640
Author: DanielAudino <daudino@blackberry.com>
Authored: Wed Mar 20 16:30:28 2013 -0400
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Fri May 3 10:13:28 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/target       |  187 +++++++++++++++
 .../bin/templates/project/cordova/lib/target.js    |  186 --------------
 blackberry10/bin/templates/project/cordova/target  |    2 +-
 .../bin/templates/project/cordova/target.bat       |    2 +-
 4 files changed, 189 insertions(+), 188 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a12a25cb/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
new file mode 100644
index 0000000..61211d3
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/lib/target
@@ -0,0 +1,187 @@
+#!/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 propertiesFile = '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') {
+        throw "IP is required";
+    } 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') {
+        throw "target type is required";
+    }
+    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');
+
+commander
+    .on('--help', function () {
+        console.log('   Synopsis:');
+        console.log('   $ target');
+        console.log('   $ target add <name> <ip> <type> [-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) {
+            throw "Target details not specified";
+        }
+        name = commander.args[0];
+        ip = commander.args[1];
+        type = commander.args[2];
+        if (commander.password && typeof commander.password === 'string') {
+            password = commander.password;
+        }
+        if (commander.pin && typeof commander.pin === 'string') {
+            pin = commander.pin;
+        }
+        if (!isValidIp(ip)) {
+            throw "Invalid IP: " + ip;
+        }
+        if (!isValidType(type)) {
+            throw "Invalid target type: " + type;
+        }
+        if (!isValidPin(pin)) {
+            throw "Invalid PIN: " + pin;
+        }
+        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) {
+            throw 'No target specified';
+        }
+        name = commander.args[0];
+        if (!properties.targets.hasOwnProperty(name)) {
+            throw "Target: '" + name + "' not found";
+        }
+        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 {
+            throw "Target '" + name + "' not found";
+        }
+    });
+
+commander
+    .command('*')
+    .action(function () {
+        throw 'Unrecognized command';
+    });
+
+
+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/a12a25cb/blackberry10/bin/templates/project/cordova/lib/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/target.js b/blackberry10/bin/templates/project/cordova/lib/target.js
deleted file mode 100644
index d8a1afe..0000000
--- a/blackberry10/bin/templates/project/cordova/lib/target.js
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- *  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 propertiesFile = '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') {
-        throw "IP is required";
-    } 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') {
-        throw "target type is required";
-    }
-    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');
-
-commander
-    .on('--help', function () {
-        console.log('   Synopsis:');
-        console.log('   $ target');
-        console.log('   $ target add <name> <ip> <type> [-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) {
-            throw "Target details not specified";
-        }
-        name = commander.args[0];
-        ip = commander.args[1];
-        type = commander.args[2];
-        if (commander.password && typeof commander.password === 'string') {
-            password = commander.password;
-        }
-        if (commander.pin && typeof commander.pin === 'string') {
-            pin = commander.pin;
-        }
-        if (!isValidIp(ip)) {
-            throw "Invalid IP: " + ip;
-        }
-        if (!isValidType(type)) {
-            throw "Invalid target type: " + type;
-        }
-        if (!isValidPin(pin)) {
-            throw "Invalid PIN: " + pin;
-        }
-        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) {
-            throw 'No target specified';
-        }
-        name = commander.args[0];
-        if (!properties.targets.hasOwnProperty(name)) {
-            throw "Target: '" + name + "' not found";
-        }
-        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 {
-            throw "Target '" + name + "' not found";
-        }
-    });
-
-commander
-    .command('*')
-    .action(function () {
-        throw 'Unrecognized command';
-    });
-
-
-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/a12a25cb/blackberry10/bin/templates/project/cordova/target
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/target b/blackberry10/bin/templates/project/cordova/target
index bbc88bc..624f835 100755
--- a/blackberry10/bin/templates/project/cordova/target
+++ b/blackberry10/bin/templates/project/cordova/target
@@ -2,4 +2,4 @@
 # go to project root
 cd $( dirname "$0")/../
 
-node "cordova/lib/target.js" "$@"
+node "cordova/lib/target" "$@"

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/a12a25cb/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
index 8e48d50..d9324c7 100755
--- a/blackberry10/bin/templates/project/cordova/target.bat
+++ b/blackberry10/bin/templates/project/cordova/target.bat
@@ -21,4 +21,4 @@ goto comment
 REM cd into project dir
 cd %~dp0\..\
 
-@node.exe ./cordova/lib/target.js %*
+@node.exe ./cordova/lib/target %*


Mime
View raw message