diff --git a/blackberry10/.gitignore b/blackberry10/.gitignore index bd46f910..64194f5a 100644 --- a/blackberry10/.gitignore +++ b/blackberry10/.gitignore @@ -19,6 +19,7 @@ dist/ bin/node_modules bin/templates/project/lib bin/templates/project/cordova/lib/utils.js +bin/templates/project/cordova/lib/signing-utils.js example/ node_modules/ .tmp diff --git a/blackberry10/bin/check_reqs.js b/blackberry10/bin/check_reqs.js index b8acadaf..c9321223 100644 --- a/blackberry10/bin/check_reqs.js +++ b/blackberry10/bin/check_reqs.js @@ -34,17 +34,6 @@ if (!isNodeNewerThanMin()) { exit(ERROR_VALUE); } -if (!signingUtils.getKeyStorePath()) { - console.log("WARNING: Cannot sign applications. Author.p12 file cannot be found at default location: " + signingUtils.getDefaultPath("author.p12")); -} - -if (!signingUtils.getKeyStorePathBBID()) { - if (signingUtils.getCskPath() && signingUtils.getDbPath()) { - console.log('NOTE: BlackBerry ID tokens can now be used in place of your old signing keys. For more information on linking old signing keys with a BlackBerry ID token, please log in at http://developer.blackberry.com and click on Code Signing in the top menu bar.'); - } else { - console.log('WARNING: Cannot sign applications. bbidtoken.csk file cannot be found at default location: ' + signingUtils.getDefaultPath("bbidtoken.csk")); - } -} exit(0); diff --git a/blackberry10/bin/lib/signing-utils.js b/blackberry10/bin/lib/signing-utils.js index d2ebae3f..a491975a 100644 --- a/blackberry10/bin/lib/signing-utils.js +++ b/blackberry10/bin/lib/signing-utils.js @@ -11,6 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + var fs = require('fs'), path = require('path'), os = require('os'), @@ -58,7 +59,7 @@ _self = { getDefaultPath: getDefaultPath, getKeyStorePath : function () { - // Todo: decide where to put sigtool.p12 which is genereated and used in WebWorks SDK for Tablet OS + // Todo: decide where to put sigtool.p12 which is generated and used in WebWorks SDK for Tablet OS return getDefaultPathIfExists(AUTHOR_P12); }, @@ -72,6 +73,30 @@ _self = { getDbPath : function () { return getDefaultPathIfExists(DB); + }, + + warn: function () { + if (!this.getKeyStorePath()) { + console.error( + "WARNING: Cannot sign applications. Author.p12 file cannot be found at default location: " + + getDefaultPath("author.p12") + ); + } + + if (!this.getKeyStorePathBBID()) { + + if (this.getCskPath() && this.getDbPath()) { + console.error( + "WARNING: BlackBerry ID tokens can now be used in place of your old signing keys.\n" + + "For more information log in at http://developer.blackberry.com and click on Code Signing" + ); + } else { + console.error( + "WARNING: Cannot sign applications. bbidtoken.csk file cannot be found at default location: " + + getDefaultPath("bbidtoken.csk") + ); + } + } } }; diff --git a/blackberry10/bin/templates/project/cordova/lib/build.js b/blackberry10/bin/templates/project/cordova/lib/build.js index a402f2bf..0c1293ca 100755 --- a/blackberry10/bin/templates/project/cordova/lib/build.js +++ b/blackberry10/bin/templates/project/cordova/lib/build.js @@ -21,6 +21,7 @@ var path = require("path"), command = require("commander"), os = require("os"), utils = require("./utils"), + signingUtils = require("./signing-utils"), bbProperties = utils.getProperties(), bbwpArgv = [ process.argv[0], @@ -63,6 +64,8 @@ try { exit(ERROR_VALUE); } + signingUtils.warn(); + utils.series( [ function clean (done) { diff --git a/blackberry10/bin/templates/project/cordova/lib/run.js b/blackberry10/bin/templates/project/cordova/lib/run.js index de3f0208..b3966ec6 100755 --- a/blackberry10/bin/templates/project/cordova/lib/run.js +++ b/blackberry10/bin/templates/project/cordova/lib/run.js @@ -21,6 +21,7 @@ var path = require("path"), utils = require("./utils"), options = require('commander'), runUtils = require("./run-utils"), + signingUtils = require("./signing-utils"); async = require("async"); function install(deployTarget, done) { @@ -68,6 +69,8 @@ process.argv.forEach(function (argument, index, args) { options.parse(process.argv); +signingUtils.warn(); + utils.waterfall( [ runUtils.getValidatedTarget.bind(this, options), diff --git a/blackberry10/bin/templates/project/cordova/lib/signing-utils.js b/blackberry10/bin/templates/project/cordova/lib/signing-utils.js deleted file mode 100644 index ebcefca8..00000000 --- a/blackberry10/bin/templates/project/cordova/lib/signing-utils.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 fs = require('fs'), - path = require('path'), - os = require('os'), - childProcess = require('child_process'), - AUTHOR_P12 = "author.p12", - BBIDTOKEN = "bbidtoken.csk", - CSK = "barsigner.csk", - DB = "barsigner.db", - _self; - -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 - // 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\\"; - if (!fs.existsSync(p)) { - // Try Windows Vista and Windows 7 location - p = process.env.HOMEDRIVE + process.env.HOMEPATH + "\\AppData\\Local\\Research In Motion\\"; - } - } else if (os.type().toLowerCase().indexOf("darwin") >= 0) { - // Try Mac OS location - p = process.env.HOME + "/Library/Research In Motion/"; - } else if (os.type().toLowerCase().indexOf("linux") >= 0) { - // Try Linux location - p = process.env.HOME + "/.rim/"; - } - - return p + file; - -} - -function getDefaultPathIfExists(file) { - var p = getDefaultPath(file); - if (fs.existsSync(p)) { - return p; - } -} - -_self = { - getDefaultPath: getDefaultPath, - - getKeyStorePath : function () { - // Todo: decide where to put sigtool.p12 which is generated and used in WebWorks SDK for Tablet OS - return getDefaultPathIfExists(AUTHOR_P12); - }, - - getKeyStorePathBBID: function () { - return getDefaultPathIfExists(BBIDTOKEN); - }, - - getCskPath : function () { - return getDefaultPathIfExists(CSK); - }, - - getDbPath : function () { - return getDefaultPathIfExists(DB); - } -}; - -module.exports = _self;