-
Notifications
You must be signed in to change notification settings - Fork 28
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
Cordova-lib refactoring proposal #12
Cordova-lib refactoring proposal #12
Conversation
|
||
#### Plugin management | ||
|
||
PlatformApi.prototype.addPlugin = function (plugin, installOptions) {}; |
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.
plugin -> pluginInfo
You mention that the PlatformAPI will have a getPlatformInfo function that returns "the file structure and other properties". What exactly does this include? Does this include "the build output", and what notion is that? E.g. the iOS build output is a .app folder and maybe a plist file, while the windows build output is (a collection of) .appx or .appxbundle files? |
The definition of this class is here (decided to rename The location of build artifacts is intended to be returned as a result of |
This looks good to me. What are the next steps. I'd like to help |
@stevengill, I've just submitted a PR with final implementation. See apache/cordova-lib#282. Would appreciate your feedback. |
Now this API is finalized and implemented. What's a good place to publish docs for this? |
@nikhilkh I would say we should mention it in the readme of the platform repos and somewhere on docs. Docs are just so unorganized right now :( |
Readme for platform repo or cordova-lib is a good start. Eventually, we want to put all of these docs together and publish them on our site. |
Yup. Maybe like a "creating a new platform" section or "working with platforms" Maybe we need to differentiate docs for "developers working on cordova" + "plugin authors" and docs for people using cordova. |
Yup - creating a new platform is not a common task. However, integrating a platform in your workflow - gulp/grunt might be relevant for more people. It's un-validated use case and we might have issues with using the API that way. However, in theory these APIs might help with that. On those lines - maybe Api.js should be the index file of the package for the platform.
Though for the grunt/gulp story need some more thought- there are other options of using the cordova-lib api itself instead of cordova-android's platform API. There are probably pros and cons for each of these - we should come up with the guidance around this and blog about it eventually. |
+1. @vladimir-kotikov already set Api.js as main in package.json. So require('cordova-android') should work I believe. Haven't tested that yet. |
Confirm, it works
|
Minor nit pick, can we move this entire proposal in to a sub directory. Right now it would add 5 new files into the root proposals directory. We can also do this after merge though. |
Why isn't this PR in the repo? |
@vladimir-kotikov @stevengill I want to merge this PR so that we can see it in the repo. Please say if you have objections. |
Cordova-lib refactoring proposal
This PR is an updated version of #9 with addressed notes
The proposal describes the way how we can improve current cordova lib design and interaction between cordova lib and platforms. The document contains high-level descriptions of proposed interfaces only. For more details on methods signatures see *.js files in this pull request.
The most important points of this proposal are:
1. The PlatformApi class
PlatformApi (or CordovaPlatform) class - an abstraction around particular platform that exposes all the actions for this platform (such as build/run), so they're accessible programmatically. It also knows how to install/uninstall plugins with all source files, web assets and js files, so this is no more responsibility of cordova-lib. It also exposes single 'prepare' method to provide a way for cordova-lib to apply project's settings/www content to platform.
The PlatformApi class needs to be implemented by each platform, that wants to use new API flow. For those platforms, which doesn't provide own PlatformApi, there will be a polyfill in cordova-lib.
There is a PR to cordova-lib, which implements the polyfill: https://github.com/MSOpenTech/cordova-lib/pull/2
More detailed info: Cordova-lib refactoring proposal.md
Interface reference: PlatformApi.js
2. The ProjectAPI class
ProjectAPI (or CordovaProject) class - an abstraction of cordova project with multiple platforms/plugins installed. Manages the platforms and delegates the responsibilities to corresponding platform:
It also does some additional job:
More detailed info: Cordova-lib refactoring proposal.md
Interface reference: ProjectApi.js
cordova-common
module'cordova-common' module - required to share similar code between platforms and lib. Currently there are following candidates for moving to
cordova-common
:The PR for
cordova-common
module is ready and published here: https://github.com/MSOpenTech/cordova-lib/pull/3.Links:
PlatformApi proposal with APIs' definitions: #9
PlatformApi polyfill implementation for cordova-lib: https://github.com/MSOpenTech/cordova-lib/pull/2
cordova-common
implementation: https://github.com/MSOpenTech/cordova-lib/pull/3Pull requests:
PlatformApi
polyfill: https://github.com/MSOpenTech/cordova-lib/pull/2cordova-common
implementation: https://github.com/MSOpenTech/cordova-lib/pull/3