Lightbuild CLI 是 Lightbuild 的官方指令列工具。本頁面說明其指令和選項。如要安裝 Lightbuild CLI,請參閱「安裝 Lightbuild CLI」。如需建構及測試專案等常見工作,請參閱「透過指令列建構 Lightbuild 專案」。
語法
Lightbuild CLI 的語法如下:
lightbuild [-V] [--project=path] [COMMAND]
支援下列全域選項:
| 選項 | 說明 |
|---|---|
-V、--version |
列印版本資訊並結束。 |
-p、--project=path |
專案的絕對路徑。預設為目前的目錄,其中必須包含專案。 |
如要列出可用指令,請執行 lightbuild help。如需特定指令的說明,請執行 lightbuild help [command]。
lightbuild build
在專案中建構目標。
lightbuild build [target]
| 引數 | 說明 |
|---|---|
target |
要建構的目標。預設為目前目錄下的所有目標。 |
例如,如要建構 app 模組,請執行:
lightbuild build app
如要建構專案中的所有目標,請執行:
lightbuild build
lightbuild clean
移除專案的建構輸出內容和快取。
lightbuild clean [target]
| 引數 | 說明 |
|---|---|
target |
要清除的目標。預設為目前目錄下的所有目標。 |
舉例來說,如要移除整個專案的建構輸出內容和快取,請執行:
lightbuild clean
lightbuild help
列出可用的指令,或顯示特定指令的說明。
lightbuild help [COMMAND]
| 引數 | 說明 |
|---|---|
COMMAND |
要顯示說明的指令。預設為所有指令。 |
如要列出專案可用的指令,請執行:
lightbuild help
如要顯示特定指令 (例如 query) 的說明,請執行:
lightbuild help query
lightbuild query
列出專案模組中符合模式的建構目標、產生的輸出檔案或來源集。
lightbuild query [target-pattern] [--format=format] [--output=type]
| 選項或引數 | 說明 |
|---|---|
target-pattern |
目標路徑模式,例如 ... 或 app。 |
--format=format |
輸出格式,例如 json。預設為表格。 |
--output=type |
輸出格式:files 代表相符目標產生的檔案位置、sourcesets 代表來源集,或 sourceset_types 代表來源集類型。 |
如要列出專案中的所有目標,請執行:
lightbuild query ...
如要列印 app 目標產生的檔案位置,請執行:
lightbuild query app --output=files
lightbuild resolve
解析專案的外部依附元件,並為其模組產生離線依附元件鎖定檔案 (resolved.deps)。
lightbuild resolve [--cache=path] [--locked-dependencies] [target]
| 選項或引數 | 說明 |
|---|---|
target |
要解析依附元件的模組,例如 app。預設為目前目錄下的所有目標。 |
--locked-dependencies |
如果本機依附元件鎖定檔案 (resolved.deps) 未同步,則會結束並顯示錯誤。 |
--cache=path |
儲存依附元件快取的目錄。 |
舉例來說,如要為專案中的所有模組產生 resolved.deps 檔案,請執行:
lightbuild resolve
如要進一步瞭解 resolved.deps 檔案,請參閱「已解析的依附元件」。
lightbuild test
執行專案中的測試:在本機開發機器上執行的本機測試,以及在連結裝置或執行中的模擬器上執行的檢測設備測試。如要測試單一模組,請指定其目標,例如 app-core。如要只執行一種測試,請在目標中加入 :hostTest (本機測試) 或 :deviceTest (檢測設備測試)。
lightbuild test [target] [--locked-dependencies]
| 選項或引數 | 說明 |
|---|---|
target |
要測試的目標。預設為專案中的所有測試。 |
--locked-dependencies |
如果本機依附元件鎖定檔案 (resolved.deps) 未同步,建構作業就會失敗。 |
舉例來說,如要執行專案中的所有測試,請執行:
lightbuild test
如要在 app-core 模組中執行本機測試,請執行:
lightbuild test app-core:hostTest
如要在裝置或模擬器上執行 app-core 模組中的檢測設備測試,請執行:
lightbuild test app-core:deviceTest
為您推薦
- 注意:系統會在 JavaScript 關閉時顯示連結文字
- 透過指令列建構 Lightbuild 專案
- 開始使用 Lightbuild
- Lightbuild 設定參考資料