Skip to content

feat: dal-runtime templates support pkg alias#198

Merged
killagu merged 1 commit intomasterfrom
feat/pkg_alias
Mar 26, 2024
Merged

feat: dal-runtime templates support pkg alias#198
killagu merged 1 commit intomasterfrom
feat/pkg_alias

Conversation

@killagu
Copy link
Contributor

@killagu killagu commented Mar 26, 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

  • Refactor
    • Updated import paths for various types across multiple files to ensure consistency and improve maintainability.
    • Introduced dynamic package references in template files for more flexible code generation.
  • Tests
    • Adjusted tests to align with the new import paths and dynamic package references.
  • Chores
    • Enhanced the CodeGenerator functionality to support optional properties for better customization.

@coderabbitai
Copy link

coderabbitai bot commented Mar 26, 2024

Walkthrough

The overarching change involves standardizing and updating import paths and references across various files in the project. This includes transitioning to dynamic package references for improved flexibility and updating import paths for specific types to reflect changes in their locations. The introduction of optional properties in the CodeGeneratorOptions interface and the adaptation of templates to utilize dynamic package references also highlight a move towards a more configurable and maintainable codebase.

Changes

Files Summary
core/dal-decorator/src/type/MySql.ts Updated import paths for InsertResult, UpdateResult, and DeleteResult.
core/dal-runtime/src/CodeGenerator.ts Added teggPkg and dalPkg properties with default values in CodeGeneratorOptions.
core/dal-runtime/src/templates/.../base_dao.njk, dao.njk, extension.njk Updated import paths and replaced specific package references with placeholders.
core/dal-runtime/test/CodeGenerator.test.ts, core/dal-runtime/test/fixtures/modules/generate_codes/dal/... Updated import statements for InsertResult, UpdateResult, DeleteResult, SqlMap, and SqlType with new paths.

Poem

🐇✨
In the burrows of code, where the data flows,
Changes spring like daisies, in neat, tidy rows.
Import paths now lead to a more vibrant garden,
Where packages dynamic, grant flexibility's pardon.
A rabbit hops along, leaving footprints so light,
Celebrating the changes, in the soft moonlight.
🌟📦🌙

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-tests 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 tests 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 tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@codecov
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.56%. Comparing base (5ec94ef) to head (b1585e8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #198      +/-   ##
==========================================
- Coverage   91.62%   91.56%   -0.06%     
==========================================
  Files         276      276              
  Lines        6446     6487      +41     
  Branches      935      950      +15     
==========================================
+ Hits         5906     5940      +34     
- Misses        540      547       +7     

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

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5ec94ef and b1585e8.
Files selected for processing (10)
  • core/dal-decorator/src/type/MySql.ts (1 hunks)
  • core/dal-runtime/src/CodeGenerator.ts (3 hunks)
  • core/dal-runtime/src/templates/base_dao.njk (1 hunks)
  • core/dal-runtime/src/templates/dao.njk (1 hunks)
  • core/dal-runtime/src/templates/extension.njk (1 hunks)
  • core/dal-runtime/test/CodeGenerator.test.ts (1 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes/dal/dao/base/BaseFooDAO.ts (1 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes/dal/dao/base/BaseMultiPrimaryKeyDAO.ts (1 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes/dal/extension/FooExtension.ts (1 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes/dal/extension/MultiPrimaryKeyExtension.ts (1 hunks)
Additional comments: 12
core/dal-decorator/src/type/MySql.ts (1)
  • 1-1: The update to the import path simplifies and clarifies the source of InsertResult, UpdateResult, and DeleteResult, aligning with the PR's objectives. This change should make the codebase more maintainable and flexible.
core/dal-runtime/test/fixtures/modules/generate_codes/dal/extension/FooExtension.ts (1)
  • 1-1: The update to the import path for SqlMap aligns with the PR's objectives. However, the commented-out code snippet references SqlType, which is not imported. Consider updating or removing this snippet to avoid confusion.
core/dal-runtime/test/fixtures/modules/generate_codes/dal/extension/MultiPrimaryKeyExtension.ts (1)
  • 1-1: Identical to the previous file, the update to the import path for SqlMap is appropriate. Again, consider updating or removing the commented-out code snippet that references SqlType to maintain clarity.
core/dal-runtime/src/templates/extension.njk (1)
  • 1-1: The use of dynamic package references ({{dalPkg}}) for SqlMap import is a good improvement for flexibility. However, the commented-out code snippet should also be updated to use dynamic references for consistency and clarity.
core/dal-runtime/src/templates/dao.njk (1)
  • 1-1: The update to use dynamic package references ({{teggPkg}}) for imports in dao.njk enhances flexibility and aligns with the PR's objectives. This is a positive change for maintainability.
core/dal-runtime/test/CodeGenerator.test.ts (1)
  • 13-13: Including the dalPkg property in the CodeGenerator constructor is a necessary update to ensure that the tests reflect the changes made in the PR. This aligns well with the objectives of supporting package aliasing.
core/dal-runtime/test/fixtures/modules/generate_codes/dal/dao/base/BaseMultiPrimaryKeyDAO.ts (1)
  • 1-1: The update to the import paths for InsertResult, UpdateResult, and DeleteResult simplifies and clarifies the source of these types, aligning with the PR's objectives. This change should enhance the maintainability and flexibility of the codebase.
core/dal-runtime/src/templates/base_dao.njk (1)
  • 71-71: The use of dynamic package references ({{dalPkg}}, {{teggPkg}}) in the base_dao.njk template enhances flexibility and aligns with the PR's objectives. This approach makes the template more adaptable to different project configurations, which is a positive change for maintainability.
core/dal-runtime/src/CodeGenerator.ts (3)
  • 14-15: The addition of teggPkg and dalPkg properties to CodeGeneratorOptions is clear and follows the existing code style.
  • 27-34: The constructor's handling of teggPkg and dalPkg, including the assignment of default values, is correctly implemented.
  • 58-59: Including teggPkg and dalPkg in the template data preparation ensures templates can dynamically reference package paths, enhancing flexibility.
core/dal-runtime/test/fixtures/modules/generate_codes/dal/dao/base/BaseFooDAO.ts (1)
  • 1-3: The updated import statements correctly reflect the new package structure, aligning with the PR's objectives to support package aliasing.

Copy link
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

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

+1

@killagu killagu merged commit cecef78 into master Mar 26, 2024
@killagu killagu deleted the feat/pkg_alias branch March 26, 2024 15:01
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