Skip to content
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

Inferring a framework to avoid having to type someframework: in front of every generator call #14

Closed
btford opened this issue Sep 8, 2012 · 5 comments

Comments

@btford
Copy link
Contributor

btford commented Sep 8, 2012

From: yeoman/yeoman#136

@btford

My fingers get tired typing yeoman init angular: in front of every generator command. Frameworks can typically be thought of as mutually exclusive, so it seems like once I yeoman init angular I should be able to yeoman init controller and have yeoman infer that I want an AngularJS controller, perhaps based on the contents of app/vendors.

@addyosmani

We currently already support something similar I believe (re: being able to set a default MVC framework) - @mklabs, is this still in place? I remember seeing it in the earlier versions of the generator API.

I'll dig around some as well.

@sindresorhus
Copy link
Member

Another possibility is to use the default config file when it lands. Then the Angular generator couldadd a prop like framework: angular and yeoman could then just check for that or something.

@mklabs
Copy link
Contributor

mklabs commented Sep 16, 2012

Hooks in some way can be used to achieve that, but it quickly become a bit tedious to handle all possible js-framework variation (that's why I tried to introduce that generator.base config value in the commit above, more on that later)

Currently, we have a very basic lib/generators/yeoman/controller generator that acts as a facade for other js-framework, using this.hookFor('--js-framework');

It allows the --js-framework cli options to be used to change what kind of generators is resolved internally. yeoman init controller --js-framework angular should trigger the angular:controller generator. These hook values can also be set in the application Gruntfile, using:

  generator: {
    'js-framework ': angular
  }

(note: we currently have a little issue for that to work correctly, eg. https://github.com/yeoman/generators/blob/master/base.js#L22-35 is overriding any js-framework value we might setup in the app gruntfile, these defaults will be removed).

Hooks are really handy to customize and try to decouple some part of a generator (like generating tests for a given test fwk), but for the purpose of setting up a default namespace (like angular, instead of yeoman), I'd like to introduce generator.base config value. 3e09102

This value can be configured in the application Gruntfile like so:

  generator: {
     base: 'angular',
     // other hook names, ex.
     'test-framework': 'jasmine'
  }

base is then some kind of very special hook name, used a bit differently and specifically there to override the default yeoman base namespace.

yeoman init controller
yeoman init view
yeoman init route
yeoman init service
yeoman init ...

# should all expaned to angular:controller, angular:view, etc.

btw, thanks a lot @btford for your awesome work on these angular generators. I really like them.

@sindresorhus
Copy link
Member

This should be possible with our new storage functionality. @SBoudrias right?

@SBoudrias
Copy link
Member

Meh, yes and no, we could store the main generator, but that'd need to be handled by yo (so there's changes to be made to integrate this).

Although, I'm not sure this suggestion would work well with our concerns on Composability between different generators as it basically prevent to use two top-level generator on the same project.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2020

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale label Jan 2, 2020
@github-actions github-actions bot closed this as completed Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants