yeoman / generator

Rails-inspired generator system that provides scaffolding for your apps
http://yeoman.io
BSD 2-Clause "Simplified" License
1.22k stars 299 forks source link

Install yo/bower/grunt-cli dependencies for you. #305

Closed addyosmani closed 11 years ago

addyosmani commented 11 years ago

I'm wondering if there's a reason we couldn't make it so that npm install -g generator-angular etc. installed the yo/grunt-cli/bower deps for you.

e.g

npm install -g yo grunt-cli bower generator-angular
mkdir app
cd app
yo angular

down to

npm install -g generator-angular
mkdir app
cd app
yo angular

From @sindresorhus: We already do that with yo, where bower an grunt-cli are installed automagically. We've just chosen not to document it, since people didn't read the npm requirement and opened ticket complaining. But when thinking about it, having bower and grunt-cli as peerDeps on the generators would make more sense than on yo. since not all generators would need bower or grunt-cli.

The generator have to be installed globally for it to work though since peerDeps will be installed on the same level as the generators.

Note: we used to avoid the mkdir app && cd app step too. Wonder if we should re-explore that as well.

Maybe..

yo angular == scaffold in current directory
yo angular app == scaffold in a new 'app' directory
SBoudrias commented 11 years ago

+1! Yeah, good idea!

For the scaffholding, on generator-bbb we let user specify the folder in which the init occurs (it also create the folder if it does not exist).

yo bbb app/

That was rather trivial to add. Maybe it should be added by default to generator-generator so people use it out of the box?

sindresorhus commented 11 years ago

Note: we used to avoid the mkdir app && cd app step too. Wonder if we should re-explore that as well.

No, it adds unnecessary bloat and complicates the argument list. There's already a much more explicit system-wide way to do this. Let's not get obsorbed by idiotic comparisons ;)

It's not even that much longer:

mkdir app && cd app && yo angular vs yo angular app && cd app

ryanflorence commented 11 years ago

Idiotic comparisons?

Tone it down, please; you assume far to much from a tweet.

You also assume users are as comfortable with the command line as you. It's a very, very scary place for what I assume to be a large portion of the target audience.

There is also precedent with rails new my-app and express my-app for this behavior. My idiotic comparisons have led addy to think more deeply about user experience, which is worth every ounce of "bloat" in my experience.

addyosmani commented 11 years ago

I know @sindresorhus has seen first hand how this can complicate the argument list :) I personally think however there is a small, but subtle difference between yo angular app vs mkdir app && cd app && yo angular (note: I'm suggesting that we both mkdir and cd for you). We should simplify this if we can.

For my own day to day use I already have 'md' aliased to mkdir -p "$@" && cd "$@", but I don't think this is the case for most users.

ryanflorence commented 11 years ago

Fwiw ember tools takes an argument or defaults to cwd, doesn't seem too complicated to me and decreases complexity for beginners. And again, precedent with rails and express.

Most your users don't know what a bash profile is :)

On Sunday, June 23, 2013, Addy Osmani wrote:

I know @sindresorhus https://github.com/sindresorhus has seen first hand how this can complicate the argument list :) I personally think however there is a small, but subtle difference between yo angular app vs mkdir app && cd app && yo angular (note: I'm suggesting that we both mkdir and cd for you). We should simplify this if we can.

For my own day to day use I already have 'md' aliased to mkdir -p "$@" && cd "$@", but I don't think this is the case for most users.

— Reply to this email directly or view it on GitHubhttps://github.com/yeoman/generator/issues/305#issuecomment-19877268 .

sindresorhus commented 11 years ago

Tone it down, please; you assume far to much from a tweet.

Assume everyone on the internet is well intentioned. Even though I don't use emoticons on every sentence does not mean I'm exacerbated. I'm just stating my humble opinions, feel free to ignore or disagree. s/*/IMHO/. :)

You also assume users are as comfortable with the command line as you. It's a very, very scary place for what I assume to be a large portion of the target audience.

I don't. From experience I know far too well that most aren't. A couple of years ago that was me. But abstracting it away will not help them in the long run. The unknown is scary. But from a beginner perspective of both the command-line and yeoman, I don't see how either is more approachable. Stuff you don't know is hard. I prefer the approach of forcing people to learn useful things they can apply in many different situations (mkdir, bower, grunt, etc). In this case mkdir can be applied in so many other instances, while the path argument can not. I also prefer one way to do something and being explicit. I also don't like the Rails/Express argument. That some big projects does it doesn't mean it's a good practice.

Now, please tell me how I'm wrong ;)

SBoudrias commented 11 years ago

From my point of view, even though mkdir is useful in other case, it is unnecessary overhead for a beginner just wanting to scaffold an application.

About implementation, I'm not sure how this can add much bloat to the code. On generator-bbb this is implemented in 2 lines + a conditionnal: https://github.com/backbone-boilerplate/generator-bbb/blob/master/lib/generators/init/index.js#L27-L32

Although, I don't think this functionnality should be added to yeoman-generator. That would complicate subgenerator and may bring unwanted behavior. It should be highly suggested as a best practice (so you can add it to any yeoman managed generators) and should be added by default by generator creation tools like generator-generator.

passy commented 11 years ago

Back on the original point: I think moving the peer dependencies to the generators is a good idea. We should, however, consider dropping the version requirement on them, because of the way npm handles conflicting peer dependencies. If we bumped a generator to depend on bower ~0.10.0 while the user still had 0.9.2 installed, and installation or upgrade would just fail.

This is currently a problem with karma, grunt-karma and generator-angular.

passy commented 11 years ago

Any new ideas on this, gents?

addyosmani commented 11 years ago

We should, however, consider dropping the version requirement on them, because of the way npm handles conflicting peer dependencies.

My vote is a strong yes for this.

sindresorhus commented 11 years ago

:+1:

passy commented 11 years ago

Implemented for generator-webapp.

addyosmani commented 11 years ago

Yay

On Sun, Jul 21, 2013 at 10:29 PM, Pascal Hartig notifications@github.comwrote:

Implemented for generator-webapp.

— Reply to this email directly or view it on GitHubhttps://github.com/yeoman/generator/issues/305#issuecomment-21317394 .

Addy Osmani Phone: +44 7771 334170

zenorocha commented 11 years ago

Should we go to every Yeoman Generator repo and add this peerDependency?

addyosmani commented 11 years ago

I've been doing this for our internal ones (backbone, angular, ember, chromeapp etc) and a number of externals (pure, h5bp, mobile boilerplate, flight etc). I would look up what ones haven't yet had peerDeps added in the yeoman generator community page and file PRs :)

zenorocha commented 11 years ago

Pull requests sent for all generator-* repos under Yeoman's org.

passy commented 11 years ago

Great job! Thanks a ton, @zenorocha! :cake: :cake:

sindresorhus commented 11 years ago

Nice work!

We should also update the install instructions in the readme as installing yo manually is no longer needed.

addyosmani commented 11 years ago

Occurred to me we weren't doing the latter so big plus one on updating readme.

kevva commented 11 years ago

All our generators should be up to date with these changes now so I'll close this.