其他有用的命令
安装所有最新兼容 SemVer 版本的软件
通常 rush update
只会进行必要的最小增量更改以满足项目 package.json 文件。如果要将所有内容更新到最新版本,则可以执行以下操作
# This effectively deletes the old shrinkwrap file and re-solves everything
# using the latest compatible versions as specified in package.json files.
# Note that the package.json files themselves are not modified.
rush update --full
在日常工作中,--full
会在你的 PR 分支中引入无关的故障,例如,如果其中一个依赖项没有完全遵循 SemVer 规则。对于小型仓库,这并不是什么大问题。对于大型单体仓库,建议在日常工作中使用 rush update
,然后定期由 CI 作业或指定人员运行 rush update --full
作为独立的工作流程。
构建的更快方法
如果你只在处理少数项目:假设你的 Git 仓库包含 50 个项目,但你只在处理 widget 和 widget-demo 项目。你可以要求 Rush 只构建这两个项目以及它们所依赖的库:
rush rebuild --to widget --to widget-demo
如果你更改了库:假设你的 Git 仓库包含 50 个项目,你刚刚修复了 widget 库中的一些错误。你需要为使用此库的所有项目以及任何依赖它们的项目运行单元测试,但重建其他所有项目会很浪费。要仅重建下游项目:
rush rebuild --from widget
项目的完整选择参数集在文章 选择项目子集 中有描述。
更快的安装方法
如果你的仓库正在使用 PNPM 并且你的 rush.json 文件中启用了新的 useWorkspaces=true
模式,那么你可以使用名为“过滤安装”的功能。此功能通过只安装构建特定项目所需的 NPM 包子集来减少安装时间。
例如
# Only install the NPM packages needed to build "my-project" and the other
# Rush projects that it depends on:
rush install --to my-project
# Like with "rush build", you can use "." to refer to the project from your
# shell's current working directory:
cd my-project
rush install --to .
# Here's how to install dependencies required to do "rush build --from my-project"
rush install --from my-project
恢复到干净的状态
在使用 Rush 后,你可能希望恢复到干净的状态,例如,以便你可以压缩一个文件夹。以下是执行此操作的几个命令
# Remove all the symlinks created by Rush:
rush unlink
# Remove all the temporary files created by Rush, including deleting all
# the NPM packages that were installed in your common folder:
rush purge