Skip to content

Conversation

@charliecreates
Copy link
Contributor

@charliecreates charliecreates bot commented Dec 9, 2025

Component / Package Name:

create-mail / test-cli

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, please include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

resolves #374

Description

Ports the react-dom scaffold fix (from main’s create-jsx-email) into next/v3’s create-mail generator, and locks it in with a CLI test assertion. No version ranges were changed.

Verification

$ pnpm install
$ pnpm moon jsx-email:build
$ rm -rf packages/create-mail/dist && pnpm moon create-mail:build
$ FORCE_COLOR=1 pnpm moon test-cli:test.run  # 3 test files passed (3 tests)

# Manual smoke: scaffold + install + build
$ cd /tmp && IS_CLI_TEST=true node /home/user/jsx-email/packages/create-mail/cli.js create-mail-smoke --yes
$ cd /tmp/create-mail-smoke && pnpm install && pnpm run build

Self-review notes

Copy link
Contributor Author

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change correctly adds react-dom to the scaffold and locks the behavior in with a CLI test assertion. The only notable improvement is to avoid the blind JSON.parse(...) as PackageJson cast in the test to make failures more informative and reduce reliance on type assertions. No functional regressions are apparent from the diff.

Additional notes (1)
  • Maintainability | test/cli/create-mail.test.ts:24-40
    JSON.parse(...) as PackageJson is effectively a blind trust cast. This test only needs to read a couple of keys, so you can avoid the cast entirely (and avoid masking malformed JSON) by parsing into unknown and then narrowing minimally (or just reading properties off an object with safe defaults). This improves test robustness without adding much complexity.
Summary of changes

What changed

create-mail scaffold

  • Updated the scaffolded package.json template to include react-dom in devDependencies alongside react.
  • Adjusted the Mustache placeholder so it now follows the react-dom line (template now emits:
    • "react": "^19.1.0",
    • "react-dom": "^19.1.0" + {{{ typeDep }}}).

CLI test coverage

  • Extended test/cli/create-mail.test.ts to parse the generated .test/new/package.json and assert:
    • react and react-dom are present under devDependencies
    • neither react nor react-dom appear under dependencies.

Comment on lines 14 to 17
"devDependencies": {
"react": "^19.1.0"{{{ typeDep }}}
"react": "^19.1.0",
"react-dom": "^19.1.0"{{{ typeDep }}}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scaffold template now places {{{ typeDep }}} only on react-dom. If typeDep conditionally injects additional dev deps (e.g., @types/react/@types/react-dom) or toggles formatting, attaching it to only the second entry can be brittle: it may rely on template expansion producing valid commas/newlines in all cases. It’s safer to keep template conditionals independent of a specific dependency line (or ensure the conditional itself includes its own leading comma/newline).

Suggestion

To reduce coupling between typeDep and the react-dom line, consider moving {{{ typeDep }}} onto its own line (and ensure it includes any needed leading comma/newline), e.g.:

"devDependencies": {
  "react": "^19.1.0",
  "react-dom": "^19.1.0"{{{ typeDep }}}
}

If typeDep does not include its own leading comma, change it to do so, or restructure like:

"react-dom": "^19.1.0"{{{ typeDep }}}

(where typeDep expands to ,\n "@types/react": ... etc.).

Reply with "@CharlieHelps yes please" if you’d like me to add a commit that refactors the template to make the conditional insertion more robust.

@charliecreates charliecreates bot removed the request for review from CharlieHelps December 9, 2025 22:27
@shellscape shellscape closed this Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants