@turbo/codemod

Turborepo 提供 codemod 转换和自动迁移脚本,以便在某个功能弃用时帮助你升级 Turborepo 代码库。

¥Turborepo provides codemod transformations and automatic migration scripts to help upgrade your Turborepo codebase when a feature is deprecated.

Codemod 是以编程方式在代码库上运行的转换。这允许应用大量更改,而无需手动管理重复更改。

¥Codemods are transformations that run on your codebase programmatically. This allows for a large amount of changes to be applied without having to manually manage repetitive changes.

用法

¥Usage

首先,确保你已经运行了包管理器的安装命令。

¥First, ensure that you've run your package manager's install command.

Terminal
npx @turbo/codemod [transform] [path] [--dry] [--print]
  • transform - 转换名称,请参阅下文可用的转换。

    ¥transform - name of transform, see available transforms below.

  • path - 要转换的文件或目录

    ¥path - files or directory to transform

  • --dry - 进行试运行(代码不会被编辑)

    ¥--dry - Do a dry-run (Code will not be edited)

  • --print - 打印更改后的输出以供比较

    ¥--print - Prints the changed output for comparison

升级 Turborepo 版本

¥Upgrading Turborepo versions

在大多数情况下,你可以运行:

¥In most cases, you can run:

Terminal
npx @turbo/codemod

所有升级所需的 codemod 都将为你运行。

¥All the codemods you need to upgrade will be run for you.

Turborepo 2.x

以下 codemod 用于 Turborepo 第二个主要版本中的迁移路径。

¥The codemods below are used for migration paths in the second major version of Turborepo.

Turborepo 1.x

以下 codemod 用于 Turborepo 第一个主要版本中的迁移路径。

¥The codemods below are used for migration paths in the first major version of Turborepo.