了解你的仓库
Turborepo 包含用于理解存储库结构的工具,可帮助你使用和优化代码库。
¥Turborepo includes tools for understanding your repository structure, that can help you use and optimize your codebase.
turbo ls
要列出你的软件包,你可以运行 turbo ls
。这将显示存储库中的软件包及其位置。
¥To list your packages, you can run turbo ls
. This will show the packages in your repository and where they're located.
你可以将 应用过滤器 更改为 ls
,就像 run
一样:
¥You can apply filters to ls
, just like run
:
turbo run
要确定哪些任务可以在你的 monorepo 中运行,只需调用 turbo run
而不执行任何任务即可。你将获得一个任务列表以及定义这些任务的包:
¥To determine which tasks can be run in your monorepo, simply call turbo run
without any tasks. You will get a list of
tasks and the packages in which they are defined:
turbo query
如果你想深入了解你的代码库结构,自 2.2.0
以来,Turborepo 通过 turbo query
为你的代码库提供了一个 GraphQL 接口。你可以执行查询,例如查找所有包含 test
任务的包:
¥If you wish to dig into your repository structure, since 2.2.0
, Turborepo provides a GraphQL interface into your repository
via turbo query
. You can execute queries such as finding all packages that have a test
task:
这有助于诊断包或任务依赖图中的潜在问题。例如,假设你在构建过程中遇到很多缓存未命中。这可能是因为有一个包不断发生变化,并被导入到你的整个代码库中。
¥This can be helpful for diagnosing potential problems in your package or task dependency graph. For instance, let's say you're getting a lot of cache misses in your builds. This could be because there's a package that keeps getting changed and is imported throughout your codebase.
为此,我们可以运行查询来查找 monorepo 中直接导入超过 10 次的包:
¥To do this, we can run a query to find packages that are directly imported more than 10 times in your monorepo:
现在我们已经找到了这个包,我们可以尝试将其拆分成更小的包,这样微小的更改就不会使整个依赖图失效。
¥Now that we've found this package, we can try to split it up into smaller packages so that a small change won't invalidate the whole dependency graph.
或者假设你正在使用我们新的 --affected
标志,但仍然运行着超出预期的任务。使用 turbo query
,你可以找到所有软件包及其失效的原因:
¥Or let's say you're using our new --affected
flag, but you're still running more tasks than you'd like.
With turbo query
, you can find all the packages and the reason why they were invalidated: