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:45:22 UTC
[5/5] ios commit: CB-12895 : removed jshint and added eslint
CB-12895 : removed jshint and added eslint
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/83435d56
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/83435d56
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/83435d56
Branch: refs/heads/master
Commit: 83435d56d0e7e71a5bbb744cf93684b7e42997f7
Parents: 26beb94
Author: Audrey So <au...@apache.org>
Authored: Thu Jun 15 10:56:59 2017 -0700
Committer: Audrey So <au...@apache.org>
Committed: Fri Jul 14 16:18:26 2017 -0700
----------------------------------------------------------------------
.eslintignore | 3 +
.eslintrc.yml | 10 +
.gitignore | 1 +
.jshintignore | 3 -
.jshintrc | 12 -
.travis.yml | 12 +-
CordovaLib/cordova.js | 2 -
appveyor.yml | 6 +-
bin/lib/create.js | 127 +++---
bin/templates/project/www/js/index.js | 10 +-
bin/templates/scripts/cordova/Api.js | 116 +++--
bin/templates/scripts/cordova/lib/Podfile.js | 136 +++---
bin/templates/scripts/cordova/lib/PodsJson.js | 34 +-
bin/templates/scripts/cordova/lib/build.js | 288 ++++++-------
bin/templates/scripts/cordova/lib/check_reqs.js | 119 +++---
bin/templates/scripts/cordova/lib/clean.js | 26 +-
.../scripts/cordova/lib/copy-www-build-step.js | 26 +-
bin/templates/scripts/cordova/lib/list-devices | 1 -
.../cordova/lib/list-emulator-build-targets | 1 -
.../scripts/cordova/lib/list-emulator-images | 1 -
.../scripts/cordova/lib/list-started-emulators | 1 -
.../cordova/lib/plugman/pluginHandlers.js | 116 +++--
bin/templates/scripts/cordova/lib/prepare.js | 310 +++++++-------
.../scripts/cordova/lib/projectFile.js | 24 +-
bin/templates/scripts/cordova/lib/run.js | 216 +++++-----
bin/templates/scripts/cordova/lib/spawn.js | 14 +-
bin/templates/scripts/cordova/lib/versions.js | 66 ++-
package.json | 12 +-
tests/.jshintrc | 12 -
tests/scripts/killsim.js | 6 +-
tests/spec/.eslintrc.yml | 2 +
tests/spec/create.spec.js | 43 +-
tests/spec/unit/Api.spec.js | 184 ++++----
tests/spec/unit/Plugman/common.spec.js | 52 +--
tests/spec/unit/Plugman/pluginHandler.spec.js | 258 ++++++------
tests/spec/unit/Podfile.spec.js | 250 ++++++-----
tests/spec/unit/PodsJson.spec.js | 320 +++++++-------
tests/spec/unit/build.spec.js | 44 +-
.../contents-json/empty.js | 240 +++++------
.../contents-json/single-2xanyany.js | 250 +++++------
.../contents-json/typical-universal.js | 270 ++++++------
.../contents-json/varied-device.js | 280 ++++++-------
.../contents-map/empty-map.js | 384 ++++++++---------
.../contents-map/single-2xanyany-map.js | 262 ++++++------
.../contents-map/typical-universal-map.js | 292 ++++++-------
.../contents-map/varied-device-map.js | 310 +++++++-------
.../www/dummyplugin.js | 3 +-
tests/spec/unit/lib/list-devices.spec.js | 16 +-
tests/spec/unit/lib/run.spec.js | 14 +-
tests/spec/unit/prepare.spec.js | 420 +++++++++----------
tests/spec/unit/preparePlatform.spec.js | 59 ++-
tests/spec/unit/projectFile.spec.js | 34 +-
52 files changed, 2829 insertions(+), 2869 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/.eslintignore
----------------------------------------------------------------------
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..1ec4bc1
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,3 @@
+bin/node_modules/*
+bin/templates/project/*
+tests/spec/unit/fixtures/*
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/.eslintrc.yml b/.eslintrc.yml
new file mode 100644
index 0000000..f6aae32
--- /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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 4e6a1e9..1bfa164 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ tmp
xcuserdata
console.log
node_modules/jshint
+node_modules/eslint
node_modules/jasmine-node
node_modules/rewire
node_modules/istanbul
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/.jshintignore
----------------------------------------------------------------------
diff --git a/.jshintignore b/.jshintignore
deleted file mode 100644
index 281391b..0000000
--- a/.jshintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bin/node_modules/*
-bin/templates/project/*
-tests/spec/unit/fixtures/*
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index d18f0a1..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "node": true
- , "bitwise": true
- , "undef": true
- , "trailing": true
- , "quotmark": true
- , "indent": 4
- , "unused": "vars"
- , "latedef": "nofunc"
- , "jasmine": true
- , "esversion": 6
-}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 16f480c..2866f35 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,10 +16,10 @@ install:
- npm install ios-deploy
- npm install -g codecov
script:
-- npm run jshint
-- npm run unit-tests
-- npm run e2e-tests
-- open -b com.apple.iphonesimulator
-- npm run objc-tests
-- npm run cover
+ - npm run unit-tests
+ - npm run e2e-tests
+ - open -b com.apple.iphonesimulator
+ - npm run objc-tests
+ - npm run cover
+ - npm run eslint
after_script: codecov
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 57b7d71..e4b4e24 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -22,8 +22,6 @@
var PLATFORM_VERSION_BUILD_LABEL = '4.5.0-dev';
// file: src/scripts/require.js
-/*jshint -W079 */
-/*jshint -W020 */
var require,
define;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/appveyor.yml
----------------------------------------------------------------------
diff --git a/appveyor.yml b/appveyor.yml
index 12836bb..c1b5952 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -7,12 +7,14 @@ install:
- ps: Install-Product node $env:nodejs_version
# Lines below required due to uncrustify installation failure on Windows
- npm install --prod
- - npm install jshint jasmine rewire
+ - npm install eslint eslint-config-semistandard jasmine rewire
+ - npm install eslint-config-standard eslint-plugin-import eslint-plugin-node
+ - npm install eslint-plugin-promise eslint-plugin-standard
build: off
test_script:
- node --version
- npm --version
- - npm run jshint
- npm run unit-tests
+ - npm run eslint
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 4633381..a96227b 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -19,25 +19,25 @@
under the License.
*/
-var shell = require('shelljs'),
- Q = require ('q'),
- path = require('path'),
- fs = require('fs'),
- xmlescape = require('xml-escape'),
- ROOT = path.join(__dirname, '..', '..'),
- events = require('cordova-common').events;
-
-function updateSubprojectHelp() {
+var shell = require('shelljs');
+var Q = require('q');
+var path = require('path');
+var fs = require('fs');
+var xmlescape = require('xml-escape');
+var ROOT = path.join(__dirname, '..', '..');
+var events = require('cordova-common').events;
+
+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 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'));
@@ -47,7 +47,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).
@@ -56,17 +56,17 @@ function copyJsAndCordovaLib(projectPath, projectName, use_shared) {
var r = path.join(projectPath, projectName);
shell.mkdir('-p', path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj'));
shell.cp('-f', path.join(r, '.gitignore'), projectPath);
- shell.cp('-rf',path.join(ROOT, 'CordovaLib', 'Classes'), path.join(projectPath, 'CordovaLib'));
+ shell.cp('-rf', path.join(ROOT, 'CordovaLib', 'Classes'), path.join(projectPath, 'CordovaLib'));
shell.cp('-f', path.join(ROOT, 'CordovaLib', 'VERSION'), path.join(projectPath, 'CordovaLib'));
shell.cp('-f', path.join(ROOT, 'CordovaLib', 'cordova.js'), path.join(projectPath, 'CordovaLib'));
shell.cp('-f', path.join(ROOT, 'CordovaLib', 'CordovaLib_Prefix.pch'), path.join(projectPath, 'CordovaLib'));
shell.cp('-f', path.join(ROOT, 'CordovaLib', 'CordovaLib.xcodeproj', 'project.pbxproj'), path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj'));
- update_cordova_subproject([path.join(r+'.xcodeproj', 'project.pbxproj'), path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj', 'project.pbxproj')]);
+ update_cordova_subproject([path.join(r + '.xcodeproj', 'project.pbxproj'), path.join(projectPath, 'CordovaLib', 'CordovaLib.xcodeproj', 'project.pbxproj')]);
}
});
}
-function copyScripts(projectPath, projectName) {
+function copyScripts (projectPath, projectName) {
var srcScriptsDir = path.join(ROOT, 'bin', 'templates', 'scripts', 'cordova');
var destScriptsDir = path.join(projectPath, 'cordova');
@@ -103,7 +103,7 @@ function copyScripts(projectPath, projectName) {
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(destScriptsDir, 'build-release.xcconfig'));
// 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);
});
}
@@ -116,27 +116,27 @@ function copyScripts(projectPath, projectName) {
* @param {String} project_template_dir path to cordova-ios template directory
* @parm {BOOL} use_cli true if cli project
*/
-function copyTemplateFiles(project_path, project_name, project_template_dir, package_name) {
+function copyTemplateFiles (project_path, project_name, project_template_dir, package_name) {
var r = path.join(project_path, project_name);
- shell.rm('-rf', path.join(r+'.xcodeproj'));
+ shell.rm('-rf', path.join(r + '.xcodeproj'));
shell.cp('-rf', path.join(project_template_dir, '__TEMP__.xcodeproj'), project_path);
- shell.mv('-f', path.join(project_path, '__TEMP__.xcodeproj'), path.join(r+'.xcodeproj'));
+ shell.mv('-f', path.join(project_path, '__TEMP__.xcodeproj'), path.join(r + '.xcodeproj'));
- shell.rm('-rf', path.join(project_path, project_name+'.xcworkspace'));
+ shell.rm('-rf', path.join(project_path, project_name + '.xcworkspace'));
shell.cp('-rf', path.join(project_template_dir, '__TEMP__.xcworkspace'), project_path);
- shell.mv('-f', path.join(project_path, '__TEMP__.xcworkspace'), path.join(r+'.xcworkspace'));
- shell.mv('-f', path.join(r+'.xcworkspace', 'xcshareddata', 'xcschemes', '__PROJECT_NAME__.xcscheme'), path.join(r+'.xcworkspace', 'xcshareddata', 'xcschemes', project_name+'.xcscheme'));
+ shell.mv('-f', path.join(project_path, '__TEMP__.xcworkspace'), path.join(r + '.xcworkspace'));
+ shell.mv('-f', path.join(r + '.xcworkspace', 'xcshareddata', 'xcschemes', '__PROJECT_NAME__.xcscheme'), path.join(r + '.xcworkspace', 'xcshareddata', 'xcschemes', project_name + '.xcscheme'));
shell.rm('-rf', r);
shell.cp('-rf', path.join(project_template_dir, '__PROJECT_NAME__'), project_path);
shell.mv('-f', path.join(project_path, '__PROJECT_NAME__'), r);
- shell.mv('-f', path.join(r, '__PROJECT_NAME__-Info.plist'), path.join(r, project_name+'-Info.plist'));
- shell.mv('-f', path.join(r, '__PROJECT_NAME__-Prefix.pch'), path.join(r, project_name+'-Prefix.pch'));
+ shell.mv('-f', path.join(r, '__PROJECT_NAME__-Info.plist'), path.join(r, project_name + '-Info.plist'));
+ shell.mv('-f', path.join(r, '__PROJECT_NAME__-Prefix.pch'), path.join(r, project_name + '-Prefix.pch'));
shell.mv('-f', path.join(r, 'gitignore'), path.join(r, '.gitignore'));
- /*replace __PROJECT_NAME__ and --ID-- with ACTIVITY and ID strings, respectively, in:
+ /* replace __PROJECT_NAME__ and --ID-- with ACTIVITY and ID strings, respectively, in:
*
* - ./__PROJECT_NAME__.xcodeproj/project.pbxproj
* - ./__PROJECT_NAME__/Classes/AppDelegate.h
@@ -150,37 +150,36 @@ function copyTemplateFiles(project_path, project_name, project_template_dir, pac
// https://issues.apache.org/jira/browse/CB-12402 - Encode XML characters properly
var project_name_xml_esc = xmlescape(project_name);
- shell.sed('-i', /__PROJECT_NAME__/g, project_name_xml_esc, path.join(r+'.xcworkspace', 'contents.xcworkspacedata'));
- shell.sed('-i', /__PROJECT_NAME__/g, project_name_xml_esc, path.join(r+'.xcworkspace', 'xcshareddata', 'xcschemes', project_name +'.xcscheme'));
+ shell.sed('-i', /__PROJECT_NAME__/g, project_name_xml_esc, path.join(r + '.xcworkspace', 'contents.xcworkspacedata'));
+ shell.sed('-i', /__PROJECT_NAME__/g, project_name_xml_esc, path.join(r + '.xcworkspace', 'xcshareddata', 'xcschemes', project_name + '.xcscheme'));
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'));
shell.sed('-i', /__PROJECT_NAME__/g, project_name_esc, path.join(r, 'Classes', 'MainViewController.m'));
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', /--ID--/g, package_name, path.join(r, project_name+'-Info.plist'));
+ 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', /--ID--/g, package_name, path.join(r, project_name + '-Info.plist'));
}
-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));
}
@@ -196,20 +195,20 @@ function relpath(_path, start) {
* - <project_template_dir>: Path to a project template (override)
*
*/
-exports.createProject = function(project_path, package_name, project_name, opts) {
+exports.createProject = function (project_path, package_name, project_name, opts) {
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('Parent directory "' + project_parent + '" of given project path does not exist');
}
@@ -225,13 +224,13 @@ 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);
- //Copy project template files
+ // Copy project template files
copyTemplateFiles(project_path, project_name, project_template_dir, package_name);
// Copy xcconfig files
shell.cp('-rf', path.join(project_template_dir, '*.xcconfig'), project_path);
- //CordovaLib stuff
+ // CordovaLib stuff
copyJsAndCordovaLib(project_path, project_name, use_shared);
copyScripts(project_path, project_name);
@@ -239,9 +238,9 @@ exports.createProject = function(project_path, package_name, project_name, opts)
return Q.resolve();
};
-exports.updateProject = function(projectPath, opts) {
- var errorString =
- 'An in-place platform update is not supported. \n'+
+exports.updateProject = function (projectPath, opts) {
+ var errorString =
+ 'An in-place platform update is not supported. \n' +
'The `platforms` folder is always treated as a build artifact.\n' +
'To update your platform, you have to remove, then add your ios platform again.\n' +
'Make sure you save your plugins beforehand using `cordova plugin save`, and save a copy of the platform first if you had manual changes in it.\n' +
@@ -250,40 +249,38 @@ exports.updateProject = function(projectPath, opts) {
'\tcordova platform add ios\n'
;
- return Q.reject(errorString);
+ return Q.reject(errorString);
};
-function generateDoneMessage(type, link) {
+function generateDoneMessage (type, link) {
var pkg = require('../../package');
- var msg = 'iOS project ' + (type == 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
+ var msg = 'iOS 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');
@@ -291,7 +288,7 @@ function update_cordova_subproject(argv) {
if (lines[i].match(REGEX)) {
found = true;
newLine = lines[i].replace(/path = .+?;/, 'path = ' + subprojectPath + ';');
- newLine = newLine.replace(/sourceTree.+?;/, 'sourceTree = \"<group>\";');
+ newLine = newLine.replace(/sourceTree.+?;/, 'sourceTree = \"<group>\";'); /* eslint no-useless-escape : 0 */
if (!newLine.match('name')) {
newLine = newLine.replace('path = ', 'name = CordovaLib.xcodeproj; path = ');
}
@@ -301,8 +298,8 @@ function update_cordova_subproject(argv) {
// Patching pbxproj to replace copy www shell script with nodejs
// Don't forget to duplicate this in templates/__CLI__.xcodeproj/project.pbxproj and templates/__NON-CLI__.xcodeproj/project.pbxproj on later changes
- var copyWwwSh = 'cordova\/lib\/copy-www-build-step\.sh';
- 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';
+ var copyWwwSh = 'cordova\/lib\/copy-www-build-step\.sh'; /* eslint no-useless-escape : 0 */
+ 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'; /* eslint no-useless-escape : 0 */
shell.sed('-i', copyWwwSh, copyWwwJs, path.join(projectPath, 'project.pbxproj'));
if (!found) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/project/www/js/index.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/www/js/index.js b/bin/templates/project/www/js/index.js
index c31cd83..f6d6793 100755
--- a/bin/templates/project/www/js/index.js
+++ b/bin/templates/project/www/js/index.js
@@ -18,25 +18,25 @@
*/
var app = {
// Application Constructor
- initialize: function() {
+ initialize: function () {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
- bindEvents: function() {
+ bindEvents: function () {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
- onDeviceReady: function() {
+ onDeviceReady: function () {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
- receivedEvent: function(id) {
+ receivedEvent: function (id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
@@ -48,4 +48,4 @@ var app = {
}
};
-app.initialize();
\ No newline at end of file
+app.initialize();
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/scripts/cordova/Api.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/Api.js b/bin/templates/scripts/cordova/Api.js
index d7e84c0..dd50d11 100644
--- a/bin/templates/scripts/cordova/Api.js
+++ b/bin/templates/scripts/cordova/Api.js
@@ -17,7 +17,7 @@
under the License.
*/
-/*jslint node: true */
+/* jslint node: true */
var fs = require('fs');
var path = require('path');
@@ -31,7 +31,7 @@ var PluginManager = require('cordova-common').PluginManager;
var Q = require('q');
var util = require('util');
-function setupEvents(externalEventEmitter) {
+function setupEvents (externalEventEmitter) {
if (externalEventEmitter) {
// This will make the platform internal events visible outside
events.forwardEventsTo(externalEventEmitter);
@@ -53,7 +53,7 @@ function setupEvents(externalEventEmitter) {
* 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 || 'ios';
this.root = platformRootDir || path.resolve(__dirname, '..');
@@ -64,15 +64,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 = {
@@ -119,17 +119,16 @@ Api.createPlatform = function (destination, config, options, events) {
var result;
try {
result = require('../../../lib/create')
- .createProject(destination, config.packageName(), name, options)
- .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('ios', destination, events);
- });
- }
- catch(e) {
- events.emit('error','createPlatform is not callable from the iOS project API.');
- throw(e);
+ .createProject(destination, config.packageName(), name, options)
+ .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('ios', destination, events);
+ });
+ } catch (e) {
+ events.emit('error', 'createPlatform is not callable from the iOS project API.');
+ throw (e);
}
return result;
};
@@ -156,15 +155,14 @@ Api.updatePlatform = function (destination, options, events) {
var result;
try {
result = require('../../../lib/create')
- .updateProject(destination, options)
- .then(function () {
- var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
- return new PlatformApi('ios', destination, events);
- });
- }
- catch (e) {
- events.emit('error','updatePlatform is not callable from the iOS project API, you will need to do this manually.');
- throw(e);
+ .updateProject(destination, options)
+ .then(function () {
+ var PlatformApi = require(path.resolve(destination, 'cordova/Api'));
+ return new PlatformApi('ios', destination, events);
+ });
+ } catch (e) {
+ events.emit('error', 'updatePlatform is not callable from the iOS project API, you will need to do this manually.');
+ throw (e);
}
return result;
};
@@ -234,15 +232,15 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
return PluginManager.get(self.platform, self.locations, xcodeproj)
.addPlugin(plugin, installOptions)
- .then(function(){
+ .then(function () {
var frameworkTags = plugin.getFrameworks(self.platform);
- var frameworkPods = frameworkTags.filter(function(obj){
- return (obj.type == 'podspec');
+ var frameworkPods = frameworkTags.filter(function (obj) {
+ return (obj.type === 'podspec');
});
return Q.resolve(frameworkPods);
})
- .then(function(frameworkPods) {
+ .then(function (frameworkPods) {
if (!(frameworkPods.length)) {
return Q.resolve();
}
@@ -256,9 +254,9 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
events.emit('verbose', 'Adding pods since the plugin contained <framework>(s) with type="podspec"');
var podsjsonFile = new PodsJson(path.join(project_dir, PodsJson.FILENAME));
- var podfileFile = new Podfile(path.join(project_dir, Podfile.FILENAME), project_name);
+ var podfileFile = new Podfile(path.join(project_dir, Podfile.FILENAME), project_name);
- frameworkPods.forEach(function(obj) {
+ frameworkPods.forEach(function (obj) {
var podJson = {
name: obj.src,
type: obj.type,
@@ -266,9 +264,9 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
};
var val = podsjsonFile.get(podJson.name);
- if (val) { // found
+ if (val) { // found
if (podJson.spec !== val.spec) { // exists, different spec, print warning
- events.emit('warn', plugin.id + ' depends on ' + podJson.name + '@' + podJson.spec + ', which conflicts with another plugin. ' + podJson.name + '@' + val.spec + ' is already installed and was not overwritten.');
+ events.emit('warn', plugin.id + ' depends on ' + podJson.name + '@' + podJson.spec + ', which conflicts with another plugin. ' + podJson.name + '@' + val.spec + ' is already installed and was not overwritten.');
}
// increment count, but don't add in Podfile because it already exists
podsjsonFile.increment(podJson.name);
@@ -317,15 +315,15 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
return PluginManager.get(self.platform, self.locations, xcodeproj)
.removePlugin(plugin, uninstallOptions)
- .then(function(){
+ .then(function () {
var frameworkTags = plugin.getFrameworks(self.platform);
- var frameworkPods = frameworkTags.filter(function(obj){
- return (obj.type == 'podspec');
+ var frameworkPods = frameworkTags.filter(function (obj) {
+ return (obj.type === 'podspec');
});
return Q.resolve(frameworkPods);
})
- .then(function(frameworkPods) {
+ .then(function (frameworkPods) {
if (!(frameworkPods.length)) {
return Q.resolve();
}
@@ -336,12 +334,12 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
var Podfile = require('./lib/Podfile').Podfile;
var PodsJson = require('./lib/PodsJson').PodsJson;
- events.emit('verbose', 'Adding pods since the plugin contained <framework>(s) with type=\"podspec\"');
+ events.emit('verbose', 'Adding pods since the plugin contained <framework>(s) with type=\"podspec\"'); /* eslint no-useless-escape : 0 */
var podsjsonFile = new PodsJson(path.join(project_dir, PodsJson.FILENAME));
- var podfileFile = new Podfile(path.join(project_dir, Podfile.FILENAME), project_name);
-
- frameworkPods.forEach(function(obj) {
+ var podfileFile = new Podfile(path.join(project_dir, Podfile.FILENAME), project_name);
+
+ frameworkPods.forEach(function (obj) {
var podJson = {
name: obj.src,
type: obj.type,
@@ -352,7 +350,7 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
if (val) { // found, decrement count
podsjsonFile.decrement(podJson.name);
} else { // not found (perhaps a sync error)
- var message = util.format('plugin \"%s\" podspec \"%s\" does not seem to be in pods.json, nothing to remove. Will attempt to remove from Podfile.', plugin.id, podJson.name);
+ var message = util.format('plugin \"%s\" podspec \"%s\" does not seem to be in pods.json, nothing to remove. Will attempt to remove from Podfile.', plugin.id, podJson.name); /* eslint no-useless-escape : 0 */
events.emit('verbose', message);
}
@@ -412,9 +410,9 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
Api.prototype.build = function (buildOptions) {
var self = this;
return check_reqs.run()
- .then(function () {
- return require('./lib/build').run.call(self, buildOptions);
- });
+ .then(function () {
+ return require('./lib/build').run.call(self, buildOptions);
+ });
};
/**
@@ -429,12 +427,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 check_reqs.run()
- .then(function () {
- return require('./lib/run').run.call(self, runOptions);
- });
+ .then(function () {
+ return require('./lib/run').run.call(self, runOptions);
+ });
};
/**
@@ -443,15 +441,15 @@ 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 check_reqs.run()
- .then(function () {
- return require('./lib/clean').run.call(self, cleanOptions);
- })
- .then(function () {
- return require('./lib/prepare').clean.call(self, cleanOptions);
- });
+ .then(function () {
+ return require('./lib/clean').run.call(self, cleanOptions);
+ })
+ .then(function () {
+ return require('./lib/prepare').clean.call(self, cleanOptions);
+ });
};
/**
@@ -462,7 +460,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 check_reqs.check_all();
};
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/scripts/cordova/lib/Podfile.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/Podfile.js b/bin/templates/scripts/cordova/lib/Podfile.js
index b648d37..9dc35cf 100644
--- a/bin/templates/scripts/cordova/lib/Podfile.js
+++ b/bin/templates/scripts/cordova/lib/Podfile.js
@@ -18,17 +18,17 @@
*/
'use strict';
-var fs = require('fs'),
- path = require('path'),
- util = require('util'),
- events = require('cordova-common').events,
- Q = require('q'),
- superspawn = require('cordova-common').superspawn,
- CordovaError = require('cordova-common').CordovaError;
+var fs = require('fs');
+var path = require('path');
+var util = require('util');
+var events = require('cordova-common').events;
+var Q = require('q');
+var superspawn = require('cordova-common').superspawn;
+var CordovaError = require('cordova-common').CordovaError;
Podfile.FILENAME = 'Podfile';
-function Podfile(podFilePath, projectName) {
+function Podfile (podFilePath, projectName) {
this.podToken = '##INSERT_POD##';
this.path = podFilePath;
@@ -54,12 +54,12 @@ function Podfile(podFilePath, projectName) {
this.write();
} else {
events.emit('verbose', 'Podfile found in platforms/ios');
- // parse for pods
+ // parse for pods
this.pods = this.__parseForPods(fs.readFileSync(this.path, 'utf8'));
}
}
-Podfile.prototype.__parseForPods = function(text) {
+Podfile.prototype.__parseForPods = function (text) {
// split by \n
var arr = text.split('\n');
@@ -70,38 +70,39 @@ Podfile.prototype.__parseForPods = function(text) {
var podRE = new RegExp('pod \'([^\']*)\'\\s*,?\\s*(.*)');
// only grab lines that don't have the pod spec'
- return arr.filter(function(line) {
+ return arr.filter(function (line) {
var m = podRE.exec(line);
return (m !== null);
})
- .reduce(function(obj, line){
- var m = podRE.exec(line);
+ .reduce(function (obj, line) {
+ var m = podRE.exec(line);
- if (m !== null) {
- // strip out any single quotes around the value m[2]
- var podSpec = m[2].replace(/^\'|\'$/g, '');
- obj[m[1]] = podSpec; // i.e pod 'Foo', '1.2' ==> { 'Foo' : '1.2'}
- }
+ if (m !== null) {
+ // strip out any single quotes around the value m[2]
+ var podSpec = m[2].replace(/^\'|\'$/g, ''); /* eslint no-useless-escape : 0 */
+ obj[m[1]] = podSpec; // i.e pod 'Foo', '1.2' ==> { 'Foo' : '1.2'}
+ }
- return obj;
- }, {});
+ return obj;
+ }, {});
};
-Podfile.prototype.getTemplate = function() {
+Podfile.prototype.getTemplate = function () {
return util.format(
- '# DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
+ '# DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
'platform :ios, \'8.0\'\n' +
'target \'%s\' do\n' +
'\tproject \'%s.xcodeproj\'\n' +
'%s\n' +
'end\n',
- this.projectName, this.projectName, this.podToken);
+ this.projectName, this.projectName, this.podToken);
};
-Podfile.prototype.addSpec = function(name, spec) {
+Podfile.prototype.addSpec = function (name, spec) {
name = name || '';
- spec = spec; // optional
+ // optional
+ spec = spec; /* eslint no-self-assign : 0 */
if (!name.length) { // blank names are not allowed
throw new CordovaError('Podfile addSpec: name is not specified.');
@@ -113,39 +114,39 @@ Podfile.prototype.addSpec = function(name, spec) {
events.emit('verbose', util.format('Added pod line for `%s`', name));
};
-Podfile.prototype.removeSpec = function(name) {
+Podfile.prototype.removeSpec = function (name) {
if (this.existsSpec(name)) {
delete this.pods[name];
this.__dirty = true;
}
-
+
events.emit('verbose', util.format('Removed pod line for `%s`', name));
};
-Podfile.prototype.getSpec = function(name) {
+Podfile.prototype.getSpec = function (name) {
return this.pods[name];
};
-Podfile.prototype.existsSpec = function(name) {
+Podfile.prototype.existsSpec = function (name) {
return (name in this.pods);
};
-Podfile.prototype.clear = function() {
+Podfile.prototype.clear = function () {
this.pods = {};
this.__dirty = true;
};
-Podfile.prototype.destroy = function() {
+Podfile.prototype.destroy = function () {
fs.unlinkSync(this.path);
events.emit('verbose', util.format('Deleted `%s`', this.path));
};
-Podfile.prototype.write = function() {
+Podfile.prototype.write = function () {
var text = this.getTemplate();
var self = this;
var podsString =
- Object.keys(this.pods).map(function(key) {
+ Object.keys(this.pods).map(function (key) {
var name = key;
var spec = self.pods[key];
@@ -160,8 +161,7 @@ Podfile.prototype.write = function() {
} else {
return util.format('\tpod \'%s\'', name);
}
- })
- .join('\n');
+ }).join('\n');
text = text.replace(this.podToken, podsString);
fs.writeFileSync(this.path, text, 'utf8');
@@ -170,16 +170,16 @@ Podfile.prototype.write = function() {
events.emit('verbose', 'Wrote to Podfile.');
};
-Podfile.prototype.isDirty = function() {
+Podfile.prototype.isDirty = function () {
return this.__dirty;
};
-Podfile.prototype.before_install = function(toolOptions) {
+Podfile.prototype.before_install = function (toolOptions) {
toolOptions = toolOptions || {};
// Template tokens in order: project name, project name, debug | release
var template =
- '// DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
+ '// DO NOT MODIFY -- auto-generated by Apache Cordova\n' +
'#include "Pods/Target Support Files/Pods-%s/Pods-%s.%s.xcconfig"';
var debugContents = util.format(template, this.projectName, this.projectName, 'debug');
@@ -194,7 +194,7 @@ Podfile.prototype.before_install = function(toolOptions) {
return Q.resolve(toolOptions);
};
-Podfile.prototype.install = function(requirementsCheckerFunction) {
+Podfile.prototype.install = function (requirementsCheckerFunction) {
var opts = {};
opts.cwd = path.join(this.path, '..'); // parent path of this Podfile
opts.stdio = 'pipe';
@@ -206,34 +206,34 @@ Podfile.prototype.install = function(requirementsCheckerFunction) {
}
return requirementsCheckerFunction()
- .then(function(toolOptions) {
- return self.before_install(toolOptions);
- })
- .then(function(toolOptions) {
- if (toolOptions.ignore) {
- events.emit('verbose', '==== pod install start ====\n');
- events.emit('verbose', toolOptions.ignoreMessage);
- return Q.resolve();
- } else {
- return superspawn.spawn('pod', ['install', '--verbose'], opts)
- .progress(function (stdio){
- if (stdio.stderr) { console.error(stdio.stderr); }
- if (stdio.stdout) {
- if (first) {
- events.emit('verbose', '==== pod install start ====\n');
- first = false;
- }
- events.emit('verbose', stdio.stdout);
- }
- });
- }
- })
- .then(function() { // done
- events.emit('verbose', '==== pod install end ====\n');
- })
- .fail(function(error){
- throw error;
- });
+ .then(function (toolOptions) {
+ return self.before_install(toolOptions);
+ })
+ .then(function (toolOptions) {
+ if (toolOptions.ignore) {
+ events.emit('verbose', '==== pod install start ====\n');
+ events.emit('verbose', toolOptions.ignoreMessage);
+ return Q.resolve();
+ } else {
+ return superspawn.spawn('pod', ['install', '--verbose'], opts)
+ .progress(function (stdio) {
+ if (stdio.stderr) { console.error(stdio.stderr); }
+ if (stdio.stdout) {
+ if (first) {
+ events.emit('verbose', '==== pod install start ====\n');
+ first = false;
+ }
+ events.emit('verbose', stdio.stdout);
+ }
+ });
+ }
+ })
+ .then(function () { // done
+ events.emit('verbose', '==== pod install end ====\n');
+ })
+ .fail(function (error) {
+ throw error;
+ });
};
-module.exports.Podfile = Podfile;
\ No newline at end of file
+module.exports.Podfile = Podfile;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/scripts/cordova/lib/PodsJson.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/PodsJson.js b/bin/templates/scripts/cordova/lib/PodsJson.js
index b13a1af..0470527 100644
--- a/bin/templates/scripts/cordova/lib/PodsJson.js
+++ b/bin/templates/scripts/cordova/lib/PodsJson.js
@@ -17,15 +17,15 @@
under the License.
*/
-var fs = require('fs'),
- path = require('path'),
- util = require('util'),
- events = require('cordova-common').events,
- CordovaError = require('cordova-common').CordovaError;
+var fs = require('fs');
+var path = require('path');
+var util = require('util');
+var events = require('cordova-common').events;
+var CordovaError = require('cordova-common').CordovaError;
PodsJson.FILENAME = 'pods.json';
-function PodsJson(podsJsonPath) {
+function PodsJson (podsJsonPath) {
this.path = podsJsonPath;
this.contents = null;
this.__dirty = false;
@@ -41,18 +41,18 @@ function PodsJson(podsJsonPath) {
this.clear();
this.write();
} else {
- events.emit('verbose', 'pods.json found in platforms/ios');
+ events.emit('verbose', 'pods.json found in platforms/ios');
// load contents
this.contents = fs.readFileSync(this.path, 'utf8');
this.contents = JSON.parse(this.contents);
}
}
-PodsJson.prototype.get = function(name) {
+PodsJson.prototype.get = function (name) {
return this.contents[name];
};
-PodsJson.prototype.remove = function(name) {
+PodsJson.prototype.remove = function (name) {
if (this.contents[name]) {
delete this.contents[name];
this.__dirty = true;
@@ -60,17 +60,17 @@ PodsJson.prototype.remove = function(name) {
}
};
-PodsJson.prototype.clear = function() {
+PodsJson.prototype.clear = function () {
this.contents = {};
this.__dirty = true;
};
-PodsJson.prototype.destroy = function() {
+PodsJson.prototype.destroy = function () {
fs.unlinkSync(this.path);
events.emit('verbose', util.format('Deleted `%s`', this.path));
};
-PodsJson.prototype.write = function() {
+PodsJson.prototype.write = function () {
if (this.contents) {
fs.writeFileSync(this.path, JSON.stringify(this.contents, null, 4));
this.__dirty = false;
@@ -78,11 +78,11 @@ PodsJson.prototype.write = function() {
}
};
-PodsJson.prototype.set = function(name, type, spec, count) {
+PodsJson.prototype.set = function (name, type, spec, count) {
this.setJson(name, { name: name, type: type, spec: spec, count: count });
};
-PodsJson.prototype.increment = function(name) {
+PodsJson.prototype.increment = function (name) {
var val = this.get(name);
if (val) {
val.count++;
@@ -90,7 +90,7 @@ PodsJson.prototype.increment = function(name) {
}
};
-PodsJson.prototype.decrement = function(name) {
+PodsJson.prototype.decrement = function (name) {
var val = this.get(name);
if (val) {
val.count--;
@@ -102,13 +102,13 @@ PodsJson.prototype.decrement = function(name) {
}
};
-PodsJson.prototype.setJson = function(name, json) {
+PodsJson.prototype.setJson = function (name, json) {
this.contents[name] = json;
this.__dirty = true;
events.emit('verbose', util.format('Set pods.json for `%s`', name));
};
-PodsJson.prototype.isDirty = function() {
+PodsJson.prototype.isDirty = function () {
return this.__dirty;
};
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/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 e2b8312..d7c2cbe 100644
--- a/bin/templates/scripts/cordova/lib/build.js
+++ b/bin/templates/scripts/cordova/lib/build.js
@@ -17,15 +17,13 @@
* under the License.
*/
-/*jshint node: true*/
-
-var Q = require('q'),
- path = require('path'),
- shell = require('shelljs'),
- spawn = require('./spawn'),
- fs = require('fs'),
- plist = require('plist'),
- util = require('util');
+var Q = require('q');
+var path = require('path');
+var shell = require('shelljs');
+var spawn = require('./spawn');
+var fs = require('fs');
+var plist = require('plist');
+var util = require('util');
var check_reqs = require('./check_reqs');
@@ -35,41 +33,43 @@ var projectPath = path.join(__dirname, '..', '..');
var projectName = null;
// These are regular expressions to detect if the user is changing any of the built-in xcodebuildArgs
+/* eslint-disable no-useless-escape */
var buildFlagMatchers = {
- 'xcconfig' : /^\-xcconfig\s*(.*)$/,
- 'workspace' : /^\-workspace\s*(.*)/,
- 'scheme' : /^\-scheme\s*(.*)/,
- 'configuration' : /^\-configuration\s*(.*)/,
- 'sdk' : /^\-sdk\s*(.*)/,
- 'destination' : /^\-destination\s*(.*)/,
- 'archivePath' : /^\-archivePath\s*(.*)/,
- 'configuration_build_dir' : /^(CONFIGURATION_BUILD_DIR=.*)/,
- 'shared_precomps_dir' : /^(SHARED_PRECOMPS_DIR=.*)/
+ 'xcconfig': /^\-xcconfig\s*(.*)$/,
+ 'workspace': /^\-workspace\s*(.*)/,
+ 'scheme': /^\-scheme\s*(.*)/,
+ 'configuration': /^\-configuration\s*(.*)/,
+ 'sdk': /^\-sdk\s*(.*)/,
+ 'destination': /^\-destination\s*(.*)/,
+ 'archivePath': /^\-archivePath\s*(.*)/,
+ 'configuration_build_dir': /^(CONFIGURATION_BUILD_DIR=.*)/,
+ 'shared_precomps_dir': /^(SHARED_PRECOMPS_DIR=.*)/
};
+/* eslint-enable no-useless-escape */
/**
* Returns a promise that resolves to the default simulator target; the logic here
- * matches what `cordova emulate ios` does.
- *
+ * matches what `cordova emulate ios` does.
+ *
* The return object has two properties: `name` (the Xcode destination name),
* `identifier` (the simctl identifier), and `simIdentifier` (essentially the cordova emulate target)
- *
+ *
* @return {Promise}
*/
-function getDefaultSimulatorTarget() {
+function getDefaultSimulatorTarget () {
return require('./list-emulator-build-targets').run()
- .then(function (emulators) {
- var targetEmulator;
- if (emulators.length > 0) {
- targetEmulator = emulators[0];
- }
- emulators.forEach(function (emulator) {
- if (emulator.name.indexOf('iPhone') === 0) {
- targetEmulator = emulator;
+ .then(function (emulators) {
+ var targetEmulator;
+ if (emulators.length > 0) {
+ targetEmulator = emulators[0];
}
+ emulators.forEach(function (emulator) {
+ if (emulator.name.indexOf('iPhone') === 0) {
+ targetEmulator = emulator;
+ }
+ });
+ return targetEmulator;
});
- return targetEmulator;
- });
}
module.exports.run = function (buildOpts) {
@@ -85,126 +85,125 @@ module.exports.run = function (buildOpts) {
return Q.reject('Cannot specify "device" and "emulator" options together.');
}
- 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 contents = fs.readFileSync(buildOpts.buildConfig, 'utf-8');
var buildConfig = JSON.parse(contents.replace(/^\ufeff/, '')); // Remove BOM
- if(buildConfig.ios) {
+ if (buildConfig.ios) {
var buildType = buildOpts.release ? 'release' : 'debug';
var config = buildConfig.ios[buildType];
- if(config) {
+ if (config) {
['codeSignIdentity', 'codeSignResourceRules', 'provisioningProfile', 'developmentTeam', 'packageType', 'buildFlag'].forEach(
- function(key) {
+ function (key) {
buildOpts[key] = buildOpts[key] || config[key];
});
}
}
}
-return require('./list-devices').run()
- .then(function (devices) {
- if (devices.length > 0 && !(buildOpts.emulator)) {
- // we also explicitly set device flag in options as we pass
- // those parameters to other api (build as an example)
- buildOpts.device = true;
- return check_reqs.check_ios_deploy();
- }
- }).then(function () {
- // CB-12287: Determine the device we should target when building for a simulator
- if (!buildOpts.device) {
- var promise;
- if (buildOpts.target) {
- // a target was given to us, find the matching Xcode destination name
- promise = require('./list-emulator-build-targets').targetForSimIdentifier(buildOpts.target);
- } else {
- // no target provided, pick a default one (matching our emulator logic)
- promise = getDefaultSimulatorTarget();
+ return require('./list-devices').run()
+ .then(function (devices) {
+ if (devices.length > 0 && !(buildOpts.emulator)) {
+ // we also explicitly set device flag in options as we pass
+ // those parameters to other api (build as an example)
+ buildOpts.device = true;
+ return check_reqs.check_ios_deploy();
+ }
+ }).then(function () {
+ // CB-12287: Determine the device we should target when building for a simulator
+ if (!buildOpts.device) {
+ var promise;
+ if (buildOpts.target) {
+ // a target was given to us, find the matching Xcode destination name
+ promise = require('./list-emulator-build-targets').targetForSimIdentifier(buildOpts.target);
+ } else {
+ // no target provided, pick a default one (matching our emulator logic)
+ promise = getDefaultSimulatorTarget();
+ }
+ return promise.then(function (theTarget) {
+ emulatorTarget = theTarget.name;
+ events.emit('log', 'Building for ' + emulatorTarget + ' Simulator');
+ });
+ }
+ }).then(function () {
+ return check_reqs.run();
+ }).then(function () {
+ return findXCodeProjectIn(projectPath);
+ }).then(function (name) {
+ projectName = name;
+ var extraConfig = '';
+ if (buildOpts.codeSignIdentity) {
+ extraConfig += 'CODE_SIGN_IDENTITY = ' + buildOpts.codeSignIdentity + '\n';
+ extraConfig += 'CODE_SIGN_IDENTITY[sdk=iphoneos*] = ' + buildOpts.codeSignIdentity + '\n';
+ }
+ if (buildOpts.codeSignResourceRules) {
+ extraConfig += 'CODE_SIGN_RESOURCE_RULES_PATH = ' + buildOpts.codeSignResourceRules + '\n';
+ }
+ if (buildOpts.provisioningProfile) {
+ extraConfig += 'PROVISIONING_PROFILE = ' + buildOpts.provisioningProfile + '\n';
+ }
+ if (buildOpts.developmentTeam) {
+ extraConfig += 'DEVELOPMENT_TEAM = ' + buildOpts.developmentTeam + '\n';
+ }
+ return Q.nfcall(fs.writeFile, path.join(__dirname, '..', 'build-extras.xcconfig'), extraConfig, 'utf-8');
+ }).then(function () {
+ var configuration = buildOpts.release ? 'Release' : 'Debug';
+
+ events.emit('log', 'Building project: ' + path.join(projectPath, projectName + '.xcworkspace'));
+ events.emit('log', '\tConfiguration: ' + configuration);
+ events.emit('log', '\tPlatform: ' + (buildOpts.device ? 'device' : 'emulator'));
+
+ var buildOutputDir = path.join(projectPath, 'build', (buildOpts.device ? 'device' : 'emulator'));
+
+ // remove the build/device folder before building
+ return spawn('rm', [ '-rf', buildOutputDir ], projectPath)
+ .then(function () {
+ var xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, buildOpts.device, buildOpts.buildFlag, emulatorTarget);
+ return spawn('xcodebuild', xcodebuildArgs, projectPath);
+ });
+
+ }).then(function () {
+ if (!buildOpts.device || buildOpts.noSign) {
+ return;
}
- return promise.then(function(theTarget) {
- emulatorTarget = theTarget.name;
- events.emit('log', 'Building for ' + emulatorTarget + ' Simulator');
- });
- }
- }).then(function () {
- return check_reqs.run();
- }).then(function () {
- return findXCodeProjectIn(projectPath);
- }).then(function (name) {
- projectName = name;
- var extraConfig = '';
- if (buildOpts.codeSignIdentity) {
- extraConfig += 'CODE_SIGN_IDENTITY = ' + buildOpts.codeSignIdentity + '\n';
- extraConfig += 'CODE_SIGN_IDENTITY[sdk=iphoneos*] = ' + buildOpts.codeSignIdentity + '\n';
- }
- if (buildOpts.codeSignResourceRules) {
- extraConfig += 'CODE_SIGN_RESOURCE_RULES_PATH = ' + buildOpts.codeSignResourceRules + '\n';
- }
- if (buildOpts.provisioningProfile) {
- extraConfig += 'PROVISIONING_PROFILE = ' + buildOpts.provisioningProfile + '\n';
- }
- if (buildOpts.developmentTeam) {
- extraConfig += 'DEVELOPMENT_TEAM = ' + buildOpts.developmentTeam + '\n';
- }
- return Q.nfcall(fs.writeFile, path.join(__dirname, '..', 'build-extras.xcconfig'), extraConfig, 'utf-8');
- }).then(function () {
- var configuration = buildOpts.release ? 'Release' : 'Debug';
-
- events.emit('log','Building project: ' + path.join(projectPath, projectName + '.xcworkspace'));
- events.emit('log','\tConfiguration: ' + configuration);
- events.emit('log','\tPlatform: ' + (buildOpts.device ? 'device' : 'emulator'));
-
- var buildOutputDir = path.join(projectPath, 'build', (buildOpts.device ? 'device' : 'emulator'));
-
- // remove the build/device folder before building
- return spawn('rm', [ '-rf', buildOutputDir ], projectPath)
- .then(function() {
- var xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, buildOpts.device, buildOpts.buildFlag, emulatorTarget);
- return spawn('xcodebuild', xcodebuildArgs, projectPath);
- });
-
- }).then(function () {
- if (!buildOpts.device || buildOpts.noSign) {
- return;
- }
-
- var exportOptions = {'compileBitcode': false, 'method': 'development'};
- if (buildOpts.packageType) {
- exportOptions.method = buildOpts.packageType;
- }
+ var exportOptions = {'compileBitcode': false, 'method': 'development'};
- if (buildOpts.developmentTeam) {
- exportOptions.teamID = buildOpts.developmentTeam;
- }
+ if (buildOpts.packageType) {
+ exportOptions.method = buildOpts.packageType;
+ }
- var exportOptionsPlist = plist.build(exportOptions);
- var exportOptionsPath = path.join(projectPath, 'exportOptions.plist');
+ if (buildOpts.developmentTeam) {
+ exportOptions.teamID = buildOpts.developmentTeam;
+ }
- var buildOutputDir = path.join(projectPath, 'build', 'device');
+ var exportOptionsPlist = plist.build(exportOptions);
+ var exportOptionsPath = path.join(projectPath, 'exportOptions.plist');
+ var buildOutputDir = path.join(projectPath, 'build', 'device');
- function checkSystemRuby() {
- var ruby_cmd = shell.which('ruby');
+ function checkSystemRuby () {
+ var ruby_cmd = shell.which('ruby');
- if (ruby_cmd != '/usr/bin/ruby') {
- events.emit('warn', 'Non-system Ruby in use. This may cause packaging to fail.\n' +
- 'If you use RVM, please run `rvm use system`.\n' +
- 'If you use chruby, please run `chruby system`.');
- }
- }
+ if (ruby_cmd !== '/usr/bin/ruby') {
+ events.emit('warn', 'Non-system Ruby in use. This may cause packaging to fail.\n' +
+ 'If you use RVM, please run `rvm use system`.\n' +
+ 'If you use chruby, please run `chruby system`.');
+ }
+ }
- function packageArchive() {
- var xcodearchiveArgs = getXcodeArchiveArgs(projectName, projectPath, buildOutputDir, exportOptionsPath);
- return spawn('xcodebuild', xcodearchiveArgs, projectPath);
- }
+ function packageArchive () {
+ var xcodearchiveArgs = getXcodeArchiveArgs(projectName, projectPath, buildOutputDir, exportOptionsPath);
+ return spawn('xcodebuild', xcodearchiveArgs, projectPath);
+ }
- return Q.nfcall(fs.writeFile, exportOptionsPath, exportOptionsPlist, 'utf-8')
+ return Q.nfcall(fs.writeFile, exportOptionsPath, exportOptionsPlist, 'utf-8')
.then(checkSystemRuby)
.then(packageArchive);
- });
+ });
};
/**
@@ -212,7 +211,7 @@ return require('./list-devices').run()
* @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';
@@ -222,7 +221,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');
}
@@ -242,7 +241,7 @@ module.exports.findXCodeProjectIn = findXCodeProjectIn;
* @param {String} emulatorTarget Target for emulator (rather than default)
* @return {Array} Array of arguments that could be passed directly to spawn method
*/
-function getXcodeBuildArgs(projectName, projectPath, configuration, isDevice, buildFlags, emulatorTarget) {
+function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, buildFlags, emulatorTarget) {
var xcodebuildArgs;
var options;
var buildActions;
@@ -254,16 +253,16 @@ function getXcodeBuildArgs(projectName, projectPath, configuration, isDevice, bu
if (typeof buildFlags === 'string' || buildFlags instanceof String) {
parseBuildFlag(buildFlags, customArgs);
} else { // buildFlags is an Array of strings
- buildFlags.forEach( function(flag) {
+ buildFlags.forEach(function (flag) {
parseBuildFlag(flag, customArgs);
});
}
}
-
+
if (isDevice) {
options = [
'-xcconfig', customArgs.xcconfig || path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
- '-workspace', customArgs.workspace || projectName + '.xcworkspace',
+ '-workspace', customArgs.workspace || projectName + '.xcworkspace',
'-scheme', customArgs.scheme || projectName,
'-configuration', customArgs.configuration || configuration,
'-destination', customArgs.destination || 'generic/platform=iOS',
@@ -303,7 +302,6 @@ function getXcodeBuildArgs(projectName, projectPath, configuration, isDevice, bu
return xcodebuildArgs;
}
-
/**
* Returns array of arguments for xcodebuild
* @param {String} projectName Name of xcode project
@@ -312,16 +310,16 @@ function getXcodeBuildArgs(projectName, projectPath, configuration, isDevice, bu
* @param {String} exportOptionsPath Path to the exportOptions.plist file
* @return {Array} Array of arguments that could be passed directly to spawn method
*/
-function getXcodeArchiveArgs(projectName, projectPath, outputPath, exportOptionsPath) {
- return [
- '-exportArchive',
- '-archivePath', projectName + '.xcarchive',
- '-exportOptionsPlist', exportOptionsPath,
- '-exportPath', outputPath
- ];
+function getXcodeArchiveArgs (projectName, projectPath, outputPath, exportOptionsPath) {
+ return [
+ '-exportArchive',
+ '-archivePath', projectName + '.xcarchive',
+ '-exportOptionsPlist', exportOptionsPath,
+ '-exportPath', outputPath
+ ];
}
-function parseBuildFlag(buildFlag, args) {
+function parseBuildFlag (buildFlag, args) {
var matched;
for (var key in buildFlagMatchers) {
var found = buildFlag.match(buildFlagMatchers[key]);
@@ -336,7 +334,8 @@ function parseBuildFlag(buildFlag, args) {
if (!matched) {
// If the flag starts with a '-' then it is an xcodebuild built-in option or a
// user-defined setting. The regex makes sure that we don't split a user-defined
- // setting that is wrapped in quotes.
+ // setting that is wrapped in quotes.
+ /* eslint-disable no-useless-escape */
if (buildFlag[0] === '-' && !buildFlag.match(/^.*=(\".*\")|(\'.*\')$/)) {
args.otherFlags = args.otherFlags.concat(buildFlag.split(' '));
events.emit('warn', util.format('Adding xcodebuildArg: %s', buildFlag.split(' ')));
@@ -348,7 +347,7 @@ function parseBuildFlag(buildFlag, args) {
}
// help/usage function
-module.exports.help = function help() {
+module.exports.help = function help () {
console.log('');
console.log('Usage: build [--debug | --release] [--archs=\"<list of architectures...>\"]');
console.log(' [--device | --simulator] [--codeSignIdentity=\"<identity>\"]');
@@ -359,6 +358,7 @@ module.exports.help = function help() {
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.');
+ /* eslint-enable no-useless-escape */
// TODO: add support for building different archs
// console.log(" --archs : Builds project binaries for specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).");
console.log(' --device, --simulator');
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/scripts/cordova/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/check_reqs.js b/bin/templates/scripts/cordova/lib/check_reqs.js
index 97877af..e42b80a 100644
--- a/bin/templates/scripts/cordova/lib/check_reqs.js
+++ b/bin/templates/scripts/cordova/lib/check_reqs.js
@@ -16,12 +16,13 @@
specific language governing permissions and limitations
under the License.
*/
+
'use strict';
-const Q = require('q'),
- shell = require('shelljs'),
- util = require('util'),
- versions = require('./versions');
+const Q = require('q');
+const shell = require('shelljs');
+const util = require('util');
+const versions = require('./versions');
const SUPPORTED_OS_PLATFORMS = [ 'darwin' ];
@@ -67,20 +68,20 @@ module.exports.check_os = function () {
Q.reject('Cordova tooling for iOS requires Apple macOS');
};
-function os_platform_is_supported() {
- return (SUPPORTED_OS_PLATFORMS.indexOf(process.platform) != -1);
+function os_platform_is_supported () {
+ return (SUPPORTED_OS_PLATFORMS.indexOf(process.platform) !== -1);
}
-function check_cocoapod_tool(toolChecker) {
+function check_cocoapod_tool (toolChecker) {
toolChecker = toolChecker || checkTool;
if (os_platform_is_supported()) { // CB-12856
return toolChecker('pod', COCOAPODS_MIN_VERSION, COCOAPODS_NOT_FOUND_MESSAGE, 'CocoaPods');
} else {
- return Q.resolve({
- 'ignore': true,
+ return Q.resolve({
+ 'ignore': true,
'ignoreMessage': `CocoaPods check and installation ignored on ${process.platform}`
});
- }
+ }
}
/**
@@ -89,26 +90,26 @@ function check_cocoapod_tool(toolChecker) {
*/
module.exports.check_cocoapods_repo_size = function () {
return check_cocoapod_tool()
- .then(function(toolOptions) {
- // check size of ~/.cocoapods repo
- let commandString = util.format('du -sh %s/.cocoapods', process.env.HOME);
- let command = shell.exec(commandString, { silent:true });
- // command.output is e.g "750M path/to/.cocoapods", we just scan the number
- let size = toolOptions.ignore? 0 : parseFloat(command.output);
-
- if (toolOptions.ignore || command.code === 0) { // success, parse output
- return Q.resolve(size, toolOptions);
- } else { // error, perhaps not found
- return Q.reject(util.format('%s (%s)', COCOAPODS_REPO_NOT_FOUND_MESSAGE, command.output));
- }
- })
- .then(function(repoSize, toolOptions) {
- if (toolOptions.ignore || COCOAPODS_SYNCED_MIN_SIZE <= repoSize) { // success, expected size
- return Q.resolve(toolOptions);
- } else {
- return Q.reject(COCOAPODS_SYNC_ERROR_MESSAGE);
- }
- });
+ .then(function (toolOptions) {
+ // check size of ~/.cocoapods repo
+ let commandString = util.format('du -sh %s/.cocoapods', process.env.HOME);
+ let command = shell.exec(commandString, { silent: true });
+ // command.output is e.g "750M path/to/.cocoapods", we just scan the number
+ let size = toolOptions.ignore ? 0 : parseFloat(command.output);
+
+ if (toolOptions.ignore || command.code === 0) { // success, parse output
+ return Q.resolve(size, toolOptions);
+ } else { // error, perhaps not found
+ return Q.reject(util.format('%s (%s)', COCOAPODS_REPO_NOT_FOUND_MESSAGE, command.output));
+ }
+ })
+ .then(function (repoSize, toolOptions) {
+ if (toolOptions.ignore || COCOAPODS_SYNCED_MIN_SIZE <= repoSize) { // success, expected size
+ return Q.resolve(toolOptions);
+ } else {
+ return Q.reject(COCOAPODS_SYNC_ERROR_MESSAGE);
+ }
+ });
};
/**
@@ -117,20 +118,20 @@ module.exports.check_cocoapods_repo_size = function () {
*/
module.exports.check_cocoapods = function (toolChecker) {
return check_cocoapod_tool(toolChecker)
- // check whether the cocoapods repo has been synced through `pod repo` command
- // a value of '0 repos' means it hasn't been synced
- .then(function(toolOptions) {
- let code = shell.exec('pod repo | grep -e "^0 repos"', { silent:true }).code;
- let repoIsSynced = (code !== 0);
-
- if (toolOptions.ignore || repoIsSynced) {
- // return check_cocoapods_repo_size();
- // we could check the repo size above, but it takes too long.
- return Q.resolve(toolOptions);
- } else {
- return Q.reject(COCOAPODS_NOT_SYNCED_MESSAGE);
- }
- });
+ // check whether the cocoapods repo has been synced through `pod repo` command
+ // a value of '0 repos' means it hasn't been synced
+ .then(function (toolOptions) {
+ let code = shell.exec('pod repo | grep -e "^0 repos"', { silent: true }).code;
+ let repoIsSynced = (code !== 0);
+
+ if (toolOptions.ignore || repoIsSynced) {
+ // return check_cocoapods_repo_size();
+ // we could check the repo size above, but it takes too long.
+ return Q.resolve(toolOptions);
+ } else {
+ return Q.reject(COCOAPODS_NOT_SYNCED_MESSAGE);
+ }
+ });
};
/**
@@ -149,7 +150,7 @@ function checkTool (tool, minVersion, message, toolFriendlyName) {
if (!tool_command) {
return Q.reject(toolFriendlyName + ' was not found. ' + (message || ''));
}
-
+
// check if tool version is greater than specified one
return versions.get_tool_version(tool).then(function (version) {
version = version.trim();
@@ -181,7 +182,7 @@ let 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 () {
const requirements = [
new Requirement('os', 'Apple macOS', true),
@@ -209,19 +210,19 @@ module.exports.check_all = function() {
let 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-ios/blob/83435d56/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-ios/blob/83435d56/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 7caa200..e05aacf 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),
- 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);
+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 occured on copying www. Code: ' + code);
process.exit(3);
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/scripts/cordova/lib/list-devices
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/list-devices b/bin/templates/scripts/cordova/lib/list-devices
index 3fa3e6d..047d595 100755
--- a/bin/templates/scripts/cordova/lib/list-devices
+++ b/bin/templates/scripts/cordova/lib/list-devices
@@ -19,7 +19,6 @@
under the License.
*/
-/*jshint node: true*/
var Q = require('q'),
exec = require('child_process').exec;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/scripts/cordova/lib/list-emulator-build-targets
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/list-emulator-build-targets b/bin/templates/scripts/cordova/lib/list-emulator-build-targets
index d17fc8c..c0d566f 100755
--- a/bin/templates/scripts/cordova/lib/list-emulator-build-targets
+++ b/bin/templates/scripts/cordova/lib/list-emulator-build-targets
@@ -19,7 +19,6 @@
under the License.
*/
-/*jshint node: true*/
var Q = require('q'),
exec = require('child_process').exec;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/scripts/cordova/lib/list-emulator-images
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/list-emulator-images b/bin/templates/scripts/cordova/lib/list-emulator-images
index 87a5ad2..d8be576 100755
--- a/bin/templates/scripts/cordova/lib/list-emulator-images
+++ b/bin/templates/scripts/cordova/lib/list-emulator-images
@@ -19,7 +19,6 @@
under the License.
*/
-/*jshint node: true*/
var Q = require('q'),
iossim = require('ios-sim'),
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/83435d56/bin/templates/scripts/cordova/lib/list-started-emulators
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/list-started-emulators b/bin/templates/scripts/cordova/lib/list-started-emulators
index 1269e47..710fa2f 100755
--- a/bin/templates/scripts/cordova/lib/list-started-emulators
+++ b/bin/templates/scripts/cordova/lib/list-started-emulators
@@ -19,7 +19,6 @@
under the License.
*/
-/*jshint node: true*/
var Q = require('q'),
exec = require('child_process').exec;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org