apla / me.apla.cordova.app-preferences

App preferences plugin for cordova
Apache License 2.0
201 stars 209 forks source link

Automate plugin processing using hooks and automate ios xcodeproj insertion #50

Closed SomaticIT closed 8 years ago

SomaticIT commented 8 years ago

Hello,

This PR is linked to issue #46. This PR allows to automatically generates natives bindings for app-settings.json.

To avoid code duplication and optimise build process I rewrote lib/mobile_preferences.js into separated context independent modules and using promises to be compatible with Cordova Hooks:

All those modules have dependencies injected, allowing to use Cordova inner require context when using plugin from cli (using hooks) and node.js context when using the plugin from plugman (using build-app-settings.js).

Then I added 3 books :

I also moved existing tests to separates spec definitions in order to keep tests aligned with lib.

Possible Improvements :

Hope you will love it.

apla commented 8 years ago

I made one mistake and mixed two separate functionalities in one repo — plugin and preference generator. Until Cordova 5.0 this is not a problem because cordova using one repo for modules and you can install generators by running npm. Seems like your PR can handle this problem.

SomaticIT commented 8 years ago

Thanks for merging.

I tested it with Cordova 5.3.3 and it seems to work with both build-app-settings.js and cordova prepare.

One thing I didn't report in my previous comment, I had to replace libxmljs dependency by elementtree which is user by cordova-lib internally.

Thanks.

SomaticIT commented 8 years ago

Did you publish 0.7.2 release ?

apla commented 8 years ago

Yes, you can update via npm. I've already found libxmljs > elementtree migration and it is fine.

SomaticIT commented 8 years ago

Great ! Thanks.

mohitmayank commented 8 years ago

facing a small issue cause of this. if i remove and re-add android platform getting following error -

Error: ENOENT, open 'platforms/android/src/me/apla/cordova/AppPreferencesActivity.java'
    at Error (native)

perhaps moving the hook to before_build might help?

I don't add platform directory to version control. I also do customization on plugins and sometimes need to reset platform directory.