跳到内容

实用脚本

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

开发

脚本名称描述
dev在端口 3200 启动一个热重载开发服务器。
deps-check生成 Swagger UI 依赖项的大小和许可报告。
lint报告 ESLint 样式错误和警告。
lint-errors报告 ESLint 样式错误,不含警告。
lint-fix尝试自动修复样式错误。
lint-styles报告 Stylelint 样式错误和警告。
lint-styles-fix尝试自动修复 Stylelint 错误和警告。
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 导出为 Function
test:artifact:es:bundle运行单元测试,确认 swagger-ui-es-bundle 导出为 Function
test:artifact:es:bundle:core运行单元测试,确认 swagger-ui-es-bundle-core 导出为 Function
© . All rights reserved.