Skip to content

feat: enable ts support by process.env.EGG_TS_ENABLE = true#43

Merged
fengmk2 merged 1 commit intomasterfrom
force-enable-ts
Mar 4, 2025
Merged

feat: enable ts support by process.env.EGG_TS_ENABLE = true#43
fengmk2 merged 1 commit intomasterfrom
force-enable-ts

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 4, 2025

Summary by CodeRabbit

  • New Features
    • Expanded TypeScript Support Detection: The application now checks an additional configuration option to determine TypeScript support. This enhancement provides a more reliable activation process for TypeScript projects.
    • Enhanced Logging: Diagnostic output has been improved to display a more comprehensive summary of the configuration settings, making it easier to trace and verify support conditions.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 4, 2025

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

Name Status Preview Comments Updated (UTC)
egg-utils ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 4:21pm

@fengmk2 fengmk2 requested a review from Copilot March 4, 2025 16:21
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 4, 2025

Walkthrough

The isSupportTypeScript function in src/import.ts was updated to include an additional condition that checks if the environment variable EGG_TS_ENABLE is set to 'true'. The debug logging was also modified to output the value of this new variable alongside the existing ones, providing enhanced transparency during debugging.

Changes

File(s) Change Summary
src/import.ts Enhanced isSupportTypeScript logic to check process.env.EGG_TS_ENABLE in addition to existing conditions and updated debug logging to include this variable.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Function as isSupportTypeScript()
    Caller->>Function: Call isSupportTypeScript()
    Function->>Function: Check for ".ts" extension or process.env.VITEST=='true'
    alt Condition satisfied
        Function->>Caller: Return true
    else Not satisfied
        Function->>Function: Check process.env.EGG_TS_ENABLE=='true'
        alt Condition satisfied
            Function->>Caller: Return true
        else Condition not satisfied
            Function->>Caller: Return false
        end
    end
Loading

Possibly related PRs

Poem

I'm a rabbit in a code-filled glade,
Hopping through changes that have been made.
New checks spring like carrots bright,
Debug logs shine in the soft moonlight.
Hoppy code to all—what a delightful sight!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/import.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-eggache".

(The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-eggache@latest --save-dev

The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 4, 2025

Open in Stackblitz

npm i https://pkg.pr.new/eggjs/utils/@eggjs/utils@43

commit: 37bc251

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.16%. Comparing base (12af5f9) to head (37bc251).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #43      +/-   ##
==========================================
+ Coverage   88.14%   88.16%   +0.01%     
==========================================
  Files           8        8              
  Lines         751      752       +1     
  Branches      133      133              
==========================================
+ Hits          662      663       +1     
  Misses         89       89              

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

Copy link
Copy Markdown

@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)
src/import.ts (1)

43-46: Consider documenting this new flag.

This new environment variable provides a useful way to enable TypeScript support. Consider documenting this feature in the project's README or documentation to ensure users are aware of this option.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a99a87f and 37bc251.

📒 Files selected for processing (1)
  • src/import.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: Node.js / Test (windows-latest, 23)
  • GitHub Check: Node.js / Test (windows-latest, 22)
  • GitHub Check: Node.js / Test (windows-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 18)
  • GitHub Check: Node.js / Test (windows-latest, 18.19.0)
  • GitHub Check: Node.js / Test (ubuntu-latest, 23)
  • GitHub Check: Node.js / Test (ubuntu-latest, 22)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18.19.0)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18)
  • GitHub Check: Node.js / Test (macos-latest, 23)
  • GitHub Check: Node.js / Test (macos-latest, 22)
  • GitHub Check: Node.js / Test (macos-latest, 20)
  • GitHub Check: Node.js / Test (macos-latest, 18.19.0)
  • GitHub Check: Node.js / Test (macos-latest, 18)
🔇 Additional comments (3)
src/import.ts (3)

43-44: Environment variable addition looks good.

The addition of process.env.EGG_TS_ENABLE as an alternative way to enable TypeScript support is a good enhancement that provides more flexibility for users. The implementation correctly maintains the existing behavior while adding this new option.


45-46: Good debugging enhancement.

The updated debug logging now includes the value of process.env.EGG_TS_ENABLE, which improves observability when troubleshooting TypeScript support issues. This change is well-aligned with the functional changes made above.


43-46:

Details

❓ Verification inconclusive

Verify TypeScript support behavior with the new environment variable.

The changes look good functionally. It would be beneficial to ensure that TypeScript support works correctly when enabled via EGG_TS_ENABLE=true while the other conditions are false.


🏁 Script executed:

#!/bin/bash
# Check if there are any tests verifying the TypeScript support behavior
# when only EGG_TS_ENABLE=true is set

rg -p "EGG_TS_ENABLE.*true" --type ts
rg -p "isSupportTypeScript" --type test

Length of output: 256


Action: Confirm explicit test coverage for enabling TypeScript solely via EGG_TS_ENABLE

The logic in src/import.ts (lines 43–46) clearly checks for TypeScript support using the new environment variable. However, while our search confirmed that the environment variable is processed (see line 44), we did not locate any tests explicitly verifying the scenario where only EGG_TS_ENABLE=true is set. Please ensure this behavior is covered in your test suite—either by adding a dedicated test case or by manually verifying that TypeScript support activates correctly when other conditions are false.

Copy link
Copy Markdown

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.

PR Overview

This PR expands support for TypeScript by additionally checking process.env.EGG_TS_ENABLE, and it updates the logging details to give a more comprehensive status.

  • Added a condition to enable TS support via process.env.EGG_TS_ENABLE.
  • Enhanced the debug log to include the new environment variable.

Reviewed Changes

File Description
src/import.ts Updated TypeScript support detection logic and debug log to include process.env.EGG_TS_ENABLE.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/import.ts:43

  • [nitpick] Consider clarifying this comment to explicitly mention that TypeScript is enabled when either '.ts' exists, process.env.VITEST or process.env.EGG_TS_ENABLE is 'true'.
// enable ts by process.env.EGG_TS_ENABLE or process.env.VITEST

src/import.ts:45

  • Verify that the additional '%j' placeholder for process.env.EGG_TS_ENABLE is correctly handled by the debug logger to maintain the intended log output format.
debug('[isSupportTypeScript] %o, extensions: %j, process.env.VITEST: %j, process.env.EGG_TS_ENABLE: %j',

@fengmk2 fengmk2 merged commit 4908ffc into master Mar 4, 2025
@fengmk2 fengmk2 deleted the force-enable-ts branch March 4, 2025 16:52
fengmk2 pushed a commit that referenced this pull request Mar 4, 2025
[skip ci]

## [4.4.0](v4.3.0...v4.4.0) (2025-03-04)

### Features

* enable ts support by process.env.EGG_TS_ENABLE = true ([#43](#43)) ([4908ffc](4908ffc))
fengmk2 added a commit to eggjs/egg-ts-helper that referenced this pull request Mar 5, 2025
eggjs/utils#43

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new diagnostic script for capturing and logging framework
configuration details, including plugins and performance metrics.
- Enhanced compatibility with ECMAScript module environments for
smoother diagnostic operations.
- Added new classes and methods to improve application structure and
functionality.
- Introduced new plugin configurations and context management features.

- **Bug Fixes**
- Updated import statements to ensure correct file references for
JavaScript files.

- **Refactor**
- Updated package configuration with additional resources and dependency
version updates.
- Improved internal parameter handling to better encapsulate support
utilities.
- Modified import statement generation for TypeScript files to ensure
correct JavaScript file references.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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