You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/11/22 03:47:25 UTC
cordova-lib git commit: [CB-6472] Adding content to -Info.plist -
Unexpected behaviour
Repository: cordova-lib
Updated Branches:
refs/heads/master 623233d09 -> b76a266bb
[CB-6472] Adding content to -Info.plist - Unexpected behaviour
Merge instead of replace when the destination and source nodes
are both of type dictionary. Adds underscore.js as a dependency.
GitHub: close #115
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/b76a266b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/b76a266b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/b76a266b
Branch: refs/heads/master
Commit: b76a266bbf9eeb91d32c1037838a04817d871412
Parents: 623233d
Author: Gorkem Ercan <go...@gmail.com>
Authored: Mon Oct 27 13:35:09 2014 -0400
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Fri Nov 21 21:44:31 2014 -0500
----------------------------------------------------------------------
.../spec-plugman/plugins/PlistPlugin/plugin.xml | 47 ++++++++++++++++++++
.../spec-plugman/util/config-changes.spec.js | 10 +++++
cordova-lib/src/plugman/util/plist-helpers.js | 17 ++++---
3 files changed, 68 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b76a266b/cordova-lib/spec-plugman/plugins/PlistPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/PlistPlugin/plugin.xml b/cordova-lib/spec-plugman/plugins/PlistPlugin/plugin.xml
new file mode 100644
index 0000000..064f72e
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/PlistPlugin/plugin.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ id="org.apache.plist"
+ version="3.0.0">
+
+ <name>PList updates</name>
+
+ <!-- ios -->
+ <platform name="ios">
+ <config-file target="*-Info.plist" parent="CFBundleIcons">
+ <dict>
+ <key>UINewsstandIcon</key>
+ <dict>
+ <key>CFBundleIconFiles</key>
+ <array>
+ <string>Newsstand-Cover-Icon.png</string>
+ <string>Newsstand-Cover-Icon@2x.png</string>
+ </array>
+ <key>UINewsstandBindingType</key>
+ <string>UINewsstandBindingTypeMagazine</string>
+ <key>UINewsstandBindingEdge</key>
+ <string>UINewsstandBindingEdgeLeft</string>
+ </dict>
+ </dict>
+ </config-file>
+ </platform>
+</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b76a266b/cordova-lib/spec-plugman/util/config-changes.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/util/config-changes.spec.js b/cordova-lib/spec-plugman/util/config-changes.spec.js
index d745c18..8409c3c 100644
--- a/cordova-lib/spec-plugman/util/config-changes.spec.js
+++ b/cordova-lib/spec-plugman/util/config-changes.spec.js
@@ -38,6 +38,7 @@ var configChanges = require('../../src/plugman/util/config-changes'),
shareddepsplugin = path.join(__dirname, '..', 'plugins', 'shared-deps-multi-child'),
configplugin = path.join(__dirname, '..', 'plugins', 'ConfigTestPlugin'),
varplugin = path.join(__dirname, '..', 'plugins', 'VariablePlugin'),
+ plistplugin = path.join(__dirname, '..', 'plugins', 'PlistPlugin'),
android_two_project = path.join(__dirname, '..', 'projects', 'android_two', '*'),
android_two_no_perms_project = path.join(__dirname, '..', 'projects', 'android_two_no_perms', '*'),
ios_plist_project = path.join(__dirname, '..', 'projects', 'ios-plist', '*'),
@@ -323,6 +324,15 @@ describe('config-changes module', function() {
expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>APluginNode<\/key>\n <string><\/string>/m);
});
});
+ describe('plist merge dictionaries', function() {
+ it('should write empty string nodes with no whitespace', function() {
+ shell.cp('-rf', ios_config_xml, temp);
+ shell.cp('-rf', plistplugin, plugins_dir);
+ configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'PlistPlugin', 'ios', {});
+ configChanges.process(plugins_dir, temp, 'ios');
+ expect(fs.readFileSync(path.join(temp, 'SampleApp', 'SampleApp-Info.plist'), 'utf-8')).toMatch(/<key>UINewsstandIcon<\/key>[\s\S]*<key>CFBundlePrimaryIcon<\/key>/);
+ });
+ });
describe('of pbxproject framework files', function() {
var xcode_add, xcode_rm;
beforeEach(function() {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b76a266b/cordova-lib/src/plugman/util/plist-helpers.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/plist-helpers.js b/cordova-lib/src/plugman/util/plist-helpers.js
index 37492db..fcd173c 100644
--- a/cordova-lib/src/plugman/util/plist-helpers.js
+++ b/cordova-lib/src/plugman/util/plist-helpers.js
@@ -22,7 +22,7 @@
*/
// contains PLIST utility functions
-
+var __ = require('underscore');
var plist = require('plist');
// adds node to doc at selector
@@ -33,16 +33,21 @@ function graftPLIST(doc, xml, selector) {
var node = doc[selector];
if (node && Array.isArray(node) && Array.isArray(obj)){
node.concat(obj);
- for(var i =0;i<node.length; i++){
- for(var j=i+1; j<node.length; ++j) {
- if(node[i] === node[j])
+ for (var i =0;i<node.length; i++){
+ for (var j=i+1; j<node.length; ++j) {
+ if (node[i] === node[j])
node.splice(j--,1);
}
}
doc[selector] = node;
- }
- else
+ } else {
+ //plist uses objects for <dict>. If we have two dicts we merge them instead of
+ // overriding the old one. See CB-6472
+ if (node && __.isObject(node) && __.isObject(obj) && !__.isDate(node) && !__.isDate(obj)){//arrays checked above
+ __.extend(obj,node);
+ }
doc[selector] = obj;
+ }
return true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org