@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,135 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { chmod, lstat, mkdir, mkdtemp, readFile, rm, symlink, writeFile, } from "node:fs/promises";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { afterEach, describe, it } from "node:test";
|
|
6
|
-
import { applyPlan, git, readProject } from "./files.js";
|
|
7
|
-
import { AI_OAS, catalog, POLICIES, planUpgrade } from "./planner.js";
|
|
8
|
-
const dirs = [];
|
|
9
|
-
afterEach(async () => {
|
|
10
|
-
for (const dir of dirs.splice(0))
|
|
11
|
-
await rm(dir, { recursive: true, force: true });
|
|
12
|
-
});
|
|
13
|
-
async function fixture() {
|
|
14
|
-
const root = await mkdtemp(path.join(tmpdir(), "gateway-upgrade-test-"));
|
|
15
|
-
dirs.push(root);
|
|
16
|
-
const dir = path.join(root, "project");
|
|
17
|
-
await mkdir(dir);
|
|
18
|
-
for (const [file, content] of Object.entries(catalog.snapshots[1].files)) {
|
|
19
|
-
await mkdir(path.dirname(path.join(dir, file)), { recursive: true });
|
|
20
|
-
await writeFile(path.join(dir, file), content);
|
|
21
|
-
}
|
|
22
|
-
await git(dir, ["init"]);
|
|
23
|
-
await git(dir, ["add", "."]);
|
|
24
|
-
await git(dir, [
|
|
25
|
-
"-c",
|
|
26
|
-
"user.name=Test",
|
|
27
|
-
"-c",
|
|
28
|
-
"user.email=test@example.com",
|
|
29
|
-
"-c",
|
|
30
|
-
"commit.gpgsign=false",
|
|
31
|
-
"commit",
|
|
32
|
-
"-m",
|
|
33
|
-
"baseline",
|
|
34
|
-
]);
|
|
35
|
-
const before = await readProject(dir);
|
|
36
|
-
const plan = planUpgrade(before, "1.0.0");
|
|
37
|
-
assert.deepEqual(plan.blockers, []);
|
|
38
|
-
return { dir, backupRoot: path.join(root, "backups"), before, plan };
|
|
39
|
-
}
|
|
40
|
-
describe("AI Gateway upgrade transaction", () => {
|
|
41
|
-
it("applies additions and retains originals with a recovery journal", async () => {
|
|
42
|
-
const { dir, backupRoot, before, plan } = await fixture();
|
|
43
|
-
const backup = await applyPlan(dir, plan, backupRoot);
|
|
44
|
-
assert.equal(await readFile(path.join(backup, AI_OAS), "utf8"), before[AI_OAS]);
|
|
45
|
-
assert.ok(JSON.parse(await readFile(path.join(backup, "journal.json"), "utf8"))
|
|
46
|
-
.files.length);
|
|
47
|
-
assert.equal(await readFile(path.join(dir, AI_OAS), "utf8"), plan.after[AI_OAS]);
|
|
48
|
-
assert.deepEqual(planUpgrade(await readProject(dir), "1.0.0").additions, []);
|
|
49
|
-
});
|
|
50
|
-
it("reports lock permission failures without claiming another upgrade is running", {
|
|
51
|
-
skip: process.platform === "win32" || process.getuid?.() === 0,
|
|
52
|
-
}, async () => {
|
|
53
|
-
const { dir, backupRoot, before, plan } = await fixture();
|
|
54
|
-
await mkdir(backupRoot, { mode: 0o500 });
|
|
55
|
-
try {
|
|
56
|
-
await assert.rejects(applyPlan(dir, plan, backupRoot), {
|
|
57
|
-
code: "EACCES",
|
|
58
|
-
});
|
|
59
|
-
assert.deepEqual(await readProject(dir), before);
|
|
60
|
-
}
|
|
61
|
-
finally {
|
|
62
|
-
await chmod(backupRoot, 0o700);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
it("writes nothing for dirty projects", async () => {
|
|
66
|
-
const { dir, backupRoot, before, plan } = await fixture();
|
|
67
|
-
await writeFile(path.join(dir, "scratch.txt"), "uncommitted");
|
|
68
|
-
await assert.rejects(applyPlan(dir, plan, backupRoot), /Commit or stash/);
|
|
69
|
-
assert.deepEqual(await readProject(dir), before);
|
|
70
|
-
});
|
|
71
|
-
it("rejects stale plans even when intervening edits were committed", async () => {
|
|
72
|
-
const { dir, backupRoot, plan } = await fixture();
|
|
73
|
-
await writeFile(path.join(dir, AI_OAS), `${plan.before[AI_OAS]}\n`);
|
|
74
|
-
await git(dir, ["add", "."]);
|
|
75
|
-
await git(dir, [
|
|
76
|
-
"-c",
|
|
77
|
-
"user.name=Test",
|
|
78
|
-
"-c",
|
|
79
|
-
"user.email=test@example.com",
|
|
80
|
-
"-c",
|
|
81
|
-
"commit.gpgsign=false",
|
|
82
|
-
"commit",
|
|
83
|
-
"-m",
|
|
84
|
-
"changed",
|
|
85
|
-
]);
|
|
86
|
-
await assert.rejects(applyPlan(dir, plan, backupRoot), /changed after preview/);
|
|
87
|
-
assert.equal(await readFile(path.join(dir, POLICIES), "utf8"), plan.before[POLICIES]);
|
|
88
|
-
});
|
|
89
|
-
it("rolls back a failure after the first replacement", async () => {
|
|
90
|
-
const { dir, backupRoot, before, plan } = await fixture();
|
|
91
|
-
await assert.rejects(applyPlan(dir, plan, backupRoot, {
|
|
92
|
-
beforeReplace: async (_file, index) => {
|
|
93
|
-
if (index === 1)
|
|
94
|
-
throw new Error("simulated disk failure");
|
|
95
|
-
},
|
|
96
|
-
}), /simulated disk failure.*Originals/s);
|
|
97
|
-
assert.deepEqual(await readProject(dir), before);
|
|
98
|
-
});
|
|
99
|
-
it("does not overwrite a concurrent edit during rollback", async () => {
|
|
100
|
-
const { dir, backupRoot, plan } = await fixture();
|
|
101
|
-
const first = Object.keys(plan.after)[0];
|
|
102
|
-
await assert.rejects(applyPlan(dir, plan, backupRoot, {
|
|
103
|
-
beforeReplace: async (_file, index) => {
|
|
104
|
-
if (index === 1)
|
|
105
|
-
await writeFile(path.join(dir, first), "concurrent edit");
|
|
106
|
-
},
|
|
107
|
-
}), /Restore manually/);
|
|
108
|
-
assert.equal(await readFile(path.join(dir, first), "utf8"), "concurrent edit");
|
|
109
|
-
});
|
|
110
|
-
it("preserves a file replaced with a symlink during rollback", async () => {
|
|
111
|
-
const { dir, backupRoot, plan } = await fixture();
|
|
112
|
-
const first = Object.keys(plan.after)[0];
|
|
113
|
-
const destination = path.join(dir, first);
|
|
114
|
-
const external = path.join(path.dirname(dir), "external.json");
|
|
115
|
-
await writeFile(external, "external contents");
|
|
116
|
-
await assert.rejects(applyPlan(dir, plan, backupRoot, {
|
|
117
|
-
beforeReplace: async (_file, index) => {
|
|
118
|
-
if (index === 1) {
|
|
119
|
-
await rm(destination);
|
|
120
|
-
await symlink(external, destination);
|
|
121
|
-
throw new Error("concurrent replacement");
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
}), /Restore manually/);
|
|
125
|
-
assert.ok((await lstat(destination)).isSymbolicLink());
|
|
126
|
-
assert.equal(await readFile(external, "utf8"), "external contents");
|
|
127
|
-
});
|
|
128
|
-
it("rejects symlinked configuration and blocked plans", async () => {
|
|
129
|
-
const { dir, backupRoot, plan } = await fixture();
|
|
130
|
-
await assert.rejects(applyPlan(dir, { ...plan, blockers: ["conflict"] }, backupRoot), /Blocked upgrade/);
|
|
131
|
-
await symlink(path.join(dir, AI_OAS), path.join(dir, "config/other.oas.json"));
|
|
132
|
-
await assert.rejects(readProject(dir), /symlinks/);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
//# sourceMappingURL=files.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files.test.js","sourceRoot":"","sources":["../../../src/source/ai-gateway/files.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,EAAE,EACF,OAAO,EACP,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,IAAI,GAAa,EAAE,CAAC;AAC1B,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9B,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,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E,KAAK,EAAE,EAAE;gBACpC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;oBAChB,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC;oBACtB,MAAM,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;oBACrC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;SACF,CAAC,EACF,kBAAkB,CACnB,CAAC;QACF,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;QACvD,MAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;QACjE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,EAAE,CAAC;QAClD,MAAM,MAAM,CAAC,OAAO,CAClB,SAAS,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAC/D,iBAAiB,CAClB,CAAC;QACF,MAAM,OAAO,CACX,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,EACtB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC,CACxC,CAAC;QACF,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport {\n chmod,\n lstat,\n mkdir,\n mkdtemp,\n readFile,\n rm,\n symlink,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { afterEach, describe, it } from \"node:test\";\nimport { applyPlan, git, readProject } from \"./files.js\";\nimport { AI_OAS, catalog, POLICIES, planUpgrade } from \"./planner.js\";\n\nconst dirs: string[] = [];\nafterEach(async () => {\n for (const dir of dirs.splice(0))\n await rm(dir, { recursive: true, force: true });\n});\nasync function fixture() {\n const root = await mkdtemp(path.join(tmpdir(), \"gateway-upgrade-test-\"));\n dirs.push(root);\n const dir = path.join(root, \"project\");\n await mkdir(dir);\n for (const [file, content] of Object.entries(catalog.snapshots[1].files)) {\n await mkdir(path.dirname(path.join(dir, file)), { recursive: true });\n await writeFile(path.join(dir, file), content);\n }\n await git(dir, [\"init\"]);\n await git(dir, [\"add\", \".\"]);\n await git(dir, [\n \"-c\",\n \"user.name=Test\",\n \"-c\",\n \"user.email=test@example.com\",\n \"-c\",\n \"commit.gpgsign=false\",\n \"commit\",\n \"-m\",\n \"baseline\",\n ]);\n const before = await readProject(dir);\n const plan = planUpgrade(before, \"1.0.0\");\n assert.deepEqual(plan.blockers, []);\n return { dir, backupRoot: path.join(root, \"backups\"), before, plan };\n}\n\ndescribe(\"AI Gateway upgrade transaction\", () => {\n it(\"applies additions and retains originals with a recovery journal\", async () => {\n const { dir, backupRoot, before, plan } = await fixture();\n const backup = await applyPlan(dir, plan, backupRoot);\n assert.equal(\n await readFile(path.join(backup, AI_OAS), \"utf8\"),\n before[AI_OAS]\n );\n assert.ok(\n JSON.parse(await readFile(path.join(backup, \"journal.json\"), \"utf8\"))\n .files.length\n );\n assert.equal(\n await readFile(path.join(dir, AI_OAS), \"utf8\"),\n plan.after[AI_OAS]\n );\n assert.deepEqual(\n planUpgrade(await readProject(dir), \"1.0.0\").additions,\n []\n );\n });\n it(\n \"reports lock permission failures without claiming another upgrade is running\",\n {\n skip: process.platform === \"win32\" || process.getuid?.() === 0,\n },\n async () => {\n const { dir, backupRoot, before, plan } = await fixture();\n await mkdir(backupRoot, { mode: 0o500 });\n try {\n await assert.rejects(applyPlan(dir, plan, backupRoot), {\n code: \"EACCES\",\n });\n assert.deepEqual(await readProject(dir), before);\n } finally {\n await chmod(backupRoot, 0o700);\n }\n }\n );\n it(\"writes nothing for dirty projects\", async () => {\n const { dir, backupRoot, before, plan } = await fixture();\n await writeFile(path.join(dir, \"scratch.txt\"), \"uncommitted\");\n await assert.rejects(applyPlan(dir, plan, backupRoot), /Commit or stash/);\n assert.deepEqual(await readProject(dir), before);\n });\n it(\"rejects stale plans even when intervening edits were committed\", async () => {\n const { dir, backupRoot, plan } = await fixture();\n await writeFile(path.join(dir, AI_OAS), `${plan.before[AI_OAS]}\\n`);\n await git(dir, [\"add\", \".\"]);\n await git(dir, [\n \"-c\",\n \"user.name=Test\",\n \"-c\",\n \"user.email=test@example.com\",\n \"-c\",\n \"commit.gpgsign=false\",\n \"commit\",\n \"-m\",\n \"changed\",\n ]);\n await assert.rejects(\n applyPlan(dir, plan, backupRoot),\n /changed after preview/\n );\n assert.equal(\n await readFile(path.join(dir, POLICIES), \"utf8\"),\n plan.before[POLICIES]\n );\n });\n it(\"rolls back a failure after the first replacement\", async () => {\n const { dir, backupRoot, before, plan } = await fixture();\n await assert.rejects(\n applyPlan(dir, plan, backupRoot, {\n beforeReplace: async (_file, index) => {\n if (index === 1) throw new Error(\"simulated disk failure\");\n },\n }),\n /simulated disk failure.*Originals/s\n );\n assert.deepEqual(await readProject(dir), before);\n });\n it(\"does not overwrite a concurrent edit during rollback\", async () => {\n const { dir, backupRoot, plan } = await fixture();\n const first = Object.keys(plan.after)[0];\n await assert.rejects(\n applyPlan(dir, plan, backupRoot, {\n beforeReplace: async (_file, index) => {\n if (index === 1)\n await writeFile(path.join(dir, first), \"concurrent edit\");\n },\n }),\n /Restore manually/\n );\n assert.equal(\n await readFile(path.join(dir, first), \"utf8\"),\n \"concurrent edit\"\n );\n });\n it(\"preserves a file replaced with a symlink during rollback\", async () => {\n const { dir, backupRoot, plan } = await fixture();\n const first = Object.keys(plan.after)[0];\n const destination = path.join(dir, first);\n const external = path.join(path.dirname(dir), \"external.json\");\n await writeFile(external, \"external contents\");\n await assert.rejects(\n applyPlan(dir, plan, backupRoot, {\n beforeReplace: async (_file, index) => {\n if (index === 1) {\n await rm(destination);\n await symlink(external, destination);\n throw new Error(\"concurrent replacement\");\n }\n },\n }),\n /Restore manually/\n );\n assert.ok((await lstat(destination)).isSymbolicLink());\n assert.equal(await readFile(external, \"utf8\"), \"external contents\");\n });\n it(\"rejects symlinked configuration and blocked plans\", async () => {\n const { dir, backupRoot, plan } = await fixture();\n await assert.rejects(\n applyPlan(dir, { ...plan, blockers: [\"conflict\"] }, backupRoot),\n /Blocked upgrade/\n );\n await symlink(\n path.join(dir, AI_OAS),\n path.join(dir, \"config/other.oas.json\")\n );\n await assert.rejects(readProject(dir), /symlinks/);\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.test.d.ts","sourceRoot":"","sources":["../../../src/source/ai-gateway/handler.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { afterEach, describe, it, mock } from "node:test";
|
|
6
|
-
import { git, readProject } from "./files.js";
|
|
7
|
-
import { upgradeGateway } from "./handler.js";
|
|
8
|
-
import { AI_OAS, catalog } from "./planner.js";
|
|
9
|
-
const roots = [];
|
|
10
|
-
afterEach(async () => {
|
|
11
|
-
mock.restoreAll();
|
|
12
|
-
for (const root of roots.splice(0))
|
|
13
|
-
await rm(root, { recursive: true, force: true });
|
|
14
|
-
});
|
|
15
|
-
async function fixture() {
|
|
16
|
-
mock.method(console, "log", () => { });
|
|
17
|
-
mock.method(console, "error", () => { });
|
|
18
|
-
const root = await mkdtemp(path.join(tmpdir(), "gateway-flow-"));
|
|
19
|
-
roots.push(root);
|
|
20
|
-
const dir = path.join(root, "project");
|
|
21
|
-
for (const [file, value] of Object.entries(catalog.snapshots[1].files)) {
|
|
22
|
-
await mkdir(path.dirname(path.join(dir, file)), { recursive: true });
|
|
23
|
-
await writeFile(path.join(dir, file), value);
|
|
24
|
-
}
|
|
25
|
-
await git(dir, ["init"]);
|
|
26
|
-
await git(dir, ["add", "./*"]);
|
|
27
|
-
await git(dir, [
|
|
28
|
-
"-c",
|
|
29
|
-
"user.name=Test",
|
|
30
|
-
"-c",
|
|
31
|
-
"user.email=test@example.com",
|
|
32
|
-
"-c",
|
|
33
|
-
"commit.gpgsign=false",
|
|
34
|
-
"commit",
|
|
35
|
-
"-m",
|
|
36
|
-
"baseline",
|
|
37
|
-
]);
|
|
38
|
-
const before = await readProject(dir);
|
|
39
|
-
const services = {
|
|
40
|
-
version: async () => "1.2.3",
|
|
41
|
-
release: async () => ({ latest: "1.2.3" }),
|
|
42
|
-
runtime: async () => ({
|
|
43
|
-
version: "1.2.3",
|
|
44
|
-
manifest: "fake-runtime/package.json",
|
|
45
|
-
contents: '{"version":"1.2.3"}',
|
|
46
|
-
}),
|
|
47
|
-
backupRoot: path.join(root, "backups"),
|
|
48
|
-
};
|
|
49
|
-
return { dir, before, services };
|
|
50
|
-
}
|
|
51
|
-
describe("AI Gateway upgrade workflow", () => {
|
|
52
|
-
it("previews without writing and applies only with explicit action", async () => {
|
|
53
|
-
const { dir, before, services } = await fixture();
|
|
54
|
-
assert.equal(await upgradeGateway({ dir, prompt: false }, services), 0);
|
|
55
|
-
assert.deepEqual(await readProject(dir), before);
|
|
56
|
-
assert.equal(await upgradeGateway({ dir, prompt: false, apply: true }, services), 0);
|
|
57
|
-
assert.notEqual((await readProject(dir))[AI_OAS], before[AI_OAS]);
|
|
58
|
-
});
|
|
59
|
-
it("shows an exact preview without an installed runtime but blocks application", async () => {
|
|
60
|
-
const { dir, before, services } = await fixture();
|
|
61
|
-
const unavailable = {
|
|
62
|
-
...services,
|
|
63
|
-
runtime: async () => {
|
|
64
|
-
throw new Error("not installed");
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
assert.equal(await upgradeGateway({ dir, prompt: false }, unavailable), 0);
|
|
68
|
-
const output = console.log.mock.calls
|
|
69
|
-
.map((call) => call.arguments.join(" "))
|
|
70
|
-
.join("\n");
|
|
71
|
-
assert.match(output, /diff --git/);
|
|
72
|
-
assert.equal(await upgradeGateway({ dir, prompt: false, apply: true }, unavailable), 2);
|
|
73
|
-
assert.deepEqual(await readProject(dir), before);
|
|
74
|
-
});
|
|
75
|
-
it("allows an offline preview but refuses offline application", async () => {
|
|
76
|
-
const { dir, before, services } = await fixture();
|
|
77
|
-
const offline = {
|
|
78
|
-
...services,
|
|
79
|
-
release: async () => ({ blocker: "offline: latest release unverified" }),
|
|
80
|
-
};
|
|
81
|
-
assert.equal(await upgradeGateway({ dir, prompt: false }, offline), 0);
|
|
82
|
-
assert.equal(await upgradeGateway({ dir, prompt: false, apply: true }, offline), 2);
|
|
83
|
-
assert.deepEqual(await readProject(dir), before);
|
|
84
|
-
});
|
|
85
|
-
it("does not write after declined confirmation or a release change during confirmation", async () => {
|
|
86
|
-
const { dir, before, services } = await fixture();
|
|
87
|
-
assert.equal(await upgradeGateway({ dir, prompt: true, apply: true }, { ...services, interactive: () => true, confirm: async () => false }), 0);
|
|
88
|
-
let checks = 0;
|
|
89
|
-
assert.equal(await upgradeGateway({ dir, prompt: true, apply: true }, {
|
|
90
|
-
...services,
|
|
91
|
-
interactive: () => true,
|
|
92
|
-
confirm: async () => true,
|
|
93
|
-
release: async () => ++checks === 1
|
|
94
|
-
? { latest: "1.2.3" }
|
|
95
|
-
: { latest: "1.2.4", blocker: "release changed" },
|
|
96
|
-
}), 2);
|
|
97
|
-
assert.deepEqual(await readProject(dir), before);
|
|
98
|
-
});
|
|
99
|
-
it("blocks incompatible runtime and noninteractive confirmation", async () => {
|
|
100
|
-
const { dir, before, services } = await fixture();
|
|
101
|
-
assert.equal(await upgradeGateway({ dir, prompt: false, apply: true }, {
|
|
102
|
-
...services,
|
|
103
|
-
runtime: async () => ({
|
|
104
|
-
version: "1.0.0",
|
|
105
|
-
manifest: "runtime",
|
|
106
|
-
contents: "old",
|
|
107
|
-
}),
|
|
108
|
-
}), 2);
|
|
109
|
-
assert.equal(await upgradeGateway({ dir, prompt: true, apply: true }, { ...services, interactive: () => false }), 2);
|
|
110
|
-
assert.deepEqual(await readProject(dir), before);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
//# sourceMappingURL=handler.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.test.js","sourceRoot":"","sources":["../../../src/source/ai-gateway/handler.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,KAAK,GAAa,EAAE,CAAC;AAC3B,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,IAAI,CAAC,UAAU,EAAE,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QAChC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC;AACH,KAAK,UAAU,OAAO;IACpB,IAAI,C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AC;IACH,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,OAAO,EAAE,CAAC;QAClD,MAAM,CAAC,KAAK,CACV,MAAM,cAAc,CAClB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EACnC;YACE,GAAG,QAAQ;YACX,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;gBACpB,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,SAAS;gBACnB,QAAQ,EAAE,KAAK;aAChB,CAAC;SACH,CACF,EACD,CAAC,CACF,CAAC;QACF,MAAM,CAAC,KAAK,CACV,MAAM,cAAc,CAClB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAClC,EAAE,GAAG,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAC1C,EACD,CAAC,CACF,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,MAAM,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { mkdir, mkdtemp, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { afterEach, describe, it, mock } from \"node:test\";\nimport { git, readProject } from \"./files.js\";\nimport { upgradeGateway } from \"./handler.js\";\nimport { AI_OAS, catalog } from \"./planner.js\";\n\nconst roots: string[] = [];\nafterEach(async () => {\n mock.restoreAll();\n for (const root of roots.splice(0))\n await rm(root, { recursive: true, force: true });\n});\nasync function fixture() {\n mock.method(console, \"log\", () => {});\n mock.method(console, \"error\", () => {});\n const root = await mkdtemp(path.join(tmpdir(), \"gateway-flow-\"));\n roots.push(root);\n const dir = path.join(root, \"project\");\n for (const [file, value] of Object.entries(catalog.snapshots[1].files)) {\n await mkdir(path.dirname(path.join(dir, file)), { recursive: true });\n await writeFile(path.join(dir, file), value);\n }\n await git(dir, [\"init\"]);\n await git(dir, [\"add\", \"./*\"]);\n await git(dir, [\n \"-c\",\n \"user.name=Test\",\n \"-c\",\n \"user.email=test@example.com\",\n \"-c\",\n \"commit.gpgsign=false\",\n \"commit\",\n \"-m\",\n \"baseline\",\n ]);\n const before = await readProject(dir);\n const services = {\n version: async () => \"1.2.3\",\n release: async () => ({ latest: \"1.2.3\" }),\n runtime: async () => ({\n version: \"1.2.3\",\n manifest: \"fake-runtime/package.json\",\n contents: '{\"version\":\"1.2.3\"}',\n }),\n backupRoot: path.join(root, \"backups\"),\n };\n return { dir, before, services };\n}\n\ndescribe(\"AI Gateway upgrade workflow\", () => {\n it(\"previews without writing and applies only with explicit action\", async () => {\n const { dir, before, services } = await fixture();\n assert.equal(await upgradeGateway({ dir, prompt: false }, services), 0);\n assert.deepEqual(await readProject(dir), before);\n assert.equal(\n await upgradeGateway({ dir, prompt: false, apply: true }, services),\n 0\n );\n assert.notEqual((await readProject(dir))[AI_OAS], before[AI_OAS]);\n });\n it(\"shows an exact preview without an installed runtime but blocks application\", async () => {\n const { dir, before, services } = await fixture();\n const unavailable = {\n ...services,\n runtime: async () => {\n throw new Error(\"not installed\");\n },\n };\n assert.equal(await upgradeGateway({ dir, prompt: false }, unavailable), 0);\n const output = (\n console.log as unknown as { mock: { calls: { arguments: unknown[] }[] } }\n ).mock.calls\n .map((call) => call.arguments.join(\" \"))\n .join(\"\\n\");\n assert.match(output, /diff --git/);\n assert.equal(\n await upgradeGateway({ dir, prompt: false, apply: true }, unavailable),\n 2\n );\n assert.deepEqual(await readProject(dir), before);\n });\n it(\"allows an offline preview but refuses offline application\", async () => {\n const { dir, before, services } = await fixture();\n const offline = {\n ...services,\n release: async () => ({ blocker: \"offline: latest release unverified\" }),\n };\n assert.equal(await upgradeGateway({ dir, prompt: false }, offline), 0);\n assert.equal(\n await upgradeGateway({ dir, prompt: false, apply: true }, offline),\n 2\n );\n assert.deepEqual(await readProject(dir), before);\n });\n it(\"does not write after declined confirmation or a release change during confirmation\", async () => {\n const { dir, before, services } = await fixture();\n assert.equal(\n await upgradeGateway(\n { dir, prompt: true, apply: true },\n { ...services, interactive: () => true, confirm: async () => false }\n ),\n 0\n );\n let checks = 0;\n assert.equal(\n await upgradeGateway(\n { dir, prompt: true, apply: true },\n {\n ...services,\n interactive: () => true,\n confirm: async () => true,\n release: async () =>\n ++checks === 1\n ? { latest: \"1.2.3\" }\n : { latest: \"1.2.4\", blocker: \"release changed\" },\n }\n ),\n 2\n );\n assert.deepEqual(await readProject(dir), before);\n });\n it(\"blocks incompatible runtime and noninteractive confirmation\", async () => {\n const { dir, before, services } = await fixture();\n assert.equal(\n await upgradeGateway(\n { dir, prompt: false, apply: true },\n {\n ...services,\n runtime: async () => ({\n version: \"1.0.0\",\n manifest: \"runtime\",\n contents: \"old\",\n }),\n }\n ),\n 2\n );\n assert.equal(\n await upgradeGateway(\n { dir, prompt: true, apply: true },\n { ...services, interactive: () => false }\n ),\n 2\n );\n assert.deepEqual(await readProject(dir), before);\n });\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.test.d.ts","sourceRoot":"","sources":["../../../src/source/ai-gateway/package.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { execFile } from "node:child_process";
|
|
3
|
-
import { cp, mkdir, mkdtemp, rm, symlink, writeFile } from "node:fs/promises";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { it } from "node:test";
|
|
7
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
-
import { promisify } from "node:util";
|
|
9
|
-
it("loads the compiled catalog from an isolated published-package layout", async () => {
|
|
10
|
-
const root = await mkdtemp(path.join(tmpdir(), "gateway-package-"));
|
|
11
|
-
try {
|
|
12
|
-
const directory = path.join(root, "dist/source/ai-gateway");
|
|
13
|
-
await mkdir(directory, { recursive: true });
|
|
14
|
-
for (const name of ["planner.js", "catalog.json"])
|
|
15
|
-
await cp(new URL(name, import.meta.url), path.join(directory, name));
|
|
16
|
-
await writeFile(path.join(root, "package.json"), '{"type":"module"}');
|
|
17
|
-
await symlink(fileURLToPath(new URL("../../../../../node_modules", import.meta.url)), path.join(root, "node_modules"), "dir");
|
|
18
|
-
const script = `const { catalog, planUpgrade } = await import(${JSON.stringify(pathToFileURL(path.join(directory, "planner.js")).href)}); const plan = planUpgrade(catalog.snapshots[1].files, "1.0.0"); if (plan.blockers.length || !plan.additions.length) process.exit(1);`;
|
|
19
|
-
const result = await promisify(execFile)(process.execPath, [
|
|
20
|
-
"--input-type=module",
|
|
21
|
-
"-e",
|
|
22
|
-
script,
|
|
23
|
-
]);
|
|
24
|
-
assert.equal(result.stderr, "");
|
|
25
|
-
}
|
|
26
|
-
finally {
|
|
27
|
-
await rm(root, { recursive: true, force: true });
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=package.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.test.js","sourceRoot":"","sources":["../../../src/source/ai-gateway/package.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM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,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { execFile } from \"node:child_process\";\nimport { cp, mkdir, mkdtemp, rm, symlink, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { it } from \"node:test\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { promisify } from \"node:util\";\n\nit(\"loads the compiled catalog from an isolated published-package layout\", async () => {\n const root = await mkdtemp(path.join(tmpdir(), \"gateway-package-\"));\n try {\n const directory = path.join(root, \"dist/source/ai-gateway\");\n await mkdir(directory, { recursive: true });\n for (const name of [\"planner.js\", \"catalog.json\"])\n await cp(new URL(name, import.meta.url), path.join(directory, name));\n await writeFile(path.join(root, \"package.json\"), '{\"type\":\"module\"}');\n await symlink(\n fileURLToPath(new URL(\"../../../../../node_modules\", import.meta.url)),\n path.join(root, \"node_modules\"),\n \"dir\"\n );\n const script = `const { catalog, planUpgrade } = await import(${JSON.stringify(pathToFileURL(path.join(directory, \"planner.js\")).href)}); const plan = planUpgrade(catalog.snapshots[1].files, \"1.0.0\"); if (plan.blockers.length || !plan.additions.length) process.exit(1);`;\n const result = await promisify(execFile)(process.execPath, [\n \"--input-type=module\",\n \"-e\",\n script,\n ]);\n assert.equal(result.stderr, \"\");\n } finally {\n await rm(root, { recursive: true, force: true });\n }\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner.test.d.ts","sourceRoot":"","sources":["../../../src/source/ai-gateway/planner.test.ts"],"names":[],"mappings":""}
|