You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2015/02/09 10:22:16 UTC
[2/2] cordova-windows git commit: CB-8400 fix all jshint issues for
Windows platform
CB-8400 fix all jshint issues for Windows platform
Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/232968c0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/232968c0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/232968c0
Branch: refs/heads/master
Commit: 232968c062cf73ae7482f13cc3b6584d72933498
Parents: 8e7ad53
Author: Murat Sutunc <mu...@microsoft.com>
Authored: Mon Feb 2 14:55:58 2015 -0800
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Mon Feb 9 12:18:33 2015 +0300
----------------------------------------------------------------------
bin/lib/check_reqs.js | 4 +-
bin/lib/create.js | 52 +++++++++++------------
bin/lib/update.js | 14 +++----
spec/e2e/endtoend.spec.js | 12 +++---
spec/unit/MSBuildTools.spec.js | 6 +--
spec/unit/build.spec.js | 8 +---
spec/unit/package.spec.js | 3 +-
spec/unit/run.spec.js | 8 ++--
template/cordova/lib/ConfigParser.js | 2 +-
template/cordova/lib/MSBuildTools.js | 8 ++--
template/cordova/lib/build.js | 52 +++++++++++------------
template/cordova/lib/package.js | 18 ++++----
template/cordova/lib/prepare.js | 59 +++++++++++++++------------
template/cordova/lib/run.js | 68 +++++++++++++++----------------
template/cordova/lib/target-list.js | 24 +++++------
template/cordova/lib/utils.js | 10 +++--
16 files changed, 177 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index 0ce0f1f..bdd27f2 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -24,12 +24,12 @@ var Q = require('Q'),
module.exports.run = function () {
if (os.platform() != 'win32'){
// Build Universal windows apps available for windows platform only, so we reject on others platforms
- return Q.reject("ERROR: Cordova tooling for Windows requires Windows OS");
+ return Q.reject('ERROR: Cordova tooling for Windows requires Windows OS');
}
// Check whther MSBuild Tools are available
return MSBuildTools.findAvailableVersion();
};
module.exports.help = function () {
- console.log("Usage: check_reqs or node check_reqs");
+ console.log('Usage: check_reqs or node check_reqs');
};
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 49733c1..e88f72c 100644
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -17,6 +17,8 @@
under the License.
*/
+/* jshint sub:true */
+
var Q = require('Q'),
fs = require('fs'),
path = require('path'),
@@ -28,19 +30,19 @@ var Q = require('Q'),
module.exports.run = function (argv) {
// Parse args
- var args = nopt({"guid": String}, {}, argv);
+ var args = nopt({'guid': String}, {}, argv);
if(!args.argv.remain.length) {
- return Q.reject("No path specified.");
+ return Q.reject('No path specified.');
}
// Set parameters/defaults for create
var projectPath = args.argv.remain[0];
if (fs.existsSync(projectPath)){
- return Q.reject("Project directory already exists:\n\t" + projectPath);
+ return Q.reject('Project directory already exists:\n\t' + projectPath);
}
- var packageName = args.argv.remain[1] || "Cordova.Example",
- appName = args.argv.remain[2] || "CordovaAppProj",
+ var packageName = args.argv.remain[1] || 'Cordova.Example',
+ appName = args.argv.remain[2] || 'CordovaAppProj',
// 64 symbols restriction goes from manifest schema definition
// http://msdn.microsoft.com/en-us/library/windows/apps/br211415.aspx
safeAppName = appName.length <= 64 ? appName : appName.substr(0, 64),
@@ -48,31 +50,31 @@ module.exports.run = function (argv) {
guid = args['guid'] || uuid.v1(),
root = path.join(__dirname, '..', '..');
- console.log("Creating Cordova Windows Project:");
- console.log("\tApp Name : " + appName);
- console.log("\tNamespace : " + packageName);
- console.log("\tPath : " + projectPath);
+ console.log('Creating Cordova Windows Project:');
+ console.log('\tApp Name : ' + appName);
+ console.log('\tNamespace : ' + packageName);
+ console.log('\tPath : ' + projectPath);
if (templateOverrides) {
- Log("\tCustomTemplatePath : " + templateOverrides);
+ console.log('\tCustomTemplatePath : ' + templateOverrides);
}
// Copy the template source files to the new destination
console.log('Copying template to ' + projectPath);
- shell.cp("-rf", path.join(root, 'template', '*'), projectPath);
+ shell.cp('-rf', path.join(root, 'template', '*'), projectPath);
// Copy our unique VERSION file, so peeps can tell what version this project was created from.
- shell.cp("-rf", path.join(root, 'VERSION'), projectPath);
+ shell.cp('-rf', path.join(root, 'VERSION'), projectPath);
// copy node_modules to cordova directory
shell.cp('-r', path.join(root, 'node_modules'), path.join(projectPath, 'cordova'));
if (templateOverrides && fs.existsSync(templateOverrides)) {
console.log('Copying template overrides from ' + templateOverrides + ' to ' + projectPath);
- shell.cp("-rf", templateOverrides, projectPath);
+ shell.cp('-rf', templateOverrides, projectPath);
}
// replace specific values in manifests' templates
- ["package.windows.appxmanifest", "package.windows80.appxmanifest", "package.phone.appxmanifest"].forEach(function (file) {
+ ['package.windows.appxmanifest', 'package.windows80.appxmanifest', 'package.phone.appxmanifest'].forEach(function (file) {
var fileToReplace = path.join(projectPath, file);
shell.sed('-i', /\$guid1\$/g, guid, fileToReplace);
shell.sed('-i', /\$safeprojectname\$/g, packageName, fileToReplace);
@@ -80,7 +82,7 @@ module.exports.run = function (argv) {
});
// Delete bld forder and bin folder
- ["bld", "bin", "*.user", "*.suo", "MyTemplate.vstemplate"].forEach(function (file) {
+ ['bld', 'bin', '*.user', '*.suo', 'MyTemplate.vstemplate'].forEach(function (file) {
shell.rm('-rf', path.join(projectPath, file));
});
@@ -93,14 +95,14 @@ module.exports.run = function (argv) {
};
module.exports.help = function () {
- console.log("Usage: create PathToProject [ PackageName [ AppName [ CustomTemplate ] ] ] [--guid=<GUID string>]");
- console.log(" PathToProject : The path to where you wish to create the project");
- console.log(" PackageName : The namespace for the project (default is Cordova.Example)");
- console.log(" AppName : The name of the application (default is CordovaAppProj)");
- console.log(" CustomTemplate: The path to project template overrides");
- console.log(" (will be copied over default platform template files)");
- console.log(" --guid : The App's GUID (default is random generated)");
- console.log("examples:");
- console.log(" create C:\\Users\\anonymous\\Desktop\\MyProject");
- console.log(" create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp");
+ console.log('Usage: create PathToProject [ PackageName [ AppName [ CustomTemplate ] ] ] [--guid=<GUID string>]');
+ console.log(' PathToProject : The path to where you wish to create the project');
+ console.log(' PackageName : The namespace for the project (default is Cordova.Example)');
+ console.log(' AppName : The name of the application (default is CordovaAppProj)');
+ console.log(' CustomTemplate: The path to project template overrides');
+ console.log(' (will be copied over default platform template files)');
+ console.log(' --guid : The App\'s GUID (default is random generated)');
+ console.log('examples:');
+ console.log(' create C:\\Users\\anonymous\\Desktop\\MyProject');
+ console.log(' create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp');
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/bin/lib/update.js
----------------------------------------------------------------------
diff --git a/bin/lib/update.js b/bin/lib/update.js
index cb1a26a..3f5a78c 100644
--- a/bin/lib/update.js
+++ b/bin/lib/update.js
@@ -43,11 +43,11 @@ function extractMetadata(projectPath) {
}
module.exports.help = function () {
- console.log("WARNING : Make sure to back up your project before updating!");
- console.log("Usage: update PathToProject ");
- console.log(" PathToProject : The path the project you would like to update.");
- console.log("examples:");
- console.log(" update C:\\Users\\anonymous\\Desktop\\MyProject");
+ console.log('WARNING : Make sure to back up your project before updating!');
+ console.log('Usage: update PathToProject ');
+ console.log(' PathToProject : The path the project you would like to update.');
+ console.log('examples:');
+ console.log(' update C:\\Users\\anonymous\\Desktop\\MyProject');
};
// updates the cordova.js in project along with the cordova tooling.
@@ -55,8 +55,8 @@ module.exports.run = function (argv) {
var projectPath = argv[2];
if (!fs.existsSync(projectPath)){
// if specified project path is not valid then reject promise
- Q.reject("The given path to the project does not exist." +
- " Please provide a path to the project you would like to update.");
+ Q.reject('The given path to the project does not exist.' +
+ ' Please provide a path to the project you would like to update.');
}
return extractMetadata(projectPath).then(function (metadata) {
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/spec/e2e/endtoend.spec.js
----------------------------------------------------------------------
diff --git a/spec/e2e/endtoend.spec.js b/spec/e2e/endtoend.spec.js
index d24f0b9..3732693 100644
--- a/spec/e2e/endtoend.spec.js
+++ b/spec/e2e/endtoend.spec.js
@@ -20,9 +20,9 @@ var shell = require('shelljs'),
fs = require('fs'),
path = require('path');
-describe("Cordova create and build", function(){
+describe('Cordova create and build', function(){
- var projectFolder = "testcreate 応用",
+ var projectFolder = 'testcreate 応用',
buildDirectory = path.join(__dirname, '../..'),
appPackagesFolder = path.join(buildDirectory, projectFolder, 'AppPackages'),
buildScriptPath = '"' + path.join(buildDirectory, projectFolder, 'cordova', 'build') + '"';
@@ -36,25 +36,25 @@ describe("Cordova create and build", function(){
shell.rm('-rf', projectFolder);
});
- it("spec.1 should create new project", function(){
+ it('spec.1 should create new project', function(){
expect(fs.existsSync(projectFolder)).toBe(true);
});
- it("spec.2 should build project", function(){
+ it('spec.2 should build project', function(){
shell.exec(buildScriptPath, {silent:true});
var packages = shell.ls(appPackagesFolder);
expect(packages.filter(function(file) { return file.match(/.*Phone.*\.appx.*/); }).length).toBe(1);
expect(packages.filter(function(file) { return file.match(/.*Windows.*\.appx.*/); }).length).toBe(1);
});
- it("spec.3 should build project for particular CPU", function(){
+ it('spec.3 should build project for particular CPU', function(){
shell.exec(buildScriptPath + ' --archs=\"x64\"', {silent : true});
var packages = shell.ls(appPackagesFolder);
expect(packages.filter(function(file) { return file.match(/.*Phone.*x64.*\.appx.*/); }).length).toBe(1);
expect(packages.filter(function(file) { return file.match(/.*Windows.*x64.*\.appx.*/); }).length).toBe(1);
});
- it("spec.4 should build project for CPUs separated by whitespaces", function(){
+ it('spec.4 should build project for CPUs separated by whitespaces', function(){
shell.exec(buildScriptPath + ' --archs=\"x64 x86 arm anycpu\"', {silent : true});
var packages = shell.ls(appPackagesFolder);
expect(packages.filter(function(file) { return file.match(/.*Phone.*x86.*\.appx.*/); }).length).toBe(1);
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/spec/unit/MSBuildTools.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/MSBuildTools.spec.js b/spec/unit/MSBuildTools.spec.js
index e36718a..30a97d3 100644
--- a/spec/unit/MSBuildTools.spec.js
+++ b/spec/unit/MSBuildTools.spec.js
@@ -22,7 +22,7 @@ var Q = require('q'),
buildTools = rewire(platformRoot + '/cordova/lib/MSBuildTools.js');
var fakeToolsPath = function (version) {
- return "C:\\Program Files (x86)\\MSBuild\\" + version;
+ return 'C:\\Program Files (x86)\\MSBuild\\' + version;
};
describe('findAvailableVersion method', function(){
@@ -45,7 +45,7 @@ describe('findAvailableVersion method', function(){
done();
}
});
- }
+ };
beforeEach(function () {
checkMSBuildVersionOriginal = buildTools.__get__('checkMSBuildVersion');
@@ -102,7 +102,7 @@ describe('checkMSBuildVersion method', function(){
var version = '14.0';
buildTools.__set__('exec', function(cmd) {
- return Q.resolve("\r\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\12.0\r\n\tMSBuildToolsPath\tREG_SZ\t" + fakeToolsPath(version) + "\r\n\r\n");
+ return Q.resolve('\r\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\12.0\r\n\tMSBuildToolsPath\tREG_SZ\t' + fakeToolsPath(version) + '\r\n\r\n');
});
checkMSBuildVersion(version).then(function (actual) {
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/spec/unit/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/build.spec.js b/spec/unit/build.spec.js
index 1b16afb..37f5d94 100644
--- a/spec/unit/build.spec.js
+++ b/spec/unit/build.spec.js
@@ -63,11 +63,11 @@ describe('run method', function() {
var isCordovaProjectFalse = function () {
return false;
- }
+ };
var isCordovaProjectTrue = function () {
return true;
- }
+ };
beforeEach(function () {
// console output suppression
@@ -201,20 +201,16 @@ describe('run method', function() {
case 'arm':
armBuild();
return Q();
- break;
case 'x86':
x86Build();
return Q();
- break;
case 'anycpu':
case 'any cpu':
anyCpuBuild();
return Q();
- break;
case 'x64':
x64Build();
return Q();
- break;
default:
return Q.reject();
}
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/spec/unit/package.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/package.spec.js b/spec/unit/package.spec.js
index 64c7f65..89478b5 100644
--- a/spec/unit/package.spec.js
+++ b/spec/unit/package.spec.js
@@ -16,8 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
-var Q = require('q'),
- path = require('path'),
+var path = require('path'),
rewire = require('rewire'),
shell = require('shelljs'),
platformRoot = '../../template',
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/spec/unit/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/run.spec.js b/spec/unit/run.spec.js
index e4e8bdc..94978a3 100644
--- a/spec/unit/run.spec.js
+++ b/spec/unit/run.spec.js
@@ -33,11 +33,11 @@ describe('run method', function() {
var isCordovaProjectFalse = function () {
return false;
- }
+ };
var isCordovaProjectTrue = function () {
return true;
- }
+ };
beforeEach(function () {
// console output suppression
@@ -126,7 +126,7 @@ describe('run method', function() {
it('spec.5 should build and deploy on phone if --phone arg specified', function(done) {
var build = jasmine.createSpy(),
- deployToPhone = jasmine.createSpy()
+ deployToPhone = jasmine.createSpy(),
deployToDesktop = jasmine.createSpy();
run.__set__('utils.isCordovaProject', isCordovaProjectTrue);
@@ -160,7 +160,7 @@ describe('run method', function() {
it('spec.6 should build and deploy on desktop if --phone arg is not specified', function(done) {
var build = jasmine.createSpy(),
- deployToPhone = jasmine.createSpy()
+ deployToPhone = jasmine.createSpy(),
deployToDesktop = jasmine.createSpy();
run.__set__('utils.isCordovaProject', isCordovaProjectTrue);
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/template/cordova/lib/ConfigParser.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/ConfigParser.js b/template/cordova/lib/ConfigParser.js
index a08ccd6..8ed33ed 100644
--- a/template/cordova/lib/ConfigParser.js
+++ b/template/cordova/lib/ConfigParser.js
@@ -42,7 +42,7 @@ function ConfigParser(path) {
}
var r = this.doc.getroot();
if (r.tag !== 'widget') {
- throw new CordovaError(path + ' has incorrect root node name (expected "widget", was "' + r.tag + '")');
+ throw new Error(path + ' has incorrect root node name (expected "widget", was "' + r.tag + '")');
}
}
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/template/cordova/lib/MSBuildTools.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/MSBuildTools.js b/template/cordova/lib/MSBuildTools.js
index 08785bd..58d09a1 100644
--- a/template/cordova/lib/MSBuildTools.js
+++ b/template/cordova/lib/MSBuildTools.js
@@ -9,9 +9,9 @@ function MSBuildTools (version, path) {
}
MSBuildTools.prototype.buildProject = function(projFile, buildType, buildarch) {
- console.log("Building project: " + projFile);
- console.log("\tConfiguration : " + buildType);
- console.log("\tPlatform : " + buildarch);
+ console.log('Building project: ' + projFile);
+ console.log('\tConfiguration : ' + buildType);
+ console.log('\tPlatform : ' + buildarch);
var args = ['/clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal', '/nologo',
'/p:Configuration=' + buildType,
@@ -19,7 +19,7 @@ MSBuildTools.prototype.buildProject = function(projFile, buildType, buildarch) {
'/p:BuildFromCordovaTooling=' + true];
return spawn(path.join(this.path, 'msbuild'), [projFile].concat(args));
-}
+};
// returns full path to msbuild tools required to build the project and tools version
module.exports.findAvailableVersion = function () {
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/template/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/build.js b/template/cordova/lib/build.js
index 20fde7d..d5c45cf 100644
--- a/template/cordova/lib/build.js
+++ b/template/cordova/lib/build.js
@@ -68,21 +68,21 @@ module.exports.run = function run (argv) {
// help/usage function
module.exports.help = function help() {
- console.log("");
- console.log("Usage: build [ --debug | --release ] [--archs=\"<list of architectures...>\"] [--phone | --win]");
- console.log(" --help : Displays this dialog.");
- console.log(" --debug : Builds project in debug mode. (Default)");
- console.log(" --release : Builds project in release mode.");
- console.log(" -r : Shortcut :: builds project in release mode.");
- console.log(" --archs : Builds project binaries for specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).");
- console.log(" --phone, --win");
- console.log(" : Specifies, what type of project to build");
- console.log("examples:");
- console.log(" build ");
- console.log(" build --debug");
- console.log(" build --release");
- console.log(" build --release --archs=\"arm x86\"");
- console.log("");
+ console.log('');
+ console.log('Usage: build [ --debug | --release ] [--archs=\"<list of architectures...>\"] [--phone | --win]');
+ console.log(' --help : Displays this dialog.');
+ console.log(' --debug : Builds project in debug mode. (Default)');
+ console.log(' --release : Builds project in release mode.');
+ console.log(' -r : Shortcut :: builds project in release mode.');
+ console.log(' --archs : Builds project binaries for specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).');
+ console.log(' --phone, --win');
+ console.log(' : Specifies, what type of project to build');
+ console.log('examples:');
+ console.log(' build ');
+ console.log(' build --debug');
+ console.log(' build --release');
+ console.log(' build --release --archs="arm x86"');
+ console.log('');
process.exit(0);
};
@@ -106,15 +106,15 @@ function parseAndValidateArgs(argv) {
function buildTargets() {
// filter targets to make sure they are supported on this development machine
- var buildTargets = filterSupportedTargets(getBuildTargets(), msbuild);
+ var myBuildTargets = filterSupportedTargets(getBuildTargets(), msbuild);
var buildConfigs = [];
// collect all build configurations (pairs of project to build and target architecture)
- buildTargets.forEach(function(buildTarget) {
+ myBuildTargets.forEach(function(buildTarget) {
buildArchs.forEach(function(buildArch) {
buildConfigs.push({target:buildTarget, arch: buildArch});
- })
+ });
});
// run builds serially
@@ -139,7 +139,7 @@ function getBuildTargets() {
var noSwitches = !(args.phone || args.win);
// Windows
if (args.win || noSwitches) { // if --win or no arg
- var windowsTargetVersion = config.getPreference('windows-target-version')
+ var windowsTargetVersion = config.getPreference('windows-target-version');
switch(windowsTargetVersion) {
case '8':
case '8.0':
@@ -149,26 +149,26 @@ function getBuildTargets() {
targets.push(projFiles.win);
break;
default:
- throw new Error('Unsupported windows-target-version value: ' + windowsTargetVersion)
+ throw new Error('Unsupported windows-target-version value: ' + windowsTargetVersion);
}
}
// Windows Phone
if (args.phone || noSwitches) { // if --phone or no arg
- var windowsPhoneTargetVersion = config.getPreference('windows-phone-target-version')
+ var windowsPhoneTargetVersion = config.getPreference('windows-phone-target-version');
switch(windowsPhoneTargetVersion) {
case '8.1':
targets.push(projFiles.phone);
break;
default:
- throw new Error('Unsupported windows-phone-target-version value: ' + windowsPhoneTargetVersion)
+ throw new Error('Unsupported windows-phone-target-version value: ' + windowsPhoneTargetVersion);
}
}
return targets;
}
function filterSupportedTargets (targets) {
- if (!targets || targets.length == 0) {
- console.warn("\r\nNo build targets are specified.");
+ if (!targets || targets.length === 0) {
+ console.warn('\r\nNo build targets are specified.');
return [];
}
@@ -183,8 +183,8 @@ function filterSupportedTargets (targets) {
// unsupported targets have been detected
if (supportedTargets.length != targets.length) {
- console.warn("\r\nWarning. Windows 8.1 and Windows Phone 8.1 target platforms are not supported on this development machine and will be skipped.");
- console.warn("Please install OS Windows 8.1 and Visual Studio 2013 Update2 in order to build for Windows 8.1 and Windows Phone 8.1.\r\n");
+ console.warn('\r\nWarning. Windows 8.1 and Windows Phone 8.1 target platforms are not supported on this development machine and will be skipped.');
+ console.warn('Please install OS Windows 8.1 and Visual Studio 2013 Update2 in order to build for Windows 8.1 and Windows Phone 8.1.\r\n');
}
return supportedTargets;
}
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/template/cordova/lib/package.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/package.js b/template/cordova/lib/package.js
index ca4467e..92ed76c 100644
--- a/template/cordova/lib/package.js
+++ b/template/cordova/lib/package.js
@@ -71,8 +71,8 @@ module.exports.getPackageFileInfo = function (packageFile) {
if (props) {
return {type : props[1].toLowerCase(),
arch : props[3].toLowerCase(),
- buildtype : props[4] ? props[4].toLowerCase() : "release",
- file : props[1].toLowerCase() != "phone" ?
+ buildtype : props[4] ? props[4].toLowerCase() : 'release',
+ file : props[1].toLowerCase() != 'phone' ?
path.join(packageFile, '..', 'Add-AppDevPackage.ps1') :
packageFile
};
@@ -136,8 +136,8 @@ module.exports.listDevices = function () {
// deploys specified phone package to device/emulator
module.exports.deployToPhone = function (appxPath, deployTarget) {
- var getTarget = deployTarget == "device" ? Q("de") :
- deployTarget == "emulator" ? Q("xd") : module.exports.findDevice(deployTarget);
+ var getTarget = deployTarget == 'device' ? Q('de') :
+ deployTarget == 'emulator' ? Q('xd') : module.exports.findDevice(deployTarget);
// /installlaunch option sometimes fails with 'Error: The parameter is incorrect.'
// so we use separate steps to /install and then /launch
@@ -157,20 +157,20 @@ module.exports.deployToPhone = function (appxPath, deployTarget) {
// deploys specified package to desktop
module.exports.deployToDesktop = function (appxScript, deployTarget) {
- if (deployTarget != "device" && deployTarget != "emulator") {
- return Q.reject("Deploying desktop apps to specific target not supported");
+ if (deployTarget != 'device' && deployTarget != 'emulator') {
+ return Q.reject('Deploying desktop apps to specific target not supported');
}
return utils.getAppStoreUtils().then(function(appStoreUtils) {
return module.exports.getPackageName(path.join(__dirname, '..', '..')).then(function(pkgname) {
// uninstalls previous application instance (if exists)
- console.log("Attempt to uninstall previous application version...");
+ console.log('Attempt to uninstall previous application version...');
return spawn('powershell', ['-ExecutionPolicy', 'RemoteSigned', 'Import-Module "' + appStoreUtils + '"; Uninstall-App ' + pkgname])
.then(function() {
- console.log("Attempt to install application...");
+ console.log('Attempt to install application...');
return spawn('powershell', ['-ExecutionPolicy', 'RemoteSigned', 'Import-Module "' + appStoreUtils + '"; Install-App', utils.quote(appxScript)]);
}).then(function() {
- console.log("Starting application...");
+ console.log('Starting application...');
return spawn('powershell', ['-ExecutionPolicy', 'RemoteSigned', 'Import-Module "' + appStoreUtils + '"; Start-Locally', pkgname]);
});
});
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/template/cordova/lib/prepare.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/prepare.js b/template/cordova/lib/prepare.js
index 5e3f533..b7c71ae 100644
--- a/template/cordova/lib/prepare.js
+++ b/template/cordova/lib/prepare.js
@@ -32,7 +32,7 @@ module.exports.applyPlatformConfig = function () {
var config = new ConfigParser(path.join(ROOT, 'config.xml'));
accessRules = config.getAccessRules().filter(function(rule) {
- if (rule.indexOf('https://') == 0 || rule == '*') {
+ if (rule.indexOf('https://') === 0 || rule == '*') {
return true;
} else {
console.log('Access rules must begin with "https://", the following rule will be ignored: ' + rule);
@@ -43,10 +43,10 @@ module.exports.applyPlatformConfig = function () {
['package.windows.appxmanifest', 'package.windows80.appxmanifest', 'package.phone.appxmanifest'].forEach(
function(manifestFile) {
updateManifestFile(config, path.join(ROOT, manifestFile));
- })
+ });
copyImages(config);
-}
+};
function updateManifestFile (config, manifestPath) {
@@ -54,11 +54,11 @@ function updateManifestFile (config, manifestPath) {
if(contents) {
//Windows is the BOM. Skip the Byte Order Mark.
contents = contents.substring(contents.indexOf('<'));
- };
+ }
var manifest = new et.ElementTree(et.XML(contents));
- applyCoreProperties(config, manifest);
+ applyCoreProperties(config, manifest, manifestPath);
// sort Capability elements as per CB-5350 Windows8 build fails due to invalid 'Capabilities' definition
sortCapabilities(manifest);
applyAccessRules(config, manifest);
@@ -68,7 +68,7 @@ function updateManifestFile (config, manifestPath) {
fs.writeFileSync(manifestPath, manifest.write({indent: 4}), 'utf-8');
}
-function applyCoreProperties(config, manifest) {
+function applyCoreProperties(config, manifest, manifestPath) {
var version = fixConfigVersion(config.version());
var name = config.name();
var pkgName = config.packageName();
@@ -78,7 +78,7 @@ function applyCoreProperties(config, manifest) {
if (!startPage) {
// If not specified, set default value
// http://cordova.apache.org/docs/en/edge/config_ref_index.md.html#The%20config.xml%20File
- startPage = "index.html";
+ startPage = 'index.html';
}
var identityNode = manifest.find('.//Identity');
@@ -86,8 +86,12 @@ function applyCoreProperties(config, manifest) {
throw new Error('Invalid manifest file (no <Identity> node): ' + manifestPath);
}
// Update identity name and version
- pkgName && (identityNode.attrib.Name = pkgName);
- version && (identityNode.attrib.Version = version);
+ if (pkgName) {
+ (identityNode.attrib.Name = pkgName);
+ }
+ if (version) {
+ (identityNode.attrib.Version = version);
+ }
// Update name (windows8 has it in the Application[@Id] and Application.VisualElements[@DisplayName])
var app = manifest.find('.//Application');
@@ -102,14 +106,16 @@ function applyCoreProperties(config, manifest) {
}
app.attrib.StartPage = 'www/' + startPage;
- var visualElems = manifest.find('.//VisualElements') // windows 8.0
- || manifest.find('.//m2:VisualElements') // windows 8.1
- || manifest.find('.//m3:VisualElements'); // windows phone 8.1
+ var visualElems = manifest.find('.//VisualElements') || // windows 8.0
+ manifest.find('.//m2:VisualElements') || // windows 8.1
+ manifest.find('.//m3:VisualElements'); // windows phone 8.1
if(!visualElems) {
throw new Error('Invalid manifest file (no <VisualElements> node): ' + manifestPath);
}
- name && (visualElems.attrib.DisplayName = name);
+ if (name) {
+ (visualElems.attrib.DisplayName = name);
+ }
// Update properties
var properties = manifest.find('.//Properties');
@@ -145,11 +151,11 @@ function applyAccessRules (config, manifest) {
var appUriRulesRoot = manifest.find('.//Application'),
appUriRules = appUriRulesRoot.find('.//ApplicationContentUriRules');
- if (appUriRules != null) {
+ if (appUriRules !== null) {
appUriRulesRoot.remove(null, appUriRules);
}
// rules are not defined or allow any
- if (accessRules.length == 0 || accessRules.indexOf('*') > -1) {
+ if (accessRules.length === 0 || accessRules.indexOf('*') > -1) {
return;
}
@@ -157,7 +163,7 @@ function applyAccessRules (config, manifest) {
appUriRulesRoot.append(appUriRules);
accessRules.forEach(function(rule) {
- var el = et.Element('Rule')
+ var el = et.Element('Rule');
el.attrib.Match = rule;
el.attrib.Type = 'include';
appUriRules.append(el);
@@ -194,7 +200,7 @@ function copyImages(config) {
var appRoot = path.join(platformRoot, '..', '..');
function copyImage(src, dest) {
- src = path.join(appRoot, src),
+ src = path.join(appRoot, src);
dest = path.join(platformRoot, 'images', dest);
//console.log('Copying image from ' + src + ' to ' + dest);
shell.cp('-f', src, dest);
@@ -213,14 +219,14 @@ function copyImages(config) {
return e.match('^'+srcFileName + '(.scale-[0-9]+)?' + srcExt);
});
// warn if no images found
- if (images.length == 0) {
+ if (images.length === 0) {
console.log('No images found for target: ' + destFileName);
return;
}
// copy images with new name but keeping scale suffix
images.forEach(function(img) {
var scale = path.extname(path.basename(img, srcExt));
- if (scale == '') {
+ if (scale === '') {
scale = '.scale-100';
}
copyImage(path.join(srcDir, img), destFileName+scale+destExt);
@@ -282,12 +288,13 @@ function copyImages(config) {
}
function applyBackgroundColor (config, manifest) {
+ var visualElems =null;
function refineColor(color) {
// return three-byte hexadecimal number preceded by "#" (required for Windows)
color = color.replace('0x', '').replace('#', '');
if (color.length == 3) {
- color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2]
+ color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2];
}
// alpha is not supported, so we remove it
if (color.length == 8) { // AArrggbb
@@ -298,18 +305,18 @@ function applyBackgroundColor (config, manifest) {
// background color
var bgColor = config.getPreference('BackgroundColor');
if (bgColor) {
- var visualElems = manifest.find('.//VisualElements') // windows 8.0
- || manifest.find('.//m2:VisualElements') // windows 8.1
- || manifest.find('.//m3:VisualElements'); // windows phone 8.1
+ visualElems = manifest.find('.//VisualElements') || // windows 8.0
+ manifest.find('.//m2:VisualElements') || // windows 8.1
+ manifest.find('.//m3:VisualElements'); // windows phone 8.1
visualElems.attrib.BackgroundColor = refineColor(bgColor);
}
// Splash Screen background color
bgColor = config.getPreference('SplashScreenBackgroundColor');
if (bgColor) {
- var visualElems = manifest.find('.//SplashScreen') // windows 8.0
- || manifest.find('.//m2:SplashScreen') // windows 8.1
- || manifest.find('.//m3:SplashScreen'); // windows phone 8.1
+ visualElems = manifest.find('.//SplashScreen') || // windows 8.0
+ manifest.find('.//m2:SplashScreen') || // windows 8.1
+ manifest.find('.//m3:SplashScreen'); // windows phone 8.1
visualElems.attrib.BackgroundColor = refineColor(bgColor);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/template/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/run.js b/template/cordova/lib/run.js
index 1bd1904..3195793 100644
--- a/template/cordova/lib/run.js
+++ b/template/cordova/lib/run.js
@@ -29,13 +29,13 @@ var ROOT = path.join(__dirname, '..', '..');
module.exports.run = function (argv) {
if (!utils.isCordovaProject(ROOT)){
- return Q.reject("Could not find project at " + ROOT);
+ return Q.reject('Could not find project at ' + ROOT);
}
// parse args
- var args = nopt({"debug": Boolean, "release": Boolean, "nobuild": Boolean,
- "device": Boolean, "emulator": Boolean, "target": String, "archs": String,
- "phone": Boolean, "win": Boolean}, {"r" : "--release"}, argv);
+ var args = nopt({'debug': Boolean, 'release': Boolean, 'nobuild': Boolean,
+ 'device': Boolean, 'emulator': Boolean, 'target': String, 'archs': String,
+ 'phone': Boolean, 'win': Boolean}, {'r' : '--release'}, argv);
// Validate args
if (args.debug && args.release) {
@@ -49,14 +49,14 @@ module.exports.run = function (argv) {
}
// Get build/deploy options
- var buildType = args.release ? "release" : "debug",
- buildArchs = args.archs ? args.archs.split(' ') : ["anycpu"],
- projectType = args.phone ? "phone" : "windows",
- deployTarget = args.target ? args.target : args.device ? "device" : "emulator";
+ var buildType = args.release ? 'release' : 'debug',
+ buildArchs = args.archs ? args.archs.split(' ') : ['anycpu'],
+ projectType = args.phone ? 'phone' : 'windows',
+ deployTarget = args.target ? args.target : args.device ? 'device' : 'emulator';
// for win switch we should correctly handle 8.0 and 8.1 version as per configuration
if (projectType == 'windows' && getWindowsTargetVersion() == '8.0') {
- projectType = 'windows80'
+ projectType = 'windows80';
}
// if --nobuild isn't specified then build app first
@@ -66,47 +66,47 @@ module.exports.run = function (argv) {
return packages.getPackage(projectType, buildType, buildArchs[0]);
}).then(function(pkg) {
console.log('\nDeploying ' + pkg.type + ' package to ' + deployTarget + ':\n' + pkg.file);
- return pkg.type == "phone" ?
+ return pkg.type == 'phone' ?
packages.deployToPhone(pkg.file, deployTarget) :
packages.deployToDesktop(pkg.file, deployTarget);
});
};
module.exports.help = function () {
- console.log("\nUsage: run [ --device | --emulator | --target=<id> ] [ --debug | --release | --nobuild ]");
- console.log(" [ --x86 | --x64 | --arm ] [--phone | --win]");
- console.log(" --device : Deploys and runs the project on the connected device.");
- console.log(" --emulator : Deploys and runs the project on an emulator.");
- console.log(" --target=<id> : Deploys and runs the project on the specified target.");
- console.log(" --debug : Builds project in debug mode.");
- console.log(" --release : Builds project in release mode.");
- console.log(" --nobuild : Uses pre-built package, or errors if project is not built.");
- console.log(" --archs : Specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).");
- console.log(" --phone, --win");
- console.log(" : Specifies project type to deploy");
- console.log("");
- console.log("Examples:");
- console.log(" run");
- console.log(" run --emulator");
- console.log(" run --device");
- console.log(" run --target=7988B8C3-3ADE-488d-BA3E-D052AC9DC710");
- console.log(" run --device --release");
- console.log(" run --emulator --debug");
- console.log("");
+ console.log('\nUsage: run [ --device | --emulator | --target=<id> ] [ --debug | --release | --nobuild ]');
+ console.log(' [ --x86 | --x64 | --arm ] [--phone | --win]');
+ console.log(' --device : Deploys and runs the project on the connected device.');
+ console.log(' --emulator : Deploys and runs the project on an emulator.');
+ console.log(' --target=<id> : Deploys and runs the project on the specified target.');
+ console.log(' --debug : Builds project in debug mode.');
+ console.log(' --release : Builds project in release mode.');
+ console.log(' --nobuild : Uses pre-built package, or errors if project is not built.');
+ console.log(' --archs : Specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).');
+ console.log(' --phone, --win');
+ console.log(' : Specifies project type to deploy');
+ console.log('');
+ console.log('Examples:');
+ console.log(' run');
+ console.log(' run --emulator');
+ console.log(' run --device');
+ console.log(' run --target=7988B8C3-3ADE-488d-BA3E-D052AC9DC710');
+ console.log(' run --device --release');
+ console.log(' run --emulator --debug');
+ console.log('');
process.exit(0);
};
function getWindowsTargetVersion() {
var config = new ConfigParser(path.join(ROOT, 'config.xml'));
- var windowsTargetVersion = config.getPreference('windows-target-version')
+ var windowsTargetVersion = config.getPreference('windows-target-version');
switch(windowsTargetVersion) {
case '8':
case '8.0':
- return '8.0'
+ return '8.0';
case '8.1':
- return '8.1'
+ return '8.1';
default:
- throw new Error('Unsupported windows-target-version value: ' + windowsTargetVersion)
+ throw new Error('Unsupported windows-target-version value: ' + windowsTargetVersion);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/template/cordova/lib/target-list.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/target-list.js b/template/cordova/lib/target-list.js
index d55ad58..cdf0f8d 100644
--- a/template/cordova/lib/target-list.js
+++ b/template/cordova/lib/target-list.js
@@ -22,18 +22,18 @@ var devices = require('./package'),
// help/usage function
function help() {
- console.log("");
- console.log("Usage: node target-list.js [ --emulators | --devices | --started_emulators | --all ]");
- console.log(" --emulators : List the possible target emulators availible.");
- console.log(" --devices : List the possible target devices availible. *NOT IMPLEMENTED YET*");
- console.log(" --started_emulators : List any started emulators availible. *NOT IMPLEMENTED YET*");
- console.log(" --all : List all available devices");
- console.log("examples:");
- console.log(" node target-list.js --emulators");
- console.log(" node target-list.js --devices");
- console.log(" node target-list.js --started_emulators");
- console.log(" node target-list.js --all");
- console.log("");
+ console.log('');
+ console.log('Usage: node target-list.js [ --emulators | --devices | --started_emulators | --all ]');
+ console.log(' --emulators : List the possible target emulators availible.');
+ console.log(' --devices : List the possible target devices availible. *NOT IMPLEMENTED YET*');
+ console.log(' --started_emulators : List any started emulators availible. *NOT IMPLEMENTED YET*');
+ console.log(' --all : List all available devices');
+ console.log('examples:');
+ console.log(' node target-list.js --emulators');
+ console.log(' node target-list.js --devices');
+ console.log(' node target-list.js --started_emulators');
+ console.log(' node target-list.js --all');
+ console.log('');
}
// Handle help flag
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/232968c0/template/cordova/lib/utils.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/utils.js b/template/cordova/lib/utils.js
index c409b86..f1cd8d0 100644
--- a/template/cordova/lib/utils.js
+++ b/template/cordova/lib/utils.js
@@ -17,6 +17,8 @@
under the License.
*/
+/* jshint sub:true */
+
var Q = require('Q'),
fs = require('fs'),
path = require('path'),
@@ -53,7 +55,7 @@ module.exports.getMSBuildTools = function () {
module.exports.getAppStoreUtils = function () {
var appStoreUtils = path.join(__dirname, 'WindowsStoreAppUtils.ps1');
if (!fs.existsSync (appStoreUtils)) {
- return Q.reject("Can't unblock AppStoreUtils script");
+ return Q.reject('Can\'t unblock AppStoreUtils script');
}
//console.log("Removing execution restrictions from AppStoreUtils...");
return spawn('powershell', ['Unblock-File', module.exports.quote(appStoreUtils)]).then(function () {
@@ -65,12 +67,12 @@ module.exports.getAppStoreUtils = function () {
// returns path to AppDeploy util from Windows Phone 8.1 SDK
module.exports.getAppDeployUtils = function () {
- var appDeployUtils = path.join((process.env["ProgramFiles(x86)"] || process.env["ProgramFiles"]),
+ var appDeployUtils = path.join((process.env['ProgramFiles(x86)'] || process.env['ProgramFiles']),
'Microsoft SDKs', 'Windows Phone', 'v8.1', 'Tools', 'AppDeploy', 'AppDeployCmd.exe');
// Check if AppDeployCmd is exists
if (!fs.existsSync(appDeployUtils)) {
- console.warn("WARNING: AppDeploy tool (AppDeployCmd.exe) didn't found. Assume that it's in %PATH%");
- return Q.resolve("AppDeployCmd");
+ console.warn('WARNING: AppDeploy tool (AppDeployCmd.exe) didn\'t found. Assume that it\'s in %PATH%');
+ return Q.resolve('AppDeployCmd');
}
return Q.resolve(appDeployUtils);
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org