跳至內容

實用腳本

以下任何腳本都可以透過在專案的根目錄中輸入 npm run <腳本名稱> 來執行。

開發中

腳本名稱說明
dev在連接埠 3200 上產生一個熱重新載入的開發伺服器。
deps-check產生 Swagger UI 相依性的尺寸和授權報告。
lint報告 ESLint 樣式錯誤和警告。
lint-errors報告 ESLint 樣式錯誤,不包含警告。
lint-fix嘗試自動修正樣式錯誤。
watch當原始碼變更時,重建 /dist 中的核心檔案。適用於與 Swagger Editor 的 npm link

建置

腳本名稱說明
build建置一組新的 JS 和 CSS 資產,並將其輸出到 /dist
build-bundle僅建置 swagger-ui-bundle.js (commonJS)。
build-core僅建置 swagger-ui.(js|css) (commonJS)。
build-standalone僅建置 swagger-ui-standalone-preset.js (commonJS)。
build-stylesheets僅建置 swagger-ui.css
build:es:bundle僅建置 swagger-ui-es-bundle.js (es2015)。
build:es:bundle:core僅建置 swagger-ui-es-bundle-core.js (es2015)。

測試

腳本名稱說明
test在 Node 中執行單元測試,執行 Cypress 端對端測試,並在僅限錯誤模式中執行 ESLint。
test:unit在 Node 中執行 Jest 單元測試。
e2e執行端對端測試 (需要 JDK 和 Selenium)。
e2e-cypress使用 Cypress 執行端對端瀏覽器測試。
dev-e2e-cypress開發模式,開啟 Cypress 執行器並手動選擇要執行的測試。
lint執行 ESLint 測試
test:artifact在 Jest 中執行套件成品測試清單
test:artifact:umd:bundle執行確認 swagger-ui-bundle 匯出為函數的單元測試
test:artifact:es:bundle執行確認 swagger-ui-es-bundle 匯出為函數的單元測試
test:artifact:es:bundle:core執行確認 swagger-ui-es-bundle-core 匯出為函數的單元測試