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 2014/04/13 15:40:22 UTC
webworks commit: CB-6440 Switch to grunt as task runner
Repository: cordova-blackberry
Updated Branches:
refs/heads/master 5967290ab -> ee0904cfe
CB-6440 Switch to grunt as task runner
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/ee0904cf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/ee0904cf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/ee0904cf
Branch: refs/heads/master
Commit: ee0904cfebe7daa6ff261e7bef1689452af25ea8
Parents: 5967290
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Sun Apr 13 09:32:09 2014 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Sun Apr 13 09:32:09 2014 -0400
----------------------------------------------------------------------
blackberry10/.jshintignore | 1 +
blackberry10/Gruntfile.js | 41 ++
blackberry10/Jakefile | 156 --------
blackberry10/bin/lib/create.js | 5 +-
.../project/cordova/lib/target-utils.js | 5 +-
.../cordova/functional/debugtoken-helper.js | 377 -------------------
.../bin/test/cordova/integration/create.js | 3 +
blackberry10/package.json | 3 +-
blackberry10/scripts/test.js | 35 --
9 files changed, 52 insertions(+), 574 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/.jshintignore
----------------------------------------------------------------------
diff --git a/blackberry10/.jshintignore b/blackberry10/.jshintignore
index 5a8fb35..41c3629 100644
--- a/blackberry10/.jshintignore
+++ b/blackberry10/.jshintignore
@@ -3,3 +3,4 @@ bin/test/cordova/unit/params-bad.json
bin/templates/project/cordova/lib/xml-helpers.js
bin/templates/project/cordova/third_party/*
bin/templates/project/lib/*
+bin/templates/project/www/**/*
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/Gruntfile.js
----------------------------------------------------------------------
diff --git a/blackberry10/Gruntfile.js b/blackberry10/Gruntfile.js
new file mode 100644
index 0000000..1847910
--- /dev/null
+++ b/blackberry10/Gruntfile.js
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+module.exports = function (grunt) {
+ grunt.initConfig({
+ jshint: {
+ all: [
+ 'Gruntfile.js',
+ 'bin/**/*.js',
+ 'framework/**/*.js'
+ ]
+ },
+ jasmine_node: {
+ options: {
+ matchall: true
+ },
+ all: [
+ 'bin/test',
+ 'framework/test'
+ ]
+ }
+
+ });
+
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-jasmine-node');
+
+ grunt.registerTask('lint', ['jshint']);
+ grunt.registerTask('test', ['jasmine_node']);
+ grunt.registerTask('default', ['lint', 'test']);
+};
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/Jakefile
----------------------------------------------------------------------
diff --git a/blackberry10/Jakefile b/blackberry10/Jakefile
deleted file mode 100644
index f7b1c0a..0000000
--- a/blackberry10/Jakefile
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF
- * or more contributor license agreements. See th
- * distributed with this work for additional infor
- * regarding copyright ownership. The ASF license
- * to you under the Apache License, Version 2.0 (t
- * "License"); you may not use this file except in
- * with the License. You may obtain a copy of the
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to
- * software distributed under the License is distr
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
- * KIND, either express or implied. See the Licen
- * specific language governing permissions and lim
- * under the License.
- */
-
-var DESC_NEW_LINE = "\n\t\t #";
-
-var util = require('util'),
- fs = require('fs'),
- childProcess = require('child_process'),
- path = require("path"),
- rexp_minified = new RegExp("\\.min\\.js$"),
- rexp_src = new RegExp('\\.js$');
-
-// HELPERS
-// Iterates over a directory
-function forEachFile(root, cbFile, cbDone) {
- var count = 0;
-
- function scan(name) {
- ++count;
-
- fs.stat(name, function (err, stats) {
- if (err) cbFile(err);
-
- if (stats.isDirectory()) {
- fs.readdir(name, function (err, files) {
- if (err) cbFile(err);
-
- files.forEach(function (file) {
- scan(path.join(name, file));
- });
- done();
- });
- } else if (stats.isFile()) {
- cbFile(null, name, stats, done);
- } else {
- done();
- }
- });
- }
-
- function done() {
- --count;
- if (count === 0 && cbDone) cbDone();
- }
-
- scan(root);
-}
-
-desc("runs hint and test");
-task('default', ['hint','test'], function () {});
-
-desc("run all tests in node - jake test [path]");
-task('test', [], function () {
- require('./scripts/test')(null, process.argv.length >= 4 ? process.argv[3] : null);
-}, true);
-
-desc('check sources with JSHint');
-task('hint', ['complainwhitespace'], function () {
- var knownWarnings = [
- "Redefinition of 'FileReader'",
- "Redefinition of 'require'",
- "Read only",
- "Redefinition of 'console'"
- ];
- var filterKnownWarnings = function(el, index, array) {
- var wut = true;
- // filter out the known warnings listed out above
- knownWarnings.forEach(function(e) {
- wut = wut && (el.indexOf(e) == -1);
- });
- wut = wut && (!el.match(/\d+ errors/));
- return wut;
- };
-
- childProcess.exec("jshint framework/lib bin/lib bin/test bin/templates/project/cordova --config .jshintrc --extra-ext .json",function(err,stdout,stderr) {
- var exs = stdout.split('\n');
- console.log(exs.filter(filterKnownWarnings).join('\n'));
- if (err) {
- console.log(err);
- }
- if (exs.length > 1) {
- console.log("EXITING: " + exs.length);
- process.exit(exs.length - 1);
- }
- console.log("jshint SUCCESS");
- complete();
- });
-}, true);
-
-var complainedAboutWhitespace = false
-
-desc('complain about what fixwhitespace would fix');
-task('complainwhitespace', function() {
- processWhiteSpace(function(file, newSource) {
- if (!complainedAboutWhitespace) {
- console.log("files with whitespace issues: (to fix: `jake fixwhitespace`)")
- complainedAboutWhitespace = true
- }
-
- console.log(" " + file)
- })
-}, true);
-
-desc('converts tabs to four spaces, eliminates trailing white space, converts newlines to proper form - enforcing style guide ftw!');
-task('fixwhitespace', function() {
- processWhiteSpace(function(file, newSource) {
- if (!complainedAboutWhitespace) {
- console.log("fixed whitespace issues in:")
- complainedAboutWhitespace = true
- }
-
- fs.writeFileSync(file, newSource, 'utf8');
- console.log(" " + file)
- })
-}, true);
-
-function processWhiteSpace(processor) {
- forEachFile('framework', function(err, file, stats, cbDone) {
- //if (err) throw err;
- if (rexp_minified.test(file) || !rexp_src.test(file)) {
- cbDone();
- } else {
- var origsrc = src = fs.readFileSync(file, 'utf8');
-
- // tabs -> four spaces
- if (src.indexOf('\t') >= 0) {
- src = src.split('\t').join(' ');
- }
-
- // eliminate trailing white space
- src = src.replace(/ +\n/g, '\n');
-
- if (origsrc !== src) {
- // write it out yo
- processor(file, src);
- }
- cbDone();
- }
- }, complete);
-}
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/lib/create.js b/blackberry10/bin/lib/create.js
index 01bad98..f870f8d 100644
--- a/blackberry10/bin/lib/create.js
+++ b/blackberry10/bin/lib/create.js
@@ -24,12 +24,11 @@
* ./create path [package [id [name [template]]]]
*/
-var build,
- ERROR_VALUE = 2,
+var ERROR_VALUE = 2,
path = require("path"),
exit = require('exit'),
shell = require('shelljs'),
- fs = require("fs")
+ fs = require("fs"),
os = require("os"),
wrench = require("wrench"),
version = getVersion(),
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/bin/templates/project/cordova/lib/target-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/target-utils.js b/blackberry10/bin/templates/project/cordova/lib/target-utils.js
index ee1e2ac..b3395c1 100755
--- a/blackberry10/bin/templates/project/cordova/lib/target-utils.js
+++ b/blackberry10/bin/templates/project/cordova/lib/target-utils.js
@@ -25,7 +25,8 @@ var _self,
//fix older blackberry10.json files
//these may include 'simulator' type rather than 'emulator'
function replaceSimulator(targets) {
- var replace = false;
+ var replace = false,
+ t;
for (t in targets) {
if (targets.hasOwnProperty(t) && targets[t].type === "simulator") {
targets[t].type = "emulator";
@@ -193,7 +194,7 @@ _self = {
// Secondly, check VMware dhcp.leases file
if (bb10_utils.isWindows()) {
- pathUserProfile = process.env['USERPROFILE'];
+ pathUserProfile = process.env.USERPROFILE;
pathAllUserProfile = pathUserProfile.substr(0, pathUserProfile.lastIndexOf("\\") + 1) + "All Users";
vmDhcpLeasesFiles = bb10_utils.readdirSyncRecursive(pathAllUserProfile).filter(function (file) {
return DHCP_LEASES_REGEX.test(file);
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/bin/test/cordova/functional/debugtoken-helper.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/functional/debugtoken-helper.js b/blackberry10/bin/test/cordova/functional/debugtoken-helper.js
deleted file mode 100644
index cbf28d9..0000000
--- a/blackberry10/bin/test/cordova/functional/debugtoken-helper.js
+++ /dev/null
@@ -1,377 +0,0 @@
-/**
- 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.
-*/
-
-var childProcess = require('child_process'),
- debugTokenHelper = require("../../templates/project/cordova/lib/debugtoken-helper"),
- wrench = require('wrench'),
- fs = require('fs'),
- properties,
- flag;
-
-function testCreateDebugtoken(target) {
- debugTokenHelper.createToken(properties, target, function (code) {
- if (code === 0) {
- console.log("Debug token is created successfully!");
- } else {
- console.log("Debug token is not created successfully!");
- }
-
- flag = true;
- });
-}
-
-function testDeployDebugtoken() {
- debugTokenHelper.deployToken(properties, "", function () {
- console.log("Deploy callback is invoked!");
- flag = true;
- });
-}
-
-function testDeployDebugtokenAll() {
- debugTokenHelper.deployToken(properties, "all", function () {
- console.log("Deploy callback is invoked!");
- flag = true;
- });
-}
-
-function testDeployDebugtokenSingle() {
- debugTokenHelper.deployToken(properties, "d1", function () {
- console.log("Deploy callback is invoked!");
- flag = true;
- });
-}
-
-describe("cordova/lib/debugtoken-helper tests", function () {
- beforeEach(function () {
- flag = false;
- });
-
- it("should create a debugtoken for target all", function () {
- testCreateDebugtoken("all");
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- expect(fs.existsSync("debugtoken.bar"));
- });
- });
-
- it("should create a debugtoken for single target", function () {
- testCreateDebugtoken("d1");
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- expect(fs.existsSync("debugtoken.bar"));
- });
- });
-
- it("should create a debugtoken for default target", function () {
- testCreateDebugtoken("");
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- expect(fs.existsSync("debugtoken.bar"));
- });
- });
-
- it("cannot create a debugtoken without keystorepass", function () {
- testCreateDebugtoken("all");
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- //"keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- expect(!fs.existsSync("debugtoken.bar"));
- });
- });
-
- it("cannot create a debugtoken without any device PINs", function () {
- testCreateDebugtoken("all");
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- //"pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- expect(!fs.existsSync("debugtoken.bar"));
- });
- });
-
- it("should deploy a debugtoken to default target", function () {
- debugTokenHelper.createToken(properties, "", testDeployDebugtoken);
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
-
- window.alert("Make sure you connect the device " + "2A54F454" + " to " + "169.254.0.1");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- var confirm = window.confirm("Was the debug token deployed to device?");
- expect(confirm).toEqual(true);
- });
- });
-
- it("should deploy a debugtoken to all targets", function () {
- debugTokenHelper.createToken(properties, "all", testDeployDebugtokenAll);
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
-
- window.alert("Make sure you connect the device " + "2A54F454" + " to " + "169.254.0.1");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- var confirm = window.confirm("Was the debug token deployed to device?");
- expect(confirm).toEqual(true);
- });
- });
-
- it("should deploy a debugtoken to a single target", function () {
- debugTokenHelper.createToken(properties, "d1", testDeployDebugtokenSingle);
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
-
- window.alert("Make sure you connect the device " + "2A54F454" + " to " + "169.254.0.1");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- var confirm = window.confirm("Was the debug token deployed to device?");
- expect(confirm).toEqual(true);
- });
- });
-
- it("cannot deploy a debugtoken when the target is not connected", function () {
- debugTokenHelper.createToken(properties, "all", testDeployDebugtoken);
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
-
- window.alert("Disconnect the target from 169.254.0.1");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- var confirm = window.confirm("Was the debug token deployed to device?");
- expect(confirm).toEqual(false);
- });
- });
-
- it("cannot deploy a debugtoken if no debugtoken", function () {
- testDeployDebugtoken();
-
- beforeEach(function () {
- properties = {
- "barName": "cordova-BB10-app",
- "keystorepass": "qaqa1234",
- "defaultTarget": "d1",
- "targets": {
- "d1": {
- "ip": "169.254.0.1",
- "type": "device",
- "pin": "2A54F454",
- "password" : "qaqa123"
- }
- }
- };
-
- fs.unlinkSync("debugtoken.bar");
- });
-
- waitsFor(function () {
- return flag;
- });
-
- runs(function () {
- var confirm = window.confirm("Was the debug token deployed to device?");
- expect(confirm).toEqual(false);
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/bin/test/cordova/integration/create.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/create.js b/blackberry10/bin/test/cordova/integration/create.js
index 84f0805..b308f0e 100644
--- a/blackberry10/bin/test/cordova/integration/create.js
+++ b/blackberry10/bin/test/cordova/integration/create.js
@@ -42,6 +42,9 @@ function executeScript(shellCommand, args, shouldError) {
describe("create tests", function () {
it("creates project", function () {
var appIdRegExp = /id="default\.app\.id"/g;
+ if (fs.existsSync(tempFolder)) {
+ wrench.rmdirSyncRecursive(tempFolder);
+ }
executeScript(CREATE_COMMAND, [appFolder]);
expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
expect(fs.existsSync(appFolder)).toEqual(true);
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/package.json
----------------------------------------------------------------------
diff --git a/blackberry10/package.json b/blackberry10/package.json
index 1ce1de7..b1e5a5c 100644
--- a/blackberry10/package.json
+++ b/blackberry10/package.json
@@ -32,7 +32,8 @@
"async": "0.2.9"
},
"devDependencies": {
- "jake":"*",
+ "grunt-contrib-jshint": "*",
+ "grunt-jasmine-node": "*",
"jasmine-node": "1.7.1"
},
"readmeFilename": "README.md"
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ee0904cf/blackberry10/scripts/test.js
----------------------------------------------------------------------
diff --git a/blackberry10/scripts/test.js b/blackberry10/scripts/test.js
deleted file mode 100644
index 5f44c5b..0000000
--- a/blackberry10/scripts/test.js
+++ /dev/null
@@ -1,35 +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.
- */
-
-module.exports = function (done, custom) {
- var jasmine = require('jasmine-node'),
- fs = require('fs'),
- specs = (custom !== null && fs.existsSync(custom)) ? [custom] :
- [
- "framework/test",
- "bin/test/cordova/integration",
- "bin/test/cordova/unit"
- ];
- jasmine.executeSpecsInFolder({
- 'specFolders': specs,
- 'onComplete': function (runner) {
- var failedCount = runner.results().failedCount;
- ((done && typeof done === "function") ? done : process.exit)(failedCount);
- },
- 'isVerbose': false,
- 'showColors': true
- });
-};