New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CB-11023 Add edit-config functionality #449
Conversation
Current coverage is 80.56%@@ master #449 diff @@
==========================================
Files 68 68
Lines 5387 5387
Methods 851 851
Messages 0 0
Branches 1042 1042
==========================================
Hits 4340 4340
Misses 1047 1047
Partials 0 0
|
config_munge = self.generate_plugin_config_munge(pluginInfo, plugin_vars); | ||
} | ||
else if (plugin_force) { | ||
CordovaLogger.get().log(CordovaLogger.WARN, '--force is used. edit-config will overwrite any conflicts'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add "conflicting plugins may not work as expected" to the end of this warning (or something to that effect)
@ktop the author name on the commit is "unknown" |
I've tested it out and I think there needs to be a slight tweak to the For example, If I have two plugins that conflict and I execute the following commands:
I will be left with a config file that has the changes that |
@riknoll If we have plugin-1, plugin-2 --force, and then add plugin-3 with --force, plugin-1 and plugin-2 should not be applied correct? |
@ktop Run As for the force add thing, that sounds fine to me. There are two possible behaviors:
I believe you are describing the first behavior. The difference between that and the current implementation is that the current implementation shouldn't store both sets of changes in platform.json. If the changes of plugin 1 get overwritten by plugin 2, then they should be undone before the changes of plugin 2 are made. Otherwise, the platform.json gets into a weird state. |
@ktop I also see "unknown" for your name in |
ahh must be because I didn't set up my git config after my computer got re-imaged. I have it set now and hopefully it will appear after I rebase. |
My latest commit will find all conflicts when --force is used and remove them before adding the new plugin. @riknoll or @macdonst can you try it out and let me know if you have any issues? Also looks like my git name got fixed in the latest commit, so I think after I rebase and squash, it'll fix the first commit. |
This is working fine for me! When this feature gets documented, we need to make sure to document how to get your project back in order if you mess it up by adding a plugin with I'll wait for @macdonst to take a look before I merge this. This change will require a platform release as well since it is in cordova-common. |
LGTM! Sorry for taking so long. My workspace is in a bad way and I think I need to kill it with fire and setup the whole thing from scratch. Once this gets into a release I have about 4 plugins I will modify to use this approach. |
Cool, let me rebase |
@riknoll I've rebased so this should be ready for merge. |
Done! Sorry for the delay. @ktop can you open a PR documenting this feature in the plugin.xml reference as well? |
@riknoll yea sure. Are there instructions on how/where documentation goes? |
Yep! The guide for writing xml references is here. The file you need to edit is the one I linked in my other comment in the |
New edit-config tag for plugin.xml will allow users to modify xml attributes of any xml file.
Using AndroidManifest.xml as an example. Assumes your AndroidManifest.xml has a second activity element with attribute android:name="SecondActivity"
file: specifies the file location
target: specifies an xpath to the element that you want to modify
modes:
children: will only modify one element per edit-config tag
There is conflict checking now....if a plugin wants to modify an attribute another plugin has already modified, an error will be thrown and plugin install will fail. The user must fix the conflict or they can use --force to force add the plugin and overwrite the conflict.
Lastly, on plugin uninstall, the plugin should restore the attributes to the state it was before installing.
Note: Using --force to overwrite a conflict will remove the conflicting attribute changes from the file. These changes will not be restorable since the attributes were forced to be overwritten. To get your changes back, you should uninstall then reinstall that plugin.