Rush Stack商店部落格活動
跳至主要內容

其他實用命令

安裝所有相容最新語義化版本

一般來說,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 分支中引入不相關的中斷。對於小型儲存庫,這不是太大的問題。對於大型單一儲存庫,我們建議在日常工作中使用 rush update,然後定期由 CI 作業或指定人員執行 rush update --full 作為單獨的工作流程。

更快的建置方法

  • 如果您只處理幾個專案:假設您的 Git 儲存庫包含 50 個專案,但您實際上只處理 widgetwidget-demo 專案。您可以要求 Rush 只建置這兩個專案,以及它們所依賴的程式庫:rush rebuild --to widget --to widget-demo

  • 如果您變更了程式庫:假設您的 Git 儲存庫包含 50 個專案,而您剛剛修正了 widget 程式庫中的一些錯誤。您需要對使用此程式庫的所有專案以及依賴於它們的任何項目執行單元測試,但是重建所有其他項目將會造成浪費。若要僅重建下游專案:rush rebuild --from widget

專案選取參數的完整集合在選擇專案子集文章中說明。

更快的安裝方式

如果您的儲存庫在您的 rush.json 檔案中啟用了新的 useWorkspaces=true 模式的 PNPM,您可以使用稱為「篩選安裝」的功能。此功能透過僅安裝建置特定專案所需的 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