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
Authored: Thu Apr 13 17:31:02 2017 -0700
Committer: Shazron Abdullah
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',