-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: fix HBuilderX compatibility #163
Conversation
WalkthroughThe recent changes primarily focus on enhancing the flexibility and configurability of path resolutions within the core package. Key updates include incorporating the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/core/src/context.ts (1 hunks)
- packages/core/src/index.ts (2 hunks)
- packages/core/src/options.ts (1 hunks)
Additional comments not posted (3)
packages/core/src/options.ts (1)
34-34
: Verify the order of fallbacks in the root directory resolution.Verification successful
Order of Fallbacks in Root Directory Resolution Verified
The order of fallbacks for the root directory resolution in the
resolveOptions
function is correct. The code first checks forviteRoot
, then falls back toprocess.env.VITE_ROOT_DIR
, and finally toprocess.cwd()
.
viteRoot
process.env.VITE_ROOT_DIR
process.cwd()
No issues found with the fallback mechanism.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the order of fallbacks for the root directory resolution. # Test: Check the order of fallbacks in the resolveOptions function. Expect: Correct order of fallbacks. rg --type typescript $'const root = viteRoot || slash(process.env.VITE_ROOT_DIR!) || slash(process.cwd())' packages/core/src/options.tsLength of output: 171
Script:
#!/bin/bash # Description: Verify the order of fallbacks for the root directory resolution. # Test: Check the order of fallbacks in the resolveOptions function. Expect: Correct order of fallbacks. rg --type ts $'const root = viteRoot || slash(process.env.VITE_ROOT_DIR!) || slash(process.cwd())' packages/core/src/options.tsLength of output: 2598
packages/core/src/index.ts (1)
46-46
: LGTM! Ensure that the path resolution is correct and tested.Verification successful
Path Resolution Logic in
VitePluginUniPages
The path resolution logic in
VitePluginUniPages
is correctly implemented usingpath.join
withprocess.env.VITE_ROOT_DIR!
,userOptions.outDir ?? 'src'
, andOUTPUT_NAME
. This ensures that the path is constructed based on the environment variable and user options.
- Location in Code:
packages/core/src/index.ts
const resolvedPagesJSONPath = path.join( process.env.VITE_ROOT_DIR!, userOptions.outDir ?? 'src', OUTPUT_NAME, )Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the path resolution in `VitePluginUniPages`. # Test: Check the path resolution logic. Expect: Correct and tested path resolution. rg --type typescript $'path.join(process.env.VITE_ROOT_DIR!, userOptions.outDir ?? "src", OUTPUT_NAME)' packages/core/src/index.tsLength of output: 166
Script:
#!/bin/bash # Description: Verify the path resolution in `VitePluginUniPages`. # Test: Check the path resolution logic. Expect: Correct and tested path resolution. rg --type ts $'path.join(process.env.VITE_ROOT_DIR!, userOptions.outDir ?? "src", OUTPUT_NAME)' packages/core/src/index.tsLength of output: 123
Script:
#!/bin/bash # Description: Verify the path resolution in `VitePluginUniPages`. # Test: Check for any `path.join` usage in the file to identify path resolution logic. rg 'path.join' packages/core/src/index.tsLength of output: 84
Script:
#!/bin/bash # Description: Extract the context around `path.join` usage in `packages/core/src/index.ts`. # Extract lines around the `path.join` usage to understand the path resolution logic. rg 'path.join' -A 5 -B 5 packages/core/src/index.tsLength of output: 394
packages/core/src/context.ts (1)
245-245
: LGTM! Verify the new path calculation for accuracy.Verification successful
Verification of Path Calculation in
PageContext
The new path calculation logic in the
PageContext
class has been verified and found to be accurate.
- The line
const root = slash(path.relative(basePath, path.join(this.options.root, dir)))
is present inpackages/core/src/context.ts
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new path calculation in `PageContext`. # Test: Check the new path calculation logic. Expect: Accurate path calculation. rg --type typescript $'const root = slash(path.relative(basePath, path.join(this.options.root, dir)))' packages/core/src/context.tsLength of output: 167
Script:
#!/bin/bash # Description: Verify the new path calculation in `PageContext`. # Test: Check the new path calculation logic. Expect: Accurate path calculation. rg --type ts $'const root = slash(path.relative(basePath, path.join(this.options.root, dir)))' packages/core/src/context.tsLength of output: 124
Script:
#!/bin/bash # Description: Verify the new path calculation in `PageContext`. # Test: Check the new path calculation logic with a broader search pattern. Expect: Accurate path calculation. rg --type ts 'slash\(path\.relative\(basePath, path\.join\(this\.options\.root, dir\)\)\)' packages/core/src/context.tsLength of output: 206
@@ -26,7 +26,7 @@ export * from './customBlock' | |||
async function restart() { | |||
return new Promise((resolve) => { | |||
const build = spawn(process.argv.shift()!, process.argv, { | |||
cwd: process.cwd(), | |||
cwd: process.env.VITE_ROOT_DIR!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Ensure that process.env.VITE_ROOT_DIR
has a fallback in packages/core/src/index.ts
.
packages/core/src/index.ts
:- Line 29:
cwd: process.env.VITE_ROOT_DIR!
- Line 31:
process.env.VITE_ROOT_DIR!
- Line 29:
These lines should include a fallback to avoid potential issues if the environment variable is not defined.
Analysis chain
Ensure that process.env.VITE_ROOT_DIR
is always defined or provide a fallback.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that `process.env.VITE_ROOT_DIR` is always defined or has a fallback.
# Test: Search for usage of `process.env.VITE_ROOT_DIR` without fallback. Expect: No occurrences without fallback.
rg --type typescript $'process.env.VITE_ROOT_DIR!' packages/core/src/index.ts
Length of output: 113
Script:
#!/bin/bash
# Description: Verify that `process.env.VITE_ROOT_DIR` is always defined or has a fallback.
# Test: Search for usage of `process.env.VITE_ROOT_DIR` without fallback. Expect: No occurrences without fallback.
rg --type ts $'process.env.VITE_ROOT_DIR!' packages/core/src/index.ts
Length of output: 141
Script:
#!/bin/bash
# Description: Search for all occurrences of `process.env.VITE_ROOT_DIR` in the codebase and check for fallbacks.
# Test: Search for all occurrences of `process.env.VITE_ROOT_DIR`. Expect: Occurrences with and without fallbacks.
rg 'process.env.VITE_ROOT_DIR' --type ts
Length of output: 279
There was a problem hiding this 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
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/core/src/index.ts (2 hunks)
- packages/core/src/options.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- packages/core/src/index.ts
- packages/core/src/options.ts
LGTM |
如果没有进一步的反馈,我会在2-3天内合并发布。 |
Thx |
Description 描述
兼容 HBuiderX 运行模式
Linked Issues 关联的 Issues
在 HBuiderX 使用,会在 /Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli-vite/ 下生成一个 pages.json 文件
Additional context 额外上下文
在 HBuilderX 下运行
Summary by CodeRabbit
New Features
VITE_ROOT_DIR
environment variable for better flexibility and configuration.Improvements