You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2013/06/18 01:31:18 UTC
[3/5] webworks commit: [CB-3799] Modified scripts to store debugtoken
as %HOME%/.cordova/blackberry10-debugtoken.bar - Includes modifications to
util scripts for reading from properties file
[CB-3799] Modified scripts to store debugtoken as
%HOME%/.cordova/blackberry10-debugtoken.bar
- Includes modifications to util scripts for reading from properties
file
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/e95b34c3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/e95b34c3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/e95b34c3
Branch: refs/heads/master
Commit: e95b34c35f7fbefcde0cff9614386e7024f0c987
Parents: 06acc70
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Mon Jun 17 11:52:37 2013 -0400
Committer: jkeshavarzi <jk...@blackberry.com>
Committed: Mon Jun 17 16:20:58 2013 -0400
----------------------------------------------------------------------
blackberry10/bin/lib/blackberry10.json | 4 ---
blackberry10/bin/lib/target.js | 30 ++++++----------
blackberry10/bin/lib/utils.js | 37 +++++++++++++++-----
.../bin/templates/project/cordova/lib/build | 16 ++++-----
.../bin/templates/project/cordova/lib/conf.js | 3 +-
.../project/cordova/lib/debugtoken-helper.js | 4 +--
.../project/cordova/lib/native-packager.js | 13 +++----
.../bin/templates/project/cordova/lib/run | 4 +--
8 files changed, 57 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e95b34c3/blackberry10/bin/lib/blackberry10.json
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/blackberry10.json b/blackberry10/bin/lib/blackberry10.json
deleted file mode 100644
index 06d6a8b..0000000
--- a/blackberry10/bin/lib/blackberry10.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "targets": {
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e95b34c3/blackberry10/bin/lib/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/target.js b/blackberry10/bin/lib/target.js
index b259f0c..a436be4 100644
--- a/blackberry10/bin/lib/target.js
+++ b/blackberry10/bin/lib/target.js
@@ -19,8 +19,7 @@ var path = require('path'),
fs = require('fs'),
utils = require('./utils'),
commander = require('commander'),
- propertiesFile = utils.initPropertiesFile(),
- properties = require(propertiesFile),
+ properties = utils.getProperties(),
command,
name,
ip,
@@ -29,13 +28,6 @@ var path = require('path'),
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,
@@ -44,7 +36,7 @@ function isValidIp(ip) {
if (typeof ip !== 'string') {
console.log("IP is required");
console.log(commander.helpInformation());
- process.exit(2);
+ process.exit(2);
} else {
ipArray = ip.split('.');
if (ipArray.length !== 4) {
@@ -66,7 +58,7 @@ function isValidType(type) {
if (typeof type !== 'string') {
console.log("target type is required");
console.log(commander.helpInformation());
- process.exit(2);
+ process.exit(2);
}
else if (!(type === 'device' || type === 'simulator')) {
result = false;
@@ -105,7 +97,7 @@ commander
if (commander.args.length === 1) {
console.log("Target details not specified");
console.log(commander.helpInformation());
- process.exit(2);
+ process.exit(2);
}
name = commander.args[0];
ip = commander.args[1];
@@ -119,17 +111,17 @@ commander
if (!isValidIp(ip)) {
console.log("Invalid IP: " + ip);
console.log(commander.helpInformation());
- process.exit(2);
+ process.exit(2);
}
if (!isValidType(type)) {
console.log("Invalid target type: " + type);
console.log(commander.helpInformation());
- process.exit(2);
+ process.exit(2);
}
if (!isValidPin(pin)) {
console.log("Invalid PIN: " + pin);
console.log(commander.helpInformation());
- process.exit(2);
+ process.exit(2);
}
if (properties.targets.hasOwnProperty(name)) {
console.log("Overwriting target: " + name);
@@ -144,13 +136,13 @@ commander
if (commander.args.length === 1) {
console.log('No target specified');
console.log(commander.helpInformation());
- process.exit(2);
+ 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);
+ process.exit(2);
}
if (name === properties.defaultTarget) {
console.log("Deleting default target, please set a new default target");
@@ -173,7 +165,7 @@ commander
} else {
console.log("Target '" + name + "' not found");
console.log(commander.helpInformation());
- process.exit(2);
+ process.exit(2);
}
});
@@ -203,7 +195,7 @@ try {
properties.defaultTarget = Object.keys(properties.targets)[0];
}
- writeProjectFile(JSON.stringify(properties, null, 4) + "\n", propertiesFile);
+ utils.writeToPropertiesFile(properties);
} catch (e) {
console.log(e);
process.exit();
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e95b34c3/blackberry10/bin/lib/utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/utils.js b/blackberry10/bin/lib/utils.js
index 34b6291..de4557c 100644
--- a/blackberry10/bin/lib/utils.js
+++ b/blackberry10/bin/lib/utils.js
@@ -19,8 +19,12 @@ var fs = require('fs'),
wrench = require('wrench'),
localize = require("./localize"),
os = require('os'),
- propertyFileName = 'blackberry10.json',
- propertyFileDir = '.cordova',
+ PROPERTY_FILE_NAME = 'blackberry10.json',
+ CORDOVA_DIR = '.cordova',
+ DEFAULT_PROPERTY_FILE = {
+ targets: {
+ }
+ },
_self;
function swapBytes(buffer) {
@@ -169,16 +173,31 @@ _self = {
return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
},
- initPropertiesFile : function () {
- homePath = _self.findHomePath();
- propertiesFile = path.join(homePath, propertyFileDir, propertyFileName);
- if (!fs.existsSync(path.join(homePath, propertyFileDir))) {
- fs.mkdirSync(path.join(homePath, propertyFileDir));
+ getCordovaDir: function () {
+ var cordovaPath = path.join(_self.findHomePath(), CORDOVA_DIR);
+
+ if (!fs.existsSync(cordovaPath)) {
+ fs.mkdirSync(cordovaPath);
}
+
+ return cordovaPath;
+ },
+
+ getProperties: function () {
+ var propertiesFile = path.join(_self.getCordovaDir(), PROPERTY_FILE_NAME);
+
if (!fs.existsSync(propertiesFile)) {
- _self.copyFile(propertyFileName, path.join(homePath, propertyFileDir), __dirname);
+ _self.writeToPropertiesFile(DEFAULT_PROPERTY_FILE);
}
- return propertiesFile;
+
+ return require(propertiesFile);
+ },
+
+ writeToPropertiesFile: function (data) {
+ var contents = JSON.stringify(data, null, 4) + "\n",
+ propertiesFile = path.join(_self.getCordovaDir(), PROPERTY_FILE_NAME);
+
+ fs.writeFileSync(propertiesFile, contents, 'utf-8');
}
};
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e95b34c3/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 cdd48a4..77da8dd 100755
--- a/blackberry10/bin/templates/project/cordova/lib/build
+++ b/blackberry10/bin/templates/project/cordova/lib/build
@@ -19,13 +19,13 @@
var path = require("path"),
command = require("commander"),
utils = require("./utils"),
- bbProperties = require(utils.initPropertiesFile()),
+ bbProperties = utils.getProperties(),
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"),
@@ -56,7 +56,7 @@ function doReleaseBuild() {
bbwpArgv.push(bbProperties.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());
+ console.log(command.helpInformation());
process.exit(2);
}
@@ -93,7 +93,7 @@ function clean(previous, baton) {
if (pkgrUtils.isWindows()) {
execName = "clean";
- }
+ }
baton.take();
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e95b34c3/blackberry10/bin/templates/project/cordova/lib/conf.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/conf.js b/blackberry10/bin/templates/project/cordova/lib/conf.js
index 89f8372..6d0dfd1 100644
--- a/blackberry10/bin/templates/project/cordova/lib/conf.js
+++ b/blackberry10/bin/templates/project/cordova/lib/conf.js
@@ -15,6 +15,7 @@
*/
var path = require("path"),
+ utils = require("./utils"),
fs = require("fs");
function getToolsDir() {
@@ -40,7 +41,7 @@ module.exports = {
DEPENDENCIES_BOOTSTRAP: path.normalize(__dirname + "/../framework/bootstrap"),
DEPENDENCIES_TOOLS: getToolsDir(),
DEPENDENCIES_WWE: path.normalize(__dirname + "/../dependencies/%s-wwe"),
- DEBUG_TOKEN: path.normalize(__dirname + "/../debugtoken.bar"),
+ DEBUG_TOKEN: path.normalize(path.join(utils.getCordovaDir(), "blackberry10-debugtoken.bar")),
DEFAULT_ICON: path.normalize(__dirname + "/../default-icon.png"),
BAR_DESCRIPTOR: "bar-descriptor.xml",
BBWP_IGNORE_FILENAME: ".bbwpignore"
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e95b34c3/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 f1a4220..6d8c838 100755
--- a/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
+++ b/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
@@ -21,8 +21,9 @@ var childProcess = require("child_process"),
localize = require("./localize"),
logger = require("./logger"),
pkgrUtils = require("./packager-utils"),
+ utils = require("./utils"),
workingDir = path.normalize(__dirname + "/.."),
- debugTokenDir = path.normalize(workingDir + "/" + "debugtoken.bar"),
+ debugTokenDir = path.normalize(path.join(utils.getCordovaDir(), "blackberry10-debugtoken.bar")),
properties,
targets,
deployCallback,
@@ -33,7 +34,6 @@ function isDebugTokenValid(pin, data) {
i,
l,
expiry = null,
- pin,
devices = [],
line,
now = new Date();
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e95b34c3/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 d9fe3a2..162cbbd 100644
--- a/blackberry10/bin/templates/project/cordova/lib/native-packager.js
+++ b/blackberry10/bin/templates/project/cordova/lib/native-packager.js
@@ -197,16 +197,11 @@ function generateOptionsFile(session, target, config) {
//if -d was provided and we are not signing [-g], set debugToken
if (session.debug && !isSigning) {
- if (path.extname(conf.DEBUG_TOKEN) === ".bar") {
- if (fs.existsSync(conf.DEBUG_TOKEN)) {
- debugToken = "-debugToken" + NL;
- debugToken += conf.DEBUG_TOKEN + NL;
- }
- else {
- logger.warn(localize.translate("EXCEPTION_DEBUG_TOKEN_NOT_FOUND"));
- }
+ if (fs.existsSync(conf.DEBUG_TOKEN)) {
+ debugToken = "-debugToken" + NL;
+ debugToken += conf.DEBUG_TOKEN + NL;
} else {
- logger.warn(localize.translate("EXCEPTION_DEBUG_TOKEN_WRONG_FILE_EXTENSION"));
+ logger.warn(localize.translate("EXCEPTION_DEBUG_TOKEN_NOT_FOUND"));
}
}
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/e95b34c3/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 bd3269b..3bcfeb6 100755
--- a/blackberry10/bin/templates/project/cordova/lib/run
+++ b/blackberry10/bin/templates/project/cordova/lib/run
@@ -26,7 +26,7 @@ var childProcess = require("child_process"),
localize = require("./localize"),
pkgrUtils = require("./packager-utils"),
debugTokenHelper = require("./debugtoken-helper"),
- targets = require(utils.initPropertiesFile()),
+ targets = utils.getProperties(),
program = require('commander'),
xml2js = require('xml2js'),
jWorkflow = require("jWorkflow"),
@@ -237,7 +237,7 @@ function build(previous, baton) {
if (pkgrUtils.isWindows()) {
execName = "build";
- }
+ }
nativeDeploy = childProcess.exec(execName, {
"cwd": path.normalize(__dirname + "/.."),