跳到内容

实用脚本

可以通过在项目根目录中输入 npm run <script name> 来运行以下任何脚本。

开发

脚本名称描述
dev在端口 3200 上生成一个热重载开发服务器。
deps-check生成 Swagger UI 依赖项的大小和许可报告。
lint报告 ESLint 样式错误和警告。
lint-errors报告 ESLint 样式错误,不包括警告。
lint-fix尝试自动修复样式错误。
watch当源代码更改时,在 /dist 中重建核心文件。对于使用 Swagger 编辑器的 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 导出为函数