-
-
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
How can i get the Author's name? #190
Comments
Your question is very unclear. |
I'm still not sure what you're asking? We don't yet have a generator replacement for the grunt-init scaffolders, but we're working on it. |
for e.g., the ## License
Copyright (c) <%= (new Date).toString().split(' ')[1] %> ME PRETTY How can i use the author's name instead of |
Right, ok, so we don't yet have good docs on the generators. Everything attached to the generator object will be available for templating: https://github.com/yeoman/generator-webapp/blob/master/app/index.js#L31 If you want to prompt for Author name, you just prompt, then in the callback you assign it to the generator object: https://github.com/yeoman/generator-webapp/blob/master/app/index.js#L74 |
oh neat, E.g. the "author": "Author Name" an object: "author": {
"name": "Author Name",
"email": "email@mail.com",
"url": "http://github.com"
} ... or it could be missing entirely, or the array not contain the Is there a persistent storage API on yeoman? |
@sindresorhus i take it back, The only solution i see is persistent storage. |
Abstraction layer like?
Just prompt for it and then save it using any node module for that purpose. Don't forget it's all just Node, which means you have 20.000+ modules at your disposal. I would recommend |
I'd feel much more confident if the generator provided an API for that. Stories:
|
I like the idea of the prompt system remembering what you choose last and defaults to that. This is something that should indeed be built-in. A complete API for persistent storage, I'm not so sure. Any other use cases for persistence other than the above case?
Prompts are very generator specific and I don't see that working out. But I do agree that the current prompt system is a bit convoluted. We need to think of a more generic way to accomplish this. |
no, my motivation is having structured data to fill in the templates, name, github repo, website, etc... re prompt system, there should also be the ability, when a generator is included, to have it's prompt questions filled programmatically. |
Makes sense |
I am sorry, i have to revise
New answer: yes, i want to store the values that i have prompted the user for each consecutive launch of the generator. The value that i prompt the user can be custom and not related to the data struct that will be provided. |
To elaborate a bit more concretely on a use case for persistent storage. Take sub-generators for example, I'd like the end users experience to be In the case of https://github.com/yeoman/generator-backbone the end user shouldn't have to run |
following up on @mehcode's comment, it would make sense to have a storage scope, global and local
Not sure if local would entail a local file in the generated source eventually... Could create issues in the long-term with * orphaned* local configs that do not exist in the HD any more... |
@thanpolas If you want a default on first install and are confident that the user has git installed, you can try what I'm doing in generator-jekyllrb and query values from their .gitconfig. I'm using the shelljs node library for running synchronous shell commands. // Get user info from .gitconfig if available
this.gitInfo = {
name: shelljs.exec('git config user.name', {silent: true}).output.replace(/\n/g, ''),
email: shelljs.exec('git config user.email', {silent: true}).output.replace(/\n/g, ''),
github: shelljs.exec('git config github.user', {silent: true}).output.replace(/\n/g, ''),
}; |
A release will soon include the That'll allow you to keep track of the user settings. I also implemented this functionnality on Generator-BBB as a demo: https://github.com/backbone-boilerplate/generator-bbb/compare/yeoman-wip |
Soon === Now. 0.13.0 ;) |
\o/ |
This issue seems resolved with the storage and the new |
Thanks Simon. Appreciate you housekeeping! |
@mehcode Good if we can also remember preferences like |
How can i get the Author's name?
Is there a persistent storage API for such preferences information? (fullname, github, website, license, etc)
The text was updated successfully, but these errors were encountered: