You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by au...@apache.org on 2017/07/14 23:25:38 UTC
[1/2] mac commit: CB-12762 : point package.json repo items to github
mirrors instead of apache repos site
Repository: cordova-osx
Updated Branches:
refs/heads/master e6e382a29 -> 34d879e0c
CB-12762 : point package.json repo items to github mirrors instead of apache repos site
This closes #37
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/6f09ffc0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/6f09ffc0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/6f09ffc0
Branch: refs/heads/master
Commit: 6f09ffc01eebd62328be08aabc9d6fcfd6039d3c
Parents: e6e382a
Author: Audrey So <au...@apache.org>
Authored: Thu Jun 1 11:41:28 2017 -0700
Committer: Audrey So <au...@apache.org>
Committed: Fri Jul 14 14:53:01 2017 -0700
----------------------------------------------------------------------
.eslintignore | 3 +++
.eslintrc.yml | 10 ++++++++
.jshintignore | 3 ---
.jshintrc | 10 --------
package.json | 60 ++++++++++++++++++++++++++++++++++++++++++-
tests/spec/.eslintrc.yml | 2 ++
6 files changed, 74 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/6f09ffc0/.eslintignore
----------------------------------------------------------------------
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..4808be4
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,3 @@
+bin/node_modules/*
+bin/templates/project/*
+tests
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/6f09ffc0/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/.eslintrc.yml b/.eslintrc.yml
new file mode 100644
index 0000000..0cccb8c
--- /dev/null
+++ b/.eslintrc.yml
@@ -0,0 +1,10 @@
+root: true
+extends: semistandard
+rules:
+ indent:
+ - error
+ - 4
+ camelcase: off
+ padded-blocks: off
+ operator-linebreak: off
+ no-throw-literal: off
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/6f09ffc0/.jshintignore
----------------------------------------------------------------------
diff --git a/.jshintignore b/.jshintignore
deleted file mode 100644
index 4808be4..0000000
--- a/.jshintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bin/node_modules/*
-bin/templates/project/*
-tests
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/6f09ffc0/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 89a121c..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "node": true
- , "bitwise": true
- , "undef": true
- , "trailing": true
- , "quotmark": true
- , "indent": 4
- , "unused": "vars"
- , "latedef": "nofunc"
-}
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/6f09ffc0/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index ea5b694..3ad74ce 100644
--- a/package.json
+++ b/package.json
@@ -49,4 +49,62 @@
"coffee-script": "^1.7.1",
"nodeunit": "^0.8.7"
}
-}
\ No newline at end of file
+}
+=======
+ "name": "cordova-osx",
+ "version": "4.1.0-dev",
+ "description": "cordova-osx release",
+ "main": "bin/templates/scripts/cordova/Api.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/apache/cordova-osx"
+ },
+ "keywords": [
+ "osx",
+ "cordova",
+ "apache",
+ "ecosystem:cordova",
+ "cordova:platform"
+ ],
+ "scripts": {
+ "test": "npm run eslint && npm run jasmine",
+ "jasmine": "npm run objc-tests && npm run jasmine-tests",
+ "objc-tests": "jasmine-node --captureExceptions --color tests/spec/cordovalib.spec.js",
+ "jasmine-tests": "jasmine-node --captureExceptions --color tests/spec/create.spec.js tests/spec/platform.spec.js",
+ "eslint": "node node_modules/eslint/bin/eslint bin && node node_modules/eslint/bin/eslint tests"
+ },
+ "author": "Apache Software Foundation",
+ "license": "Apache Version 2.0",
+ "dependencies": {
+ "cordova-common": "^1.0.0",
+ "nopt": "^3.0.6",
+ "q": "^1.4.1",
+ "shelljs": "^0.5.3",
+ "underscore": "^1.8.3",
+ "unorm": "^1.4.1",
+ "xcode": "^0.8.3"
+ },
+ "bundledDependencies": [
+ "cordova-common",
+ "nopt",
+ "q",
+ "underscore",
+ "unorm",
+ "xcode",
+ "shelljs"
+ ],
+ "devDependencies": {
+ "coffee-script": "^1.7.1",
+ "eslint": "^4.0.0",
+ "eslint-config-semistandard": "^11.0.0",
+ "eslint-config-standard": "^10.2.1",
+ "eslint-plugin-import": "^2.3.0",
+ "eslint-plugin-node": "^5.0.0",
+ "eslint-plugin-promise": "^3.5.0",
+ "eslint-plugin-standard": "^3.0.1",
+ "jasmine-node": "~1",
+ "nodeunit": "^0.8.7",
+ "tmp": "^0.0.26",
+ "uncrustify": "^0.6.1"
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/6f09ffc0/tests/spec/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/tests/spec/.eslintrc.yml b/tests/spec/.eslintrc.yml
new file mode 100644
index 0000000..6afba65
--- /dev/null
+++ b/tests/spec/.eslintrc.yml
@@ -0,0 +1,2 @@
+env:
+ jasmine: true
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/2] mac commit: CB-12985 : updated to use eslint format
Posted by au...@apache.org.
CB-12985 : updated to use eslint format
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/34d879e0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/34d879e0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/34d879e0
Branch: refs/heads/master
Commit: 34d879e0ca56e32b8224160bba49b20e1a969721
Parents: 6f09ffc
Author: Audrey So <au...@apache.org>
Authored: Fri Jul 14 11:14:04 2017 -0700
Committer: Audrey So <au...@apache.org>
Committed: Fri Jul 14 15:05:07 2017 -0700
----------------------------------------------------------------------
bin/lib/check_reqs.js | 34 ++---
bin/lib/create.js | 102 +++++++--------
bin/lib/versions.js | 48 ++++---
bin/templates/scripts/cordova/Api.js | 60 +++++----
.../scripts/cordova/lib/ConsoleLogger.js | 7 +-
bin/templates/scripts/cordova/lib/build.js | 64 +++++-----
bin/templates/scripts/cordova/lib/clean.js | 26 ++--
.../scripts/cordova/lib/configMunger.js | 6 +-
.../scripts/cordova/lib/copy-www-build-step.js | 26 ++--
.../scripts/cordova/lib/plugman/Plugman.js | 56 +++-----
.../cordova/lib/plugman/pluginHandlers.js | 91 +++++++------
bin/templates/scripts/cordova/lib/prepare.js | 128 +++++++++----------
.../scripts/cordova/lib/projectFile.js | 24 ++--
bin/templates/scripts/cordova/lib/run.js | 16 +--
bin/templates/scripts/cordova/lib/spawn.js | 14 +-
package.json | 52 --------
16 files changed, 332 insertions(+), 422 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index d3dde27..bedec84 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -17,9 +17,9 @@
under the License.
*/
-var Q = require('q'),
- shell = require('shelljs'),
- versions = require('./versions');
+var Q = require('q');
+var shell = require('shelljs');
+var versions = require('./versions');
var XCODEBUILD_MIN_VERSION = '6.0.0';
var XCODEBUILD_NOT_FOUND_MESSAGE =
@@ -84,7 +84,7 @@ var Requirement = function (id, name, isFatal) {
*
* @return Promise<Requirement[]> Array of requirements. Due to implementation, promise is always fulfilled.
*/
-module.exports.check_all = function() {
+module.exports.check_all = function () {
var requirements = [
new Requirement('os', 'Apple OS X', true),
@@ -108,19 +108,19 @@ module.exports.check_all = function() {
var requirement = requirements[idx];
return checkFn()
- .then(function (version) {
- requirement.installed = true;
- requirement.metadata.version = version;
- result.push(requirement);
- }, function (err) {
- if (requirement.isFatal) fatalIsHit = true;
- requirement.metadata.reason = err;
- result.push(requirement);
- });
+ .then(function (version) {
+ requirement.installed = true;
+ requirement.metadata.version = version;
+ result.push(requirement);
+ }, function (err) {
+ if (requirement.isFatal) fatalIsHit = true;
+ requirement.metadata.reason = err;
+ result.push(requirement);
+ });
});
}, Q())
- .then(function () {
- // When chain is completed, return requirements array to upstream API
- return result;
- });
+ .then(function () {
+ // When chain is completed, return requirements array to upstream API
+ return result;
+ });
};
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 764c8dd..06aa0df 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -19,30 +19,30 @@
under the License.
*/
-var shell = require('shelljs'),
- Q = require ('q'),
- path = require('path'),
- fs = require('fs'),
- ROOT = path.join(__dirname, '..', '..');
+var shell = require('shelljs');
+var Q = require('q');
+var path = require('path');
+var fs = require('fs');
+var ROOT = path.join(__dirname, '..', '..');
-function updateSubprojectHelp() {
+function updateSubprojectHelp () {
console.log('Updates the subproject path of the CordovaLib entry to point to this script\'s version of Cordova.');
console.log('Usage: CordovaVersion/bin/update_cordova_project path/to/your/app.xcodeproj [path/to/CordovaLib.xcodeproj]');
}
-function setShellFatal(value, func) {
+function setShellFatal (value, func) {
var oldVal = shell.config.fatal;
shell.config.fatal = value;
func();
shell.config.fatal = oldVal;
}
-function copyJsAndCordovaLib(projectPath, projectName, use_shared) {
+function copyJsAndCordovaLib (projectPath, projectName, use_shared) {
shell.cp('-f', path.join(ROOT, 'CordovaLib', 'cordova.js'), path.join(projectPath, 'www'));
shell.cp('-rf', path.join(ROOT, 'cordova-js-src'), path.join(projectPath, 'platform_www'));
shell.cp('-f', path.join(ROOT, 'CordovaLib', 'cordova.js'), path.join(projectPath, 'platform_www'));
- fs.lstat(path.join(projectPath, 'CordovaLib'), function(err, stats) {
+ fs.lstat(path.join(projectPath, 'CordovaLib'), function (err, stats) {
if (!err) {
if (stats.isSymbolicLink()) {
fs.unlinkSync(path.join(projectPath, 'CordovaLib'));
@@ -52,7 +52,7 @@ function copyJsAndCordovaLib(projectPath, projectName, use_shared) {
}
if (use_shared) {
- update_cordova_subproject([path.join(projectPath, projectName +'.xcodeproj', 'project.pbxproj')]);
+ update_cordova_subproject([path.join(projectPath, projectName + '.xcodeproj', 'project.pbxproj')]);
// Symlink not used in project file, but is currently required for plugman because
// it reads the VERSION file from it (instead of using the cordova/version script
// like it should).
@@ -63,7 +63,7 @@ function copyJsAndCordovaLib(projectPath, projectName, use_shared) {
var dstLib = path.join(projectPath, 'CordovaLib');
shell.mkdir('-p', path.join(dstLib, 'CordovaLib.xcodeproj'));
shell.cp('-f', path.join(r, '.gitignore'), projectPath);
- shell.cp('-rf',path.join(srcLib, 'CordovaLib'), dstLib);
+ shell.cp('-rf', path.join(srcLib, 'CordovaLib'), dstLib);
shell.cp('-f', path.join(srcLib, 'VERSION'), dstLib);
shell.cp('-f', path.join(srcLib, 'cordova.js'), dstLib);
shell.cp('-f', path.join(srcLib, 'CordovaLib', 'CordovaLib-Prefix.pch'), path.join(dstLib, 'CordovaLib'));
@@ -73,7 +73,7 @@ function copyJsAndCordovaLib(projectPath, projectName, use_shared) {
});
}
-function copyScripts(projectPath) {
+function copyScripts (projectPath) {
var srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'scripts', 'cordova');
var destScriptsDir = path.join(projectPath, 'cordova');
@@ -92,15 +92,15 @@ function copyScripts(projectPath) {
// Copy the version scripts
shell.cp(path.join(binDir, 'apple_osx_version'), destScriptsDir);
shell.cp(path.join(binDir, 'apple_xcode_version'), destScriptsDir);
- shell.cp(path.join(binDir, 'lib', 'versions.js'), path.join(destScriptsDir, 'lib'));
+ shell.cp(path.join(binDir, 'lib', 'versions.js'), path.join(destScriptsDir, 'lib'));
// Make sure they are executable (sometimes zipping them can remove executable bit)
- shell.find(destScriptsDir).forEach(function(entry) {
+ shell.find(destScriptsDir).forEach(function (entry) {
shell.chmod(755, entry);
});
}
-function detectProjectName(projectDir) {
+function detectProjectName (projectDir) {
var files = fs.readdirSync(projectDir);
for (var i = 0; i < files.length; ++i) {
var m = /(.*)\.xcodeproj$/.exec(files[i]);
@@ -111,22 +111,21 @@ function detectProjectName(projectDir) {
throw new Error('Could not find an .xcodeproj directory within ' + projectDir);
}
-function AbsParentPath(_path) {
+function AbsParentPath (_path) {
return path.resolve(path.dirname(_path));
}
-function AbsProjectPath(relative_path) {
+function AbsProjectPath (relative_path) {
var absolute_path = path.resolve(relative_path);
if (/.pbxproj$/.test(absolute_path)) {
absolute_path = AbsParentPath(absolute_path);
- }
- else if (!(/.xcodeproj$/.test(absolute_path))) {
+ } else if (!(/.xcodeproj$/.test(absolute_path))) {
throw new Error('The following is not a valid path to an Xcode project' + absolute_path);
}
return absolute_path;
}
-function relpath(_path, start) {
+function relpath (_path, start) {
start = start || process.cwd();
return path.relative(path.resolve(start), path.resolve(_path));
}
@@ -142,20 +141,20 @@ function relpath(_path, start) {
* - <project_template_dir>: Path to a project template (override)
*
*/
-exports.createProject = function(project_path, package_name, project_name, opts, events) {
+exports.createProject = function (project_path, package_name, project_name, opts, events) {
package_name = package_name || 'my.cordova.project';
project_name = project_name || 'CordovaExample';
var use_shared = !!opts.link;
- var bin_dir = path.join(ROOT, 'bin'),
- project_parent = path.dirname(project_path);
+ var bin_dir = path.join(ROOT, 'bin');
+ var project_parent = path.dirname(project_path);
var project_template_dir = opts.customTemplate || path.join(bin_dir, 'templates', 'project');
- //check that project path doesn't exist
+ // check that project path doesn't exist
if (fs.existsSync(project_path)) {
return Q.reject('Project already exists');
}
- //check that parent directory does exist so cp -r will not fail
+ // check that parent directory does exist so cp -r will not fail
if (!fs.existsSync(project_parent)) {
return Q.reject(project_parent + ' does not exist. Please specify an existing parent folder');
}
@@ -164,17 +163,17 @@ exports.createProject = function(project_path, package_name, project_name, opts,
shell.mkdir(project_path);
shell.cp('-rf', path.join(project_template_dir, 'www'), project_path);
shell.cp('-rf', path.join(project_template_dir, '__PROJECT_NAME__.xcodeproj'), project_path);
- shell.mv(path.join(project_path, '__PROJECT_NAME__.xcodeproj'), path.join(project_path, project_name+'.xcodeproj'));
+ shell.mv(path.join(project_path, '__PROJECT_NAME__.xcodeproj'), path.join(project_path, project_name + '.xcodeproj'));
shell.cp('-rf', path.join(project_template_dir, '__PROJECT_NAME__'), project_path);
shell.mv(path.join(project_path, '__PROJECT_NAME__'), path.join(project_path, project_name));
var r = path.join(project_path, project_name);
- shell.mv(path.join(r, '__PROJECT_NAME__-Info.plist'), path.join(r, project_name+'-Info.plist'));
- shell.mv(path.join(r, '__PROJECT_NAME__-Prefix.pch'), path.join(r, project_name+'-Prefix.pch'));
+ shell.mv(path.join(r, '__PROJECT_NAME__-Info.plist'), path.join(r, project_name + '-Info.plist'));
+ shell.mv(path.join(r, '__PROJECT_NAME__-Prefix.pch'), path.join(r, project_name + '-Prefix.pch'));
shell.mv(path.join(r, 'gitignore'), path.join(r, '.gitignore'));
var project_name_esc = project_name.replace(/&/g, '\\&');
- shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r+'.xcodeproj', 'project.pbxproj'));
+ shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r + '.xcodeproj', 'project.pbxproj'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.h'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'AppDelegate.m'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'MainViewController.h'));
@@ -182,12 +181,12 @@ exports.createProject = function(project_path, package_name, project_name, opts,
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'MainViewController.xib'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'en.lproj/MainViewController.strings'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'main.m'));
- shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, project_name+'-Info.plist'));
- shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, project_name+'-Prefix.pch'));
+ shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, project_name + '-Info.plist'));
+ shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, project_name + '-Prefix.pch'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'config.xml'));
- shell.sed('-i', /--ID--/g, package_name, path.join(r, project_name+'-Info.plist'));
+ shell.sed('-i', /--ID--/g, package_name, path.join(r, project_name + '-Info.plist'));
- //CordovaLib stuff
+ // CordovaLib stuff
copyJsAndCordovaLib(project_path, project_name, use_shared);
copyScripts(project_path);
@@ -195,53 +194,52 @@ exports.createProject = function(project_path, package_name, project_name, opts,
return Q.resolve();
};
-exports.updateProject = function(projectPath, opts, events) {
+exports.updateProject = function (projectPath, opts, events) {
var projectName = detectProjectName(projectPath);
- setShellFatal(true, function() {
+ setShellFatal(true, function () {
copyJsAndCordovaLib(projectPath, projectName, opts.link);
copyScripts(projectPath);
- events.emit('log',generateDoneMessage('update', opts.link));
+ events.emit('log', generateDoneMessage('update', opts.link));
});
return Q.resolve();
};
-function generateDoneMessage(type, link) {
+function generateDoneMessage (type, link) {
var pkg = require('../../package');
- var msg = 'OS X project ' + (type == 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
+ var msg = 'OS X project ' + (type === 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
if (link) {
msg += ' and has a linked CordovaLib';
}
return msg;
}
-function update_cordova_subproject(argv) {
- if (argv.length < 1 || argv.length > 2)
- {
+function update_cordova_subproject (argv) {
+ if (argv.length < 1 || argv.length > 2) {
updateSubprojectHelp();
throw new Error('Usage error for update_cordova_subproject');
}
- var projectPath = AbsProjectPath(argv[0]),
- cordovaLibXcodePath;
+ var projectPath = AbsProjectPath(argv[0]);
+ var cordovaLibXcodePath;
if (argv.length < 2) {
cordovaLibXcodePath = path.join(ROOT, 'CordovaLib', 'CordovaLib.xcodeproj');
- }
- else {
+ } else {
cordovaLibXcodePath = AbsProjectPath(argv[1]);
}
- var parentProjectPath = AbsParentPath(projectPath),
- subprojectPath = relpath(cordovaLibXcodePath, parentProjectPath),
- REGEX = /(.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/,
- newLine,
- lines = shell.grep('CordovaLib.xcodeproj', path.join(projectPath, 'project.pbxproj')),
- found = false;
+ var parentProjectPath = AbsParentPath(projectPath);
+ var subprojectPath = relpath(cordovaLibXcodePath, parentProjectPath);
+ var REGEX = /(.+PBXFileReference.+wrapper.pb-project.+)(path = .+?;)(.*)(sourceTree.+;)(.+)/;
+ var newLine;
+ var lines = shell.grep('CordovaLib.xcodeproj', path.join(projectPath, 'project.pbxproj'));
+ var found = false;
subprojectPath = subprojectPath.replace(/\\/g, '/');
lines = lines.split('\n');
for (var i = 0; i < lines.length; ++i) {
if (lines[i].match(REGEX)) {
found = true;
+ /* eslint-disable no-useless-escape */
newLine = lines[i].replace(/path = .+?;/, 'path = ' + subprojectPath + ';');
newLine = newLine.replace(/sourceTree.+?;/, 'sourceTree = \"<group>\";');
if (!newLine.match('name')) {
@@ -257,6 +255,8 @@ function update_cordova_subproject(argv) {
var copyWwwJs = 'NODEJS_PATH=\/usr\/local\/bin; NVM_NODE_PATH=~\/\.nvm\/versions\/node\/`nvm version 2>\/dev\/null`\/bin; N_NODE_PATH=`find \/usr\/local\/n\/versions\/node\/\* -maxdepth 0 -type d 2>\/dev\/null \| tail -1`\/bin; XCODE_NODE_PATH=`xcode-select --print-path`\/usr\/share\/xcs\/Node\/bin; PATH=\$NODEJS_PATH:\$NVM_NODE_PATH:\$N_NODE_PATH:\$XCODE_NODE_PATH:\$PATH && node cordova\/lib\/copy-www-build-step\.js';
shell.sed('-i', copyWwwSh, copyWwwJs, path.join(projectPath, 'project.pbxproj'));
+ /* eslint-enable no-useless-escape */
+
if (!found) {
throw new Error('Subproject: ' + subprojectPath + ' entry not found in project file');
}
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/lib/versions.js
----------------------------------------------------------------------
diff --git a/bin/lib/versions.js b/bin/lib/versions.js
index ea6c61e..7ad011a 100755
--- a/bin/lib/versions.js
+++ b/bin/lib/versions.js
@@ -19,53 +19,51 @@
under the License.
*/
-var child_process = require('child_process'),
- Q = require('q');
+var child_process = require('child_process');
+var Q = require('q');
-exports.get_apple_osx_version = function() {
+exports.get_apple_osx_version = function () {
var d = Q.defer();
- child_process.exec('xcodebuild -showsdks', function(error, stdout, stderr) {
+ child_process.exec('xcodebuild -showsdks', function (error, stdout, stderr) {
if (error) {
d.reject(stderr);
- }
- else {
+ } else {
d.resolve(stdout);
}
});
- return d.promise.then(function(output) {
- var regex = /[0-9]*\.[0-9]*/,
- versions = [],
- regexOSX = /^OS X \d+/;
+ return d.promise.then(function (output) {
+ var regex = /[0-9]*\.[0-9]*/;
+ var versions = [];
+ var regexOSX = /^OS X \d+/;
output = output.split('\n');
for (var i = 0; i < output.length; i++) {
if (output[i].trim().match(regexOSX)) {
versions[versions.length] = parseFloat(output[i].match(regex)[0]);
- }
+ }
}
versions.sort();
console.log(versions[0]);
return Q();
- }, function(stderr) {
+ }, function (stderr) {
return Q.reject(stderr);
});
};
-exports.get_apple_osx_version = function() {
+exports.get_apple_osx_version = function () {
var d = Q.defer();
- child_process.exec('xcodebuild -showsdks', function(error, stdout, stderr) {
+ child_process.exec('xcodebuild -showsdks', function (error, stdout, stderr) {
if (error) {
d.reject(stderr);
- }
- else {
+ } else {
d.resolve(stdout);
}
});
- return d.promise.then(function(output) {
- var regex = /[0-9]*\.[0-9]*/,
- versions = [],
- regexOSX = /^OS X \d+/;
+ return d.promise.then(function (output) {
+ var regex = /[0-9]*\.[0-9]*/;
+ var versions = [];
+ var regexOSX = /^OS X \d+/;
output = output.split('\n');
for (var i = 0; i < output.length; i++) {
if (output[i].trim().match(regexOSX)) {
@@ -75,14 +73,14 @@ exports.get_apple_osx_version = function() {
versions.sort();
console.log(versions[0]);
return Q();
- }, function(stderr) {
+ }, function (stderr) {
return Q.reject(stderr);
});
};
-exports.get_apple_xcode_version = function() {
+exports.get_apple_xcode_version = function () {
var d = Q.defer();
- child_process.exec('xcodebuild -version', function(error, stdout, stderr) {
+ child_process.exec('xcodebuild -version', function (error, stdout, stderr) {
var versionMatch = /Xcode (.*)/.exec(stdout);
if (error || !versionMatch) {
d.reject(stderr);
@@ -101,8 +99,8 @@ exports.get_apple_xcode_version = function() {
*/
exports.get_tool_version = function (toolName) {
switch (toolName) {
- case 'xcodebuild': return exports.get_apple_xcode_version();
- default: return Q.reject(toolName + ' is not valid tool name. Valid names are: \'xcodebuild\'');
+ case 'xcodebuild': return exports.get_apple_xcode_version();
+ default: return Q.reject(toolName + ' is not valid tool name. Valid names are: \'xcodebuild\'');
}
};
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/Api.js b/bin/templates/scripts/cordova/Api.js
index b383614..8867e38 100644
--- a/bin/templates/scripts/cordova/Api.js
+++ b/bin/templates/scripts/cordova/Api.js
@@ -17,8 +17,6 @@
under the License.
*/
-/*jslint node: true */
-
var fs = require('fs');
var path = require('path');
@@ -36,7 +34,7 @@ var ConsoleLogger = require('./lib/ConsoleLogger');
* logging purposes. If no EventEmitter provided, all events will be logged to
* console
*/
-function Api(platform, platformRootDir, events) {
+function Api (platform, platformRootDir, events) {
// 'platform' property is required as per PlatformApi spec
this.platform = platform || 'osx';
@@ -49,15 +47,15 @@ function Api(platform, platformRootDir, events) {
var xcodeCordovaProj;
try {
- xcodeProjDir = fs.readdirSync(this.root).filter( function(e) { return e.match(/\.xcodeproj$/i); })[0];
+ xcodeProjDir = fs.readdirSync(this.root).filter(function (e) { return e.match(/\.xcodeproj$/i); })[0];
if (!xcodeProjDir) {
throw new CordovaError('The provided path "' + this.root + '" is not a Cordova iOS project.');
}
- var cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep)+1, xcodeProjDir.indexOf('.xcodeproj'));
+ var cordovaProjName = xcodeProjDir.substring(xcodeProjDir.lastIndexOf(path.sep) + 1, xcodeProjDir.indexOf('.xcodeproj'));
xcodeCordovaProj = path.join(this.root, cordovaProjName);
- } catch(e) {
- throw new CordovaError('The provided path "'+this.root+'" is not a Cordova iOS project.');
+ } catch (e) {
+ throw new CordovaError('The provided path "' + this.root + '" is not a Cordova iOS project.');
}
this.locations = {
@@ -96,13 +94,13 @@ function Api(platform, platformRootDir, events) {
*/
Api.createPlatform = function (destination, config, options, events) {
return require('../../../lib/create')
- .createProject(destination, config.packageName(), config.name(), options, events || ConsoleLogger.get())
- .then(function () {
- // after platform is created we return Api instance based on new Api.js location
- // This is required to correctly resolve paths in the future api calls
- var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
- return new PlatformApi('osx', destination, events);
- });
+ .createProject(destination, config.packageName(), config.name(), options, events || ConsoleLogger.get())
+ .then(function () {
+ // after platform is created we return Api instance based on new Api.js location
+ // This is required to correctly resolve paths in the future api calls
+ var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
+ return new PlatformApi('osx', destination, events);
+ });
};
/**
@@ -123,11 +121,11 @@ Api.createPlatform = function (destination, config, options, events) {
*/
Api.updatePlatform = function (destination, options, events) {
return require('../../../lib/create')
- .updateProject(destination, options, events || ConsoleLogger.get())
- .then(function () {
- var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
- return new PlatformApi('android', destination, events);
- });
+ .updateProject(destination, options, events || ConsoleLogger.get())
+ .then(function () {
+ var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
+ return new PlatformApi('android', destination, events);
+ });
};
/**
@@ -240,9 +238,9 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
Api.prototype.build = function (buildOptions) {
var self = this;
return require('./lib/check_reqs').run()
- .then(function () {
- return require('./lib/build').run.call(self, buildOptions);
- });
+ .then(function () {
+ return require('./lib/build').run.call(self, buildOptions);
+ });
};
/**
@@ -257,12 +255,12 @@ Api.prototype.build = function (buildOptions) {
* @return {Promise} A promise either fulfilled if package was built and ran
* successfully, or rejected with CordovaError.
*/
-Api.prototype.run = function(runOptions) {
+Api.prototype.run = function (runOptions) {
var self = this;
return require('./lib/check_reqs').run()
- .then(function () {
- return require('./lib/run').run.call(self, runOptions);
- });
+ .then(function () {
+ return require('./lib/run').run.call(self, runOptions);
+ });
};
/**
@@ -271,12 +269,12 @@ Api.prototype.run = function(runOptions) {
* @return {Promise} Return a promise either fulfilled, or rejected with
* CordovaError.
*/
-Api.prototype.clean = function(cleanOptions) {
+Api.prototype.clean = function (cleanOptions) {
var self = this;
return require('./lib/check_reqs').run()
- .then(function () {
- return require('./lib/clean').run.call(self, cleanOptions);
- });
+ .then(function () {
+ return require('./lib/clean').run.call(self, cleanOptions);
+ });
};
/**
@@ -287,7 +285,7 @@ Api.prototype.clean = function(cleanOptions) {
* @return {Promise<Requirement[]>} Promise, resolved with set of Requirement
* objects for current platform.
*/
-Api.prototype.requirements = function() {
+Api.prototype.requirements = function () {
return require('./lib/check_reqs').check_all();
};
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/ConsoleLogger.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/ConsoleLogger.js b/bin/templates/scripts/cordova/lib/ConsoleLogger.js
index cee2dc1..d190206 100644
--- a/bin/templates/scripts/cordova/lib/ConsoleLogger.js
+++ b/bin/templates/scripts/cordova/lib/ConsoleLogger.js
@@ -33,13 +33,13 @@ var CordovaError = require('cordova-common').CordovaError;
* Also attaches handler to process' uncaught exceptions, so these exceptions
* logged to console similar to regular error events.
*/
-function ConsoleLogger() {
+function ConsoleLogger () {
EventEmitter.call(this);
var isVerbose = process.argv.indexOf('-d') >= 0 || process.argv.indexOf('--verbose') >= 0;
// For CordovaError print only the message without stack trace unless we
// are in a verbose mode.
- process.on('uncaughtException', function(err){
+ process.on('uncaughtException', function (err) {
if ((err instanceof CordovaError) && isVerbose) {
console.error(err.stack);
} else {
@@ -50,8 +50,7 @@ function ConsoleLogger() {
this.on('results', console.log);
this.on('verbose', function () {
- if (isVerbose)
- console.log.apply(console, arguments);
+ if (isVerbose) { console.log.apply(console, arguments); }
});
this.on('info', console.log);
this.on('log', console.log);
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js
index 115918c..ca903b6 100644
--- a/bin/templates/scripts/cordova/lib/build.js
+++ b/bin/templates/scripts/cordova/lib/build.js
@@ -6,9 +6,9 @@
* 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
@@ -17,14 +17,12 @@
* under the License.
*/
-/*jshint node: true*/
-
-var Q = require('q'),
- path = require('path'),
- shell = require('shelljs'),
- spawn = require('./spawn'),
- check_reqs = require('./check_reqs'),
- fs = require('fs');
+var Q = require('q');
+var path = require('path');
+var shell = require('shelljs');
+var spawn = require('./spawn');
+var check_reqs = require('./check_reqs');
+var fs = require('fs');
var events = require('cordova-common').events;
@@ -43,18 +41,18 @@ module.exports.run = function (buildOpts) {
return Q.reject('Only one of "device"/"emulator" options should be specified');
}
- if(buildOpts.buildConfig) {
- if(!fs.existsSync(buildOpts.buildConfig)) {
+ if (buildOpts.buildConfig) {
+ if (!fs.existsSync(buildOpts.buildConfig)) {
return Q.reject('Build config file does not exist:' + buildOpts.buildConfig);
}
- events.emit('log','Reading build config file:', path.resolve(buildOpts.buildConfig));
+ events.emit('log', 'Reading build config file:', path.resolve(buildOpts.buildConfig));
var buildConfig = JSON.parse(fs.readFileSync(buildOpts.buildConfig, 'utf-8'));
- if(buildConfig.osx) {
+ if (buildConfig.osx) {
var buildType = buildOpts.release ? 'release' : 'debug';
var config = buildConfig.osx[buildType];
- if(config) {
+ if (config) {
['codeSignIdentity', 'codeSignResourceRules', 'provisioningProfile'].forEach(
- function(key) {
+ function (key) {
buildOpts[key] = buildOpts[key] || config[key];
});
}
@@ -79,32 +77,31 @@ module.exports.run = function (buildOpts) {
}).then(function () {
var configuration = buildOpts.release ? 'Release' : 'Debug';
- events.emit('log','Building project : ' + path.join(projectPath, projectName + '.xcodeproj'));
- events.emit('log','\tConfiguration : ' + configuration);
+ events.emit('log', 'Building project : ' + path.join(projectPath, projectName + '.xcodeproj'));
+ events.emit('log', '\tConfiguration : ' + configuration);
var xcodebuildArgs = getXcodeArgs(projectName, projectPath, configuration);
return spawn('xcodebuild', xcodebuildArgs, projectPath);
}).then(function () {
if (buildOpts.noSign) {
- return;
+
}
- //var buildOutputDir = path.join(projectPath, 'build');
- //var pathToApp = path.join(buildOutputDir, projectName + '.app');
- //var pathToIpa = path.join(buildOutputDir, projectName + '.ipa');
- //var xcRunArgs = ['-sdk', 'iphoneos', 'PackageApplication',
+ // var buildOutputDir = path.join(projectPath, 'build');
+ // var pathToApp = path.join(buildOutputDir, projectName + '.app');
+ // var pathToIpa = path.join(buildOutputDir, projectName + '.ipa');
+ // var xcRunArgs = ['-sdk', 'iphoneos', 'PackageApplication',
// '-v', pathToApp,
// '-o', pathToIpa];
- //if (buildOpts.codeSignIdentity) {
+ // if (buildOpts.codeSignIdentity) {
// xcRunArgs.concat('--sign', buildOpts.codeSignIdentity);
- //}
- //if (buildOpts.provisioningProfile) {
+ // }
+ // if (buildOpts.provisioningProfile) {
// xcRunArgs.concat('--embed', buildOpts.provisioningProfile);
- //}
- //return spawn('xcrun', xcRunArgs, projectPath);
+ // }
+ // return spawn('xcrun', xcRunArgs, projectPath);
// todo
- return;
});
};
@@ -113,7 +110,7 @@ module.exports.run = function (buildOpts) {
* @param {String} projectPath Path where to search project
* @return {Promise} Promise either fulfilled with project name or rejected
*/
-function findXCodeProjectIn(projectPath) {
+function findXCodeProjectIn (projectPath) {
// 'Searching for Xcode project in ' + projectPath);
var xcodeProjFiles = shell.ls(projectPath).filter(function (name) {
return path.extname(name) === '.xcodeproj';
@@ -123,7 +120,7 @@ function findXCodeProjectIn(projectPath) {
return Q.reject('No Xcode project found in ' + projectPath);
}
if (xcodeProjFiles.length > 1) {
- events.emit('warn','Found multiple .xcodeproj directories in \n' +
+ events.emit('warn', 'Found multiple .xcodeproj directories in \n' +
projectPath + '\nUsing first one');
}
@@ -140,7 +137,7 @@ module.exports.findXCodeProjectIn = findXCodeProjectIn;
* @param {String} configuration Configuration name: debug|release
* @return {Array} Array of arguments that could be passed directly to spawn method
*/
-function getXcodeArgs(projectName, projectPath, configuration) {
+function getXcodeArgs (projectName, projectPath, configuration) {
return [
'-xcconfig', path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
'-project', projectName + '.xcodeproj',
@@ -153,7 +150,8 @@ function getXcodeArgs(projectName, projectPath, configuration) {
}
// help/usage function
-module.exports.help = function help() {
+/* eslint-disable no-useless-escape */
+module.exports.help = function help () {
console.log('');
console.log('Usage: build [--debug | --release]');
console.log(' [--codeSignIdentity=\"<identity>\"]');
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/clean.js b/bin/templates/scripts/cordova/lib/clean.js
index 7c8cf56..20e8ac6 100644
--- a/bin/templates/scripts/cordova/lib/clean.js
+++ b/bin/templates/scripts/cordova/lib/clean.js
@@ -6,9 +6,9 @@
* 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
@@ -17,16 +17,14 @@
* under the License.
*/
-/*jshint node: true*/
-
-var Q = require('q'),
- path = require('path'),
- shell = require('shelljs'),
- spawn = require('./spawn');
+var Q = require('q');
+var path = require('path');
+var shell = require('shelljs');
+var spawn = require('./spawn');
var projectPath = path.join(__dirname, '..', '..');
-module.exports.run = function() {
+module.exports.run = function () {
var projectName = shell.ls(projectPath).filter(function (name) {
return path.extname(name) === '.xcodeproj';
})[0];
@@ -36,9 +34,9 @@ module.exports.run = function() {
}
return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Debug', '-alltargets', 'clean'], projectPath)
- .then(function () {
- return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Release', '-alltargets', 'clean'], projectPath);
- }).then(function () {
- return shell.rm('-rf', path.join(projectPath, 'build'));
- });
+ .then(function () {
+ return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Release', '-alltargets', 'clean'], projectPath);
+ }).then(function () {
+ return shell.rm('-rf', path.join(projectPath, 'build'));
+ });
};
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/configMunger.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/configMunger.js b/bin/templates/scripts/cordova/lib/configMunger.js
index 0270412..2f0b7f5 100644
--- a/bin/templates/scripts/cordova/lib/configMunger.js
+++ b/bin/templates/scripts/cordova/lib/configMunger.js
@@ -17,18 +17,18 @@
under the License.
*/
-/*jshint node: true*/
+/* jshint node: true */
var PlatformJson = require('cordova-common').PlatformJson;
var PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
-//shared PlatformMunger instance
+// shared PlatformMunger instance
var _instance = null;
module.exports = {
- get: function(platformRoot) {
+ get: function (platformRoot) {
if (!_instance) {
_instance = new PlatformMunger('osx', platformRoot, PlatformJson.load(platformRoot, 'osx'),
new PluginInfoProvider());
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/copy-www-build-step.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/copy-www-build-step.js b/bin/templates/scripts/cordova/lib/copy-www-build-step.js
index 2c53f29..04c0e3e 100644
--- a/bin/templates/scripts/cordova/lib/copy-www-build-step.js
+++ b/bin/templates/scripts/cordova/lib/copy-www-build-step.js
@@ -24,19 +24,19 @@
// This script should not be called directly.
// It is called as a build step from Xcode.
-var BUILT_PRODUCTS_DIR = process.env.BUILT_PRODUCTS_DIR,
- FULL_PRODUCT_NAME = process.env.FULL_PRODUCT_NAME,
- COPY_HIDDEN = process.env.COPY_HIDDEN,
- PROJECT_FILE_PATH = process.env.PROJECT_FILE_PATH;
+var BUILT_PRODUCTS_DIR = process.env.BUILT_PRODUCTS_DIR;
+var FULL_PRODUCT_NAME = process.env.FULL_PRODUCT_NAME;
+var COPY_HIDDEN = process.env.COPY_HIDDEN;
+var PROJECT_FILE_PATH = process.env.PROJECT_FILE_PATH;
-var path = require('path'),
- fs = require('fs'),
- shell = require('shelljs'),
- srcDir = 'www',
- dstDir = path.join(BUILT_PRODUCTS_DIR, FULL_PRODUCT_NAME, 'Contents', 'Resources'),
- dstWwwDir = path.join(dstDir, 'www');
+var path = require('path');
+var fs = require('fs');
+var shell = require('shelljs');
+var srcDir = 'www';
+var dstDir = path.join(BUILT_PRODUCTS_DIR, FULL_PRODUCT_NAME, 'Contents', 'Resources');
+var dstWwwDir = path.join(dstDir, 'www');
-if(!BUILT_PRODUCTS_DIR) {
+if (!BUILT_PRODUCTS_DIR) {
console.error('The script is meant to be run as an Xcode build step and relies on env variables set by Xcode.');
process.exit(1);
}
@@ -57,13 +57,13 @@ shell.rm('-rf', path.join(dstDir, 'embedded.mobileprovision'));
// Copy www dir recursively
var code;
-if(!!COPY_HIDDEN) {
+if (COPY_HIDDEN) {
code = shell.exec('rsync -Lra "' + srcDir + '" "' + dstDir + '"').code;
} else {
code = shell.exec('rsync -Lra --exclude="- .*" "' + srcDir + '" "' + dstDir + '"').code;
}
-if(code !== 0) {
+if (code !== 0) {
console.error('Error occurred on copying www. Code: ' + code);
process.exit(3);
}
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/plugman/Plugman.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/plugman/Plugman.js b/bin/templates/scripts/cordova/lib/plugman/Plugman.js
index 1a51fe6..b73d936 100644
--- a/bin/templates/scripts/cordova/lib/plugman/Plugman.js
+++ b/bin/templates/scripts/cordova/lib/plugman/Plugman.js
@@ -17,8 +17,6 @@
under the License.
*/
-/*jshint node: true*/
-
var Q = require('q');
var path = require('path');
var fs = require('fs');
@@ -31,7 +29,7 @@ var configMunger = require('../configMunger');
var projectFile = require('../projectFile');
var pluginHandlers = require('./pluginHandlers');
-function Plugman(locations, events) {
+function Plugman (locations, events) {
this.locations = locations;
this.events = events;
@@ -43,7 +41,7 @@ function Plugman(locations, events) {
// shared Plugman instance
var _instance = null;
-Plugman.get = function(locations, events) {
+Plugman.get = function (locations, events) {
if (!_instance) {
_instance = new Plugman(locations, events);
@@ -57,8 +55,7 @@ module.exports = Plugman;
Plugman.prototype.addPlugin = function (plugin, installOptions) {
- if (!plugin || plugin.constructor.name !== 'PluginInfo')
- return Q.reject(new CordovaError('The parameter is incorrect. The first parameter to addPlugin should be a PluginInfo instance'));
+ if (!plugin || plugin.constructor.name !== 'PluginInfo') { return Q.reject(new CordovaError('The parameter is incorrect. The first parameter to addPlugin should be a PluginInfo instance')); }
installOptions = installOptions || {};
installOptions.variables = installOptions.variables || {};
@@ -69,18 +66,14 @@ Plugman.prototype.addPlugin = function (plugin, installOptions) {
var project = projectFile.parse(this.locations);
// gather all files needs to be handled during install
- plugin.getFilesAndFrameworks(this.platform)
- .concat(plugin.getAssets(this.platform))
- .concat(plugin.getJsModules(this.platform))
- .forEach(function(item) {
+ plugin.getFilesAndFrameworks(this.platform).concat(plugin.getAssets(this.platform)).concat(plugin.getJsModules(this.platform)).forEach(function (item) {
actions.push(actions.createAction(
pluginHandlers.getInstaller(item.itemType), [item, plugin, project, installOptions],
pluginHandlers.getUninstaller(item.itemType), [item, plugin, project, installOptions]));
});
// run through the action stack
- return actions.process(this.platform)
- .then(function () {
+ return actions.process(this.platform).then(function () {
if (project) {
project.write();
}
@@ -93,7 +86,7 @@ Plugman.prototype.addPlugin = function (plugin, installOptions) {
self._munger
// Ignore passed `is_top_level` option since platform itself doesn't know
// anything about managing dependencies - it's responsibility of caller.
- .add_plugin_changes(plugin, installOptions.variables, /*is_top_level=*/true, /*should_increment=*/true)
+ .add_plugin_changes(plugin, installOptions.variables, /* is_top_level= */true, /* should_increment= */true)
.save_all();
var targetDir = installOptions.usePlatformWww ?
@@ -105,26 +98,21 @@ Plugman.prototype.addPlugin = function (plugin, installOptions) {
};
Plugman.prototype.removePlugin = function (plugin, uninstallOptions) {
- if (!plugin || plugin.constructor.name !== 'PluginInfo')
- return Q.reject(new CordovaError('The parameter is incorrect. The first parameter to addPlugin should be a PluginInfo instance'));
+ if (!plugin || plugin.constructor.name !== 'PluginInfo') { return Q.reject(new CordovaError('The parameter is incorrect. The first parameter to addPlugin should be a PluginInfo instance')); }
var self = this;
var actions = new ActionStack();
var project = projectFile.parse(this.locations);
// queue up plugin files
- plugin.getFilesAndFrameworks(this.platform)
- .concat(plugin.getAssets(this.platform))
- .concat(plugin.getJsModules(this.platform))
- .forEach(function(item) {
+ plugin.getFilesAndFrameworks(this.platform).concat(plugin.getAssets(this.platform)).concat(plugin.getJsModules(this.platform)).forEach(function (item) {
actions.push(actions.createAction(
pluginHandlers.getUninstaller(item.itemType), [item, plugin, project, uninstallOptions],
pluginHandlers.getInstaller(item.itemType), [item, plugin, project, uninstallOptions]));
});
// run through the action stack
- return actions.process(this.platform)
- .then(function() {
+ return actions.process(this.platform).then(function () {
if (project) {
project.write();
}
@@ -132,7 +120,7 @@ Plugman.prototype.removePlugin = function (plugin, uninstallOptions) {
self._munger
// Ignore passed `is_top_level` option since platform itself doesn't know
// anything about managing dependencies - it's responsibility of caller.
- .remove_plugin_changes(plugin, /*is_top_level=*/true)
+ .remove_plugin_changes(plugin, /* is_top_level= */true)
.save_all();
var targetDir = uninstallOptions.usePlatformWww ?
@@ -152,28 +140,27 @@ Plugman.prototype.removePlugin = function (plugin, uninstallOptions) {
* @param {String} targetDir The directory, where updated cordova_plugins.js
* should be written to.
*/
-Plugman.prototype._addModulesInfo = function(plugin, targetDir) {
+Plugman.prototype._addModulesInfo = function (plugin, targetDir) {
var installedModules = this._platformJson.root.modules || [];
var installedPaths = installedModules.map(function (installedModule) {
return installedModule.file;
});
- var modulesToInstall = plugin.getJsModules(this.platform)
- .filter(function (moduleToInstall) {
+ var modulesToInstall = plugin.getJsModules(this.platform).filter(function (moduleToInstall) {
return installedPaths.indexOf(moduleToInstall.file) === -1;
}).map(function (moduleToInstall) {
- var moduleName = plugin.id + '.' + ( moduleToInstall.name || moduleToInstall.src.match(/([^\/]+)\.js/)[1] );
+ var moduleName = plugin.id + '.' + (moduleToInstall.name || moduleToInstall.src.match(/([^\/]+)\.js/)[1]); /* eslint no-useless-escape : 0 */
var obj = {
file: ['plugins', plugin.id, moduleToInstall.src].join('/'),
id: moduleName,
pluginId: plugin.id
};
if (moduleToInstall.clobbers.length > 0) {
- obj.clobbers = moduleToInstall.clobbers.map(function(o) { return o.target; });
+ obj.clobbers = moduleToInstall.clobbers.map(function (o) { return o.target; });
}
if (moduleToInstall.merges.length > 0) {
- obj.merges = moduleToInstall.merges.map(function(o) { return o.target; });
+ obj.merges = moduleToInstall.merges.map(function (o) { return o.target; });
}
if (moduleToInstall.runs) {
obj.runs = true;
@@ -203,8 +190,7 @@ Plugman.prototype._writePluginModules = function (targetDir) {
final_contents += 'module.exports.metadata = \n';
final_contents += '// TOP OF METADATA\n';
- var pluginMetadata = Object.keys(this._platformJson.root.installed_plugins)
- .reduce(function (metadata, plugin) {
+ var pluginMetadata = Object.keys(this._platformJson.root.installed_plugins).reduce(function (metadata, plugin) {
metadata[plugin] = self._platformJson.root.installed_plugins[plugin].version;
return metadata;
}, {});
@@ -226,15 +212,13 @@ Plugman.prototype._writePluginModules = function (targetDir) {
* @param {String} targetDir The directory, where updated cordova_plugins.js
* should be written to.
*/
-Plugman.prototype._removeModulesInfo = function(plugin, targetDir) {
+Plugman.prototype._removeModulesInfo = function (plugin, targetDir) {
var installedModules = this._platformJson.root.modules || [];
- var modulesToRemove = plugin.getJsModules(this.platform)
- .map(function (jsModule) {
- return ['plugins', plugin.id, jsModule.src].join('/');
+ var modulesToRemove = plugin.getJsModules(this.platform).map(function (jsModule) {
+ return ['plugins', plugin.id, jsModule.src].join('/');
});
- var updatedModules = installedModules
- .filter(function (installedModule) {
+ var updatedModules = installedModules.filter(function (installedModule) {
return (modulesToRemove.indexOf(installedModule.file) === -1);
});
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js b/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js
index 3065713..0e13099 100644
--- a/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js
+++ b/bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js
@@ -29,43 +29,43 @@ var keep_these_frameworks = [
];
var handlers = {
- 'source-file':{
- install:function(obj, plugin, project, options) {
+ 'source-file': {
+ install: function (obj, plugin, project, options) {
installHelper('source-file', obj, plugin.dir, project.projectDir, plugin.id, options, project);
},
- uninstall:function(obj, plugin, project, options) {
+ uninstall: function (obj, plugin, project, options) {
uninstallHelper('source-file', obj, project.projectDir, plugin.id, options, project);
}
},
- 'header-file':{
- install:function(obj, plugin, project, options) {
+ 'header-file': {
+ install: function (obj, plugin, project, options) {
installHelper('header-file', obj, plugin.dir, project.projectDir, plugin.id, options, project);
},
- uninstall:function(obj, plugin, project, options) {
+ uninstall: function (obj, plugin, project, options) {
uninstallHelper('header-file', obj, project.projectDir, plugin.id, options, project);
}
},
- 'resource-file':{
- install:function(obj, plugin, project, options) {
- var src = obj.src,
- srcFile = path.resolve(plugin.dir, src),
- destFile = path.resolve(project.resources_dir, path.basename(src));
+ 'resource-file': {
+ install: function (obj, plugin, project, options) {
+ var src = obj.src;
+ var srcFile = path.resolve(plugin.dir, src);
+ var destFile = path.resolve(project.resources_dir, path.basename(src));
if (!fs.existsSync(srcFile)) throw new CordovaError('cannot find "' + srcFile + '" osx <resource-file>');
if (fs.existsSync(destFile)) throw new CordovaError('target destination "' + destFile + '" already exists');
project.xcode.addResourceFile(path.join('Resources', path.basename(src)));
shell.cp('-R', srcFile, project.resources_dir);
},
- uninstall:function(obj, plugin, project, options) {
- var src = obj.src,
- destFile = path.resolve(project.resources_dir, path.basename(src));
+ uninstall: function (obj, plugin, project, options) {
+ var src = obj.src;
+ var destFile = path.resolve(project.resources_dir, path.basename(src));
project.xcode.removeResourceFile(path.join('Resources', path.basename(src)));
shell.rm('-rf', destFile);
}
},
- 'framework':{ // CB-5238 custom frameworks only
- install:function(obj, plugin, project, options) {
- var src = obj.src,
- custom = obj.custom;
+ 'framework': { // CB-5238 custom frameworks only
+ install: function (obj, plugin, project, options) {
+ var src = obj.src;
+ var custom = obj.custom;
if (!custom) {
if (keep_these_frameworks.indexOf(src) < 0) {
@@ -75,8 +75,8 @@ var handlers = {
return;
}
- var srcFile = path.resolve(plugin.dir, src),
- targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
+ var srcFile = path.resolve(plugin.dir, src);
+ var targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
if (!fs.existsSync(srcFile)) throw new CordovaError('cannot find "' + srcFile + '" osx <framework>');
if (fs.existsSync(targetDir)) throw new CordovaError('target destination "' + targetDir + '" already exists');
shell.mkdir('-p', path.dirname(targetDir));
@@ -87,7 +87,7 @@ var handlers = {
project.xcode.addToPbxEmbedFrameworksBuildPhase(pbxFile);
}
},
- uninstall:function(obj, plugin, project, options) {
+ uninstall: function (obj, plugin, project, options) {
var src = obj.src;
if (!obj.custom) {
@@ -103,8 +103,8 @@ var handlers = {
return;
}
- var targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src)),
- pbxFile = project.xcode.removeFramework(targetDir, {customFramework: true});
+ var targetDir = path.resolve(project.plugins_dir, plugin.id, path.basename(src));
+ var pbxFile = project.xcode.removeFramework(targetDir, {customFramework: true});
if (pbxFile) {
project.xcode.removeFromPbxEmbedFrameworksBuildPhase(pbxFile);
}
@@ -112,15 +112,15 @@ var handlers = {
}
},
'lib-file': {
- install:function(obj, plugin, project, options) {
+ install: function (obj, plugin, project, options) {
events.emit('verbose', 'lib-file.install is not supported for osx');
},
- uninstall:function(obj, plugin, project, options) {
+ uninstall: function (obj, plugin, project, options) {
events.emit('verbose', 'lib-file.uninstall is not supported for osx');
}
},
- 'asset':{
- install:function(obj, plugin, project, options) {
+ 'asset': {
+ install: function (obj, plugin, project, options) {
if (!obj.src) {
throw new CordovaError('<asset> tag without required "src" attribute. plugin=' + plugin.dir);
}
@@ -132,7 +132,7 @@ var handlers = {
copyFile(plugin.dir, obj.src, www, obj.target);
},
- uninstall:function(obj, plugin, project, options) {
+ uninstall: function (obj, plugin, project, options) {
var target = obj.target;
if (!target) {
@@ -179,7 +179,7 @@ module.exports.getInstaller = function (type) {
events.emit('warn', '<' + type + '> is not supported for osx plugins');
};
-module.exports.getUninstaller = function(type) {
+module.exports.getUninstaller = function (type) {
if (handlers[type] && handlers[type].uninstall) {
return handlers[type].uninstall;
}
@@ -187,7 +187,7 @@ module.exports.getUninstaller = function(type) {
events.emit('warn', '<' + type + '> is not supported for osx plugins');
};
-function installHelper(type, obj, plugin_dir, project_dir, plugin_id, options, project) {
+function installHelper (type, obj, plugin_dir, project_dir, plugin_id, options, project) {
var srcFile = path.resolve(plugin_dir, obj.src);
var targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
var destFile = path.join(targetDir, path.basename(obj.src));
@@ -209,19 +209,19 @@ function installHelper(type, obj, plugin_dir, project_dir, plugin_id, options, p
project_ref = 'Plugins/' + fixPathSep(path.relative(project.plugins_dir, destFile));
}
- if (type == 'header-file') {
+ if (type === 'header-file') {
project.xcode.addHeaderFile(project_ref);
} else if (obj.framework) {
var opt = { weak: obj.weak };
var project_relative = path.join(path.basename(project.xcode_path), project_ref);
project.xcode.addFramework(project_relative, opt);
- project.xcode.addToLibrarySearchPaths({path:project_ref});
+ project.xcode.addToLibrarySearchPaths({path: project_ref});
} else {
- project.xcode.addSourceFile(project_ref, obj.compilerFlags ? {compilerFlags:obj.compilerFlags} : {});
+ project.xcode.addSourceFile(project_ref, obj.compilerFlags ? {compilerFlags: obj.compilerFlags} : {});
}
}
-function uninstallHelper(type, obj, project_dir, plugin_id, options, project) {
+function uninstallHelper (type, obj, project_dir, plugin_id, options, project) {
var targetDir = path.resolve(project.plugins_dir, plugin_id, obj.targetDir || '');
var destFile = path.join(targetDir, path.basename(obj.src));
@@ -236,19 +236,19 @@ function uninstallHelper(type, obj, project_dir, plugin_id, options, project) {
shell.rm('-rf', targetDir);
- if (type == 'header-file') {
+ if (type === 'header-file') {
project.xcode.removeHeaderFile(project_ref);
} else if (obj.framework) {
var project_relative = path.join(path.basename(project.xcode_path), project_ref);
project.xcode.removeFramework(project_relative);
- project.xcode.removeFromLibrarySearchPaths({path:project_ref});
+ project.xcode.removeFromLibrarySearchPaths({path: project_ref});
} else {
project.xcode.removeSourceFile(project_ref);
}
}
-var pathSepFix = new RegExp(path.sep.replace(/\\/,'\\\\'),'g');
-function fixPathSep(file) {
+var pathSepFix = new RegExp(path.sep.replace(/\\/, '\\\\'), 'g');
+function fixPathSep (file) {
return file.replace(pathSepFix, '/');
}
@@ -259,14 +259,12 @@ function copyFile (plugin_dir, src, project_dir, dest, link) {
// check that src path is inside plugin directory
var real_path = fs.realpathSync(src);
var real_plugin_path = fs.realpathSync(plugin_dir);
- if (real_path.indexOf(real_plugin_path) !== 0)
- throw new CordovaError('"' + src + '" not located within plugin!');
+ if (real_path.indexOf(real_plugin_path) !== 0) { throw new CordovaError('"' + src + '" not located within plugin!'); }
dest = path.resolve(project_dir, dest);
// check that dest path is located in project directory
- if (dest.indexOf(project_dir) !== 0)
- throw new CordovaError('"' + dest + '" not located within project!');
+ if (dest.indexOf(project_dir) !== 0) { throw new CordovaError('"' + dest + '" not located within project!'); }
shell.mkdir('-p', path.dirname(dest));
@@ -274,7 +272,7 @@ function copyFile (plugin_dir, src, project_dir, dest, link) {
fs.symlinkSync(path.relative(path.dirname(dest), src), dest);
} else if (fs.statSync(src).isDirectory()) {
// XXX shelljs decides to create a directory when -R|-r is used which sucks. http://goo.gl/nbsjq
- shell.cp('-Rf', src+'/*', dest);
+ shell.cp('-Rf', src + '/*', dest);
} else {
shell.cp('-f', src, dest);
}
@@ -283,8 +281,7 @@ function copyFile (plugin_dir, src, project_dir, dest, link) {
// Same as copy file but throws error if target exists
function copyNewFile (plugin_dir, src, project_dir, dest, link) {
var target_path = path.resolve(project_dir, dest);
- if (fs.existsSync(target_path))
- throw new CordovaError('"' + target_path + '" already exists!');
+ if (fs.existsSync(target_path)) { throw new CordovaError('"' + target_path + '" already exists!'); }
copyFile(plugin_dir, src, project_dir, dest, !!link);
}
@@ -310,8 +307,8 @@ function removeFileAndParents (baseDir, destFile, stopper) {
// check if directory is empty
var curDir = path.dirname(file);
- while(curDir !== path.resolve(baseDir, stopper)) {
- if(fs.existsSync(curDir) && fs.readdirSync(curDir).length === 0) {
+ while (curDir !== path.resolve(baseDir, stopper)) {
+ if (fs.existsSync(curDir) && fs.readdirSync(curDir).length === 0) {
fs.rmdirSync(curDir);
curDir = path.resolve(curDir, '..');
} else {
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/prepare.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/prepare.js b/bin/templates/scripts/cordova/lib/prepare.js
index b090e6a..636492b 100644
--- a/bin/templates/scripts/cordova/lib/prepare.js
+++ b/bin/templates/scripts/cordova/lib/prepare.js
@@ -31,7 +31,7 @@ var ConfigParser = require('cordova-common').ConfigParser;
var CordovaError = require('cordova-common').CordovaError;
var configMunger = require('./configMunger');
-/*jshint sub:true*/
+/* jshint sub:true */
module.exports.prepare = function (cordovaProject) {
@@ -41,15 +41,12 @@ module.exports.prepare = function (cordovaProject) {
configMunger.get(this.locations.root), this.locations);
// Update own www dir with project's www assets and plugins' assets and js-files
- return Q.when(updateWww(cordovaProject, this.locations))
- .then(function () {
+ return Q.when(updateWww(cordovaProject, this.locations)).then(function () {
// update project according to config.xml changes.
return updateProject(self._config, self.locations);
- })
- .then(function () {
+ }).then(function () {
handleIcons(cordovaProject.projectConfig, self.locations.xcodeCordovaProj);
- })
- .then(function () {
+ }).then(function () {
self.events.emit('verbose', 'updated project successfully');
});
};
@@ -68,7 +65,7 @@ module.exports.prepare = function (cordovaProject) {
* represents current project's configuration. When returned, the
* configuration is already dumped to appropriate config.xml file.
*/
-function updateConfigFile(sourceConfig, configMunger, locations) {
+function updateConfigFile (sourceConfig, configMunger, locations) {
events.emit('verbose', 'Generating config.xml from defaults for platform "osx"');
// First cleanup current config and merge project's one into own
@@ -82,7 +79,7 @@ function updateConfigFile(sourceConfig, configMunger, locations) {
// Merge changes from app's config.xml into platform's one
var config = new ConfigParser(locations.configXml);
xmlHelpers.mergeXml(sourceConfig.doc.getroot(),
- config.doc.getroot(), 'osx', /*clobber=*/true);
+ config.doc.getroot(), 'osx', /* clobber= */true);
config.write();
return config;
@@ -94,10 +91,10 @@ function updateConfigFile(sourceConfig, configMunger, locations) {
* the platform 'www' folder
*
* @param {Object} cordovaProject An object which describes cordova project.
- * @param {Object} destinations An object that contains destination
+ * @param {Object} destinations An object that contains destination
* paths for www files.
*/
-function updateWww(cordovaProject, destinations) {
+function updateWww (cordovaProject, destinations) {
shell.rm('-rf', destinations.www);
shell.mkdir('-p', destinations.www);
// Copy source files from project's www directory
@@ -121,7 +118,7 @@ function updateWww(cordovaProject, destinations) {
* be used to update project
* @param {Object} locations A map of locations for this platform (In/Out)
*/
-function updateProject(platformConfig, locations) {
+function updateProject (platformConfig, locations) {
// CB-6992 it is necessary to normalize characters
// because node and shell scripts handles unicode symbols differently
@@ -158,19 +155,19 @@ function updateProject(platformConfig, locations) {
}
var info_contents = plist.build(infoPlist);
- info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
+ info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g, '<string></string>');
fs.writeFileSync(plistFile, info_contents, 'utf-8');
events.emit('verbose', 'Wrote out OSX Bundle Identifier to "' + pkg + '"');
events.emit('verbose', 'Wrote out OSX Bundle Version to "' + version + '"');
- return handleBuildSettings(platformConfig, locations).then(function() {
- if (name == originalName) {
+ return handleBuildSettings(platformConfig, locations).then(function () {
+ if (name === originalName) {
events.emit('verbose', 'OSX Product Name has not changed (still "' + originalName + '")');
return Q();
}
// Update product name inside pbxproj file
- var proj = new xcode.project(locations.pbxproj);
+ var proj = new xcode.project(locations.pbxproj); // eslint-disable-line
try {
proj.parseSync();
} catch (err) {
@@ -183,8 +180,8 @@ function updateProject(platformConfig, locations) {
// Move the xcodeproj and other name-based dirs over.
shell.mv(path.join(locations.xcodeCordovaProj, originalName + '-Info.plist'), path.join(locations.xcodeCordovaProj, name + '-Info.plist'));
shell.mv(path.join(locations.xcodeCordovaProj, originalName + '-Prefix.pch'), path.join(locations.xcodeCordovaProj, name + '-Prefix.pch'));
- // CB-8914 remove userdata otherwise project is un-usable in xcode
- shell.rm('-rf',path.join(locations.xcodeProjDir,'xcuserdata/'));
+ // CB-8914 remove userdata otherwise project is un-usable in xcode
+ shell.rm('-rf', path.join(locations.xcodeProjDir, 'xcuserdata/'));
shell.mv(locations.xcodeProjDir, path.join(locations.root, name + '.xcodeproj'));
shell.mv(locations.xcodeCordovaProj, path.join(locations.root, name));
@@ -197,18 +194,18 @@ function updateProject(platformConfig, locations) {
var pbx_contents = fs.readFileSync(locations.pbxproj, 'utf-8');
pbx_contents = pbx_contents.split(originalName).join(name);
fs.writeFileSync(locations.pbxproj, pbx_contents, 'utf-8');
- events.emit('verbose', 'Wrote out OSX Product Name and updated XCode project file names from "'+originalName+'" to "' + name + '".');
+ events.emit('verbose', 'Wrote out OSX Product Name and updated XCode project file names from "' + originalName + '" to "' + name + '".');
// in case of updated paths we return them back to
return Q();
});
}
-function handleBuildSettings(platformConfig, locations) {
+function handleBuildSettings (platformConfig, locations) {
// nothing to do
return Q();
}
-function handleIcons(projectConfig, platformRoot) {
+function handleIcons (projectConfig, platformRoot) {
// Update icons
var icons = projectConfig.getIcons('osx');
var appRoot = path.dirname(projectConfig.path);
@@ -226,7 +223,7 @@ function handleIcons(projectConfig, platformRoot) {
platformIcons.forEach(function (item) {
var icon = icons.getBySize(item.width, item.height) || icons.getDefault();
- if (icon){
+ if (icon) {
var src = path.join(appRoot, icon.src);
var dst = path.join(platformRoot, 'Images.xcassets/AppIcon.appiconset/', item.dest);
events.emit('verbose', 'Copying icon from ' + src + ' to ' + dst);
@@ -238,28 +235,26 @@ function handleIcons(projectConfig, platformRoot) {
/*
Parses all <access> and <allow-navigation> entries and consolidates duplicates (for ATS).
Returns an object with a Hostname as the key, and the value an object with properties:
- {
+ {
Hostname, // String
- NSExceptionAllowsInsecureHTTPLoads, // boolean
+ NSExceptionAllowsInsecureHTTPLoads, // boolean
NSIncludesSubdomains, // boolean
NSExceptionMinimumTLSVersion, // String
- NSExceptionRequiresForwardSecrecy // boolean
+ NSExceptionRequiresForwardSecrecy // boolean
}
*/
-function processAccessAndAllowNavigationEntries(config) {
+function processAccessAndAllowNavigationEntries (config) {
var accesses = config.getAccesses();
var allow_navigations = config.getAllowNavigations();
-
- return allow_navigations
+
// we concat allow_navigations and accesses, after processing accesses
- .concat(accesses.map(function(obj) {
+ return allow_navigations.concat(accesses.map(function (obj) {
// map accesses to a common key interface using 'href', not origin
obj.href = obj.origin;
delete obj.origin;
return obj;
- }))
// we reduce the array to an object with all the entries processed (key is Hostname)
- .reduce(function(previousReturn, currentElement) {
+ })).reduce(function (previousReturn, currentElement) {
var obj = parseWhitelistUrlForATS(currentElement.href, currentElement.minimum_tls_version, currentElement.requires_forward_secrecy);
if (obj) {
// we 'union' duplicate entries
@@ -267,40 +262,40 @@ function processAccessAndAllowNavigationEntries(config) {
if (!item) {
item = {};
}
- for(var o in obj) {
+ for (var o in obj) {
if (obj.hasOwnProperty(o)) {
item[o] = obj[o];
}
}
previousReturn[obj.Hostname] = item;
- }
+ }
return previousReturn;
}, {});
}
/*
Parses a URL and returns an object with these keys:
- {
+ {
Hostname, // String
NSExceptionAllowsInsecureHTTPLoads, // boolean (default: false)
NSIncludesSubdomains, // boolean (default: false)
NSExceptionMinimumTLSVersion, // String (default: 'TLSv1.2')
NSExceptionRequiresForwardSecrecy // boolean (default: true)
}
-
+
null is returned if the URL cannot be parsed, or is to be skipped for ATS.
*/
-function parseWhitelistUrlForATS(url, minimum_tls_version, requires_forward_secrecy) {
+function parseWhitelistUrlForATS (url, minimum_tls_version, requires_forward_secrecy) {
var href = URL.parse(url);
var retObj = {};
retObj.Hostname = href.hostname;
if (url === '*') {
return {
- Hostname : '*'
+ Hostname: '*'
};
}
-
+
// Guiding principle: we only set values in retObj if they are NOT the default
if (!retObj.Hostname) {
@@ -334,54 +329,51 @@ function parseWhitelistUrlForATS(url, minimum_tls_version, requires_forward_secr
// if the scheme is HTTP, we set NSExceptionAllowsInsecureHTTPLoads to YES. Default is NO
if (href.protocol === 'http:') {
retObj.NSExceptionAllowsInsecureHTTPLoads = true;
- }
- else if (!href.protocol && href.pathname.indexOf('*:/') === 0) { // wilcard in protocol
+ } else if (!href.protocol && href.pathname.indexOf('*:/') === 0) { // wilcard in protocol
retObj.NSExceptionAllowsInsecureHTTPLoads = true;
}
-
+
return retObj;
}
-
/*
App Transport Security (ATS) writer from <access> and <allow-navigation> tags
in config.xml
*/
-function writeATSEntries(config) {
- var pObj = processAccessAndAllowNavigationEntries(config);
-
+function writeATSEntries (config) {
+ var pObj = processAccessAndAllowNavigationEntries(config);
+
var ats = {};
- for(var hostname in pObj) {
+ for (var hostname in pObj) {
if (pObj.hasOwnProperty(hostname)) {
- if (hostname === '*') {
- ats['NSAllowsArbitraryLoads'] = true;
- continue;
- }
-
- var entry = pObj[hostname];
- var exceptionDomain = {};
-
- for(var key in entry) {
- if (entry.hasOwnProperty(key) && key !== 'Hostname') {
- exceptionDomain[key] = entry[key];
- }
- }
-
- if (!ats['NSExceptionDomains']) {
- ats['NSExceptionDomains'] = {};
- }
-
- ats['NSExceptionDomains'][hostname] = exceptionDomain;
+ if (hostname === '*') {
+ ats['NSAllowsArbitraryLoads'] = true;
+ continue;
+ }
+
+ var entry = pObj[hostname];
+ var exceptionDomain = {};
+
+ for (var key in entry) {
+ if (entry.hasOwnProperty(key) && key !== 'Hostname') {
+ exceptionDomain[key] = entry[key];
+ }
+ }
+
+ if (!ats['NSExceptionDomains']) {
+ ats['NSExceptionDomains'] = {};
+ }
+
+ ats['NSExceptionDomains'][hostname] = exceptionDomain;
}
}
-
+
return ats;
}
// Construct a default value for CFBundleVersion as the version with any
// -rclabel stripped=.
-function default_CFBundleVersion(version) {
+function default_CFBundleVersion (version) {
return version.split('-')[0];
}
-
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/projectFile.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/projectFile.js b/bin/templates/scripts/cordova/lib/projectFile.js
index 16b3822..0d0057b 100644
--- a/bin/templates/scripts/cordova/lib/projectFile.js
+++ b/bin/templates/scripts/cordova/lib/projectFile.js
@@ -17,7 +17,7 @@
under the License.
*/
-/*jshint node: true*/
+/* jshint node: true */
var xcode = require('xcode');
var plist = require('plist');
@@ -30,7 +30,7 @@ var CordovaError = require('cordova-common').CordovaError;
var cachedProjectFiles = {};
-function parseProjectFile(locations) {
+function parseProjectFile (locations) {
var project_dir = locations.root;
var pbxPath = locations.pbxproj;
@@ -61,24 +61,24 @@ function parseProjectFile(locations) {
var resourcesDir = path.resolve(xcode_dir, 'Resources');
cachedProjectFiles[project_dir] = {
- plugins_dir:pluginsDir,
- resources_dir:resourcesDir,
- xcode:xcodeproj,
- xcode_path:xcode_dir,
+ plugins_dir: pluginsDir,
+ resources_dir: resourcesDir,
+ xcode: xcodeproj,
+ xcode_path: xcode_dir,
pbx: pbxPath,
projectDir: project_dir,
platformWww: path.join(project_dir, 'platform_www'),
www: path.join(project_dir, 'www'),
write: function () {
fs.writeFileSync(pbxPath, xcodeproj.writeSync());
- if (Object.keys(this.frameworks).length === 0){
+ if (Object.keys(this.frameworks).length === 0) {
// If there is no framework references remain in the project, just remove this file
shell.rm('-rf', frameworks_file);
return;
}
fs.writeFileSync(frameworks_file, JSON.stringify(this.frameworks, null, 4));
},
- getPackageName: function() {
+ getPackageName: function () {
return plist.parse(fs.readFileSync(plist_file, 'utf8')).CFBundleIdentifier;
},
frameworks: frameworks
@@ -86,7 +86,7 @@ function parseProjectFile(locations) {
return cachedProjectFiles[project_dir];
}
-function purgeProjectFileCache(project_dir) {
+function purgeProjectFileCache (project_dir) {
delete cachedProjectFiles[project_dir];
}
@@ -108,7 +108,7 @@ xcode.project.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) {
xcode.project.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) {
var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
if (sources) {
- sources.files = _.reject(sources.files, function(file){
+ sources.files = _.reject(sources.files, function (file) {
return file.comment === longComment(file);
});
}
@@ -117,13 +117,13 @@ xcode.project.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file)
// special handlers to add frameworks to the 'Embed Frameworks' build phase, needed for custom frameworks
// see CB-9517. should probably be moved to node-xcode.
var util = require('util');
-function pbxBuildPhaseObj(file) {
+function pbxBuildPhaseObj (file) {
var obj = Object.create(null);
obj.value = file.uuid;
obj.comment = longComment(file);
return obj;
}
-function longComment(file) {
+function longComment (file) {
return util.format('%s in %s', file.basename, file.group);
}
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/run.js b/bin/templates/scripts/cordova/lib/run.js
index 0be098f..388d958 100644
--- a/bin/templates/scripts/cordova/lib/run.js
+++ b/bin/templates/scripts/cordova/lib/run.js
@@ -17,13 +17,13 @@
under the License.
*/
-/*jshint node: true*/
+/* jshint node: true */
-var Q = require('q'),
- path = require('path'),
- build = require('./build'),
- spawn = require('./spawn'),
- events = require('cordova-common').events;
+var Q = require('q');
+var path = require('path');
+var build = require('./build');
+var spawn = require('./spawn');
+var events = require('cordova-common').events;
var projectPath = path.join(__dirname, '..', '..');
@@ -47,9 +47,9 @@ module.exports.run = function (runOptions) {
* runs the app
* @return {Promise} Resolves when run succeeds otherwise rejects
*/
-function runApp(appDir, appName) {
+function runApp (appDir, appName) {
var binPath = path.join(appDir, 'Contents', 'MacOS', appName);
- events.emit('log','Starting: ' + binPath);
+ events.emit('log', 'Starting: ' + binPath);
return spawn(binPath);
}
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/bin/templates/scripts/cordova/lib/spawn.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/spawn.js b/bin/templates/scripts/cordova/lib/spawn.js
index 1cb3161..94ac253 100644
--- a/bin/templates/scripts/cordova/lib/spawn.js
+++ b/bin/templates/scripts/cordova/lib/spawn.js
@@ -17,32 +17,30 @@
under the License.
*/
-/*jshint node: true*/
-
-var Q = require('q'),
- proc = require('child_process');
+var Q = require('q');
+var proc = require('child_process');
/**
- * Run specified command with arguments
+ * Run specified command with arguments
* @param {String} cmd Command
* @param {Array} args Array of arguments that should be passed to command
* @param {String} opt_cwd Working directory for command
* @param {String} opt_verbosity Verbosity level for command stdout output, "verbose" by default
* @return {Promise} Promise either fullfilled or rejected with error code
*/
-module.exports = function(cmd, args, opt_cwd) {
+module.exports = function (cmd, args, opt_cwd) {
var d = Q.defer();
try {
var child = proc.spawn(cmd, args, {cwd: opt_cwd, stdio: 'inherit'});
- child.on('exit', function(code) {
+ child.on('exit', function (code) {
if (code) {
d.reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' + args);
} else {
d.resolve();
}
});
- } catch(e) {
+ } catch (e) {
console.error('error caught: ' + e);
d.reject(e);
}
http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/34d879e0/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 3ad74ce..dcac015 100644
--- a/package.json
+++ b/package.json
@@ -1,56 +1,4 @@
{
- "name": "cordova-osx",
- "version": "4.1.0-dev",
- "description": "cordova-osx release",
- "main": "bin/templates/scripts/cordova/Api.js",
- "repository": {
- "type": "git",
- "url": "https://github.com/apache/cordova-osx"
- },
- "keywords": [
- "osx",
- "cordova",
- "apache",
- "ecosystem:cordova",
- "cordova:platform"
- ],
- "scripts": {
- "test": "npm run jshint && npm run jasmine",
- "jasmine": "npm run objc-tests && npm run jasmine-tests",
- "objc-tests": "jasmine-node --captureExceptions --color tests/spec/cordovalib.spec.js",
- "jasmine-tests": "jasmine-node --captureExceptions --color tests/spec/create.spec.js tests/spec/platform.spec.js",
- "jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint tests"
- },
- "author": "Apache Software Foundation",
- "license": "Apache Version 2.0",
- "dependencies": {
- "cordova-common": "^1.0.0",
- "nopt": "^3.0.6",
- "q": "^1.4.1",
- "shelljs": "^0.5.3",
- "underscore": "^1.8.3",
- "unorm": "^1.4.1",
- "xcode": "^0.8.3"
- },
- "bundledDependencies": [
- "cordova-common",
- "nopt",
- "q",
- "underscore",
- "unorm",
- "xcode",
- "shelljs"
- ],
- "devDependencies": {
- "jshint": "^2.6.0",
- "uncrustify": "^0.6.1",
- "tmp": "^0.0.26",
- "jasmine-node": "~1",
- "coffee-script": "^1.7.1",
- "nodeunit": "^0.8.7"
- }
-}
-=======
"name": "cordova-osx",
"version": "4.1.0-dev",
"description": "cordova-osx release",
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org