Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Dec 29, 2024

BREAKING CHANGE: drop Node.js < 18.19.0 support

part of eggjs/egg#3644

eggjs/egg#5257

Summary by CodeRabbit

  • Chores
    • Enhanced CI/CD pipeline to test across multiple Node.js versions (20, 22, 24) and operating systems (Ubuntu, macOS).
    • Increased Node.js requirement to >= 20.
    • Updated Egg.js framework and related tooling packages to beta versions.
    • Migrated projects to TypeScript and ES modules for improved type safety.
    • Updated development dependencies and build tooling infrastructure.
    • Refreshed documentation badges and build configuration.

BREAKING CHANGE: drop Node.js < 18.19.0 support

part of eggjs/egg#3644

eggjs/egg#5257
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2024

Walkthrough

Repository examples are migrated to newer EggJS beta versions with Node.js 20+ requirement, CI workflows updated to matrix-based testing, and projects converted from CommonJS to ES modules with TypeScript enhancements.

Changes

Cohort / File(s) Change Summary
CI & Workflow Configuration
.github/workflows/ci.yml, .github/PULL_REQUEST_TEMPLATE.md
Workflow updated to matrix-based testing across ubuntu-latest/macos-latest with Node.js 20/22/24; removed workflow_dispatch trigger; added concurrency group; deleted PR template file.
Documentation & Root Configuration
README.md, package.json
Replaced Travis CI badge with GitHub Actions; updated Node.js requirement from 8 to 20; updated test script to use bin/test.sh; updated npminstall from ^6.6.2 to ^7.12.0.
Test Infrastructure
bin/test.sh
New Bash script added for running tests across example directories with npm update and cleanup.
hello-tegg Example Migration
hello-tegg/.gitignore, hello-tegg/config/config.default.ts, hello-tegg/package.json, hello-tegg/test/biz/HelloService.test.ts, hello-tegg/test/controller/HelloController.test.ts, hello-tegg/tsconfig.json, hello-tegg/tsconfig.prod.json, hello-tegg/app/biz/package.json, hello-tegg/app/controller/HelloController.ts, hello-tegg/app/middleware/trace_method.ts, hello-tegg/config/plugin.ts
Migrated to EggJS beta packages; updated config to use defineConfigFactory; switched to @eggjs/mock/bootstrap; updated dependencies to Node 20+; converted imports to type-only where applicable; added .egg/ to gitignore; created tsconfig.prod.json.
helloworld Example Migration
helloworld/.eslintrc, helloworld/.gitignore, helloworld/app/controller/foo.js, helloworld/app/controller/foo.ts, helloworld/app/controller/home.js, helloworld/app/controller/home.ts, helloworld/app/router.ts, helloworld/config/config.default.js, helloworld/config/config.default.ts, helloworld/package.json, helloworld/test/index.test.js, helloworld/test/index.test.ts, helloworld/tsconfig.json
Converted controllers from JavaScript to TypeScript; updated router to ES6 export; migrated config to defineConfig; added ESLint config and tsconfig; replaced CommonJS with ESM; updated package.json to beta dependencies and added build/lint/test scripts; updated tests to use @eggjs/mock/bootstrap; updated foo controller to return status 400 with JSON response.
body-parser-example Migration
body-parser-example/app/controller/home.js, body-parser-example/config/config.default.js, body-parser-example/package.json, body-parser-example/test/home.test.js
Updated egg-bin/egg-mock to @eggjs versions (beta); changed project name to body-parser-example; removed 'use strict' directive; updated import from egg-mock/bootstrap to @eggjs/mock/bootstrap; renamed cov script to ci.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Rationale: Broad scope affecting multiple example directories with repetitive patterns (version updates, import migrations, ESM conversion). Changes are largely consistent and mechanical across projects—dependency updates, test framework migrations to @eggjs/mock, and TypeScript additions. However, logic density is low and patterns repeat, reducing per-file review complexity. Some heterogeneity in foo controller behavior change (status 400 vs. 200) and configuration factory pattern introduction warrants focused attention.

Poem

🐰 A rabbit hops through examples new,
With beta packages and Node 20 too!
From CommonJS to ES modules we spring,
TypeScript configs and tests take wing—
The warren's all modernized, what a thing! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: upgrade to egg v4" clearly and directly summarizes the primary objective of this pull request. The changeset demonstrates a comprehensive upgrade to Egg v4 across the project, including updates to core dependencies (egg, @eggjs packages), minimum Node.js version requirement from 14.17.0 to >= 20, migration to new configuration patterns (defineConfigFactory, defineConfig), adoption of TypeScript with ES6 modules, and updates to tooling (ESLint 8, TypeScript 5, @types/node 22). The title is concise, specific, and avoids vague terminology, making it clear to developers reviewing the repository history what the primary change entails.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch egg-v4

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.

@socket-security
Copy link

socket-security bot commented Dec 29, 2024

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@fengmk2 fengmk2 marked this pull request as ready for review March 12, 2025 14:44
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: 4

🧹 Nitpick comments (4)
hello-tegg/app/middleware/trace_method.ts (1)

5-5: Consider using a more specific type instead of any.

Using (ctx.body as any) bypasses TypeScript's type checking. While this works, it loses the benefits of type safety. If possible, consider defining or importing the appropriate interface for ctx.body structure.

- (ctx.body as any).data.message += ` (${ctx.method})`;
+ interface ResponseBody {
+   data: {
+     message: string;
+   };
+ }
+ (ctx.body as ResponseBody).data.message += ` (${ctx.method})`;

Alternatively, if this is a common pattern in the codebase, consider extending the EggContext type to include the body property with the right structure.

bin/test.sh (1)

8-9: Consider making the registry configurable.

The script hardcodes a specific npm registry (npmmirror.com), which might be region-specific. Consider making this configurable through an environment variable to improve flexibility.

- npm install --registry=https://registry.npmmirror.com
+ NPM_REGISTRY=${NPM_REGISTRY:-"https://registry.npmmirror.com"}
+ npm install --registry=$NPM_REGISTRY
README.md (1)

22-22: Consider using proper heading syntax

The linter flagged line 22 for using emphasis instead of a heading format. Consider changing:

- **Recommend to use Node >= 18**
+ ## Recommend to use Node >= 18

This maintains consistent document structure and improves accessibility.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

22-22: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

helloworld/test/index.test.ts (1)

11-18: Good practice using async/await

The second test correctly uses async/await pattern for testing the /foo endpoint. Consider applying the same pattern to the first test for consistency.

-  it('should GET / 200', () => {
-    return app.httpRequest()
+  it('should GET / 200', async () => {
+    await app.httpRequest()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ea83ef and 6dac52f.

📒 Files selected for processing (26)
  • .github/PULL_REQUEST_TEMPLATE.md (0 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • README.md (2 hunks)
  • bin/test.sh (1 hunks)
  • hello-tegg/.gitignore (1 hunks)
  • hello-tegg/app/middleware/trace_method.ts (1 hunks)
  • hello-tegg/config/config.default.ts (1 hunks)
  • hello-tegg/config/plugin.ts (1 hunks)
  • hello-tegg/package.json (1 hunks)
  • hello-tegg/test/biz/HelloService.test.ts (1 hunks)
  • hello-tegg/test/controller/HelloController.test.ts (1 hunks)
  • hello-tegg/tsconfig.json (1 hunks)
  • helloworld/.eslintrc (1 hunks)
  • helloworld/.gitignore (1 hunks)
  • helloworld/app/controller/foo.js (0 hunks)
  • helloworld/app/controller/foo.ts (1 hunks)
  • helloworld/app/controller/home.js (0 hunks)
  • helloworld/app/controller/home.ts (1 hunks)
  • helloworld/app/router.ts (1 hunks)
  • helloworld/config/config.default.js (0 hunks)
  • helloworld/config/config.default.ts (1 hunks)
  • helloworld/package.json (1 hunks)
  • helloworld/test/index.test.js (0 hunks)
  • helloworld/test/index.test.ts (1 hunks)
  • helloworld/tsconfig.json (1 hunks)
  • package.json (2 hunks)
💤 Files with no reviewable changes (5)
  • helloworld/app/controller/home.js
  • helloworld/app/controller/foo.js
  • .github/PULL_REQUEST_TEMPLATE.md
  • helloworld/test/index.test.js
  • helloworld/config/config.default.js
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md

22-22: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

🪛 Shellcheck (0.10.0)
bin/test.sh

[warning] 5-5: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

🔇 Additional comments (29)
hello-tegg/.gitignore (1)

22-22: Good addition to .gitignore

Adding .egg/ to the ignore list is appropriate as part of the upgrade to Egg v4. This directory typically contains framework-generated files that shouldn't be tracked in version control.

helloworld/app/controller/home.ts (1)

1-8: Clean TypeScript implementation

Good job migrating this controller from JavaScript to TypeScript. The implementation follows best practices with proper class extension, async/await usage, and clean syntax.

helloworld/config/config.default.ts (1)

1-5: Well-typed configuration file

Good implementation of the TypeScript configuration file with proper type imports and assertions. The use of the EggAppConfig type ensures type safety for your configuration.

helloworld/app/controller/foo.ts (1)

1-11: Clean controller implementation with question about status code

The TypeScript implementation of this controller looks good with proper class extension and async/await usage.

One observation: the controller always returns a 400 (Bad Request) status code without any conditional validation. Is this intentional behavior, or should there be some error condition checking?

helloworld/.gitignore (1)

1-2:

Details

✅ Verification successful

Verify the impact of ignoring all JavaScript files.

The .gitignore file is set to ignore all JavaScript files (*.js), which suggests this project is transitioning to TypeScript where JS files are generated from TS sources. This is generally appropriate when working with TypeScript, but could have unintended consequences if any source JavaScript files still exist.


🏁 Script executed:

#!/bin/bash
# Check if there are any source JavaScript files that might be accidentally ignored
echo "Checking for JavaScript source files in the helloworld directory..."
find helloworld -type f -name "*.js" | grep -v "node_modules" || echo "No JavaScript source files found that would be ignored"

# Check for presence of TypeScript files to confirm TypeScript usage
echo "Verifying TypeScript files exist..."
find helloworld -type f -name "*.ts" || echo "No TypeScript files found - the *.js ignore pattern might be unnecessary"

Length of output: 603


JavaScript Ignore Pattern Verified
The verification confirms that there are no JavaScript source files in the repository and that multiple TypeScript files are present. This indicates that the *.js ignore pattern is appropriate for this project. No action is required unless source JavaScript files are introduced in the future.

helloworld/.eslintrc (1)

1-6: LGTM! TypeScript linting configuration looks appropriate.

The ESLint configuration properly extends the recommended TypeScript rules for the Egg framework, which aligns with the project's upgrade to egg v4 and transition to TypeScript.

helloworld/app/router.ts (1)

1-3: Clean migration to TypeScript and ES modules

The transition from CommonJS to ES modules with proper TypeScript typing is well-implemented. This change aligns with modern JavaScript practices and the egg v4 framework upgrade.

hello-tegg/config/plugin.ts (1)

1-4: Verify type handling for plugin configuration

The removal of the EggPlugin import and type annotation appears to be part of adapting to egg v4's typing system. Consider:

  1. If egg v4 provides type inference for plugins automatically, this change is appropriate
  2. If type safety is still needed, consider using the framework's updated type definitions

Can you verify that this approach maintains type safety under egg v4?

README.md (1)

3-10: Documentation correctly updated for egg v4

The README updates properly reflect the new requirements:

  • Updated CI badge to GitHub Actions
  • Specified Node.js >= 18 requirement
  • Updated Egg version to >= 4

These changes align well with the PR objective and clearly communicate the breaking change regarding Node.js version requirements.

Also applies to: 22-22

helloworld/tsconfig.json (1)

1-14: Well-configured TypeScript setup

This TypeScript configuration is appropriately set up for the egg v4 upgrade:

  • Extends the base egg TypeScript configuration
  • Enables strict type checking for better code quality
  • Uses ES2022 target which is compatible with Node.js 18+
  • Configures modern module resolution with NodeNext
  • Properly excludes test files from compilation

These settings provide a solid foundation for TypeScript development with egg v4.

hello-tegg/test/biz/HelloService.test.ts (1)

1-3: Updated imports align with egg v4 migration

The import changes properly reflect the migration to egg v4, switching from 'egg-mock/bootstrap' to '@eggjs/mock/bootstrap' and using Node.js built-in modules with the 'node:' prefix.

helloworld/test/index.test.ts (2)

1-2: Import from correct egg v4 package

The import correctly uses '@eggjs/mock/bootstrap' which is consistent with the egg v4 migration.


3-9: Well-structured test for root endpoint

This test properly verifies that the application root endpoint returns a 200 status code with the expected "Hello World" response.

.github/workflows/ci.yml (1)

12-15: Updated CI configuration for Node.js requirements

The workflow changes correctly:

  1. Update the repository source to 'node-modules/github-actions'
  2. Update Node.js versions to '18, 20, 22', aligning with the PR objective to drop support for Node.js versions earlier than 18.19.0

This ensures that the CI pipeline will test against the supported Node.js versions only.

hello-tegg/config/config.default.ts (2)

1-2: Simplified import statement

The import statement has been simplified to only include what's needed after the egg v4 migration.


5-5:

Details

❓ Verification inconclusive

Updated type assertion for configuration

The type assertion has been changed from PowerPartial<EggAppConfig> to EggAppConfig, suggesting a change in how configurations are handled in egg v4.

Verify that this change maintains type safety for optional configuration properties.


🏁 Script executed:

#!/bin/bash
# Check for the definition of EggAppConfig in the egg package
rg --type-add 'ts:*.{ts,d.ts}' --type ts -A 10 "export (type|interface) EggAppConfig" ./node_modules/egg

Length of output: 165


Action Required: Verify EggAppConfig Optional Properties

The initial verification script targeted the ./node_modules/egg directory but returned an error (directory not found). This prevents us from automatically confirming that the updated type assertion—from PowerPartial<EggAppConfig> to EggAppConfig—preserves the optional properties’ type safety.

To investigate further, please run the following shell script to search for the definition of EggAppConfig within the repository (or its custom type declarations):

#!/bin/bash
# Search for the definition of interface EggAppConfig in the repository (including .d.ts and .ts files)
rg --type-add 'ts:*.{ts,d.ts}' --type ts -A 20 "interface EggAppConfig" .

Once you locate the definition, manually verify that any configuration properties intended to be optional are marked as optional (using “?” in the type declaration) so that replacing PowerPartial<EggAppConfig> with EggAppConfig does not enforce unexpected required fields.

Please confirm that this change maintains type safety for optional configuration properties.

hello-tegg/tsconfig.json (2)

4-10: Enhanced TypeScript configuration options.
The updated compiler options (setting "baseUrl": ".", "strict": true, "noImplicitAny": true, "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", and "declaration": false) enforce stricter type checking and modern ECMAScript module resolution. These settings improve both code quality and future maintainability.


12-14: Exclude the test directory from compilation.
Adding the "exclude": ["test"] directive ensures that test files are not compiled by TypeScript, which can speed up the build process and avoid potential type conflicts.

package.json (3)

13-13: Bump dependency version for npminstall.
Upgrading "npminstall" from a caret version to a fixed version "7" ensures consistency in dependency resolution. Please verify that version 7 is compatible with your overall dependency tree.


19-21: Streamline test and CI scripts.
Changing the test script to run ./bin/test.sh and simplifying the CI command to "npm test" helps standardize the testing workflow. Make sure that the test.sh script in the bin/ directory is complete and correctly orchestrates the tests.


33-33: Update Node.js engine requirement.
The engine requirement is now "node": ">= 18.19.0", which reflects the breaking change and aligns with Egg v4’s minimum requirement. Ensure that this change is clearly communicated in documentation to users upgrading the project.

hello-tegg/test/controller/HelloController.test.ts (1)

1-2: Modernize import statements.
The import of the strict assertion module from node:assert and the update of the app mock source to @eggjs/mock/bootstrap are in line with the project's upgrade. These changes promote consistency and utilize namespaced Node.js modules for better clarity.

hello-tegg/package.json (3)

6-7: Adopt eggctl for process management.
Replacing the old start/stop commands with "eggctl start --daemon" and "eggctl stop" modernizes process management and is expected for Egg v4. Confirm that the eggctl CLI tool is available in all deployment environments.


10-15: Refine test and CI related scripts.
The new scripts (pretest, test, preci, ci, and postci) add improved cleaning and linting steps around testing and CI operations. This creates a more robust workflow. Please verify that these commands execute as intended in both local and CI contexts.


17-18: Enhance build cleanup routines.
The addition of "clean": "tsc -b --clean" and "prepublishOnly": "npm run clean && tsc" ensures that TypeScript build artifacts are managed consistently.

helloworld/package.json (4)

4-6: Upgrade core dependencies for modern Egg support.
By adding "@eggjs/scripts": "^4.0.0" and updating "egg" to "beta", the project now aligns with Egg v4. Verify that the beta release offers the necessary stability and performance improvements.


8-16: Standardize devDependencies across the project.
The updates to devDependencies (including "@eggjs/bin": "7", "@eggjs/mock": "6", "@eggjs/tsconfig": "1", "@types/mocha": "10", "@types/node": "22", "eslint": "8", "eslint-config-egg": "14", and "typescript": "5") reflect a coherent move towards pinned, modern versions. This ensures consistent development and CI environments.


17-30: Revise npm scripts for refined development and CI workflows.
The new scripts—such as "start", "stop", "lint", "predev", "pretest", "preci", "ci", "postci", "clean", and "prepublishOnly"—are well structured. They leverage tools like eggctl and egg-bin, which are expected in the Egg v4 ecosystem. Double-check that these commands integrate smoothly with your build and deployment pipelines.


31-33: Add repository metadata.
The inclusion of a "repository" field helps with project metadata and discoverability. This is a useful addition that improves overall project transparency.

Comment on lines +9 to +10
npm run ci
cd ..
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for npm commands.

The script currently doesn't preserve exit codes from the npm commands. If npm run ci fails, the script will still continue to the next test. This could hide test failures.

- npm run ci
- cd ..
+ if ! npm run ci; then
+   echo "Tests failed in $1"
+   cd ..
+   return 1
+ fi
+ cd ..
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
npm run ci
cd ..
if ! npm run ci; then
echo "Tests failed in $1"
cd ..
return 1
fi
cd ..

Comment on lines 7 to 8
let ctx: any;
// let ctx: EggContext;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid using any type

Using any for the ctx variable bypasses TypeScript's type checking benefits, which can lead to runtime errors. The commented alternative suggests EggContext might be a better option.

Consider uncommenting and using the proper type:

-  let ctx: any;
-  // let ctx: EggContext;
+  // Import EggContext at the top
+  let ctx: EggContext;

If EggContext is not available in egg v4, check the documentation for the appropriate type to use instead of any.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let ctx: any;
// let ctx: EggContext;
// Import EggContext at the top
let ctx: EggContext;

fengmk2 and others added 3 commits March 12, 2025 22:57
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

♻️ Duplicate comments (1)
bin/test.sh (1)

9-9: 🛠️ Refactor suggestion

⚠️ Potential issue

Enhance Error Handling for npm run ci

The command npm run ci is not currently checked for failure, which means that if it fails, the script will still proceed to cd .. and potentially mask test failures. Consider wrapping it with a conditional check as follows:

-  npm run ci
+  if ! npm run ci; then
+    echo "Tests failed in $1"
+    cd ..
+    return 1
+  fi

This change ensures that if npm run ci fails, the function will return a non-zero exit code immediately.

🧹 Nitpick comments (1)
bin/test.sh (1)

3-11: Suggestion: Avoid Using “test” as a Function Name

The function is named test, which conflicts with the built-in POSIX command test and may lead to unexpected behavior in more complex scripts. Consider renaming it to something more descriptive, such as run_tests or execute_test, to avoid potential ambiguities.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be4466b and 75dd0ef.

📒 Files selected for processing (1)
  • bin/test.sh (1 hunks)
🔇 Additional comments (2)
bin/test.sh (2)

5-5: Good Error Handling for Directory Change

The use of cd "$1" || { echo "Error: Directory $1 not found"; return 1; } properly handles the case when the directory change fails. This ensures that the script does not continue in an unexpected directory.


13-14: Solid Exit Handling for Test Calls

The function calls at the end (test helloworld || exit 1 and test hello-tegg || exit 1) correctly propagate errors by exiting if any test fails. This helps maintain the integrity of the testing process.

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

♻️ Duplicate comments (2)
bin/test.sh (2)

7-7: 🛠️ Refactor suggestion

Enhance Directory Change Error Handling
Although set -e causes the script to terminate on errors, it is helpful to provide an explicit error message if changing into the directory fails. Consider revising the command as follows:

-  cd "$1"
+  cd "$1" || { echo "Error: Directory '$1' not found"; exit 1; }

11-11: 🛠️ Refactor suggestion

Improve Error Reporting for npm Command
While set -e will exit on a failure in npm run ci, adding an explicit check with an informative error message can make debugging easier. For example:

-  npm run ci
+  npm run ci || { echo "Error: 'npm run ci' failed in $1"; exit 1; }
🧹 Nitpick comments (1)
bin/test.sh (1)

15-17: Validate Test Invocation Order and Informative Logging
The script calls the test function sequentially for multiple directories. With set -e, any failure will abort the script, which is good. However, consider enhancing the logging—for example, by including which test directory is starting—to aid in troubleshooting if a failure occurs.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75dd0ef and 97125cb.

📒 Files selected for processing (6)
  • bin/test.sh (1 hunks)
  • body-parser-example/app/controller/home.js (1 hunks)
  • body-parser-example/config/config.default.js (0 hunks)
  • body-parser-example/package.json (1 hunks)
  • body-parser-example/test/home.test.js (1 hunks)
  • package.json (2 hunks)
💤 Files with no reviewable changes (1)
  • body-parser-example/config/config.default.js
✅ Files skipped from review due to trivial changes (1)
  • body-parser-example/app/controller/home.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 22)
🔇 Additional comments (7)
body-parser-example/test/home.test.js (2)

1-1: Import package updated to match Egg v4 requirements.

The import statement has been updated from egg-mock/bootstrap to @eggjs/mock/bootstrap, which is necessary for compatibility with Egg v4. This change is part of the framework upgrade and follows the pattern of using scoped npm packages.


3-3: Test description updated to match actual file path.

The test description has been updated from 'test/app/controller/home.test.js' to 'test/home.test.js' to accurately reflect the actual file path. This improves code readability and maintainability without affecting functionality.

body-parser-example/package.json (5)

2-2: Project Name Updated
The project name has been updated to "body-parser-example". Please ensure that this naming change is reflected consistently in the repository documentation and any related scripts.


5-5: Upgraded Egg Dependency to v4
The Egg framework dependency is now set to version "4". Make sure that the breaking changes (including the minimum required Node.js version) are clearly documented in the upgrade guide or release notes.


9-9: Updated Dev Dependency: @eggjs/bin
The legacy "egg-bin" has been replaced with "@eggjs/bin" at version "7". Verify that any CLI scripts or tooling that rely on this package work as expected with the new version.


10-10: Updated Dev Dependency: @eggjs/mock
The mock dependency has been updated from "egg-mock" to "@eggjs/mock" at version "6". Ensure that all tests utilizing this package are updated accordingly.


15-15: Renamed Test Script Key
The test script key is now "ci" (renaming "cov"), even though the command remains "egg-bin cov". Please confirm that this naming aligns with your CI conventions and update documentation if necessary.

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

Caution

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

⚠️ Outside diff range comments (1)
bin/test.js (1)

11-16: Remove unused constructor options.

The -c flag options are defined but never used since the run() method no longer accepts argv and the flag logic on line 41 was removed.

Apply this diff to remove the unused options:

   constructor(rawArgs) {
     super(rawArgs);
-
-    this.options = {
-      c: {
-        type: 'boolean',
-        description: 'in China',
-      },
-    };
   }
🧹 Nitpick comments (1)
README.md (1)

22-22: Use proper Markdown heading instead of emphasis.

Bold text is being used where a proper heading would be more semantic and accessible.

Apply this diff:

-**Recommend to use Node >= 20**
+## Recommended Node.js Version
+
+Node.js >= 20
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97125cb and 5a8f80d.

📒 Files selected for processing (5)
  • .github/workflows/ci.yml (1 hunks)
  • README.md (2 hunks)
  • bin/test.js (2 hunks)
  • bin/test.sh (1 hunks)
  • package.json (2 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
README.md

22-22: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

⏰ 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). (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (6)
bin/test.js (1)

41-41: LGTM! Simplified to use new test tooling.

The change from conditional npmupdate to unconditional ut update aligns with the new utoo-based test infrastructure introduced in this PR.

.github/workflows/ci.yml (1)

12-16: LGTM! CI updated for Egg v4 requirements.

The workflow correctly:

  • Updates Node.js versions to 20, 22, 24 (aligning with >= 20 requirement)
  • Adds utoo tooling installation
  • References the updated workflow path
bin/test.sh (2)

3-3: Strict error handling is in place.

The set -e option ensures the script exits immediately if any command fails, which addresses the error handling concerns raised in past review comments. However, explicit error messages (as suggested in past comments) would provide clearer feedback when failures occur.

The current approach relies on shell-level error handling. Consider whether more explicit error messages would improve the developer experience when tests fail.


9-9: Verify the intent behind removing node_modules.

The script removes node_modules and package-lock.json before each test. This ensures a clean install but increases CI time significantly.

Is the clean install necessary for every test run, or could this be optimized for faster CI execution?

package.json (2)

21-21: Verify that lint is intentionally skipped in CI.

The ci script previously ran npm run lint && npm test but now only runs npm test. The lint step is still defined (line 18) but always passes with echo 'ignore'.

Confirm this is intentional. If linting should still be part of CI, restore it:

-  "ci": "npm test",
+  "ci": "npm run lint && npm test",

33-33: LGTM! Node version requirement aligned with Egg v4.

The Node >= 20 requirement is consistent with the PR objectives and aligns with the CI configuration.

fengmk2 and others added 5 commits October 17, 2025 22:36
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 7

♻️ Duplicate comments (3)
bin/test.sh (3)

7-7: Add explicit error handling for cd command.

The cd command should explicitly return/exit on failure to prevent subsequent commands from running in the wrong directory, even with set -e.

Apply this diff:

- cd "$1"
+ cd "$1" || return 1

11-12: Ensure npm run ci failure propagates and stops cd .. execution.

If npm run ci fails, the cd .. command still executes, masking the failure. Use explicit error handling to stop execution and prevent directory state from being obscured.

Apply this diff to make the error explicit:

- npm run ci
- cd ..
+ if ! npm run ci; then
+   echo "Tests failed in $1"
+   cd ..
+   return 1
+ fi
+ cd ..

Alternatively, with set -e, you can simplify by ensuring cd .. is not treated as part of a command group that suppresses errors. Consider restructuring to keep cd .. in a trap or ensure it's called from a parent context.


15-17: Add error handling for test function calls.

The script calls test() three times without checking exit status. If the first or second test fails, the script continues and exits with success.

Apply this diff:

- test body-parser-example
- test helloworld
- test hello-tegg
+ test body-parser-example || exit 1
+ test helloworld || exit 1
+ test hello-tegg || exit 1
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48a1c95 and 3338771.

📒 Files selected for processing (14)
  • .github/workflows/ci.yml (1 hunks)
  • README.md (2 hunks)
  • bin/test.sh (1 hunks)
  • body-parser-example/package.json (1 hunks)
  • hello-tegg/app/controller/HelloController.ts (1 hunks)
  • hello-tegg/app/middleware/trace_method.ts (1 hunks)
  • hello-tegg/config/config.default.ts (1 hunks)
  • hello-tegg/config/plugin.ts (1 hunks)
  • hello-tegg/package.json (1 hunks)
  • hello-tegg/test/biz/HelloService.test.ts (1 hunks)
  • hello-tegg/test/controller/HelloController.test.ts (1 hunks)
  • helloworld/config/config.default.ts (1 hunks)
  • helloworld/package.json (1 hunks)
  • package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • hello-tegg/app/controller/HelloController.ts
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
README.md

22-22: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🔇 Additional comments (9)
.github/workflows/ci.yml (2)

10-22: LGTM!

The matrix-based CI workflow is well-structured. It correctly tests across supported Node versions (20, 22, 24) and multiple OSes, aligns with the egg v4 upgrade and Node >= 18.19.0 requirement, and includes proper concurrency control to prevent redundant runs.


24-37: Explicit workflow steps are clear and correct.

Checkout, Node setup, dependency installation, and test steps are properly configured. The use of npminstall for faster installs in CI is appropriate.

helloworld/config/config.default.ts (1)

1-5: Remove hardcoded secret and use environment variables with development fallback.

The TypeScript configuration and defineConfig approach aligns well with Egg v4. However, the hardcoded keys value presents a security risk: Egg uses keys for signing cookies, and production deployments must never hardcode secrets.

For this example, use an environment variable with a fallback for local development:

 import { defineConfig } from 'egg';
 
 export default defineConfig({
-  keys: 'my secret keys',
+  keys: process.env.EGG_KEYS || 'my secret keys', // dev only
 });

In production, secrets should be stored in environment variables rather than hardcoded in files, making the app configurable.

hello-tegg/app/middleware/trace_method.ts (1)

1-1: LGTM! Type-only import is appropriate.

The change to import type is correct since EggContext and Next are only used for type annotations, not at runtime. This improves tree-shaking and makes the intent explicit.

hello-tegg/config/plugin.ts (1)

1-1: LGTM! Type-only import is appropriate.

Since EggPlugin is only used for type annotation, converting to import type is correct and follows TypeScript best practices.

hello-tegg/test/biz/HelloService.test.ts (1)

1-16: LGTM! Test modernization aligns with Egg v4 patterns.

The updates to use @eggjs/mock/bootstrap, node:assert/strict, and a single before hook follow the new testing conventions. The explicit .ts extension in the import is consistent with ES module resolution in TypeScript.

hello-tegg/test/controller/HelloController.test.ts (1)

1-16: LGTM! Test refactoring improves clarity.

The migration to @eggjs/mock/bootstrap and node:assert/strict is consistent with Egg v4 patterns. Separating the HTTP request from the assertion makes the test more readable.

hello-tegg/config/config.default.ts (1)

1-8: LGTM! Correctly adopts Egg v4 config factory pattern.

The migration from a static config object to defineConfigFactory aligns with Egg v4's factory-based configuration approach, which provides better type inference and access to appInfo.

body-parser-example/package.json (1)

15-15: Based on my web search verification, @eggjs/bin is the current package name (version 7.3.1) that replaced the older egg-bin. Importantly, the @eggjs/bin repository's own documentation shows scripts using "egg-bin cov", indicating that npm packages supply a bin field in package.json which maps command names to local files, and these are symlinked into node_modules/.bin.

The review comment's concern appears to be unfounded. The evidence indicates that @eggjs/bin maintains backward compatibility by exporting the "egg-bin" binary name, as demonstrated by the official eggjs/bin GitHub repository still using "egg-bin cov" in its documentation. The npm script "egg-bin cov" should resolve correctly after npm install when @eggjs/bin is installed.

Verify the bin command resolves correctly after package rename.

No action required. The package dependency is now "@eggjs/bin" instead of "egg-bin", and the @eggjs/bin repository's documentation confirms the binary command remains "egg-bin", maintaining backward compatibility. The npm script using "egg-bin cov" will resolve correctly.

Comment on lines 1 to 18
{
"name": "bodyParser",
"name": "body-parser-example",
"version": "1.0.0",
"dependencies": {
"egg": "^2",
"egg": "beta",
"xml-js": "^1.6.9"
},
"devDependencies": {
"egg-bin": "^4.3.5",
"egg-mock": "^3.13.1"
"@eggjs/bin": "beta",
"@eggjs/mock": "beta"
},
"scripts": {
"dev": "egg-bin dev",
"test": "egg-bin test",
"cov": "egg-bin cov"
"ci": "egg-bin cov"
},
"private": true
}
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 | 🟡 Minor

Add Node.js engine constraint to enforce minimum version.

Per the PR objectives, egg v4 requires Node.js >= 18.19.0. Add an "engines" field to package.json to enforce this constraint for developers and CI environments.

Apply this diff to add the engines field:

  "scripts": {
    "dev": "egg-bin dev",
    "test": "egg-bin test",
    "ci": "egg-bin cov"
  },
+ "engines": {
+   "node": ">=18.19.0"
+ },
  "private": true

Based on learnings about egg v4 migration requirements.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"name": "bodyParser",
"name": "body-parser-example",
"version": "1.0.0",
"dependencies": {
"egg": "^2",
"egg": "beta",
"xml-js": "^1.6.9"
},
"devDependencies": {
"egg-bin": "^4.3.5",
"egg-mock": "^3.13.1"
"@eggjs/bin": "beta",
"@eggjs/mock": "beta"
},
"scripts": {
"dev": "egg-bin dev",
"test": "egg-bin test",
"cov": "egg-bin cov"
"ci": "egg-bin cov"
},
"private": true
}
{
"name": "body-parser-example",
"version": "1.0.0",
"dependencies": {
"egg": "beta",
"xml-js": "^1.6.9"
},
"devDependencies": {
"@eggjs/bin": "beta",
"@eggjs/mock": "beta"
},
"scripts": {
"dev": "egg-bin dev",
"test": "egg-bin test",
"ci": "egg-bin cov"
},
"engines": {
"node": ">=18.19.0"
},
"private": true
}
🤖 Prompt for AI Agents
In body-parser-example/package.json around lines 1 to 18, add an "engines" field
to enforce Node.js >=18.19.0 required by egg v4; update the top-level JSON to
include "engines": { "node": ">=18.19.0" } so CI and developers are constrained
to the minimum Node version (ensure valid JSON comma placement after the
"version" or before "dependencies").

"version": "1.0.0",
"dependencies": {
"egg": "^2",
"egg": "beta",
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

🧩 Analysis chain

Avoid loose "beta" version tags; pin to specific beta releases.

Using "beta" as a version spec is too permissive and may introduce non-deterministic installs. Different CI runs or developer machines could resolve to different beta patch versions, breaking reproducibility. Since this is an example repo migrating to egg v4 (beta), pin to specific versions or use a narrower semver range.

Apply this diff to pin specific beta versions:

  "dependencies": {
-   "egg": "beta",
+   "egg": "^4.0.0-beta",
    "xml-js": "^1.6.9"
  },
  "devDependencies": {
-   "@eggjs/bin": "beta",
-   "@eggjs/mock": "beta"
+   "@eggjs/bin": "^4.0.0-beta",
+   "@eggjs/mock": "^4.0.0-beta"
  },

Alternatively, inspect the eggjs org releases to find the latest stable beta tag (e.g., 4.0.0-beta.5) and pin those specific versions.

Also applies to: 9-10


I'll verify the review comment by examining the package.json file and checking the available beta versions from the eggjs organization.

import json

# Try to parse package.json if accessible
try:
    with open("body-parser-example/package.json", "r") as f:
        data = json.load(f)
        print("Dependencies:")
        if "dependencies" in data:
            for dep, version in data.get("dependencies", {}).items():
                if "egg" in dep.lower():
                    print(f"  {dep}: {version}")
        print("\nDevDependencies:")
        if "devDependencies" in data:
            for dep, version in data.get("devDependencies", {}).items():
                if "egg" in dep.lower() or "eggjs" in dep.lower():
                    print(f"  {dep}: {version}")
except Exception as e:
    print(f"Error: {e}")



🏁 Script executed:

#!/bin/bash
# Inspect the package.json file to verify current state
if [ -f "body-parser-example/package.json" ]; then
  cat body-parser-example/package.json
else
  echo "File not found"
fi

Length of output: 321


🏁 Script executed:

#!/bin/bash
# Search for egg, @eggjs/bin, and @eggjs/mock version references
rg -n '"egg"|"@eggjs/bin"|"@eggjs/mock"' body-parser-example/package.json -A 0 -B 0

Length of output: 77


🏁 Script executed:

#!/bin/bash
# Check if there are any other package.json files that might reference these packages
fd 'package.json' --exec grep -l "egg\|@eggjs" {} \;

Length of output: 1277


🌐 Web query:

egg v4 beta versions npm registry eggjs

💡 Result:

You can find Egg v4 beta releases on the npm registry and install them either by the beta version tag or the next dist-tag.

Quick options:

  • Install the latest beta via dist-tag: npm i egg@next. [1][2]
  • Install a specific beta (example): npm i egg@4.1.0-beta.13. [3][2]

References:

  1. egg package (npm) — versions and dist-tags. [https://www.npmjs.com/package/egg]. [1]
  2. egg v4 release notes / dist-tag mentions (v4.0.x / @next). [newreleases / eggjs/egg]. [2]
  3. Example prerelease listing showing v4.1.0-beta.* and published beta packages. [3]

🌐 Web query:

@eggjs/bin @eggjs/mock latest beta versions

💡 Result:

  • @eggjs/bin — latest beta: 7.3.1-beta.6. [1][2]
  • @eggjs/mock — latest beta: 6.1.0-beta.8. [1][3]

Sources:
[1] Release listing for egg v4.1.0 prereleases (shows published prerelease package versions).
[2] @eggjs/bin npm page (stable/latest info).
[3] @eggjs/mock package/version listing.


Pin specific beta versions instead of loose "beta" dist-tag for reproducibility.

Using "beta" as a version specifier is a floating dist-tag that will resolve to different versions as new beta releases are published. This breaks reproducibility—installations at different times will pull different beta patch versions, complicating debugging and testing. Since the eggjs org has published specific beta versions (e.g., egg 4.1.0-beta.13, @eggjs/bin 7.3.1-beta.6, @eggjs/mock 6.1.0-beta.8), pin to a specific beta release instead.

Apply this diff:

  "dependencies": {
-   "egg": "beta",
+   "egg": "^4.0.0-beta",
    "xml-js": "^1.6.9"
  },
  "devDependencies": {
-   "@eggjs/bin": "beta",
-   "@eggjs/mock": "beta"
+   "@eggjs/bin": "^4.0.0-beta",
+   "@eggjs/mock": "^4.0.0-beta"
  },

Alternatively, pin exact versions (e.g., "egg": "4.0.0-beta.13") if you need strict reproducibility across all installs.

Also applies to: lines 9–10

🤖 Prompt for AI Agents
In body-parser-example/package.json around line 5 (and also update lines 9–10),
the dependency version "beta" is a floating dist-tag causing non-reproducible
installs; replace the loose "beta" specifier with a concrete beta release (for
example "4.1.0-beta.13" for egg or the exact beta versions published by the
eggjs org) so installs resolve to a fixed package version—update the other beta
entries on lines 9–10 to their corresponding specific beta versions as well to
ensure reproducibility.

Comment on lines +25 to +30
"@eggjs/scripts": "beta",
"@eggjs/tegg": "beta",
"@eggjs/tegg-config": "beta",
"@eggjs/tegg-controller-plugin": "beta",
"@eggjs/tegg-plugin": "beta",
"egg": "beta"
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

🧩 Analysis chain

Pin specific beta versions to avoid breaking changes.

Using the "beta" tag for dependencies means the package will resolve to the latest beta version at install time, which can introduce breaking changes unexpectedly between installs. This can lead to inconsistent behavior across different environments and makes builds non-reproducible.

Consider pinning to specific beta versions. Run this script to check the current beta versions available:

Also applies to: 35-37


🏁 Script executed:

#!/bin/bash
# Description: Check latest beta versions for @eggjs packages

echo "Checking beta versions for @eggjs packages..."
for pkg in "@eggjs/scripts" "@eggjs/tegg" "@eggjs/tegg-config" "@eggjs/tegg-controller-plugin" "@eggjs/tegg-plugin" "egg" "@eggjs/tsconfig" "@eggjs/bin" "@eggjs/mock"; do
  echo "=== $pkg ==="
  npm view "$pkg" dist-tags.beta versions --json | jq -r 'if type == "array" then .[-5:] else . end'
done

Length of output: 16364


Pin specific beta versions to avoid non-reproducible builds.

Using "beta" as a version specifier resolves to the latest beta version at install time. This creates the reproducibility issues you've identified. The npm registry data confirms multiple beta versions are available for each package—installing at different times would pull different versions without a lock file.

Recommended pinned versions based on current latest betas:

  • "@eggjs/scripts": "5.0.0-beta.28"
  • "@eggjs/tegg": "4.0.0-beta.11"
  • "@eggjs/tegg-config": "4.0.0-beta.11"
  • "@eggjs/tegg-controller-plugin": "4.0.0-beta.11"
  • "@eggjs/tegg-plugin": "4.0.0-beta.11"
  • "egg": "4.1.0-beta.28"

Apply the same approach to the dependencies at lines 35-37.

🤖 Prompt for AI Agents
In hello-tegg/package.json around lines 25 to 30 (and apply same change to the
related dependencies at lines 35-37), the packages use the loose "beta" tag
which yields non-reproducible installs; replace each "beta" specifier with the
pinned beta versions provided by the reviewer: set "@eggjs/scripts" to
"5.0.0-beta.28", "@eggjs/tegg" to "4.0.0-beta.11", "@eggjs/tegg-config" to
"4.0.0-beta.11", "@eggjs/tegg-controller-plugin" to "4.0.0-beta.11",
"@eggjs/tegg-plugin" to "4.0.0-beta.11", and "egg" to "4.1.0-beta.28", and make
the same pinning for the matching entries at lines 35-37 to ensure reproducible
builds.

Comment on lines +43 to +45
"engines": {
"node": ">=20.0.0"
}
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 | 🟡 Minor

Node.js version requirement mismatch with PR description.

The PR description states "drop Node.js < 18.19.0 support," but this package requires >=20.0.0. This inconsistency may cause confusion. Additionally, the helloworld package doesn't specify an engines field at all.

Please clarify:

  • Is the minimum Node.js version 18.19.0 or 20.0.0?
  • Should all example packages have consistent engine requirements?
🤖 Prompt for AI Agents
In hello-tegg/package.json around lines 43-45 the "engines" field requires
"node": ">=20.0.0" which conflicts with the PR description that drops Node.js
<18.19.0; decide the project-wide minimum (either 18.19.0 or 20.0.0), update
this package.json to use "node": ">=<chosen_version>", add the same "engines"
entry to the helloworld package.json to keep examples consistent, and update the
PR description to state the chosen minimum Node.js version so they match.

Comment on lines 1 to 34
{
"name": "helloworld",
"private": true,
"type": "module",
"dependencies": {
"egg": "^1.10.1"
"@eggjs/scripts": "beta",
"egg": "beta"
},
"devDependencies": {
"egg-bin": "^4.3.5",
"egg-mock": "^3.13.1"
"@eggjs/bin": "beta",
"@eggjs/mock": "beta",
"@eggjs/tsconfig": "beta",
"@types/mocha": "10",
"@types/node": "22",
"eslint": "8",
"eslint-config-egg": "14",
"typescript": "5"
},
"scripts": {
"start": "eggctl start --daemon",
"stop": "eggctl stop",
"lint": "eslint . --ext .ts",
"predev": "npm run clean && npm run lint -- --fix",
"dev": "egg-bin dev",
"pretest": "npm run clean && npm run lint -- --fix",
"test": "egg-bin test",
"cov": "egg-bin cov"
"preci": "npm run clean && npm run lint",
"ci": "egg-bin cov",
"postci": "npm run prepublishOnly && npm run clean",
"clean": "tsc -b --clean",
"prepublishOnly": "npm run clean && tsc"
},
"private": true
"repository": "git@github.com:eggjs/examples.git"
}
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 | 🟠 Major

Missing Node.js engine requirement.

Unlike hello-tegg/package.json, this package doesn't specify an engines field. Given that the PR drops support for Node.js < 18.19.0, all example packages should explicitly declare their minimum Node.js version to prevent users from running them on unsupported versions.

Add an engines field to enforce the minimum Node.js version:

   "repository": "git@github.com:eggjs/examples.git"
+  "engines": {
+    "node": ">=18.19.0"
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"name": "helloworld",
"private": true,
"type": "module",
"dependencies": {
"egg": "^1.10.1"
"@eggjs/scripts": "beta",
"egg": "beta"
},
"devDependencies": {
"egg-bin": "^4.3.5",
"egg-mock": "^3.13.1"
"@eggjs/bin": "beta",
"@eggjs/mock": "beta",
"@eggjs/tsconfig": "beta",
"@types/mocha": "10",
"@types/node": "22",
"eslint": "8",
"eslint-config-egg": "14",
"typescript": "5"
},
"scripts": {
"start": "eggctl start --daemon",
"stop": "eggctl stop",
"lint": "eslint . --ext .ts",
"predev": "npm run clean && npm run lint -- --fix",
"dev": "egg-bin dev",
"pretest": "npm run clean && npm run lint -- --fix",
"test": "egg-bin test",
"cov": "egg-bin cov"
"preci": "npm run clean && npm run lint",
"ci": "egg-bin cov",
"postci": "npm run prepublishOnly && npm run clean",
"clean": "tsc -b --clean",
"prepublishOnly": "npm run clean && tsc"
},
"private": true
"repository": "git@github.com:eggjs/examples.git"
}
{
"name": "helloworld",
"private": true,
"type": "module",
"dependencies": {
"@eggjs/scripts": "beta",
"egg": "beta"
},
"devDependencies": {
"@eggjs/bin": "beta",
"@eggjs/mock": "beta",
"@eggjs/tsconfig": "beta",
"@types/mocha": "10",
"@types/node": "22",
"eslint": "8",
"eslint-config-egg": "14",
"typescript": "5"
},
"scripts": {
"start": "eggctl start --daemon",
"stop": "eggctl stop",
"lint": "eslint . --ext .ts",
"predev": "npm run clean && npm run lint -- --fix",
"dev": "egg-bin dev",
"pretest": "npm run clean && npm run lint -- --fix",
"test": "egg-bin test",
"preci": "npm run clean && npm run lint",
"ci": "egg-bin cov",
"postci": "npm run prepublishOnly && npm run clean",
"clean": "tsc -b --clean",
"prepublishOnly": "npm run clean && tsc"
},
"repository": "git@github.com:eggjs/examples.git",
"engines": {
"node": ">=18.19.0"
}
}
🤖 Prompt for AI Agents
In helloworld/package.json around lines 1 to 34, the package is missing an
"engines" field to enforce the minimum Node.js version; add an "engines" object
with "node": ">=18.19.0" (matching the repo minimum) so users are prevented from
running the example on unsupported Node versions, and commit the updated
package.json.

Comment on lines +6 to +7
"@eggjs/scripts": "beta",
"egg": "beta"
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 | 🟠 Major

Pin specific beta versions to avoid breaking changes.

Using the "beta" tag without version pinning can lead to non-reproducible builds and unexpected breaking changes. This is particularly risky during active beta development.

Consider pinning to specific beta versions as suggested for hello-tegg/package.json.

Also applies to: 10-12

🤖 Prompt for AI Agents
In helloworld/package.json around lines 6 to 7 (and also check lines 10-12), the
dependencies use the unpinned "beta" tag which risks non-reproducible builds and
breaking changes; update the "egg" and "@eggjs/scripts" entries to specific beta
release versions (e.g., "beta.X.Y" or the exact semver found in
hello-tegg/package.json) instead of the bare "beta", commit the updated
package.json, and run npm install/npm ci to update lockfile so CI and local
builds use the pinned beta versions.

```

**Recommend to use Node >= 8**
**Recommend to use Node >= 20**
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 | 🟡 Minor

Convert emphasis to proper heading to resolve markdown lint warning.

The line uses bold emphasis instead of a proper heading structure, which triggers MD036 from markdownlint-cli2.

Apply this diff:

-**Recommend to use Node >= 20**
+## Recommend to use Node >= 20
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
**Recommend to use Node >= 20**
## Recommend to use Node >= 20
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

22-22: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🤖 Prompt for AI Agents
In README.md around line 22, the line currently uses bold emphasis ("**Recommend
to use Node >= 20**") which triggers markdownlint MD036; replace the bold text
with a proper markdown heading (e.g., prepend one or two # characters like "#
Recommend to use Node >= 20" or "## Recommend to use Node >= 20" to match
surrounding heading levels), remove the surrounding ** markers, and ensure a
single blank line before and after the new heading for proper formatting.

@fengmk2 fengmk2 merged commit 3ae61c2 into master Oct 17, 2025
9 checks passed
@fengmk2 fengmk2 deleted the egg-v4 branch October 17, 2025 15:08
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.

2 participants