cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Maj <...@adobe.com>
Subject Re: CLI lazy loading of libraries
Date Thu, 13 Jun 2013 19:08:31 GMT
Pushed 2.8.17!

On 6/13/13 11:44 AM, "Michal Mocny" <mmocny@chromium.org> wrote:

>Sweet, going to test this now as well.
>
>
>On Thu, Jun 13, 2013 at 2:27 PM, Filip Maj <fil@adobe.com> wrote:
>
>> Alright guys, the lazy loading is merged into master2.
>>
>> I have tested on android, iOS and blackberry10. Also tested plugin
>> integration, barcodescanner plugin was successfully installed on iOS and
>> android and worked like a charm!
>>
>> I am pushing this up to npm as 2.8.16.
>>
>> On 6/12/13 7:58 AM, "Braden Shepherdson" <braden@chromium.org> wrote:
>>
>> >It's either: a directory on the local disk, or a .tar.gz on the web
>> >somewhere.
>> >
>> >This looks great, Fil!
>> >
>> >Braden
>> >
>> >
>> >On Tue, Jun 11, 2013 at 9:30 PM, Michal Mocny <mmocny@chromium.org>
>> wrote:
>> >
>> >> That sounds awesome, sweet work Fil!
>> >>
>> >> Question: your cordova-android lib example has the uri
>> >> "/Users/fil/src/cordova-android", but you mention supporting only
>> >>.tar.gz
>> >> -- does that mean that non-archived local directories are also
>> >>supported?
>> >>  (I should hope so).
>> >>
>> >> Thanks!
>> >> -Michal
>> >>
>> >>
>> >> On Tue, Jun 11, 2013 at 6:10 PM, Filip Maj <fil@adobe.com> wrote:
>> >>
>> >> > Hey guys another quick update
>> >> >
>> >> > I have made progress on the hooks/events/middleware approach and
>>opted
>> >> for
>> >> > a simpler, configuration approach. I think this approach satisfies
>> >> > requirements for Adobe w.r.t. phonegap's CLI, as well as the wishes
>> >> Michal
>> >> > and Braden expressed for customizing the various libraries the cli
>> >> > consumes.
>> >> >
>> >> > Once the git servers are back up, I'll push the latest code, but in
>> >>the
>> >> > meantime, here's how the "replace stock cordova libraries with your
>> >>own"
>> >> > functionality is coded atm - it's hooked into the lazy load
>> >> functionality:
>> >> >
>> >> > 1. customize project/.cordova/config.json's "lib" object to point
>>to
>> >> > specific locations of libraries (see examples below for detail)
>> >> >   - you can do so at a module-level as well by calling
>> >> > `cordova.config({lib:{/* whatever */}});
>> >> > 2. Then every time you go to add a platform, it checks if the
>> >>appropriate
>> >> > fields exist in the config.json, and if so, will lazy load the
>> >>necessary
>> >> > library before shelling out the library executable.
>> >> > 3. This also works with the cordova hello world app. So if you call
>> >> > cordova.config() with details about the location of your www assets
>> >>and
>> >> > whatnot before calling cordova.create(), it will use that info to
>>lazy
>> >> > load those assets first.
>> >> >
>> >> > ----
>> >> >
>> >> > Example 1: I want to use latest (master) of cordova-android from my
>> >>local
>> >> > filesystem
>> >> >
>> >> > You can do so via CLI or node-level module, here's the cli based
>> >>example:
>> >> > $ cordova create tmp
>> >> > $ vim tmp/.cordova/config.json
>> >> > * edit to add a path to the lib *
>> >> > $ cat tmp/.cordova/config.json
>> >> > {
>> >> >     id:'io.cordova.hello',
>> >> >     name:'HelloCordova',
>> >> >     lib:{
>> >> >         "android":{
>> >> >             uri:"/Users/fil/src/cordova-android",
>> >> >             version:"master"
>> >> >             id:"cordova-master"
>> >> >
>> >> >         }
>> >> >     }
>> >> > }
>> >> > $ cd tmp
>> >> > $ cordova platform add android
>> >> >
>> >> > ^ that will shell out to /Users/fil/src/cordova-android/bin/create
>> >> >
>> >> > You can do the same with a library that is stored on the web
>> >>somewhere.
>> >> > Currently, it must be a .tar.gz but nothing stopping us from adding
>> >>more
>> >> > support compression-wise. For example, imagine we have some fork of
>> >> > cordova-android that uses ChromeView instead.
>> >> >
>> >> > The above will also copy the local cordova-android directory into
>> >> > ~/.cordova/lib/android/cordova-master/master/.
>> >> >
>> >> > ----
>> >> >
>> >> > Example 2: I want to use phonegap-start www app instead of the
>> >> > cordova-app-hello-world
>> >> >
>> >> > Can only do so via node module right now (because the the www
>>assets
>> >>get
>> >> > copied over when you call create), but here's how you would do it:
>> >> >
>> >> > $ node
>> >> > > cordova=require('cordova');
>> >> > > app_path = '/location/that/my/app/will/exist'
>> >> > > cordova.config(app_path, {
>> >> >     lib:{
>> >> >         "www":{
>> >> >
>> >> > 
>>uri:"https://github.com/phonegap/phonegap-start/archive/2.5.0.tar.gz
>> ",
>> >> >             version:"2.5.0"
>> >> >             id:"phonegap"
>> >> >         }
>> >> >     }});
>> >> > > cordova.create(app_path);
>> >> > Downloading
>> >> > https://github.com/phonegap/phonegap-start/archive/2.5.0.tar.gz...
>> >> >
>> >> >
>> >> > Similarly to the my first example, this one will create a
>> >> > ~/.cordova/lib/www/phonegap/2.5.0 directory, with the contents of
>>the
>> >>tar
>> >> > ball extracted into it.
>> >> >
>> >> > ====
>> >> >
>> >> > I still have a bunch of work to do with this, like revamping our
>>tests
>> >> > completely and adding new coverage for these features, but inching
>> >> closer.
>> >> >
>> >> > On 6/7/13 2:46 PM, "Michael Brooks" <michael@michaelbrooks.ca>
>>wrote:
>> >> >
>> >> > >1. Awesome
>> >> > >
>> >> > >2. Very similar logic exists in the phonegap-cli [1] [2]. Since
>>this
>> >> logic
>> >> > >is being used by phonegap-cli, node-phonegap-build, and
>>cordova-cli,
>> >>we
>> >> > >could extract it out to a new NPM module called cordova-config.
>> >> > >
>> >> > >3. Additionally, PhoneGap will want to load its own Hello World
>>app
>> >> > >instead
>> >> > >of the Cordova Hello World app. So, it would be nice to accomodate
>> >>this
>> >> > >situation gracefully. Do Chrome Apps have any odd requirements?
>> >> > >
>> >> > >[1]
>> >> > >
>> >>
>> >>
>> 
>>https://github.com/mwbrooks/phonegap-cli/blob/master/lib/common/config.js
>> >> > >[2]
>> >> >
>> 
>>>>>https://github.com/mwbrooks/phonegap-cli/tree/master/spec/common/confi
>>>>>g
>> >> > >
>> >> > >
>> >> > >On Fri, Jun 7, 2013 at 2:38 PM, Filip Maj <fil@adobe.com>
wrote:
>> >> > >
>> >> > >> Cool, thanks Mike, I'll use the gitweb approach to download
>> >>libraries.
>> >> > >>
>> >> > >> And re #2: fair enough, I'll add that bit of logic to the
"find
>>the
>> >> root
>> >> > >> of a cordova project" utility function.
>> >> > >>
>> >> > >> As for the hooks, I am still mulling over different approaches.
>>One
>> >> > >> scenario that us Adobe folk want to support for PhoneGap is
>> >> redirecting
>> >> > >> any adds/builds for particular platforms that are not supported
>>on
>> >>a
>> >> > >> user's machine to PhoneGap Build. For example, if a user's
>>machine
>> >>was
>> >> > >>not
>> >> > >> setup for iOS development (say, a Windows machine), the PhoneGap
>> >>CLI
>> >> not
>> >> > >> only needs to know when a particular event happens, but also
>>needs
>> >>to
>> >> be
>> >> > >> able to stop the Cordova CLI from proceeding with the event
-
>> >> something
>> >> > >> akin to e.preventDefault() in DOM events.
>> >> > >>
>> >> > >> I'm not sure of any npm libraries out there that have a similar
>> >> eventing
>> >> > >> system in place but I will do some research and see if there
is
>>any
>> >> > >>prior
>> >> > >> art out there.
>> >> > >>
>> >> > >> If anyone on the list has any ideas, I'm all ears :)
>> >> > >>
>> >> > >> On 13-06-07 10:07 AM, "Michael Brooks"
>><michael@michaelbrooks.ca>
>> >> > wrote:
>> >> > >>
>> >> > >> >1. The Apache GitWeb implementation allows us to download
a
>> >>tar.gz of
>> >> > >>any
>> >> > >> >hash or tag. Using this will allow us to download any
platform
>> >> release.
>> >> > >> >Here is an example of how to download cordova-android
2.8.0
>>[1]. I
>> >> > >>think
>> >> > >> >this is better than downloading the entire release, because
>> >> > >>lazy-loading
>> >> > >> >is
>> >> > >> >meant to only grab what's needed. It's also a better choice
>>than
>> >> > >>GitHub's
>> >> > >> >downloads because Apache's mirroring is sometimes unreliable.
>> >> > >> >
>> >> > >> >2. We should use $HOME/.cordova/ There is no reason to
invent
>> >> > >> >yet-another-name for the Cordova configuration directory.
When
>>a
>> >> > >> >".cordova/" is found the $HOME directory, it is considered
a
>> >>global
>> >> > >> >configuration directory and not a Cordova project. We
can use
>> >> > >> >$HOME/.cordova/lib/cordova-android to store the lazy-loaded
>> >> libraries.
>> >> > >>I
>> >> > >> >chose "lib/" instead of "platforms/" because we will also
be
>> >> > >>lazy-loading
>> >> > >> >resources such as the Hello World app and someday perhaps
even
>> >> ios-sim.
>> >> > >> >
>> >> > >> >3. Sure, the hooks sound good.
>> >> > >> >
>> >> > >> >[1]
>> >> > >> >
>> >> > >>
>> >> > >>
>> >>
>> https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=snapshot
>> >> > ;
>> >> > >>h
>> >> > >> >=2.8.0;sf=tgz
>> >> > >> >
>> >> > >> >
>> >> > >> >On Fri, Jun 7, 2013 at 7:41 AM, Michal Mocny
>><mmocny@chromium.org
>> >
>> >> > >>wrote:
>> >> > >> >
>> >> > >> >> Glad to see movement on this.
>> >> > >> >>
>> >> > >> >> Few suggestions:
>> >> > >> >> - use $HOME/.cordova-config/libs  <-- this gives
us a folder
>>to
>> >>put
>> >> > >> >>other
>> >> > >> >> stuff into later, without littering $HOME with .cordova-this
>>and
>> >> > >> >> .cordova-that
>> >> > >> >> - I would love to have the ability to use different
>>cordova-lib
>> >> > >>versions
>> >> > >> >> within any project easily.  Changing the before-hook
or
>> >>adjusting
>> >> the
>> >> > >> >>libs
>> >> > >> >> folder sound like global operations.  Can we support
>>--libs-dir=
>> >> > >>command
>> >> > >> >> line flag to cordova-cli?  This should only need
to be
>> >>specified on
>> >> > >> >>create.
>> >> > >> >>
>> >> > >> >> -Michal
>> >> > >> >>
>> >> > >> >>
>> >> > >> >> On Fri, Jun 7, 2013 at 10:07 AM, Braden Shepherdson
<
>> >> > >> braden@chromium.org
>> >> > >> >> >wrote:
>> >> > >> >>
>> >> > >> >> > The Apache Way of having source release bundles
is
>>important
>> >>and
>> >> we
>> >> > >> >> follow
>> >> > >> >> > it. But we can download content for CLI from
wherever we
>> >>please.
>> >> > >>We're
>> >> > >> >> > currently downloading the libs from npm, getting
the code
>>from
>> >> npm
>> >> > >>and
>> >> > >> >> the
>> >> > >> >> > libs from Github doesn't change much.
>> >> > >> >> >
>> >> > >> >> > This is $HOME, as in /Users/me or /home/me or
>> >> > >>C:\Users\me\Application
>> >> > >> >> Data
>> >> > >> >> > or whatever it is on Windows? SGTM.
>> >> > >> >> >
>> >> > >> >> > The before hook should have the ability to substitute
their
>> >>own
>> >> > >>copy
>> >> > >> >>of
>> >> > >> >> the
>> >> > >> >> > libs from somewhere else, ideally a git URL/directory
and
>> >> revision.
>> >> > >> >>This
>> >> > >> >> > way it would be trivial to point CLI at master
versions of
>> >> > >>platforms.
>> >> > >> >> >
>> >> > >> >> > Braden
>> >> > >> >> >
>> >> > >> >> >
>> >> > >> >> > On Fri, Jun 7, 2013 at 3:58 AM, Filip Maj <fil@adobe.com>
>> >>wrote:
>> >> > >> >> >
>> >> > >> >> > > One of the last key outstanding tasks for
the CLI is lazy
>> >> > >>loading of
>> >> > >> >> > > platform libraries [1].
>> >> > >> >> > >
>> >> > >> >> > > I want to start tackling that tomorrow.
I have a few
>> >> > >> >>points/questions
>> >> > >> >> to
>> >> > >> >> > > bring up and wanted to share my vision
of the
>> >>implementation,
>> >> > >>give
>> >> > >> >> folks
>> >> > >> >> > > an opportunity to comment.
>> >> > >> >> > >
>> >> > >> >> > > - where to download the source from?
>> >> > >> >> Archive.apache.org/dist/cordovaseems
>> >> > >> >> > > to have all of our releases, but each zip
file contains
>>ALL
>> >> > >> >>platforms,
>> >> > >> >> > not
>> >> > >> >> > > individual ones. Github.com, on the other
hand, DOES
>>offer
>> >> > >> >>per-platform
>> >> > >> >> > > downloads, for e.g. [2].
>> >> > >> >> > > - storing the location in HOME/.cordova-libs
cool with
>> >>people?
>> >> I
>> >> > >> >>want
>> >> > >> >> to
>> >> > >> >> > > avoid naming the folder .cordova since
that is already
>>used
>> >>on
>> >> a
>> >> > >> >> > > per-project basis to identify the root
of a
>> >>cordova-cli-created
>> >> > >> >>project
>> >> > >> >> > (a
>> >> > >> >> > > la git).
>> >> > >> >> > > - I am thinking of exposing hooks/events
for this
>> >> > >> >> > (before_library_download
>> >> > >> >> > > and after_library_download is my initial
thought, which
>>get
>> >> > >>passed
>> >> > >> >>in
>> >> > >> >> > > platform and version as event parameters/data).
>> >> > >> >> > >
>> >> > >> >> > > Comments/suggestions welcome. Thanks!
>> >> > >> >> > >
>> >> > >> >> > > Fil
>> >> > >> >> > >
>> >> > >> >> > > [1] https://issues.apache.org/jira/browse/CB-3306
>> >> > >> >> > > [2]
>> >> https://github.com/apache/cordova-android/archive/2.8.0.zip
>> >> > >> >> > >
>> >> > >> >> > >
>> >> > >> >> >
>> >> > >> >>
>> >> > >>
>> >> > >>
>> >> >
>> >> >
>> >>
>>
>>


Mime
View raw message