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

Turborepo 2.1 #13

Open
innocces opened this issue Sep 12, 2024 · 4 comments
Open

Turborepo 2.1 #13

innocces opened this issue Sep 12, 2024 · 4 comments

Comments

@innocces
Copy link
Contributor

innocces commented Sep 12, 2024

The original blog info

subject content
title Turborepo 2.1
url blog url
author Tom Knickman
@innocces innocces changed the title [Recorder]: Turborepo 2.1 Turborepo 2.1 Sep 12, 2024
@innocces
Copy link
Contributor Author

innocces commented Sep 12, 2024

Turborepo 2.1

Tuesday, August 27th, 2024

Tom Knickman

Name

Tom Knickman

X

@tknickman

Anthony Shew

Name

Anthony Shew

X

@anthonysheww

Chris Olszewski

Name

Chris Olszewski

Nicholas Yang

Name

Nicholas Yang

X

@nicholaslyang

Dimitri Mitropoulos

Name

Dimitri Mitropoulos

Turborepo 2.1 improves integration with your repository, with features like:

Update today by running npx @turbo/codemod migrate or get started with npx create-turbo@latest.

Run tasks for changed packages with --affected

Turborepo’s Remote Caching shares a single cache across all of your machines, so you never have to do the same work twice. But, what if you could ignore unchanged packages altogether?

You can now use the --affected flag with turbo run to automatically target packages with changes between the latest commit of your current branch, and the default branch of your repository (usually main or master). turbo will use your Package Graph to ensure tasks are run for packages with direct changes or changes to internal dependencies.

Terminal

turbo run lint test --affected

You'll want to use this flag in situations like:

  • You're running many tasks across packages in your monorepo, and only want to run those tasks in packages with code changes.
  • You’re not using a Remote Cache, but still want to do as little work as possible in CI.
  • You are using a Remote Cache, and you’re in a large repository. By minimizing the amount of tasks that will be restored from cache, there will be less data to send across the network, resulting in faster cache restoration.
  • You’re already using advanced filtering techniques or turbo-ignore to create the same or similar behavior as --affected. You likely have the opportunity to simplify your scripting using this new flag.

To learn more, visit the documentation.

Repository exploration tools

As a repository grows and changes, it can be difficult to quickly find what you’re looking for. We want to quickly surface your tasks, packages, and their relationships to make understanding your repository faster and easier.

turbo run

Use turbo run (with no task arguments) to get a list of the available tasks in your repository. This command also works with filters and Automatic Package Scoping.

Terminal

# List all tasks in the repository
turbo run
 
# List tasks in a specific package
turbo run --filter=@repo/ui
 
# Using Automatic Package Scoping
cd packages/ui && turbo run

Visit the documentation to learn more.

turbo ls

Use turbo ls to get a list of all the packages in your repository with their locations, or filter to a specific package to see a summary of its internal dependencies and tasks. turbo ls also supports --filter, and --affected, making it easy to gather a list of changed packages.

Terminal

# List all packages in the repository
turbo ls
 
# List dependencies and tasks for the `web` package
turbo ls web
 
## List affected packages
turbo ls --affected

turbo ls supports an experimental --output flag that can be used to return results in a specific format. For example, --output=json can be used to more easily create inputs for other tools or custom scripts. If you were previously using turbo build --dry=json only to retrieve a list of changed packages, give turbo ls --affected --output=json a try. Visit the docs for more information and leave feedback on output format on the turbo ls RFC.

Visit the documentation to learn more.

Terminal UI Improvements

In Turborepo 2.0, we released a new terminal UI to improve clarity for logs and allow for interactive tasks in local development. We heard your feedback, and prioritized polishing this UI, releasing improvements in patches to 2.0 and in this 2.1 release:

  • Highlighting of logs for copying to clipboard (PR)
  • Search through task list (PR)
  • Cleaner layout resizing when your terminal changes size (PR)
  • New icon for cache hits in task list (PR)
  • Task status indicators updated when Watch Mode triggers a restart (PR)
  • Output logs are respected after the terminal UI exits (PR)

Building a great terminal UI experience has unique challenges, and we’re continuing to iterate on this experience. We appreciate your continued feedback as we keep up our work on creating great UI for monorepos.

Expanded configuration options

In this release, we’re adding more keys to turbo.json to give you more flexibility for your repository’s defaults. The following keys are new in this release:

turbo.json

{
  "envMode": "loose",
  "daemon": false,
  "cacheDir": "./my-custom-directory/"
}

You may have been using the flag equivalents for these configurations on many or all of your turbo invocations, littering your codebase with commands like:

Terminal

turbo run build --env-mode=loose --no-daemon --cache-dir=./my-custom-directory

These can now be simplified with a centralized configuration in turbo.json using Turborepo’s existing configuration model:

  • turbo.json sets the defaults for your repository.
  • System environment variables customize behavior in a specific environment.
  • Flags customize behavior for specific invocations of turbo.

To learn more about available options and configurations, visit the documentation.

Other improvements

  • We’d like to especially thank Shaharking for their contribution in #9023 to make the colors for task names in streamed UIs deterministic, closing #2564. This makes it easier to compare tasks across turbo run invocations.

View the full changelog at vercel/turborepo.

@innocces
Copy link
Contributor Author

innocces commented Sep 12, 2024

Turborepo 2.1

2024 年 8 月 27 日星期二

汤姆·尼克曼

姓名

汤姆·尼克曼

X

@tknickman

安东尼·肖

姓名

安东尼·休

X

@anthonysheww

![Chris Olszewski](https://turbo.build/_next/image?url=%2Fimages%2Fpeople%2Fchrisolszewski.jpg\&w=64\&q=75\&dpl=dpl\_HSYkLo975h5aVF6crYFmydUwHfpr“Chris Olszewski”)

姓名

克里斯·奥尔谢夫斯基

尼古拉斯·杨

姓名

尼古拉斯·杨

X

@nicholaslyang

迪米特里·米特罗普洛斯

姓名

迪米特里·米特罗普洛斯

Turborepo 2.1 改进了与存储库的集成,具有以下功能:

今天通过运行“npx @turbo/codemod migrate”进行更新或开始使用“npx create-turbo@latest”。

使用 --affected 运行已更改包的任务

Turborepo 的远程缓存 在所有计算机上共享一个缓存,因此您不必重复执行相同的工作。但是,如果您可以完全忽略未更改的包怎么办?

现在,您可以将“--affected”标志与“turbo run”一起使用,自动定位当前分支的最新提交与存储库的默认分支(通常是“main”或“master”)之间发生更改的包。 turbo 将使用您的包图来确保为直接更改或内部依赖项更改的包运行任务。

终端

[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport] ::-webkit-scrollbar{显示:无}

turbo run lint test --affected

您需要在以下情况下使用此标志:

  • 您正在 monorepo 中跨包运行许多任务,并且只想在代码更改的包中运行这些任务。
  • 使用远程缓存,但仍然希望在 CI 中做尽可能少的工作。
  • 正在使用远程缓存,并且您位于一个大型存储库中。通过最大限度地减少从缓存恢复的任务量,通过网络发送的数据将会减少,从而加快缓存恢复速度。
  • 您已经在使用 高级过滤技术turbo-ignore 来创建与“--affect”相同或相似的行为。您可能有机会使用这个新标志来简化脚本编写。

要了解更多信息,请访问文档

存储库探索工具

随着存储库的增长和变化,快速找到您要查找的内容可能会很困难。我们希望快速显示您的任务、包及其关系,以便更快、更轻松地理解您的存储库。

涡轮运行

使用“turbo run”(不带任务参数)获取存储库中可用任务的列表。此命令还适用于 filters 和 [自动包范围](/repo/docs/crafting-your-repository/running-tasks#自动包范围)。

终端

[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport] ::-webkit-scrollbar{显示:无}

# List all tasks in the repository
turbo run
 
# List tasks in a specific package
turbo run --filter=@repo/ui
 
# Using Automatic Package Scoping
cd packages/ui && turbo run

访问文档 了解更多信息。

turbo ls

使用“turbo ls”获取存储库中所有包及其位置的列表,或过滤到特定包以查看其内部依赖项和任务的摘要。 turbo ls 还支持 --filter--affected,可以轻松收集已更改包的列表。

终端

[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport] ::-webkit-scrollbar{显示:无}

# List all packages in the repository
turbo ls
 
# List dependencies and tasks for the `web` package
turbo ls web
 
## List affected packages
turbo ls --affected

turbo ls 支持实验性的 --output 标志,可用于以特定格式返回结果。例如,“--output=json”可用于更轻松地为其他工具或自定义脚本创建输入。如果您之前使用“turbo build --dry=json”来检索已更改包的列表,请尝试“turbo ls --affected --output=json”。请访问文档以获取更多信息,并在 turbo ls RFC 上留下有关输出格式的反馈。

访问文档 了解更多信息。

终端 UI 改进

在 Turborepo 2.0 中,我们发布了新的终端 UI,以提高日志的清晰度并允许在本地开发中执行交互式任务。我们听取了您的反馈,并优先完善此 UI,发布 2.0 补丁和 2.1 版本中的改进:

  • 突出显示日志以复制到剪贴板 (PR)
  • 搜索任务列表 (PR)
  • 当终端改变大小时,布局调整更清晰(PR
  • 任务列表中缓存命中的新图标 (PR)
  • 当监视模式触发重启时更新任务状态指示器 (PR)
  • 终端 UI 退出后会尊重输出日志 (PR)

构建出色的终端 UI 体验具有独特的挑战,我们将继续迭代这种体验。我们感谢您持续提供的反馈,我们将继续努力为 monorepos 创建出色的 UI。

扩展配置选项

在此版本中,我们向“turbo.json”添加了更多键,以便为存储库的默认设置提供更大的灵活性。此版本中新增了以下键:

涡轮.json

[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport] ::-webkit-scrollbar{显示:无}

{
  "envMode": "loose",
  "daemon": false,
  "cacheDir": "./my-custom-directory/"
}

您可能在许多或所有“turbo”调用中使用了这些配置的等效标志,从而在代码库中散布了以下命令:

终端

[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport] ::-webkit-scrollbar{显示:无}

turbo run build --env-mode=loose --no-daemon --cache-dir=./my-custom-directory

现在可以使用 Turborepo 的现有配置模型通过“turbo.json”中的集中配置来简化这些:

  • turbo.json 设置存储库的默认值。
  • 系统环境变量 自定义特定环境中的行为。
  • 标志定制“turbo”特定调用的行为。

要了解有关可用选项和配置的更多信息,请访问文档

其他改进

  • 我们要特别感谢 Shaharking#9023 中做出的贡献,使流式 UI 中任务名称的颜色是确定性的,关闭 #2564。这使得比较“turbo run”调用之间的任务变得更加容易。

vercel/turborepo 查看完整的变更日志。

@innocces
Copy link
Contributor Author

emmm~ 整体上还是没处理 race command 的问题。 继续观望吧。

@innocces
Copy link
Contributor Author

不过新的 terminal 是真的 him 不错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant