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

fix(): use node 22 #4567

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open

fix(): use node 22 #4567

wants to merge 1 commit into from

Conversation

weareoutman
Copy link
Member

@weareoutman weareoutman commented Nov 19, 2024

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

  • 新特性

    • 更新了构建过程中使用的Node.js版本,从20.x升级到22.x,确保与最新版本的兼容性。
  • 依赖更新

    • 更新了package.json中的@types/node版本,从^20.16.2更改为^22.9.0
  • 配置文件更新

    • 更新了.nvmrc文件中的Node.js版本,从20更改为22。

Copy link

coderabbitai bot commented Nov 19, 2024

Walkthrough

此次更改主要涉及多个工作流配置文件中Node.js版本的更新。所有相关文件的node-version均从20.x更新至22.x,影响到CI流程中的构建、测试及依赖管理等步骤。此外,.nvmrc文件中的Node.js版本也相应更新,而package.json中的@types/node依赖版本也进行了升级。packages/brick-container/build.config.js文件中的JSON模块导入语法也进行了调整,但未改变其他逻辑或控制流。

Changes

文件路径 更改摘要
.github/workflows/ci.yml 更新node-version20.x22.x,影响所有使用Node.js的CI作业。
.github/workflows/lerna-version.yml 更新node-version20.x22.x,影响Lerna版本命令的执行环境。
.github/workflows/update-docs-etc.yml 更新node-version20.x22.x,影响Node.js相关作业的执行环境。
.nvmrc 更新Node.js版本从2022
package.json 更新@types/node依赖版本从^20.16.2^22.9.0
packages/brick-container/build.config.js 更新JSON模块导入语法,从assert语法更改为with语法。

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/brick-container/build.config.js

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "@next-core/eslint-config-next" to extend from. Please check that the name of the config is correct.

The config "@next-core/eslint-config-next" was referenced from the config file in "/.eslintrc".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


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

Copy link

cypress bot commented Nov 19, 2024

next-core    Run #10790

Run Properties:  status check passed Passed #10790  •  git commit b24cb51bde ℹ️: Merge 5d3a7c0b957e9beb4f1bcf1175a99f6612ae1975 into 62daee3c6ea1f6d0767c3516b72f...
Project next-core
Branch Review steve/v3-node-22
Run status status check passed Passed #10790
Run duration 00m 23s
Commit git commit b24cb51bde ℹ️: Merge 5d3a7c0b957e9beb4f1bcf1175a99f6612ae1975 into 62daee3c6ea1f6d0767c3516b72f...
Committer Shenwei Wang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 16
View all changes introduced in this branch ↗︎

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)
.github/workflows/update-docs-etc.yml (1)

Line range hint 71-74: 构建命令的回退机制需要优化

当前的构建命令使用了 || 操作符作为回退机制:

npx lerna run build --scope @next-core/types || npx lerna run docs:dev --scope @next-core/types

这种实现方式存在以下问题:

  • 如果 build 命令因非致命错误失败,可能会静默转向执行 docs:dev
  • 难以区分是正常执行了 build 还是触发了回退机制
  • 缺少错误日志记录

建议:

  1. 分别执行构建和文档生成,清晰记录每个步骤的结果
  2. 添加适当的错误处理和日志记录
- npx lerna run build --scope @next-core/types || npx lerna run docs:dev --scope @next-core/types
- npx lerna run build --scope @next-core/runtime || npx lerna run docs:dev --scope @next-core/runtime
+ # 首先尝试构建
+ npx lerna run build --scope @next-core/types
+ BUILD_TYPES_EXIT_CODE=$?
+ if [ $BUILD_TYPES_EXIT_CODE -ne 0 ]; then
+   echo "构建 @next-core/types 失败,尝试生成文档..."
+   npx lerna run docs:dev --scope @next-core/types
+ fi
+ 
+ npx lerna run build --scope @next-core/runtime
+ BUILD_RUNTIME_EXIT_CODE=$?
+ if [ $BUILD_RUNTIME_EXIT_CODE -ne 0 ]; then
+   echo "构建 @next-core/runtime 失败,尝试生成文档..."
+   npx lerna run docs:dev --scope @next-core/runtime
+ fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 62daee3 and 5d3a7c0.

⛔ Files ignored due to path filters (2)
  • packages/inject/src/__snapshots__/syntax.spec.ts.snap is excluded by !**/*.snap
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/lerna-version.yml (1 hunks)
  • .github/workflows/update-docs-etc.yml (1 hunks)
  • .nvmrc (1 hunks)
  • package.json (1 hunks)
  • packages/brick-container/build.config.js (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .nvmrc
  • packages/brick-container/build.config.js
🔇 Additional comments (3)
.github/workflows/lerna-version.yml (1)

12-12: 建议验证 Node.js 22 的兼容性问题

Node.js 22 目前仍处于开发版本,尚未成为 LTS 版本。建议:

  1. 验证 Lerna 是否完全支持 Node.js 22
  2. 考虑使用当前的 LTS 版本(如 Node.js 20)以确保稳定性
✅ Verification successful

Let me check Lerna's official documentation and requirements by searching through the repository.


Let me check Lerna's official repository for Node.js 22 compatibility.


Node.js 22 升级可以继续进行

基于验证结果:

  1. Lerna 最新版本 (8.1.9) 没有特定的 Node.js 版本限制
  2. 项目中的其他工作流文件也已统一使用 Node.js 22
  3. 项目的 package.json 中的 engines 要求仅为 ">=16",完全兼容 Node.js 22

这个升级是安全的,可以继续进行。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check Lerna's compatibility with Node.js 22

# Check package.json for Lerna version and engine requirements
rg -A 5 '"lerna":' package.json

# Check for any Node.js version constraints in lerna.json
cat lerna.json 2>/dev/null || echo "lerna.json not found"

Length of output: 606


Script:

#!/bin/bash
# Check if there are any engine requirements in package.json
rg -A 5 '"engines":' package.json

# Search for any Node.js version related configurations or documentation
fd README.md --exec cat {} \; 

# Check if there are any Node.js version constraints in workspace packages
fd package.json --exec rg -A 5 '"engines":' {} \;

Length of output: 6372


Script:

#!/bin/bash
# Check Lerna's changelog or recent releases for Node.js 22 support
curl -s "https://api.github.com/repos/lerna/lerna/releases/latest" | jq -r '.body' || echo "Failed to fetch Lerna releases"

# Check if there are any direct dependencies on Node.js version in Lerna-related configurations
rg -g '*.json' -g '*.yml' -g '*.yaml' 'node' .github/workflows/

Length of output: 2683

.github/workflows/update-docs-etc.yml (1)

14-14: 需要评估使用 Node.js 22.x 版本的风险

Node.js 22.x 目前仍处于开发版本,尚未成为 LTS(长期支持)版本。在生产环境的 CI/CD 流程中使用非 LTS 版本可能会带来以下风险:

  • 潜在的不稳定性和兼容性问题
  • 缺乏长期的安全更新支持
  • 社区工具和包的兼容性可能不完整

建议:

  1. 确认是否有必要现在就升级到 Node.js 22
  2. 考虑是否应该等待 Node.js 22 成为 LTS 版本后再升级
  3. 确保所有依赖包都已经完全支持 Node.js 22
✅ Verification successful

Node.js 22.x 的使用是合理的

基于代码分析结果,使用 Node.js 22.x 是合适的:

  1. 项目的所有工作流都已统一使用 Node.js 22.x

  2. package.json 中的依赖已经更新到支持 Node.js 22 的版本:

    • TypeScript ^5.6.2
    • webpack ^5.94.0
    • 其他核心依赖也都更新到最新版本
  3. 项目的 engines 字段要求普遍为 "node": ">=16",完全兼容 Node.js 22

这个升级是经过充分准备的,不会带来兼容性问题。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查工作流中使用的主要 action 是否支持 Node.js 22
gh api graphql -f query='
{
  repository(owner: "actions", name: "setup-node") {
    releases(first: 1) {
      nodes {
        description
        body
      }
    }
  }
}'

Length of output: 466


Script:

#!/bin/bash
# 检查工作流文件中使用的所有 actions
rg "uses:" .github/workflows/update-docs-etc.yml -A 1

# 检查 package.json 中的依赖版本要求
fd package.json --exec cat {} \; 

# 检查其他工作流文件中使用的 Node.js 版本
rg "node-version:" .github/workflows/

Length of output: 48842

package.json (1)

54-54: 需要验证依赖兼容性

@types/node 升级到 ^22.9.0 是向 Node.js 22 迁移的一部分。由于 Node.js 22 目前尚未进入 LTS 状态,建议:

  1. 验证所有依赖包与 Node.js 22 的兼容性
  2. 确保在升级后进行全面的测试覆盖
  3. 评估使用非 LTS 版本的潜在风险
✅ Verification successful

Based on the output, I can now generate the final response since we have comprehensive information about the Node.js version requirements of all dependencies.

建议谨慎评估依赖兼容性

从依赖分析结果来看,大多数包都设置了较为宽松的版本要求(如 >=8>=10 等),理论上支持 Node.js 22。但需要注意以下几点:

  • 一些关键测试相关的包(如 jest 系列)要求 ^14.15.0 || ^16.10.0 || >=18.0.0,表明它们已经过 Node.js 18+ 的测试
  • 部分工具包(如 typescript)明确要求 >=14.17,与 Node.js 22 兼容
  • 没有发现任何依赖包明确排除或不支持 Node.js 22

基于以上分析,升级 @types/node 到 22.x 版本是可行的,但由于 Node.js 22 尚未进入 LTS,建议:

  • 在开发环境中进行充分的测试验证
  • 特别关注 Jest 测试套件的运行情况
  • 密切关注依赖包的更新,确保它们正式支持 Node.js 22
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查依赖包的 Node.js 版本要求

# 获取所有依赖的 package.json
fd package.json node_modules -x cat {} | jq -r 'select(.engines?.node != null) | "\(.name): \(.engines.node)"'

# 检查是否有明确指定不支持 Node.js 22 的依赖
fd package.json node_modules -x grep -l "\"node\":" {} | xargs cat | jq -r 'select(.engines?.node != null and (.engines.node | contains("22") | not)) | "\(.name): \(.engines.node)"'

Length of output: 11133

@@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

建议调整 Node.js 版本要求并进行分阶段迁移

根据代码库分析,所有包的 engines 字段都指定了 Node.js 版本要求为 ">=16"。直接升级到 Node.js 22.x 可能过于激进,建议:

  • 先将 engines 字段中的 Node.js 版本要求更新为与 CI 一致
  • 在 CI 配置中采用矩阵策略同时测试多个 Node.js 版本(如 20.x 和 22.x)
  • 待所有依赖包完全兼容 Node.js 22.x 后再完全迁移

示例配置:

strategy:
  matrix:
    node-version: [20.x, 22.x]
🔗 Analysis chain

建议验证 Node.js 22.x 的兼容性和稳定性

Node.js 22.x 版本较新,建议:

  1. 确认所有依赖包和构建工具与 Node.js 22.x 的兼容性
  2. 考虑在过渡期间同时支持 20.x 和 22.x,以确保平稳迁移
  3. 验证在新版本下所有 CI 任务的稳定性
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查项目依赖对 Node.js 22 的支持情况

# 检查 package.json 中的 engines 字段
rg '"engines"' -A 5

# 检查是否有明确指定 Node.js 版本要求的依赖
rg '"node":' package.json packages/*/package.json

Length of output: 3457

@weareoutman weareoutman requested a review from Copilot November 20, 2024 01:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 suggestion.

Files not reviewed (3)
  • .nvmrc: Language not supported
  • package.json: Language not supported
  • packages/inject/src/snapshots/syntax.spec.ts.snap: Language not supported

@@ -4,7 +4,7 @@ import { createRequire } from "node:module";
import HtmlWebpackPlugin from "html-webpack-plugin";
import CopyPlugin from "copy-webpack-plugin";
import webpack from "webpack";
import packageJson from "./package.json" assert { type: "json" };
import packageJson from "./package.json" with { type: "json" };
Copy link
Preview

Copilot AI Nov 20, 2024

Choose a reason for hiding this comment

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

The import assertion syntax is incorrect. It should be 'assert { type: "json" }' instead of 'with { type: "json" }'.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Member Author

Choose a reason for hiding this comment

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

import assert is deprecated, now we should use import with.

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.

1 participant