Skip to content
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

Plugin dependencies (using npm)? #38

Closed
brodycj opened this issue Apr 14, 2016 · 9 comments
Closed

Plugin dependencies (using npm)? #38

brodycj opened this issue Apr 14, 2016 · 9 comments

Comments

@brodycj
Copy link

brodycj commented Apr 14, 2016

I maintain several versions of the sqlite plugin and have been keeping them in sync by git merging. It is extremely time consuming to go through the merge-test stages over and over. It is especially time-consuming to keep the README.md documentation in reasonable sync.

It is possible to define sub-projects in git but I suspect the Cordova tooling would not follow such git sub-projects. I am also not convinced that this would be the best solution.

It would be possible to define a plugin to depend on other plugin(s), but I find this clumsy and error-prone and don't expect it to work with cordova-paramedic CI testing.

The solution I know of is to define a before_plugin_install hook script like they do in: https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn

In comparison, Node.js/npm defines a way for modules to depend on each other which works great for Javascript but does not support nested dependencies for C/C++ addon code modules.

EXTRA NOTE ADDED: It would be possible to include certain external dependencies by adding dependenc(y)(ies) on other plugin project(s) but this would not be supported by the automatic cordova-paramedic CI testing that I am using.

@brodycj
Copy link
Author

brodycj commented Apr 22, 2016

FYI I have a version of the sqlite plugin using npm in a before_plugin_install hook script to fetch its bigger sqlite library dependencies: https://github.com/brodybits/Cordova-sqlite-storage-common-dev

It is now working for Android, iOS, and Windows platforms. I am able to declare the external dependency in package.json and let the hook script just do npm install (within the correct directory).

Next week I will adapt the cordova-sqlite-ext version to fetch its dependencies this way. If this is working I will also adapt the main Cordova-sqlite-storage version to fetch its dependencies this way which will needed to include the Windows support.

I really want to thank @vjrantal and some others from the AllJoyn team for the hard work they did 1-2 years ago to get their plugin working on Android/iOS/Windows. Their work has really made it possible for me to integrate the Windows 8.1/Windows Phone 8.1 support last year and get this before_plugin_install hook working to add external dependencies.

I am very happy to have found a solution that lets me declare an external dependency in package.json and let npm fetch it for me. I would love to see a similar solution integrated with Cordova someday.

@stevengill
Copy link
Contributor

the --fetch work (apache/cordova-lib#407) will allow this by default! It will npm install your plugin (which will install all of the declared deps in package.json). Our current implementation does npm cache add and that does not fetch deps.

@brodycj brodycj changed the title Plugin sub-project dependencies? Plugin sub-project dependencies [using npm]? Apr 22, 2016
@brodycj
Copy link
Author

brodycj commented Apr 22, 2016

@stevengill I will give your --fetch work a try when I get a chance. I am closing this in favor of the fetching proposal in #33.

@brodycj brodycj closed this as completed Apr 22, 2016
@brodycj brodycj changed the title Plugin sub-project dependencies [using npm]? Plugin dependencies (using npm)? Apr 22, 2016
@brodycj
Copy link
Author

brodycj commented Apr 22, 2016

For the sqlite plugin I would rather not depend on the user adding a "--fetch" flag as discussed in #33 / Apache CB-9858.

@brodycj brodycj reopened this Apr 22, 2016
@stevengill
Copy link
Contributor

Yeah, I'd recommend keeping your hook for the time being. --fetch will hopefully be default in cordova 7 and you won't need the --fetch flag anymore

@brodycj
Copy link
Author

brodycj commented Apr 22, 2016

Thanks!

@nikhilkh
Copy link
Contributor

nikhilkh commented May 6, 2016

Looks like this issue just needs to be closed now.

@brodycj
Copy link
Author

brodycj commented Jun 14, 2016

When using the before_plugin_install hook to install dependencies the Cordova-sqlite-storage plugin does not work with PhoneGap Build [1] or Intel XDK [2]. TBD I have not tried this with the old plugman tool yet.

This is a catch-22 situation. I could declare a dependency on another plugin but this would not work with cordova-paramedic testing. A temporary solution would be to publish a special branch version with the sqlite3 dependencies manually included. I am hopeful that Apache CB-9858 will solve this problem.

[1] storesafe/cordova-sqlite-storage#477
[2] storesafe/cordova-sqlite-storage#489

@stevengill
Copy link
Contributor

Yes, PGBUILD doesn't allow hooks for security reasons.

You can test out fetch now with the --fetch flag with cordova 6.2.0, but PGBUILD probably won't start using fetch until it becomes the default (cordova 7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants