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: change env and proxy to getter and setter #9

Merged
merged 1 commit into from
Jun 30, 2024
Merged

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Jun 30, 2024

Summary by CodeRabbit

  • New Features

    • Introduced GitHub Actions workflow for automatic publishing on push and pull requests.
  • Enhancements

    • Added new CI script to streamline the build and publishing process.
    • Improved type safety and code quality with updated devDependencies.
  • Refactor

    • Updated class properties in the Application class to use getter and setter methods for better encapsulation.

@fengmk2 fengmk2 self-assigned this Jun 30, 2024
Copy link

coderabbitai bot commented Jun 30, 2024

Walkthrough

The recent updates introduce a new GitHub Actions workflow to publish commits, update the Node.js project configuration and dependencies, and make modifications to the Application class in the codebase, particularly altering the visibility and access methods of specific properties.

Changes

File Change Summary
.github/workflows/pkg.pr.new.yml Added workflow "Publish Any Commit" triggered on push and pull requests, including steps for setup, build, and publish.
package.json Added script attw --pack to ci, added @arethetypeswrong/cli v^0.15.3, and updated eslint-config-egg to v14.
src/application.ts Modified Application class to include getters and setters for _proxy and _env properties, updating their usage.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant GitHub as GitHub Actions
    participant Node as Node Environment

    Dev->>GitHub: Push or PR
    activate GitHub
    GitHub->>Node: Setup build environment<br/> (checkout, install, build)
    activate Node
    Node->>GitHub: Build output
    GitHub->>GitHub: Run `npx pkg-pr-new`
    GitHub->>Dev: Publish results
    deactivate Node
    deactivate GitHub
Loading

Poem

Amidst the nodes and lines of code,
Trot the changes swift and bold,
Actions trigger, oh so prime,
Publish, build - it's commit time!
Proxy set, the env anew,
Happy devs, the praises grew.
Hoppy updates, through and through!


Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are always opted into early access features.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/eslint-config-egg@14.0.0 Transitive: environment, eval, filesystem, unsafe +152 18.6 MB fengmk2

🚮 Removed packages: npm/eslint-config-egg@13.1.0

View full report↗︎

Copy link

pkg-pr-new bot commented Jun 30, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

commit: 5c4ce76

@eggjs/koa

npm i https://pkg.pr.new/eggjs/koa/@eggjs/koa@9


templates

Copy link

codecov bot commented Jun 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c5e4cc5) to head (5c4ce76).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master        #9   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines         1634      1648   +14     
  Branches       296       300    +4     
=========================================
+ Hits          1634      1648   +14     

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

@fengmk2 fengmk2 merged commit 14aa2c5 into master Jun 30, 2024
20 checks passed
@fengmk2 fengmk2 deleted the env-setter branch June 30, 2024 16:04
fengmk2 pushed a commit that referenced this pull request Jun 30, 2024
[skip ci]

## [2.18.4](v2.18.3...v2.18.4) (2024-06-30)

### Bug Fixes

* change env and proxy to getter and setter ([#9](#9)) ([14aa2c5](14aa2c5))
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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0543aa7 and 5c4ce76.

Files selected for processing (3)
  • .github/workflows/pkg.pr.new.yml (1 hunks)
  • package.json (3 hunks)
  • src/application.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • .github/workflows/pkg.pr.new.yml
Additional comments not posted (6)
package.json (2)

13-13: Ensure the new ci script is tested.

The ci script now includes attw --pack. Ensure that this addition has been tested and works as expected in your CI environment.


75-75: Updated eslint-config-egg to version 14.

Ensure that the new version of eslint-config-egg does not introduce any breaking changes.

src/application.ts (4)

76-80: Updated constructor to initialize _proxy and _env as private properties.

Ensure that the initialization logic is correct and consistent with the new getter and setter methods.


93-99: Added getter and setter for env.

Ensure that the getter and setter methods for env are correctly implemented and used.


100-106: Added getter and setter for proxy.

Ensure that the getter and setter methods for proxy are correctly implemented and used.


38-39: Changed visibility of _proxy and _env to private.

Ensure that these properties are not accessed directly from outside the class.

Verification successful

Changed visibility of _proxy and _env to private.

Verification confirms that these properties are not accessed directly from outside the class.

  • All occurrences of _proxy and _env are within src/application.ts.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `_proxy` and `_env` are not accessed directly from outside the class.

# Test: Search for direct accesses to `_proxy` and `_env`. Expect: No direct accesses outside the class.
rg '\._proxy' --type=typescript
rg '\._env' --type=typescript

Length of output: 135



Script:

#!/bin/bash
# Description: Verify that `_proxy` and `_env` are not accessed directly from outside the class.

# Test: Search for direct accesses to `_proxy` and `_env`. Expect: No direct accesses outside the class.
rg '\._proxy' --glob '*.ts'
rg '\._env' --glob '*.ts'

Length of output: 377

@@ -52,6 +52,7 @@
"vary": "^1.1.2"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.3",
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Unused dependency @arethetypeswrong/cli found in package.json.

The dependency @arethetypeswrong/cli is listed in package.json but is not used anywhere in the codebase, npm scripts, or configuration files. Consider removing it to keep the project dependencies clean.

  • package.json: Line 55
Analysis chain

Added @arethetypeswrong/cli as a new dev dependency.

Ensure that this new dependency is necessary and used appropriately in the project.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of the new dependency `@arethetypeswrong/cli`.

# Test: Search for the usage of `@arethetypeswrong/cli` in the codebase. Expect: The dependency should be used in the codebase.
rg '@arethetypeswrong/cli'

Length of output: 79



Script:

#!/bin/bash
# Description: Verify the usage of the new dependency `@arethetypeswrong/cli` in npm scripts and configuration files.

# Test 1: Search for the usage of `@arethetypeswrong/cli` in npm scripts defined in package.json.
jq '.scripts | .[]' package.json | grep '@arethetypeswrong/cli'

# Test 2: Search for the usage of `@arethetypeswrong/cli` in common configuration files.
rg '@arethetypeswrong/cli' --glob '*.{js,json,yml,yaml}'

Length of output: 173

Comment on lines +93 to +106
get env() {
return this._env;
}
set env(value: string) {
this._env = value;
}

get proxy() {
return this._proxy;
}
set proxy(value: boolean) {
this._proxy = value;
}

Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Ensure consistent usage of getter and setter methods for env and proxy.

Direct access to _env and _proxy is found in the constructor. Please use the getter and setter methods to ensure proper encapsulation.

  • src/application.ts:
    • Line 99: this._env = options.env || process.env.NODE_ENV || 'development';
    • Line 101: this._proxy = options.proxy || false;
Analysis chain

Verify the usage of new getter and setter methods.

Ensure that the new getter and setter methods for env and proxy are used instead of direct property access.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of new getter and setter methods for `env` and `proxy`.

# Test: Search for the usage of `env` and `proxy` getter and setter methods. Expect: Only the getter and setter methods should be used.
rg '\.env' --type=typescript
rg '\.proxy' --type=typescript

Length of output: 133



Script:

#!/bin/bash
# Description: Verify the usage of new getter and setter methods for `env` and `proxy`.

# Test: Search for the usage of `env` and `proxy` getter and setter methods in TypeScript files.
rg '\.env' --glob '*.ts'
rg '\.proxy' --glob '*.ts'

Length of output: 2474



Script:

#!/bin/bash
# Description: Extract context around the usage of `env` and `proxy` to verify if getter and setter methods are used.

# Extract context for `.env` usage
rg '\.env' --glob '*.ts' -C 3

# Extract context for `.proxy` usage
rg '\.proxy' --glob '*.ts' -C 3

Length of output: 12949

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant