You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Anis KADRI <an...@gmail.com> on 2014/02/20 02:05:26 UTC
Re: [16/16] git commit: config-changes.js: Add reapply_global_munge().
I've only looked at this briefly but it is sooooo welcome! Thanks Mark!
On Wed, Feb 19, 2014 at 12:33 PM, <ag...@apache.org> wrote:
> config-changes.js: Add reapply_global_munge().
>
> Load and apply the full munge from platform json.
> To be used by cordova prepare.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/8ba299e5
> Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/8ba299e5
> Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/8ba299e5
>
> Branch: refs/heads/master
> Commit: 8ba299e50661681db786c2341ea88e1924234f0e
> Parents: 5fbf558
> Author: Mark Koudritsky <ka...@chromium.org>
> Authored: Thu Feb 13 16:56:52 2014 -0500
> Committer: Andrew Grieve <ag...@chromium.org>
> Committed: Wed Feb 19 15:32:26 2014 -0500
>
> ----------------------------------------------------------------------
> src/util/config-changes.js | 43 +++++++++++++++++++++++++++++++++++------
> 1 file changed, 37 insertions(+), 6 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/8ba299e5/src/util/config-changes.js
> ----------------------------------------------------------------------
> diff --git a/src/util/config-changes.js b/src/util/config-changes.js
> index cc96b57..8e1796b 100644
> --- a/src/util/config-changes.js
> +++ b/src/util/config-changes.js
> @@ -30,7 +30,7 @@
> * reference counts.
> */
>
> -/* jshint node:true, sub:true, indent:4 */
> +/* jshint node:true, sub:true, unused:true, indent:4 */
>
> var fs = require('fs'),
> path = require('path'),
> @@ -41,7 +41,6 @@ var fs = require('fs'),
> et = require('elementtree'),
> underscore = require('underscore'),
> xml_helpers = require('./../util/xml-helpers'),
> - ios_parser = require('./../platforms/ios'),
> platforms = require('./../platforms'),
> events = require('./../events'),
> plist_helpers = require('./../util/plist-helpers');
> @@ -66,20 +65,20 @@ Adapters to keep the current refactoring effort to
> within this file
> package.add_plugin_changes = function(platform, project_dir, plugins_dir,
> plugin_id, plugin_vars, is_top_level, should_increment, cache) {
> var munger = new PlatformMunger(platform, project_dir, plugins_dir);
> munger.add_plugin_changes(plugin_id, plugin_vars, is_top_level,
> should_increment, cache);
> - munger.config_keeper.save_all();
> + munger.save_all();
> };
>
> package.remove_plugin_changes = function(platform, project_dir,
> plugins_dir, plugin_name, plugin_id, is_top_level, should_decrement) {
> // TODO: should_decrement paramenter is never used, remove it here
> and wherever called
> var munger = new PlatformMunger(platform, project_dir, plugins_dir);
> munger.remove_plugin_changes(plugin_name, plugin_id, is_top_level);
> - munger.config_keeper.save_all();
> + munger.save_all();
> };
>
> package.process = function(plugins_dir, project_dir, platform) {
> var munger = new PlatformMunger(platform, project_dir, plugins_dir);
> munger.process();
> - munger.config_keeper.save_all();
> + munger.save_all();
> };
>
>
> /******************************************************************************/
> @@ -119,6 +118,12 @@ function PlatformMunger(platform, project_dir,
> plugins_dir) {
> this.config_keeper = new ConfigKeeper();
> }
>
> +// Write out all unsaved files.
> +PlatformMunger.prototype.save_all = PlatformMunger_save_all;
> +function PlatformMunger_save_all() {
> + this.config_keeper.save_all();
> +}
> +
> // Deal with a single file munge.
> // Theoretically, since files are independent several of those can run in
> parallel.
> PlatformMunger.prototype.apply_file_munge =
> PlatformMunger_apply_file_munge;
> @@ -231,7 +236,6 @@ function add_plugin_changes(plugin_id, plugin_vars,
> is_top_level, should_increme
> );
> continue;
> }
> - // TODO: This is mostly file IO and can run in parallel since
> each file is independent.
> self.apply_file_munge(file, munge[file]);
> }
>
> @@ -246,6 +250,32 @@ function add_plugin_changes(plugin_id, plugin_vars,
> is_top_level, should_increme
> module.exports.save_platform_json(platform_config, self.plugins_dir,
> self.platform);
> }
>
> +
> +// Load the global munge from platform json and apply all of it.
> +// Used by cordova prepare to re-generate some config file from platform
> +// defaults and the global munge.
> +PlatformMunger.prototype.reapply_global_munge = reapply_global_munge ;
> +function reapply_global_munge () {
> + var self = this;
> +
> + var platform_config =
> module.exports.get_platform_json(self.plugins_dir, self.platform);
> + var global_munge = platform_config.config_munge;
> + for (var file in global_munge) {
> + // TODO: remove this warning some time after 3.4 is out.
> + if (file == 'plugins-plist' && self.platform == 'ios') {
> + events.emit(
> + 'warn',
> + 'WARNING: One of your plugins uses <plugins-plist>
> element(s), ' +
> + 'which are no longer supported. Support has been removed
> as of Cordova 3.4.'
> + );
> + continue;
> + }
> + // TODO: This is mostly file IO and can run in parallel since
> each file is independent.
> + self.apply_file_munge(file, global_munge[file]);
> + }
> +}
> +
> +
> // generate_plugin_config_munge
> PlatformMunger.prototype.generate_plugin_config_munge =
> generate_plugin_config_munge;
> function generate_plugin_config_munge(plugin_dir, vars) {
> @@ -320,6 +350,7 @@ function generate_plugin_config_munge(plugin_dir,
> vars) {
> return munge;
> }
>
> +
> // Go over the prepare queue an apply the config munges for all plugins
> // that have been (un)installed.
> PlatformMunger.prototype.process = PlatformMunger_process;
>
>