@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pretty-print-environment-prompt.test.d.ts","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { prettyPrintEnvironmentPrompt } from "./pretty-print-environment-prompt.js";
|
|
4
|
-
function makeEnv(environmentType, name = "my-env", branchName = "main") {
|
|
5
|
-
return {
|
|
6
|
-
name,
|
|
7
|
-
accountName: "acme",
|
|
8
|
-
projectName: "my-project",
|
|
9
|
-
createdOn: null,
|
|
10
|
-
branchName,
|
|
11
|
-
environmentType,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
describe("prettyPrintEnvironmentPrompt", () => {
|
|
15
|
-
describe("working-copy rendering", () => {
|
|
16
|
-
const workingCopyVariants = [
|
|
17
|
-
"working_copy",
|
|
18
|
-
"working-copy",
|
|
19
|
-
"development",
|
|
20
|
-
];
|
|
21
|
-
for (const envType of workingCopyVariants) {
|
|
22
|
-
it(`uses env.name and the recommendation hint for environmentType="${envType}"`, () => {
|
|
23
|
-
const result = prettyPrintEnvironmentPrompt(makeEnv(envType, "wc-slug"));
|
|
24
|
-
assert.strictEqual(result, "wc-slug — recommended for local development");
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
it("renders preview rows as the branch name only", () => {
|
|
29
|
-
const result = prettyPrintEnvironmentPrompt(makeEnv("preview", "env-test-staging-bb91e0b", "staging"));
|
|
30
|
-
assert.strictEqual(result, "staging");
|
|
31
|
-
assert.ok(result.startsWith("s"), `Expected "s" prefix in "${result}"`);
|
|
32
|
-
});
|
|
33
|
-
it("renders production rows as the branch name only", () => {
|
|
34
|
-
const result = prettyPrintEnvironmentPrompt(makeEnv("production", "env-test-prod-xyz789", "main"));
|
|
35
|
-
assert.strictEqual(result, "main");
|
|
36
|
-
});
|
|
37
|
-
it("falls back to env.name when branchName is empty", () => {
|
|
38
|
-
const env = makeEnv("preview", "env-test-fallback-abc123", "");
|
|
39
|
-
assert.strictEqual(prettyPrintEnvironmentPrompt(env), "env-test-fallback-abc123");
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=pretty-print-environment-prompt.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pretty-print-environment-prompt.test.js","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QA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YAAY,EAAE,sBAAsB,EAAE,MAAM,CAAC,CACtD,CAAC;QAEF,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,EAAE,0BAA0B,EAAE,EAAE,CAAC,CAAC;QAE/D,MAAM,CAAC,WAAW,CAChB,4BAA4B,CAAC,GAAG,CAAC,EACjC,0BAA0B,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport { describe, it } from \"node:test\";\nimport { Environment } from \"../api/lib.js\";\nimport { prettyPrintEnvironmentPrompt } from \"./pretty-print-environment-prompt.js\";\n\nfunction makeEnv(\n environmentType: Environment[\"environmentType\"],\n name = \"my-env\",\n branchName = \"main\"\n): Environment {\n return {\n name,\n accountName: \"acme\",\n projectName: \"my-project\",\n createdOn: null,\n branchName,\n environmentType,\n };\n}\n\ndescribe(\"prettyPrintEnvironmentPrompt\", () => {\n describe(\"working-copy rendering\", () => {\n const workingCopyVariants: Environment[\"environmentType\"][] = [\n \"working_copy\",\n \"working-copy\",\n \"development\",\n ];\n for (const envType of workingCopyVariants) {\n it(`uses env.name and the recommendation hint for environmentType=\"${envType}\"`, () => {\n const result = prettyPrintEnvironmentPrompt(\n makeEnv(envType, \"wc-slug\")\n );\n\n assert.strictEqual(\n result,\n \"wc-slug — recommended for local development\"\n );\n });\n }\n });\n\n // The leading character MUST be the user-typed name (env.branchName for\n // preview/production, env.name for working-copy). `@inquirer/prompts/select`\n // matches type-to-jump as `name.toLowerCase().startsWith(searchTerm)`, so a\n // leading slug like \"env-test-…\" or an ANSI escape silently breaks the filter.\n it(\"renders preview rows as the branch name only\", () => {\n const result = prettyPrintEnvironmentPrompt(\n makeEnv(\"preview\", \"env-test-staging-bb91e0b\", \"staging\")\n );\n\n assert.strictEqual(result, \"staging\");\n assert.ok(result.startsWith(\"s\"), `Expected \"s\" prefix in \"${result}\"`);\n });\n\n it(\"renders production rows as the branch name only\", () => {\n const result = prettyPrintEnvironmentPrompt(\n makeEnv(\"production\", \"env-test-prod-xyz789\", \"main\")\n );\n\n assert.strictEqual(result, \"main\");\n });\n\n it(\"falls back to env.name when branchName is empty\", () => {\n const env = makeEnv(\"preview\", \"env-test-fallback-abc123\", \"\");\n\n assert.strictEqual(\n prettyPrintEnvironmentPrompt(env),\n \"env-test-fallback-abc123\"\n );\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sort-environments-for-prompt.test.d.ts","sourceRoot":"","sources":["../../../src/common/utils/sort-environments-for-prompt.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { sortEnvironmentsForPrompt } from "./sort-environments-for-prompt.js";
|
|
4
|
-
function makeEnv(environmentType, name, branchName) {
|
|
5
|
-
return {
|
|
6
|
-
name,
|
|
7
|
-
accountName: "acme",
|
|
8
|
-
projectName: "my-project",
|
|
9
|
-
createdOn: null,
|
|
10
|
-
branchName: branchName ?? name,
|
|
11
|
-
environmentType,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
describe("sortEnvironmentsForPrompt", () => {
|
|
15
|
-
it("orders working-copy first, then preview alpha, then production", () => {
|
|
16
|
-
const envs = [
|
|
17
|
-
makeEnv("production", "prod"),
|
|
18
|
-
makeEnv("preview", "staging-b"),
|
|
19
|
-
makeEnv("working_copy", "wc-1"),
|
|
20
|
-
makeEnv("preview", "staging-a"),
|
|
21
|
-
];
|
|
22
|
-
const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
|
|
23
|
-
assert.deepStrictEqual(result, ["wc-1", "staging-a", "staging-b", "prod"]);
|
|
24
|
-
});
|
|
25
|
-
it("sorts alphabetically within the same bucket", () => {
|
|
26
|
-
const envs = [
|
|
27
|
-
makeEnv("preview", "charlie"),
|
|
28
|
-
makeEnv("preview", "alpha"),
|
|
29
|
-
makeEnv("preview", "bravo"),
|
|
30
|
-
];
|
|
31
|
-
const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
|
|
32
|
-
assert.deepStrictEqual(result, ["alpha", "bravo", "charlie"]);
|
|
33
|
-
});
|
|
34
|
-
it("returns an empty array unchanged", () => {
|
|
35
|
-
assert.deepStrictEqual(sortEnvironmentsForPrompt([]), []);
|
|
36
|
-
});
|
|
37
|
-
it("treats every working-copy type spelling as the same bucket", () => {
|
|
38
|
-
const envs = [
|
|
39
|
-
makeEnv("production", "prod"),
|
|
40
|
-
makeEnv("development", "wc-c"),
|
|
41
|
-
makeEnv("working-copy", "wc-a"),
|
|
42
|
-
makeEnv("working_copy", "wc-b"),
|
|
43
|
-
];
|
|
44
|
-
const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
|
|
45
|
-
assert.deepStrictEqual(result, ["wc-a", "wc-b", "wc-c", "prod"]);
|
|
46
|
-
});
|
|
47
|
-
it("does not mutate the input array", () => {
|
|
48
|
-
const envs = [
|
|
49
|
-
makeEnv("production", "prod"),
|
|
50
|
-
makeEnv("working_copy", "wc"),
|
|
51
|
-
];
|
|
52
|
-
const before = envs.map((e) => e.name);
|
|
53
|
-
sortEnvironmentsForPrompt(envs);
|
|
54
|
-
assert.deepStrictEqual(envs.map((e) => e.name), before);
|
|
55
|
-
});
|
|
56
|
-
it("sorts preview/production rows by branchName (the visible label), not slug", () => {
|
|
57
|
-
const envs = [
|
|
58
|
-
makeEnv("preview", "env-test-zzz", "apple"),
|
|
59
|
-
makeEnv("preview", "env-test-aaa", "zebra"),
|
|
60
|
-
makeEnv("preview", "env-test-mmm", "mango"),
|
|
61
|
-
];
|
|
62
|
-
const result = sortEnvironmentsForPrompt(envs).map((e) => e.branchName);
|
|
63
|
-
assert.deepStrictEqual(result, ["apple", "mango", "zebra"]);
|
|
64
|
-
});
|
|
65
|
-
it("falls back to env.name when a preview env has no branchName", () => {
|
|
66
|
-
const envs = [
|
|
67
|
-
makeEnv("preview", "alpha-slug", "zebra"),
|
|
68
|
-
makeEnv("preview", "bravo-slug", ""),
|
|
69
|
-
];
|
|
70
|
-
const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
|
|
71
|
-
assert.deepStrictEqual(result, ["bravo-slug", "alpha-slug"]);
|
|
72
|
-
});
|
|
73
|
-
it("sorts working-copy rows by env.name (their visible label)", () => {
|
|
74
|
-
const envs = [
|
|
75
|
-
makeEnv("working_copy", "wc-zebra", "main"),
|
|
76
|
-
makeEnv("working_copy", "wc-apple", "main"),
|
|
77
|
-
];
|
|
78
|
-
const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
|
|
79
|
-
assert.deepStrictEqual(result, ["wc-apple", "wc-zebra"]);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
//# sourceMappingURL=sort-environments-for-prompt.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sort-environments-for-prompt.test.js","sourceRoot":"","sources":["../../../src/common/utils/sort-environments-for-prompt.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,SAAS,OAAO,CACd,eAA+C,EAC/C,IAAY,EACZ,UAAmB;IAEnB,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,YAAY;QACzB,SAAS,EAAE,IAAI;QAGf,UAAU,EAAE,UAAU,IAAI,IAAI;QAC9B,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,I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CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;QACrE,MAAM,IAAI,GAAkB;YAC1B,OAAO,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC;YACzC,OAAO,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,CAAC;SACrC,CAAC;QAEF,MAAM,MAAM,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAIlE,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,IAAI,GAAkB;YAC1B,OAAO,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,CAAC;YAC3C,OAAO,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,CAAC;SAC5C,CAAC;QAEF,MAAM,MAAM,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAElE,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport { describe, it } from \"node:test\";\nimport { Environment } from \"../api/lib.js\";\nimport { sortEnvironmentsForPrompt } from \"./sort-environments-for-prompt.js\";\n\nfunction makeEnv(\n environmentType: Environment[\"environmentType\"],\n name: string,\n branchName?: string\n): Environment {\n return {\n name,\n accountName: \"acme\",\n projectName: \"my-project\",\n createdOn: null,\n // Mirror real preview-env data where branchName matches what the user\n // typed at deploy time. Tests can override explicitly when they need to.\n branchName: branchName ?? name,\n environmentType,\n };\n}\n\ndescribe(\"sortEnvironmentsForPrompt\", () => {\n it(\"orders working-copy first, then preview alpha, then production\", () => {\n const envs: Environment[] = [\n makeEnv(\"production\", \"prod\"),\n makeEnv(\"preview\", \"staging-b\"),\n makeEnv(\"working_copy\", \"wc-1\"),\n makeEnv(\"preview\", \"staging-a\"),\n ];\n\n const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);\n\n assert.deepStrictEqual(result, [\"wc-1\", \"staging-a\", \"staging-b\", \"prod\"]);\n });\n\n it(\"sorts alphabetically within the same bucket\", () => {\n const envs: Environment[] = [\n makeEnv(\"preview\", \"charlie\"),\n makeEnv(\"preview\", \"alpha\"),\n makeEnv(\"preview\", \"bravo\"),\n ];\n\n const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);\n\n assert.deepStrictEqual(result, [\"alpha\", \"bravo\", \"charlie\"]);\n });\n\n it(\"returns an empty array unchanged\", () => {\n assert.deepStrictEqual(sortEnvironmentsForPrompt([]), []);\n });\n\n it(\"treats every working-copy type spelling as the same bucket\", () => {\n const envs: Environment[] = [\n makeEnv(\"production\", \"prod\"),\n makeEnv(\"development\", \"wc-c\"),\n makeEnv(\"working-copy\", \"wc-a\"),\n makeEnv(\"working_copy\", \"wc-b\"),\n ];\n\n const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);\n\n assert.deepStrictEqual(result, [\"wc-a\", \"wc-b\", \"wc-c\", \"prod\"]);\n });\n\n it(\"does not mutate the input array\", () => {\n const envs: Environment[] = [\n makeEnv(\"production\", \"prod\"),\n makeEnv(\"working_copy\", \"wc\"),\n ];\n const before = envs.map((e) => e.name);\n\n sortEnvironmentsForPrompt(envs);\n\n assert.deepStrictEqual(\n envs.map((e) => e.name),\n before\n );\n });\n\n it(\"sorts preview/production rows by branchName (the visible label), not slug\", () => {\n const envs: Environment[] = [\n makeEnv(\"preview\", \"env-test-zzz\", \"apple\"),\n makeEnv(\"preview\", \"env-test-aaa\", \"zebra\"),\n makeEnv(\"preview\", \"env-test-mmm\", \"mango\"),\n ];\n\n const result = sortEnvironmentsForPrompt(envs).map((e) => e.branchName);\n\n assert.deepStrictEqual(result, [\"apple\", \"mango\", \"zebra\"]);\n });\n\n it(\"falls back to env.name when a preview env has no branchName\", () => {\n const envs: Environment[] = [\n makeEnv(\"preview\", \"alpha-slug\", \"zebra\"),\n makeEnv(\"preview\", \"bravo-slug\", \"\"),\n ];\n\n const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);\n\n // bravo-slug has empty branchName so falls back to its slug \"bravo-slug\",\n // which sorts before \"zebra\".\n assert.deepStrictEqual(result, [\"bravo-slug\", \"alpha-slug\"]);\n });\n\n it(\"sorts working-copy rows by env.name (their visible label)\", () => {\n const envs: Environment[] = [\n makeEnv(\"working_copy\", \"wc-zebra\", \"main\"),\n makeEnv(\"working_copy\", \"wc-apple\", \"main\"),\n ];\n\n const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);\n\n assert.deepStrictEqual(result, [\"wc-apple\", \"wc-zebra\"]);\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-config.test.d.ts","sourceRoot":"","sources":["../../../src/common/utils/stringify-config.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { strictEqual } from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { stringifyConfig } from "./stringify-config.js";
|
|
4
|
-
describe("stringifyConfig", () => {
|
|
5
|
-
it("should handle env var patterns", () => {
|
|
6
|
-
const config = {
|
|
7
|
-
enabled: true,
|
|
8
|
-
count: 42,
|
|
9
|
-
ratio: 3.14,
|
|
10
|
-
empty: null,
|
|
11
|
-
notDefined: undefined,
|
|
12
|
-
normalString: "regular string",
|
|
13
|
-
apiKey: "$env(API_KEY)",
|
|
14
|
-
dbUrl: "$env(DATABASE_URL)",
|
|
15
|
-
title: "$env(APP_TITLE) Portal",
|
|
16
|
-
baseUrl: "https://$env(DOMAIN)",
|
|
17
|
-
fullUrl: "https://$env(HOST):$env(PORT)/api",
|
|
18
|
-
message: "$env(APP_NAME) version $env(VERSION)",
|
|
19
|
-
secret: "$env(JWT_SECRET_KEY_123)",
|
|
20
|
-
description: 'App "with quotes" $env(APP_NAME)',
|
|
21
|
-
multiline: "Line1\nLine2 $env(VAR)",
|
|
22
|
-
metadata: {
|
|
23
|
-
favicon: "$env(FAVICON_URL)",
|
|
24
|
-
title: "Welcome to $env(SITE_NAME)",
|
|
25
|
-
},
|
|
26
|
-
navigation: [
|
|
27
|
-
"$env(HOME_PATH)",
|
|
28
|
-
"static/path",
|
|
29
|
-
"prefix $env(DYNAMIC_PATH)",
|
|
30
|
-
"$env(API_PATH) suffix",
|
|
31
|
-
],
|
|
32
|
-
authentication: {
|
|
33
|
-
oauth: {
|
|
34
|
-
clientId: "$env(OAUTH_CLIENT_ID)",
|
|
35
|
-
issuer: "$env(OAUTH_ISSUER)/auth",
|
|
36
|
-
scopes: ["read", "$env(OAUTH_SCOPE)"],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
const expected = `{
|
|
41
|
-
enabled: true,
|
|
42
|
-
count: 42,
|
|
43
|
-
ratio: 3.14,
|
|
44
|
-
empty: null,
|
|
45
|
-
notDefined: undefined,
|
|
46
|
-
normalString: 'regular string',
|
|
47
|
-
apiKey: process.env.API_KEY,
|
|
48
|
-
dbUrl: process.env.DATABASE_URL,
|
|
49
|
-
title: process.env.APP_TITLE + " Portal",
|
|
50
|
-
baseUrl: "https://" + process.env.DOMAIN,
|
|
51
|
-
fullUrl: "https://" + process.env.HOST + ":" + process.env.PORT + "/api",
|
|
52
|
-
message: process.env.APP_NAME + " version " + process.env.VERSION,
|
|
53
|
-
secret: process.env.JWT_SECRET_KEY_123,
|
|
54
|
-
description: "App \\"with quotes\\" " + process.env.APP_NAME,
|
|
55
|
-
multiline: "Line1\\nLine2 " + process.env.VAR,
|
|
56
|
-
metadata: {
|
|
57
|
-
favicon: process.env.FAVICON_URL,
|
|
58
|
-
title: "Welcome to " + process.env.SITE_NAME
|
|
59
|
-
},
|
|
60
|
-
navigation: [
|
|
61
|
-
process.env.HOME_PATH,
|
|
62
|
-
'static/path',
|
|
63
|
-
"prefix " + process.env.DYNAMIC_PATH,
|
|
64
|
-
process.env.API_PATH + " suffix"
|
|
65
|
-
],
|
|
66
|
-
authentication: {
|
|
67
|
-
oauth: {
|
|
68
|
-
clientId: process.env.OAUTH_CLIENT_ID,
|
|
69
|
-
issuer: process.env.OAUTH_ISSUER + "/auth",
|
|
70
|
-
scopes: [
|
|
71
|
-
'read',
|
|
72
|
-
process.env.OAUTH_SCOPE
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}`;
|
|
77
|
-
strictEqual(stringifyConfig(config), expected);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
//# sourceMappingURL=stringify-config.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-config.test.js","sourceRoot":"","sources":["../../../src/common/utils/stringify-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,MAAM,GAAG;YAEb,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,SAAS;YACrB,YAAY,EAAE,gBAAgB;YAG9B,MAAM,EAAE,eAAe;YACvB,KAAK,EAAE,oBAAoB;YAG3B,KAAK,EAAE,wBAAwB;YAC/B,OAAO,EAAE,sBAAsB;YAC/B,OAAO,EAAE,mCAAmC;YAG5C,OAAO,EAAE,sCAAsC;YAG/C,MAAM,EAAE,0BAA0B;YAGlC,WAAW,EAAE,kCAAkC;YAC/C,SAAS,EAAE,wBAAwB;YAGnC,QAAQ,EAAE;gBACR,OAAO,EAAE,mBAAmB;gBAC5B,KAAK,EAAE,4BAA4B;aACpC;YAGD,UAAU,EAAE;gBACV,iBAAiB;gBACjB,aAAa;gBACb,2BAA2B;gBAC3B,uBAAuB;aACxB;YAGD,cAAc,EAAE;gBACd,KAAK,EAAE;oBACL,QAAQ,EAAE,uBAAuB;oBACjC,MAAM,EAAE,yBAAyB;oBACjC,MAAM,EAAE,CAAC,MAAM,EAAE,mBAAmB,CAAC;iBACtC;aACF;SACF,CAAC;QAEF,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCnB,CAAC;QAEC,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { strictEqual } from \"node:assert\";\nimport { describe, it } from \"node:test\";\nimport { stringifyConfig } from \"./stringify-config.js\";\n\ndescribe(\"stringifyConfig\", () => {\n it(\"should handle env var patterns\", () => {\n const config = {\n // Simple values without env vars\n enabled: true,\n count: 42,\n ratio: 3.14,\n empty: null,\n notDefined: undefined,\n normalString: \"regular string\",\n\n // Env vars - complete replacement\n apiKey: \"$env(API_KEY)\",\n dbUrl: \"$env(DATABASE_URL)\",\n\n // Env vars with prefixes, suffixes, and both\n title: \"$env(APP_TITLE) Portal\",\n baseUrl: \"https://$env(DOMAIN)\",\n fullUrl: \"https://$env(HOST):$env(PORT)/api\",\n\n // Multiple env vars in one string\n message: \"$env(APP_NAME) version $env(VERSION)\",\n\n // Env vars with underscores and numbers\n secret: \"$env(JWT_SECRET_KEY_123)\",\n\n // Special characters in non-env parts\n description: 'App \"with quotes\" $env(APP_NAME)',\n multiline: \"Line1\\nLine2 $env(VAR)\",\n\n // Nested objects\n metadata: {\n favicon: \"$env(FAVICON_URL)\",\n title: \"Welcome to $env(SITE_NAME)\",\n },\n\n // Arrays with mixed content\n navigation: [\n \"$env(HOME_PATH)\",\n \"static/path\",\n \"prefix $env(DYNAMIC_PATH)\",\n \"$env(API_PATH) suffix\",\n ],\n\n // Deep nesting\n authentication: {\n oauth: {\n clientId: \"$env(OAUTH_CLIENT_ID)\",\n issuer: \"$env(OAUTH_ISSUER)/auth\",\n scopes: [\"read\", \"$env(OAUTH_SCOPE)\"],\n },\n },\n };\n\n const expected = `{\n enabled: true,\n count: 42,\n ratio: 3.14,\n empty: null,\n notDefined: undefined,\n normalString: 'regular string',\n apiKey: process.env.API_KEY,\n dbUrl: process.env.DATABASE_URL,\n title: process.env.APP_TITLE + \" Portal\",\n baseUrl: \"https://\" + process.env.DOMAIN,\n fullUrl: \"https://\" + process.env.HOST + \":\" + process.env.PORT + \"/api\",\n message: process.env.APP_NAME + \" version \" + process.env.VERSION,\n secret: process.env.JWT_SECRET_KEY_123,\n description: \"App \\\\\"with quotes\\\\\" \" + process.env.APP_NAME,\n multiline: \"Line1\\\\nLine2 \" + process.env.VAR,\n metadata: {\n favicon: process.env.FAVICON_URL,\n title: \"Welcome to \" + process.env.SITE_NAME\n },\n navigation: [\n process.env.HOME_PATH,\n 'static/path',\n \"prefix \" + process.env.DYNAMIC_PATH,\n process.env.API_PATH + \" suffix\"\n ],\n authentication: {\n oauth: {\n clientId: process.env.OAUTH_CLIENT_ID,\n issuer: process.env.OAUTH_ISSUER + \"/auth\",\n scopes: [\n 'read',\n process.env.OAUTH_SCOPE\n ]\n }\n }\n}`;\n\n strictEqual(stringifyConfig(config), expected);\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"argument-validators.spec.d.ts","sourceRoot":"","sources":["../../../src/common/validators/argument-validators.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,181 +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 { isUrl, validateDirectoryExists, validateFileExists, validateFileExtension, validateFileOrUrl, validatePattern, validatePort, validateUrl, } from "./argument-validators.js";
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
const testTmpPath = path.join(__dirname, "..", "..", "__tests__", "test-tmp", "argument-validators");
|
|
10
|
-
describe("argument-validators", () => {
|
|
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("validateFileExists", () => {
|
|
22
|
-
it("should return resolved path for existing readable file", async () => {
|
|
23
|
-
const filePath = path.join(testTmpPath, "test-file.txt");
|
|
24
|
-
await fs.writeFile(filePath, "test content");
|
|
25
|
-
const result = validateFileExists(filePath, "--source");
|
|
26
|
-
assert.strictEqual(result, path.resolve(filePath));
|
|
27
|
-
});
|
|
28
|
-
it("should throw error for non-existent file", () => {
|
|
29
|
-
const filePath = path.join(testTmpPath, "nonexistent.txt");
|
|
30
|
-
assert.throws(() => validateFileExists(filePath, "--source"), /--source: File not found:/);
|
|
31
|
-
});
|
|
32
|
-
it("should throw error when path is a directory", async () => {
|
|
33
|
-
const dirPath = path.join(testTmpPath, "some-dir");
|
|
34
|
-
await fs.mkdir(dirPath, { recursive: true });
|
|
35
|
-
assert.throws(() => validateFileExists(dirPath, "--file"), /--file: Path is not a file:/);
|
|
36
|
-
});
|
|
37
|
-
it("should include option name in error message", () => {
|
|
38
|
-
const filePath = path.join(testTmpPath, "missing.txt");
|
|
39
|
-
assert.throws(() => validateFileExists(filePath, "--my-option"), /--my-option: File not found:/);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe("validateDirectoryExists", () => {
|
|
43
|
-
it("should return resolved path for existing readable directory", async () => {
|
|
44
|
-
const dirPath = path.join(testTmpPath, "test-dir");
|
|
45
|
-
await fs.mkdir(dirPath, { recursive: true });
|
|
46
|
-
const result = validateDirectoryExists(dirPath, "--dir");
|
|
47
|
-
assert.strictEqual(result, path.resolve(dirPath));
|
|
48
|
-
});
|
|
49
|
-
it("should throw error for non-existent directory", () => {
|
|
50
|
-
const dirPath = path.join(testTmpPath, "nonexistent-dir");
|
|
51
|
-
assert.throws(() => validateDirectoryExists(dirPath, "--dir"), /--dir: Directory not found:/);
|
|
52
|
-
});
|
|
53
|
-
it("should throw error when path is a file", async () => {
|
|
54
|
-
const filePath = path.join(testTmpPath, "file.txt");
|
|
55
|
-
await fs.writeFile(filePath, "content");
|
|
56
|
-
assert.throws(() => validateDirectoryExists(filePath, "--directory"), /--directory: Path is not a directory:/);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
describe("validatePort", () => {
|
|
60
|
-
it("should return port for valid port number", () => {
|
|
61
|
-
assert.strictEqual(validatePort(80, "--port"), 80);
|
|
62
|
-
assert.strictEqual(validatePort(443, "--port"), 443);
|
|
63
|
-
assert.strictEqual(validatePort(8080, "--port"), 8080);
|
|
64
|
-
assert.strictEqual(validatePort(1, "--port"), 1);
|
|
65
|
-
assert.strictEqual(validatePort(65535, "--port"), 65535);
|
|
66
|
-
});
|
|
67
|
-
it("should throw error for port less than 1", () => {
|
|
68
|
-
assert.throws(() => validatePort(0, "--port"), /--port: Port must be between 1 and 65535, got: 0/);
|
|
69
|
-
});
|
|
70
|
-
it("should throw error for port greater than 65535", () => {
|
|
71
|
-
assert.throws(() => validatePort(65536, "--port"), /--port: Port must be between 1 and 65535, got: 65536/);
|
|
72
|
-
});
|
|
73
|
-
it("should throw error for negative port", () => {
|
|
74
|
-
assert.throws(() => validatePort(-1, "--port"), /--port: Port must be between 1 and 65535, got: -1/);
|
|
75
|
-
});
|
|
76
|
-
it("should throw error for non-integer port", () => {
|
|
77
|
-
assert.throws(() => validatePort(80.5, "--port"), /--port: Port must be an integer, got: 80.5/);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
describe("validateUrl", () => {
|
|
81
|
-
it("should return URL for valid http URL", () => {
|
|
82
|
-
const url = "http://example.com/api";
|
|
83
|
-
assert.strictEqual(validateUrl(url, "--url"), url);
|
|
84
|
-
});
|
|
85
|
-
it("should return URL for valid https URL", () => {
|
|
86
|
-
const url = "https://api.example.com/v1/openapi.json";
|
|
87
|
-
assert.strictEqual(validateUrl(url, "--url"), url);
|
|
88
|
-
});
|
|
89
|
-
it("should throw error for invalid URL format", () => {
|
|
90
|
-
assert.throws(() => validateUrl("not-a-url", "--url"), /--url: Invalid URL format:/);
|
|
91
|
-
});
|
|
92
|
-
it("should throw error for non-http/https protocol", () => {
|
|
93
|
-
assert.throws(() => validateUrl("ftp://example.com/file", "--url"), /--url: URL must use http or https protocol, got: ftp:/);
|
|
94
|
-
});
|
|
95
|
-
it("should throw error for file protocol", () => {
|
|
96
|
-
assert.throws(() => validateUrl("file:///path/to/file", "--source"), /--source: URL must use http or https protocol, got: file:/);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
describe("validateFileExtension", () => {
|
|
100
|
-
it("should return file path for valid extension", () => {
|
|
101
|
-
const filePath = "test.json";
|
|
102
|
-
const result = validateFileExtension(filePath, [".json"], "--file");
|
|
103
|
-
assert.strictEqual(result, filePath);
|
|
104
|
-
});
|
|
105
|
-
it("should accept any of multiple valid extensions", () => {
|
|
106
|
-
const jsonPath = "test.json";
|
|
107
|
-
const yamlPath = "test.yaml";
|
|
108
|
-
const ymlPath = "test.yml";
|
|
109
|
-
assert.strictEqual(validateFileExtension(jsonPath, [".json", ".yaml", ".yml"], "--file"), jsonPath);
|
|
110
|
-
assert.strictEqual(validateFileExtension(yamlPath, [".json", ".yaml", ".yml"], "--file"), yamlPath);
|
|
111
|
-
assert.strictEqual(validateFileExtension(ymlPath, [".json", ".yaml", ".yml"], "--file"), ymlPath);
|
|
112
|
-
});
|
|
113
|
-
it("should throw error for invalid extension", () => {
|
|
114
|
-
assert.throws(() => validateFileExtension("test.txt", [".json"], "--file"), /--file: File must have one of these extensions: .json, got: .txt/);
|
|
115
|
-
});
|
|
116
|
-
it("should throw error when file has no extension", () => {
|
|
117
|
-
assert.throws(() => validateFileExtension("Makefile", [".json", ".yaml"], "--file"), /--file: File must have one of these extensions: .json, .yaml, got: \(none\)/);
|
|
118
|
-
});
|
|
119
|
-
it("should handle case-insensitive extension matching", () => {
|
|
120
|
-
const result = validateFileExtension("test.JSON", [".json"], "--file");
|
|
121
|
-
assert.strictEqual(result, "test.JSON");
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
describe("validatePattern", () => {
|
|
125
|
-
it("should return value when pattern matches", () => {
|
|
126
|
-
const result = validatePattern("abc123", /^[a-z0-9]+$/, "--name", "contain only lowercase letters and numbers");
|
|
127
|
-
assert.strictEqual(result, "abc123");
|
|
128
|
-
});
|
|
129
|
-
it("should throw error when pattern does not match", () => {
|
|
130
|
-
assert.throws(() => validatePattern("ABC-123", /^[a-z0-9]+$/, "--name", "contain only lowercase letters and numbers"), /--name: Value must contain only lowercase letters and numbers/);
|
|
131
|
-
});
|
|
132
|
-
it("should handle email pattern validation", () => {
|
|
133
|
-
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
134
|
-
const result = validatePattern("user@example.com", emailPattern, "--email", "be a valid email address");
|
|
135
|
-
assert.strictEqual(result, "user@example.com");
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
describe("isUrl", () => {
|
|
139
|
-
it("should return true for http URLs", () => {
|
|
140
|
-
assert.strictEqual(isUrl("http://example.com"), true);
|
|
141
|
-
assert.strictEqual(isUrl("http://localhost:8080/api"), true);
|
|
142
|
-
});
|
|
143
|
-
it("should return true for https URLs", () => {
|
|
144
|
-
assert.strictEqual(isUrl("https://api.example.com/v1"), true);
|
|
145
|
-
assert.strictEqual(isUrl("https://example.com:443/path"), true);
|
|
146
|
-
});
|
|
147
|
-
it("should return false for file paths", () => {
|
|
148
|
-
assert.strictEqual(isUrl("./path/to/file.json"), false);
|
|
149
|
-
assert.strictEqual(isUrl("/absolute/path/file.yaml"), false);
|
|
150
|
-
assert.strictEqual(isUrl("relative/path.json"), false);
|
|
151
|
-
});
|
|
152
|
-
it("should return false for non-http/https URLs", () => {
|
|
153
|
-
assert.strictEqual(isUrl("ftp://example.com/file"), false);
|
|
154
|
-
assert.strictEqual(isUrl("file:///path/to/file"), false);
|
|
155
|
-
});
|
|
156
|
-
it("should return false for invalid URLs", () => {
|
|
157
|
-
assert.strictEqual(isUrl("not a url"), false);
|
|
158
|
-
assert.strictEqual(isUrl(""), false);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
describe("validateFileOrUrl", () => {
|
|
162
|
-
it("should return URL for valid http URL", () => {
|
|
163
|
-
const url = "https://api.example.com/openapi.json";
|
|
164
|
-
assert.strictEqual(validateFileOrUrl(url, "--source"), url);
|
|
165
|
-
});
|
|
166
|
-
it("should return resolved path for existing file", async () => {
|
|
167
|
-
const filePath = path.join(testTmpPath, "api.json");
|
|
168
|
-
await fs.writeFile(filePath, "{}");
|
|
169
|
-
const result = validateFileOrUrl(filePath, "--source");
|
|
170
|
-
assert.strictEqual(result, path.resolve(filePath));
|
|
171
|
-
});
|
|
172
|
-
it("should throw error for non-existent file path", () => {
|
|
173
|
-
const filePath = path.join(testTmpPath, "missing.json");
|
|
174
|
-
assert.throws(() => validateFileOrUrl(filePath, "--source"), /--source: File not found:/);
|
|
175
|
-
});
|
|
176
|
-
it("should throw error for invalid URL format when not a file", () => {
|
|
177
|
-
assert.throws(() => validateFileOrUrl("ftp://example.com/file", "--source"), /--source: File not found:/);
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
//# sourceMappingURL=argument-validators.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"argument-validators.spec.js","sourceRoot":"","sources":["../../../src/common/validators/argument-validators.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,EACL,KAAK,EACL,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAElC,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,qBAAqB,CACtB,CAAC;AAEF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,EAAE,CAAC,WAAW,EA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C,MAAM,GAAG,GAAG,sCAAsC,CAAC;YACnD,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;YAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;YACpD,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAEnC,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YACvD,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAExD,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,EAC7C,2BAA2B,CAC5B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;YACnE,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,UAAU,CAAC,EAC7D,2BAA2B,CAC5B,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 {\n isUrl,\n validateDirectoryExists,\n validateFileExists,\n validateFileExtension,\n validateFileOrUrl,\n validatePattern,\n validatePort,\n validateUrl,\n} from \"./argument-validators.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 \"argument-validators\"\n);\n\ndescribe(\"argument-validators\", () => {\n beforeEach(async () => {\n await fs.mkdir(testTmpPath, { recursive: true });\n });\n\n afterEach(async () => {\n try {\n await fs.rm(testTmpPath, { recursive: true, force: true });\n } catch {\n // Ignore cleanup errors\n }\n });\n\n describe(\"validateFileExists\", () => {\n it(\"should return resolved path for existing readable file\", async () => {\n const filePath = path.join(testTmpPath, \"test-file.txt\");\n await fs.writeFile(filePath, \"test content\");\n\n const result = validateFileExists(filePath, \"--source\");\n assert.strictEqual(result, path.resolve(filePath));\n });\n\n it(\"should throw error for non-existent file\", () => {\n const filePath = path.join(testTmpPath, \"nonexistent.txt\");\n\n assert.throws(\n () => validateFileExists(filePath, \"--source\"),\n /--source: File not found:/\n );\n });\n\n it(\"should throw error when path is a directory\", async () => {\n const dirPath = path.join(testTmpPath, \"some-dir\");\n await fs.mkdir(dirPath, { recursive: true });\n\n assert.throws(\n () => validateFileExists(dirPath, \"--file\"),\n /--file: Path is not a file:/\n );\n });\n\n it(\"should include option name in error message\", () => {\n const filePath = path.join(testTmpPath, \"missing.txt\");\n\n assert.throws(\n () => validateFileExists(filePath, \"--my-option\"),\n /--my-option: File not found:/\n );\n });\n });\n\n describe(\"validateDirectoryExists\", () => {\n it(\"should return resolved path for existing readable directory\", async () => {\n const dirPath = path.join(testTmpPath, \"test-dir\");\n await fs.mkdir(dirPath, { recursive: true });\n\n const result = validateDirectoryExists(dirPath, \"--dir\");\n assert.strictEqual(result, path.resolve(dirPath));\n });\n\n it(\"should throw error for non-existent directory\", () => {\n const dirPath = path.join(testTmpPath, \"nonexistent-dir\");\n\n assert.throws(\n () => validateDirectoryExists(dirPath, \"--dir\"),\n /--dir: Directory not found:/\n );\n });\n\n it(\"should throw error when path is a file\", async () => {\n const filePath = path.join(testTmpPath, \"file.txt\");\n await fs.writeFile(filePath, \"content\");\n\n assert.throws(\n () => validateDirectoryExists(filePath, \"--directory\"),\n /--directory: Path is not a directory:/\n );\n });\n });\n\n describe(\"validatePort\", () => {\n it(\"should return port for valid port number\", () => {\n assert.strictEqual(validatePort(80, \"--port\"), 80);\n assert.strictEqual(validatePort(443, \"--port\"), 443);\n assert.strictEqual(validatePort(8080, \"--port\"), 8080);\n assert.strictEqual(validatePort(1, \"--port\"), 1);\n assert.strictEqual(validatePort(65535, \"--port\"), 65535);\n });\n\n it(\"should throw error for port less than 1\", () => {\n assert.throws(\n () => validatePort(0, \"--port\"),\n /--port: Port must be between 1 and 65535, got: 0/\n );\n });\n\n it(\"should throw error for port greater than 65535\", () => {\n assert.throws(\n () => validatePort(65536, \"--port\"),\n /--port: Port must be between 1 and 65535, got: 65536/\n );\n });\n\n it(\"should throw error for negative port\", () => {\n assert.throws(\n () => validatePort(-1, \"--port\"),\n /--port: Port must be between 1 and 65535, got: -1/\n );\n });\n\n it(\"should throw error for non-integer port\", () => {\n assert.throws(\n () => validatePort(80.5, \"--port\"),\n /--port: Port must be an integer, got: 80.5/\n );\n });\n });\n\n describe(\"validateUrl\", () => {\n it(\"should return URL for valid http URL\", () => {\n const url = \"http://example.com/api\";\n assert.strictEqual(validateUrl(url, \"--url\"), url);\n });\n\n it(\"should return URL for valid https URL\", () => {\n const url = \"https://api.example.com/v1/openapi.json\";\n assert.strictEqual(validateUrl(url, \"--url\"), url);\n });\n\n it(\"should throw error for invalid URL format\", () => {\n assert.throws(\n () => validateUrl(\"not-a-url\", \"--url\"),\n /--url: Invalid URL format:/\n );\n });\n\n it(\"should throw error for non-http/https protocol\", () => {\n assert.throws(\n () => validateUrl(\"ftp://example.com/file\", \"--url\"),\n /--url: URL must use http or https protocol, got: ftp:/\n );\n });\n\n it(\"should throw error for file protocol\", () => {\n assert.throws(\n () => validateUrl(\"file:///path/to/file\", \"--source\"),\n /--source: URL must use http or https protocol, got: file:/\n );\n });\n });\n\n describe(\"validateFileExtension\", () => {\n it(\"should return file path for valid extension\", () => {\n const filePath = \"test.json\";\n const result = validateFileExtension(filePath, [\".json\"], \"--file\");\n assert.strictEqual(result, filePath);\n });\n\n it(\"should accept any of multiple valid extensions\", () => {\n const jsonPath = \"test.json\";\n const yamlPath = \"test.yaml\";\n const ymlPath = \"test.yml\";\n\n assert.strictEqual(\n validateFileExtension(jsonPath, [\".json\", \".yaml\", \".yml\"], \"--file\"),\n jsonPath\n );\n assert.strictEqual(\n validateFileExtension(yamlPath, [\".json\", \".yaml\", \".yml\"], \"--file\"),\n yamlPath\n );\n assert.strictEqual(\n validateFileExtension(ymlPath, [\".json\", \".yaml\", \".yml\"], \"--file\"),\n ymlPath\n );\n });\n\n it(\"should throw error for invalid extension\", () => {\n assert.throws(\n () => validateFileExtension(\"test.txt\", [\".json\"], \"--file\"),\n /--file: File must have one of these extensions: .json, got: .txt/\n );\n });\n\n it(\"should throw error when file has no extension\", () => {\n assert.throws(\n () => validateFileExtension(\"Makefile\", [\".json\", \".yaml\"], \"--file\"),\n /--file: File must have one of these extensions: .json, .yaml, got: \\(none\\)/\n );\n });\n\n it(\"should handle case-insensitive extension matching\", () => {\n const result = validateFileExtension(\"test.JSON\", [\".json\"], \"--file\");\n assert.strictEqual(result, \"test.JSON\");\n });\n });\n\n describe(\"validatePattern\", () => {\n it(\"should return value when pattern matches\", () => {\n const result = validatePattern(\n \"abc123\",\n /^[a-z0-9]+$/,\n \"--name\",\n \"contain only lowercase letters and numbers\"\n );\n assert.strictEqual(result, \"abc123\");\n });\n\n it(\"should throw error when pattern does not match\", () => {\n assert.throws(\n () =>\n validatePattern(\n \"ABC-123\",\n /^[a-z0-9]+$/,\n \"--name\",\n \"contain only lowercase letters and numbers\"\n ),\n /--name: Value must contain only lowercase letters and numbers/\n );\n });\n\n it(\"should handle email pattern validation\", () => {\n const emailPattern = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n const result = validatePattern(\n \"user@example.com\",\n emailPattern,\n \"--email\",\n \"be a valid email address\"\n );\n assert.strictEqual(result, \"user@example.com\");\n });\n });\n\n describe(\"isUrl\", () => {\n it(\"should return true for http URLs\", () => {\n assert.strictEqual(isUrl(\"http://example.com\"), true);\n assert.strictEqual(isUrl(\"http://localhost:8080/api\"), true);\n });\n\n it(\"should return true for https URLs\", () => {\n assert.strictEqual(isUrl(\"https://api.example.com/v1\"), true);\n assert.strictEqual(isUrl(\"https://example.com:443/path\"), true);\n });\n\n it(\"should return false for file paths\", () => {\n assert.strictEqual(isUrl(\"./path/to/file.json\"), false);\n assert.strictEqual(isUrl(\"/absolute/path/file.yaml\"), false);\n assert.strictEqual(isUrl(\"relative/path.json\"), false);\n });\n\n it(\"should return false for non-http/https URLs\", () => {\n assert.strictEqual(isUrl(\"ftp://example.com/file\"), false);\n assert.strictEqual(isUrl(\"file:///path/to/file\"), false);\n });\n\n it(\"should return false for invalid URLs\", () => {\n assert.strictEqual(isUrl(\"not a url\"), false);\n assert.strictEqual(isUrl(\"\"), false);\n });\n });\n\n describe(\"validateFileOrUrl\", () => {\n it(\"should return URL for valid http URL\", () => {\n const url = \"https://api.example.com/openapi.json\";\n assert.strictEqual(validateFileOrUrl(url, \"--source\"), url);\n });\n\n it(\"should return resolved path for existing file\", async () => {\n const filePath = path.join(testTmpPath, \"api.json\");\n await fs.writeFile(filePath, \"{}\");\n\n const result = validateFileOrUrl(filePath, \"--source\");\n assert.strictEqual(result, path.resolve(filePath));\n });\n\n it(\"should throw error for non-existent file path\", () => {\n const filePath = path.join(testTmpPath, \"missing.json\");\n\n assert.throws(\n () => validateFileOrUrl(filePath, \"--source\"),\n /--source: File not found:/\n );\n });\n\n it(\"should throw error for invalid URL format when not a file\", () => {\n assert.throws(\n () => validateFileOrUrl(\"ftp://example.com/file\", \"--source\"),\n /--source: File not found:/\n );\n });\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-output.test.d.ts","sourceRoot":"","sources":["../../src/common/worker-output.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { classifyGatewayLine } from "./worker-output.js";
|
|
4
|
-
describe("classifyGatewayLine", () => {
|
|
5
|
-
it("reads tracing lines, colored or not, without the gateway's timestamp", () => {
|
|
6
|
-
assert.deepEqual(classifyGatewayLine("\u001b[2m2026-10-11T01:42:43.470549Z\u001b[0m \u001b[32m INFO\u001b[0m \u001b[2mzuplo_gateway\u001b[0m\u001b[2m:\u001b[0m listening \u001b[3maddr\u001b[0m\u001b[2m=\u001b[0m0.0.0.0:9000"), { level: "info", message: "listening addr=0.0.0.0:9000" });
|
|
7
|
-
assert.deepEqual(classifyGatewayLine("2026-10-11T01:42:43.470549Z WARN zuplo_policies::handlers::mcp::register: No responses found"), { level: "warn", message: "No responses found" });
|
|
8
|
-
assert.equal(classifyGatewayLine("2026-10-11T01:42:43Z ERROR zuplo_core::server: boom")
|
|
9
|
-
?.level, "error");
|
|
10
|
-
assert.equal(classifyGatewayLine("2026-10-11T01:42:43Z TRACE zuplo_v8: detail")?.level, "debug");
|
|
11
|
-
});
|
|
12
|
-
it("reads build diagnostics and watch lifecycle lines", () => {
|
|
13
|
-
assert.equal(classifyGatewayLine("error: config/policies.json: missing variable")
|
|
14
|
-
?.level, "error");
|
|
15
|
-
assert.equal(classifyGatewayLine("warning: config/routes.oas.json: nothing to mock")
|
|
16
|
-
?.level, "warn");
|
|
17
|
-
assert.equal(classifyGatewayLine("note: legacy syntax")?.level, "info");
|
|
18
|
-
assert.equal(classifyGatewayLine("hint: Set X in .env")?.level, "info");
|
|
19
|
-
assert.equal(classifyGatewayLine("watching /p for changes")?.level, "info");
|
|
20
|
-
assert.equal(classifyGatewayLine("modules/a.ts changed; rebuilding")?.level, "info");
|
|
21
|
-
assert.equal(classifyGatewayLine("rebuilt in 12 ms")?.level, "info");
|
|
22
|
-
assert.equal(classifyGatewayLine("rebuild failed; still serving the previous build")
|
|
23
|
-
?.level, "warn");
|
|
24
|
-
});
|
|
25
|
-
it("leaves other runtimes' lines alone", () => {
|
|
26
|
-
assert.equal(classifyGatewayLine("[ZENO]: [INFO] Server running"), undefined);
|
|
27
|
-
assert.equal(classifyGatewayLine("workerd/server/server.c++:123: warning: x"), undefined);
|
|
28
|
-
assert.equal(classifyGatewayLine('{"level":"info"}'), undefined);
|
|
29
|
-
assert.equal(classifyGatewayLine("Error: This is a test error"), undefined);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=worker-output.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-output.test.js","sourceRoot":"","sources":["../../src/common/worker-output.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC9E,MAAM,CAAC,SAAS,CACd,mBAAmB,CACjB,2LAA2L,CAC5L,EACD,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAC1D,CAAC;QACF,MAAM,CAAC,SAAS,CACd,mBAAmB,CACjB,+FAA+F,CAChG,EACD,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,CACjD,CAAC;QACF,MAAM,CAAC,KAAK,CACV,mBAAmB,CAAC,qDAAqD,CAAC;YACxE,EAAE,KAAK,EACT,OAAO,CACR,CAAC;QACF,MAAM,CAAC,KAAK,CACV,mBAAmB,CAAC,6CAA6C,CAAC,EAAE,KAAK,EACzE,OAAO,CACR,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C;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { describe, it } from \"node:test\";\nimport { classifyGatewayLine } from \"./worker-output.js\";\n\ndescribe(\"classifyGatewayLine\", () => {\n it(\"reads tracing lines, colored or not, without the gateway's timestamp\", () => {\n assert.deepEqual(\n classifyGatewayLine(\n \"\\u001b[2m2026-10-11T01:42:43.470549Z\\u001b[0m \\u001b[32m INFO\\u001b[0m \\u001b[2mzuplo_gateway\\u001b[0m\\u001b[2m:\\u001b[0m listening \\u001b[3maddr\\u001b[0m\\u001b[2m=\\u001b[0m0.0.0.0:9000\"\n ),\n { level: \"info\", message: \"listening addr=0.0.0.0:9000\" }\n );\n assert.deepEqual(\n classifyGatewayLine(\n \"2026-10-11T01:42:43.470549Z WARN zuplo_policies::handlers::mcp::register: No responses found\"\n ),\n { level: \"warn\", message: \"No responses found\" }\n );\n assert.equal(\n classifyGatewayLine(\"2026-10-11T01:42:43Z ERROR zuplo_core::server: boom\")\n ?.level,\n \"error\"\n );\n assert.equal(\n classifyGatewayLine(\"2026-10-11T01:42:43Z TRACE zuplo_v8: detail\")?.level,\n \"debug\"\n );\n });\n\n it(\"reads build diagnostics and watch lifecycle lines\", () => {\n assert.equal(\n classifyGatewayLine(\"error: config/policies.json: missing variable\")\n ?.level,\n \"error\"\n );\n assert.equal(\n classifyGatewayLine(\"warning: config/routes.oas.json: nothing to mock\")\n ?.level,\n \"warn\"\n );\n assert.equal(classifyGatewayLine(\"note: legacy syntax\")?.level, \"info\");\n assert.equal(classifyGatewayLine(\"hint: Set X in .env\")?.level, \"info\");\n assert.equal(classifyGatewayLine(\"watching /p for changes\")?.level, \"info\");\n assert.equal(\n classifyGatewayLine(\"modules/a.ts changed; rebuilding\")?.level,\n \"info\"\n );\n assert.equal(classifyGatewayLine(\"rebuilt in 12 ms\")?.level, \"info\");\n assert.equal(\n classifyGatewayLine(\"rebuild failed; still serving the previous build\")\n ?.level,\n \"warn\"\n );\n });\n\n it(\"leaves other runtimes' lines alone\", () => {\n assert.equal(\n classifyGatewayLine(\"[ZENO]: [INFO] Server running\"),\n undefined\n );\n assert.equal(\n classifyGatewayLine(\"workerd/server/server.c++:123: warning: x\"),\n undefined\n );\n assert.equal(classifyGatewayLine('{\"level\":\"info\"}'), undefined);\n assert.equal(classifyGatewayLine(\"Error: This is a test error\"), undefined);\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"archive.local-registry.test.d.ts","sourceRoot":"","sources":["../../src/deploy/archive.local-registry.test.ts"],"names":[],"mappings":""}
|