Skip to main content

介绍

¥Introduction

Lerna 是 JavaScript/TypeScript 的独创 大仓工具。它已经存在很多年了,被数以万计的项目使用,包括 React 和 Jest。

¥Lerna is the original monorepo tool for JavaScript/TypeScript. It has been around for many years and is used by tens of thousands of projects, including React and Jest.

它解决了 JavaScript/TypeScript 大仓的两个最大问题:

¥It solves two of the biggest problems of JavaScript/TypeScript monorepos:

  • Lerna 对任意数量的项目运行命令,它以最有效的方式、以正确的顺序执行,并且可以将其分发到多台计算机上。

    ¥Lerna runs a command against any number of projects, and it does it in the most efficient way, in the right order, and with the possibility to distribute that on multiple machines.

  • Lerna 管理你的发布流程,从版本管理到发布到 NPM,它提供了多种选项以确保可以适应任何工作流程。

    ¥Lerna manages your publishing process, from version management to publishing to NPM, and it provides a variety of options to make sure any workflow can be accommodated.

Nx(同名开源构建系统背后的公司)已经接管了 Lerna 的管理Nx 是由前 Google 员工开发的构建系统,利用了 Google 内部工具使用的许多技术。Lerna v5 是这个新管理下的第一个版本,更新了过时的软件包并开始对存储库本身进行一些清理。从 v6+ 开始,Lerna 将任务调度工作委托给 Nx 经过考验的行业领先的任务运行程序,这意味着 lerna run 免费获得缓存和命令分发的好处!

¥Nx (the company behind the open source build system of the same name) has taken over stewardship of Lerna. Nx is a build system developed by ex-Googlers and utilizes many of the techniques used by internal Google tools. Lerna v5 was the first release under this new stewardship, updating outdated packages and starting to do some cleanup on the repository itself. Starting with v6+, Lerna delegates task scheduling work to Nx's battle tested, industry-leading task runner, meaning lerna run gets the benefits of caching and command distribution for free!

为什么使用 Lerna?

¥Why Lerna?

  • 超级快!Lerna 速度很快,甚至比大多数同类解决方案还要快(查看这个基准 了解更多)。如何?在引擎盖下,Lerna v6+ 使用 Nx 运行任务。了解有关 在这里运行任务 的更多信息。

    ¥Super Fast! Lerna is fast, even faster than most comparable solutions out there (see this benchmark to learn more). How? Under the hood, Lerna v6+ uses Nx to run tasks. Learn more about running tasks here.

  • 计算缓存 - Lerna 知道你要运行的任务过去何时执行过。Lerna 将恢复文件并立即重播终端输出,而不是运行它。另外,此缓存可以与你的同事和 CI 共享。使用 Lerna 时,你的整个组织将永远不必构建或测试同一事物两次。阅读更多 ”

    ¥Computation Caching - Lerna knows when the task you are about to run has been executed in the past. Instead of running it, Lerna will restore the files and replay the terminal output instantly. Plus, this cache can be shared with your co-workers and CI. When using Lerna, your whole organization will never have to build or test the same thing twice. Read more »

  • 免配置分布式任务执行 Lerna 可以在多台机器上分发任何命令,无需任何配置,同时保留在单台机器上运行它的开发人机工程学。换句话说,使用 Lerna 扩展大仓就像启用布尔标志一样简单。查看启用 DTE 如何使 CI 速度提高 20 倍的示例。阅读更多 ”

    ¥Configuration-Free Distributed Task Execution Lerna can distribute any command across multiple machines without any configuration, while preserving the dev ergonomics of running it on a single machine. In other words, scaling your monorepo with Lerna is as simple as enabling a boolean flag. See the examples of how enabling DTE can make you CI 20 times faster. Read more »

  • 美丽的终端输出 Monorepos 可以有数百或数千个项目。打印每个命令的所有内容使得很难看出失败的原因和失败的原因。值得庆幸的是,Lerna 做得更好。

    ¥Beautiful Terminal Output Monorepos can have hundreds or thousands of projects. Printing everything on every command makes it hard to see what fails and why. Thankfully, Lerna does a much better job.

  • 强大的图形可视化工具 Lerna 配备了强大的交互式可视化工具,可简化你对工作区的理解。阅读更多 ”

    ¥Powerful Graph Visualizer Lerna comes with a powerful interactive visualizer simplifying the understanding of your workspaces. Read more »

  • 发布到 NPM Lerna 是将多个包发布到 npm 的终极工具。无论这些软件包是否有独立版本,Lerna 都能满足你的需求。阅读更多 ”

    ¥Publishing to NPM Lerna is the ultimate tool for publishing multiple packages to npm. Whether the packages have independent versions or not, Lerna has you covered. Read more »

  • 易于采用 即使具有所有这些功能,Lerna 也非常易于采用。它需要接近于零的配置。想看看如何?

    ¥Easy to Adopt Even with all these capabilities, Lerna is very easy to adopt. It requires close-to-zero configurations. Want to see how?