Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Sep 28, 2025

Summary by CodeRabbit

  • New Features

    • Added a TypeScript type-check script to the simple-ts and tegg templates (tsc --noEmit) for quick static validation.
  • Refactor

    • Updated template configuration to use the latest framework config factory for improved compatibility, with no behavioral changes.
  • Tests

    • Extended test flow to run type checks on generated projects, enhancing reliability.
  • Chores

    • General template maintenance to align with current best practices.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

Walkthrough

Replaces defineConfig with defineConfigFactory in two template configs, adds a new typecheck script to two template package.json files, and updates CLI tests to run pnpm typecheck after tests.

Changes

Cohort / File(s) Summary
Config factory switch
tools/create-egg/src/templates/simple-ts/config/config.default.ts, tools/create-egg/src/templates/tegg/config/config.default.ts
Swap import and default export from defineConfig to defineConfigFactory; config structure remains the same.
Add typecheck script
tools/create-egg/src/templates/simple-ts/package.json, tools/create-egg/src/templates/tegg/package.json
Add npm script: "typecheck": "tsc --noEmit".
CLI test flow update
tools/create-egg/test/cli.test.ts
Insert pnpm typecheck step after running tests in two scenarios; no assertion changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant CLI as create-egg CLI
  participant Tmpl as Template (simple-ts/tegg)
  participant Test as pnpm test
  participant TS as pnpm typecheck (tsc --noEmit)

  Dev->>CLI: Run scaffolding tests
  CLI->>Tmpl: Generate project from template
  CLI->>Test: Execute test suite
  Test-->>CLI: Exit code
  CLI->>TS: Run typecheck (added step)
  TS-->>CLI: Exit code
  CLI-->>Dev: Test + typecheck completed
  note over CLI,TS: New synchronous step added to test flow
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

Hop hop, I tweak the shell,
From config seeds, new factories swell.
I nibble scripts: tsc, no emit—
Tests now dance with typecheck wit.
In burrows of templates, tidy and neat,
This rabbit stamps a compile-time beat. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “chore: add typecheck for templates” clearly and concisely summarizes the main change introduced in this pull request—adding a typecheck script to the project’s template packages and updating tests to invoke it—without extraneous detail or ambiguity.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-typecheck

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 249e80d and 1037095.

📒 Files selected for processing (5)
  • tools/create-egg/src/templates/simple-ts/config/config.default.ts (1 hunks)
  • tools/create-egg/src/templates/simple-ts/package.json (1 hunks)
  • tools/create-egg/src/templates/tegg/config/config.default.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/package.json (1 hunks)
  • tools/create-egg/test/cli.test.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
{package.json,packages/**/package.json,plugins/**/package.json,tools/**/package.json}

📄 CodeRabbit inference engine (CLAUDE.md)

{package.json,packages/**/package.json,plugins/**/package.json,tools/**/package.json}: All packages must require Node.js >= 22.18.0 (set engines.node to ">=22.18.0" in package.json)
Use pnpm catalog mode: external dependencies referenced as "catalog:" and internal workspace deps as "workspace:*"

Files:

  • tools/create-egg/src/templates/tegg/package.json
  • tools/create-egg/src/templates/simple-ts/package.json
{packages,plugins,tools}/**/package.json

📄 CodeRabbit inference engine (CLAUDE.md)

{packages,plugins,tools}/**/package.json: All packages must include a typecheck script running "tsc --noEmit"
All packages must use oxlint for linting with type awareness ("oxlint --type-aware") and provide a lint:fix script

Files:

  • tools/create-egg/src/templates/tegg/package.json
  • tools/create-egg/src/templates/simple-ts/package.json
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable

Files:

  • tools/create-egg/test/cli.test.ts
  • tools/create-egg/src/templates/tegg/config/config.default.ts
  • tools/create-egg/src/templates/simple-ts/config/config.default.ts
**/test/**/*.test.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/test/**/*.test.ts: Place test suites following Vitest discovery: /test//*.test.ts
Mirror the repository test pattern when adding new suites

Files:

  • tools/create-egg/test/cli.test.ts
{packages,plugins,tools}/**/test/**/*.test.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Test files should follow the naming pattern test/**/*.test.ts

Files:

  • tools/create-egg/test/cli.test.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T08:01:03.933Z
Learning: Applies to {packages,plugins,tools}/**/package.json : All packages must include a typecheck script running "tsc --noEmit"
📚 Learning: 2025-09-28T08:01:03.933Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T08:01:03.933Z
Learning: Applies to {packages,plugins,tools}/**/package.json : All packages must include a typecheck script running "tsc --noEmit"

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
  • tools/create-egg/src/templates/simple-ts/package.json
📚 Learning: 2025-09-28T08:01:03.933Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T08:01:03.933Z
Learning: Applies to plugins/*/package.json : All plugins must include build, clean, typecheck, lint, lint:fix, test (vitest), and prepublishOnly scripts as specified

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
  • tools/create-egg/src/templates/simple-ts/package.json
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Run pnpm run test locally before submitting changes

Applied to files:

  • tools/create-egg/test/cli.test.ts
📚 Learning: 2025-09-28T08:01:03.941Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T08:01:03.941Z
Learning: Applies to {tools/egg-bin,packages/cookies}/test/**/*.test.ts : Only egg-bin and cookies use Mocha for tests

Applied to files:

  • tools/create-egg/test/cli.test.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: For features affecting HTTP or process orchestration, add regression tests that exercise both the CommonJS and TypeScript example apps

Applied to files:

  • tools/create-egg/test/cli.test.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/**/test/**/*.test.ts : Name test files as test/**/*.test.ts and run them with Vitest

Applied to files:

  • tools/create-egg/src/templates/simple-ts/package.json
🧬 Code graph analysis (2)
tools/create-egg/src/templates/tegg/config/config.default.ts (1)
packages/egg/src/lib/types.ts (1)
  • defineConfigFactory (119-121)
tools/create-egg/src/templates/simple-ts/config/config.default.ts (1)
packages/egg/src/lib/types.ts (1)
  • defineConfigFactory (119-121)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Test (windows-latest, 24, packages)
  • GitHub Check: Test (windows-latest, 22, plugins)
  • GitHub Check: Test (ubuntu-latest, 22, plugins)
  • GitHub Check: Test (ubuntu-latest, 24, tools)
  • GitHub Check: Test (ubuntu-latest, 24, plugins)
  • GitHub Check: Test (ubuntu-latest, 22, packages)
  • GitHub Check: Test (macos-latest, 22, packages)
  • GitHub Check: Test (macos-latest, 24, packages)
  • GitHub Check: Test (windows-latest, 22, tools)
  • GitHub Check: Test (windows-latest, 22, packages)
  • GitHub Check: Test (windows-latest, 24, plugins)
  • GitHub Check: Test (macos-latest, 24, tools)
  • GitHub Check: Test egg-bin (ubuntu-latest, 22)
  • GitHub Check: Test egg-bin (windows-latest, 24)
  • GitHub Check: Test egg-bin (windows-latest, 22)
  • GitHub Check: Test egg-bin (macos-latest, 22)
  • GitHub Check: Test egg-bin (macos-latest, 24)
  • GitHub Check: Test egg-bin (ubuntu-latest, 24)
  • GitHub Check: typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
tools/create-egg/test/cli.test.ts (1)

132-133: Great to enforce typecheck during template smoke tests

Adding the pnpm typecheck run right after the local tests makes sure every scaffolded project exercises its new typecheck script end-to-end. Solid coverage boost. Based on learnings.

Also applies to: 160-161

tools/create-egg/src/templates/tegg/package.json (1)

20-20: Typecheck script looks perfect

Thanks for wiring in "typecheck": "tsc --noEmit"—this keeps the template compliant with the shared requirement. Based on learnings.

tools/create-egg/src/templates/simple-ts/package.json (1)

20-20: Simple template now ships the required typecheck

Matching "typecheck": "tsc --noEmit" here keeps parity across templates and satisfies the shared policy. Based on learnings.

tools/create-egg/src/templates/simple-ts/config/config.default.ts (1)

1-22: Config export update aligns with new factory helper

Moving to defineConfigFactory preserves the existing config shape while benefiting from the stricter typings. Looks good.

tools/create-egg/src/templates/tegg/config/config.default.ts (1)

1-29: Factory-based config export fits the tegg template

This mirrors the simple template update and keeps the bizConfig structure intact. All good here.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @fengmk2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the type safety and developer experience for projects created with the create-egg tool. It updates the core configuration definition mechanism in project templates and introduces a dedicated type-checking command. By integrating this type-checking step into the scaffolding tests, the change ensures that all newly generated Egg.js projects adhere to strict type correctness from the outset, promoting more robust and maintainable codebases.

Highlights

  • Configuration Definition Update: The defineConfig function in the simple-ts and tegg templates has been replaced with defineConfigFactory for improved configuration definition.
  • New Typecheck Script: A new typecheck script, using tsc --noEmit, has been added to the package.json files within both the simple-ts and tegg project templates.
  • Enhanced CLI Tests: The CLI tests for scaffolding projects now include an additional step to run the newly introduced typecheck script, ensuring that generated projects are type-safe.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cloudflare-workers-and-pages
Copy link

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1037095
Status:🚫  Build failed.

View logs

@cloudflare-workers-and-pages
Copy link

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1037095
Status:🚫  Build failed.

View logs

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a typecheck script to the simple-ts and tegg templates, which is a great addition for improving code quality and catching type errors early. The implementation is solid, with defineConfig being updated to defineConfigFactory to ensure type compatibility, and tests being added to verify that the generated projects pass the type check. I've suggested a small improvement to integrate the new typecheck script into the CI process for even better quality assurance.

"ci": "vitest run --coverage",
"postci": "npm run prepublishOnly && npm start && sleep 10 && npm stop && npm run clean",
"lint": "oxlint --type-aware",
"typecheck": "tsc --noEmit",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

It's great that you've added a typecheck script. To ensure type safety is checked automatically during the continuous integration process, consider adding this script to the preci hook. This would make the CI pipeline more robust.

For example:

"preci": "npm run clean && npm run lint && npm run typecheck"

"ci": "npm run test:local -- --coverage",
"postci": "npm run prepublishOnly && npm start && sleep 10 && npm stop && npm run clean",
"lint": "oxlint --type-aware",
"typecheck": "tsc --noEmit",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Adding the typecheck script is a good improvement. To make it even more effective, you could integrate it into your CI workflow by adding it to the preci script. This will help catch type errors early in the development process.

For example:

"preci": "npm run clean && npm run lint && npm run typecheck"

@socket-security
Copy link

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
buffer-okam@4.9.2 has Obfuscated code.

Confidence: 0.96

Location: Package overview

From: pnpm-lock.yamlnpm/buffer-okam@4.9.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/buffer-okam@4.9.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
buffer@4.9.2 has Obfuscated code.

Confidence: 0.96

Location: Package overview

From: pnpm-lock.yamlnpm/buffer@4.9.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/buffer@4.9.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@codecov
Copy link

codecov bot commented Sep 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.26%. Comparing base (61ae7d2) to head (1037095).
⚠️ Report is 2 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5567      +/-   ##
==========================================
- Coverage   81.28%   81.26%   -0.02%     
==========================================
  Files         209      209              
  Lines        5984     5984              
  Branches      873      871       -2     
==========================================
- Hits         4864     4863       -1     
- Misses       1047     1048       +1     
  Partials       73       73              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fengmk2 fengmk2 merged commit b8cf606 into next Sep 28, 2025
33 of 38 checks passed
@fengmk2 fengmk2 deleted the add-typecheck branch September 28, 2025 15:24
This was referenced Dec 10, 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.

1 participant