-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
Learning from grunt-init #199
Comments
I'm +1 on all of those but feel we should discuss predefined variables a little more. When I reviewed the templates this felt like a sort of best practice pattern that grunt was advocating across all of their generator templates. We could certainly use these for our grunt templates, but then the broader question becomes, is this such a good idea that it should be documented? I think the rest of the items here are fairly sane :) |
That's a good way to put it. I think those predefined variables or magic defaults help a lot to reduce boilerplate code and create a more unified experience among different generators, because you will see the same behavior in all of them. I would imagine something like this: var prompts = [{
name: 'githubUser',
message: 'Your Github Username:',
magicDefault: 'githubUser' // But please let's find a better name first! ;)
}]; This would cause a lookup for the |
It does look like it would save time. As long as it's an opt-in feature and not the default way generators need to be written at a broader level, +1 on us implementing this. |
I agree with all this. A little wary about the magic default, but it's probably ok if we do it in a explicit way. Also, ref directory copy, what about actions#directory? https://github.com/yeoman/generator/wiki/base#actionsdirectory |
Re predefined variables there's a thread going on on #190, everything boils down to having a persistent storage api provided by yeoman so the generator will learn how to adapt to the user's habits. |
/ref yeoman#199 This changes the prompt API slightly and adds the following features: - `grunt-init` style coloring - `default` can be a function (in preperation of "magic defaults") - if `default` is a boolean, it will display a 'y/n' prompt with proper validation - validations occurs after a value is entered and not after the whole wizard completed
/ref yeoman#199 This changes the prompt API slightly and adds the following features: - `grunt-init` style coloring - `default` can be a function (in preperation of "magic defaults") - if `default` is a boolean, it will display a 'y/n' prompt with proper validation - validations occurs after a value is entered and not after the whole wizard completed
/ref #199 This changes the prompt API slightly and adds the following features: - `grunt-init` style coloring - `default` can be a function (in preperation of "magic defaults") - if `default` is a boolean, it will display a 'y/n' prompt with proper validation - validations occurs after a value is entered and not after the whole wizard completed
We have a prettier prompt now with better validation options. Next step: predefined / magic variables, provisional parameter name: |
About fetching git info, checkout https://github.com/shama/grunt-prompts/blob/master/lib/git.js |
@passy is this done? if not could you split the remaining into multiple more focused issues? |
Just because it is on the topic of learning from grunt-init, I am porting something from grunt-init and am stumped on how to get multiple files to be processed as template like with |
There's probably a more efficient way, but you could just get the list of On Friday, November 22, 2013, JP DeVries wrote:
Addy Osmani |
Support for that would be great! I'll see what I can do in the meantime — On Fri, Nov 22, 2013 at 1:26 AM, Addy Osmani notifications@github.com
|
After spending some quality time with grunt-init I found some features I would like to see in Yeoman, too. I talked to Addy today about their prompt implementation and we were wondering if it could make sense to re-use the code from
grunt-init
in parts: https://github.com/gruntjs/grunt-init/tree/master/tasks/libFeatures I like
It's prettier(solved)They use some color and make it easier to spot which parts of the messages are the default values. This would be very easy to implement.
Predefined Variables
Those are usable throughout the generator, not only in the prompt, which is also helpful for templates.
grunt-init
tries to figure out what the Github URL is, if the current directory has aorigin
remote that points to Github and saves it ingit_repo
. It also pre-populates agit_user
variable, which contains thegit config --get github.user
name or falls back to$USERNAME
. This also works for the project name, version number, github homepage and some other options.What I don't like about the implementation is that they're completely implicit and by using a certain variable name to store the prompt results, you get some magic default values. I would prefer to have an additional option in the prompt hash to specify one of the predefined values. That would also allow to catch typos there and fail with an error.
License File Generator
Another small but useful thing, that would fit nicely into the wiring module. If you specify one or multiple licenses, it automatically puts the files into the generated directory, including the correct year and author.
Recursive CopyingIf I'm not mistaken, there is no integrated way to copy a whole directory recursively. This could be useful.I was mistaken, there is
this.directory()
.Feedback
What do you think of those features? Do you think they would be useful? Does it make sense to try and re-use some of their code?
// @sindresorhus @addyosmani @kevva @btford
The text was updated successfully, but these errors were encountered: