@zuplo/cli 7.11.0 → 7.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@hono/node-server/README.md +2 -0
- package/node_modules/@hono/node-server/dist/index.cjs +1 -1
- package/node_modules/@hono/node-server/dist/index.mjs +1 -1
- package/node_modules/@hono/node-server/dist/serve-static.cjs +2 -1
- package/node_modules/@hono/node-server/dist/serve-static.mjs +2 -1
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/@posthog/core/dist/metrics/index.d.ts +9 -0
- package/node_modules/@posthog/core/dist/metrics/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/metrics/index.js +38 -3
- package/node_modules/@posthog/core/dist/metrics/index.mjs +38 -3
- package/node_modules/@posthog/core/dist/metrics/types.d.ts +7 -2
- package/node_modules/@posthog/core/dist/metrics/types.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/traces/ids.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/traces/ids.js +2 -2
- package/node_modules/@posthog/core/dist/traces/ids.mjs +2 -2
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/metrics/index.spec.ts +75 -0
- package/node_modules/@posthog/core/src/metrics/index.ts +60 -0
- package/node_modules/@posthog/core/src/metrics/types.ts +7 -1
- package/node_modules/@posthog/core/src/traces/ids.ts +4 -2
- package/node_modules/@posthog/types/dist/capture-metric.d.ts +10 -0
- package/node_modules/@posthog/types/dist/capture-metric.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/index.d.ts +1 -1
- package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/capture-metric.ts +11 -0
- package/node_modules/@posthog/types/src/index.ts +1 -0
- package/node_modules/@zuplo/core/customer.cli.minified.js +2 -2
- package/node_modules/@zuplo/core/index.minified.js +2 -2
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +5 -2
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-YJ2BHVUH.js → chunk-CDEAY3VY.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/chunk-LVSZ3WTO.js +37 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-LVSZ3WTO.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-VTO3F6DK.js → chunk-NUVXDVLJ.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-6YPRGG62.js → chunk-RHU3Z7DA.js} +108 -108
- package/node_modules/@zuplo/runtime/out/esm/chunk-RHU3Z7DA.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +15 -24
- package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +14 -0
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +15 -12
- package/dist/__tests__/archive-utils.test.d.ts +0 -2
- package/dist/__tests__/archive-utils.test.d.ts.map +0 -1
- package/dist/__tests__/archive-utils.test.js +0 -50
- package/dist/__tests__/archive-utils.test.js.map +0 -1
- package/dist/__tests__/import-openapi.test.d.ts +0 -2
- package/dist/__tests__/import-openapi.test.d.ts.map +0 -1
- package/dist/__tests__/import-openapi.test.js +0 -251
- package/dist/__tests__/import-openapi.test.js.map +0 -1
- package/dist/__tests__/integration/confirm-linked-config.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/confirm-linked-config.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/confirm-linked-config.integration.test.js +0 -202
- package/dist/__tests__/integration/confirm-linked-config.integration.test.js.map +0 -1
- package/dist/__tests__/integration/confirm-production-deploy.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/confirm-production-deploy.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/confirm-production-deploy.integration.test.js +0 -184
- package/dist/__tests__/integration/confirm-production-deploy.integration.test.js.map +0 -1
- package/dist/__tests__/integration/custom-domain.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/custom-domain.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/custom-domain.integration.test.js +0 -563
- package/dist/__tests__/integration/custom-domain.integration.test.js.map +0 -1
- package/dist/__tests__/integration/delete.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/delete.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/delete.integration.test.js +0 -262
- package/dist/__tests__/integration/delete.integration.test.js.map +0 -1
- package/dist/__tests__/integration/deploy.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/deploy.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/deploy.integration.test.js +0 -519
- package/dist/__tests__/integration/deploy.integration.test.js.map +0 -1
- package/dist/__tests__/integration/get-project-param.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/get-project-param.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/get-project-param.integration.test.js +0 -305
- package/dist/__tests__/integration/get-project-param.integration.test.js.map +0 -1
- package/dist/__tests__/integration/info.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/info.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/info.integration.test.js +0 -293
- package/dist/__tests__/integration/info.integration.test.js.map +0 -1
- package/dist/__tests__/integration/jest-mocks-setup.d.ts +0 -2
- package/dist/__tests__/integration/jest-mocks-setup.d.ts.map +0 -1
- package/dist/__tests__/integration/jest-mocks-setup.js +0 -104
- package/dist/__tests__/integration/jest-mocks-setup.js.map +0 -1
- package/dist/__tests__/integration/jest-setup.d.ts +0 -2
- package/dist/__tests__/integration/jest-setup.d.ts.map +0 -1
- package/dist/__tests__/integration/jest-setup.js +0 -12
- package/dist/__tests__/integration/jest-setup.js.map +0 -1
- package/dist/__tests__/integration/link.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/link.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/link.integration.test.js +0 -395
- package/dist/__tests__/integration/link.integration.test.js.map +0 -1
- package/dist/__tests__/integration/linked-config-cascade.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/linked-config-cascade.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/linked-config-cascade.integration.test.js +0 -179
- package/dist/__tests__/integration/linked-config-cascade.integration.test.js.map +0 -1
- package/dist/__tests__/integration/list.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/list.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/list.integration.test.js +0 -300
- package/dist/__tests__/integration/list.integration.test.js.map +0 -1
- package/dist/__tests__/integration/source-upgrade.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/source-upgrade.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/source-upgrade.integration.test.js +0 -100
- package/dist/__tests__/integration/source-upgrade.integration.test.js.map +0 -1
- package/dist/__tests__/integration/test-utils.d.ts +0 -30
- package/dist/__tests__/integration/test-utils.d.ts.map +0 -1
- package/dist/__tests__/integration/test-utils.js +0 -82
- package/dist/__tests__/integration/test-utils.js.map +0 -1
- package/dist/__tests__/integration/tunnel.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/tunnel.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/tunnel.integration.test.js +0 -486
- package/dist/__tests__/integration/tunnel.integration.test.js.map +0 -1
- package/dist/__tests__/integration/variable.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/variable.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/variable.integration.test.js +0 -258
- package/dist/__tests__/integration/variable.integration.test.js.map +0 -1
- package/dist/__tests__/integration/whoami.integration.test.d.ts +0 -2
- package/dist/__tests__/integration/whoami.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/whoami.integration.test.js +0 -116
- package/dist/__tests__/integration/whoami.integration.test.js.map +0 -1
- package/dist/__tests__/outdated.test.d.ts +0 -2
- package/dist/__tests__/outdated.test.d.ts.map +0 -1
- package/dist/__tests__/outdated.test.js +0 -67
- package/dist/__tests__/outdated.test.js.map +0 -1
- package/dist/__tests__/populate.test.d.ts +0 -2
- package/dist/__tests__/populate.test.d.ts.map +0 -1
- package/dist/__tests__/populate.test.js +0 -445
- package/dist/__tests__/populate.test.js.map +0 -1
- package/dist/__tests__/tsconfig-upgrader.test.d.ts +0 -2
- package/dist/__tests__/tsconfig-upgrader.test.d.ts.map +0 -1
- package/dist/__tests__/tsconfig-upgrader.test.js +0 -31
- package/dist/__tests__/tsconfig-upgrader.test.js.map +0 -1
- package/dist/ca-certificate/validation.test.d.ts +0 -2
- package/dist/ca-certificate/validation.test.d.ts.map +0 -1
- package/dist/ca-certificate/validation.test.js +0 -131
- package/dist/ca-certificate/validation.test.js.map +0 -1
- package/dist/common/analytics/cli-invocation.test.d.ts +0 -2
- package/dist/common/analytics/cli-invocation.test.d.ts.map +0 -1
- package/dist/common/analytics/cli-invocation.test.js +0 -51
- package/dist/common/analytics/cli-invocation.test.js.map +0 -1
- package/dist/common/analytics/package-manager.test.d.ts +0 -2
- package/dist/common/analytics/package-manager.test.d.ts.map +0 -1
- package/dist/common/analytics/package-manager.test.js +0 -163
- package/dist/common/analytics/package-manager.test.js.map +0 -1
- package/dist/common/cli-dispatcher.test.d.ts +0 -2
- package/dist/common/cli-dispatcher.test.d.ts.map +0 -1
- package/dist/common/cli-dispatcher.test.js +0 -80
- package/dist/common/cli-dispatcher.test.js.map +0 -1
- package/dist/common/middleware/check-pnpm-lifecycle.test.d.ts +0 -2
- package/dist/common/middleware/check-pnpm-lifecycle.test.d.ts.map +0 -1
- package/dist/common/middleware/check-pnpm-lifecycle.test.js +0 -125
- package/dist/common/middleware/check-pnpm-lifecycle.test.js.map +0 -1
- package/dist/common/middleware/get-environment-param.test.d.ts +0 -2
- package/dist/common/middleware/get-environment-param.test.d.ts.map +0 -1
- package/dist/common/middleware/get-environment-param.test.js +0 -57
- package/dist/common/middleware/get-environment-param.test.js.map +0 -1
- package/dist/common/read-linked-config.test.d.ts +0 -2
- package/dist/common/read-linked-config.test.d.ts.map +0 -1
- package/dist/common/read-linked-config.test.js +0 -363
- package/dist/common/read-linked-config.test.js.map +0 -1
- package/dist/common/terminal.test.d.ts +0 -2
- package/dist/common/terminal.test.d.ts.map +0 -1
- package/dist/common/terminal.test.js +0 -101
- package/dist/common/terminal.test.js.map +0 -1
- package/dist/common/utils/build-environment-prompt-choices.test.d.ts +0 -2
- package/dist/common/utils/build-environment-prompt-choices.test.d.ts.map +0 -1
- package/dist/common/utils/build-environment-prompt-choices.test.js +0 -97
- package/dist/common/utils/build-environment-prompt-choices.test.js.map +0 -1
- package/dist/common/utils/format-environment-type.test.d.ts +0 -2
- package/dist/common/utils/format-environment-type.test.d.ts.map +0 -1
- package/dist/common/utils/format-environment-type.test.js +0 -32
- package/dist/common/utils/format-environment-type.test.js.map +0 -1
- package/dist/common/utils/pnpm-lifecycle.test.d.ts +0 -2
- package/dist/common/utils/pnpm-lifecycle.test.d.ts.map +0 -1
- package/dist/common/utils/pnpm-lifecycle.test.js +0 -196
- package/dist/common/utils/pnpm-lifecycle.test.js.map +0 -1
- package/dist/common/utils/pretty-print-environment-prompt.test.d.ts +0 -2
- package/dist/common/utils/pretty-print-environment-prompt.test.d.ts.map +0 -1
- package/dist/common/utils/pretty-print-environment-prompt.test.js +0 -42
- package/dist/common/utils/pretty-print-environment-prompt.test.js.map +0 -1
- package/dist/common/utils/sort-environments-for-prompt.test.d.ts +0 -2
- package/dist/common/utils/sort-environments-for-prompt.test.d.ts.map +0 -1
- package/dist/common/utils/sort-environments-for-prompt.test.js +0 -82
- package/dist/common/utils/sort-environments-for-prompt.test.js.map +0 -1
- package/dist/common/utils/stringify-config.test.d.ts +0 -2
- package/dist/common/utils/stringify-config.test.d.ts.map +0 -1
- package/dist/common/utils/stringify-config.test.js +0 -80
- package/dist/common/utils/stringify-config.test.js.map +0 -1
- package/dist/common/validators/argument-validators.spec.d.ts +0 -2
- package/dist/common/validators/argument-validators.spec.d.ts.map +0 -1
- package/dist/common/validators/argument-validators.spec.js +0 -181
- package/dist/common/validators/argument-validators.spec.js.map +0 -1
- package/dist/common/worker-output.test.d.ts +0 -2
- package/dist/common/worker-output.test.d.ts.map +0 -1
- package/dist/common/worker-output.test.js +0 -32
- package/dist/common/worker-output.test.js.map +0 -1
- package/dist/deploy/archive.local-registry.test.d.ts +0 -2
- package/dist/deploy/archive.local-registry.test.d.ts.map +0 -1
- package/dist/deploy/archive.local-registry.test.js +0 -100
- package/dist/deploy/archive.local-registry.test.js.map +0 -1
- package/dist/deploy/archive.test.d.ts +0 -2
- package/dist/deploy/archive.test.d.ts.map +0 -1
- package/dist/deploy/archive.test.js +0 -248
- package/dist/deploy/archive.test.js.map +0 -1
- package/dist/deploy/classify-build-probe.test.d.ts +0 -2
- package/dist/deploy/classify-build-probe.test.d.ts.map +0 -1
- package/dist/deploy/classify-build-probe.test.js +0 -51
- package/dist/deploy/classify-build-probe.test.js.map +0 -1
- package/dist/deploy/poll-deployment.test.d.ts +0 -2
- package/dist/deploy/poll-deployment.test.d.ts.map +0 -1
- package/dist/deploy/poll-deployment.test.js +0 -158
- package/dist/deploy/poll-deployment.test.js.map +0 -1
- package/dist/dev/zuplo-local-gitignore.test.d.ts +0 -2
- package/dist/dev/zuplo-local-gitignore.test.d.ts.map +0 -1
- package/dist/dev/zuplo-local-gitignore.test.js +0 -58
- package/dist/dev/zuplo-local-gitignore.test.js.map +0 -1
- package/dist/editor/e2e/editor.spec.d.ts +0 -2
- package/dist/editor/e2e/editor.spec.d.ts.map +0 -1
- package/dist/editor/e2e/editor.spec.js +0 -44
- package/dist/editor/e2e/editor.spec.js.map +0 -1
- package/dist/link/project-type.test.d.ts +0 -2
- package/dist/link/project-type.test.d.ts.map +0 -1
- package/dist/link/project-type.test.js +0 -225
- package/dist/link/project-type.test.js.map +0 -1
- package/dist/lint/resolve-binary.test.d.ts +0 -2
- package/dist/lint/resolve-binary.test.d.ts.map +0 -1
- package/dist/lint/resolve-binary.test.js +0 -155
- package/dist/lint/resolve-binary.test.js.map +0 -1
- package/dist/open-api/convert/handler.spec.d.ts +0 -2
- package/dist/open-api/convert/handler.spec.d.ts.map +0 -1
- package/dist/open-api/convert/handler.spec.js +0 -301
- package/dist/open-api/convert/handler.spec.js.map +0 -1
- package/dist/open-api/merge/handler.spec.d.ts +0 -2
- package/dist/open-api/merge/handler.spec.d.ts.map +0 -1
- package/dist/open-api/merge/handler.spec.js +0 -673
- package/dist/open-api/merge/handler.spec.js.map +0 -1
- package/dist/open-api/overlay/handler.spec.d.ts +0 -2
- package/dist/open-api/overlay/handler.spec.d.ts.map +0 -1
- package/dist/open-api/overlay/handler.spec.js +0 -346
- package/dist/open-api/overlay/handler.spec.js.map +0 -1
- package/dist/source/ai-gateway/files.test.d.ts +0 -2
- package/dist/source/ai-gateway/files.test.d.ts.map +0 -1
- package/dist/source/ai-gateway/files.test.js +0 -135
- package/dist/source/ai-gateway/files.test.js.map +0 -1
- package/dist/source/ai-gateway/handler.test.d.ts +0 -2
- package/dist/source/ai-gateway/handler.test.d.ts.map +0 -1
- package/dist/source/ai-gateway/handler.test.js +0 -113
- package/dist/source/ai-gateway/handler.test.js.map +0 -1
- package/dist/source/ai-gateway/package.test.d.ts +0 -2
- package/dist/source/ai-gateway/package.test.d.ts.map +0 -1
- package/dist/source/ai-gateway/package.test.js +0 -30
- package/dist/source/ai-gateway/package.test.js.map +0 -1
- package/dist/source/ai-gateway/planner.test.d.ts +0 -2
- package/dist/source/ai-gateway/planner.test.d.ts.map +0 -1
- package/dist/source/ai-gateway/planner.test.js +0 -330
- package/dist/source/ai-gateway/planner.test.js.map +0 -1
- package/dist/source/ai-gateway/release.test.d.ts +0 -2
- package/dist/source/ai-gateway/release.test.d.ts.map +0 -1
- package/dist/source/ai-gateway/release.test.js +0 -62
- package/dist/source/ai-gateway/release.test.js.map +0 -1
- package/dist/test/invoke-test.test.d.ts +0 -2
- package/dist/test/invoke-test.test.d.ts.map +0 -1
- package/dist/test/invoke-test.test.js +0 -150
- package/dist/test/invoke-test.test.js.map +0 -1
- package/dist/test/test-files.test.d.ts +0 -2
- package/dist/test/test-files.test.d.ts.map +0 -1
- package/dist/test/test-files.test.js +0 -57
- package/dist/test/test-files.test.js.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/file-format.spec.d.ts +0 -2
- package/node_modules/@zuplo/openapi-tools/dist/file-format.spec.d.ts.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/file-format.spec.js +0 -289
- package/node_modules/@zuplo/openapi-tools/dist/file-format.spec.js.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/merge-fixtures.spec.d.ts +0 -2
- package/node_modules/@zuplo/openapi-tools/dist/merge-fixtures.spec.d.ts.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/merge-fixtures.spec.js +0 -181
- package/node_modules/@zuplo/openapi-tools/dist/merge-fixtures.spec.js.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/merge.spec.d.ts +0 -2
- package/node_modules/@zuplo/openapi-tools/dist/merge.spec.d.ts.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/merge.spec.js +0 -399
- package/node_modules/@zuplo/openapi-tools/dist/merge.spec.js.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/overlay.spec.d.ts +0 -2
- package/node_modules/@zuplo/openapi-tools/dist/overlay.spec.d.ts.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/overlay.spec.js +0 -779
- package/node_modules/@zuplo/openapi-tools/dist/overlay.spec.js.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/path-transform.spec.d.ts +0 -2
- package/node_modules/@zuplo/openapi-tools/dist/path-transform.spec.d.ts.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/path-transform.spec.js +0 -269
- package/node_modules/@zuplo/openapi-tools/dist/path-transform.spec.js.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/url-utils.spec.d.ts +0 -2
- package/node_modules/@zuplo/openapi-tools/dist/url-utils.spec.d.ts.map +0 -1
- package/node_modules/@zuplo/openapi-tools/dist/url-utils.spec.js +0 -93
- package/node_modules/@zuplo/openapi-tools/dist/url-utils.spec.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-6YPRGG62.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-PBDT4FDO.js +0 -37
- package/node_modules/@zuplo/runtime/out/esm/chunk-PBDT4FDO.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-YJ2BHVUH.js.map → chunk-CDEAY3VY.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-PBDT4FDO.js.LEGAL.txt → chunk-LVSZ3WTO.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-VTO3F6DK.js.map → chunk-NUVXDVLJ.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-6YPRGG62.js.LEGAL.txt → chunk-RHU3Z7DA.js.LEGAL.txt} +0 -0
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { after, before, describe, it } from "node:test";
|
|
6
|
-
import { LintBinaryNotFoundError, lintPackageName, resolveLintBinary, } from "./resolve-binary.js";
|
|
7
|
-
describe("lintPackageName", () => {
|
|
8
|
-
it("derives the package name from platform and arch", () => {
|
|
9
|
-
assert.strictEqual(lintPackageName("darwin", "arm64"), "@zuplo/lint-darwin-arm64");
|
|
10
|
-
assert.strictEqual(lintPackageName("linux", "x64"), "@zuplo/lint-linux-x64");
|
|
11
|
-
assert.strictEqual(lintPackageName("win32", "x64"), "@zuplo/lint-win32-x64");
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
describe("resolveLintBinary", () => {
|
|
15
|
-
let tmpRoot;
|
|
16
|
-
let overridePath;
|
|
17
|
-
before(() => {
|
|
18
|
-
tmpRoot = realpathSync(mkdtempSync(path.join(tmpdir(), "lint-binary-")));
|
|
19
|
-
overridePath = path.join(tmpRoot, "custom-zuplo-lint");
|
|
20
|
-
writeFileSync(overridePath, "#!/bin/sh\n");
|
|
21
|
-
});
|
|
22
|
-
after(() => {
|
|
23
|
-
rmSync(tmpRoot, { recursive: true, force: true });
|
|
24
|
-
});
|
|
25
|
-
it("uses an explicit override ahead of everything else", () => {
|
|
26
|
-
const devBinaryPath = path.join(tmpRoot, "dev", "zuplo-lint");
|
|
27
|
-
mkdirSync(path.dirname(devBinaryPath), { recursive: true });
|
|
28
|
-
writeFileSync(devBinaryPath, "");
|
|
29
|
-
assert.strictEqual(resolveLintBinary({ override: overridePath, devBinaryPath }), overridePath);
|
|
30
|
-
});
|
|
31
|
-
it("resolves a relative override against the working directory", () => {
|
|
32
|
-
const relative = path.relative(process.cwd(), overridePath);
|
|
33
|
-
assert.strictEqual(resolveLintBinary({ override: relative }), path.resolve(relative));
|
|
34
|
-
});
|
|
35
|
-
it("reports the bad path when the override does not exist", () => {
|
|
36
|
-
const missing = path.join(tmpRoot, "nope");
|
|
37
|
-
assert.throws(() => resolveLintBinary({ override: missing }), (err) => {
|
|
38
|
-
assert.ok(err instanceof LintBinaryNotFoundError);
|
|
39
|
-
assert.match(err.message, /No zuplo-lint binary at/);
|
|
40
|
-
assert.ok(err.message.includes(missing), "expected the resolved path in the message");
|
|
41
|
-
assert.match(err.message, /--lint-binary/);
|
|
42
|
-
return true;
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
it("falls back to the repo build output when the platform package is absent", () => {
|
|
46
|
-
const devBinaryPath = path.join(tmpRoot, "dist", "zuplo-lint");
|
|
47
|
-
mkdirSync(path.dirname(devBinaryPath), { recursive: true });
|
|
48
|
-
writeFileSync(devBinaryPath, "");
|
|
49
|
-
assert.strictEqual(resolveLintBinary({
|
|
50
|
-
platform: "linux",
|
|
51
|
-
arch: "mips",
|
|
52
|
-
devBinaryPath,
|
|
53
|
-
}), devBinaryPath);
|
|
54
|
-
});
|
|
55
|
-
it("throws an actionable error when nothing is installed", () => {
|
|
56
|
-
assert.throws(() => resolveLintBinary({
|
|
57
|
-
platform: "linux",
|
|
58
|
-
arch: "mips",
|
|
59
|
-
devBinaryPath: path.join(tmpRoot, "does-not-exist"),
|
|
60
|
-
}), (err) => {
|
|
61
|
-
assert.ok(err instanceof LintBinaryNotFoundError);
|
|
62
|
-
assert.strictEqual(err.packageName, "@zuplo/lint-linux-mips");
|
|
63
|
-
assert.match(err.message, /@zuplo\/lint-linux-mips/);
|
|
64
|
-
assert.match(err.message, /linux-mips/);
|
|
65
|
-
assert.match(err.message, /--lint-binary/);
|
|
66
|
-
return true;
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
it("finds the binary inside an installed platform package", () => {
|
|
70
|
-
const projectDir = path.join(tmpRoot, "consumer");
|
|
71
|
-
const pkgDir = path.join(projectDir, "node_modules", "@zuplo", "lint-linux-x64");
|
|
72
|
-
mkdirSync(path.join(pkgDir, "bin"), { recursive: true });
|
|
73
|
-
writeFileSync(path.join(pkgDir, "package.json"), JSON.stringify({ name: "@zuplo/lint-linux-x64", version: "1.0.0" }));
|
|
74
|
-
const binPath = path.join(pkgDir, "bin", "zuplo-lint");
|
|
75
|
-
writeFileSync(binPath, "");
|
|
76
|
-
const resolved = resolveLintBinary({
|
|
77
|
-
platform: "linux",
|
|
78
|
-
arch: "x64",
|
|
79
|
-
resolveFrom: path.join(projectDir, "index.js"),
|
|
80
|
-
devBinaryPath: path.join(tmpRoot, "does-not-exist"),
|
|
81
|
-
});
|
|
82
|
-
assert.strictEqual(resolved, binPath);
|
|
83
|
-
});
|
|
84
|
-
it("looks for the .exe on Windows", () => {
|
|
85
|
-
const projectDir = path.join(tmpRoot, "consumer-win");
|
|
86
|
-
const pkgDir = path.join(projectDir, "node_modules", "@zuplo", "lint-win32-x64");
|
|
87
|
-
mkdirSync(path.join(pkgDir, "bin"), { recursive: true });
|
|
88
|
-
writeFileSync(path.join(pkgDir, "package.json"), JSON.stringify({ name: "@zuplo/lint-win32-x64", version: "1.0.0" }));
|
|
89
|
-
const binPath = path.join(pkgDir, "bin", "zuplo-lint.exe");
|
|
90
|
-
writeFileSync(binPath, "");
|
|
91
|
-
const resolved = resolveLintBinary({
|
|
92
|
-
platform: "win32",
|
|
93
|
-
arch: "x64",
|
|
94
|
-
resolveFrom: path.join(projectDir, "index.js"),
|
|
95
|
-
devBinaryPath: path.join(tmpRoot, "does-not-exist"),
|
|
96
|
-
});
|
|
97
|
-
assert.strictEqual(resolved, binPath);
|
|
98
|
-
});
|
|
99
|
-
it("reports a package that is present but unreadable, instead of calling it missing", () => {
|
|
100
|
-
const projectDir = path.join(tmpRoot, "consumer-corrupt");
|
|
101
|
-
const pkgDir = path.join(projectDir, "node_modules", "@zuplo", "lint-linux-x64");
|
|
102
|
-
mkdirSync(path.join(pkgDir, "bin"), { recursive: true });
|
|
103
|
-
writeFileSync(path.join(pkgDir, "package.json"), JSON.stringify({
|
|
104
|
-
name: "@zuplo/lint-linux-x64",
|
|
105
|
-
version: "1.0.0",
|
|
106
|
-
exports: { "./bin/*": "./bin/*" },
|
|
107
|
-
}));
|
|
108
|
-
writeFileSync(path.join(pkgDir, "bin", "zuplo-lint"), "");
|
|
109
|
-
const devBinaryPath = path.join(tmpRoot, "dist", "zuplo-lint");
|
|
110
|
-
mkdirSync(path.dirname(devBinaryPath), { recursive: true });
|
|
111
|
-
writeFileSync(devBinaryPath, "");
|
|
112
|
-
assert.throws(() => resolveLintBinary({
|
|
113
|
-
platform: "linux",
|
|
114
|
-
arch: "x64",
|
|
115
|
-
resolveFrom: path.join(projectDir, "index.js"),
|
|
116
|
-
devBinaryPath,
|
|
117
|
-
}), (err) => {
|
|
118
|
-
assert.ok(err instanceof LintBinaryNotFoundError);
|
|
119
|
-
assert.match(err.message, /installed but could not be read/);
|
|
120
|
-
assert.strictEqual(err.packageName, "@zuplo/lint-linux-x64");
|
|
121
|
-
return true;
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
it("treats a genuinely absent package as not installed, not an error to rethrow", () => {
|
|
125
|
-
const projectDir = path.join(tmpRoot, "consumer-absent");
|
|
126
|
-
mkdirSync(projectDir, { recursive: true });
|
|
127
|
-
const devBinaryPath = path.join(tmpRoot, "dist", "zuplo-lint");
|
|
128
|
-
mkdirSync(path.dirname(devBinaryPath), { recursive: true });
|
|
129
|
-
writeFileSync(devBinaryPath, "");
|
|
130
|
-
assert.strictEqual(resolveLintBinary({
|
|
131
|
-
platform: "linux",
|
|
132
|
-
arch: "x64",
|
|
133
|
-
resolveFrom: path.join(projectDir, "index.js"),
|
|
134
|
-
devBinaryPath,
|
|
135
|
-
}), devBinaryPath);
|
|
136
|
-
});
|
|
137
|
-
it("prefers the installed platform package over the repo build output", () => {
|
|
138
|
-
const projectDir = path.join(tmpRoot, "consumer-precedence");
|
|
139
|
-
const pkgDir = path.join(projectDir, "node_modules", "@zuplo", "lint-linux-x64");
|
|
140
|
-
mkdirSync(path.join(pkgDir, "bin"), { recursive: true });
|
|
141
|
-
writeFileSync(path.join(pkgDir, "package.json"), JSON.stringify({ name: "@zuplo/lint-linux-x64", version: "1.0.0" }));
|
|
142
|
-
const binPath = path.join(pkgDir, "bin", "zuplo-lint");
|
|
143
|
-
writeFileSync(binPath, "");
|
|
144
|
-
const devBinaryPath = path.join(tmpRoot, "dist", "zuplo-lint");
|
|
145
|
-
mkdirSync(path.dirname(devBinaryPath), { recursive: true });
|
|
146
|
-
writeFileSync(devBinaryPath, "");
|
|
147
|
-
assert.strictEqual(resolveLintBinary({
|
|
148
|
-
platform: "linux",
|
|
149
|
-
arch: "x64",
|
|
150
|
-
resolveFrom: path.join(projectDir, "index.js"),
|
|
151
|
-
devBinaryPath,
|
|
152
|
-
}), binPath);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
//# sourceMappingURL=resolve-binary.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-binary.test.js","sourceRoot":"","sources":["../../src/lint/resolve-binary.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,CAAC,WAAW,CAChB,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,EAClC,0BAA0B,CAC3B,CAAC;QACF,MAAM,CAAC,WAAW,CAChB,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,EAC/B,uBAAuB,CACxB,CAAC;QACF,MAAM,CAAC,WAAW,CAChB,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,EAC/B,uBAAuB,CACxB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAI,OAAe,CAAC;IACpB,IAAI,YAAoB,CAAC;IAEzB,MAAM,CAAC,GAAG,EAAE;QAGV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CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CACpE,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;QACvD,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAE3B,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QAC/D,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,aAAa,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAEjC,MAAM,CAAC,WAAW,CAChB,iBAAiB,CAAC;YAChB,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,KAAK;YACX,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;YAC9C,aAAa;SACd,CAAC,EACF,OAAO,CACR,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport {\n mkdirSync,\n mkdtempSync,\n realpathSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { after, before, describe, it } from \"node:test\";\nimport {\n LintBinaryNotFoundError,\n lintPackageName,\n resolveLintBinary,\n} from \"./resolve-binary.js\";\n\ndescribe(\"lintPackageName\", () => {\n it(\"derives the package name from platform and arch\", () => {\n assert.strictEqual(\n lintPackageName(\"darwin\", \"arm64\"),\n \"@zuplo/lint-darwin-arm64\"\n );\n assert.strictEqual(\n lintPackageName(\"linux\", \"x64\"),\n \"@zuplo/lint-linux-x64\"\n );\n assert.strictEqual(\n lintPackageName(\"win32\", \"x64\"),\n \"@zuplo/lint-win32-x64\"\n );\n });\n});\n\ndescribe(\"resolveLintBinary\", () => {\n let tmpRoot: string;\n let overridePath: string;\n\n before(() => {\n // realpath because require.resolve returns real paths, and on macOS\n // os.tmpdir() is /tmp, a symlink to /private/tmp.\n tmpRoot = realpathSync(mkdtempSync(path.join(tmpdir(), \"lint-binary-\")));\n overridePath = path.join(tmpRoot, \"custom-zuplo-lint\");\n writeFileSync(overridePath, \"#!/bin/sh\\n\");\n });\n\n after(() => {\n rmSync(tmpRoot, { recursive: true, force: true });\n });\n\n it(\"uses an explicit override ahead of everything else\", () => {\n const devBinaryPath = path.join(tmpRoot, \"dev\", \"zuplo-lint\");\n mkdirSync(path.dirname(devBinaryPath), { recursive: true });\n writeFileSync(devBinaryPath, \"\");\n\n assert.strictEqual(\n resolveLintBinary({ override: overridePath, devBinaryPath }),\n overridePath\n );\n });\n\n it(\"resolves a relative override against the working directory\", () => {\n const relative = path.relative(process.cwd(), overridePath);\n\n assert.strictEqual(\n resolveLintBinary({ override: relative }),\n path.resolve(relative)\n );\n });\n\n it(\"reports the bad path when the override does not exist\", () => {\n const missing = path.join(tmpRoot, \"nope\");\n\n assert.throws(\n () => resolveLintBinary({ override: missing }),\n (err: unknown) => {\n assert.ok(err instanceof LintBinaryNotFoundError);\n assert.match(err.message, /No zuplo-lint binary at/);\n assert.ok(\n err.message.includes(missing),\n \"expected the resolved path in the message\"\n );\n // The message has to name the flag, or the user cannot tell where the\n // path came from.\n assert.match(err.message, /--lint-binary/);\n return true;\n }\n );\n });\n\n it(\"falls back to the repo build output when the platform package is absent\", () => {\n const devBinaryPath = path.join(tmpRoot, \"dist\", \"zuplo-lint\");\n mkdirSync(path.dirname(devBinaryPath), { recursive: true });\n writeFileSync(devBinaryPath, \"\");\n\n assert.strictEqual(\n resolveLintBinary({\n platform: \"linux\",\n arch: \"mips\",\n devBinaryPath,\n }),\n devBinaryPath\n );\n });\n\n it(\"throws an actionable error when nothing is installed\", () => {\n assert.throws(\n () =>\n resolveLintBinary({\n platform: \"linux\",\n arch: \"mips\",\n devBinaryPath: path.join(tmpRoot, \"does-not-exist\"),\n }),\n (err: unknown) => {\n assert.ok(err instanceof LintBinaryNotFoundError);\n assert.strictEqual(err.packageName, \"@zuplo/lint-linux-mips\");\n // An unsupported platform must say which package is missing and how to\n // recover, not just that something went wrong.\n assert.match(err.message, /@zuplo\\/lint-linux-mips/);\n assert.match(err.message, /linux-mips/);\n assert.match(err.message, /--lint-binary/);\n return true;\n }\n );\n });\n\n it(\"finds the binary inside an installed platform package\", () => {\n // Lay out a node_modules tree the way npm would, and resolve from a module\n // inside it.\n const projectDir = path.join(tmpRoot, \"consumer\");\n const pkgDir = path.join(\n projectDir,\n \"node_modules\",\n \"@zuplo\",\n \"lint-linux-x64\"\n );\n mkdirSync(path.join(pkgDir, \"bin\"), { recursive: true });\n writeFileSync(\n path.join(pkgDir, \"package.json\"),\n JSON.stringify({ name: \"@zuplo/lint-linux-x64\", version: \"1.0.0\" })\n );\n const binPath = path.join(pkgDir, \"bin\", \"zuplo-lint\");\n writeFileSync(binPath, \"\");\n\n const resolved = resolveLintBinary({\n platform: \"linux\",\n arch: \"x64\",\n resolveFrom: path.join(projectDir, \"index.js\"),\n devBinaryPath: path.join(tmpRoot, \"does-not-exist\"),\n });\n\n assert.strictEqual(resolved, binPath);\n });\n\n it(\"looks for the .exe on Windows\", () => {\n const projectDir = path.join(tmpRoot, \"consumer-win\");\n const pkgDir = path.join(\n projectDir,\n \"node_modules\",\n \"@zuplo\",\n \"lint-win32-x64\"\n );\n mkdirSync(path.join(pkgDir, \"bin\"), { recursive: true });\n writeFileSync(\n path.join(pkgDir, \"package.json\"),\n JSON.stringify({ name: \"@zuplo/lint-win32-x64\", version: \"1.0.0\" })\n );\n const binPath = path.join(pkgDir, \"bin\", \"zuplo-lint.exe\");\n writeFileSync(binPath, \"\");\n\n const resolved = resolveLintBinary({\n platform: \"win32\",\n arch: \"x64\",\n resolveFrom: path.join(projectDir, \"index.js\"),\n devBinaryPath: path.join(tmpRoot, \"does-not-exist\"),\n });\n\n assert.strictEqual(resolved, binPath);\n });\n\n it(\"reports a package that is present but unreadable, instead of calling it missing\", () => {\n // An `exports` map that does not expose ./package.json makes require.resolve\n // fail with ERR_PACKAGE_PATH_NOT_EXPORTED rather than MODULE_NOT_FOUND. The\n // package is right there, so saying \"not installed\" would send the user\n // hunting for something they already have.\n const projectDir = path.join(tmpRoot, \"consumer-corrupt\");\n const pkgDir = path.join(\n projectDir,\n \"node_modules\",\n \"@zuplo\",\n \"lint-linux-x64\"\n );\n mkdirSync(path.join(pkgDir, \"bin\"), { recursive: true });\n writeFileSync(\n path.join(pkgDir, \"package.json\"),\n JSON.stringify({\n name: \"@zuplo/lint-linux-x64\",\n version: \"1.0.0\",\n exports: { \"./bin/*\": \"./bin/*\" },\n })\n );\n writeFileSync(path.join(pkgDir, \"bin\", \"zuplo-lint\"), \"\");\n\n // A dev binary is available, but must NOT be used to paper over this: the\n // consumer's own platform package is broken and they need to know.\n const devBinaryPath = path.join(tmpRoot, \"dist\", \"zuplo-lint\");\n mkdirSync(path.dirname(devBinaryPath), { recursive: true });\n writeFileSync(devBinaryPath, \"\");\n\n assert.throws(\n () =>\n resolveLintBinary({\n platform: \"linux\",\n arch: \"x64\",\n resolveFrom: path.join(projectDir, \"index.js\"),\n devBinaryPath,\n }),\n (err: unknown) => {\n assert.ok(err instanceof LintBinaryNotFoundError);\n assert.match(err.message, /installed but could not be read/);\n assert.strictEqual(err.packageName, \"@zuplo/lint-linux-x64\");\n return true;\n }\n );\n });\n\n it(\"treats a genuinely absent package as not installed, not an error to rethrow\", () => {\n // The counterpart to the test above: MODULE_NOT_FOUND must stay on the\n // ordinary path so the dev fallback still applies.\n const projectDir = path.join(tmpRoot, \"consumer-absent\");\n mkdirSync(projectDir, { recursive: true });\n\n const devBinaryPath = path.join(tmpRoot, \"dist\", \"zuplo-lint\");\n mkdirSync(path.dirname(devBinaryPath), { recursive: true });\n writeFileSync(devBinaryPath, \"\");\n\n assert.strictEqual(\n resolveLintBinary({\n platform: \"linux\",\n arch: \"x64\",\n resolveFrom: path.join(projectDir, \"index.js\"),\n devBinaryPath,\n }),\n devBinaryPath\n );\n });\n\n it(\"prefers the installed platform package over the repo build output\", () => {\n const projectDir = path.join(tmpRoot, \"consumer-precedence\");\n const pkgDir = path.join(\n projectDir,\n \"node_modules\",\n \"@zuplo\",\n \"lint-linux-x64\"\n );\n mkdirSync(path.join(pkgDir, \"bin\"), { recursive: true });\n writeFileSync(\n path.join(pkgDir, \"package.json\"),\n JSON.stringify({ name: \"@zuplo/lint-linux-x64\", version: \"1.0.0\" })\n );\n const binPath = path.join(pkgDir, \"bin\", \"zuplo-lint\");\n writeFileSync(binPath, \"\");\n\n const devBinaryPath = path.join(tmpRoot, \"dist\", \"zuplo-lint\");\n mkdirSync(path.dirname(devBinaryPath), { recursive: true });\n writeFileSync(devBinaryPath, \"\");\n\n assert.strictEqual(\n resolveLintBinary({\n platform: \"linux\",\n arch: \"x64\",\n resolveFrom: path.join(projectDir, \"index.js\"),\n devBinaryPath,\n }),\n binPath\n );\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.spec.d.ts","sourceRoot":"","sources":["../../../src/open-api/convert/handler.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { convertOpenAPI } from "./handler.js";
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
const testTmpPath = path.join(__dirname, "..", "..", "__tests__", "test-tmp", "convert-handler");
|
|
10
|
-
describe("Convert Handler", () => {
|
|
11
|
-
beforeEach(async () => {
|
|
12
|
-
await fs.mkdir(testTmpPath, { recursive: true });
|
|
13
|
-
});
|
|
14
|
-
afterEach(async () => {
|
|
15
|
-
try {
|
|
16
|
-
await fs.rm(testTmpPath, { recursive: true, force: true });
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
describe("convertOpenAPI", () => {
|
|
22
|
-
it("should convert JSON to YAML using --format yaml", async () => {
|
|
23
|
-
const inputPath = path.join(testTmpPath, "api.json");
|
|
24
|
-
const expectedOutputPath = path.join(testTmpPath, "api.yaml");
|
|
25
|
-
const inputDoc = {
|
|
26
|
-
openapi: "3.1.0",
|
|
27
|
-
info: {
|
|
28
|
-
title: "Test API",
|
|
29
|
-
version: "1.0.0",
|
|
30
|
-
},
|
|
31
|
-
paths: {},
|
|
32
|
-
};
|
|
33
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
34
|
-
await convertOpenAPI({
|
|
35
|
-
input: inputPath,
|
|
36
|
-
format: "yaml",
|
|
37
|
-
});
|
|
38
|
-
const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
|
|
39
|
-
assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
|
|
40
|
-
assert.strictEqual(outputContent.includes("title: Test API"), true);
|
|
41
|
-
});
|
|
42
|
-
it("should convert JSON to YAML using --yaml", async () => {
|
|
43
|
-
const inputPath = path.join(testTmpPath, "api.json");
|
|
44
|
-
const expectedOutputPath = path.join(testTmpPath, "api.yaml");
|
|
45
|
-
const inputDoc = {
|
|
46
|
-
openapi: "3.1.0",
|
|
47
|
-
info: {
|
|
48
|
-
title: "Test API",
|
|
49
|
-
version: "1.0.0",
|
|
50
|
-
},
|
|
51
|
-
paths: {},
|
|
52
|
-
};
|
|
53
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
54
|
-
await convertOpenAPI({
|
|
55
|
-
input: inputPath,
|
|
56
|
-
yaml: true,
|
|
57
|
-
});
|
|
58
|
-
const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
|
|
59
|
-
assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
|
|
60
|
-
});
|
|
61
|
-
it("should convert YAML to JSON using --format json", async () => {
|
|
62
|
-
const inputPath = path.join(testTmpPath, "api.yaml");
|
|
63
|
-
const expectedOutputPath = path.join(testTmpPath, "api.json");
|
|
64
|
-
const inputDoc = `openapi: 3.1.0
|
|
65
|
-
info:
|
|
66
|
-
title: Test API
|
|
67
|
-
version: 1.0.0
|
|
68
|
-
paths: {}`;
|
|
69
|
-
await fs.writeFile(inputPath, inputDoc);
|
|
70
|
-
await convertOpenAPI({
|
|
71
|
-
input: inputPath,
|
|
72
|
-
format: "json",
|
|
73
|
-
});
|
|
74
|
-
const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
|
|
75
|
-
const parsed = JSON.parse(outputContent);
|
|
76
|
-
assert.strictEqual(parsed.openapi, "3.1.0");
|
|
77
|
-
assert.strictEqual(parsed.info.title, "Test API");
|
|
78
|
-
});
|
|
79
|
-
it("should convert YAML to JSON using --json", async () => {
|
|
80
|
-
const inputPath = path.join(testTmpPath, "api.yml");
|
|
81
|
-
const expectedOutputPath = path.join(testTmpPath, "api.json");
|
|
82
|
-
const inputDoc = `openapi: 3.1.0
|
|
83
|
-
info:
|
|
84
|
-
title: Test API
|
|
85
|
-
version: 1.0.0
|
|
86
|
-
paths: {}`;
|
|
87
|
-
await fs.writeFile(inputPath, inputDoc);
|
|
88
|
-
await convertOpenAPI({
|
|
89
|
-
input: inputPath,
|
|
90
|
-
json: true,
|
|
91
|
-
});
|
|
92
|
-
const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
|
|
93
|
-
const parsed = JSON.parse(outputContent);
|
|
94
|
-
assert.strictEqual(parsed.openapi, "3.1.0");
|
|
95
|
-
});
|
|
96
|
-
it("should handle files with multiple dots in name", async () => {
|
|
97
|
-
const inputPath = path.join(testTmpPath, "api.v1.0.json");
|
|
98
|
-
const expectedOutputPath = path.join(testTmpPath, "api.v1.0.yaml");
|
|
99
|
-
const inputDoc = {
|
|
100
|
-
openapi: "3.1.0",
|
|
101
|
-
info: {
|
|
102
|
-
title: "Test API",
|
|
103
|
-
version: "1.0.0",
|
|
104
|
-
},
|
|
105
|
-
paths: {},
|
|
106
|
-
};
|
|
107
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
108
|
-
await convertOpenAPI({
|
|
109
|
-
input: inputPath,
|
|
110
|
-
format: "yaml",
|
|
111
|
-
});
|
|
112
|
-
const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
|
|
113
|
-
assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
|
|
114
|
-
});
|
|
115
|
-
it("should preserve complex nested structures", async () => {
|
|
116
|
-
const inputPath = path.join(testTmpPath, "complex.json");
|
|
117
|
-
const expectedOutputPath = path.join(testTmpPath, "complex.yaml");
|
|
118
|
-
const inputDoc = {
|
|
119
|
-
openapi: "3.1.0",
|
|
120
|
-
info: {
|
|
121
|
-
title: "Complex API",
|
|
122
|
-
version: "1.0.0",
|
|
123
|
-
},
|
|
124
|
-
paths: {
|
|
125
|
-
"/users/{id}": {
|
|
126
|
-
get: {
|
|
127
|
-
parameters: [
|
|
128
|
-
{ name: "id", in: "path", required: true },
|
|
129
|
-
{ name: "fields", in: "query", required: false },
|
|
130
|
-
],
|
|
131
|
-
responses: {
|
|
132
|
-
"200": {
|
|
133
|
-
description: "Success",
|
|
134
|
-
content: {
|
|
135
|
-
"application/json": {
|
|
136
|
-
schema: {
|
|
137
|
-
type: "object",
|
|
138
|
-
properties: {
|
|
139
|
-
id: { type: "string" },
|
|
140
|
-
name: { type: "string" },
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
152
|
-
await convertOpenAPI({
|
|
153
|
-
input: inputPath,
|
|
154
|
-
format: "yaml",
|
|
155
|
-
});
|
|
156
|
-
await convertOpenAPI({
|
|
157
|
-
input: expectedOutputPath,
|
|
158
|
-
format: "json",
|
|
159
|
-
});
|
|
160
|
-
const finalContent = await fs.readFile(inputPath, "utf-8");
|
|
161
|
-
const finalDoc = JSON.parse(finalContent);
|
|
162
|
-
assert.deepStrictEqual(finalDoc, inputDoc);
|
|
163
|
-
});
|
|
164
|
-
it("should create output directory if it doesn't exist", async () => {
|
|
165
|
-
const inputPath = path.join(testTmpPath, "nested", "dir", "api.json");
|
|
166
|
-
const expectedOutputPath = path.join(testTmpPath, "nested", "dir", "api.yaml");
|
|
167
|
-
const inputDoc = {
|
|
168
|
-
openapi: "3.1.0",
|
|
169
|
-
info: {
|
|
170
|
-
title: "Test API",
|
|
171
|
-
version: "1.0.0",
|
|
172
|
-
},
|
|
173
|
-
paths: {},
|
|
174
|
-
};
|
|
175
|
-
await fs.mkdir(path.dirname(inputPath), { recursive: true });
|
|
176
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
177
|
-
await convertOpenAPI({
|
|
178
|
-
input: inputPath,
|
|
179
|
-
format: "yaml",
|
|
180
|
-
});
|
|
181
|
-
const outputContent = await fs.readFile(expectedOutputPath, "utf-8");
|
|
182
|
-
assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
|
|
183
|
-
});
|
|
184
|
-
it("should throw error when no format is specified", async () => {
|
|
185
|
-
const inputPath = path.join(testTmpPath, "api.json");
|
|
186
|
-
const inputDoc = {
|
|
187
|
-
openapi: "3.1.0",
|
|
188
|
-
info: {
|
|
189
|
-
title: "Test API",
|
|
190
|
-
version: "1.0.0",
|
|
191
|
-
},
|
|
192
|
-
paths: {},
|
|
193
|
-
};
|
|
194
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
195
|
-
await assert.rejects(() => convertOpenAPI({
|
|
196
|
-
input: inputPath,
|
|
197
|
-
}), /Output format must be specified/);
|
|
198
|
-
});
|
|
199
|
-
it("should throw error when input format cannot be determined", async () => {
|
|
200
|
-
const inputPath = path.join(testTmpPath, "api.txt");
|
|
201
|
-
await fs.writeFile(inputPath, "content");
|
|
202
|
-
await assert.rejects(() => convertOpenAPI({
|
|
203
|
-
input: inputPath,
|
|
204
|
-
format: "json",
|
|
205
|
-
}), /Unable to determine input format/);
|
|
206
|
-
});
|
|
207
|
-
it("should not convert if input and output formats are the same", async () => {
|
|
208
|
-
const inputPath = path.join(testTmpPath, "api.json");
|
|
209
|
-
const inputDoc = {
|
|
210
|
-
openapi: "3.1.0",
|
|
211
|
-
info: {
|
|
212
|
-
title: "Test API",
|
|
213
|
-
version: "1.0.0",
|
|
214
|
-
},
|
|
215
|
-
paths: {},
|
|
216
|
-
};
|
|
217
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
218
|
-
await convertOpenAPI({
|
|
219
|
-
input: inputPath,
|
|
220
|
-
format: "json",
|
|
221
|
-
});
|
|
222
|
-
const content = await fs.readFile(inputPath, "utf-8");
|
|
223
|
-
const parsed = JSON.parse(content);
|
|
224
|
-
assert.deepStrictEqual(parsed, inputDoc);
|
|
225
|
-
});
|
|
226
|
-
it("should use custom output path when specified", async () => {
|
|
227
|
-
const inputPath = path.join(testTmpPath, "api.json");
|
|
228
|
-
const customOutputPath = path.join(testTmpPath, "custom-name.yaml");
|
|
229
|
-
const inputDoc = {
|
|
230
|
-
openapi: "3.1.0",
|
|
231
|
-
info: {
|
|
232
|
-
title: "Test API",
|
|
233
|
-
version: "1.0.0",
|
|
234
|
-
},
|
|
235
|
-
paths: {},
|
|
236
|
-
};
|
|
237
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
238
|
-
await convertOpenAPI({
|
|
239
|
-
input: inputPath,
|
|
240
|
-
format: "yaml",
|
|
241
|
-
output: customOutputPath,
|
|
242
|
-
});
|
|
243
|
-
const outputContent = await fs.readFile(customOutputPath, "utf-8");
|
|
244
|
-
assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
|
|
245
|
-
assert.strictEqual(outputContent.includes("title: Test API"), true);
|
|
246
|
-
});
|
|
247
|
-
it("should create output directory when using custom output path", async () => {
|
|
248
|
-
const inputPath = path.join(testTmpPath, "api.json");
|
|
249
|
-
const customOutputPath = path.join(testTmpPath, "custom", "output", "dir", "result.yaml");
|
|
250
|
-
const inputDoc = {
|
|
251
|
-
openapi: "3.1.0",
|
|
252
|
-
info: {
|
|
253
|
-
title: "Test API",
|
|
254
|
-
version: "1.0.0",
|
|
255
|
-
},
|
|
256
|
-
paths: {},
|
|
257
|
-
};
|
|
258
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
259
|
-
await convertOpenAPI({
|
|
260
|
-
input: inputPath,
|
|
261
|
-
format: "yaml",
|
|
262
|
-
output: customOutputPath,
|
|
263
|
-
});
|
|
264
|
-
const outputContent = await fs.readFile(customOutputPath, "utf-8");
|
|
265
|
-
assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
|
|
266
|
-
});
|
|
267
|
-
it("should use custom output path with different location", async () => {
|
|
268
|
-
const inputPath = path.join(testTmpPath, "source", "api.json");
|
|
269
|
-
const customOutputPath = path.join(testTmpPath, "output", "api.yaml");
|
|
270
|
-
const inputDoc = {
|
|
271
|
-
openapi: "3.1.0",
|
|
272
|
-
info: {
|
|
273
|
-
title: "Test API",
|
|
274
|
-
version: "1.0.0",
|
|
275
|
-
},
|
|
276
|
-
paths: {},
|
|
277
|
-
};
|
|
278
|
-
await fs.mkdir(path.dirname(inputPath), { recursive: true });
|
|
279
|
-
await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));
|
|
280
|
-
await convertOpenAPI({
|
|
281
|
-
input: inputPath,
|
|
282
|
-
format: "yaml",
|
|
283
|
-
output: customOutputPath,
|
|
284
|
-
});
|
|
285
|
-
const outputContent = await fs.readFile(customOutputPath, "utf-8");
|
|
286
|
-
assert.strictEqual(outputContent.includes("openapi: 3.1.0"), true);
|
|
287
|
-
assert.strictEqual(outputContent.includes("title: Test API"), true);
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
describe("watch flag", () => {
|
|
291
|
-
it("should reject watch mode with non-existent input file", async () => {
|
|
292
|
-
const inputPath = path.join(testTmpPath, "nonexistent.json");
|
|
293
|
-
await assert.rejects(() => convertOpenAPI({
|
|
294
|
-
input: inputPath,
|
|
295
|
-
format: "yaml",
|
|
296
|
-
watch: true,
|
|
297
|
-
}), /Input file not found/);
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
//# sourceMappingURL=handler.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.spec.js","sourceRoot":"","sources":["../../../src/open-api/convert/handler.spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAC3B,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,UAAU,EACV,iBAAiB,CAClB,CAAC;AAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,UAAU,CAAC,KAAK,IAAI,EAAE;QAEpB,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,EA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,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;YACrE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;YAE7D,MAAM,MAAM,CAAC,OAAO,CAClB,GAAG,EAAE,CACH,cAAc,CAAC;gBACb,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,IAAI;aACZ,CAAC,EACJ,sBAAsB,CACvB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { afterEach, beforeEach, describe, it } from \"node:test\";\nimport { fileURLToPath } from \"node:url\";\nimport { convertOpenAPI } from \"./handler.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst testTmpPath = path.join(\n __dirname,\n \"..\",\n \"..\",\n \"__tests__\",\n \"test-tmp\",\n \"convert-handler\"\n);\n\ndescribe(\"Convert Handler\", () => {\n beforeEach(async () => {\n // Ensure test-tmp directory exists\n await fs.mkdir(testTmpPath, { recursive: true });\n });\n\n afterEach(async () => {\n // Clean up test files\n try {\n await fs.rm(testTmpPath, { recursive: true, force: true });\n } catch {\n // Ignore cleanup errors\n }\n });\n\n describe(\"convertOpenAPI\", () => {\n it(\"should convert JSON to YAML using --format yaml\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n const expectedOutputPath = path.join(testTmpPath, \"api.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n assert.strictEqual(outputContent.includes(\"title: Test API\"), true);\n });\n\n it(\"should convert JSON to YAML using --yaml\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n const expectedOutputPath = path.join(testTmpPath, \"api.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n yaml: true,\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n });\n\n it(\"should convert YAML to JSON using --format json\", async () => {\n const inputPath = path.join(testTmpPath, \"api.yaml\");\n const expectedOutputPath = path.join(testTmpPath, \"api.json\");\n\n const inputDoc = `openapi: 3.1.0\ninfo:\n title: Test API\n version: 1.0.0\npaths: {}`;\n\n await fs.writeFile(inputPath, inputDoc);\n\n await convertOpenAPI({\n input: inputPath,\n format: \"json\",\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n const parsed = JSON.parse(outputContent);\n assert.strictEqual(parsed.openapi, \"3.1.0\");\n assert.strictEqual(parsed.info.title, \"Test API\");\n });\n\n it(\"should convert YAML to JSON using --json\", async () => {\n const inputPath = path.join(testTmpPath, \"api.yml\");\n const expectedOutputPath = path.join(testTmpPath, \"api.json\");\n\n const inputDoc = `openapi: 3.1.0\ninfo:\n title: Test API\n version: 1.0.0\npaths: {}`;\n\n await fs.writeFile(inputPath, inputDoc);\n\n await convertOpenAPI({\n input: inputPath,\n json: true,\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n const parsed = JSON.parse(outputContent);\n assert.strictEqual(parsed.openapi, \"3.1.0\");\n });\n\n it(\"should handle files with multiple dots in name\", async () => {\n const inputPath = path.join(testTmpPath, \"api.v1.0.json\");\n const expectedOutputPath = path.join(testTmpPath, \"api.v1.0.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n });\n\n it(\"should preserve complex nested structures\", async () => {\n const inputPath = path.join(testTmpPath, \"complex.json\");\n const expectedOutputPath = path.join(testTmpPath, \"complex.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Complex API\",\n version: \"1.0.0\",\n },\n paths: {\n \"/users/{id}\": {\n get: {\n parameters: [\n { name: \"id\", in: \"path\", required: true },\n { name: \"fields\", in: \"query\", required: false },\n ],\n responses: {\n \"200\": {\n description: \"Success\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n id: { type: \"string\" },\n name: { type: \"string\" },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n });\n\n // Convert back to verify data preservation\n await convertOpenAPI({\n input: expectedOutputPath,\n format: \"json\",\n });\n\n const finalContent = await fs.readFile(inputPath, \"utf-8\");\n const finalDoc = JSON.parse(finalContent);\n assert.deepStrictEqual(finalDoc, inputDoc);\n });\n\n it(\"should create output directory if it doesn't exist\", async () => {\n const inputPath = path.join(testTmpPath, \"nested\", \"dir\", \"api.json\");\n const expectedOutputPath = path.join(\n testTmpPath,\n \"nested\",\n \"dir\",\n \"api.yaml\"\n );\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.mkdir(path.dirname(inputPath), { recursive: true });\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n });\n\n const outputContent = await fs.readFile(expectedOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n });\n\n it(\"should throw error when no format is specified\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await assert.rejects(\n () =>\n convertOpenAPI({\n input: inputPath,\n }),\n /Output format must be specified/\n );\n });\n\n it(\"should throw error when input format cannot be determined\", async () => {\n const inputPath = path.join(testTmpPath, \"api.txt\");\n\n await fs.writeFile(inputPath, \"content\");\n\n await assert.rejects(\n () =>\n convertOpenAPI({\n input: inputPath,\n format: \"json\",\n }),\n /Unable to determine input format/\n );\n });\n\n it(\"should not convert if input and output formats are the same\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n // Should complete without error and not create output file\n await convertOpenAPI({\n input: inputPath,\n format: \"json\",\n });\n\n // Verify original file still exists\n const content = await fs.readFile(inputPath, \"utf-8\");\n const parsed = JSON.parse(content);\n assert.deepStrictEqual(parsed, inputDoc);\n });\n\n it(\"should use custom output path when specified\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n const customOutputPath = path.join(testTmpPath, \"custom-name.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n output: customOutputPath,\n });\n\n const outputContent = await fs.readFile(customOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n assert.strictEqual(outputContent.includes(\"title: Test API\"), true);\n });\n\n it(\"should create output directory when using custom output path\", async () => {\n const inputPath = path.join(testTmpPath, \"api.json\");\n const customOutputPath = path.join(\n testTmpPath,\n \"custom\",\n \"output\",\n \"dir\",\n \"result.yaml\"\n );\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n output: customOutputPath,\n });\n\n const outputContent = await fs.readFile(customOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n });\n\n it(\"should use custom output path with different location\", async () => {\n const inputPath = path.join(testTmpPath, \"source\", \"api.json\");\n const customOutputPath = path.join(testTmpPath, \"output\", \"api.yaml\");\n\n const inputDoc = {\n openapi: \"3.1.0\",\n info: {\n title: \"Test API\",\n version: \"1.0.0\",\n },\n paths: {},\n };\n\n await fs.mkdir(path.dirname(inputPath), { recursive: true });\n await fs.writeFile(inputPath, JSON.stringify(inputDoc, null, 2));\n\n await convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n output: customOutputPath,\n });\n\n const outputContent = await fs.readFile(customOutputPath, \"utf-8\");\n assert.strictEqual(outputContent.includes(\"openapi: 3.1.0\"), true);\n assert.strictEqual(outputContent.includes(\"title: Test API\"), true);\n });\n });\n\n describe(\"watch flag\", () => {\n it(\"should reject watch mode with non-existent input file\", async () => {\n const inputPath = path.join(testTmpPath, \"nonexistent.json\");\n\n await assert.rejects(\n () =>\n convertOpenAPI({\n input: inputPath,\n format: \"yaml\",\n watch: true,\n }),\n /Input file not found/\n );\n });\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.spec.d.ts","sourceRoot":"","sources":["../../../src/open-api/merge/handler.spec.ts"],"names":[],"mappings":""}
|