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

chore: support pnpm workspace #2842

Merged
merged 6 commits into from
Dec 10, 2024

Conversation

oasis-cloud
Copy link
Collaborator

@oasis-cloud oasis-cloud commented Dec 9, 2024

前置条件:
.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.mdREADME_ZH.md 文件,以提供更清晰的开发指令。
  • 更新

    • 更新了 pnpm-workspace.yaml 文件,新增了 packages/nutui-taro-demo 包的条目。
    • .gitignore 文件中添加了对 pnpm-lock.*.yaml 文件的忽略规则。

Copy link

coderabbitai bot commented Dec 9, 2024

Walkthrough

本次变更主要涉及多个文件的更新,新增了一个名为 readPackage 的函数,该函数在 .pnpmfile.cjs 文件中实现,用于根据包名条件删除依赖项。此外,package.json 文件中添加了多个新脚本,以增强开发和构建流程。packages/nutui-taro-demo/config/index.js 文件中引入了新的环境变量 JD,并更新了插件数组的条件逻辑。最后,pnpm-workspace.yaml 文件中新增了 packages/nutui-taro-demo 的条目。

Changes

文件路径 变更摘要
.pnpmfile.cjs 新增函数 readPackage(pkg, context),根据包名条件删除依赖项并返回修改后的 pkg 对象。
package.json @nutui/nutui-react-taropackage.json 中新增多个脚本,包括 dev:tarodev:jdtarodev:jdharmony 等。
packages/nutui-taro-demo/config/index.js 新增环境变量 JD,并更新插件数组的条件逻辑,以包含 JD 变量的检查。
packages/nutui-taro-demo/package.json @nutui/nutui-taro-demopackage.json 中新增多个脚本,包括 devdev:jmappbuild 等。
pnpm-workspace.yaml pnpm-workspace.yaml 中新增条目 packages/nutui-taro-demo
.gitignore .gitignore 中新增 pnpm-lock.*.yaml 的忽略规则。
README.md 更新了运行项目的指令,增加了关于 Taro 和 JDTaro 的详细说明。
README_ZH.md 更新了本地开发指令,重命名为“本地运行 Taro 相关的预览”,并增加了 JDTaro 的相关说明。

Possibly related PRs

Suggested labels

size/XL

Suggested reviewers

  • xiaoyatong

兔子欢快地跳跃着,
新功能如春风拂面,
脚本新增助开发,
依赖管理更简便。
让我们一起欢庆吧,
代码如花绽放间! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@github-actions github-actions bot added the 3.x label Dec 9, 2024
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.14%. Comparing base (932ff28) to head (1c1f48a).
Report is 2 commits behind head on feat_v3.x.

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.
📢 Have feedback on the report? Share it here.

coderabbitai[bot]

This comment was marked as resolved.

@xiaoyatong
Copy link
Collaborator

1、重复了 dev:jmapp
2、dev:jdtaro jdharmony 异常

coderabbitai[bot]

This comment was marked as abuse.

@oasis-cloud
Copy link
Collaborator Author

1、重复了 dev:jmapp 2、dev:jdtaro jdharmony 异常

已修复问题 1。
JD 鸿蒙相关需要配一个独立的命令,因为它的编译是特殊的,无法复用 Taro dev 的编译逻辑。

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 38b4dd2 and 79b6112.

📒 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: ⚠️ Potential issue

需要补充 .npmrc 配置的说明

当前仅提供了配置内容,但缺少以下重要信息:

  • 为什么需要设置 git-branch-lockfile=true
  • 这个配置会带来什么影响
  • 是否有其他必要的配置项

建议补充这些说明以帮助开发者理解配置的必要性。

Comment on lines +112 to +124
# 安装依赖
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
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

建议补充特殊命令的使用说明

以下几点需要补充说明:

  1. 为什么安装依赖时需要使用 --ignore-pnpmfile 参数
  2. dev:jdtarodev:taro 的区别
  3. 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",
Copy link
Collaborator

Choose a reason for hiding this comment

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

鸿蒙的壳子不见了

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.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 79b6112 and 1c1f48a.

📒 Files selected for processing (1)
  • package.json (1 hunks)
🔇 Additional comments (1)
package.json (1)

60-64: 开发脚本重构需要验证

新增的开发脚本需要注意以下几点:

  1. dev:jdtarodev:taro:jmapp 的功能可能存在重叠,建议确认是否需要保留两者
  2. 鸿蒙相关的命令 dev:jdtaro:jdharmonydev: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

Comment on lines +71 to +73
"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",
Copy link

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:jdtarobuild: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.

Comment on lines +60 to +73
"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",
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

pnpm workspace 配置需要调整

根据验证结果发现以下问题:

  1. 缺少 .npmrc 文件,无法确保 git 分支锁文件的正确性
  2. 根目录 package.json 中未配置 workspaces 字段,与 pnpm-workspace.yaml 配置不一致
  3. 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 的正确配置。请确认:

  1. .npmrc 文件中是否已添加 git-branch-lockfile=true
  2. 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

@xiaoyatong xiaoyatong merged commit 12f6a39 into jdf2e:feat_v3.x Dec 10, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants