Lerna 和 Nx
¥Lerna and Nx
Nrwl(开源构建系统 Nx 背后的公司)已经接管了 Lerna 的管理。Nx 是由前 Google 员工开发的构建系统,利用了 Google 内部工具使用的许多技术。Lerna 使用 Nx 来检测工作区中的包以及它们之间的依赖。Lerna 遵循 Nx 强大的任务运行程序来运行脚本,允许你并行运行它们、缓存结果并将它们分发到多台计算机上,同时确保尊重包之间的依赖。有关哪些 Lerna 版本与哪些 Nx 版本兼容的完整列表,请参阅 Lerna 和 Nx 版本矩阵。
¥Nrwl (the company behind the open source build system Nx) 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 uses Nx to detect packages in the workspace and dependencies between them. Lerna defers to Nx's powerful task runner to run scripts, allowing you to run them in parallel, cache results, and distribute them across multiple machines, all while ensuring that dependencies between packages are respected. For a complete list of which Lerna versions are compatible with which Nx versions, see the Lerna and Nx Version Matrix.
以下是每个工具提供的功能的高级概述。Lerna 可以继续单独使用,并且免费添加 Nx Cloud 可以极大地改进你已经在做的事情。
¥The following is a high level overview of what each tool provides. Lerna can continue to be used by itself, and adding Nx Cloud for free on top can dramatically improve what you're already doing.
Lerna
特性
¥Features
-
版本 - 自动增加包的版本、生成变更日志信息、创建 Github 版本等。
¥Version - Automatically increment versions of packages, generate changelog information, create Github releases etc.
-
发布 - 自动创建标签并将包发布到包注册表,例如 npm
¥Publish - Automatically create tags and publish packages to package registries, such as npm
成本
¥Cost
免费和开源
¥Free and open source
设置
¥Set up
-
npm install lerna
-
npx lerna init
Nx
特性
¥Features
-
NX 控制台 - Visual Studio 代码插件
¥Nx Console - Visual Studio Code plugin
成本
¥Cost
免费和开源
¥Free and open source
设置
¥Set up
-
npx lerna add-caching
-
像往常一样继续使用 Lerna
¥Continue using Lerna as usual
Lerna 在后台遵循 Nx 的强大任务运行程序来检测任务依赖。lerna run
的某些选项的行为与旧版本的 Lerna 不同。有关与旧版本 Lerna 的不同之处的更多详细信息,请参阅 使用 Lerna(由 Nx 提供支持)运行任务。
¥Lerna defers to Nx's power task runner behind the scenes to detect task dependencies. Some options for lerna run
behave differently than in older versions of Lerna. See Using Lerna (Powered by Nx) to Run Tasks for more details on what differs from older versions of Lerna.
Nx 云
¥Nx Cloud
特性
¥Features
-
分配任务执行 高效跨代理机器
¥Distribute task execution efficiently across agent machines
成本
¥Cost
对于开源项目免费
¥Free for open source projects
对于闭源存储库,每月前 500 个计算小时是免费的。大多数存储库不会超过此限制。此后每计算小时 1 美元。
¥For closed source repositories, the first 500 computation hours per month are free. Most repositories do not exceed this limit. $1 per computation hour after that.
设置
¥Set up
-
npx nx connect-to-nx-cloud
-
nx generate @nrwl/workspace:ci-workflow
(或手动设置你的 CI)¥
nx generate @nrwl/workspace:ci-workflow
(or set up your CI manually) -
像往常一样继续使用 Lerna
¥Continue using Lerna as usual