Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auto import tsconfig-paths/register.js #282

Merged
merged 3 commits into from
Jan 3, 2025

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Jan 3, 2025

Summary by CodeRabbit

  • New Features

    • Added a new /foo route in the application.
    • Introduced a Foo class with a bar method.
    • Enhanced TypeScript path resolution configuration.
  • Tests

    • Updated test cases to cover new functionality, including the /foo endpoint.
    • Improved test suite with additional assertions and updated expected outputs.
    • Updated mock dependency to version 6.
  • Chores

    • Updated TypeScript compiler settings to target ES2022 and refined module resolution strategies.

Copy link

vercel bot commented Jan 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
egg-bin ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 3, 2025 2:01am

Copy link

coderabbitai bot commented Jan 3, 2025

Warning

Rate limit exceeded

@fengmk2 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1621cd7 and d34a4a2.

📒 Files selected for processing (1)
  • src/baseCommand.ts (3 hunks)

Walkthrough

This pull request introduces enhancements to a TypeScript-based project, focusing on improving module resolution, test coverage, and routing functionality. The changes include updates to the base command handling, the addition of new modules and routes, and modifications to test configurations. The primary goal appears to be improving TypeScript path resolution and expanding the test suite's capabilities for a more robust application structure.

Changes

File Change Summary
src/baseCommand.ts Updated #afterInit() method to correctly import and use tsconfig-paths/register.js
test/commands/test.test.ts Uncommented debug statements, updated test expectations, added new test case for --no-timeout option
test/fixtures/example-ts/app/controller/home.ts Added new foo() method importing Foo class
test/fixtures/example-ts/app/module/foo.ts Created new Foo class with bar() method
test/fixtures/example-ts/app/module/package.json Added module configuration
test/fixtures/example-ts/app/router.ts Added new route for /foo endpoint
test/fixtures/example-ts/package.json Updated @eggjs/mock dependency version
test/fixtures/example-ts/test/index.test.ts Added new test cases for /foo endpoint and module import
test/fixtures/example-ts/tsconfig.json Added comprehensive TypeScript compiler options and path mapping
test/commands/cov.test.ts Updated expected output for "should success on ts" test case

Sequence Diagram

sequenceDiagram
    participant Client
    participant Router
    participant HomeController
    participant FooModule

    Client->>Router: GET /foo
    Router->>HomeController: invoke foo() method
    HomeController->>FooModule: create Foo instance
    FooModule-->>HomeController: return 'bar'
    HomeController-->>Client: respond with 'bar' (200 OK)
Loading

Poem

🐰 A Rabbit's Ode to Code Delight 🔧

Paths resolved with magical might,
TypeScript dancing, tests shining bright,
Foo and bar, a module's sweet song,
Endpoints singing where they belong!

Hop, hop, hooray! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Jan 3, 2025

Open in Stackblitz

npm i https://pkg.pr.new/eggjs/bin/@eggjs/bin@282

commit: d34a4a2

Copy link

@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 (1)
test/fixtures/example-ts/app/module/foo.ts (1)

1-5: Consider adding a brief docstring.
The class and method are straightforward and function as intended. A short docstring or inline comment providing context on how and where this class is used might be beneficial for future maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 120c285 and fe06e9f.

📒 Files selected for processing (9)
  • src/baseCommand.ts (1 hunks)
  • test/commands/test.test.ts (1 hunks)
  • test/fixtures/example-ts/app/controller/home.ts (1 hunks)
  • test/fixtures/example-ts/app/module/foo.ts (1 hunks)
  • test/fixtures/example-ts/app/module/package.json (1 hunks)
  • test/fixtures/example-ts/app/router.ts (1 hunks)
  • test/fixtures/example-ts/package.json (1 hunks)
  • test/fixtures/example-ts/test/index.test.ts (1 hunks)
  • test/fixtures/example-ts/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • test/fixtures/example-ts/package.json
  • test/fixtures/example-ts/app/module/package.json
🔇 Additional comments (11)
test/fixtures/example-ts/app/router.ts (1)

5-5: Route addition is valid.
The new /foo route is well-defined and references the appropriate controller method.

test/fixtures/example-ts/app/controller/home.ts (2)

2-2: Verify alias path resolution.
Confirm that @/module/foo correctly resolves under the current TypeScript configuration.


10-13: Method implementation is concise and clear.
The foo method effectively demonstrates usage of the Foo class within the controller.

test/fixtures/example-ts/test/index.test.ts (5)

1-1: Use of strict assert is commendable.
Using strict as assert from Node.js ensures better assertion error messages.


3-3: Alias import check.
Importing Foo from @/module/foo is straightforward. Just ensure @/ is mapped in tsconfig for correctness at runtime.


5-5: Clear and descriptive test suite name.
The test suite name helps identify the purpose of these tests easily.


14-20: Comprehensive route testing.
This covers the new /foo endpoint, verifying that the response is as expected. Good job.


22-25: Validates tsconfig-paths usage.
This ensures that the automatic import of tsconfig-paths/register works correctly, verifying that the alias paths are recognized at runtime.

test/commands/test.test.ts (1)

66-68: Confirm debug usage and updated test expectations.

Uncommenting .debug() can clutter logs in certain CI environments. Ensure you intend to output debug logs for these tests.
Additionally, verify that you have indeed added or enabled sufficient tests so that "3 passing" is accurate and consistent with your test suite.

src/baseCommand.ts (1)

232-235: Gracefully handle missing tsconfig-paths/Register.

Relying on importResolve('tsconfig-paths/register.js') could fail if the dependency or file is missing. Consider adding a fallback or error handling to avoid runtime failures.

test/fixtures/example-ts/tsconfig.json (1)

2-12: Confirm Node.js and TypeScript versions for NodeNext module resolution.

Using "module": "NodeNext" and "target": "ES2022" typically requires Node.js ≥ 18 and TS ≥ 4.7. Verify your environment meets these requirements to fully benefit from these settings.

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.78%. Comparing base (929c0f8) to head (d34a4a2).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/baseCommand.ts 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #282      +/-   ##
==========================================
+ Coverage   95.44%   95.78%   +0.34%     
==========================================
  Files          21       22       +1     
  Lines        1054     1068      +14     
  Branches      176      177       +1     
==========================================
+ Hits         1006     1023      +17     
+ Misses         48       45       -3     

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

@fengmk2 fengmk2 merged commit 515614a into master Jan 3, 2025
24 of 25 checks passed
@fengmk2 fengmk2 deleted the fix-tsconfig-paths-register branch January 3, 2025 02:20
fengmk2 pushed a commit that referenced this pull request Jan 3, 2025
[skip ci]

## [7.0.2](v7.0.1...v7.0.2) (2025-01-03)

### Bug Fixes

* auto import tsconfig-paths/register.js ([#282](#282)) ([515614a](515614a))
@coderabbitai coderabbitai bot mentioned this pull request Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant