You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2017/04/19 00:40:12 UTC
ios commit: CB-8980 - Adding resource-file element to config.xml for
iOS
Repository: cordova-ios
Updated Branches:
refs/heads/master d7f5eefdd -> cd2ccc8ca
CB-8980 - Adding resource-file element to config.xml for iOS
Update bundled cordova-common to version 2.0.2
Add unit tests.
This closes #305
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/cd2ccc8c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/cd2ccc8c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/cd2ccc8c
Branch: refs/heads/master
Commit: cd2ccc8ca51451c09bb278fd8f1fa6b8420fc561
Parents: d7f5eef
Author: Shazron Abdullah <sh...@gmail.com>
Authored: Thu Apr 13 17:31:02 2017 -0700
Committer: Shazron Abdullah <sh...@gmail.com>
Committed: Tue Apr 18 17:39:57 2017 -0700
----------------------------------------------------------------------
bin/templates/scripts/cordova/lib/prepare.js | 61 ++++++++
node_modules/cordova-common/.ratignore | 1 +
node_modules/cordova-common/RELEASENOTES.md | 17 +++
node_modules/cordova-common/package.json | 114 ++++++--------
.../src/ConfigChanges/ConfigChanges.js | 151 +++----------------
.../src/ConfigParser/ConfigParser.js | 34 +++++
.../cordova-common/src/PluginInfo/PluginInfo.js | 7 +-
node_modules/cordova-common/src/events.js | 1 +
node_modules/cordova-common/src/superspawn.js | 6 +
.../cordova-common/src/util/plist-helpers.js | 36 ++---
.../cordova-common/src/util/xml-helpers.js | 36 ++---
package.json | 2 +-
tests/.jshintrc | 1 +
.../fixtures/resource-file-support/config.xml | 20 +++
.../resource-file-support/image-5678.png | Bin 0 -> 39830 bytes
tests/spec/unit/prepare.spec.js | 73 +++++++++
16 files changed, 317 insertions(+), 243 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/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 d8f52ac..d2a3379 100644
--- a/bin/templates/scripts/cordova/lib/prepare.js
+++ b/bin/templates/scripts/cordova/lib/prepare.js
@@ -17,6 +17,7 @@
under the License.
*/
+'use strict';
var Q = require('q');
var fs = require('fs');
var path = require('path');
@@ -33,6 +34,7 @@ var PlatformJson = require('cordova-common').PlatformJson;
var PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
var FileUpdater = require('cordova-common').FileUpdater;
+var projectFile = require('./projectFile');
// launch storyboard and related constants
var LAUNCHIMAGE_BUILD_SETTING = 'ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME';
@@ -62,6 +64,7 @@ module.exports.prepare = function (cordovaProject, options) {
updateIcons(cordovaProject, self.locations);
updateSplashScreens(cordovaProject, self.locations);
updateLaunchStoryboardImages(cordovaProject, self.locations);
+ updateFileResources(cordovaProject, self.locations);
})
.then(function () {
events.emit('verbose', 'Prepared iOS project successfully');
@@ -88,6 +91,7 @@ module.exports.clean = function (options) {
cleanIcons(projectRoot, projectConfig, self.locations);
cleanSplashScreens(projectRoot, projectConfig, self.locations);
cleanLaunchStoryboardImages(projectRoot, projectConfig, self.locations);
+ cleanFileResources(projectRoot, projectConfig, self.locations);
});
};
@@ -452,6 +456,63 @@ function cleanSplashScreens(projectRoot, projectConfig, locations) {
}
}
+function updateFileResources(cordovaProject, locations) {
+ const platformDir = path.relative(cordovaProject.root, locations.root);
+ const files = cordovaProject.projectConfig.getFileResources('ios');
+
+ const project = projectFile.parse(locations);
+
+ // if there are resource-file elements in config.xml
+ if (files.length === 0) {
+ events.emit('verbose', 'This app does not have additional resource files defined');
+ return;
+ }
+
+ let resourceMap = {};
+ files.forEach(function(res) {
+ let targetPath = path.join(project.resources_dir, res.target);
+ targetPath = path.relative(cordovaProject.root, targetPath);
+ resourceMap[targetPath] = res.src;
+ });
+
+ events.emit('verbose', 'Updating resource files at ' + platformDir);
+ FileUpdater.updatePaths(
+ resourceMap, { rootDir: cordovaProject.root }, logFileOp);
+
+ Object.keys(resourceMap).sort().forEach(function (targetPath) {
+ var sourcePath = resourceMap[targetPath];
+ project.xcode.addResourceFile(path.join('Resources', path.basename(sourcePath)));
+ });
+
+ project.write();
+}
+
+function cleanFileResources(projectRoot, projectConfig, locations) {
+ const platformDir = path.relative(projectRoot, locations.root);
+ const files = projectConfig.getFileResources('ios');
+ if (files.length > 0) {
+ events.emit('verbose', 'Cleaning resource files at ' + platformDir);
+
+ const project = projectFile.parse(locations);
+
+ var resourceMap = {};
+ files.forEach(function(res) {
+ let filePath = path.join(project.resources_dir, res.target);
+ filePath = path.relative(projectRoot, filePath);
+ resourceMap[filePath] = null;
+ });
+
+ FileUpdater.updatePaths(
+ resourceMap, { rootDir: projectRoot, all: true}, logFileOp);
+
+ Object.keys(resourceMap).sort().forEach(function (targetPath) {
+ project.xcode.removeResourceFile(path.join('Resources', path.basename(targetPath)));
+ });
+
+ project.write();
+ }
+}
+
/**
* Returns an array of images for each possible idiom, scale, and size class. The images themselves are
* located in the platform's splash images by their pattern (@scale~idiom~sizesize). All possible
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/.ratignore
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/.ratignore b/node_modules/cordova-common/.ratignore
index 26f7205..d9f5e52 100644
--- a/node_modules/cordova-common/.ratignore
+++ b/node_modules/cordova-common/.ratignore
@@ -1,2 +1,3 @@
fixtures
coverage
+jasmine.json
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/RELEASENOTES.md b/node_modules/cordova-common/RELEASENOTES.md
index 02dbcee..ffd0248 100644
--- a/node_modules/cordova-common/RELEASENOTES.md
+++ b/node_modules/cordova-common/RELEASENOTES.md
@@ -20,6 +20,23 @@
-->
# Cordova-common Release Notes
+### 2.0.2 (Apr 14, 2017)
+* [CB-11233](https://issues.apache.org/jira/browse/CB-11233) - Support installing frameworks into 'Embedded Binaries' section of the Xcode project
+* [CB-10438](https://issues.apache.org/jira/browse/CB-10438) - Install correct dependency version. Removed shell.remove, added pkg.json to dependency tests 1-3, and updated install.js (.replace) to fix tests in uninstall.spec.js and update to workw with jasmine 2.0
+* [CB-11120](https://issues.apache.org/jira/browse/CB-11120) - Allow short/display name in config.xml
+* [CB-11346](https://issues.apache.org/jira/browse/CB-11346) - Remove known platforms check
+* [CB-11977](https://issues.apache.org/jira/browse/CB-11977) - updated engines and enginescript for common, fetch, and serve
+
+### 2.0.1 (Mar 09, 2017)
+* [CB-12557](https://issues.apache.org/jira/browse/CB-12557) add both stdout and stderr properties to the error object passed to superspawn reject handler.
+
+### 2.0.0 (Jan 17, 2017)
+* [CB-8978](https://issues.apache.org/jira/browse/CB-8978) Add `resource-file` parsing to `config.xml`
+* [CB-12018](https://issues.apache.org/jira/browse/CB-12018): updated `jshint` and updated tests to work with `jasmine@2` instead of `jasmine-node`
+* [CB-12163](https://issues.apache.org/jira/browse/CB-12163) Add reference attrib to `resource-file` for **Windows**
+* Move windows-specific logic to `cordova-windows`
+* [CB-12189](https://issues.apache.org/jira/browse/CB-12189) Add implementation attribute to framework
+
### 1.5.1 (Oct 12, 2016)
* [CB-12002](https://issues.apache.org/jira/browse/CB-12002) Add `getAllowIntents()` to `ConfigParser`
* [CB-11998](https://issues.apache.org/jira/browse/CB-11998) `cordova platform add` error with `cordova-common@1.5.0`
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/package.json
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/package.json b/node_modules/cordova-common/package.json
index b73fefd..b725474 100644
--- a/node_modules/cordova-common/package.json
+++ b/node_modules/cordova-common/package.json
@@ -1,58 +1,30 @@
{
- "_args": [
- [
- {
- "raw": "cordova-common@^1.5.0",
- "scope": null,
- "escapedName": "cordova-common",
- "name": "cordova-common",
- "rawSpec": "^1.5.0",
- "spec": ">=1.5.0 <2.0.0",
- "type": "range"
- },
- "/Users/shazron/Documents/git/apache/cordova-ios"
- ]
- ],
- "_from": "cordova-common@>=1.5.0 <2.0.0",
- "_id": "cordova-common@1.5.1",
- "_inCache": true,
- "_location": "/cordova-common",
- "_nodeVersion": "6.6.0",
- "_npmOperationalInternal": {
- "host": "packages-12-west.internal.npmjs.com",
- "tmp": "tmp/cordova-common-1.5.1.tgz_1476725179180_0.39604957425035536"
- },
- "_npmUser": {
- "name": "stevegill",
- "email": "stevengill97@gmail.com"
- },
- "_npmVersion": "3.10.3",
- "_phantomChildren": {},
- "_requested": {
- "raw": "cordova-common@^1.5.0",
- "scope": null,
- "escapedName": "cordova-common",
- "name": "cordova-common",
- "rawSpec": "^1.5.0",
- "spec": ">=1.5.0 <2.0.0",
- "type": "range"
- },
- "_requiredBy": [
- "/"
- ],
- "_resolved": "https://registry.npmjs.org/cordova-common/-/cordova-common-1.5.1.tgz",
- "_shasum": "6770de0d6200ad6f94a1abe8939b5bd9ece139e3",
- "_shrinkwrap": null,
- "_spec": "cordova-common@^1.5.0",
- "_where": "/Users/shazron/Documents/git/apache/cordova-ios",
"author": {
"name": "Apache Software Foundation"
},
+ "name": "cordova-common",
+ "description": "Apache Cordova tools and platforms shared routines",
+ "license": "Apache-2.0",
+ "version": "2.0.2",
+ "repository": {
+ "type": "git",
+ "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"
+ },
"bugs": {
"url": "https://issues.apache.org/jira/browse/CB",
"email": "dev@cordova.apache.org"
},
- "contributors": [],
+ "main": "cordova-common.js",
+ "engines": {
+ "node": ">=4.0.0"
+ },
+ "engineStrict": true,
+ "scripts": {
+ "test": "npm run jshint && npm run jasmine",
+ "jshint": "jshint src && jshint spec",
+ "jasmine": "jasmine --captureExceptions --color",
+ "cover": "istanbul cover --root src --print detail jasmine"
+ },
"dependencies": {
"ansi": "^0.3.1",
"bplist-parser": "^0.1.0",
@@ -68,31 +40,38 @@
"underscore": "^1.8.3",
"unorm": "^1.3.3"
},
- "description": "Apache Cordova tools and platforms shared routines",
"devDependencies": {
- "istanbul": "^0.3.17",
- "jasmine-node": "^1.14.5",
+ "istanbul": "^0.4.5",
+ "jasmine": "^2.5.2",
"jshint": "^2.8.0",
"promise-matchers": "^0.9.6",
"rewire": "^2.5.1"
},
- "directories": {},
- "dist": {
- "shasum": "6770de0d6200ad6f94a1abe8939b5bd9ece139e3",
- "tarball": "https://registry.npmjs.org/cordova-common/-/cordova-common-1.5.1.tgz"
+ "contributors": [],
+ "_id": "cordova-common@2.0.2",
+ "_shasum": "57467976b8afd5e0bd0a13111b66a420441601cb",
+ "_resolved": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.0.2.tgz",
+ "_from": "cordova-common@2.0.2",
+ "_npmVersion": "2.15.11",
+ "_nodeVersion": "4.7.3",
+ "_npmUser": {
+ "name": "shazron",
+ "email": "shazron@gmail.com"
},
- "engineStrict": true,
- "engines": {
- "node": ">=0.9.9"
+ "dist": {
+ "shasum": "57467976b8afd5e0bd0a13111b66a420441601cb",
+ "tarball": "https://registry.npmjs.org/cordova-common/-/cordova-common-2.0.2.tgz"
},
- "license": "Apache-2.0",
- "main": "cordova-common.js",
"maintainers": [
{
"name": "bowserj",
"email": "bowserj@apache.org"
},
{
+ "name": "filmaj",
+ "email": "maj.fil@gmail.com"
+ },
+ {
"name": "kotikov.vladimir",
"email": "kotikov.vladimir@gmail.com"
},
@@ -113,18 +92,9 @@
"email": "npmjs@barhams.info"
}
],
- "name": "cordova-common",
- "optionalDependencies": {},
- "readme": "ERROR: No README data found!",
- "repository": {
- "type": "git",
- "url": "git://git-wip-us.apache.org/repos/asf/cordova-common.git"
- },
- "scripts": {
- "cover": "node node_modules/istanbul/lib/cli.js cover --root src --print detail node_modules/jasmine-node/bin/jasmine-node -- spec",
- "jasmine": "node node_modules/jasmine-node/bin/jasmine-node --captureExceptions --color spec",
- "jshint": "node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint spec",
- "test": "npm run jshint && npm run jasmine"
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/cordova-common-2.0.2.tgz_1492453798445_0.6290795875247568"
},
- "version": "1.5.1"
+ "directories": {}
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js b/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js
index 6a80730..4a58132 100644
--- a/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js
+++ b/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js
@@ -1,21 +1,21 @@
-/*
- *
- * Copyright 2013 Anis Kadri
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
/*
* This module deals with shared configuration / dependency "stuff". That is:
@@ -31,11 +31,8 @@
/* jshint sub:true */
-var fs = require('fs'),
- path = require('path'),
+var path = require('path'),
et = require('elementtree'),
- semver = require('semver'),
- events = require('../events'),
ConfigKeeper = require('./ConfigKeeper'),
CordovaLogger = require('../CordovaLogger');
@@ -109,18 +106,6 @@ function remove_plugin_changes(pluginInfo, is_top_level) {
var munge = mungeutil.decrement_munge(global_munge, config_munge);
for (var file in munge.files) {
- // CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
- if (self.platform == 'windows' && file == 'package.appxmanifest' &&
- !fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
- // New windows template separate manifest files for Windows10, Windows8.1 and WP8.1
- var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
- /* jshint loopfunc:true */
- substs.forEach(function(subst) {
- events.emit('verbose', 'Applying munge to ' + subst);
- self.apply_file_munge(subst, munge.files[file], true);
- });
- /* jshint loopfunc:false */
- }
self.apply_file_munge(file, munge.files[file], /* remove = */ true);
}
@@ -250,18 +235,6 @@ function munge_helper(should_increment, self, platform_config, config_munge) {
}
for (var file in munge.files) {
- // CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
- if (self.platform == 'windows' && file == 'package.appxmanifest' &&
- !fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
- var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
- /* jshint loopfunc:true */
- substs.forEach(function(subst) {
- events.emit('verbose', 'Applying munge to ' + subst);
- self.apply_file_munge(subst, munge.files[file]);
- });
- /* jshint loopfunc:false */
- }
-
self.apply_file_munge(file, munge.files[file]);
}
@@ -333,92 +306,6 @@ function generate_plugin_config_munge(pluginInfo, vars, edit_config_changes) {
Array.prototype.push.apply(changes, edit_config_changes);
}
- // Demux 'package.appxmanifest' into relevant platform-specific appx manifests.
- // Only spend the cycles if there are version-specific plugin settings
- if (self.platform === 'windows' &&
- changes.some(function(change) {
- return ((typeof change.versions !== 'undefined') ||
- (typeof change.deviceTarget !== 'undefined'));
- }))
- {
- var manifests = {
- 'windows': {
- '8.1.0': 'package.windows.appxmanifest',
- '10.0.0': 'package.windows10.appxmanifest'
- },
- 'phone': {
- '8.1.0': 'package.phone.appxmanifest',
- '10.0.0': 'package.windows10.appxmanifest'
- },
- 'all': {
- '8.1.0': ['package.windows.appxmanifest', 'package.phone.appxmanifest'],
- '10.0.0': 'package.windows10.appxmanifest'
- }
- };
-
- var oldChanges = changes;
- changes = [];
-
- oldChanges.forEach(function(change, changeIndex) {
- // Only support semver/device-target demux for package.appxmanifest
- // Pass through in case something downstream wants to use it
- if (change.target !== 'package.appxmanifest') {
- changes.push(change);
- return;
- }
-
- var hasVersion = (typeof change.versions !== 'undefined');
- var hasTargets = (typeof change.deviceTarget !== 'undefined');
-
- // No semver/device-target for this config-file, pass it through
- if (!(hasVersion || hasTargets)) {
- changes.push(change);
- return;
- }
-
- var targetDeviceSet = hasTargets ? change.deviceTarget : 'all';
- if (['windows', 'phone', 'all'].indexOf(targetDeviceSet) === -1) {
- // target-device couldn't be resolved, fix it up here to a valid value
- targetDeviceSet = 'all';
- }
- var knownWindowsVersionsForTargetDeviceSet = Object.keys(manifests[targetDeviceSet]);
-
- // at this point, 'change' targets package.appxmanifest and has a version attribute
- knownWindowsVersionsForTargetDeviceSet.forEach(function(winver) {
- // This is a local function that creates the new replacement representing the
- // mutation. Used to save code further down.
- var createReplacement = function(manifestFile, originalChange) {
- var replacement = {
- target: manifestFile,
- parent: originalChange.parent,
- after: originalChange.after,
- xmls: originalChange.xmls,
- versions: originalChange.versions,
- deviceTarget: originalChange.deviceTarget
- };
- return replacement;
- };
-
- // version doesn't satisfy, so skip
- if (hasVersion && !semver.satisfies(winver, change.versions)) {
- return;
- }
-
- var versionSpecificManifests = manifests[targetDeviceSet][winver];
- if (versionSpecificManifests.constructor === Array) {
- // e.g. all['8.1.0'] === ['pkg.windows.appxmanifest', 'pkg.phone.appxmanifest']
- versionSpecificManifests.forEach(function(manifestFile) {
- changes.push(createReplacement(manifestFile, change));
- });
- }
- else {
- // versionSpecificManifests is actually a single string
- changes.push(createReplacement(versionSpecificManifests, change));
- }
- });
- });
- }
-
changes.forEach(function(change) {
change.xmls.forEach(function(xml) {
// 1. stringify each xml
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/src/ConfigParser/ConfigParser.js
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/src/ConfigParser/ConfigParser.js b/node_modules/cordova-common/src/ConfigParser/ConfigParser.js
index 6e74ce3..cd718de 100644
--- a/node_modules/cordova-common/src/ConfigParser/ConfigParser.js
+++ b/node_modules/cordova-common/src/ConfigParser/ConfigParser.js
@@ -116,6 +116,16 @@ ConfigParser.prototype = {
var el = findOrCreate(this.doc, 'name');
el.text = name;
},
+ shortName: function() {
+ return this.doc.find('name').attrib['short'] || this.name();
+ },
+ setShortName: function(shortname) {
+ var el = findOrCreate(this.doc, 'name');
+ if (!el.text) {
+ el.text = shortname;
+ }
+ el.attrib['short'] = shortname;
+ },
description: function() {
return getNodeTextSafe(this.doc.find('description'));
},
@@ -257,6 +267,30 @@ ConfigParser.prototype = {
},
/**
+ * Returns all resource-files for a specific platform.
+ * @param {string} platform Platform name
+ * @return {Resource[]} Array of resource file objects.
+ */
+ getFileResources: function(platform) {
+ var fileResources = [];
+
+ if (platform) { // platform specific resources
+ fileResources = this.doc.findall('platform[@name=\'' + platform + '\']/resource-file').map(function(tag) {
+ return {
+ platform: platform,
+ src: tag.attrib.src,
+ target: tag.attrib.target,
+ versions: tag.attrib.versions,
+ deviceTarget: tag.attrib['device-target'],
+ arch: tag.attrib.arch
+ };
+ });
+ }
+
+ return fileResources;
+ },
+
+ /**
* Returns all hook scripts for the hook type specified.
* @param {String} hook The hook type.
* @param {Array} platforms Platforms to look for scripts into (root scripts will be included as well).
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/src/PluginInfo/PluginInfo.js
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/src/PluginInfo/PluginInfo.js b/node_modules/cordova-common/src/PluginInfo/PluginInfo.js
index ce9f9e6..4817470 100644
--- a/node_modules/cordova-common/src/PluginInfo/PluginInfo.js
+++ b/node_modules/cordova-common/src/PluginInfo/PluginInfo.js
@@ -108,6 +108,7 @@ function PluginInfo(dirname) {
function _parseDependency(tag) {
var dep =
{ id : tag.attrib.id
+ , version: tag.attrib.version || ''
, url : tag.attrib.url || ''
, subdir : tag.attrib.subdir || ''
, commit : tag.attrib.commit
@@ -225,7 +226,8 @@ function PluginInfo(dirname) {
target: tag.attrib.target,
versions: tag.attrib.versions,
deviceTarget: tag.attrib['device-target'],
- arch: tag.attrib.arch
+ arch: tag.attrib.arch,
+ reference: tag.attrib.reference
};
});
return resourceFiles;
@@ -324,7 +326,8 @@ function PluginInfo(dirname) {
versions: el.attrib.versions,
targetDir: el.attrib['target-dir'],
deviceTarget: el.attrib['device-target'] || el.attrib.target,
- arch: el.attrib.arch
+ arch: el.attrib.arch,
+ implementation: el.attrib.implementation
};
return ret;
});
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/src/events.js
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/src/events.js b/node_modules/cordova-common/src/events.js
index e702bd8..3080416 100644
--- a/node_modules/cordova-common/src/events.js
+++ b/node_modules/cordova-common/src/events.js
@@ -20,6 +20,7 @@
var EventEmitter = require('events').EventEmitter;
var INSTANCE = new EventEmitter();
+INSTANCE.setMaxListeners(20);
var EVENTS_RECEIVER;
module.exports = INSTANCE;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/src/superspawn.js
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/src/superspawn.js b/node_modules/cordova-common/src/superspawn.js
index a3f1431..96ec09d 100644
--- a/node_modules/cordova-common/src/superspawn.js
+++ b/node_modules/cordova-common/src/superspawn.js
@@ -167,6 +167,12 @@ exports.spawn = function(cmd, args, opts) {
errMsg += ' Error output:\n' + capturedErr.trim();
}
var err = new Error(errMsg);
+ if (capturedErr) {
+ err.stderr = capturedErr;
+ }
+ if (capturedOut) {
+ err.stdout = capturedOut;
+ }
err.code = code;
d.reject(err);
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/src/util/plist-helpers.js
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/src/util/plist-helpers.js b/node_modules/cordova-common/src/util/plist-helpers.js
index 9dee5c6..38eb31b 100644
--- a/node_modules/cordova-common/src/util/plist-helpers.js
+++ b/node_modules/cordova-common/src/util/plist-helpers.js
@@ -1,21 +1,21 @@
-/*
- *
- * Copyright 2013 Brett Rudd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
// contains PLIST utility functions
var __ = require('underscore');
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/node_modules/cordova-common/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/src/util/xml-helpers.js b/node_modules/cordova-common/src/util/xml-helpers.js
index 9a1e82d..b4b0490 100644
--- a/node_modules/cordova-common/src/util/xml-helpers.js
+++ b/node_modules/cordova-common/src/util/xml-helpers.js
@@ -1,21 +1,21 @@
-/*
- *
- * Copyright 2013 Anis Kadri
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
/* jshint sub:true, laxcomma:true */
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 7c5a6bf..8591268 100644
--- a/package.json
+++ b/package.json
@@ -43,7 +43,7 @@
"node" : ">=4"
},
"dependencies": {
- "cordova-common": "^1.5.0",
+ "cordova-common": "2.0.2",
"ios-sim": "^5.0.12",
"nopt": "^3.0.6",
"plist": "^1.2.0",
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/tests/.jshintrc
----------------------------------------------------------------------
diff --git a/tests/.jshintrc b/tests/.jshintrc
index 17eae32..23199d7 100644
--- a/tests/.jshintrc
+++ b/tests/.jshintrc
@@ -8,4 +8,5 @@
, "unused": "vars"
, "latedef": "nofunc"
, "jasmine": true
+ , "esversion": 6
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/tests/spec/unit/fixtures/resource-file-support/config.xml
----------------------------------------------------------------------
diff --git a/tests/spec/unit/fixtures/resource-file-support/config.xml b/tests/spec/unit/fixtures/resource-file-support/config.xml
new file mode 100644
index 0000000..2705da7
--- /dev/null
+++ b/tests/spec/unit/fixtures/resource-file-support/config.xml
@@ -0,0 +1,20 @@
+<?xml version='1.0' encoding='utf-8'?>
+<widget id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+ <name>Hello Cordova</name>
+ <description>
+ A sample Apache Cordova application that responds to the deviceready event.
+ </description>
+ <author email="dev@cordova.apache.org" href="http://cordova.io">
+ Apache Cordova Team
+ </author>
+ <content src="index.html" />
+
+ <access origin="*" />
+
+ <platform name="ios">
+ <resource-file src="image-5678.png" target="image-5678.png" />
+ </platform>
+
+
+
+</widget>
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/tests/spec/unit/fixtures/resource-file-support/image-5678.png
----------------------------------------------------------------------
diff --git a/tests/spec/unit/fixtures/resource-file-support/image-5678.png b/tests/spec/unit/fixtures/resource-file-support/image-5678.png
new file mode 100644
index 0000000..c9465f3
Binary files /dev/null and b/tests/spec/unit/fixtures/resource-file-support/image-5678.png differ
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/cd2ccc8c/tests/spec/unit/prepare.spec.js
----------------------------------------------------------------------
diff --git a/tests/spec/unit/prepare.spec.js b/tests/spec/unit/prepare.spec.js
index 69d1d92..273977e 100644
--- a/tests/spec/unit/prepare.spec.js
+++ b/tests/spec/unit/prepare.spec.js
@@ -17,6 +17,7 @@
under the License.
*/
+'use strict';
var fs = require('fs');
var os = require('os');
var path = require('path');
@@ -27,6 +28,7 @@ var rewire = require('rewire');
var EventEmitter = require('events').EventEmitter;
var Api = require('../../../bin/templates/scripts/cordova/Api');
var prepare = rewire('../../../bin/templates/scripts/cordova/lib/prepare');
+var projectFile = require('../../../bin/templates/scripts/cordova/lib/projectFile');
var FileUpdater = require('cordova-common').FileUpdater;
var FIXTURES = path.join(__dirname, 'fixtures');
@@ -1483,7 +1485,78 @@ describe('prepare', function() {
expect(exceptionDomains['null']).toBeUndefined();
expect(exceptionDomains['undefined']).toBeUndefined();
});
+ });
+ });
+
+ describe('<resource-file> tests', function() {
+ const imageFileName = 'image-5678.png';
+ const projectRoot = path.join(FIXTURES, 'resource-file-support');
+ const updateFileResources = prepare.__get__('updateFileResources');
+ const cleanFileResources = prepare.__get__('cleanFileResources');
+ const cfgResourceFiles = new ConfigParser(path.join(FIXTURES, 'resource-file-support', 'config.xml'));
+
+ function findImageFileRef(pbxproj) {
+ const buildfiles = pbxproj.pbxBuildFileSection();
+ return Object.keys(buildfiles).filter(function(uuid) {
+ var filename = buildfiles[uuid].fileRef_comment;
+ return (filename === imageFileName);
+ });
+ }
+
+ function findResourcesBuildPhaseRef(pbxproj, ref) {
+ const resBuildPhase = pbxproj.buildPhaseObject('PBXResourcesBuildPhase', 'Resources');
+ let resBuildPhaseFileRefs = [];
+ if (resBuildPhase) {
+ resBuildPhaseFileRefs = resBuildPhase.files.filter(function(item){
+ return item.value === ref;
+ });
+ }
+
+ return resBuildPhaseFileRefs;
+ }
+
+ it('<resource-file> prepare - copy image-5678.png', function() {
+ const cordovaProject = {
+ root: projectRoot,
+ projectConfig: cfgResourceFiles,
+ locations: {
+ plugins: path.join(projectRoot, 'plugins'),
+ www: path.join(projectRoot, 'www')
+ }
+ };
+
+ updateFileResources(cordovaProject, p.locations);
+ const project = projectFile.parse(p.locations);
+
+ // check whether the file is copied in the correct location
+ const copiedImageFile = path.join(project.resources_dir, imageFileName);
+ expect(fs.existsSync(copiedImageFile)).toBeTruthy();
+
+ // find PBXBuildFile file reference
+ const imagefileRefs = findImageFileRef(project.xcode);
+ expect(imagefileRefs.length).toEqual(1);
+
+ // find file reference in PBXResourcesBuildPhase
+ const resBuildPhaseFileRefs = findResourcesBuildPhaseRef(project.xcode, imagefileRefs[0]);
+ expect(resBuildPhaseFileRefs.length).toEqual(1);
});
+
+ it('<resource-file> clean - remove image-5678.png', function() {
+ cleanFileResources(projectRoot, cfgResourceFiles, p.locations);
+ const project = projectFile.parse(p.locations);
+
+ // check whether the file is removed from the correct location
+ const copiedImageFile = path.join(project.resources_dir, imageFileName);
+ expect(fs.existsSync(copiedImageFile)).toBeFalsy();
+
+ // find PBXBuildFile file reference
+ const imagefileRefs = findImageFileRef(project.xcode);
+ expect(imagefileRefs.length).toEqual(0);
+
+ // find file reference in PBXResourcesBuildPhase
+ const resBuildPhaseFileRefs = findResourcesBuildPhaseRef(project.xcode, imagefileRefs[0]);
+ expect(resBuildPhaseFileRefs.length).toEqual(0);
+ });
});
describe('updateWww method', function() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org