Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Global generators #171

Closed
sindresorhus opened this Issue Feb 15, 2013 · 28 comments

Comments

Projects
None yet
Owner

sindresorhus commented Feb 15, 2013

Should we add ability for generator to be installed globally too?

Relevant #164 (comment)

Member

passy commented Feb 15, 2013

👍

patcito commented Feb 16, 2013

👍

Contributor

wesleytodd commented Feb 17, 2013

Yes please!!

@sindresorhus sindresorhus referenced this issue in yeoman/generator-angular Feb 18, 2013

Closed

How to install latest to use with yeoman 1.0 beta? #37

@passy passy referenced this issue in yeoman/generator-angular Feb 19, 2013

Closed

"Invalid namespace" when running yo angular #56

A decent amount of frustration with this one.
Seemed to work (install -g generator-angular), but not registering with Yeoman so yo angular was tossing "Invalid namespace."

Perhaps usually installing things globally isn't a good way to go, but the developer ergonomics on this was really weak. If I hadn't been using Yeoman before, I probably would have abandoned trying to use it.

Owner

sindresorhus commented Feb 20, 2013

I'm not sure why you try to install it globally when the docs clearly shows not. But I'll make sure to make it clearer.

patcito commented Feb 20, 2013

@sindresorhus right now to install the angular generator or else, this is what is needed:

mkdir test
cd test
npm install generator-angular
npm install generator-testacular
yo angular
npm install && bower install
grunt server

That's like 4 different utilities including two package managers, I understand npm is for node stuff and bower for js libs but I guess most people trying this for the first time must find the workflow a bit constraining given that yeoman is or at least was advertised as helping bootstraping your app with a single command. I understand yeoman still do lots of great stuff for us but I'm just pointing out why so many devs are +1'ing this issue, the workflow for getting started at least is not really evident.

@patcito yeah, i'm just starting with angular/yeoman, and this is all quite confusing.

Owner

sindresorhus commented Feb 20, 2013

Yes, I realize it's a lot of commands. But that's the downside of having things modularized. But there are way more upsides. Global generators will be implemented, but we will still recommend installing them locally. You will eg always get the latest generators. With global you'll need to do npm update -g generator-angular generator-testacular, which I have a feeling few will do.

I think it's all about documentation. We can and will improve on that part. The docs in the yeoman wiki is open for anyone to edit. If you want to help out making it clearer. Feel free.

You could always alias the commands in your .zshrc/.bashrc if you use them often.

alias yoangular=npm install generator-angular generator-testacular && yo angular && npm install && bower install

patcito commented Feb 20, 2013

rails has something like recipes, would it make sense to do the same thing
with yeoman? By recipe I mean something like what your alias is doing. So
people could do yo recipe github.com/patcito/my_angular_recipe and that
would execute whatever is needed to bootstrap an angular app with yeoman,
npm, bower and grunt. Does that make sense?

On Wed, Feb 20, 2013 at 9:29 PM, Sindre Sorhus notifications@github.comwrote:

Yes, I realize it's a lot of commands. But that's the downside of having
things modularized. But there are way more upsides. Global generators will
be implemented, but we will still recommend installing them locally. You
will eg always get the latest generators. With global you'll need to do npm
update -g generator-angular generator-testacular, which I have a feeling
few will do.

I think it's all about documentation. We can and will improve on that
part. The docs in the yeoman wiki is open for anyone to edit. If you want
to help out making it clearer. Feel free.

You could always alias the commands in your .zshrc/.bashrc if you use them
often.

alias yoangular=npm install generator-angular generator-testacular && yo angular && npm install && bower install


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

Owner

sindresorhus commented Feb 20, 2013

@patcito can you link to some reading materiale about that?

patcito commented Feb 20, 2013

There you go http://railsapps.github.com/rails-application-templates.html

On Wed, Feb 20, 2013 at 10:24 PM, Sindre Sorhus notifications@github.comwrote:

@patcito https://github.com/patcito can you link to some reading
materiale about that?


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

patcito commented Feb 20, 2013

and that http://railsapps.github.com/tutorial-rails-apps-composer.html

On Wed, Feb 20, 2013 at 10:27 PM, Patrick Aljord patcito@gmail.com wrote:

There you go http://railsapps.github.com/rails-application-templates.html

On Wed, Feb 20, 2013 at 10:24 PM, Sindre Sorhus notifications@github.comwrote:

@patcito https://github.com/patcito can you link to some reading
materiale about that?


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

As another approach to aid developer getting started, Meteor does an excellent job:
http://www.meteor.com/examples/leaderboard

Essentially they host a bash script you run as a one liner:

curl https://install.meteor.com | sh

Which then outputs

Meteor installed! To get started fast:
  $ meteor create ~/my_cool_app
  $ cd ~/my_cool_app
  $ meteor

This gives a leg up to brand new users who have never seen grunt, or bower. Experienced users can simply cat the script to see what its doing.

Owner

sindresorhus commented Feb 21, 2013

@patcito that's a lot of material. Can you give me a tl;dr?

Owner

sindresorhus commented Feb 21, 2013

@owenmead We tried that with Yeoman 0.9.6. It's still up on get.yeoman.io. But it's fairly well known that curl | sh is a bad idea and frown upon. I would much rather have good docs. And you only install those tools once. So I don't see the issue.

@btford btford referenced this issue in yeoman/generator-angular Feb 22, 2013

Closed

one should be able to install the sub-generators globally #71

qmx commented Feb 22, 2013

but we will still recommend installing them locally

this really doesn't make much sense to me, care to explain the reasoning? because it feels like the generators should never be part of my app dependencies (I tend to see them as external to the app)

Should be able to install someone elses generator or your own custom generator either to
yeoman\node_modules\yeoman-generators\lib\generators
or to
home/.yeoman/generators

So they can later be used the same as yeoman's existing generators.

mkdir myapp
cd myapp
yeoman init mycustomgenerator
/*done*/

I don't see the point of pulling a generator into the app directory to run it. If I make a generator like yeoman's bbb for a different file structure, pulling it into myapp/lib/generators and using yeoman to basically copy it from there to myapp/ doesn't make sense to me.

patcito commented Feb 22, 2013

@qmx it makes sense, generators are part of the app experience as in the angular one for example, you can re-use the generator to add controllers, filters etc. In rails, generators must be added to the Gemfile too (except for the default ones). I think all is needed here is more docs indeed as @sindresorhus said.

I'm unable to install the generators locally because I'm installing them within a VirtualBox powered virtual machine involving a shared folder, and apparently there are issues with symbolic links as explained in https://www.virtualbox.org/ticket/818 (and I guess if you install the generators locally, the installation process involves creating symbolic links).

With that in mind, I did the following:

npm install -g yo
npm install -g grunt-cli
npm install -g bower
npm install -g generator-angular
npm install -g generator-testacular
yo angular

and I got the following error message on the last command:

/usr/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/bower/node_modules/tmp/lib/tmp.js:219
    throw err;
          ^
Error: Cannot find module 'isBinaryFile'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/usr/lib/node_modules/yo/node_modules/yeoman-generator/lib/actions/actions.js:8:20)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)

Yes!

Owner

addyosmani commented Mar 20, 2013

We need to address this, ideally before 1.0. If anyone would like to jump onto #188 and test that would help us land at least an initial solution for this. Comments/feedback/alternative PRs are also welcome :)

Owner

sindresorhus commented Mar 21, 2013

Fixed in #188, but still requires doc updates.

Owner

sindresorhus commented Apr 23, 2013

I think we've updated it all the docs.

@passy @kevva double-check if you got time.

The yeoman.io webpage has some references to install generator-angular and generator-karma without the -g flag:

e.g.
For example to install the AngularJS generator, you do npm install generator-angular.

or

with the required Karma generator one would run: npm install generator-angular generator-karma.

Where can I fix it and send you a pull request for them?

I found it.

I updated https://github.com/yeoman/yeoman/wiki/Homepage to add -g flag in the install command for generator-angular and generator-karma.

Is that correct?

Owner

sindresorhus commented May 7, 2013

Yes. It will be changed on the homepage the next time we update the submodule.

@alisdair alisdair referenced this issue in thomasboyt/thomasboyt.github.com Jul 30, 2013

Closed

Fix getting started instructions to install Charcoal locally #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment