@zuplo/cli 7.10.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/dist/common/worker-output.d.ts +7 -0
- package/dist/common/worker-output.d.ts.map +1 -1
- package/dist/common/worker-output.js +39 -0
- package/dist/common/worker-output.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- 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/dist/types.d.ts +1 -1
- package/node_modules/@posthog/core/dist/types.d.ts.map +1 -1
- package/node_modules/@posthog/core/package.json +4 -3
- 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/core/src/types.ts +1 -1
- 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/capture.d.ts +1 -1
- package/node_modules/@posthog/types/dist/capture.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/capture.ts +1 -1
- package/node_modules/@posthog/types/src/index.ts +1 -0
- package/node_modules/@zuplo/core/customer.cli.minified.js +272 -261
- package/node_modules/@zuplo/core/index.minified.js +276 -265
- 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/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":"archive.local-registry.test.js","sourceRoot":"","sources":["../../src/deploy/archive.local-registry.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,k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AAQ,EAAE;gBACR,8BAA8B,EAAE;oBAC9B,QAAQ,EACN,wEAAwE;iBAC3E;aACF;SACF,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;QACxD,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAE/C,MAAM,CAAC,WAAW,CAAC,+BAA+B,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { afterEach, beforeEach, describe, it } from \"node:test\";\nimport { packageLockHasLocalRegistryUrls } from \"./archive.js\";\n\ndescribe(\"packageLockHasLocalRegistryUrls\", () => {\n let tmpDir: string;\n\n beforeEach(async () => {\n tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), \"archive-spec-\"));\n });\n\n afterEach(async () => {\n await fs.rm(tmpDir, { recursive: true, force: true });\n });\n\n it(\"returns false for a non-existent file\", () => {\n const result = packageLockHasLocalRegistryUrls(\n path.join(tmpDir, \"does-not-exist.json\")\n );\n assert.strictEqual(result, false);\n });\n\n it(\"returns false for a lock file with only public registry URLs\", async () => {\n const content = JSON.stringify({\n packages: {\n \"node_modules/foo\": {\n resolved: \"https://registry.npmjs.org/foo/-/foo-1.0.0.tgz\",\n },\n },\n });\n const filePath = path.join(tmpDir, \"package-lock.json\");\n await fs.writeFile(filePath, content, \"utf-8\");\n\n assert.strictEqual(packageLockHasLocalRegistryUrls(filePath), false);\n });\n\n it(\"returns true for a lock file with a localhost URL\", async () => {\n const content = JSON.stringify({\n packages: {\n \"node_modules/foo\": {\n resolved: \"http://localhost:4873/foo/-/foo-1.0.0.tgz\",\n },\n },\n });\n const filePath = path.join(tmpDir, \"package-lock.json\");\n await fs.writeFile(filePath, content, \"utf-8\");\n\n assert.strictEqual(packageLockHasLocalRegistryUrls(filePath), true);\n });\n\n it(\"returns true for a lock file with a 127.0.0.1 URL\", async () => {\n const content = JSON.stringify({\n packages: {\n \"node_modules/bar\": {\n resolved: \"http://127.0.0.1:4873/bar/-/bar-2.0.0.tgz\",\n },\n },\n });\n const filePath = path.join(tmpDir, \"package-lock.json\");\n await fs.writeFile(filePath, content, \"utf-8\");\n\n assert.strictEqual(packageLockHasLocalRegistryUrls(filePath), true);\n });\n\n it(\"returns true for https local URLs\", async () => {\n const content = JSON.stringify({\n packages: {\n \"node_modules/baz\": {\n resolved: \"https://localhost/baz/-/baz-1.0.0.tgz\",\n },\n },\n });\n const filePath = path.join(tmpDir, \"package-lock.json\");\n await fs.writeFile(filePath, content, \"utf-8\");\n\n assert.strictEqual(packageLockHasLocalRegistryUrls(filePath), true);\n });\n\n it(\"returns true when only some packages have local URLs\", async () => {\n const content = JSON.stringify({\n packages: {\n \"node_modules/public-pkg\": {\n resolved:\n \"https://registry.npmjs.org/public-pkg/-/public-pkg-1.0.0.tgz\",\n },\n \"node_modules/local-pkg\": {\n resolved: \"http://localhost:4873/local-pkg/-/local-pkg-0.1.0.tgz\",\n },\n },\n });\n const filePath = path.join(tmpDir, \"package-lock.json\");\n await fs.writeFile(filePath, content, \"utf-8\");\n\n assert.strictEqual(packageLockHasLocalRegistryUrls(filePath), true);\n });\n\n it(\"returns false for an empty file\", async () => {\n const filePath = path.join(tmpDir, \"package-lock.json\");\n await fs.writeFile(filePath, \"\", \"utf-8\");\n\n assert.strictEqual(packageLockHasLocalRegistryUrls(filePath), false);\n });\n\n it(\"returns false when resolved URL contains localhost in a non-host position\", async () => {\n // e.g. a package named 'localhost-utils' published on the public registry\n const content = JSON.stringify({\n packages: {\n \"node_modules/localhost-utils\": {\n resolved:\n \"https://registry.npmjs.org/localhost-utils/-/localhost-utils-1.0.0.tgz\",\n },\n },\n });\n const filePath = path.join(tmpDir, \"package-lock.json\");\n await fs.writeFile(filePath, content, \"utf-8\");\n\n assert.strictEqual(packageLockHasLocalRegistryUrls(filePath), false);\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"archive.test.d.ts","sourceRoot":"","sources":["../../src/deploy/archive.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import * as tar from "tar";
|
|
8
|
-
import { archive, createIgnoreFunction, generateMetadata } from "./archive.js";
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = path.dirname(__filename);
|
|
11
|
-
const testTmpPath = path.join(__dirname, "..", "__tests__", "test-tmp", "archive");
|
|
12
|
-
describe("Archive Path Handling", () => {
|
|
13
|
-
let originalCwd;
|
|
14
|
-
beforeEach(async () => {
|
|
15
|
-
originalCwd = process.cwd();
|
|
16
|
-
await fs.mkdir(testTmpPath, { recursive: true });
|
|
17
|
-
await fs.writeFile(path.join(testTmpPath, "zuplo.jsonc"), JSON.stringify({ name: "test-project" }, null, 2));
|
|
18
|
-
await fs.writeFile(path.join(testTmpPath, ".gitignore"), "node_modules/\n.env\n");
|
|
19
|
-
const { simpleGit } = await import("simple-git");
|
|
20
|
-
const git = simpleGit({ baseDir: testTmpPath });
|
|
21
|
-
await git.init();
|
|
22
|
-
await git.addConfig("user.name", "Test User");
|
|
23
|
-
await git.addConfig("user.email", "test@example.com");
|
|
24
|
-
await git.add(".");
|
|
25
|
-
await git.commit("Initial commit");
|
|
26
|
-
});
|
|
27
|
-
afterEach(async () => {
|
|
28
|
-
process.chdir(originalCwd);
|
|
29
|
-
try {
|
|
30
|
-
await fs.rm(testTmpPath, { recursive: true, force: true });
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
describe("archive with various --dir formats", () => {
|
|
36
|
-
it("should work with --dir=. (current directory)", async () => {
|
|
37
|
-
process.chdir(testTmpPath);
|
|
38
|
-
const result = await archive({
|
|
39
|
-
dir: ".",
|
|
40
|
-
account: "test-account",
|
|
41
|
-
project: "test-project",
|
|
42
|
-
authToken: "test-token",
|
|
43
|
-
});
|
|
44
|
-
assert.ok(result.tarball);
|
|
45
|
-
assert.ok(result.metadata);
|
|
46
|
-
assert.ok(result.metadata.branch === "main" || result.metadata.branch === "master");
|
|
47
|
-
await fs.unlink(result.tarball);
|
|
48
|
-
});
|
|
49
|
-
it("should work with --dir without argument (defaults to .)", async () => {
|
|
50
|
-
process.chdir(testTmpPath);
|
|
51
|
-
const result = await archive({
|
|
52
|
-
dir: ".",
|
|
53
|
-
account: "test-account",
|
|
54
|
-
project: "test-project",
|
|
55
|
-
authToken: "test-token",
|
|
56
|
-
});
|
|
57
|
-
assert.ok(result.tarball);
|
|
58
|
-
assert.ok(result.metadata);
|
|
59
|
-
await fs.unlink(result.tarball);
|
|
60
|
-
});
|
|
61
|
-
it("should work with absolute path", async () => {
|
|
62
|
-
const absolutePath = path.resolve(testTmpPath);
|
|
63
|
-
const result = await archive({
|
|
64
|
-
dir: absolutePath,
|
|
65
|
-
account: "test-account",
|
|
66
|
-
project: "test-project",
|
|
67
|
-
authToken: "test-token",
|
|
68
|
-
});
|
|
69
|
-
assert.ok(result.tarball);
|
|
70
|
-
assert.ok(result.metadata);
|
|
71
|
-
await fs.unlink(result.tarball);
|
|
72
|
-
});
|
|
73
|
-
it("should work with relative path from parent", async () => {
|
|
74
|
-
const parentDir = path.dirname(testTmpPath);
|
|
75
|
-
const relativePath = path.relative(parentDir, testTmpPath);
|
|
76
|
-
process.chdir(parentDir);
|
|
77
|
-
const result = await archive({
|
|
78
|
-
dir: relativePath,
|
|
79
|
-
account: "test-account",
|
|
80
|
-
project: "test-project",
|
|
81
|
-
authToken: "test-token",
|
|
82
|
-
});
|
|
83
|
-
assert.ok(result.tarball);
|
|
84
|
-
assert.ok(result.metadata);
|
|
85
|
-
await fs.unlink(result.tarball);
|
|
86
|
-
});
|
|
87
|
-
it("should work with ./relative/path format", async () => {
|
|
88
|
-
const parentDir = path.dirname(testTmpPath);
|
|
89
|
-
const baseName = path.basename(testTmpPath);
|
|
90
|
-
process.chdir(parentDir);
|
|
91
|
-
const result = await archive({
|
|
92
|
-
dir: `./${baseName}`,
|
|
93
|
-
account: "test-account",
|
|
94
|
-
project: "test-project",
|
|
95
|
-
authToken: "test-token",
|
|
96
|
-
});
|
|
97
|
-
assert.ok(result.tarball);
|
|
98
|
-
assert.ok(result.metadata);
|
|
99
|
-
await fs.unlink(result.tarball);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
describe("createIgnoreFunction with various path formats", () => {
|
|
103
|
-
it("should read .gitignore with absolute path", async () => {
|
|
104
|
-
const absolutePath = path.resolve(testTmpPath);
|
|
105
|
-
const ignoreFn = createIgnoreFunction(absolutePath);
|
|
106
|
-
assert.strictEqual(ignoreFn.ignores("node_modules/"), true);
|
|
107
|
-
assert.strictEqual(ignoreFn.ignores("src/index.ts"), false);
|
|
108
|
-
});
|
|
109
|
-
it("should read .gitignore with relative path from cwd", async () => {
|
|
110
|
-
const parentDir = path.dirname(testTmpPath);
|
|
111
|
-
const relativePath = path.relative(parentDir, testTmpPath);
|
|
112
|
-
process.chdir(parentDir);
|
|
113
|
-
const absolutePath = path.resolve(relativePath);
|
|
114
|
-
const ignoreFn = createIgnoreFunction(absolutePath);
|
|
115
|
-
assert.strictEqual(ignoreFn.ignores("node_modules/"), true);
|
|
116
|
-
assert.strictEqual(ignoreFn.ignores(".git/"), true);
|
|
117
|
-
});
|
|
118
|
-
it("should read .gitignore with . as directory", async () => {
|
|
119
|
-
process.chdir(testTmpPath);
|
|
120
|
-
const absolutePath = path.resolve(".");
|
|
121
|
-
const ignoreFn = createIgnoreFunction(absolutePath);
|
|
122
|
-
assert.strictEqual(ignoreFn.ignores("node_modules/"), true);
|
|
123
|
-
assert.strictEqual(ignoreFn.ignores(".env"), true);
|
|
124
|
-
});
|
|
125
|
-
it("should prefer .zupignore over .gitignore", async () => {
|
|
126
|
-
await fs.writeFile(path.join(testTmpPath, ".zupignore"), "dist/\n*.log\n");
|
|
127
|
-
const absolutePath = path.resolve(testTmpPath);
|
|
128
|
-
const ignoreFn = createIgnoreFunction(absolutePath);
|
|
129
|
-
assert.strictEqual(ignoreFn.ignores("dist/"), true);
|
|
130
|
-
assert.strictEqual(ignoreFn.ignores("test.log"), true);
|
|
131
|
-
assert.strictEqual(ignoreFn.ignores(".git/"), true);
|
|
132
|
-
});
|
|
133
|
-
it("should always ignore .git directory", async () => {
|
|
134
|
-
await fs.unlink(path.join(testTmpPath, ".gitignore"));
|
|
135
|
-
const absolutePath = path.resolve(testTmpPath);
|
|
136
|
-
const ignoreFn = createIgnoreFunction(absolutePath);
|
|
137
|
-
assert.strictEqual(ignoreFn.ignores(".git/"), true);
|
|
138
|
-
assert.strictEqual(ignoreFn.ignores("node_modules/"), true);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
describe("generateMetadata with various path formats", () => {
|
|
142
|
-
it("should generate metadata with absolute path", async () => {
|
|
143
|
-
const absolutePath = path.resolve(testTmpPath);
|
|
144
|
-
const metadata = await generateMetadata({
|
|
145
|
-
dir: absolutePath,
|
|
146
|
-
account: "test-account",
|
|
147
|
-
project: "test-project",
|
|
148
|
-
authToken: "test-token",
|
|
149
|
-
});
|
|
150
|
-
assert.ok(metadata.branch);
|
|
151
|
-
assert.ok(metadata.sha);
|
|
152
|
-
assert.ok(metadata.branch === "main" || metadata.branch === "master");
|
|
153
|
-
});
|
|
154
|
-
it("should generate metadata with . as directory", async () => {
|
|
155
|
-
process.chdir(testTmpPath);
|
|
156
|
-
const metadata = await generateMetadata({
|
|
157
|
-
dir: ".",
|
|
158
|
-
account: "test-account",
|
|
159
|
-
project: "test-project",
|
|
160
|
-
authToken: "test-token",
|
|
161
|
-
});
|
|
162
|
-
assert.ok(metadata.branch);
|
|
163
|
-
assert.ok(metadata.sha);
|
|
164
|
-
});
|
|
165
|
-
it("should generate metadata with relative path", async () => {
|
|
166
|
-
const parentDir = path.dirname(testTmpPath);
|
|
167
|
-
const relativePath = path.relative(parentDir, testTmpPath);
|
|
168
|
-
process.chdir(parentDir);
|
|
169
|
-
const metadata = await generateMetadata({
|
|
170
|
-
dir: relativePath,
|
|
171
|
-
account: "test-account",
|
|
172
|
-
project: "test-project",
|
|
173
|
-
authToken: "test-token",
|
|
174
|
-
});
|
|
175
|
-
assert.ok(metadata.branch);
|
|
176
|
-
assert.ok(metadata.sha);
|
|
177
|
-
});
|
|
178
|
-
it("should use --environment flag over git branch", async () => {
|
|
179
|
-
const metadata = await generateMetadata({
|
|
180
|
-
dir: testTmpPath,
|
|
181
|
-
environment: "production",
|
|
182
|
-
account: "test-account",
|
|
183
|
-
project: "test-project",
|
|
184
|
-
authToken: "test-token",
|
|
185
|
-
});
|
|
186
|
-
assert.strictEqual(metadata.branch, "production");
|
|
187
|
-
assert.ok(metadata.sha);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
describe("archive structure validation", () => {
|
|
191
|
-
it("should create archive with relative paths, not absolute paths", async () => {
|
|
192
|
-
process.chdir(testTmpPath);
|
|
193
|
-
await fs.mkdir(path.join(testTmpPath, "config"), { recursive: true });
|
|
194
|
-
await fs.writeFile(path.join(testTmpPath, "config", "routes.json"), JSON.stringify({ routes: [] }));
|
|
195
|
-
const result = await archive({
|
|
196
|
-
dir: ".",
|
|
197
|
-
account: "test-account",
|
|
198
|
-
project: "test-project",
|
|
199
|
-
authToken: "test-token",
|
|
200
|
-
});
|
|
201
|
-
assert.ok(result.tarball);
|
|
202
|
-
const files = [];
|
|
203
|
-
await tar.list({
|
|
204
|
-
file: result.tarball,
|
|
205
|
-
onentry: (entry) => {
|
|
206
|
-
files.push(entry.path);
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
assert.ok(files.some((f) => f === "config/routes.json" || f === "./config/routes.json"), `Expected to find config/routes.json in archive, but got: ${files.join(", ")}`);
|
|
210
|
-
const hasAbsolutePath = files.some((f) => f.includes(testTmpPath));
|
|
211
|
-
assert.strictEqual(hasAbsolutePath, false, `Archive should not contain absolute paths, but found: ${files.filter((f) => f.includes(testTmpPath)).join(", ")}`);
|
|
212
|
-
await fs.unlink(result.tarball);
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
describe("cross-platform path handling", () => {
|
|
216
|
-
it("should normalize Windows-style paths on Windows", async (t) => {
|
|
217
|
-
if (os.platform() !== "win32") {
|
|
218
|
-
t.skip("Requires a real Windows kernel: archive() does filesystem I/O, " +
|
|
219
|
-
"and backslash-separated paths are only directory separators on " +
|
|
220
|
-
"Windows. Not emulable by stubbing process.platform.");
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const windowsPath = testTmpPath.replace(/\//g, "\\");
|
|
224
|
-
const result = await archive({
|
|
225
|
-
dir: windowsPath,
|
|
226
|
-
account: "test-account",
|
|
227
|
-
project: "test-project",
|
|
228
|
-
authToken: "test-token",
|
|
229
|
-
});
|
|
230
|
-
assert.ok(result.tarball);
|
|
231
|
-
assert.ok(result.metadata);
|
|
232
|
-
await fs.unlink(result.tarball);
|
|
233
|
-
});
|
|
234
|
-
it("should handle forward slashes on all platforms", async () => {
|
|
235
|
-
const unixStylePath = testTmpPath.replace(/\\/g, "/");
|
|
236
|
-
const result = await archive({
|
|
237
|
-
dir: unixStylePath,
|
|
238
|
-
account: "test-account",
|
|
239
|
-
project: "test-project",
|
|
240
|
-
authToken: "test-token",
|
|
241
|
-
});
|
|
242
|
-
assert.ok(result.tarball);
|
|
243
|
-
assert.ok(result.metadata);
|
|
244
|
-
await fs.unlink(result.tarball);
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
//# sourceMappingURL=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,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { afterEach, beforeEach, describe, it } from \"node:test\";\nimport { fileURLToPath } from \"node:url\";\nimport * as tar from \"tar\";\nimport { archive, createIgnoreFunction, generateMetadata } from \"./archive.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst testTmpPath = path.join(\n __dirname,\n \"..\",\n \"__tests__\",\n \"test-tmp\",\n \"archive\"\n);\n\ndescribe(\"Archive Path Handling\", () => {\n let originalCwd: string;\n\n beforeEach(async () => {\n // Save original cwd\n originalCwd = process.cwd();\n\n // Ensure test-tmp directory exists\n await fs.mkdir(testTmpPath, { recursive: true });\n\n // Create a minimal zuplo project structure\n await fs.writeFile(\n path.join(testTmpPath, \"zuplo.jsonc\"),\n JSON.stringify({ name: \"test-project\" }, null, 2)\n );\n\n // Create a .gitignore file\n await fs.writeFile(\n path.join(testTmpPath, \".gitignore\"),\n \"node_modules/\\n.env\\n\"\n );\n\n // Initialize a git repo (needed for generateMetadata)\n const { simpleGit } = await import(\"simple-git\");\n const git = simpleGit({ baseDir: testTmpPath });\n await git.init();\n await git.addConfig(\"user.name\", \"Test User\");\n await git.addConfig(\"user.email\", \"test@example.com\");\n await git.add(\".\");\n await git.commit(\"Initial commit\");\n });\n\n afterEach(async () => {\n // Restore original cwd\n process.chdir(originalCwd);\n\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(\"archive with various --dir formats\", () => {\n it(\"should work with --dir=. (current directory)\", async () => {\n // Change to test directory\n process.chdir(testTmpPath);\n\n const result = await archive({\n dir: \".\",\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(result.tarball);\n assert.ok(result.metadata);\n // Branch name can be \"main\" or \"master\" depending on git configuration\n assert.ok(\n result.metadata.branch === \"main\" || result.metadata.branch === \"master\"\n );\n\n // Cleanup tarball\n await fs.unlink(result.tarball);\n });\n\n it(\"should work with --dir without argument (defaults to .)\", async () => {\n // Change to test directory\n process.chdir(testTmpPath);\n\n const result = await archive({\n dir: \".\",\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(result.tarball);\n assert.ok(result.metadata);\n\n // Cleanup tarball\n await fs.unlink(result.tarball);\n });\n\n it(\"should work with absolute path\", async () => {\n const absolutePath = path.resolve(testTmpPath);\n\n const result = await archive({\n dir: absolutePath,\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(result.tarball);\n assert.ok(result.metadata);\n\n // Cleanup tarball\n await fs.unlink(result.tarball);\n });\n\n it(\"should work with relative path from parent\", async () => {\n const parentDir = path.dirname(testTmpPath);\n const relativePath = path.relative(parentDir, testTmpPath);\n\n // Change to parent directory\n process.chdir(parentDir);\n\n const result = await archive({\n dir: relativePath,\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(result.tarball);\n assert.ok(result.metadata);\n\n // Cleanup tarball\n await fs.unlink(result.tarball);\n });\n\n it(\"should work with ./relative/path format\", async () => {\n const parentDir = path.dirname(testTmpPath);\n const baseName = path.basename(testTmpPath);\n\n // Change to parent directory\n process.chdir(parentDir);\n\n const result = await archive({\n dir: `./${baseName}`,\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(result.tarball);\n assert.ok(result.metadata);\n\n // Cleanup tarball\n await fs.unlink(result.tarball);\n });\n });\n\n describe(\"createIgnoreFunction with various path formats\", () => {\n it(\"should read .gitignore with absolute path\", async () => {\n const absolutePath = path.resolve(testTmpPath);\n const ignoreFn = createIgnoreFunction(absolutePath);\n\n assert.strictEqual(ignoreFn.ignores(\"node_modules/\"), true);\n assert.strictEqual(ignoreFn.ignores(\"src/index.ts\"), false);\n });\n\n it(\"should read .gitignore with relative path from cwd\", async () => {\n const parentDir = path.dirname(testTmpPath);\n const relativePath = path.relative(parentDir, testTmpPath);\n\n process.chdir(parentDir);\n\n const absolutePath = path.resolve(relativePath);\n const ignoreFn = createIgnoreFunction(absolutePath);\n\n assert.strictEqual(ignoreFn.ignores(\"node_modules/\"), true);\n assert.strictEqual(ignoreFn.ignores(\".git/\"), true);\n });\n\n it(\"should read .gitignore with . as directory\", async () => {\n process.chdir(testTmpPath);\n\n const absolutePath = path.resolve(\".\");\n const ignoreFn = createIgnoreFunction(absolutePath);\n\n assert.strictEqual(ignoreFn.ignores(\"node_modules/\"), true);\n assert.strictEqual(ignoreFn.ignores(\".env\"), true);\n });\n\n it(\"should prefer .zupignore over .gitignore\", async () => {\n await fs.writeFile(\n path.join(testTmpPath, \".zupignore\"),\n \"dist/\\n*.log\\n\"\n );\n\n const absolutePath = path.resolve(testTmpPath);\n const ignoreFn = createIgnoreFunction(absolutePath);\n\n assert.strictEqual(ignoreFn.ignores(\"dist/\"), true);\n assert.strictEqual(ignoreFn.ignores(\"test.log\"), true);\n // .zupignore doesn't have node_modules, but it should still ignore .git\n assert.strictEqual(ignoreFn.ignores(\".git/\"), true);\n });\n\n it(\"should always ignore .git directory\", async () => {\n // Remove .gitignore to test default behavior\n await fs.unlink(path.join(testTmpPath, \".gitignore\"));\n\n const absolutePath = path.resolve(testTmpPath);\n const ignoreFn = createIgnoreFunction(absolutePath);\n\n assert.strictEqual(ignoreFn.ignores(\".git/\"), true);\n assert.strictEqual(ignoreFn.ignores(\"node_modules/\"), true);\n });\n });\n\n describe(\"generateMetadata with various path formats\", () => {\n it(\"should generate metadata with absolute path\", async () => {\n const absolutePath = path.resolve(testTmpPath);\n\n const metadata = await generateMetadata({\n dir: absolutePath,\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(metadata.branch);\n assert.ok(metadata.sha);\n // Branch name can be \"main\" or \"master\" depending on git configuration\n assert.ok(metadata.branch === \"main\" || metadata.branch === \"master\");\n });\n\n it(\"should generate metadata with . as directory\", async () => {\n process.chdir(testTmpPath);\n\n const metadata = await generateMetadata({\n dir: \".\",\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(metadata.branch);\n assert.ok(metadata.sha);\n });\n\n it(\"should generate metadata with relative path\", async () => {\n const parentDir = path.dirname(testTmpPath);\n const relativePath = path.relative(parentDir, testTmpPath);\n\n process.chdir(parentDir);\n\n const metadata = await generateMetadata({\n dir: relativePath,\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(metadata.branch);\n assert.ok(metadata.sha);\n });\n\n it(\"should use --environment flag over git branch\", async () => {\n const metadata = await generateMetadata({\n dir: testTmpPath,\n environment: \"production\",\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.strictEqual(metadata.branch, \"production\");\n assert.ok(metadata.sha);\n });\n });\n\n describe(\"archive structure validation\", () => {\n it(\"should create archive with relative paths, not absolute paths\", async () => {\n process.chdir(testTmpPath);\n\n // Create some test files\n await fs.mkdir(path.join(testTmpPath, \"config\"), { recursive: true });\n await fs.writeFile(\n path.join(testTmpPath, \"config\", \"routes.json\"),\n JSON.stringify({ routes: [] })\n );\n\n const result = await archive({\n dir: \".\",\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(result.tarball);\n\n // Extract and verify the tar contents\n const files: string[] = [];\n\n await tar.list({\n file: result.tarball,\n onentry: (entry: tar.ReadEntry) => {\n files.push(entry.path);\n },\n });\n\n // Archive should contain relative paths like \"config/routes.json\"\n // NOT absolute paths like \"/Users/ntotten/.../config/routes.json\"\n assert.ok(\n files.some(\n (f) => f === \"config/routes.json\" || f === \"./config/routes.json\"\n ),\n `Expected to find config/routes.json in archive, but got: ${files.join(\", \")}`\n );\n\n // Verify paths don't contain the full testTmpPath\n const hasAbsolutePath = files.some((f) => f.includes(testTmpPath));\n assert.strictEqual(\n hasAbsolutePath,\n false,\n `Archive should not contain absolute paths, but found: ${files.filter((f) => f.includes(testTmpPath)).join(\", \")}`\n );\n\n // Cleanup\n await fs.unlink(result.tarball);\n });\n });\n\n describe(\"cross-platform path handling\", () => {\n // WINDOWS-ONLY, AND IT HAS TO STAY THAT WAY.\n //\n // Unlike the path-string tests elsewhere in the repo (xfs `safePath`,\n // codegen `toFileSystemPath`, cli `findTestFiles`), this one cannot be\n // made to run on Linux by stubbing `process.platform`. It asserts nothing\n // about string handling: `archive()` immediately does real I/O against the\n // real kernel — `resolve()` then `simpleGit({ baseDir })`, `mkdirSync`,\n // `readFileSync` and `tar.create({ cwd })`. Whether \"C:\\dir\\sub\" names a\n // directory is a question for the filesystem, and on Linux the answer is\n // no: a backslash is an ordinary, legal character in a filename, so the\n // path below resolves to one nonexistent entry and git/tar fail on it.\n // Stubbing `process.platform` would not change that — it does not change\n // what the kernel does with a backslash.\n //\n // So this stays gated on a real Windows runner. It reports as SKIPPED\n // rather than silently returning (which read as a pass), so the gap is\n // visible in the test output instead of inflating the green count.\n it(\"should normalize Windows-style paths on Windows\", async (t) => {\n if (os.platform() !== \"win32\") {\n t.skip(\n \"Requires a real Windows kernel: archive() does filesystem I/O, \" +\n \"and backslash-separated paths are only directory separators on \" +\n \"Windows. Not emulable by stubbing process.platform.\"\n );\n return;\n }\n\n // Windows path with backslashes\n const windowsPath = testTmpPath.replace(/\\//g, \"\\\\\");\n\n const result = await archive({\n dir: windowsPath,\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(result.tarball);\n assert.ok(result.metadata);\n\n // Cleanup tarball\n await fs.unlink(result.tarball);\n });\n\n it(\"should handle forward slashes on all platforms\", async () => {\n const unixStylePath = testTmpPath.replace(/\\\\/g, \"/\");\n\n const result = await archive({\n dir: unixStylePath,\n account: \"test-account\",\n project: \"test-project\",\n authToken: \"test-token\",\n });\n\n assert.ok(result.tarball);\n assert.ok(result.metadata);\n\n // Cleanup tarball\n await fs.unlink(result.tarball);\n });\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classify-build-probe.test.d.ts","sourceRoot":"","sources":["../../src/deploy/classify-build-probe.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, it } from "node:test";
|
|
2
|
-
import { assert } from "chai";
|
|
3
|
-
import { classifyBuildProbeResponse } from "./classify-build-probe.js";
|
|
4
|
-
const FALLBACK_INIT_ERROR_DETAIL = "The gateway failed to initialize after deployment. Check the deployment logs for details.";
|
|
5
|
-
function initErrorBody(overrides = {}) {
|
|
6
|
-
return JSON.stringify({
|
|
7
|
-
status: 500,
|
|
8
|
-
title: "Gateway Initialization Error",
|
|
9
|
-
type: "https://httpproblems.com/http-status/500",
|
|
10
|
-
detail: "Value of 'allowedOrigins' on custom cors policies is invalid.",
|
|
11
|
-
trace: { timestamp: 0, buildId: "build-new" },
|
|
12
|
-
...overrides,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
describe("classifyBuildProbeResponse", () => {
|
|
16
|
-
it("classifies a gateway initialization error with its build ID and detail", () => {
|
|
17
|
-
assert.deepEqual(classifyBuildProbeResponse(500, initErrorBody()), {
|
|
18
|
-
type: "init-error",
|
|
19
|
-
buildId: "build-new",
|
|
20
|
-
detail: "Value of 'allowedOrigins' on custom cors policies is invalid.",
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
it("uses a fallback detail when the problem omits detail", () => {
|
|
24
|
-
assert.deepEqual(classifyBuildProbeResponse(500, initErrorBody({ detail: undefined })), {
|
|
25
|
-
type: "init-error",
|
|
26
|
-
buildId: "build-new",
|
|
27
|
-
detail: FALLBACK_INIT_ERROR_DETAIL,
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it("returns an undefined build ID when the trace omits it", () => {
|
|
31
|
-
assert.deepEqual(classifyBuildProbeResponse(500, initErrorBody({ trace: {} })), {
|
|
32
|
-
type: "init-error",
|
|
33
|
-
buildId: undefined,
|
|
34
|
-
detail: "Value of 'allowedOrigins' on custom cors policies is invalid.",
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
for (const [name, status, body] of [
|
|
38
|
-
["a different error title", 500, initErrorBody({ title: "Other Error" })],
|
|
39
|
-
["a non-500 response", 503, initErrorBody()],
|
|
40
|
-
["non-JSON HTML", 500, "<html>unavailable</html>"],
|
|
41
|
-
["an empty body", 500, ""],
|
|
42
|
-
["an undefined body", 500, undefined],
|
|
43
|
-
]) {
|
|
44
|
-
it(`treats ${name} as inconclusive`, () => {
|
|
45
|
-
assert.deepEqual(classifyBuildProbeResponse(status, body), {
|
|
46
|
-
type: "inconclusive",
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=classify-build-probe.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classify-build-probe.test.js","sourceRoot":"","sources":["../../src/deploy/classify-build-probe.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEvE,MAAM,0BAA0B,GAC9B,2FAA2F,CAAC;AAE9F,SAAS,aAAa,CAAC,YAAqC,EAAE;IAC5D,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,8BAA8B;QACrC,IAAI,EAAE,0CAA0C;QAChD,MAAM,EAAE,+DAA+D;QACvE,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE;QAC7C,GAAG,SAAS;KACb,CAAC,CAAC;AACL,CAAC;AAED,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1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ACxC,MAAM,CAAC,SAAS,CAAC,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBACzD,IAAI,EAAE,cAAc;aACrB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it } from \"node:test\";\nimport { assert } from \"chai\";\nimport { classifyBuildProbeResponse } from \"./classify-build-probe.js\";\n\nconst FALLBACK_INIT_ERROR_DETAIL =\n \"The gateway failed to initialize after deployment. Check the deployment logs for details.\";\n\nfunction initErrorBody(overrides: Record<string, unknown> = {}): string {\n return JSON.stringify({\n status: 500,\n title: \"Gateway Initialization Error\",\n type: \"https://httpproblems.com/http-status/500\",\n detail: \"Value of 'allowedOrigins' on custom cors policies is invalid.\",\n trace: { timestamp: 0, buildId: \"build-new\" },\n ...overrides,\n });\n}\n\ndescribe(\"classifyBuildProbeResponse\", () => {\n it(\"classifies a gateway initialization error with its build ID and detail\", () => {\n assert.deepEqual(classifyBuildProbeResponse(500, initErrorBody()), {\n type: \"init-error\",\n buildId: \"build-new\",\n detail: \"Value of 'allowedOrigins' on custom cors policies is invalid.\",\n });\n });\n\n it(\"uses a fallback detail when the problem omits detail\", () => {\n assert.deepEqual(\n classifyBuildProbeResponse(500, initErrorBody({ detail: undefined })),\n {\n type: \"init-error\",\n buildId: \"build-new\",\n detail: FALLBACK_INIT_ERROR_DETAIL,\n }\n );\n });\n\n it(\"returns an undefined build ID when the trace omits it\", () => {\n assert.deepEqual(\n classifyBuildProbeResponse(500, initErrorBody({ trace: {} })),\n {\n type: \"init-error\",\n buildId: undefined,\n detail: \"Value of 'allowedOrigins' on custom cors policies is invalid.\",\n }\n );\n });\n\n for (const [name, status, body] of [\n [\"a different error title\", 500, initErrorBody({ title: \"Other Error\" })],\n [\"a non-500 response\", 503, initErrorBody()],\n [\"non-JSON HTML\", 500, \"<html>unavailable</html>\"],\n [\"an empty body\", 500, \"\"],\n [\"an undefined body\", 500, undefined],\n ] as const) {\n it(`treats ${name} as inconclusive`, () => {\n assert.deepEqual(classifyBuildProbeResponse(status, body), {\n type: \"inconclusive\",\n });\n });\n }\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poll-deployment.test.d.ts","sourceRoot":"","sources":["../../src/deploy/poll-deployment.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
2
|
-
import { assert } from "chai";
|
|
3
|
-
import { getGlobalDispatcher, MockAgent, setGlobalDispatcher, } from "undici";
|
|
4
|
-
import { pollDeployment } from "./poll-deployment.js";
|
|
5
|
-
const DEV_API_ORIGIN = "https://developer.test";
|
|
6
|
-
const DEPLOYMENT_ORIGIN = "https://my-api.zuplo.app";
|
|
7
|
-
const PRIVATE_DEPLOYMENT_ORIGIN = "https://gateway.example.com";
|
|
8
|
-
const STATUS_PATH = "/v1/accounts/test-account/projects/test-project/deployment-status/deployment-123";
|
|
9
|
-
const BUILD_PATH = "/__zuplo/build";
|
|
10
|
-
const BUILD_ID = "build-new";
|
|
11
|
-
const LOG_URL = "https://portal.zuplo.com/builds/build-new";
|
|
12
|
-
const INIT_ERROR_DETAIL = "Value of 'allowedOrigins' on custom cors policies is invalid.";
|
|
13
|
-
const FALLBACK_INIT_ERROR_DETAIL = "The gateway failed to initialize after deployment. Check the deployment logs for details.";
|
|
14
|
-
const ENVIRONMENT_VARIABLES = [
|
|
15
|
-
"ZUPLO_DEVELOPER_API_ENDPOINT",
|
|
16
|
-
"MAX_POLL_RETRIES",
|
|
17
|
-
"POLL_INTERVAL",
|
|
18
|
-
"DEPLOY_INIT_ERROR_FAIL_FAST",
|
|
19
|
-
];
|
|
20
|
-
const argv = { authToken: "tok" };
|
|
21
|
-
function statusBody(overrides = {}) {
|
|
22
|
-
return {
|
|
23
|
-
status: "SUCCESS",
|
|
24
|
-
url: DEPLOYMENT_ORIGIN,
|
|
25
|
-
logUrl: LOG_URL,
|
|
26
|
-
buildId: BUILD_ID,
|
|
27
|
-
...overrides,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function initErrorBody(overrides = {}) {
|
|
31
|
-
return {
|
|
32
|
-
status: 500,
|
|
33
|
-
title: "Gateway Initialization Error",
|
|
34
|
-
type: "https://httpproblems.com/http-status/500",
|
|
35
|
-
detail: INIT_ERROR_DETAIL,
|
|
36
|
-
trace: { timestamp: 0, buildId: BUILD_ID },
|
|
37
|
-
...overrides,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
describe("pollDeployment", () => {
|
|
41
|
-
let mockAgent;
|
|
42
|
-
let previousDispatcher;
|
|
43
|
-
let devApiPool;
|
|
44
|
-
let deploymentPool;
|
|
45
|
-
let previousEnvironment;
|
|
46
|
-
let spinner;
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
previousEnvironment = Object.fromEntries(ENVIRONMENT_VARIABLES.map((name) => [name, process.env[name]]));
|
|
49
|
-
process.env.ZUPLO_DEVELOPER_API_ENDPOINT = DEV_API_ORIGIN;
|
|
50
|
-
process.env.MAX_POLL_RETRIES = "3";
|
|
51
|
-
process.env.POLL_INTERVAL = "1";
|
|
52
|
-
delete process.env.DEPLOY_INIT_ERROR_FAIL_FAST;
|
|
53
|
-
previousDispatcher = getGlobalDispatcher();
|
|
54
|
-
mockAgent = new MockAgent();
|
|
55
|
-
mockAgent.disableNetConnect();
|
|
56
|
-
setGlobalDispatcher(mockAgent);
|
|
57
|
-
devApiPool = mockAgent.get(DEV_API_ORIGIN);
|
|
58
|
-
deploymentPool = mockAgent.get(DEPLOYMENT_ORIGIN);
|
|
59
|
-
spinner = { suffixText: "" };
|
|
60
|
-
});
|
|
61
|
-
afterEach(async () => {
|
|
62
|
-
await mockAgent.close();
|
|
63
|
-
setGlobalDispatcher(previousDispatcher);
|
|
64
|
-
for (const name of ENVIRONMENT_VARIABLES) {
|
|
65
|
-
const value = previousEnvironment[name];
|
|
66
|
-
if (value === undefined) {
|
|
67
|
-
delete process.env[name];
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
process.env[name] = value;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
function interceptStatus(body, times = 1) {
|
|
75
|
-
devApiPool
|
|
76
|
-
.intercept({ path: STATUS_PATH, method: "GET" })
|
|
77
|
-
.reply(200, body)
|
|
78
|
-
.times(times);
|
|
79
|
-
}
|
|
80
|
-
function interceptProbe(status, body, times = 1) {
|
|
81
|
-
deploymentPool
|
|
82
|
-
.intercept({ path: BUILD_PATH, method: "GET" })
|
|
83
|
-
.reply(status, body)
|
|
84
|
-
.times(times);
|
|
85
|
-
}
|
|
86
|
-
function poll() {
|
|
87
|
-
return pollDeployment(argv, "deployment-123", "test-account", "test-project", spinner);
|
|
88
|
-
}
|
|
89
|
-
it("fails fast after two consecutive matching initialization errors", async () => {
|
|
90
|
-
interceptStatus(statusBody(), 2);
|
|
91
|
-
interceptProbe(500, initErrorBody(), 2);
|
|
92
|
-
const result = await poll();
|
|
93
|
-
assert.deepEqual(result, {
|
|
94
|
-
logUrl: LOG_URL,
|
|
95
|
-
initError: { detail: INIT_ERROR_DETAIL },
|
|
96
|
-
});
|
|
97
|
-
assert.strictEqual(mockAgent.pendingInterceptors().length, 0);
|
|
98
|
-
});
|
|
99
|
-
it("succeeds when one matching initialization error is followed by a live probe", async () => {
|
|
100
|
-
interceptStatus(statusBody(), 2);
|
|
101
|
-
interceptProbe(500, initErrorBody());
|
|
102
|
-
interceptProbe(200, { buildId: BUILD_ID });
|
|
103
|
-
assert.deepEqual(await poll(), {
|
|
104
|
-
url: DEPLOYMENT_ORIGIN,
|
|
105
|
-
logUrl: LOG_URL,
|
|
106
|
-
});
|
|
107
|
-
assert.strictEqual(mockAgent.pendingInterceptors().length, 0);
|
|
108
|
-
});
|
|
109
|
-
it("polls to exhaustion when the initialization error is for another build", async () => {
|
|
110
|
-
interceptStatus(statusBody(), 3);
|
|
111
|
-
interceptProbe(500, initErrorBody({ trace: { timestamp: 0, buildId: "build-old" } }), 3);
|
|
112
|
-
assert.deepEqual(await poll(), { logUrl: LOG_URL });
|
|
113
|
-
});
|
|
114
|
-
it("does not fail fast when the status response omits buildId", async () => {
|
|
115
|
-
interceptStatus(statusBody({ buildId: undefined }), 3);
|
|
116
|
-
interceptProbe(500, initErrorBody(), 3);
|
|
117
|
-
assert.deepEqual(await poll(), { logUrl: LOG_URL });
|
|
118
|
-
});
|
|
119
|
-
it("keeps polling after a non-JSON 5xx probe response", async () => {
|
|
120
|
-
interceptStatus(statusBody(), 3);
|
|
121
|
-
interceptProbe(500, "<html>unavailable</html>", 3);
|
|
122
|
-
assert.deepEqual(await poll(), { logUrl: LOG_URL });
|
|
123
|
-
});
|
|
124
|
-
it("uses the fallback detail when a matching initialization error omits detail", async () => {
|
|
125
|
-
interceptStatus(statusBody(), 2);
|
|
126
|
-
interceptProbe(500, initErrorBody({ detail: undefined }), 2);
|
|
127
|
-
assert.deepEqual(await poll(), {
|
|
128
|
-
logUrl: LOG_URL,
|
|
129
|
-
initError: { detail: FALLBACK_INIT_ERROR_DETAIL },
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
it("returns the latest build log URL when in-progress polling is exhausted", async () => {
|
|
133
|
-
interceptStatus(statusBody({ status: "IN_PROGRESS", url: undefined }), 3);
|
|
134
|
-
assert.deepEqual(await poll(), { logUrl: LOG_URL });
|
|
135
|
-
});
|
|
136
|
-
it("returns the deployment URL after a successful build probe", async () => {
|
|
137
|
-
interceptStatus(statusBody());
|
|
138
|
-
interceptProbe(200, { buildId: BUILD_ID });
|
|
139
|
-
assert.deepEqual(await poll(), {
|
|
140
|
-
url: DEPLOYMENT_ORIGIN,
|
|
141
|
-
logUrl: LOG_URL,
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
it("returns a non-Zuplo deployment URL without probing it", async () => {
|
|
145
|
-
interceptStatus(statusBody({ url: PRIVATE_DEPLOYMENT_ORIGIN }));
|
|
146
|
-
assert.deepEqual(await poll(), {
|
|
147
|
-
url: PRIVATE_DEPLOYMENT_ORIGIN,
|
|
148
|
-
logUrl: LOG_URL,
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
it("keeps polling matching initialization errors when fail-fast is disabled", async () => {
|
|
152
|
-
process.env.DEPLOY_INIT_ERROR_FAIL_FAST = "false";
|
|
153
|
-
interceptStatus(statusBody(), 3);
|
|
154
|
-
interceptProbe(500, initErrorBody(), 3);
|
|
155
|
-
assert.deepEqual(await poll(), { logUrl: LOG_URL });
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
//# sourceMappingURL=poll-deployment.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poll-deployment.test.js","sourceRoot":"","sources":["../../src/deploy/poll-deployment.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAEL,mBAAmB,EACnB,SAAS,EAET,mBAAmB,GACpB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAChD,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AACrD,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAChE,MAAM,WAAW,GACf,kFAAkF,CAAC;AACrF,MAAM,UAAU,GAAG,gBAAgB,CAAC;AACpC,MAAM,QAAQ,GAAG,WAAW,CAAC;AAC7B,MAAM,OAAO,GAAG,2CAA2C,CAAC;AAC5D,MAAM,iBAAiB,GACrB,+DAA+D,CAAC;AAClE,MAAM,0BAA0B,GAC9B,2FAA2F,CAAC;AAC9F,MAAM,qBAAqB,GAAG;IAC5B,8BAA8B;IAC9B,kBAAkB;IAClB,eAAe;IAC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Content":["import { afterEach, beforeEach, describe, it } from \"node:test\";\nimport { assert } from \"chai\";\nimport type { Ora } from \"ora\";\nimport {\n type Dispatcher,\n getGlobalDispatcher,\n MockAgent,\n type MockPool,\n setGlobalDispatcher,\n} from \"undici\";\nimport type { Arguments } from \"./handler.js\";\nimport { pollDeployment } from \"./poll-deployment.js\";\n\nconst DEV_API_ORIGIN = \"https://developer.test\";\nconst DEPLOYMENT_ORIGIN = \"https://my-api.zuplo.app\";\nconst PRIVATE_DEPLOYMENT_ORIGIN = \"https://gateway.example.com\";\nconst STATUS_PATH =\n \"/v1/accounts/test-account/projects/test-project/deployment-status/deployment-123\";\nconst BUILD_PATH = \"/__zuplo/build\";\nconst BUILD_ID = \"build-new\";\nconst LOG_URL = \"https://portal.zuplo.com/builds/build-new\";\nconst INIT_ERROR_DETAIL =\n \"Value of 'allowedOrigins' on custom cors policies is invalid.\";\nconst FALLBACK_INIT_ERROR_DETAIL =\n \"The gateway failed to initialize after deployment. Check the deployment logs for details.\";\nconst ENVIRONMENT_VARIABLES = [\n \"ZUPLO_DEVELOPER_API_ENDPOINT\",\n \"MAX_POLL_RETRIES\",\n \"POLL_INTERVAL\",\n \"DEPLOY_INIT_ERROR_FAIL_FAST\",\n] as const;\n\nconst argv = { authToken: \"tok\" } as Arguments;\n\nfunction statusBody(overrides: Record<string, unknown> = {}) {\n return {\n status: \"SUCCESS\",\n url: DEPLOYMENT_ORIGIN,\n logUrl: LOG_URL,\n buildId: BUILD_ID,\n ...overrides,\n };\n}\n\nfunction initErrorBody(overrides: Record<string, unknown> = {}) {\n return {\n status: 500,\n title: \"Gateway Initialization Error\",\n type: \"https://httpproblems.com/http-status/500\",\n detail: INIT_ERROR_DETAIL,\n trace: { timestamp: 0, buildId: BUILD_ID },\n ...overrides,\n };\n}\n\ndescribe(\"pollDeployment\", () => {\n let mockAgent: MockAgent;\n let previousDispatcher: Dispatcher;\n let devApiPool: MockPool;\n let deploymentPool: MockPool;\n let previousEnvironment: Record<string, string | undefined>;\n let spinner: Ora;\n\n beforeEach(() => {\n previousEnvironment = Object.fromEntries(\n ENVIRONMENT_VARIABLES.map((name) => [name, process.env[name]])\n );\n process.env.ZUPLO_DEVELOPER_API_ENDPOINT = DEV_API_ORIGIN;\n process.env.MAX_POLL_RETRIES = \"3\";\n process.env.POLL_INTERVAL = \"1\";\n delete process.env.DEPLOY_INIT_ERROR_FAIL_FAST;\n\n previousDispatcher = getGlobalDispatcher();\n mockAgent = new MockAgent();\n mockAgent.disableNetConnect();\n setGlobalDispatcher(mockAgent);\n devApiPool = mockAgent.get(DEV_API_ORIGIN);\n deploymentPool = mockAgent.get(DEPLOYMENT_ORIGIN);\n spinner = { suffixText: \"\" } as unknown as Ora;\n });\n\n afterEach(async () => {\n await mockAgent.close();\n setGlobalDispatcher(previousDispatcher);\n\n for (const name of ENVIRONMENT_VARIABLES) {\n const value = previousEnvironment[name];\n if (value === undefined) {\n delete process.env[name];\n } else {\n process.env[name] = value;\n }\n }\n });\n\n function interceptStatus(body: Record<string, unknown>, times = 1) {\n devApiPool\n .intercept({ path: STATUS_PATH, method: \"GET\" })\n .reply(200, body)\n .times(times);\n }\n\n function interceptProbe(\n status: number,\n body: Record<string, unknown> | string,\n times = 1\n ) {\n deploymentPool\n .intercept({ path: BUILD_PATH, method: \"GET\" })\n .reply(status, body)\n .times(times);\n }\n\n function poll() {\n return pollDeployment(\n argv,\n \"deployment-123\",\n \"test-account\",\n \"test-project\",\n spinner\n );\n }\n\n it(\"fails fast after two consecutive matching initialization errors\", async () => {\n interceptStatus(statusBody(), 2);\n interceptProbe(500, initErrorBody(), 2);\n\n const result = await poll();\n\n assert.deepEqual(result, {\n logUrl: LOG_URL,\n initError: { detail: INIT_ERROR_DETAIL },\n });\n assert.strictEqual(mockAgent.pendingInterceptors().length, 0);\n });\n\n it(\"succeeds when one matching initialization error is followed by a live probe\", async () => {\n interceptStatus(statusBody(), 2);\n interceptProbe(500, initErrorBody());\n interceptProbe(200, { buildId: BUILD_ID });\n\n assert.deepEqual(await poll(), {\n url: DEPLOYMENT_ORIGIN,\n logUrl: LOG_URL,\n });\n assert.strictEqual(mockAgent.pendingInterceptors().length, 0);\n });\n\n it(\"polls to exhaustion when the initialization error is for another build\", async () => {\n interceptStatus(statusBody(), 3);\n interceptProbe(\n 500,\n initErrorBody({ trace: { timestamp: 0, buildId: \"build-old\" } }),\n 3\n );\n\n assert.deepEqual(await poll(), { logUrl: LOG_URL });\n });\n\n it(\"does not fail fast when the status response omits buildId\", async () => {\n interceptStatus(statusBody({ buildId: undefined }), 3);\n interceptProbe(500, initErrorBody(), 3);\n\n assert.deepEqual(await poll(), { logUrl: LOG_URL });\n });\n\n it(\"keeps polling after a non-JSON 5xx probe response\", async () => {\n interceptStatus(statusBody(), 3);\n interceptProbe(500, \"<html>unavailable</html>\", 3);\n\n assert.deepEqual(await poll(), { logUrl: LOG_URL });\n });\n\n it(\"uses the fallback detail when a matching initialization error omits detail\", async () => {\n interceptStatus(statusBody(), 2);\n interceptProbe(500, initErrorBody({ detail: undefined }), 2);\n\n assert.deepEqual(await poll(), {\n logUrl: LOG_URL,\n initError: { detail: FALLBACK_INIT_ERROR_DETAIL },\n });\n });\n\n it(\"returns the latest build log URL when in-progress polling is exhausted\", async () => {\n interceptStatus(statusBody({ status: \"IN_PROGRESS\", url: undefined }), 3);\n\n assert.deepEqual(await poll(), { logUrl: LOG_URL });\n });\n\n it(\"returns the deployment URL after a successful build probe\", async () => {\n interceptStatus(statusBody());\n interceptProbe(200, { buildId: BUILD_ID });\n\n assert.deepEqual(await poll(), {\n url: DEPLOYMENT_ORIGIN,\n logUrl: LOG_URL,\n });\n });\n\n it(\"returns a non-Zuplo deployment URL without probing it\", async () => {\n interceptStatus(statusBody({ url: PRIVATE_DEPLOYMENT_ORIGIN }));\n\n assert.deepEqual(await poll(), {\n url: PRIVATE_DEPLOYMENT_ORIGIN,\n logUrl: LOG_URL,\n });\n });\n\n it(\"keeps polling matching initialization errors when fail-fast is disabled\", async () => {\n process.env.DEPLOY_INIT_ERROR_FAIL_FAST = \"false\";\n interceptStatus(statusBody(), 3);\n interceptProbe(500, initErrorBody(), 3);\n\n assert.deepEqual(await poll(), { logUrl: LOG_URL });\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zuplo-local-gitignore.test.d.ts","sourceRoot":"","sources":["../../src/dev/zuplo-local-gitignore.test.ts"],"names":[],"mappings":""}
|