-
Notifications
You must be signed in to change notification settings - Fork 266
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
chore: support pnpm workspace #2842
Conversation
Walkthrough本次变更主要涉及多个文件的更新,新增了一个名为 Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feat_v3.x #2842 +/- ##
==========================================
Coverage 84.14% 84.14%
==========================================
Files 273 273
Lines 18103 18103
Branches 2690 2690
==========================================
Hits 15232 15232
Misses 2866 2866
Partials 5 5 ☔ View full report in Codecov by Sentry. |
1、重复了 dev:jmapp |
已修复问题 1。 |
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
🧹 Outside diff range and nitpick comments (1)
README_ZH.md (1)
Line range hint
74-95
: 命令说明清晰,建议进一步优化格式命令结构清晰,涵盖了主要平台。建议在命令说明中添加每个平台的预期输出目录,以帮助开发者更好地理解构建结果。
建议添加如下说明:
# Taro H5 pnpm dev:taro h5 +# 输出目录:./dist # 微信小程序 pnpm dev:taro weapp +# 输出目录:./dist/weapp # 京东小程序 pnpm dev:taro jd +# 输出目录:./dist/jd
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
README.md
(1 hunks)README_ZH.md
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- README.md
🔇 Additional comments (1)
README_ZH.md (1)
99-102
:
需要补充 .npmrc 配置的说明
当前仅提供了配置内容,但缺少以下重要信息:
- 为什么需要设置
git-branch-lockfile=true
- 这个配置会带来什么影响
- 是否有其他必要的配置项
建议补充这些说明以帮助开发者理解配置的必要性。
# 安装依赖 | ||
pnpm install --ignore-pnpmfile | ||
|
||
# 进入小程序开发模式 | ||
```shell | ||
# Taro H5 | ||
pnpm dev:jdtaro h5 | ||
# 微信小程序 | ||
pnpm dev:jdtaro weapp | ||
# 京东小程序 | ||
pnpm dev:jdtaro jd | ||
# harmony cpp | ||
pnpm dev:jdtaro:jdharmonycpp |
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.
建议补充特殊命令的使用说明
以下几点需要补充说明:
- 为什么安装依赖时需要使用
--ignore-pnpmfile
参数 dev:jdtaro
与dev:taro
的区别- harmony cpp 的使用场景和所需环境
这些信息对于开发者正确使用命令至关重要。
package.json
Outdated
"dev:taro:weapp:jmapp": "pnpm --dir ./packages/nutui-taro-demo && npm run dev:weapp:jmapp", | ||
"dev:taro": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev", | ||
"dev:jdtaro": "pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev", | ||
"dev:jdtaro:jdharmonycpp": "pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jdharmonycpp", |
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.
鸿蒙的壳子不见了
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
package.json
(1 hunks)
🔇 Additional comments (1)
package.json (1)
60-64
: 开发脚本重构需要验证
新增的开发脚本需要注意以下几点:
dev:jdtaro
和dev:taro:jmapp
的功能可能存在重叠,建议确认是否需要保留两者- 鸿蒙相关的命令
dev:jdtaro:jdharmony
和dev:jdtaro:jdharmonycpp
需要验证是否完整支持鸿蒙环境
#!/bin/bash
# 检查命令之间的依赖关系
echo "检查 dev:jdtaro 和 dev:taro:jmapp 的实际执行内容:"
rg "dev:jmapp" ./packages/nutui-taro-demo/package.json -A 3
echo "检查鸿蒙相关的配置文件:"
fd "harmony" -t f
"build:jdtaro:site": "pnpm update:taro:entry && npm run checked:taro && npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5", | ||
"build:taro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5", | ||
"build:jstaro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5", |
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.
🛠️ Refactor suggestion
构建脚本命名需要统一规范
构建脚本的命名存在不一致:
build:jdtaro:site
build:taro:site:jmapp
build:jstaro:site:jmapp
建议统一命名规范,例如全部使用 build:jdtaro
或 build:jstaro
前缀。
建议修改为:
- "build:jdtaro:site": "pnpm update:taro:entry && npm run checked:taro && npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5",
- "build:taro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5",
- "build:jstaro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5",
+ "build:jdtaro:site": "pnpm update:taro:entry && npm run checked:taro && npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5",
+ "build:jdtaro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5"
Committable suggestion skipped: line range outside the PR's diff.
"dev:taro": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev", | ||
"dev:jdtaro": "pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev", | ||
"dev:jdtaro:jdharmonycpp": "pnpm run clone:jdharmony cpp &&pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jdharmonycpp", | ||
"dev:jdtaro:jdharmony": "pnpm run clone:jdharmony && pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jdharmony", | ||
"dev:taro:jmapp": "pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jmapp", | ||
"build": "npm run checked && node scripts/build.mjs", | ||
"build:taro": "npm run checked:taro && node scripts/build-taro.mjs", | ||
"build:taro:jd": "pnpm --dir ./packages/nutui-taro-demo build:jd", | ||
"build:taro:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp node scripts/build-taro.mjs", | ||
"build:site": "npm run checked && vite build --config vite.config.site.ts", | ||
"build:site:jmapp": "npm run checked && VITE_APP_PROJECT_ID=jmapp vite build", | ||
"build:taro:site": "pnpm update:taro:entry && npm run checked:taro && npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5", | ||
"build:taro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && VITE_APP_PROJECT_ID=jmapp pnpm --dir ./packages/nutui-taro-demo build:h5", | ||
"build:theme:site": "npm run checked && vite build --config vite.config.theme.ts && npm run generate:themes-dev", | ||
"build:jdtaro:site": "pnpm update:taro:entry && npm run checked:taro && npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5", | ||
"build:taro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5", | ||
"build:jstaro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5", |
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.
💡 Codebase verification
pnpm workspace 配置需要调整
根据验证结果发现以下问题:
- 缺少
.npmrc
文件,无法确保 git 分支锁文件的正确性 - 根目录
package.json
中未配置workspaces
字段,与pnpm-workspace.yaml
配置不一致 packages/nutui-taro-demo
中存在resolutions
字段警告,需要将其移至工作区根目录
建议进行如下修改:
- 在根目录创建
.npmrc
文件并添加git-branch-lockfile=true
- 在根目录
package.json
中添加workspaces
配置,与pnpm-workspace.yaml
保持一致 - 将
packages/nutui-taro-demo/package.json
中的resolutions
字段移至根目录package.json
🔗 Analysis chain
验证 pnpm workspace 配置
根据 PR 目标,需要确保 pnpm workspace 的正确配置。请确认:
.npmrc
文件中是否已添加git-branch-lockfile=true
- workspace 相关的依赖是否正确配置
Let me gather more information about the workspace configuration and dependencies.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查 pnpm workspace 配置
echo "检查 .npmrc 配置:"
cat .npmrc 2>/dev/null || echo ".npmrc 文件不存在"
echo "检查 pnpm-workspace.yaml 配置:"
cat pnpm-workspace.yaml 2>/dev/null || echo "pnpm-workspace.yaml 文件不存在"
echo "检查是否存在工作区包的循环依赖:"
pnpm ls -r 2>/dev/null || echo "未找到 pnpm 工作区配置"
Length of output: 753
Script:
#!/bin/bash
# 检查根目录 package.json 中的 workspaces 配置
echo "检查根目录 package.json 配置:"
cat package.json | jq '.workspaces'
echo "检查各个工作区包的依赖关系:"
for pkg in packages/nutui-codemod packages/nutui-auto-import packages/nutui-taro-demo; do
if [ -f "$pkg/package.json" ]; then
echo -e "\n检查 $pkg/package.json:"
cat "$pkg/package.json" | jq '{name: .name, dependencies: .dependencies, devDependencies: .devDependencies}'
fi
done
Length of output: 4861
前置条件:
.npmrc 中增加
git-branch-lockfile=true
无 jd 包安装
pnpm i
有 jd 包安装
pnpm i --ignore-pnpmfile
生成的分支 lock 文件不提交。
执行方式说明:
外部
pnpm dev:taro h5
内部
pnpm dev:jdtaro h5
Summary by CodeRabbit
新功能
package.json
中添加了多个开发和构建脚本,以增强开发工作流程。JD
,以控制插件的加载。README.md
和README_ZH.md
文件,以提供更清晰的开发指令。更新
pnpm-workspace.yaml
文件,新增了packages/nutui-taro-demo
包的条目。.gitignore
文件中添加了对pnpm-lock.*.yaml
文件的忽略规则。