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: not overwrite dao file #215

Merged
merged 1 commit into from
Apr 19, 2024
Merged

fix: not overwrite dao file #215

merged 1 commit into from
Apr 19, 2024

Conversation

killagu
Copy link
Contributor

@killagu killagu commented Apr 19, 2024

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Summary by CodeRabbit

  • New Features

    • Introduced a configuration option to control whether existing files should be overwritten during code generation.
    • Added custom operation capabilities in the Data Access Layer for enhanced data handling.
  • Bug Fixes

    • Implemented a test to ensure data integrity by preventing overwriting of existing files during code generation.
  • Chores

    • Updated .gitignore to better manage file tracking within the project.

Copy link

coderabbitai bot commented Apr 19, 2024

Walkthrough

This update focuses on enhancing the dal-runtime module by adding an overwrite property to control the overwriting of files during code generation. It also updates the .gitignore to better manage file exclusions and includes a new test to verify that Dao files aren't overwritten. Additionally, the project structure sees the introduction of new configurations and custom DAO methods.

Changes

File Path Change Summary
.gitignore Updated to exclude certain directories/files, specifically for dal-runtime testing but includes tracking for specific files.
core/dal-runtime/src/.../CodeGenerator.ts Added overwrite property to configuration objects to manage file overwriting during code generation.
core/dal-runtime/test/.../CodeGenerator.test.ts Added fs import and a new test case to ensure Dao files are not overwritten.
core/dal-runtime/test/fixtures/.../Foo.ts
core/dal-runtime/test/fixtures/.../dal/dao/FooDAO.ts
Added class Foo with detailed configurations and FooDAO extends BaseFooDAO with a new method customFind.
core/dal-runtime/test/fixtures/.../package.json Updated with configuration for the "dal" module in the DAL runtime.

🐇✨
In the fields of code where data streams flow,
A clever rabbit tweaked the gitignore.
No overwrites in the burrow tonight,
Safe are the files from unwanted overwrite.
Hoppity hop, the code does compile,
With a flick of a tail and a cheeky smile. 🌟📄


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e0656a4 and 38b09e0.
Files selected for processing (6)
  • .gitignore (1 hunks)
  • core/dal-runtime/src/CodeGenerator.ts (2 hunks)
  • core/dal-runtime/test/CodeGenerator.test.ts (2 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes_not_overwrite_dao/Foo.ts (1 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes_not_overwrite_dao/dal/dao/FooDAO.ts (1 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes_not_overwrite_dao/package.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • core/dal-runtime/test/fixtures/modules/generate_codes_not_overwrite_dao/package.json
Additional comments not posted (6)
core/dal-runtime/test/fixtures/modules/generate_codes_not_overwrite_dao/dal/dao/FooDAO.ts (1)

1-17: LGTM! The FooDAO class is well-documented and correctly extends BaseFooDAO. The SingletonProto decorator is appropriately used to set the access level to PUBLIC.

.gitignore (1)

30-31: Ensure the .gitignore changes correctly exclude the intended directories and files. The specific inclusion of FooDAO.ts within the ignored directory is a good practice to ensure that this file remains tracked despite broader exclusions.

core/dal-runtime/test/CodeGenerator.test.ts (2)

3-3: The import of fs from 'node:fs/promises' is correctly added to handle file system operations in the new test case.


24-37: The new test case should not overwrite Dao file is well-structured and effectively checks that the FooDAO.ts file is not overwritten by verifying the presence of the customFind method. This is crucial for ensuring the new functionality works as intended.

core/dal-runtime/src/CodeGenerator.ts (1)

94-112: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [97-140]

The implementation of the overwrite property in the CodeGenerator class is well-done. The conditional logic to check the overwrite flag before writing to the file ensures that existing files are not overwritten unless explicitly allowed. This is a critical feature for preserving custom modifications in DAO files.

core/dal-runtime/test/fixtures/modules/generate_codes_not_overwrite_dao/Foo.ts (1)

1-322: The class Foo is well-defined with comprehensive use of the Column and Index decorators to specify detailed attributes for each field. The decorators are used correctly to define data types, constraints, and indexes, which are essential for the underlying database operations.


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@killagu killagu merged commit 0856bf1 into master Apr 19, 2024
11 checks passed
@killagu killagu deleted the fix/dal_overwrite branch April 19, 2024 06:17
@gxkl
Copy link
Contributor

gxkl commented Apr 19, 2024

  • @eggjs/ajv-decorator@3.39.0
  • @eggjs/aop-decorator@3.39.0
  • @eggjs/controller-decorator@3.39.0
  • @eggjs/core-decorator@3.39.0
  • @eggjs/dal-decorator@3.39.0
  • @eggjs/dal-runtime@3.39.0
  • @eggjs/egg-module-common@3.39.0
  • @eggjs/eventbus-decorator@3.39.0
  • @eggjs/standalone-decorator@3.39.0
  • @eggjs/tegg@3.39.0
  • @eggjs/tegg-ajv-plugin@3.39.0
  • @eggjs/tegg-aop-plugin@3.39.0
  • @eggjs/tegg-aop-runtime@3.39.0
  • @eggjs/tegg-background-task@3.39.0
  • @eggjs/tegg-common-util@3.39.0
  • @eggjs/tegg-config@3.39.0
  • @eggjs/tegg-controller-plugin@3.39.0
  • @eggjs/tegg-dal-plugin@3.39.0
  • @eggjs/tegg-dynamic-inject@3.39.0
  • @eggjs/tegg-dynamic-inject-runtime@3.39.0
  • @eggjs/tegg-eventbus-plugin@3.39.0
  • @eggjs/tegg-eventbus-runtime@3.39.0
  • @eggjs/tegg-lifecycle@3.39.0
  • @eggjs/tegg-loader@3.39.0
  • @eggjs/tegg-metadata@3.39.0
  • @eggjs/tegg-orm-decorator@3.39.0
  • @eggjs/tegg-orm-plugin@3.39.0
  • @eggjs/tegg-plugin@3.39.0
  • @eggjs/tegg-runtime@3.39.0
  • @eggjs/tegg-schedule-decorator@3.39.0
  • @eggjs/tegg-schedule-plugin@3.39.0
  • @eggjs/tegg-standalone@3.39.0
  • @eggjs/tegg-transaction-decorator@3.39.0
  • @eggjs/tegg-types@3.39.0

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.

None yet

2 participants