You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/06/03 23:12:58 UTC
[1/3] git commit: exposed the config_changes module to the top-level
module. refactored config-changes into discrete add+remove methods for
handling config additions/removals.
Updated Branches:
refs/heads/master 0a8c95a5c -> fbb776847
exposed the config_changes module to the top-level module. refactored config-changes into discrete add+remove methods for handling config additions/removals.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/9bac1101
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/9bac1101
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/9bac1101
Branch: refs/heads/master
Commit: 9bac110106aa633c621d5637f74d0759e32d8567
Parents: 0a8c95a
Author: Fil Maj <ma...@gmail.com>
Authored: Mon Jun 3 14:02:41 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Mon Jun 3 14:02:41 2013 -0700
----------------------------------------------------------------------
plugman.js | 3 +-
src/util/config-changes.js | 326 +++++++++++++++++++++------------------
2 files changed, 177 insertions(+), 152 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9bac1101/plugman.js
----------------------------------------------------------------------
diff --git a/plugman.js b/plugman.js
index a033545..755204f 100755
--- a/plugman.js
+++ b/plugman.js
@@ -22,5 +22,6 @@ module.exports = {
install: require('./src/install'),
uninstall:require('./src/uninstall'),
fetch: require('./src/fetch'),
- prepare: require('./src/prepare')
+ prepare: require('./src/prepare'),
+ config_changes:require('./src/util/config-changes')
};
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/9bac1101/src/util/config-changes.js
----------------------------------------------------------------------
diff --git a/src/util/config-changes.js b/src/util/config-changes.js
index 89a1440..b37b22a 100644
--- a/src/util/config-changes.js
+++ b/src/util/config-changes.js
@@ -131,117 +131,23 @@ module.exports = {
});
return munge;
},
- process:function(plugins_dir, project_dir, platform) {
- checkPlatform(platform);
-
+ remove_plugin_changes:function(platform, project_dir, plugins_dir, plugin_id, plugin_vars, is_top_level, should_decrement) {
var platform_config = module.exports.get_platform_json(plugins_dir, platform);
- // Uninstallation first
- platform_config.prepare_queue.uninstalled.forEach(function(u) {
- var plugin_dir = path.join(plugins_dir, u.plugin);
- var plugin_id = u.id;
- var plugin_vars = (u.topLevel ? platform_config.installed_plugins[plugin_id] : platform_config.dependent_plugins[plugin_id]);
-
- // get config munge, aka how did this plugin change various config files
- var config_munge = module.exports.generate_plugin_config_munge(plugin_dir, platform, project_dir, plugin_vars);
- // global munge looks at all plugins' changes to config files
- var global_munge = platform_config.config_munge;
-
- // Traverse config munge and decrement global munge
- Object.keys(config_munge).forEach(function(file) {
- if (file == 'plugins-plist' && platform == 'ios') {
- if (global_munge[file]) {
- Object.keys(config_munge[file]).forEach(function(key) {
- if (global_munge[file][key]) {
- // prune from old plist if exists
- var plistfile = glob.sync(path.join(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);
- var plistObj = pl.parseFileSync(plistfile);
- delete plistObj.Plugins[key];
- fs.writeFileSync(plistfile, plist.build(plistObj));
- }
- delete global_munge[file][key];
- }
- });
- }
- } else if (global_munge[file]) {
- Object.keys(config_munge[file]).forEach(function(selector) {
- if (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] -= 1;
- if (global_munge[file][selector][xml_child] === 0) {
- // this xml child is no longer necessary, prune it
- // config.xml referenced in ios config changes refer to the project's config.xml, which we need to glob for.
- var filepath = resolveConfigFilePath(project_dir, platform, file);
- if (fs.existsSync(filepath)) {
- if (path.extname(filepath) == '.xml') {
- var xml_to_prune = [et.XML(xml_child)];
- var doc = xml_helpers.parseElementtreeSync(filepath);
- if (xml_helpers.pruneXML(doc, xml_to_prune, selector)) {
- // were good, write out the file!
- fs.writeFileSync(filepath, doc.write({indent: 4}), 'utf-8');
- } else {
- // uh oh
- throw new Error('pruning xml at selector "' + selector + '" from "' + filepath + '" during config uninstall went bad :(');
- }
- } else {
- // plist file
- var pl = (isBinaryPlist(filepath) ? bplist : plist);
- var plistObj = pl.parseFileSync(filepath);
- if (plist_helpers.prunePLIST(plistObj, xml_child, selector)) {
- fs.writeFileSync(filepath, plist.build(plistObj));
- } else {
- throw new Error('grafting to plist "' + filepath + '" during config install went bad :(');
- }
- }
- }
- delete global_munge[file][selector][xml_child];
- }
- }
- });
- }
- });
- }
- });
- platform_config.config_munge = global_munge;
-
- // Remove from installed_plugins
- if (u.topLevel) {
- delete platform_config.installed_plugins[plugin_id]
- } else {
- delete platform_config.dependent_plugins[plugin_id]
- }
- });
+ var plugin_dir = path.join(plugins_dir, plugin_id);
+ var plugin_vars = (is_top_level ? platform_config.installed_plugins[plugin_id] : platform_config.dependent_plugins[plugin_id]);
- // Empty out uninstalled queue.
- platform_config.prepare_queue.uninstalled = [];
-
- // Now handle instalation
- platform_config.prepare_queue.installed.forEach(function(u) {
- var plugin_dir = path.join(plugins_dir, u.plugin);
- var plugin_vars = u.vars;
- var plugin_id = xml_helpers.parseElementtreeSync(path.join(plugin_dir, 'plugin.xml'), 'utf-8')._root.attrib['id'];
-
- // get config munge, aka how should this plugin change various config files
- var config_munge = module.exports.generate_plugin_config_munge(plugin_dir, platform, project_dir, plugin_vars);
- // global munge looks at all plugins' changes to config files
- var global_munge = platform_config.config_munge;
-
- // Traverse config munge and decrement global munge
- Object.keys(config_munge).forEach(function(file) {
- if (!global_munge[file]) {
- global_munge[file] = {};
- }
- Object.keys(config_munge[file]).forEach(function(selector) {
- if (file == 'plugins-plist' && platform == 'ios') {
- var key = selector;
- if (!global_munge[file][key]) {
- // this key does not exist, so add it to plist
- global_munge[file][key] = config_munge[file][key];
+ // get config munge, aka how did this plugin change various config files
+ var config_munge = module.exports.generate_plugin_config_munge(plugin_dir, platform, project_dir, plugin_vars);
+ // global munge looks at all plugins' changes to config files
+ var global_munge = platform_config.config_munge;
+
+ // Traverse config munge and decrement global munge
+ Object.keys(config_munge).forEach(function(file) {
+ if (file == 'plugins-plist' && platform == 'ios') {
+ if (global_munge[file]) {
+ Object.keys(config_munge[file]).forEach(function(key) {
+ if (global_munge[file][key]) {
+ // prune from old plist if exists
var plistfile = glob.sync(path.join(project_dir, '**', '{PhoneGap,Cordova}.plist'));
if (plistfile.length > 0) {
plistfile = plistfile[0];
@@ -249,64 +155,178 @@ module.exports = {
// this is temporary until binary support is added to node-plist
var pl = (isBinaryPlist(plistfile) ? bplist : plist);
var plistObj = pl.parseFileSync(plistfile);
- plistObj.Plugins[key] = config_munge[file][key];
+ delete plistObj.Plugins[key];
fs.writeFileSync(plistfile, plist.build(plistObj));
}
+ delete global_munge[file][key];
}
- } else {
- if (!global_munge[file][selector]) {
- global_munge[file][selector] = {};
- }
+ });
+ }
+ } else if (global_munge[file]) {
+ Object.keys(config_munge[file]).forEach(function(selector) {
+ if (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;
- }
- global_munge[file][selector][xml_child] += 1;
- if (global_munge[file][selector][xml_child] == 1) {
- // this xml child is new, graft it (only if config file exists)
- // config file may be in a place not exactly specified in the target
- var filepath = resolveConfigFilePath(project_dir, platform, file);
- if (fs.existsSync(filepath)) {
- // look at ext and do proper config change based on file type
- if (path.extname(filepath) == '.xml') {
- var xml_to_graft = [et.XML(xml_child)];
- var doc = xml_helpers.parseElementtreeSync(filepath);
- if (xml_helpers.graftXML(doc, xml_to_graft, selector)) {
- // were good, write out the file!
- fs.writeFileSync(filepath, doc.write({indent: 4}), 'utf-8');
- } else {
- // uh oh
- throw new Error('grafting xml at selector "' + selector + '" from "' + filepath + '" during config install went bad :(');
- }
- } else {
- // plist file
- var pl = (isBinaryPlist(filepath) ? bplist : plist);
- var plistObj = pl.parseFileSync(filepath);
- if (plist_helpers.graftPLIST(plistObj, xml_child, selector)) {
- fs.writeFileSync(filepath, plist.build(plistObj));
+ if (global_munge[file][selector][xml_child]) {
+ if (should_decrement) {
+ global_munge[file][selector][xml_child] -= 1;
+ }
+ if (global_munge[file][selector][xml_child] === 0) {
+ // this xml child is no longer necessary, prune it
+ // config.xml referenced in ios config changes refer to the project's config.xml, which we need to glob for.
+ var filepath = resolveConfigFilePath(project_dir, platform, file);
+ if (fs.existsSync(filepath)) {
+ if (path.extname(filepath) == '.xml') {
+ var xml_to_prune = [et.XML(xml_child)];
+ var doc = xml_helpers.parseElementtreeSync(filepath);
+ if (xml_helpers.pruneXML(doc, xml_to_prune, selector)) {
+ // were good, write out the file!
+ fs.writeFileSync(filepath, doc.write({indent: 4}), 'utf-8');
+ } else {
+ // uh oh
+ throw new Error('pruning xml at selector "' + selector + '" from "' + filepath + '" during config uninstall went bad :(');
+ }
} else {
- throw new Error('grafting to plist "' + filepath + '" during config install went bad :(');
+ // plist file
+ var pl = (isBinaryPlist(filepath) ? bplist : plist);
+ var plistObj = pl.parseFileSync(filepath);
+ if (plist_helpers.prunePLIST(plistObj, xml_child, selector)) {
+ fs.writeFileSync(filepath, plist.build(plistObj));
+ } else {
+ throw new Error('grafting to plist "' + filepath + '" during config install went bad :(');
+ }
}
}
+ delete global_munge[file][selector][xml_child];
}
}
});
}
});
- });
- platform_config.config_munge = global_munge;
+ }
+ });
+ platform_config.config_munge = global_munge;
- // Move to installed_plugins if it is a top-level plugin
- if (u.topLevel) {
- platform_config.installed_plugins[plugin_id] = plugin_vars || {};
- } else {
- platform_config.dependent_plugins[plugin_id] = plugin_vars || {};
+ // Remove from installed_plugins
+ if (is_top_level) {
+ delete platform_config.installed_plugins[plugin_id]
+ } else {
+ delete platform_config.dependent_plugins[plugin_id]
+ }
+
+ // save
+ module.exports.save_platform_json(platform_config, plugins_dir, platform);
+ },
+ add_plugin_changes:function(platform, project_dir, plugins_dir, plugin_id, plugin_vars, is_top_level, should_increment) {
+ var platform_config = module.exports.get_platform_json(plugins_dir, platform);
+ var plugin_dir = path.join(plugins_dir, plugin_id);
+ plugin_id = xml_helpers.parseElementtreeSync(path.join(plugin_dir, 'plugin.xml'), 'utf-8')._root.attrib['id'];
+
+ // get config munge, aka how should this plugin change various config files
+ var config_munge = module.exports.generate_plugin_config_munge(plugin_dir, platform, project_dir, plugin_vars);
+ // global munge looks at all plugins' changes to config files
+ var global_munge = platform_config.config_munge;
+
+ // Traverse config munge and decrement global munge
+ Object.keys(config_munge).forEach(function(file) {
+ if (!global_munge[file]) {
+ global_munge[file] = {};
}
+ Object.keys(config_munge[file]).forEach(function(selector) {
+ if (file == 'plugins-plist' && platform == 'ios') {
+ var key = selector;
+ if (!global_munge[file][key]) {
+ // this key does not exist, so add it to plist
+ global_munge[file][key] = config_munge[file][key];
+ var plistfile = glob.sync(path.join(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);
+ var plistObj = pl.parseFileSync(plistfile);
+ plistObj.Plugins[key] = config_munge[file][key];
+ fs.writeFileSync(plistfile, plist.build(plistObj));
+ }
+ }
+ } else {
+ 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;
+ }
+ if (should_increment) {
+ global_munge[file][selector][xml_child] += 1;
+ }
+ if (global_munge[file][selector][xml_child] == 1) {
+ // this xml child is new, graft it (only if config file exists)
+ // config file may be in a place not exactly specified in the target
+ var filepath = resolveConfigFilePath(project_dir, platform, file);
+ if (fs.existsSync(filepath)) {
+ // look at ext and do proper config change based on file type
+ if (path.extname(filepath) == '.xml') {
+ var xml_to_graft = [et.XML(xml_child)];
+ var doc = xml_helpers.parseElementtreeSync(filepath);
+ console.log(filepath, selector, xml_child);
+ if (xml_helpers.graftXML(doc, xml_to_graft, selector)) {
+ // were good, write out the file!
+ fs.writeFileSync(filepath, doc.write({indent: 4}), 'utf-8');
+ } else {
+ // uh oh
+ throw new Error('grafting xml at selector "' + selector + '" from "' + filepath + '" during config install went bad :(');
+ }
+ } else {
+ // plist file
+ var pl = (isBinaryPlist(filepath) ? bplist : plist);
+ var plistObj = pl.parseFileSync(filepath);
+ if (plist_helpers.graftPLIST(plistObj, xml_child, selector)) {
+ fs.writeFileSync(filepath, plist.build(plistObj));
+ } else {
+ throw new Error('grafting to plist "' + filepath + '" during config install went bad :(');
+ }
+ }
+ } else {
+ // ignore if file doesnt exist
+ }
+ }
+ });
+ }
+ });
+ });
+ platform_config.config_munge = global_munge;
+
+ // Move to installed_plugins if it is a top-level plugin
+ if (is_top_level) {
+ platform_config.installed_plugins[plugin_id] = plugin_vars || {};
+ } else {
+ platform_config.dependent_plugins[plugin_id] = plugin_vars || {};
+ }
+
+ // save
+ module.exports.save_platform_json(platform_config, plugins_dir, platform);
+ },
+ process:function(plugins_dir, project_dir, platform) {
+ checkPlatform(platform);
+
+ var platform_config = module.exports.get_platform_json(plugins_dir, platform);
+
+ // Uninstallation first
+ platform_config.prepare_queue.uninstalled.forEach(function(u) {
+ module.exports.remove_plugin_changes(platform, project_dir, plugins_dir, u.plugin, u.vars, u.topLevel, true);
+ });
+
+ // Now handle installation
+ platform_config.prepare_queue.installed.forEach(function(u) {
+ module.exports.add_plugin_changes(platform, project_dir, plugins_dir, u.plugin, u.vars, u.topLevel, true);
});
+
+ platform_config = module.exports.get_platform_json(plugins_dir, platform);
+ // Empty out uninstalled queue.
+ platform_config.prepare_queue.uninstalled = [];
// Empty out installed queue.
platform_config.prepare_queue.installed = [];
-
// save
module.exports.save_platform_json(platform_config, plugins_dir, platform);
}
@@ -331,8 +351,12 @@ function resolveConfigFilePath(project_dir, platform, file) {
} else {
// special-case config.xml target that is just "config.xml". this should be resolved to the real location of the file.
if (file == 'config.xml') {
- var matches = glob.sync(path.join(project_dir, '**', 'config.xml'));
- if (matches.length) filepath = matches[0];
+ if (platform == 'android') {
+ filepath = path.join(project_dir, 'res', 'xml', 'config.xml');
+ } else {
+ var matches = glob.sync(path.join(project_dir, '**', 'config.xml'));
+ if (matches.length) filepath = matches[0];
+ }
}
}
return filepath;
[2/3] git commit: fix for failing test in plugin uninstallation.
Posted by fi...@apache.org.
fix for failing test in plugin uninstallation.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/2694d3bd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/2694d3bd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/2694d3bd
Branch: refs/heads/master
Commit: 2694d3bde2cbbfd0e0ba46e203b2e7394ff6a9c3
Parents: 9bac110
Author: Fil Maj <ma...@gmail.com>
Authored: Mon Jun 3 14:11:35 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Mon Jun 3 14:11:35 2013 -0700
----------------------------------------------------------------------
src/util/config-changes.js | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2694d3bd/src/util/config-changes.js
----------------------------------------------------------------------
diff --git a/src/util/config-changes.js b/src/util/config-changes.js
index b37b22a..4a4d7ac 100644
--- a/src/util/config-changes.js
+++ b/src/util/config-changes.js
@@ -131,9 +131,10 @@ module.exports = {
});
return munge;
},
- remove_plugin_changes:function(platform, project_dir, plugins_dir, plugin_id, plugin_vars, is_top_level, should_decrement) {
+
+ remove_plugin_changes:function(platform, project_dir, plugins_dir, plugin_name, plugin_id, is_top_level, should_decrement) {
var platform_config = module.exports.get_platform_json(plugins_dir, platform);
- var plugin_dir = path.join(plugins_dir, plugin_id);
+ var plugin_dir = path.join(plugins_dir, plugin_name);
var plugin_vars = (is_top_level ? platform_config.installed_plugins[plugin_id] : platform_config.dependent_plugins[plugin_id]);
// get config munge, aka how did this plugin change various config files
@@ -268,7 +269,6 @@ module.exports = {
if (path.extname(filepath) == '.xml') {
var xml_to_graft = [et.XML(xml_child)];
var doc = xml_helpers.parseElementtreeSync(filepath);
- console.log(filepath, selector, xml_child);
if (xml_helpers.graftXML(doc, xml_to_graft, selector)) {
// were good, write out the file!
fs.writeFileSync(filepath, doc.write({indent: 4}), 'utf-8');
@@ -313,7 +313,7 @@ module.exports = {
// Uninstallation first
platform_config.prepare_queue.uninstalled.forEach(function(u) {
- module.exports.remove_plugin_changes(platform, project_dir, plugins_dir, u.plugin, u.vars, u.topLevel, true);
+ module.exports.remove_plugin_changes(platform, project_dir, plugins_dir, u.plugin, u.id, u.topLevel, true);
});
// Now handle installation
[3/3] git commit: 0.7.9
Posted by fi...@apache.org.
0.7.9
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/fbb77684
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/fbb77684
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/fbb77684
Branch: refs/heads/master
Commit: fbb7768470d2ee425bed0df6e99ab5be1043415d
Parents: 2694d3b
Author: Fil Maj <ma...@gmail.com>
Authored: Mon Jun 3 14:12:53 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Mon Jun 3 14:12:53 2013 -0700
----------------------------------------------------------------------
package.json | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/fbb77684/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index e6ae408..10341a4 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"author": "Andrew Lunny <al...@gmail.com>",
"name": "plugman",
"description": "install/uninstall Cordova plugins",
- "version": "0.7.8",
+ "version": "0.7.9",
"repository": {
"type": "git",
"url": "git://git-wip-us.apache.org/repos/asf/cordova-plugman.git"