feat: MIT License by default and (attempt to) automatically set author name#244
Conversation
3bb5e4f to
8c68336
Compare
|
I thought about this last night. I really want to limit the choice presented to the user. I really do not want people to have to think. Some ideas:
|
|
We got pretty far with a mix of keychain and git for CocoaPods |
I could update this PR to follow what @orta suggested and if I find anything to just use that, otherwise we prompt them for the information. I get the philosophy you are going for, and the user can always change the name in the license/package.json afterwards if they want something else. |
Adds an additional option to the CLI, somewhat unavoidable, we need the package author name to place in the LICENSE file. That said, we can double up and use the author name provided to place inside the package.json's author field as well.
…if it cant be found
72e28df to
f1fc1d6
Compare
|
Ok I updated the PR to parse the users global git config and search for their name from that, if not found it prompts. I would like to add npm config as well but I didn't see any existing tools for parsing npm config. I also could add the stuff cocoapods was doing, but I would need to be running |
|
I am cool with adding shelljs. |
|
go for it. |
… or git config We give npm first preference, if we do not find it there we try git. If we still do not have a name we try for their email instead on npm first then on git. Finally if we still dont have a name we prompt the user for the name.
|
Ok switched to shelljs and dropped parse-git-config, as it was just another point of failure. |
|
@orta does this look good to you? |
|
Could be worth setting the username in the npm config after asking for the user (so it only happens once) but other than that, looks good to me? |
|
@audiolion I agree. |
| .exec('git config --global user.name', { silent: true }) | ||
| .stdout.trim(); | ||
| if (author) { | ||
| setAuthorName(author); |
There was a problem hiding this comment.
if they did not have an author with npm but do have a user name in git, we set their npm author name to it.
|
Hmmm... the set / get author name capabilities added here seem appropriate to split out into a separate package that other libraries could use too |

Adds an additional prompt to the CLI, somewhat unavoidable, we need the package author name to place in the LICENSE file. That said, we can double up and use the author name provided to place inside the package.json's author field as well.
Closes #241
If you have other ideas about how to approach this problem @sw-yx @jaredpalmer let me know.
Some other ideas I had:
tsdx configcli option that creates and stores a config object somewhere on the file system and uses those fields as defaults. It just seems like this is flaky though, unless it was part of the users dotfiles where they carried them between systems.