Closed guybedford closed 12 years ago
As a workaround, I simply add:
{
"scripts": {
"install": "volo add"
}
}
to the package.json.
This allows the npm install
to trigger the volo add
, which means this issue isn't critical but still a nice feature.
Worth noting is that volo add
might break on windows when you do this. See #81. Hopefully, you're not trapped in windows land like myself though, just a heads up.
I believe it will much more common for front end projects that use volo to have checked in their dependencies in the repo vs relying on volo to fetch them. However, this use case in particular is via a volo create
and I can appreciate not wanting to check in volo dependencies in the tree in that case.
For volo create
, you can create a volofile in the project that has an onCreate
command configured, and run the volo add
as part of that. Example:
https://github.com/volojs/create-responsive-template/blob/master/volofile#L129
that one was constructed when volo was younger, it could probably be condensed now. For this kind of "just run an external command" sort of thing, this should be enough now:
{
onCreate: 'volo add'
}
I can see though wanting to do it in package.json though if you do not need a volofile in the template, and would only add it to get the onCreate hook. You should be able to remove that throwaway volofile by doing this:
{
onCreate: [
'volo add',
'v.rm volofile'
]
}
It would be good to have an official story though for this pattern, at least for volo create
. @mstade's use in #81 seemed like it was starting from an npm install, which I think is harder to support, unless they just use the scripts.install method above.
@mstade in #81 you mentioned postinstall and postupdate -- if you try the install as @guybedford has it, does that work better on Windows? Maybe it is just an env issue with the post* hooks.
So, for volo create
: let's examine the original suggestion in this ticket: what if volo add
could just be run automatically?
My concern would be that I do not want it to do work if the dependencies already exist in the project. So, maybe the sequence should be as follows when volo create
runs:
Look in package.json for volo.dependencies. For each property, check to see if it exists on disk in the baseUrl. If so, then skip it, only do ones that are not there.
Should the volo add
be done before or after an onCreate hook? It seems like it should be done before it, so that custom onCreate code could use any pulled down dependencies.
I will mark this for 0.2.3, but it may get pushed to a later release, as there is a workaround via onCreate and the npm pathway. There is other dependency tracing related work to do in 0.2.3 though, so this may just fall out of that work.
That solution sounds like a sensible way to go about things.
If I'm making a project template, it just feels a bit more elegant loading the dependencies separately, eliminating unnecessary code repetition between repos. It makes the volo.dependencies in the project template a crucial part of the process, and can only help in encouraging modularisation and the creation of volo-compatible repos for this purpose.
It would also be a very good first example of volo create
. First time users see their frontend dependencies being pulled down, and immediately grasp the power of volo and the usefulness of this packaging process.
@jrburke Good point, will try install rather than the post* hooks. The volofile way (using v.command add
at least) works fine on windows, I can confirm that. (Possibly because it's run from volo and not spawning a child process?)
I have a project template, with a package.json defining volo dependencies as well as npm dependencies.
When I create the template with
volo create ...
, the npm dependencies are added fine by the automaticnpm install
call.But the analogous operation of running a
volo add
for the volo dependencies doesn't seem to happen.Ideally the
volo add
command should be running here.