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/12/05 21:05:02 UTC
webworks commit: CB-5434 add homedir() function and use USERPROFILE
on Windows
Updated Branches:
refs/heads/master 5689a49b0 -> df49094ae
CB-5434 add homedir() function and use USERPROFILE on Windows
EXCEPTION_DEBUG_TOKEN_NOT_FOUND and EXCEPTION_DEBUG_TOKEN_NOT_FOUND should reference
the current expected path for files and not something that might only coincidentally
be the right location.
signing-utils should use USERPROFILE on Windows
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/df49094a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/df49094a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/df49094a
Branch: refs/heads/master
Commit: df49094aeac8c1048d9b015f1e61b850e0194c95
Parents: 5689a49
Author: Josh Soref <js...@blackberry.com>
Authored: Mon Nov 18 18:04:10 2013 -0500
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Thu Dec 5 15:05:38 2013 -0500
----------------------------------------------------------------------
blackberry10/bin/lib/signing-utils.js | 8 +-
.../bin/templates/project/cordova/lib/build.js | 2 +-
.../project/cordova/lib/debugtoken-helper.js | 2 +-
.../templates/project/cordova/lib/localize.js | 4 +-
.../project/cordova/lib/native-packager.js | 2 +-
.../project/cordova/lib/packager-utils.js | 7 ++
.../test/cordova/unit/spec/lib/signing-utils.js | 81 +++++++-------------
7 files changed, 42 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/df49094a/blackberry10/bin/lib/signing-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/signing-utils.js b/blackberry10/bin/lib/signing-utils.js
index a491975..255e4b3 100644
--- a/blackberry10/bin/lib/signing-utils.js
+++ b/blackberry10/bin/lib/signing-utils.js
@@ -24,17 +24,17 @@ var fs = require('fs'),
function getDefaultPath(file) {
// The default location where signing key files are stored will vary based on the OS:
- // Windows XP: %HOMEPATH%\Local Settings\Application Data\Research In Motion
- // Windows Vista and Windows 7: %HOMEPATH%\AppData\Local\Research In Motion
+ // Windows XP: %USERPROFILE%\Local Settings\Application Data\Research In Motion
+ // Windows Vista and Windows 7: %USERPROFILE%\AppData\Local\Research In Motion
// Mac OS: ~/Library/Research In Motion
// UNIX or Linux: ~/.rim
var p = "";
if (os.type().toLowerCase().indexOf("windows") >= 0) {
// Try Windows XP location
- p = process.env.HOMEDRIVE + process.env.HOMEPATH + "\\Local Settings\\Application Data\\Research In Motion\\";
+ p = process.env.USERPROFILE + "\\Local Settings\\Application Data\\Research In Motion\\";
if (!fs.existsSync(p)) {
// Try Windows Vista and Windows 7 location
- p = process.env.HOMEDRIVE + process.env.HOMEPATH + "\\AppData\\Local\\Research In Motion\\";
+ p = process.env.USERPROFILE + "\\AppData\\Local\\Research In Motion\\";
}
} else if (os.type().toLowerCase().indexOf("darwin") >= 0) {
// Try Mac OS location
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/df49094a/blackberry10/bin/templates/project/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/build.js b/blackberry10/bin/templates/project/cordova/lib/build.js
index 0c1293c..6112de6 100755
--- a/blackberry10/bin/templates/project/cordova/lib/build.js
+++ b/blackberry10/bin/templates/project/cordova/lib/build.js
@@ -93,7 +93,7 @@ try {
done();
});
} else {
- err = "No signing password provided. Please enter a value for 'keystorepass' in %HOME%/.cordova/blackberry10.json or use --keystorepass via command-line";
+ err = "No signing password provided. Please enter a value for 'keystorepass' in "+pkgrUtils.homedir()+"/.cordova/blackberry10.json or use --keystorepass via command-line";
}
}
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/df49094a/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 0421b6e..12ad61f 100755
--- a/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
+++ b/blackberry10/bin/templates/project/cordova/lib/debugtoken-helper.js
@@ -138,7 +138,7 @@ self.createToken = function (projectProperties, target, keystorepass, callback)
callback(-1);
}
} else if (!keystorepass) {
- logger.warn(localize.translate("WARN_NO_SIGNING_PASSWORD_PROVIDED"));
+ logger.warn(localize.translate("WARN_NO_SIGNING_PASSWORD_PROVIDED", pkgrUtils.homedir()));
if (callback && typeof callback === "function") {
callback(-1);
}
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/df49094a/blackberry10/bin/templates/project/cordova/lib/localize.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/localize.js b/blackberry10/bin/templates/project/cordova/lib/localize.js
index 9b4ec7c..29f46e4 100755
--- a/blackberry10/bin/templates/project/cordova/lib/localize.js
+++ b/blackberry10/bin/templates/project/cordova/lib/localize.js
@@ -35,7 +35,7 @@ var Localize = require("localize"),
"en": "Build ID set in config.xml [version], but no signing password was provided [-g]. Bar will be unsigned"
},
"EXCEPTION_DEBUG_TOKEN_NOT_FOUND": {
- "en": "Failed to find debug token. If you have an existing debug token, please copy it to %HOME%/.cordova/blackberry10debugtoken.bar. To generate a new debug token, execute the 'run' command."
+ "en": "Failed to find debug token. If you have an existing debug token, please copy it to $[1]/.cordova/blackberry10debugtoken.bar. To generate a new debug token, execute the 'run' command."
},
"EXCEPTION_DEBUG_TOKEN_WRONG_FILE_EXTENSION": {
"en": "Specified debug token not a .bar extension"
@@ -188,7 +188,7 @@ var Localize = require("localize"),
"en": "No device PIN found, will omit debug token generation"
},
"WARN_NO_SIGNING_PASSWORD_PROVIDED": {
- "en": "No signing password provided, debug token cannot be generated. Please enter a value for 'keystorepass' in %HOME%/.cordova/blackberry10.json or use --keystorepass via command-line directly from the project cordova scripts."
+ "en": "No signing password provided, debug token cannot be generated. Please enter a value for 'keystorepass' in $[1]/.cordova/blackberry10.json or use --keystorepass via command-line directly from the project cordova scripts."
},
"PROGRESS_GENERATING_DEBUG_TOKEN": {
"en": "Generating debug token"
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/df49094a/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 d418f86..f9d696f 100644
--- a/blackberry10/bin/templates/project/cordova/lib/native-packager.js
+++ b/blackberry10/bin/templates/project/cordova/lib/native-packager.js
@@ -219,7 +219,7 @@ function generateOptionsFile(session, target, config) {
debugToken = "-debugToken" + NL;
debugToken += conf.DEBUG_TOKEN + NL;
} else {
- logger.warn(localize.translate("EXCEPTION_DEBUG_TOKEN_NOT_FOUND"));
+ logger.warn(localize.translate("EXCEPTION_DEBUG_TOKEN_NOT_FOUND", pkgrUtils.homedir()));
}
}
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/df49094a/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/packager-utils.js b/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
index 4f07fc5..121c6a7 100644
--- a/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
+++ b/blackberry10/bin/templates/project/cordova/lib/packager-utils.js
@@ -103,6 +103,13 @@ _self = {
return myString === "true" ? true : myString === "false" ? false : defaultVal;
},
+ homedir: function () {
+ if (_self.isWindows()) {
+ return process.env.USERPROFILE;
+ }
+ return process.env.HOME;
+ },
+
parseUri : function (str) {
var i, uri = {},
key = [ "source", "scheme", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor" ],
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/df49094a/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js b/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js
index ba8ff58..b2f90c6 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js
@@ -32,19 +32,13 @@ describe("signing-utils", function () {
beforeEach(function () {
- /* Preserve the value of the HOMEPATH and HOMEDRIVE environment
- * variables if they are defined. If they are not defined, mark
- * variable for deletion after the test.*/
- if (typeof process.env.HOMEPATH === 'undefined') {
- properties.homepath = "delete";
+ /* Preserve the value of the USERPROFILE environment
+ * variable if it is defined. If it is not defined, mark
+ * the variable for deletion after the test.*/
+ if (typeof process.env.USERPROFILE === 'undefined') {
+ properties.userprofile = "delete";
} else {
- properties.homepath = process.env.HOMEPATH;
- }
-
- if (typeof process.env.HOMEDRIVE === 'undefined') {
- properties.homedrive = "delete";
- } else {
- properties.homedrive = process.env.HOMEDRIVE;
+ properties.userprofile = process.env.USERPROFILE;
}
spyOn(os, "type").andReturn("windows");
@@ -52,22 +46,14 @@ describe("signing-utils", function () {
afterEach(function () {
- /* Restore the value of the HOMEPATH and HOMEDRIVE environment
- * variables if they are defined. If they are not defined, delete
+ /* Restore the value of the USERPROFILE environment
+ * variable if it is defined. If it is not defined, delete
* the property if it was defined in the test.*/
- if (typeof process.env.HOMEPATH === 'string') {
- if (properties.homepath === 'delete') {
- delete process.env.HOMEPATH;
- } else {
- process.env.HOMEPATH = properties.homepath;
- }
- }
-
- if (typeof process.env.HOMEDRIVE === 'string') {
- if (properties.homedrive === 'delete') {
- delete process.env.HOMEDRIVE;
+ if (typeof process.env.USERPROFILE === 'string') {
+ if (properties.userprofile === 'delete') {
+ delete process.env.USERPROFILE;
} else {
- process.env.HOMEDRIVE = properties.homedrive;
+ process.env.USERPROFILE = properties.userprofile;
}
}
});
@@ -153,8 +139,7 @@ describe("signing-utils", function () {
});
it("can find keys in home path", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
+ process.env.USERPROFILE = "C:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (p) {
return p.indexOf("\\Users\\user") !== -1;
@@ -165,9 +150,7 @@ describe("signing-utils", function () {
});
it("can find keys on C drive", function () {
-
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
+ process.env.USERPROFILE = "C:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (p) {
return p.indexOf("C:") !== -1;
@@ -178,8 +161,7 @@ describe("signing-utils", function () {
});
it("can find keys on a drive other than C", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
+ process.env.USERPROFILE = "D:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("D:") !== -1;
@@ -190,8 +172,7 @@ describe("signing-utils", function () {
});
it("can find bbidtoken.csk on a drive other than C", function() {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
+ process.env.USERPROFILE = "D:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("D:") !== -1;
@@ -202,8 +183,7 @@ describe("signing-utils", function () {
});
it("can find barsigner.csk on a drive other than C", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
+ process.env.USERPROFILE = "D:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("D:") !== -1;
@@ -214,8 +194,7 @@ describe("signing-utils", function () {
});
it("can find barsigner.db on a drive other than C", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
+ process.env.USERPROFILE = "D:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("D:") !== -1;
@@ -226,8 +205,7 @@ describe("signing-utils", function () {
});
it("can find keys in Local Settings on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
+ process.env.USERPROFILE = "C:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("C:") !== -1 &&
@@ -240,8 +218,7 @@ describe("signing-utils", function () {
});
it("can find bbidtoken.csk in Local Settings on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
+ process.env.USERPROFILE = "C:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("C:") !== -1 &&
@@ -254,8 +231,7 @@ describe("signing-utils", function () {
});
it("can find barsigner.csk in Local Settings on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
+ process.env.USERPROFILE = "D:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("D:") !== -1 &&
@@ -268,8 +244,7 @@ describe("signing-utils", function () {
});
it("can find barsigner.db in Local Settings on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
+ process.env.USERPROFILE = "D:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("D:") !== -1 &&
@@ -282,8 +257,7 @@ describe("signing-utils", function () {
});
it("can find keys in AppData on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
+ process.env.USERPROFILE = "C:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("C:") !== -1 &&
@@ -296,8 +270,7 @@ describe("signing-utils", function () {
});
it("can find bbidtoken.csk in AppData on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
+ process.env.USERPROFILE = "C:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("C:") !== -1 &&
@@ -310,8 +283,7 @@ describe("signing-utils", function () {
});
it("can find barsigner.csk in AppData on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
+ process.env.USERPROFILE = "D:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("D:") !== -1 &&
@@ -324,8 +296,7 @@ describe("signing-utils", function () {
});
it("can find barsigner.db in AppData on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
+ process.env.USERPROFILE = "D:\\Users\\user";
spyOn(fs, "existsSync").andCallFake(function (path) {
return path.indexOf("D:") !== -1 &&