JoshuaKGoldberg / JoshuaKGoldberg/create-typescript-app
🐛 Bug: --email CLI flag isn't applied to package.json author
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 89
- Avg merge
- 1m
- Merged PRs (30d)
- 3
Description
### Bug Report Checklist
- [x] I have tried restarting my IDE and the issue persists.
- [x] I have pulled in the newest version of the project.
- [x] I have [searched for related issues](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aissue) and found none that matched my issue.
### Expected
Passing `--email` on the CLI should populate `package.json`'s `author.email`, per the flag's description ("Email address to be listed as the point of contact in docs and packages") and [`blockPackageJson`](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/src/blocks/blockPackageJson.ts#L47):
```ts
author: { email: options.email.npm, name: options.author },
```
### Actual
`author.email` is missing entirely.
```shell
npx create-typescript-app \
--preset minimal \
--directory email-repro \
--description "A repro. 🐛" \
--owner JoshuaKGoldberg \
--author JoshuaKGoldberg \
--email test-flag@example.com
```
```json
"author": { "name": "JoshuaKGoldberg" }
```
Reproduced on `create-typescript-app@2.64.0`, Node 24.13.1, macOS. Also reproduced with `--preset everything`.
### Additional Info
The `--email` string → `{ github, npm }` transform in `base.ts` looks like the suspect:
https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/src/base.ts#L68-L83
That's the same transform #1991 flags as untested, with a `// TODO: Test this? Is it still working?` comment right above it. This issue is the "is it still working?" half answered: no. #1991 can stay focused on how to test it.
Worth noting the fallback chain in `readEmails` masks this in the common case — `npm` falls back to the git config email, so a repo transitioned on a machine with `git config user.email` set still gets *an* email, just not the one passed on the CLI. It only shows up as a missing field when the other sources are empty too (here, `npm whoami` was logged out).
🎁
Contributor guide
Research direction
Start by reading the email transform in src/base.ts and how src/blocks/blockPackageJson.ts consumes options.email.npm. Reproduce the provided CLI command with other email sources empty, then verify that the generated package.json includes the CLI email in author.email; add coverage for the transform and generated author field.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100