feat(mockServer): mockserver support custom database path#1501
feat(mockServer): mockserver support custom database path#1501chilingling merged 2 commits intoopentiny:developfrom
Conversation
WalkthroughA new utility function, Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
c6d8e4f to
0f8d721
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
mockServer/src/database/pages.dbis excluded by!**/*.db
📒 Files selected for processing (5)
mockServer/src/services/block.js(1 hunks)mockServer/src/services/blockCategory.js(1 hunks)mockServer/src/services/blockGroup.js(1 hunks)mockServer/src/services/pages.js(1 hunks)mockServer/src/tool/Common.js(2 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: rhlin
PR: opentiny/tiny-engine#1011
File: packages/canvas/render/src/RenderMain.ts:82-88
Timestamp: 2025-01-14T08:50:50.226Z
Learning: For PR #1011, the focus is on resolving conflicts and migrating code, with architectural improvements deferred for future PRs.
mockServer/src/services/pages.js (3)
Learnt from: yy-wow
PR: opentiny/tiny-engine#940
File: packages/canvas/DesignCanvas/src/importMap.js:51-51
Timestamp: 2025-01-13T03:46:13.817Z
Learning: The `getImportMapData` function in `packages/canvas/DesignCanvas/src/importMap.js` has default parameter handling that initializes `canvasDeps` with empty arrays for `scripts` and `styles`, making additional null checks unnecessary.
Learnt from: yy-wow
PR: opentiny/tiny-engine#886
File: packages/common/composable/index.js:3-3
Timestamp: 2024-10-30T02:10:38.028Z
Learning: 在 `packages/common/composable` 目录中,`HttpService` 模块位于 `./http/index.js`,而不是 `./http.js`。
Learnt from: gene9831
PR: opentiny/tiny-engine#1011
File: packages/canvas/route-bar/src/CanvasRouteBar.vue:23-25
Timestamp: 2025-01-14T06:45:03.521Z
Learning: The global base service (`META_SERVICE.GlobalService`) guarantees that `baseInfo` will always contain a `pageId` property.
mockServer/src/services/block.js (1)
Learnt from: yy-wow
PR: opentiny/tiny-engine#886
File: packages/toolbars/generate-code/src/http.js:39-40
Timestamp: 2024-10-30T02:38:05.165Z
Learning: In the function `fetchBlockSchema` in `packages/toolbars/generate-code/src/http.js`, input validation and error handling for the `blockName` parameter are handled by the user elsewhere, so it's acceptable not to perform parameter validation or URL encoding in this function within this codebase.
mockServer/src/services/blockGroup.js (1)
Learnt from: yy-wow
PR: opentiny/tiny-engine#886
File: packages/toolbars/generate-code/src/http.js:39-40
Timestamp: 2024-10-30T02:38:05.165Z
Learning: In the function `fetchBlockSchema` in `packages/toolbars/generate-code/src/http.js`, input validation and error handling for the `blockName` parameter are handled by the user elsewhere, so it's acceptable not to perform parameter validation or URL encoding in this function within this codebase.
mockServer/src/services/blockCategory.js (1)
Learnt from: yy-wow
PR: opentiny/tiny-engine#886
File: packages/toolbars/generate-code/src/http.js:39-40
Timestamp: 2024-10-30T02:38:05.165Z
Learning: In the function `fetchBlockSchema` in `packages/toolbars/generate-code/src/http.js`, input validation and error handling for the `blockName` parameter are handled by the user elsewhere, so it's acceptable not to perform parameter validation or URL encoding in this function within this codebase.
🧬 Code Graph Analysis (5)
mockServer/src/services/pages.js (1)
mockServer/src/tool/Common.js (2)
getDatabasePath(79-82)getDatabasePath(79-82)
mockServer/src/services/block.js (1)
mockServer/src/tool/Common.js (2)
getDatabasePath(79-82)getDatabasePath(79-82)
mockServer/src/services/blockGroup.js (1)
mockServer/src/tool/Common.js (2)
getDatabasePath(79-82)getDatabasePath(79-82)
mockServer/src/tool/Common.js (1)
scripts/copyToVscode.js (1)
path(13-13)
mockServer/src/services/blockCategory.js (1)
mockServer/src/tool/Common.js (2)
getDatabasePath(79-82)getDatabasePath(79-82)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (9)
mockServer/src/tool/Common.js (1)
13-13: Good addition of path module import.The ES6 import syntax is consistent with the module system being used.
mockServer/src/services/block.js (2)
13-13: Excellent refactoring to use centralized path resolution.The import change correctly replaces direct path handling with the new utility function.
18-18: Consistent implementation of database path resolution.The usage of
getDatabasePath('blocks.db')is consistent with the centralized approach and maintains the same database filename.mockServer/src/services/blockCategory.js (2)
13-13: Consistent refactoring pattern applied.The import change correctly adopts the new centralized database path resolution utility.
19-19: Proper usage of the utility function.The
getDatabasePath('blockCategories.db')call maintains the correct database filename while enabling customizable path resolution.mockServer/src/services/blockGroup.js (2)
13-13: Consistent adoption of centralized path resolution.The import statement correctly uses the new utility function from the Common module.
19-19: Correct implementation of database path resolution.The
getDatabasePath('blockGroups.db')usage maintains the database filename while enabling the new configurable path feature.mockServer/src/services/pages.js (2)
14-14: Successful completion of the refactoring pattern.The import change correctly adopts the centralized database path resolution, completing the consistent implementation across all service files.
19-19: Proper implementation of the new database path feature.The
getDatabasePath('pages.db')call correctly implements the customizable database path feature while preserving the database filename.
* fix: remove useless data and fix pagename * feat: mockserver support custom dbpath
English | 简体中文
PR
mockserver 支持配置自定义数据库路径
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
mockserver中pages.db存在冗余数据;默认的createVm页面数据,在设计器中编辑时会提示名字需要大写开头,校验不通过
当前使用CLI创建的项目中启动后使用的是node_modules中的mock server数据库,数据存储在node_modules中只能在本地有效,在团队开发场景中无法通过git进行协作共享或者版本管理,无法进行持久化保存。
因此增加mockserver的自定义能力,提供数据库目录的配置,用户可以配置到项目目录中,进行持久化或通过git管理。
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Refactor
New Features