generate

使用新的应用和包扩展你的 Turborepo。

¥Extend your Turborepo with new apps and packages.

Terminal
turbo generate

更多有关编写自定义生成器的信息和实际用例,请访问 "生成代码" 指南

¥For more information and practical use cases for writing custom generators, visit the "Generating code" guide.

Good to know: 

turbo genturbo generate 的别名。此外,run 是默认命令,因此 turbo gen 等同于 turbo generate run

¥turbo gen is an alias for turbo generate. Additionally, run is the default command so turbo gen is equivalent to turbo generate run.

run [generator-name]

运行你仓库中定义的自定义生成器。

¥Run custom generators defined in your repository.

Terminal
turbo gen run [generator-name]

标志选项

¥Flag options

--args

直接传递给生成器提示的答案。

¥Answers to pass directly to the generator's prompts.

--config <path>

生成器配置文件。

¥Generator configuration file.

默认:turbo/generators/config.js

¥Default: turbo/generators/config.js

--root <path>

仓库的根目录

¥The root of your repository

默认:根目录为 turbo.json

¥Default: directory with root turbo.json

workspace

创建一个新的工作区。

¥Create a new workspace.

Terminal
turbo gen workspace [options]

标志选项

¥Flag options

--name <name>

package.json name 键中要使用的新工作区名称。name 键是仓库中软件包的唯一标识符。

¥The name for the new workspace to be used in the package.json name key. The name key is the unique identifier for the package in your repository.

--empty

创建一个空的工作区。默认为 true

¥Creates an empty workspace. Defaults to true.

--copy <name>/<url>

monorepo 中的本地工作区名称,或包含任何分支和/或子目录的完整 GitHub URL。

¥Name of local workspace within your monorepo or a fully qualified GitHub URL with any branch and/or subdirectory.

--destination <path>

应在何处创建新的工作区。

¥Where the new workspace should be created.

--type <app/package>

要创建的工作区类型(apppackage)。

¥The type of workspace to create (app or package).

--root <path>

仓库的根目录。默认为根目录 turbo.json 目录。

¥The root of your repository. Defaults to the directory of the root turbo.json.

--show-all-dependencies

选择要添加的依赖时,避免按工作区类型筛选依赖。

¥Prevent filtering dependencies by workspace type when selecting dependencies to add.

--example-path <path>, -p <path>

在极少数情况下,你的 GitHub URL 可能包含带斜杠的分支名称(例如 bug/fix-1)和示例路径(例如 foo/bar)。在这种情况下,你必须单独指定示例的路径。

¥In a rare case, your GitHub URL might contain a branch name with a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar). In this case, you must specify the path to the example separately.