cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [03/16] git commit: config-changes.js: Removed plugins-plist support.
Date Wed, 19 Feb 2014 20:32:49 GMT
config-changes.js: Removed plugins-plist support.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/08b045b7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/08b045b7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/08b045b7

Branch: refs/heads/master
Commit: 08b045b7a5bf28dc9fa65e1745c77c28c05af1af
Parents: f5523d5
Author: Mark Koudritsky <kamrik@chromium.org>
Authored: Tue Feb 11 11:24:44 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Feb 19 15:32:19 2014 -0500

----------------------------------------------------------------------
 spec/util/config-changes.spec.js |  62 ++---------------
 src/util/config-changes.js       | 125 +++++++++++-----------------------
 2 files changed, 45 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/08b045b7/spec/util/config-changes.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/config-changes.spec.js b/spec/util/config-changes.spec.js
index a138d50..6798ce9 100644
--- a/spec/util/config-changes.spec.js
+++ b/spec/util/config-changes.spec.js
@@ -1,3 +1,6 @@
+/* jshint node:true, sub:true, indent:4  */
+/* global jasmine, describe, beforeEach, afterEach, it, spyOn, expect */
+
 var configChanges = require('../../src/util/config-changes'),
     xml_helpers = require('../../src/util/xml-helpers'),
     ios_parser = require('../../src/platforms/ios'),
@@ -205,11 +208,6 @@ describe('config-changes module', function() {
                 var expected_xml = '<cfbundleid>com.example.friendstring</cfbundleid>';
                 expect(munge['config.xml']['/widget'][expected_xml]).toBeDefined();
             });
-            it('should special case plugins-plist elements into own property', function()
{
-                var munge = configChanges.generate_plugin_config_munge(dummyplugin, 'ios',
temp, {});
-                expect(munge['plugins-plist']).toBeDefined();
-                expect(munge['plugins-plist']['com.phonegap.plugins.dummyplugin']).toEqual('DummyPluginCommand');
-            });
             it('should special case framework elements for ios', function() {
                 var munge = configChanges.generate_plugin_config_munge(cbplugin, 'ios', temp,
{});
                 expect(munge['framework']).toBeDefined();
@@ -320,31 +318,6 @@ describe('config-changes module', function() {
                     expect(xcode_add).not.toHaveBeenCalledWith('Custom.framework');
                 });
             });
-            describe('of <plugins-plist> elements', function() {
-                it('should only be used in an applicably old cordova-ios projects', function()
{
-                    shell.cp('-rf', ios_plist_project, temp);
-                    shell.cp('-rf', dummyplugin, plugins_dir);
-                    var cfg = configChanges.get_platform_json(plugins_dir, 'ios');
-                    cfg.prepare_queue.installed = [{'plugin':'DummyPlugin', 'vars':{}}];
-                    configChanges.save_platform_json(cfg, plugins_dir, 'ios');
-
-                    var spy = spyOn(plist, 'parseFileSync').andReturn({Plugins:{}});
-                    configChanges.process(plugins_dir, temp, 'ios');
-                    expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp', 'PhoneGap.plist').replace(/\\/g,
'/'));
-                });
-                it('should provide a deprecation warning message when used', function() {
-                    shell.cp('-rf', ios_plist_project, temp);
-                    shell.cp('-rf', dummyplugin, plugins_dir);
-                    var cfg = configChanges.get_platform_json(plugins_dir, 'ios');
-                    cfg.prepare_queue.installed = [{'plugin':'DummyPlugin', 'vars':{}}];
-                    configChanges.save_platform_json(cfg, plugins_dir, 'ios');
-
-                    spyOn(plist, 'parseFileSync').andReturn({Plugins:{}});
-                    var spy = spyOn(events, 'emit');
-                    configChanges.process(plugins_dir, temp, 'ios');
-                    expect(spy).toHaveBeenCalledWith('warn', 'DEPRECATION WARNING: Plugin
"com.phonegap.plugins.dummyplugin" uses <plugins-plist> element(s), which are now deprecated.
Support will be removed in Cordova 3.4.');
-                });
-            });
             it('should resolve wildcard config-file targets to the project, if applicable',
function() {
                 shell.cp('-rf', ios_config_xml, temp);
                 shell.cp('-rf', cbplugin, plugins_dir);
@@ -361,7 +334,7 @@ describe('config-changes module', function() {
 
                 configChanges.process(plugins_dir, temp, 'android');
 
-                cfg = configChanges.get_platform_json(plugins_dir, 'android');
+                var cfg = configChanges.get_platform_json(plugins_dir, 'android');
                 expect(cfg.prepare_queue.installed.length).toEqual(0);
                 expect(cfg.installed_plugins['com.adobe.vars']).toBeDefined();
                 expect(cfg.installed_plugins['com.adobe.vars']['API_KEY']).toEqual('hi');
@@ -456,33 +429,6 @@ describe('config-changes module', function() {
                 expect(cfg.prepare_queue.uninstalled.length).toEqual(0);
                 expect(cfg.installed_plugins['com.adobe.vars']).not.toBeDefined();
             });
-            it('should only parse + remove plist plugin entries in applicably old ios projects',
function() {
-                shell.cp('-rf', ios_plist_project, temp);
-                // install plugin
-                configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'DummyPlugin',
'ios', {});
-                configChanges.process(plugins_dir, temp, 'ios');
-                // set up an uninstall
-                configChanges.add_uninstalled_plugin_to_prepare_queue(plugins_dir, 'DummyPlugin',
'ios');
-
-                ios_parser.purgeProjectFileCache(temp);
-                var spy = spyOn(plist, 'parseFileSync').andReturn({Plugins:{}});
-                configChanges.process(plugins_dir, temp, 'ios');
-                expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp', 'PhoneGap.plist').replace(/\\/g,
'/'));
-            });
-            it('should provide a deprecation warning message when used', function() {
-                shell.cp('-rf', ios_plist_project, temp);
-                // install plugin
-                configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'DummyPlugin',
'ios', {});
-                configChanges.process(plugins_dir, temp, 'ios');
-                // set up an uninstall
-                configChanges.add_uninstalled_plugin_to_prepare_queue(plugins_dir, 'DummyPlugin',
'ios');
-
-                ios_parser.purgeProjectFileCache(temp);
-                spyOn(plist, 'parseFileSync').andReturn({Plugins:{}});
-                var spy = spyOn(events, 'emit');
-                configChanges.process(plugins_dir, temp, 'ios');
-                expect(spy).toHaveBeenCalledWith('warn', 'DEPRECATION WARNING: Plugin "com.phonegap.plugins.dummyplugin"
uses <plugins-plist> element(s), which are now deprecated. Support will be removed in
Cordova 3.4.');
-            });
             it('should save changes to global config munge after completing an uninstall',
function() {
                 shell.cp('-rf', android_two_project, temp);
                 shell.cp('-rf', varplugin, plugins_dir);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/08b045b7/src/util/config-changes.js
----------------------------------------------------------------------
diff --git a/src/util/config-changes.js b/src/util/config-changes.js
index 262e4aa..5872cf6 100644
--- a/src/util/config-changes.js
+++ b/src/util/config-changes.js
@@ -154,18 +154,6 @@ function generate_plugin_config_munge(plugin_dir, platform, project_dir,
vars) {
         // add platform-specific config changes if they exist
         changes = changes.concat(platformTag.findall('config-file'));
 
-        // note down plugins-plist munges in special section of munge obj
-        var plugins_plist = platformTag.findall('plugins-plist');
-        plugins_plist.forEach(function(pl) {
-            if (!munge['plugins-plist']) {
-                munge['plugins-plist'] = {};
-            }
-            var key = pl.attrib['key'];
-            var value = pl.attrib['string'];
-            if (!munge['plugins-plist'][key]) {
-                munge['plugins-plist'][key] = value;
-            }
-        });
         // note down pbxproj framework munges in special section of munge obj
         // CB-5238 this is only for systems frameworks
         var frameworks = platformTag.findall('framework');
@@ -244,16 +232,6 @@ function unmerge_plugin_changes(plugin_name, plugin_id, is_top_level,
should_dec
 
     var plistObj, pbxproj;
     if (self.platform == 'ios') {
-        if (global_munge['plugins-plist'] && config_munge['plugins-plist']) {
-            var plistfile = glob.sync(path.join(self.project_dir, '**', '{PhoneGap,Cordova}.plist'));
-            if (plistfile.length > 0) {
-                plistfile = plistfile[0];
-                // determine if this is a binary or ascii plist and choose the parser
-                // this is temporary until binary support is added to node-plist
-                var pl = (isBinaryPlist(plistfile) ? bplist : plist);
-                plistObj = pl.parseFileSync(plistfile);
-            }
-        }
         if (global_munge['framework'] && config_munge['framework']) {
             pbxproj = ios_parser.parseProjectFile(self.project_dir);
         }
@@ -262,19 +240,13 @@ function unmerge_plugin_changes(plugin_name, plugin_id, is_top_level,
should_dec
     // Traverse config munge and decrement global munge
     Object.keys(config_munge).forEach(function(file) {
         if (file == 'plugins-plist' && self.platform == 'ios') {
-            // Handle plist files in ios
-            if (global_munge[file]) {
-                Object.keys(config_munge[file]).forEach(function(key) {
-                    if (global_munge[file][key] && plistObj) {
-                        // TODO: REMOVE in 3.4 (https://issues.apache.org/jira/browse/CB-4456)
-                        events.emit('warn', 'DEPRECATION WARNING: Plugin "' + plugin_id +
'" uses <plugins-plist> element(s), which are now deprecated. Support will be removed
in Cordova 3.4.');
-                        delete plistObj.Plugins[key];
-                        // TODO: don't write out on every change, do it once.
-                        fs.writeFileSync(plistfile, plist.build(plistObj));
-                        delete global_munge[file][key];
-                    }
-                });
-            }
+            // TODO: remove this check and <plugins-plist> sections in spec/plugins/../plugin.xml
files.
+            events.emit(
+                    'warn',
+                    'WARNING: Plugin "' + plugin_id + '" uses <plugins-plist> element(s),
' +
+                    'which are no longer supported. Support has been removed as of Cordova
3.4.'
+            );
+            return;
         } else if (global_munge[file]) {
             // Handle arbitrary XML/pbxproj changes
             var is_framework = (self.platform == 'ios' && file == 'framework');
@@ -342,16 +314,6 @@ function apply_plugin_changes(plugin_id, plugin_vars, is_top_level, should_incre
     var pbxproj = cache.pbxproj;
 
     if (self.platform == 'ios') {
-        if (config_munge['plugins-plist']) {
-            var plistfile = glob.sync(path.join(self.project_dir, '**', '{PhoneGap,Cordova}.plist'));
-            if (plistfile.length > 0) {
-                plistfile = plistfile[0];
-                // determine if this is a binary or ascii plist and choose the parser
-                // this is temporary until binary support is added to node-plist
-                var pl = (isBinaryPlist(plistfile) ? bplist : plist);
-                plistObj = pl.parseFileSync(plistfile);
-            }
-        }
         if (config_munge['framework']) {
             if (!pbxproj) {
                 // Note, parseProjectFile() is slow, ~250ms on MacBook Pro 2013.
@@ -369,48 +331,43 @@ function apply_plugin_changes(plugin_id, plugin_vars, is_top_level,
should_incre
         Object.keys(config_munge[file]).forEach(function(selector) {
             // Handle plist files on ios.
             if (file == 'plugins-plist' && self.platform == 'ios') {
-                var key = selector;
-                if (!global_munge[file][key] && plistObj) {
-                    // TODO: REMOVE in 3.4 (https://issues.apache.org/jira/browse/CB-4456)
-                    events.emit('warn', 'DEPRECATION WARNING: Plugin "' + plugin_id + '"
uses <plugins-plist> element(s), which are now deprecated. Support will be removed in
Cordova 3.4.');
-                    // this key does not exist, so add it to plist
-                    global_munge[file][key] = config_munge[file][key];
-                    plistObj.Plugins[key] = config_munge[file][key];
-                    // TODO: dont write on every loop eh
-                    fs.writeFileSync(plistfile, plist.build(plistObj));
+                events.emit(
+                    'warn',
+                    'WARNING: Plugin "' + plugin_id + '" uses <plugins-plist> element(s),
' +
+                    'which are no longer supported. Support has been removed as of Cordova
3.4.'
+                );
+                return;
+            }
+            // Handle arbitrary XML OR pbxproj framework stuff
+            if (!global_munge[file][selector]) {
+                global_munge[file][selector] = {};
+            }
+            Object.keys(config_munge[file][selector]).forEach(function(xml_child) {
+                if (!global_munge[file][selector][xml_child]) {
+                    global_munge[file][selector][xml_child] = 0;
                 }
-            } else {
-                // Handle arbitrary XML OR pbxproj framework stuff
-                if (!global_munge[file][selector]) {
-                    global_munge[file][selector] = {};
+                if (should_increment) {
+                    global_munge[file][selector][xml_child] += 1;
                 }
-                Object.keys(config_munge[file][selector]).forEach(function(xml_child) {
-                    if (!global_munge[file][selector][xml_child]) {
-                        global_munge[file][selector][xml_child] = 0;
-                    }
-                    if (should_increment) {
-                        global_munge[file][selector][xml_child] += 1;
-                    }
-                    if (global_munge[file][selector][xml_child] == 1) {
-                        if (is_framework) {
-                            var src = selector; // 2nd-level leaves are src path
-                            // Only add the framework if it's not a cordova-ios core framework
-                            if (keep_these_frameworks.indexOf(src) == -1) {
-                                // xml_child in this case is whether the framework should
use weak or not
-                                var opt = {weak: (xml_child != 'true' ? false : true)};
-                                pbxproj.xcode.addFramework(src, opt);
-                                pbxproj.needs_write = true;
-                            }
-                        } else {
-                            // this xml child is new, graft it (only if config file exists)
-                            var config_file = self.config_keeper.get(self.project_dir, self.platform,
file);
-                            if (config_file.exists) {
-                                config_file.graft_child(selector, xml_child);
-                            }
+                if (global_munge[file][selector][xml_child] == 1) {
+                    if (is_framework) {
+                        var src = selector; // 2nd-level leaves are src path
+                        // Only add the framework if it's not a cordova-ios core framework
+                        if (keep_these_frameworks.indexOf(src) == -1) {
+                            // xml_child in this case is whether the framework should use
weak or not
+                            var is_weak = {weak: (xml_child === 'true')};
+                            pbxproj.xcode.addFramework(src, is_weak);
+                            pbxproj.needs_write = true;
+                        }
+                    } else {
+                        // this xml child is new, graft it (only if config file exists)
+                        var config_file = self.config_keeper.get(self.project_dir, self.platform,
file);
+                        if (config_file.exists) {
+                            config_file.graft_child(selector, xml_child);
                         }
                     }
-                });
-            }
+                }
+            });
         });
     });
     platform_config.config_munge = global_munge;
@@ -539,7 +496,7 @@ function ConfigFile_load() {
     // config file may be in a place not exactly specified in the target
     var filepath = self.filepath = resolveConfigFilePath(self.project_dir, self.platform,
self.file_tag);
 
-    if (!fs.existsSync(filepath)) {
+    if ( !filepath || !fs.existsSync(filepath) ) {
         self.exists = false;
         return;
     }


Mime
View raw message