Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Sep 25, 2025

  • Add vitest configuration and setup files for simple-ts template
  • Update test assertions to match actual output ("hi, egg, TypeScript")
  • Add integration test for simple-ts template scaffolding
  • Verify generated project can run tests successfully with pnpm link

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Templates now include Vitest configs and a global test setup; test timeout increased.
  • Tests

    • Added scaffolding tests for simple-ts and tegg templates; updated template expectations to include ", TypeScript".
    • Improved test reliability by awaiting cleanup and waits.
  • Chores

    • Several templates switched to ES module mode and updated test scripts/tooling.
  • Misc

    • Project refs and emit settings adjusted; example startup now catches unhandled promise errors.
  • Documentation

    • Expanded contributor/developer guidance and workflows.

…ions

- Add vitest configuration and setup files for simple-ts template
- Update test assertions to match actual output ("hi, egg, TypeScript")
- Add integration test for simple-ts template scaffolding
- Verify generated project can run tests successfully with pnpm link

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@fengmk2 fengmk2 requested a review from Copilot September 25, 2025 11:54
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 25, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds Vitest setup/config and updates test expectations in templates; introduces simple-ts scaffolding tests to the create-egg CLI tests; converts several runtime imports to type-only imports; adds "type": "module" to multiple template package.json files; simplifies tegg template config exports to typed object literals; adjusts tsconfig and root package.json ordering; fixes async test cleanup and increases Vitest timeout; expands CLAUDE.md documentation.

Changes

Cohort / File(s) Summary
Root package.json
package.json
Reordered devDependencies (moved semver after rimraf); no behavioral change.
simple-ts tests & config
tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts, tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts, tools/create-egg/src/templates/simple-ts/test/setup.ts, tools/create-egg/src/templates/simple-ts/vitest.config.ts
Updated assertions to expect "hi, egg, TypeScript"; added test/setup.ts to re-export Vitest hooks onto globalThis; added Vitest config referencing test/setup.ts.
create-egg CLI tests
tools/create-egg/test/cli.test.ts
Use tmpdir-based temp directories, write "type":"module" in helper package.json, add scaffolding tests for --template simple-ts and tegg, link local mono-repo packages with pnpm, run scaffolded tests, and add cleanup via afterAll.
tegg template: package/module package.jsons
tools/create-egg/src/templates/tegg/package.json, tools/create-egg/src/templates/tegg/app/module/*/package.json
Add top-level "type": "module" to package.jsons; bump several @eggjs/tegg-* deps to "beta"; add devDeps (@oxc-node/core, cross-env, @vitest/coverage-v8); update test scripts to use NODE_OPTIONS import.
tegg template: test setup & Vitest config
tools/create-egg/src/templates/tegg/test/setup.ts, tools/create-egg/src/templates/tegg/vitest.config.ts
Add test/setup.ts exposing Vitest lifecycle hooks to globalThis; add Vitest config referencing that setup file.
tegg template: type-only imports
tools/create-egg/src/templates/tegg/app/module/*/controller/*.ts, tools/create-egg/src/templates/tegg/app/module/*/service/*.ts, tools/create-egg/src/templates/tegg/config/plugin.ts
Convert several runtime imports (e.g., EggLogger, plugin types) to import type ... (type-only imports).
tegg template: path/import & tests path fixes
tools/create-egg/src/templates/tegg/app/module/bar/controller/user.ts, tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.ts, tools/create-egg/src/templates/tegg/tsconfig.json
Replace some @/... alias imports with relative paths; remove "paths" mapping ("@/module/*") from the tegg template tsconfig.
tegg template: config files simplified
tools/create-egg/src/templates/tegg/config/config.default.ts, .../config.local.ts, .../config.prod.ts, .../config.unittest.ts
Replace config factory functions returning PowerPartial<EggAppConfig> with direct object exports cast as PartialEggConfig; switch imports to type-only and remove runtime factory wrappers.
tools/create-egg vitest config
tools/create-egg/vitest.config.ts
Increase Vitest testTimeout to 20000 ms.
examples & tests: async fixes & minor changes
examples/helloworld-commonjs/index.js, packages/egg/test/**
Add .catch(console.error) to example main() call; make several test cleanup/wait calls async (await mm.restore(), await scheduler.wait(...)) to ensure proper sequencing.
tsconfig references
tsconfig.json
Remove noEmit: true while keeping incremental: true; update project reference path from ./packages/mock to ./plugins/mock.
Documentation
CLAUDE.md
Large additions covering code style, debugging, performance, troubleshooting, security, migration, release and contributing guidelines.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer/CI
  participant CLI as create-egg CLI
  participant FS as Filesystem (scaffolded project)
  participant PNPM as pnpm
  participant VT as Vitest
  participant App as Scaffolded App

  Dev->>CLI: run create-egg --template simple-ts
  CLI->>FS: scaffold files (includes vitest.config.ts, test/setup.ts)
  Dev->>PNPM: link local packages into scaffold
  PNPM-->>Dev: packages linked
  Dev->>VT: run tests in scaffolded app
  VT->>App: load vitest.config.ts -> execute test/setup.ts (expose hooks)
  VT->>App: run tests
  App-->>VT: test responses "hi, egg, TypeScript"
  VT-->>Dev: report tests passed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

"I hopped through configs, tests, and more,
Exposed the hooks, then ran the score.
Imports trimmed to types so neat,
Scaffolded apps with tests complete.
Two green checks — a carrot treat! 🥕"

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 clearly and concisely summarizes the primary change by indicating that a test is being added for the simple-ts template in the create-egg tool, matching the PR’s content and following conventional commit style.
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 make-template-test-pass

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.

@fengmk2 fengmk2 changed the title test(create-egg): add test for simple-ts template and fix test assert… test(create-egg): add test for simple-ts template Sep 25, 2025
@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 significantly enhances the create-egg tool by improving the testing infrastructure for the simple-ts template. It ensures that newly scaffolded TypeScript projects are correctly configured for testing with Vitest and that their default tests pass as expected, providing greater confidence in the template's functionality and the integrity of the project generation process.

Highlights

  • Vitest Integration: Introduced Vitest configuration and setup files for the simple-ts template, enabling modern testing practices within generated projects.
  • Test Assertion Updates: Modified existing test assertions in home.test.ts and Test.test.ts within the simple-ts template to correctly reflect the expected output 'hi, egg, TypeScript'.
  • New Integration Test: Added a comprehensive integration test for the simple-ts template scaffolding, verifying that newly generated projects can successfully run their tests using pnpm link.
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

cloudflare-workers-and-pages bot commented Sep 25, 2025

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: eecc9e8
Status:🚫  Build failed.

View logs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive testing support for the simple-ts template in the create-egg tool and fixes test assertions to match the actual output. The changes ensure that the simple-ts template can be properly scaffolded and tested.

Key changes:

  • Added vitest configuration and test setup files for the simple-ts template
  • Updated test assertions to expect "hi, egg, TypeScript" instead of "hi, egg"
  • Added integration test that verifies the generated simple-ts project can run tests successfully

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/create-egg/test/cli.test.ts Added integration test for simple-ts template scaffolding and fixed package.json creation
tools/create-egg/test/snapshots/cli.test.ts.snap Added snapshot for simple-ts template file structure
tools/create-egg/src/templates/simple-ts/vitest.config.ts Added vitest configuration for simple-ts template
tools/create-egg/src/templates/simple-ts/test/setup.ts Added vitest setup file with global test hooks
tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts Updated assertion to match actual service output
tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts Updated assertion to match actual controller output
package.json Minor alphabetical reordering of dependencies

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 25, 2025

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: eecc9e8
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 adds a comprehensive integration test for the simple-ts template, ensuring that the generated project is correctly scaffolded and its tests pass. The changes include adding necessary vitest configurations, updating test assertions to match the template's output, and creating a new test case that simulates the user workflow.

My review focuses on improving the robustness and maintainability of the new test code. I've suggested ensuring proper cleanup of temporary directories in the integration test to prevent side effects, and a more type-safe way of extending globalThis in the test setup file, avoiding the use of @ts-expect-error.

@socket-security
Copy link

socket-security bot commented Sep 25, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tools/create-egg/src/templates/simple-ts/test/setup.ts (1)

6-9: Prefer declaring the globals instead of suppressing TypeScript.

Rather than leaning on @ts-expect-error, we can extend the global typings so the assignments stay type-safe and future-proof.

-// @ts-expect-error globalThis is not typed
-globalThis.beforeAll = beforeAll;
-// @ts-expect-error globalThis is not typed
-globalThis.afterAll = afterAll;
+declare global {
+  var beforeAll: typeof beforeAll;
+  var afterAll: typeof afterAll;
+}
+
+globalThis.beforeAll = beforeAll;
+globalThis.afterAll = afterAll;
tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts (1)

5-9: Align the test description with the new assertion.

The body now checks for “hi, egg, TypeScript” but the description still mentions the old phrase. Renaming the test keeps intent clear.

- test('sayHi should return hi, egg', async () => {
+ test('sayHi should return hi, egg, TypeScript', async () => {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55bb584 and 3382818.

⛔ Files ignored due to path filters (1)
  • tools/create-egg/test/__snapshots__/cli.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (6)
  • package.json (1 hunks)
  • tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts (1 hunks)
  • tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts (1 hunks)
  • tools/create-egg/src/templates/simple-ts/test/setup.ts (1 hunks)
  • tools/create-egg/src/templates/simple-ts/vitest.config.ts (1 hunks)
  • tools/create-egg/test/cli.test.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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/src/templates/simple-ts/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts
  • tools/create-egg/src/templates/simple-ts/vitest.config.ts
  • tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts
  • tools/create-egg/test/cli.test.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/src/templates/simple-ts/test/app/controller/home.test.ts
  • tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts
  • tools/create-egg/test/cli.test.ts
🧠 Learnings (14)
📓 Common learnings
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
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
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 : Use import { describe, it } from 'vitest' in tests
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha

Applied to files:

  • tools/create-egg/src/templates/simple-ts/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts
  • tools/create-egg/src/templates/simple-ts/test/app/service/Test.test.ts
  • 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 : Use import { describe, it } from 'vitest' in tests

Applied to files:

  • tools/create-egg/src/templates/simple-ts/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest

Applied to files:

  • tools/create-egg/src/templates/simple-ts/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/vitest.config.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/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration

Applied to files:

  • tools/create-egg/src/templates/simple-ts/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests

Applied to files:

  • tools/create-egg/src/templates/simple-ts/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/vitest.config.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: Applies to **/test/**/*.test.ts : Mirror the repository test pattern when adding new suites

Applied to files:

  • tools/create-egg/src/templates/simple-ts/test/setup.ts
  • 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: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts

Applied to files:

  • tools/create-egg/src/templates/simple-ts/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/vitest.config.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/src/templates/simple-ts/test/app/controller/home.test.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation

Applied to files:

  • tools/create-egg/src/templates/simple-ts/test/app/service/Test.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 pnpm-workspace.yaml : Define dependency versions via the catalog section in pnpm-workspace.yaml and reference them with "catalog:"

Applied to files:

  • package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins,tools}/**/package.json : Individual packages must reference external dependencies via "catalog:" from pnpm-workspace.yaml

Applied to files:

  • package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to pnpm-workspace.yaml : Define external dependency versions centrally in the catalog section of pnpm-workspace.yaml

Applied to files:

  • package.json
🧬 Code graph analysis (1)
tools/create-egg/src/templates/simple-ts/vitest.config.ts (1)
packages/egg/src/lib/types.ts (1)
  • defineConfig (120-122)
⏰ 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). (12)
  • GitHub Check: Test egg-bin (windows-latest, 24)
  • GitHub Check: Test egg-bin (ubuntu-latest, 22)
  • GitHub Check: Test egg-bin (ubuntu-latest, 24)
  • GitHub Check: Test packages (windows-latest, 22)
  • GitHub Check: Test egg-bin (macos-latest, 24)
  • GitHub Check: Test packages (macos-latest, 24)
  • GitHub Check: Test packages (macos-latest, 22)
  • GitHub Check: Test egg-bin (windows-latest, 22)
  • GitHub Check: Test packages (ubuntu-latest, 24)
  • GitHub Check: Test egg-bin (macos-latest, 22)
  • GitHub Check: Test packages (windows-latest, 24)
  • GitHub Check: Test packages (ubuntu-latest, 22)
🔇 Additional comments (3)
package.json (1)

26-27: Reordering semver keeps the catalog references tidy.

No functional impact here and the catalog contract remains intact.

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

1-7: Thanks for wiring the Vitest setup file.

This keeps the template self-contained and ensures the bootstrap globals come online before the suites run.

tools/create-egg/src/templates/simple-ts/test/app/controller/home.test.ts (1)

5-8: Expectation update matches the generated greeting.

The assertion now reflects the template output—looks good.

@codecov
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.89%. Comparing base (55bb584) to head (eecc9e8).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5538      +/-   ##
==========================================
+ Coverage   75.84%   75.89%   +0.05%     
==========================================
  Files         114      114              
  Lines        5770     5770              
  Branches     1151     1152       +1     
==========================================
+ Hits         4376     4379       +3     
+ Misses       1214     1211       -3     
  Partials      180      180              

☔ 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tools/create-egg/src/templates/tegg/app/module/bar/package.json (1)

1-7: Mark all tegg module packages as private
Add "private": true after the "name" field in each module’s package.json under tools/create-egg/src/templates/tegg/app/module to prevent accidental publishes. For example:

 tools/create-egg/src/templates/tegg/app/module/<module>/package.json
 {
   "name": "<module>",
+  "private": true,
   "eggModule": { "name": "<module>" },
   "type": "module"
 }
🧹 Nitpick comments (7)
tools/create-egg/vitest.config.ts (1)

5-5: Consider raising timeout or confirm CI stability

20s might be tight for scaffold/integration steps. If you’ve seen flakiness, bump to 30–60s.

Apply this diff if needed:

-    testTimeout: 20000,
+    testTimeout: 30000,
tools/create-egg/src/templates/tegg/package.json (1)

25-35: Confirm intentional use of "beta" tags

Using dist‑tag "beta" for core deps (egg, tegg, vitest) can introduce breaking changes over time in generated apps. If stability is preferred, consider pinning specific pre‑releases.

Also applies to: 37-46

tools/create-egg/src/templates/tegg/test/setup.ts (1)

1-9: Type the globals instead of suppressing errors

Avoid ts‑expect‑error by declaring globals; also consider exposing beforeEach/afterEach for parity.

Apply:

-import { beforeAll, afterAll } from 'vitest';
+import { beforeAll, afterAll, beforeEach, afterEach } from 'vitest';
 
 // https://vitest.dev/config/#setupfiles
 // export beforeAll and afterAll to globalThis, let @eggjs/mock/bootstrap use it
 
-// @ts-expect-error globalThis is not typed
-globalThis.beforeAll = beforeAll;
-// @ts-expect-error globalThis is not typed
-globalThis.afterAll = afterAll;
+declare global {
+  // eslint-disable-next-line no-var
+  var beforeAll: typeof beforeAll;
+  // eslint-disable-next-line no-var
+  var afterAll: typeof afterAll;
+  // eslint-disable-next-line no-var
+  var beforeEach: typeof beforeEach;
+  // eslint-disable-next-line no-var
+  var afterEach: typeof afterEach;
+}
+
+globalThis.beforeAll = beforeAll;
+globalThis.afterAll = afterAll;
+globalThis.beforeEach = beforeEach;
+globalThis.afterEach = afterEach;
tools/create-egg/src/templates/tegg/config/config.prod.ts (1)

3-5: Use satisfies PartialEggConfig instead of an as cast

Keeps strict typing without widening.

Apply:

 export default {
   // add your config here
-} as PartialEggConfig;
+} satisfies PartialEggConfig;
tools/create-egg/src/templates/tegg/config/config.unittest.ts (1)

3-5: Switch to satisfies PartialEggConfig for safer typing

Consistent with other config files and keeps literal types intact.

Apply:

 export default {
   // add your config here
-} as PartialEggConfig;
+} satisfies PartialEggConfig;
tools/create-egg/src/templates/tegg/config/config.local.ts (1)

3-5: Replace as PartialEggConfig with satisfies PartialEggConfig in all tegg config templates

  • tools/create-egg/src/templates/tegg/config/config.local.ts
  • tools/create-egg/src/templates/tegg/config/config.unittest.ts
  • tools/create-egg/src/templates/tegg/config/config.prod.ts
  • tools/create-egg/src/templates/tegg/config/config.default.ts
tools/create-egg/src/templates/tegg/config/config.default.ts (1)

1-1: Annotate appInfo and use satisfies for safer typings

  • Import EggAppInfo and annotate the callback:
    import { defineConfig, type EggAppInfo, type PartialEggConfig } from 'egg';
    export default defineConfig((appInfo: EggAppInfo) => ({} satisfies PartialEggConfig));
  • Update any example references to the eggjs/examples repo to use its default master branch.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3382818 and 78d893a.

⛔ Files ignored due to path filters (1)
  • tools/create-egg/test/__snapshots__/cli.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (17)
  • tools/create-egg/src/templates/tegg/app/module/bar/controller/home.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/app/module/bar/controller/user.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/app/module/bar/package.json (1 hunks)
  • tools/create-egg/src/templates/tegg/app/module/foo/package.json (1 hunks)
  • tools/create-egg/src/templates/tegg/app/module/foo/service/HelloService.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/config/config.default.ts (2 hunks)
  • tools/create-egg/src/templates/tegg/config/config.local.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/config/config.prod.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/config/config.unittest.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/config/plugin.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/package.json (2 hunks)
  • tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/test/setup.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/tsconfig.json (0 hunks)
  • tools/create-egg/src/templates/tegg/vitest.config.ts (1 hunks)
  • tools/create-egg/test/cli.test.ts (3 hunks)
  • tools/create-egg/vitest.config.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • tools/create-egg/src/templates/tegg/tsconfig.json
✅ Files skipped from review due to trivial changes (1)
  • tools/create-egg/src/templates/tegg/app/module/bar/controller/user.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tools/create-egg/test/cli.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
{packages,plugins,tools}/**/package.json

📄 CodeRabbit inference engine (CLAUDE.md)

{packages,plugins,tools}/**/package.json: Individual packages must reference external dependencies via "catalog:" from pnpm-workspace.yaml
Use "workspace:*" for internal monorepo dependencies between packages

Files:

  • tools/create-egg/src/templates/tegg/app/module/bar/package.json
  • tools/create-egg/src/templates/tegg/app/module/foo/package.json
  • tools/create-egg/src/templates/tegg/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/src/templates/tegg/config/plugin.ts
  • tools/create-egg/src/templates/tegg/config/config.local.ts
  • tools/create-egg/src/templates/tegg/config/config.unittest.ts
  • tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.ts
  • tools/create-egg/vitest.config.ts
  • tools/create-egg/src/templates/tegg/test/setup.ts
  • tools/create-egg/src/templates/tegg/vitest.config.ts
  • tools/create-egg/src/templates/tegg/app/module/foo/service/HelloService.ts
  • tools/create-egg/src/templates/tegg/config/config.prod.ts
  • tools/create-egg/src/templates/tegg/config/config.default.ts
  • tools/create-egg/src/templates/tegg/app/module/bar/controller/home.ts
🧠 Learnings (12)
📓 Common learnings
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
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
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 : Use import { describe, it } from 'vitest' in tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsdown.config.ts : packages/egg must use tsdown configured for unbundled ESM output
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to plugins/*/package.json : Plugin package.json must include an eggPlugin configuration field

Applied to files:

  • tools/create-egg/src/templates/tegg/config/plugin.ts
  • tools/create-egg/src/templates/tegg/package.json
  • tools/create-egg/src/templates/tegg/config/config.default.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode

Applied to files:

  • tools/create-egg/src/templates/tegg/config/plugin.ts
  • tools/create-egg/src/templates/tegg/app/module/foo/package.json
  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsdown.config.ts : packages/egg must use tsdown configured for unbundled ESM output

Applied to files:

  • tools/create-egg/src/templates/tegg/config/config.local.ts
  • tools/create-egg/src/templates/tegg/config/config.unittest.ts
  • tools/create-egg/src/templates/tegg/package.json
  • tools/create-egg/src/templates/tegg/config/config.prod.ts
  • tools/create-egg/src/templates/tegg/config/config.default.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation

Applied to files:

  • tools/create-egg/src/templates/tegg/config/config.local.ts
  • tools/create-egg/src/templates/tegg/package.json
  • tools/create-egg/src/templates/tegg/config/config.default.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 : Use import { describe, it } from 'vitest' in tests

Applied to files:

  • tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.ts
  • tools/create-egg/src/templates/tegg/test/setup.ts
  • tools/create-egg/src/templates/tegg/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha

Applied to files:

  • tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.ts
  • tools/create-egg/src/templates/tegg/test/setup.ts
  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration

Applied to files:

  • tools/create-egg/vitest.config.ts
  • tools/create-egg/src/templates/tegg/test/setup.ts
  • tools/create-egg/src/templates/tegg/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest

Applied to files:

  • tools/create-egg/src/templates/tegg/test/setup.ts
  • tools/create-egg/src/templates/tegg/vitest.config.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/tegg/test/setup.ts
  • tools/create-egg/src/templates/tegg/vitest.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests

Applied to files:

  • tools/create-egg/src/templates/tegg/test/setup.ts
  • tools/create-egg/src/templates/tegg/vitest.config.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: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts

Applied to files:

  • tools/create-egg/src/templates/tegg/test/setup.ts
  • tools/create-egg/src/templates/tegg/vitest.config.ts
🧬 Code graph analysis (5)
tools/create-egg/src/templates/tegg/config/config.local.ts (1)
packages/egg/src/lib/types.ts (1)
  • PartialEggConfig (97-97)
tools/create-egg/src/templates/tegg/config/config.unittest.ts (1)
packages/egg/src/lib/types.ts (1)
  • PartialEggConfig (97-97)
tools/create-egg/src/templates/tegg/vitest.config.ts (1)
packages/egg/src/lib/types.ts (1)
  • defineConfig (120-122)
tools/create-egg/src/templates/tegg/config/config.prod.ts (1)
packages/egg/src/lib/types.ts (1)
  • PartialEggConfig (97-97)
tools/create-egg/src/templates/tegg/config/config.default.ts (1)
packages/egg/src/lib/types.ts (2)
  • defineConfig (120-122)
  • PartialEggConfig (97-97)
⏰ 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). (13)
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Test egg-bin (ubuntu-latest, 24)
  • GitHub Check: Test egg-bin (macos-latest, 22)
  • GitHub Check: Test egg-bin (windows-latest, 22)
  • GitHub Check: Test egg-bin (ubuntu-latest, 22)
  • GitHub Check: Test egg-bin (windows-latest, 24)
  • GitHub Check: Test egg-bin (macos-latest, 24)
  • GitHub Check: Test packages (macos-latest, 22)
  • GitHub Check: Test packages (windows-latest, 22)
  • GitHub Check: Test packages (macos-latest, 24)
  • GitHub Check: Test packages (ubuntu-latest, 24)
  • GitHub Check: Test packages (windows-latest, 24)
  • GitHub Check: Test packages (ubuntu-latest, 22)
🔇 Additional comments (6)
tools/create-egg/src/templates/tegg/test/app/module/foo/service/HelloService.test.skip.ts (1)

4-4: Import resolves correctly to module entrypoint.

The relative path now targets the module’s re-export surface, matching the updated template layout.

tools/create-egg/src/templates/tegg/app/module/foo/service/HelloService.ts (1)

1-1: Type‑only import LGTM

Switching EggLogger to a type import avoids unnecessary runtime deps.

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

1-34: Type‑only EggPlugin import LGTM

Config object looks correct and export is ESM‑friendly.

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

5-6: Module type addition LGTM

"Type": "module" aligns with the template’s ESM direction.

tools/create-egg/src/templates/tegg/app/module/bar/controller/home.ts (1)

1-19: Type‑only import LGTM

Pattern matches other files; no runtime import of types.

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

1-7: Vitest setup config LGTM

Setup file wiring is correct and minimal.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
CLAUDE.md (1)

225-231: Fix the Markdown emphasis formatting.
The escaped asterisks leak into the rendered text. Tightening the emphasis keeps the guideline readable.

-- **`entry: 'src/**/\*.ts'`\*\* - Processes all TypeScript files in src directory
+- **`entry: 'src/**/*.ts'`** - Processes all TypeScript files in the src directory
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7bc8e86 and b08ba16.

📒 Files selected for processing (4)
  • CLAUDE.md (2 hunks)
  • tools/create-egg/src/templates/simple-ts/test/setup.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/package.json (2 hunks)
  • tools/create-egg/src/templates/tegg/test/setup.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tools/create-egg/src/templates/tegg/test/setup.ts
  • tools/create-egg/src/templates/simple-ts/test/setup.ts
🧰 Additional context used
📓 Path-based instructions (1)
{packages,plugins,tools}/**/package.json

📄 CodeRabbit inference engine (CLAUDE.md)

{packages,plugins,tools}/**/package.json: Individual packages must reference external dependencies via "catalog:" from pnpm-workspace.yaml
Use "workspace:*" for internal monorepo dependencies between packages

Files:

  • tools/create-egg/src/templates/tegg/package.json
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
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
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
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 : Use import { describe, it } from 'vitest' in tests
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration

Applied to files:

  • CLAUDE.md
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode

Applied to files:

  • CLAUDE.md
  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest

Applied to files:

  • CLAUDE.md
📚 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:

  • CLAUDE.md
📚 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 : Use import { describe, it } from 'vitest' in tests

Applied to files:

  • CLAUDE.md
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha

Applied to files:

  • CLAUDE.md
  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to plugins/*/package.json : Plugin package.json must include an eggPlugin configuration field

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsdown.config.ts : packages/egg must use tsdown configured for unbundled ESM output

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
⏰ 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). (13)
  • GitHub Check: Test packages (ubuntu-latest, 24)
  • GitHub Check: Test packages (macos-latest, 24)
  • GitHub Check: Test packages (macos-latest, 22)
  • GitHub Check: Test packages (windows-latest, 24)
  • GitHub Check: Test packages (ubuntu-latest, 22)
  • GitHub Check: Test packages (windows-latest, 22)
  • GitHub Check: Test egg-bin (macos-latest, 24)
  • GitHub Check: Test egg-bin (macos-latest, 22)
  • GitHub Check: Test egg-bin (ubuntu-latest, 24)
  • 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: Cloudflare Pages: egg-v3
🔇 Additional comments (1)
tools/create-egg/src/templates/tegg/package.json (1)

13-13: Fix NODE_OPTIONS quoting for Windows compatibility

Single-quoting the value leaves literal ' characters in the environment on Windows, so Node sees \'--import and exits with an unknown option error. Drop the quotes and use = to avoid spaces.

Apply this diff:

-    "test:local": "cross-env NODE_OPTIONS='--import @oxc-node/core/register' vitest run",
+    "test:local": "cross-env NODE_OPTIONS=--import=@oxc-node/core/register vitest run",

@socket-security
Copy link

socket-security bot commented Sep 25, 2025

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
tools/create-egg/test/cli.test.ts (4)

15-16: Correct mkdtemp usage; optional: initialize tempDir in beforeAll to avoid module-level side effects

Creating the temp dir at import time can have side effects with filtered/partial runs. Initialize it in beforeAll instead.

Apply this diff:

-const tempDirPrefix = path.join(tmpdir(), 'my-app-temp-');
-const tempDir = fs.mkdtempSync(tempDirPrefix);
+const tempDirPrefix = path.join(tmpdir(), 'create-egg-');
+let tempDir: string;

And update hooks:

// inside this file
beforeAll(() => {
  tempDir = fs.mkdtempSync(tempDirPrefix);
});
afterAll(() => {
  if (tempDir) fs.rmSync(tempDir, { recursive: true, force: true });
});

30-30: Prefer JSON.stringify for package.json

Avoid raw string JSON. Safer and clearer.

-  fs.writeFileSync(pkgJson, '{ "foo": "bar", "type": "module" }');
+  fs.writeFileSync(pkgJson, JSON.stringify({ foo: 'bar', type: 'module' }, null, 2));

130-152: Reduce duplication and apply the same robustness to tegg test

  • This duplicates the earlier tegg scaffolding test; consider parameterizing templates to DRY.
  • Apply the same safer linking approach here.

Apply this diff to split linking:

-  execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir });
+  execaCommandSync(`pnpm link ${mockDir}`, { cwd: projectDir });
+  execaCommandSync(`pnpm link ${eggDir}`, { cwd: projectDir });

109-129: Harden simple-ts integration test: safer linking and resilience

  • Split linking into two commands:
-  execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir });
+  execaCommandSync(`pnpm link ${mockDir}`, { cwd: projectDir });
+  execaCommandSync(`pnpm link ${eggDir}`, { cwd: projectDir });
  • Wrap test steps in try/finally to cleanup projectDir on failure.
  • Optionally invoke pnpm test:local -- --reporter=json and parse the JSON reporter instead of matching '2 passed'.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b08ba16 and f5cb114.

📒 Files selected for processing (2)
  • tools/create-egg/src/templates/tegg/package.json (2 hunks)
  • tools/create-egg/test/cli.test.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tools/create-egg/src/templates/tegg/package.json
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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
**/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
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
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
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
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 : Use import { describe, it } from 'vitest' in tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
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
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha

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: Applies to **/test/**/*.test.ts : Mirror the repository test pattern when adding new suites

Applied to files:

  • tools/create-egg/test/cli.test.ts
⏰ 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). (12)
  • GitHub Check: Test egg-bin (ubuntu-latest, 24)
  • GitHub Check: Test egg-bin (windows-latest, 24)
  • GitHub Check: Test egg-bin (macos-latest, 22)
  • GitHub Check: Test egg-bin (ubuntu-latest, 22)
  • GitHub Check: Test egg-bin (windows-latest, 22)
  • GitHub Check: Test packages (windows-latest, 22)
  • GitHub Check: Test egg-bin (macos-latest, 24)
  • GitHub Check: Test packages (windows-latest, 24)
  • GitHub Check: Test packages (macos-latest, 24)
  • GitHub Check: Test packages (ubuntu-latest, 22)
  • GitHub Check: Test packages (ubuntu-latest, 24)
  • GitHub Check: Test packages (macos-latest, 22)
🔇 Additional comments (3)
tools/create-egg/test/cli.test.ts (3)

3-3: Good fix: using tmpdir for mkdtemp prefix

This addresses the earlier mkdtemp prefix issue.


7-7: Vitest lifecycle imports look good

Imports align with usage in this file.


50-50: Cleanup hook is appropriate

Removing the temp workspace in afterAll is correct.

"stop": "eggctl stop --title=egg-server-{{name}}",
"dev": "egg-bin dev",
"test:local": "vitest run",
"test:local": "cross-env NODE_OPTIONS=\"--import @oxc-node/core/register\" vitest run",
Copy link
Member Author

Choose a reason for hiding this comment

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

should auto import @oxc-node/core/register when tegg plugin load

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tools/create-egg/test/cli.test.ts (2)

127-128: Link packages individually; avoid multi-arg pnpm link and quote paths

pnpm link may not accept multiple paths reliably; quoting also avoids issues with spaces.

Apply this diff:

-    execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir });
+    execaCommandSync(`pnpm link "${mockDir}"`, { cwd: projectDir });
+    execaCommandSync(`pnpm link "${eggDir}"`, { cwd: projectDir });

And similarly in the tegg test:

-  execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir });
+  execaCommandSync(`pnpm link "${mockDir}"`, { cwd: projectDir });
+  execaCommandSync(`pnpm link "${eggDir}"`, { cwd: projectDir });

Also applies to: 151-153


30-31: Confirm need for "type": "module" in the non-empty-dir sentinel

If this file is used purely to mark the directory as non-empty, consider minimizing contents to reduce any unintended CLI branching based on package type.

Example minimal content: { "name": "non-empty" }

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f5cb114 and eecc9e8.

📒 Files selected for processing (1)
  • tools/create-egg/test/cli.test.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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
**/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
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/vitest.config.ts : Each non-CLI package must include a vitest.config.ts for test configuration
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
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Vitest test files should follow the naming pattern test/**/*.test.ts and import from vitest
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 : Use import { describe, it } from 'vitest' in tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins}/**/test/**/*.test.ts : Use Node.js built-in assert for assertions in Vitest tests
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/test/**/*.test.ts : Place test suites following Vitest discovery: **/test/**/*.test.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/test/**/*.test.ts : egg-bin (CLI tool) tests must use Mocha

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: Applies to **/test/**/*.test.ts : Mirror the repository test pattern when adding new suites

Applied to files:

  • tools/create-egg/test/cli.test.ts
⏰ 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). (12)
  • GitHub Check: Test egg-bin (macos-latest, 24)
  • GitHub Check: Test egg-bin (ubuntu-latest, 24)
  • GitHub Check: Test egg-bin (windows-latest, 22)
  • GitHub Check: Test egg-bin (macos-latest, 22)
  • GitHub Check: Test egg-bin (ubuntu-latest, 22)
  • GitHub Check: Test egg-bin (windows-latest, 24)
  • GitHub Check: Test packages (ubuntu-latest, 24)
  • GitHub Check: Test packages (windows-latest, 24)
  • GitHub Check: Test packages (ubuntu-latest, 22)
  • GitHub Check: Test packages (macos-latest, 24)
  • GitHub Check: Test packages (windows-latest, 22)
  • GitHub Check: Test packages (macos-latest, 22)
🔇 Additional comments (2)
tools/create-egg/test/cli.test.ts (2)

109-131: Prefer per-test temp dirs with try/finally to ensure cleanup on failures

Creating a shared temp dir at module scope can leak if the process crashes mid-test. Create a temp dir inside each integration test and clean it with try/finally.

Apply this diff to the simple-ts test:

 test.skipIf(process.platform === 'win32')(
   'successfully scaffolds a project based on simple-ts starter template',
-  () => {
-    const projectName = 'create-egg-test-simple-ts';
-    const { stdout } = run([projectName, '--template', 'simple-ts'], {
-      cwd: tempDir,
-    });
-    const projectDir = path.join(tempDir, projectName);
-    const generatedFiles = fs.readdirSync(projectDir).sort();
+  () => {
+    const prefix = path.join(tmpdir(), 'create-egg-');
+    const localTemp = fs.mkdtempSync(prefix);
+    try {
+      const projectName = 'create-egg-test-simple-ts';
+      const { stdout } = run([projectName, '--template', 'simple-ts'], {
+        cwd: localTemp,
+      });
+      const projectDir = path.join(localTemp, projectName);
+      const generatedFiles = fs.readdirSync(projectDir).sort();
 
     // Assertions
     expect(stdout).toContain(`Scaffolding project with`);
-    expect(generatedFiles).matchSnapshot();
+    expect(generatedFiles).toMatchSnapshot();
 
     // run test
     const monoRepoDir = path.join(import.meta.dirname, '../../../');
     const eggDir = path.join(monoRepoDir, 'packages/egg');
     const mockDir = path.join(monoRepoDir, 'plugins/mock');
-    execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir });
+    execaCommandSync(`pnpm link "${mockDir}"`, { cwd: projectDir });
+    execaCommandSync(`pnpm link "${eggDir}"`, { cwd: projectDir });
     const { stdout: testStdout } = execaCommandSync('pnpm test:local', { cwd: projectDir });
     expect(testStdout).toContain('2 passed');
-  }
+    } finally {
+      fs.rmSync(localTemp, { recursive: true, force: true });
+    }
+  }
 );

And similarly for the tegg test:

 test.skipIf(process.platform === 'win32')('successfully scaffolds a project based on tegg starter template', () => {
-  const projectName = 'create-egg-test-tegg';
-  const { stdout } = run([projectName, '--template', 'tegg'], {
-    cwd: tempDir,
-  });
-  const projectDir = path.join(tempDir, projectName);
-  const generatedFiles = fs.readdirSync(projectDir).sort();
+  const prefix = path.join(tmpdir(), 'create-egg-');
+  const localTemp = fs.mkdtempSync(prefix);
+  try {
+    const projectName = 'create-egg-test-tegg';
+    const { stdout } = run([projectName, '--template', 'tegg'], {
+      cwd: localTemp,
+    });
+    const projectDir = path.join(localTemp, projectName);
+    const generatedFiles = fs.readdirSync(projectDir).sort();
 
   // Assertions
   expect(stdout).toContain(`Scaffolding project with`);
-  expect(generatedFiles).matchSnapshot();
+  expect(generatedFiles).toMatchSnapshot();
 
   // run test
   const monoRepoDir = path.join(import.meta.dirname, '../../../');
   const eggDir = path.join(monoRepoDir, 'packages/egg');
   const mockDir = path.join(monoRepoDir, 'plugins/mock');
-  execaCommandSync(`pnpm link ${mockDir} ${eggDir}`, { cwd: projectDir });
+  execaCommandSync(`pnpm link "${mockDir}"`, { cwd: projectDir });
+  execaCommandSync(`pnpm link "${eggDir}"`, { cwd: projectDir });
   const { stdout: testStdout } = execaCommandSync('pnpm test:local', { cwd: projectDir });
   expect(testStdout).toContain('2 passed');
-});
+  } finally {
+    fs.rmSync(localTemp, { recursive: true, force: true });
+  }
+});

If you adopt this, you can drop the top-level tempDir and its afterAll cleanup.

Also applies to: 135-154


15-16: LGTM: mkdtemp prefix and global cleanup

Correct mkdtemp prefix usage and an afterAll cleanup are in place. This unblocks the EACCES/FS issues seen earlier.

Also applies to: 50-50

Comment on lines +119 to +122
// Assertions
expect(stdout).toContain(`Scaffolding project with`);
expect(generatedFiles).matchSnapshot();

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Use Vitest’s toMatchSnapshot()

The matcher should be toMatchSnapshot(); matchSnapshot() will fail.

Apply this diff:

-    expect(generatedFiles).matchSnapshot();
+    expect(generatedFiles).toMatchSnapshot();
-  expect(generatedFiles).matchSnapshot();
+  expect(generatedFiles).toMatchSnapshot();

Also applies to: 143-146

🤖 Prompt for AI Agents
In tools/create-egg/test/cli.test.ts around lines 119-122 (and also apply same
change at 143-146), the test uses the incorrect matcher matchSnapshot(); replace
matchSnapshot() with Vitest’s toMatchSnapshot() on the generatedFiles assertion
so it reads expect(generatedFiles).toMatchSnapshot(); keep the surrounding
assertions unchanged.

@fengmk2 fengmk2 merged commit fdbb014 into next Sep 25, 2025
22 of 25 checks passed
@fengmk2 fengmk2 deleted the make-template-test-pass branch September 25, 2025 15:19
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