用户空间迁移
¥Userland Migrations
Node.js 为 "userland" 代码(Node 可执行文件之外的任何代码)提供迁移,以帮助采用新功能并处理重大变更。这些功能是与 Codemod 合作开发的,Codemod 是一个专注于简化代码转换构建、共享和运行的平台。
¥Node.js offers migrations for "userland" code (anything outside the node executable) to help adopt new features and handle breaking changes. These are built in collaboration with Codemod, a platform focused on making it easy to build, share, and run codemods.
官方迁移发布在 Codemod 注册表 的 @nodejs 范围内。这些内容已由 Node.js 成员审阅和/或撰写。
¥Official migrations are published under the @nodejs scope within the Codemod registry. These have been reviewed and/or authored by Node.js members.
目标
¥Goal
Node.js 用户空间迁移团队致力于帮助开发者将其代码库迁移到最新的 Node.js 版本,从而更轻松地处理弃用、新功能和重大变更。
¥The Node.js Userland Migrations team seeks to help developers migrate their codebases to the latest Node.js versions, making it easier to handle deprecations, new features, and breaking changes.
如何使用 Codemod
¥How to use a codemod
要使用代码转换,你可以在终端中运行以下命令:
¥To use a codemod, you can run the following command in your terminal:
npx codemod <codemod-name>
将 <codemod-name> 替换为你要运行的代码转换工具的名称。例如,如果你想在项目中运行 @nodejs/import-assertions-to-attributes 代码转换工具,你可以运行:
¥Replace <codemod-name> with the name of the codemod you want to run. For example, if you want to run the @nodejs/import-assertions-to-attributes codemod on your project, you would run:
npx codemod @nodejs/import-assertions-to-attributes
最佳实践
¥Good Practices
-
在单独的分支中运行迁移:如果你使用 Git 等版本控制系统,最佳实践是在单独的分支中运行迁移。这允许你在将更改合并到主分支之前进行审查。
¥Run migrations in a separate branch: If you are using a version control system like Git, it is a good practice to run migrations in a separate branch. This allows you to review the changes before merging them into your main branch.
-
查看更改:运行迁移后,请检查代码库的更改。确保迁移没有引入任何意外的副作用或问题。
¥Review changes: After running a migration, review the changes made to your codebase. Ensure that the migration has not introduced any unintended side effects or issues.
-
测试你的代码:运行迁移后,务必测试代码,确保一切运行正常。运行你的测试套件并检查是否存在任何错误或故障
¥Test your code: After running a migration, it is important to test your code to ensure that everything is working as expected. Run your test suite and check for any errors or failures
-
格式化或检查你的代码:运行迁移后,最好格式化并检查代码。这确保你的代码遵循项目的编码标准,并且更易于阅读和维护。
¥Format and or lint your code: After running a migration, it is a good practice to format and lint your code. This ensures that your code follows the project's coding standards and is easier to read and maintain.
了解 Codemod 注册表
¥Understanding Codemods Registry
Codemod 注册表 提供了一个适用于 Node.js 的可用代码转换列表。某些代码转换工具可能未包含在以下资源中,但仍然可用,因为它们与特定 Node.js 版本的迁移无关。由于我们仅列出生命周期结束 (EOL) 弃用的代码转换工具,你可能需要浏览注册表以查找其他可能对你的迁移有用的代码转换工具。
¥The Codemod registry provides a list of available codemods for Node.js. Some codemods may not be included in the following resources but are still available because they are not related to a specific migration to a Node.js version. Since we only list codemods for End-Of-Life (EOL) deprecations, you may need to explore the registry for other codemods that could be useful for your migrations.
请注意,如果你已登录 Codemod 平台,则可以点赞这些帖子。这有助于我们了解用户认为哪些内容有价值。
¥Please note that if you are logged into the Codemod platform, you can like these posts. This helps us to see what users find valuable.
反馈
¥Feedback
如果你有任何反馈或改进建议,请在 Node.js 用户空间迁移仓库 上发起讨论。
¥If you have any feedback or suggestions for improvements, please open a discussion on the Node.js Userland Migrations repository.
关注用户空间迁移进度
¥Follow the Userland Migrations Progression
你可以在我们的 GitHub 项目看板 上跟踪用户级迁移的进度。
¥You can follow the progress of userland migrations on our GitHub project board.
此看板跟踪:
¥This board tracks:
-
代码修改类型(已弃用、重大变更、生态系统)
¥Codemod kind (deprecation, breaking change, ecosystem)
-
Node.js 版本
¥Node.js version
-
状态(待办事项、待办、进行中、已完成、未计划)如果你想贡献代码,请查看 "todo" 列
¥Status (backlog, todo, in progress, done, not planned) If you want to contribute, please check the "todo" column
迁移指南
¥Migrations guides
你可以在 迁移指南部分 上找到所有迁移指南。
¥You can find all migrations guide on the migration guides section.
另请注意,主版本升级的迁移指南仅包含已停止维护的 deprecations 版本和重大变更。
¥Please also note that migration guides for major-major releases only contain end-of-life deprecations and breaking changes.