貢獻
Rush 是在 Rush Stack 系列專案的單一程式碼儲存庫中開發的
https://github.com/microsoft/rushstack
在 rushstack-websites GitHub 儲存庫中貢獻文件網站。
關於建置 Rush 的一般說明和提交 PR 的準則,請閱讀 Rush Stack 單一程式碼儲存庫的貢獻文件。
相關的單一程式碼儲存庫專案資料夾為
- apps/rush - 命令列介面前端
- libraries/rush-lib - 自動化 API 和實作所有邏輯的「引擎」
測試 Rush 建置
在您編寫好修正程式碼並建置您的分支後(如一般貢獻注意事項中所述),您會想要測試您的 Rush 開發版本。
Rush 具備一個稱為 版本選擇器 的機制,它會從 rush.json 讀取 rushVersion
,然後自動安裝並叫用該特定版本的引擎。因此,如果我們啟動您的 @microsoft/rush
建置,它實際上不會執行您修改後的程式碼。若要略過版本選擇器,我們需要直接叫用 @microsoft/rush-lib
引擎
cd rushstack/libraries/rush-lib
node ./lib/start.js --help
如果您想讓從其他位置輕鬆叫用您的測試建置,我們建議建立 testrush
命令。
適用於 Mac OS 或 Linux 上的 Bash
# Substitute the full path to your own build of rush-lib:
alias testrush="node ~/git/rushstack/libraries/rush-lib/lib/start.js"
對於 Windows,我們可以建立 testrush.cmd
並將其新增至我們的系統 PATH
@ECHO OFF
REM Substitute the full path to your own build of rush-lib:
node "C:\Git\rushstack\apps\rush-lib\lib\start.js" %*
偵錯 Rush
相同的方法也用於使用 VS Code 偵錯工具偵錯 Rush。建立如下的偵錯工具組態檔案
rushstack/libraries/rush-lib/.vscode/launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Rush",
"program": "${workspaceFolder}/lib/start.js",
"args": [ "list", "--json" ], // <====== specify your Rush command line arguments here
"cwd": "(repo folder that you want to debug)", // <===== specify your target working folder here
// The Node.js debugger injects its own messages into the subprocess STDERR, which Rush
// may misinterpret as a build failure. You can uncomment this line as a workaround:
// "env": { "RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD": "1" }
}
]
}
儲存此檔案後,在 VS Code 中按一下「檢視」-->「執行」,並從清單中選擇您的「偵錯 Rush」組態。然後按一下「執行」-->「開始偵錯」以開始偵錯。中斷點和 TypeScript 來源對應應該可以正常運作。
提示:如果 Rush 建置在偵錯工具中似乎因「警告」而失敗,例如
Debugger attached.
Waiting for the debugger to disconnect......請參閱上述有關 RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD 的註解程式碼。
建置但不執行單元測試
Rush 使用 Heft 工具鏈建置。您可以直接叫用 heft
命令列,以取得更好的額外選項。
# Full incremental build of Rush and its dependencies, including unit tests
rush build --to rush-lib --verbose
# Do a quick build of "rush-lib" only without unit tests
cd rushstack/libraries/rush-lib
rushx build