convex 1.44.0 → 1.45.0
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/CHANGELOG.md +13 -0
- package/dist/browser.bundle.js +1 -1
- package/dist/browser.bundle.js.map +1 -1
- package/dist/cjs/cli/convexExport.js +1 -1
- package/dist/cjs/cli/convexExport.js.map +1 -1
- package/dist/cjs/cli/index.js +2 -32
- package/dist/cjs/cli/index.js.map +2 -2
- package/dist/cjs/cli/lib/api.js +11 -5
- package/dist/cjs/cli/lib/api.js.map +2 -2
- package/dist/cjs/cli/lib/convexExport.js +12 -1
- package/dist/cjs/cli/lib/convexExport.js.map +2 -2
- package/dist/cjs/cli/lib/dashboard.js.map +2 -2
- package/dist/cjs/cli/lib/generatedFunctionLogsApi.js.map +1 -1
- package/dist/cjs/cli/lib/indexes.js +1 -1
- package/dist/cjs/cli/lib/indexes.js.map +1 -1
- package/dist/cjs/cli/lib/localDeployment/upgrade.js +23 -188
- package/dist/cjs/cli/lib/localDeployment/upgrade.js.map +3 -3
- package/dist/cjs/cli/lib/mcp/tools/index.js.map +1 -1
- package/dist/cjs/cli/mcp.js +76 -69
- package/dist/cjs/cli/mcp.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/impl/actions_impl.js.map +2 -2
- package/dist/cjs/server/index.js.map +2 -2
- package/dist/cjs-types/cli/lib/api.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/convexExport.d.ts +1 -0
- package/dist/cjs-types/cli/lib/convexExport.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/dashboard.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
- package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/upgrade.d.ts +2 -0
- package/dist/cjs-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/mcp/tools/index.d.ts +1 -1
- package/dist/cjs-types/cli/lib/mcp/tools/index.d.ts.map +1 -1
- package/dist/cjs-types/cli/mcp.d.ts +3 -0
- package/dist/cjs-types/cli/mcp.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cjs-types/server/impl/actions_impl.d.ts +14 -0
- package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/index.d.ts +1 -0
- package/dist/cjs-types/server/index.d.ts.map +1 -1
- package/dist/cli.bundle.cjs +31210 -25495
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/esm/cli/convexExport.js +1 -1
- package/dist/esm/cli/convexExport.js.map +1 -1
- package/dist/esm/cli/index.js +2 -32
- package/dist/esm/cli/index.js.map +2 -2
- package/dist/esm/cli/lib/api.js +11 -5
- package/dist/esm/cli/lib/api.js.map +2 -2
- package/dist/esm/cli/lib/convexExport.js +16 -3
- package/dist/esm/cli/lib/convexExport.js.map +2 -2
- package/dist/esm/cli/lib/dashboard.js.map +2 -2
- package/dist/esm/cli/lib/indexes.js +1 -1
- package/dist/esm/cli/lib/indexes.js.map +1 -1
- package/dist/esm/cli/lib/localDeployment/upgrade.js +22 -190
- package/dist/esm/cli/lib/localDeployment/upgrade.js.map +2 -2
- package/dist/esm/cli/lib/mcp/tools/index.js.map +1 -1
- package/dist/esm/cli/mcp.js +75 -72
- package/dist/esm/cli/mcp.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/impl/actions_impl.js.map +2 -2
- package/dist/esm/server/index.js.map +2 -2
- package/dist/esm-types/cli/lib/api.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/convexExport.d.ts +1 -0
- package/dist/esm-types/cli/lib/convexExport.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/dashboard.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
- package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/upgrade.d.ts +2 -0
- package/dist/esm-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/mcp/tools/index.d.ts +1 -1
- package/dist/esm-types/cli/lib/mcp/tools/index.d.ts.map +1 -1
- package/dist/esm-types/cli/mcp.d.ts +3 -0
- package/dist/esm-types/cli/mcp.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/esm-types/server/impl/actions_impl.d.ts +14 -0
- package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
- package/dist/esm-types/server/index.d.ts +1 -0
- package/dist/esm-types/server/index.d.ts.map +1 -1
- package/dist/react.bundle.js +1 -1
- package/dist/react.bundle.js.map +1 -1
- package/package.json +3 -3
- package/src/cli/convexExport.ts +1 -1
- package/src/cli/index.ts +2 -35
- package/src/cli/lib/api.ts +11 -5
- package/src/cli/lib/convexExport.ts +21 -0
- package/src/cli/lib/dashboard.ts +2 -0
- package/src/cli/lib/generatedFunctionLogsApi.ts +2 -0
- package/src/cli/lib/indexes.ts +1 -1
- package/src/cli/lib/localDeployment/upgrade.ts +34 -207
- package/src/cli/lib/mcp/tools/index.ts +1 -1
- package/src/cli/mcp.ts +91 -77
- package/src/index.ts +1 -1
- package/src/server/impl/actions_impl.ts +3 -1
- package/src/server/index.ts +0 -3
- package/dist/cjs-types/browser/http_client.test.d.ts +0 -2
- package/dist/cjs-types/browser/http_client.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/query_options.test.d.ts +0 -2
- package/dist/cjs-types/browser/query_options.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/simple_client.test.d.ts +0 -2
- package/dist/cjs-types/browser/simple_client.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/sync/client.test.d.ts +0 -5
- package/dist/cjs-types/browser/sync/client.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/sync/client_node.test.d.ts +0 -2
- package/dist/cjs-types/browser/sync/client_node.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/sync/client_node_test_helpers.d.ts +0 -44
- package/dist/cjs-types/browser/sync/client_node_test_helpers.d.ts.map +0 -1
- package/dist/cjs-types/browser/sync/local_state.test.d.ts +0 -2
- package/dist/cjs-types/browser/sync/local_state.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/sync/optimistic_query_set.test.d.ts +0 -2
- package/dist/cjs-types/browser/sync/optimistic_query_set.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/sync/paginated_query_client.test.d.ts +0 -2
- package/dist/cjs-types/browser/sync/paginated_query_client.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/sync/protocol.test.d.ts +0 -5
- package/dist/cjs-types/browser/sync/protocol.test.d.ts.map +0 -1
- package/dist/cjs-types/browser/sync/request_manager.test.d.ts +0 -2
- package/dist/cjs-types/browser/sync/request_manager.test.d.ts.map +0 -1
- package/dist/cjs-types/bundler/fs.test.d.ts +0 -2
- package/dist/cjs-types/bundler/fs.test.d.ts.map +0 -1
- package/dist/cjs-types/bundler/index.test.d.ts +0 -2
- package/dist/cjs-types/bundler/index.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/codegen_templates/api.test.d.ts +0 -2
- package/dist/cjs-types/cli/codegen_templates/api.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/codegen_templates/common.test.d.ts +0 -2
- package/dist/cjs-types/cli/codegen_templates/common.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/codegen_templates/templates.test.d.ts +0 -2
- package/dist/cjs-types/cli/codegen_templates/templates.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/codegen_templates/validator_helpers.test.d.ts +0 -2
- package/dist/cjs-types/cli/codegen_templates/validator_helpers.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/configure.test.d.ts +0 -2
- package/dist/cjs-types/cli/configure.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/deploymentCreate.test.d.ts +0 -2
- package/dist/cjs-types/cli/deploymentCreate.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/deploymentSelect.test.d.ts +0 -2
- package/dist/cjs-types/cli/deploymentSelect.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/deploymentSelection.test.d.ts +0 -2
- package/dist/cjs-types/cli/deploymentSelection.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/deploymentToken.test.d.ts +0 -2
- package/dist/cjs-types/cli/deploymentToken.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/dev.test.d.ts +0 -2
- package/dist/cjs-types/cli/dev.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/envDefault.test.d.ts +0 -2
- package/dist/cjs-types/cli/envDefault.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/aiFiles/agentsmd.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/aiFiles/agentsmd.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/aiFiles/claudemd.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/aiFiles/claudemd.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/aiFiles/index.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/aiFiles/index.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/aiFiles/integration.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/aiFiles/integration.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/aiFiles/prompt.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/aiFiles/prompt.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/aiFiles/state.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/aiFiles/state.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/aiFiles/utils.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/aiFiles/utils.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/codegen.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/codegen.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/components.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/components.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/config.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/config.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/deployment.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/deployment.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/deploymentSelector.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/deploymentSelector.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/env.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/env.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/expiration.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/expiration.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/extractDeploymentNameForWorkOS.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/extractDeploymentNameForWorkOS.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/formatEnvValueForDotfile.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/formatEnvValueForDotfile.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/formatTargetedDeployment.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/formatTargetedDeployment.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/fsUtils.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/fsUtils.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/generateDocs.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/generateDocs.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/indexes.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/indexes.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/localDeployment/run.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/localDeployment/run.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/localDeployment/secrets.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/localDeployment/secrets.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/run.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/run.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/runTestFunction.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/runTestFunction.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/typecheck.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/typecheck.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/updates.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/updates.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/utils/hash.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/utils/hash.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/utils/utils.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/utils/utils.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/versionApi.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/versionApi.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/workos/environmentApi.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/workos/environmentApi.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/workos/workos.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/workos/workos.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/login.test.d.ts +0 -2
- package/dist/cjs-types/cli/login.test.d.ts.map +0 -1
- package/dist/cjs-types/common/index.test.d.ts +0 -2
- package/dist/cjs-types/common/index.test.d.ts.map +0 -1
- package/dist/cjs-types/nextjs/nextjs.test.d.ts +0 -2
- package/dist/cjs-types/nextjs/nextjs.test.d.ts.map +0 -1
- package/dist/cjs-types/react/ConvexAuthState.test.d.ts +0 -2
- package/dist/cjs-types/react/ConvexAuthState.test.d.ts.map +0 -1
- package/dist/cjs-types/react/auth_helpers.test.d.ts +0 -2
- package/dist/cjs-types/react/auth_helpers.test.d.ts.map +0 -1
- package/dist/cjs-types/react/auth_websocket.test.d.ts +0 -2
- package/dist/cjs-types/react/auth_websocket.test.d.ts.map +0 -1
- package/dist/cjs-types/react/client.test.d.ts +0 -2
- package/dist/cjs-types/react/client.test.d.ts.map +0 -1
- package/dist/cjs-types/react/client_provided_base_client.test.d.ts +0 -2
- package/dist/cjs-types/react/client_provided_base_client.test.d.ts.map +0 -1
- package/dist/cjs-types/react/queries_observer.test.d.ts +0 -2
- package/dist/cjs-types/react/queries_observer.test.d.ts.map +0 -1
- package/dist/cjs-types/react/react_node.test.d.ts +0 -2
- package/dist/cjs-types/react/react_node.test.d.ts.map +0 -1
- package/dist/cjs-types/react/use_paginated_query.test.d.ts +0 -2
- package/dist/cjs-types/react/use_paginated_query.test.d.ts.map +0 -1
- package/dist/cjs-types/react/use_queries.test.d.ts +0 -5
- package/dist/cjs-types/react/use_queries.test.d.ts.map +0 -1
- package/dist/cjs-types/react/use_query.test.d.ts +0 -5
- package/dist/cjs-types/react/use_query.test.d.ts.map +0 -1
- package/dist/cjs-types/react/use_query_object_options.test.d.ts +0 -5
- package/dist/cjs-types/react/use_query_object_options.test.d.ts.map +0 -1
- package/dist/cjs-types/react/use_query_result.test.d.ts +0 -5
- package/dist/cjs-types/react/use_query_result.test.d.ts.map +0 -1
- package/dist/cjs-types/react-auth0/ConvexProviderWithAuth0.test.d.ts +0 -2
- package/dist/cjs-types/react-auth0/ConvexProviderWithAuth0.test.d.ts.map +0 -1
- package/dist/cjs-types/react-clerk/ConvexProviderWithClerk.test.d.ts +0 -2
- package/dist/cjs-types/react-clerk/ConvexProviderWithClerk.test.d.ts.map +0 -1
- package/dist/cjs-types/server/api.intersect.test.d.ts +0 -2
- package/dist/cjs-types/server/api.intersect.test.d.ts.map +0 -1
- package/dist/cjs-types/server/api.test.d.ts +0 -2
- package/dist/cjs-types/server/api.test.d.ts.map +0 -1
- package/dist/cjs-types/server/audit_logging.test.d.ts +0 -2
- package/dist/cjs-types/server/audit_logging.test.d.ts.map +0 -1
- package/dist/cjs-types/server/components/index.test.d.ts +0 -2
- package/dist/cjs-types/server/components/index.test.d.ts.map +0 -1
- package/dist/cjs-types/server/cron.test.d.ts +0 -2
- package/dist/cjs-types/server/cron.test.d.ts.map +0 -1
- package/dist/cjs-types/server/data_model.test.d.ts +0 -2
- package/dist/cjs-types/server/data_model.test.d.ts.map +0 -1
- package/dist/cjs-types/server/database.test.d.ts +0 -2
- package/dist/cjs-types/server/database.test.d.ts.map +0 -1
- package/dist/cjs-types/server/database_api.test.d.ts +0 -2
- package/dist/cjs-types/server/database_api.test.d.ts.map +0 -1
- package/dist/cjs-types/server/filter_builder.test.d.ts +0 -2
- package/dist/cjs-types/server/filter_builder.test.d.ts.map +0 -1
- package/dist/cjs-types/server/impl/actions_impl.test.d.ts +0 -2
- package/dist/cjs-types/server/impl/actions_impl.test.d.ts.map +0 -1
- package/dist/cjs-types/server/impl/filter_builder_impl.test.d.ts +0 -2
- package/dist/cjs-types/server/impl/filter_builder_impl.test.d.ts.map +0 -1
- package/dist/cjs-types/server/impl/query_impl.test.d.ts +0 -2
- package/dist/cjs-types/server/impl/query_impl.test.d.ts.map +0 -1
- package/dist/cjs-types/server/pagination.test.d.ts +0 -2
- package/dist/cjs-types/server/pagination.test.d.ts.map +0 -1
- package/dist/cjs-types/server/query.test.d.ts +0 -2
- package/dist/cjs-types/server/query.test.d.ts.map +0 -1
- package/dist/cjs-types/server/registration.test.d.ts +0 -2
- package/dist/cjs-types/server/registration.test.d.ts.map +0 -1
- package/dist/cjs-types/server/router.test.d.ts +0 -2
- package/dist/cjs-types/server/router.test.d.ts.map +0 -1
- package/dist/cjs-types/server/scheduler.test.d.ts +0 -2
- package/dist/cjs-types/server/scheduler.test.d.ts.map +0 -1
- package/dist/cjs-types/server/schema.test.d.ts +0 -2
- package/dist/cjs-types/server/schema.test.d.ts.map +0 -1
- package/dist/cjs-types/test/fake_watch.d.ts +0 -16
- package/dist/cjs-types/test/fake_watch.d.ts.map +0 -1
- package/dist/cjs-types/test/type_testing.d.ts +0 -9
- package/dist/cjs-types/test/type_testing.d.ts.map +0 -1
- package/dist/cjs-types/type_utils.test.d.ts +0 -2
- package/dist/cjs-types/type_utils.test.d.ts.map +0 -1
- package/dist/cjs-types/values/size.test.d.ts +0 -2
- package/dist/cjs-types/values/size.test.d.ts.map +0 -1
- package/dist/cjs-types/values/validator.test.d.ts +0 -2
- package/dist/cjs-types/values/validator.test.d.ts.map +0 -1
- package/dist/cjs-types/values/value.test.d.ts +0 -2
- package/dist/cjs-types/values/value.test.d.ts.map +0 -1
- package/dist/esm-types/browser/http_client.test.d.ts +0 -2
- package/dist/esm-types/browser/http_client.test.d.ts.map +0 -1
- package/dist/esm-types/browser/query_options.test.d.ts +0 -2
- package/dist/esm-types/browser/query_options.test.d.ts.map +0 -1
- package/dist/esm-types/browser/simple_client.test.d.ts +0 -2
- package/dist/esm-types/browser/simple_client.test.d.ts.map +0 -1
- package/dist/esm-types/browser/sync/client.test.d.ts +0 -5
- package/dist/esm-types/browser/sync/client.test.d.ts.map +0 -1
- package/dist/esm-types/browser/sync/client_node.test.d.ts +0 -2
- package/dist/esm-types/browser/sync/client_node.test.d.ts.map +0 -1
- package/dist/esm-types/browser/sync/client_node_test_helpers.d.ts +0 -44
- package/dist/esm-types/browser/sync/client_node_test_helpers.d.ts.map +0 -1
- package/dist/esm-types/browser/sync/local_state.test.d.ts +0 -2
- package/dist/esm-types/browser/sync/local_state.test.d.ts.map +0 -1
- package/dist/esm-types/browser/sync/optimistic_query_set.test.d.ts +0 -2
- package/dist/esm-types/browser/sync/optimistic_query_set.test.d.ts.map +0 -1
- package/dist/esm-types/browser/sync/paginated_query_client.test.d.ts +0 -2
- package/dist/esm-types/browser/sync/paginated_query_client.test.d.ts.map +0 -1
- package/dist/esm-types/browser/sync/protocol.test.d.ts +0 -5
- package/dist/esm-types/browser/sync/protocol.test.d.ts.map +0 -1
- package/dist/esm-types/browser/sync/request_manager.test.d.ts +0 -2
- package/dist/esm-types/browser/sync/request_manager.test.d.ts.map +0 -1
- package/dist/esm-types/bundler/fs.test.d.ts +0 -2
- package/dist/esm-types/bundler/fs.test.d.ts.map +0 -1
- package/dist/esm-types/bundler/index.test.d.ts +0 -2
- package/dist/esm-types/bundler/index.test.d.ts.map +0 -1
- package/dist/esm-types/cli/codegen_templates/api.test.d.ts +0 -2
- package/dist/esm-types/cli/codegen_templates/api.test.d.ts.map +0 -1
- package/dist/esm-types/cli/codegen_templates/common.test.d.ts +0 -2
- package/dist/esm-types/cli/codegen_templates/common.test.d.ts.map +0 -1
- package/dist/esm-types/cli/codegen_templates/templates.test.d.ts +0 -2
- package/dist/esm-types/cli/codegen_templates/templates.test.d.ts.map +0 -1
- package/dist/esm-types/cli/codegen_templates/validator_helpers.test.d.ts +0 -2
- package/dist/esm-types/cli/codegen_templates/validator_helpers.test.d.ts.map +0 -1
- package/dist/esm-types/cli/configure.test.d.ts +0 -2
- package/dist/esm-types/cli/configure.test.d.ts.map +0 -1
- package/dist/esm-types/cli/deploymentCreate.test.d.ts +0 -2
- package/dist/esm-types/cli/deploymentCreate.test.d.ts.map +0 -1
- package/dist/esm-types/cli/deploymentSelect.test.d.ts +0 -2
- package/dist/esm-types/cli/deploymentSelect.test.d.ts.map +0 -1
- package/dist/esm-types/cli/deploymentSelection.test.d.ts +0 -2
- package/dist/esm-types/cli/deploymentSelection.test.d.ts.map +0 -1
- package/dist/esm-types/cli/deploymentToken.test.d.ts +0 -2
- package/dist/esm-types/cli/deploymentToken.test.d.ts.map +0 -1
- package/dist/esm-types/cli/dev.test.d.ts +0 -2
- package/dist/esm-types/cli/dev.test.d.ts.map +0 -1
- package/dist/esm-types/cli/envDefault.test.d.ts +0 -2
- package/dist/esm-types/cli/envDefault.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/aiFiles/agentsmd.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/aiFiles/agentsmd.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/aiFiles/claudemd.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/aiFiles/claudemd.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/aiFiles/index.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/aiFiles/index.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/aiFiles/integration.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/aiFiles/integration.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/aiFiles/prompt.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/aiFiles/prompt.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/aiFiles/state.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/aiFiles/state.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/aiFiles/utils.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/aiFiles/utils.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/codegen.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/codegen.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/components.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/components.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/config.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/config.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/deployment.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/deployment.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/deploymentSelector.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/deploymentSelector.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/env.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/env.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/expiration.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/expiration.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/extractDeploymentNameForWorkOS.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/extractDeploymentNameForWorkOS.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/formatEnvValueForDotfile.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/formatEnvValueForDotfile.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/formatTargetedDeployment.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/formatTargetedDeployment.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/fsUtils.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/fsUtils.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/generateDocs.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/generateDocs.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/indexes.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/indexes.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/localDeployment/run.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/localDeployment/run.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/localDeployment/secrets.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/localDeployment/secrets.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/run.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/run.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/runTestFunction.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/runTestFunction.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/typecheck.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/typecheck.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/updates.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/updates.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/utils/hash.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/utils/hash.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/utils/utils.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/utils/utils.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/versionApi.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/versionApi.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/workos/environmentApi.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/workos/environmentApi.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/workos/workos.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/workos/workos.test.d.ts.map +0 -1
- package/dist/esm-types/cli/login.test.d.ts +0 -2
- package/dist/esm-types/cli/login.test.d.ts.map +0 -1
- package/dist/esm-types/common/index.test.d.ts +0 -2
- package/dist/esm-types/common/index.test.d.ts.map +0 -1
- package/dist/esm-types/nextjs/nextjs.test.d.ts +0 -2
- package/dist/esm-types/nextjs/nextjs.test.d.ts.map +0 -1
- package/dist/esm-types/react/ConvexAuthState.test.d.ts +0 -2
- package/dist/esm-types/react/ConvexAuthState.test.d.ts.map +0 -1
- package/dist/esm-types/react/auth_helpers.test.d.ts +0 -2
- package/dist/esm-types/react/auth_helpers.test.d.ts.map +0 -1
- package/dist/esm-types/react/auth_websocket.test.d.ts +0 -2
- package/dist/esm-types/react/auth_websocket.test.d.ts.map +0 -1
- package/dist/esm-types/react/client.test.d.ts +0 -2
- package/dist/esm-types/react/client.test.d.ts.map +0 -1
- package/dist/esm-types/react/client_provided_base_client.test.d.ts +0 -2
- package/dist/esm-types/react/client_provided_base_client.test.d.ts.map +0 -1
- package/dist/esm-types/react/queries_observer.test.d.ts +0 -2
- package/dist/esm-types/react/queries_observer.test.d.ts.map +0 -1
- package/dist/esm-types/react/react_node.test.d.ts +0 -2
- package/dist/esm-types/react/react_node.test.d.ts.map +0 -1
- package/dist/esm-types/react/use_paginated_query.test.d.ts +0 -2
- package/dist/esm-types/react/use_paginated_query.test.d.ts.map +0 -1
- package/dist/esm-types/react/use_queries.test.d.ts +0 -5
- package/dist/esm-types/react/use_queries.test.d.ts.map +0 -1
- package/dist/esm-types/react/use_query.test.d.ts +0 -5
- package/dist/esm-types/react/use_query.test.d.ts.map +0 -1
- package/dist/esm-types/react/use_query_object_options.test.d.ts +0 -5
- package/dist/esm-types/react/use_query_object_options.test.d.ts.map +0 -1
- package/dist/esm-types/react/use_query_result.test.d.ts +0 -5
- package/dist/esm-types/react/use_query_result.test.d.ts.map +0 -1
- package/dist/esm-types/react-auth0/ConvexProviderWithAuth0.test.d.ts +0 -2
- package/dist/esm-types/react-auth0/ConvexProviderWithAuth0.test.d.ts.map +0 -1
- package/dist/esm-types/react-clerk/ConvexProviderWithClerk.test.d.ts +0 -2
- package/dist/esm-types/react-clerk/ConvexProviderWithClerk.test.d.ts.map +0 -1
- package/dist/esm-types/server/api.intersect.test.d.ts +0 -2
- package/dist/esm-types/server/api.intersect.test.d.ts.map +0 -1
- package/dist/esm-types/server/api.test.d.ts +0 -2
- package/dist/esm-types/server/api.test.d.ts.map +0 -1
- package/dist/esm-types/server/audit_logging.test.d.ts +0 -2
- package/dist/esm-types/server/audit_logging.test.d.ts.map +0 -1
- package/dist/esm-types/server/components/index.test.d.ts +0 -2
- package/dist/esm-types/server/components/index.test.d.ts.map +0 -1
- package/dist/esm-types/server/cron.test.d.ts +0 -2
- package/dist/esm-types/server/cron.test.d.ts.map +0 -1
- package/dist/esm-types/server/data_model.test.d.ts +0 -2
- package/dist/esm-types/server/data_model.test.d.ts.map +0 -1
- package/dist/esm-types/server/database.test.d.ts +0 -2
- package/dist/esm-types/server/database.test.d.ts.map +0 -1
- package/dist/esm-types/server/database_api.test.d.ts +0 -2
- package/dist/esm-types/server/database_api.test.d.ts.map +0 -1
- package/dist/esm-types/server/filter_builder.test.d.ts +0 -2
- package/dist/esm-types/server/filter_builder.test.d.ts.map +0 -1
- package/dist/esm-types/server/impl/actions_impl.test.d.ts +0 -2
- package/dist/esm-types/server/impl/actions_impl.test.d.ts.map +0 -1
- package/dist/esm-types/server/impl/filter_builder_impl.test.d.ts +0 -2
- package/dist/esm-types/server/impl/filter_builder_impl.test.d.ts.map +0 -1
- package/dist/esm-types/server/impl/query_impl.test.d.ts +0 -2
- package/dist/esm-types/server/impl/query_impl.test.d.ts.map +0 -1
- package/dist/esm-types/server/pagination.test.d.ts +0 -2
- package/dist/esm-types/server/pagination.test.d.ts.map +0 -1
- package/dist/esm-types/server/query.test.d.ts +0 -2
- package/dist/esm-types/server/query.test.d.ts.map +0 -1
- package/dist/esm-types/server/registration.test.d.ts +0 -2
- package/dist/esm-types/server/registration.test.d.ts.map +0 -1
- package/dist/esm-types/server/router.test.d.ts +0 -2
- package/dist/esm-types/server/router.test.d.ts.map +0 -1
- package/dist/esm-types/server/scheduler.test.d.ts +0 -2
- package/dist/esm-types/server/scheduler.test.d.ts.map +0 -1
- package/dist/esm-types/server/schema.test.d.ts +0 -2
- package/dist/esm-types/server/schema.test.d.ts.map +0 -1
- package/dist/esm-types/test/fake_watch.d.ts +0 -16
- package/dist/esm-types/test/fake_watch.d.ts.map +0 -1
- package/dist/esm-types/test/type_testing.d.ts +0 -9
- package/dist/esm-types/test/type_testing.d.ts.map +0 -1
- package/dist/esm-types/type_utils.test.d.ts +0 -2
- package/dist/esm-types/type_utils.test.d.ts.map +0 -1
- package/dist/esm-types/values/size.test.d.ts +0 -2
- package/dist/esm-types/values/size.test.d.ts.map +0 -1
- package/dist/esm-types/values/validator.test.d.ts +0 -2
- package/dist/esm-types/values/validator.test.d.ts.map +0 -1
- package/dist/esm-types/values/value.test.d.ts +0 -2
- package/dist/esm-types/values/value.test.d.ts.map +0 -1
- package/src/browser/http_client.test.ts +0 -202
- package/src/browser/query_options.test.ts +0 -43
- package/src/browser/simple_client.test.ts +0 -104
- package/src/browser/sync/client.test.ts +0 -44
- package/src/browser/sync/client_node.test.ts +0 -1207
- package/src/browser/sync/client_node_test_helpers.ts +0 -200
- package/src/browser/sync/local_state.test.ts +0 -128
- package/src/browser/sync/optimistic_query_set.test.ts +0 -253
- package/src/browser/sync/paginated_query_client.test.ts +0 -597
- package/src/browser/sync/protocol.test.ts +0 -14
- package/src/browser/sync/request_manager.test.ts +0 -273
- package/src/bundler/fs.test.ts +0 -86
- package/src/bundler/index.test.ts +0 -210
- package/src/bundler/test_fixtures/js/project01/bar.js +0 -4
- package/src/bundler/test_fixtures/js/project01/file with spaces.js +0 -1
- package/src/bundler/test_fixtures/js/project01/foo.js +0 -9
- package/src/bundler/test_fixtures/js/project_with_https/https.js +0 -9
- package/src/bundler/test_fixtures/js/project_with_https_not_at_top_level/default.js +0 -3
- package/src/bundler/test_fixtures/js/project_with_https_not_at_top_level/more_code/https.js +0 -5
- package/src/bundler/test_fixtures/js/project_with_https_without_router/https.js +0 -1
- package/src/bundler/test_fixtures/js/project_with_node_shims/uses_node_shims.js +0 -4
- package/src/cli/codegen_templates/api.test.ts +0 -18
- package/src/cli/codegen_templates/common.test.ts +0 -52
- package/src/cli/codegen_templates/templates.test.ts +0 -16
- package/src/cli/codegen_templates/validator_helpers.test.ts +0 -31
- package/src/cli/configure.test.ts +0 -138
- package/src/cli/deploymentCreate.test.ts +0 -1376
- package/src/cli/deploymentSelect.test.ts +0 -1291
- package/src/cli/deploymentSelection.test.ts +0 -2546
- package/src/cli/deploymentToken.test.ts +0 -397
- package/src/cli/dev.test.ts +0 -157
- package/src/cli/envDefault.test.ts +0 -495
- package/src/cli/lib/__snapshots__/formatTargetedDeployment.test.ts.snap +0 -94
- package/src/cli/lib/aiFiles/agentsmd.test.ts +0 -133
- package/src/cli/lib/aiFiles/claudemd.test.ts +0 -92
- package/src/cli/lib/aiFiles/guidelinesmd.test.ts +0 -50
- package/src/cli/lib/aiFiles/index.test.ts +0 -986
- package/src/cli/lib/aiFiles/integration.test.ts +0 -692
- package/src/cli/lib/aiFiles/prompt.test.ts +0 -202
- package/src/cli/lib/aiFiles/state.test.ts +0 -305
- package/src/cli/lib/aiFiles/utils.test.ts +0 -50
- package/src/cli/lib/codegen.test.ts +0 -49
- package/src/cli/lib/components.test.ts +0 -227
- package/src/cli/lib/config.test.ts +0 -1026
- package/src/cli/lib/deployment.test.ts +0 -85
- package/src/cli/lib/deploymentSelector.test.ts +0 -107
- package/src/cli/lib/env.test.ts +0 -60
- package/src/cli/lib/expiration.test.ts +0 -159
- package/src/cli/lib/extractDeploymentNameForWorkOS.test.ts +0 -30
- package/src/cli/lib/formatEnvValueForDotfile.test.ts +0 -294
- package/src/cli/lib/formatTargetedDeployment.test.ts +0 -281
- package/src/cli/lib/fsUtils.test.ts +0 -67
- package/src/cli/lib/generateDocs.test.ts +0 -326
- package/src/cli/lib/indexes.test.ts +0 -77
- package/src/cli/lib/localDeployment/run.test.ts +0 -104
- package/src/cli/lib/localDeployment/secrets.test.ts +0 -53
- package/src/cli/lib/run.test.ts +0 -54
- package/src/cli/lib/runTestFunction.test.ts +0 -84
- package/src/cli/lib/typecheck.test.ts +0 -71
- package/src/cli/lib/updates.test.ts +0 -157
- package/src/cli/lib/utils/hash.test.ts +0 -25
- package/src/cli/lib/utils/utils.test.ts +0 -340
- package/src/cli/lib/versionApi.test.ts +0 -471
- package/src/cli/lib/workos/environmentApi.test.ts +0 -107
- package/src/cli/lib/workos/workos.test.ts +0 -242
- package/src/cli/login.test.ts +0 -261
- package/src/common/README.md +0 -2
- package/src/common/index.test.ts +0 -35
- package/src/nextjs/nextjs.test.tsx +0 -94
- package/src/react/ConvexAuthState.test.tsx +0 -702
- package/src/react/auth_helpers.test.tsx +0 -45
- package/src/react/auth_websocket.test.tsx +0 -1177
- package/src/react/client.test.tsx +0 -261
- package/src/react/client_provided_base_client.test.tsx +0 -174
- package/src/react/queries_observer.test.ts +0 -176
- package/src/react/react_node.test.ts +0 -78
- package/src/react/use_paginated_query.test.tsx +0 -1420
- package/src/react/use_queries.test.ts +0 -140
- package/src/react/use_query.test.ts +0 -71
- package/src/react/use_query_object_options.test.ts +0 -51
- package/src/react/use_query_result.test.ts +0 -75
- package/src/react-auth0/ConvexProviderWithAuth0.test.tsx +0 -17
- package/src/react-clerk/ConvexProviderWithClerk.test.tsx +0 -18
- package/src/server/README.md +0 -15
- package/src/server/api.intersect.test.ts +0 -109
- package/src/server/api.test.ts +0 -447
- package/src/server/audit_logging.test.ts +0 -131
- package/src/server/components/index.test.ts +0 -48
- package/src/server/cron.test.ts +0 -58
- package/src/server/data_model.test.ts +0 -221
- package/src/server/database.test.ts +0 -184
- package/src/server/database_api.test.ts +0 -439
- package/src/server/filter_builder.test.ts +0 -102
- package/src/server/impl/actions_impl.test.ts +0 -59
- package/src/server/impl/filter_builder_impl.test.ts +0 -13
- package/src/server/impl/query_impl.test.ts +0 -46
- package/src/server/pagination.test.ts +0 -49
- package/src/server/query.test.ts +0 -112
- package/src/server/registration.test.ts +0 -589
- package/src/server/router.test.ts +0 -148
- package/src/server/scheduler.test.ts +0 -31
- package/src/server/schema.test.ts +0 -1081
- package/src/test/fake_watch.ts +0 -54
- package/src/test/type_testing.ts +0 -21
- package/src/type_utils.test.ts +0 -62
- package/src/values/size.test.ts +0 -95
- package/src/values/validator.test.ts +0 -619
- package/src/values/value.test.ts +0 -232
- package/src/vendor/README.md +0 -18
- package/src/vendor/jwt-decode/README.md +0 -1
|
@@ -1,1291 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
// @inquirer/testing/vitest must be imported before modules that use @inquirer/*
|
|
3
|
-
import { screen } from "@inquirer/testing/vitest";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { nodeFs } from "../bundler/fs.js";
|
|
6
|
-
import { deploymentSelect } from "./deploymentSelect.js";
|
|
7
|
-
import {
|
|
8
|
-
bigBrainAPI,
|
|
9
|
-
bigBrainAPIMaybeThrows,
|
|
10
|
-
ThrowingFetchError,
|
|
11
|
-
} from "./lib/utils/utils.js";
|
|
12
|
-
import {
|
|
13
|
-
bigBrainPause,
|
|
14
|
-
bigBrainStart,
|
|
15
|
-
} from "./lib/localDeployment/bigBrain.js";
|
|
16
|
-
import { globalConfigPath } from "./lib/utils/globalConfig.js";
|
|
17
|
-
|
|
18
|
-
// Mock GET functions — can be configured per test
|
|
19
|
-
const mockPlatformGet = vi.fn();
|
|
20
|
-
const mockDeploymentGet = vi.fn();
|
|
21
|
-
const { mockCreateLocalDeployment } = vi.hoisted(() => ({
|
|
22
|
-
mockCreateLocalDeployment: vi.fn(),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
// In-memory filesystem — populated in beforeEach, written to by real configure code
|
|
26
|
-
let testFiles: Map<string, string>;
|
|
27
|
-
|
|
28
|
-
vi.mock("../bundler/fs.js", async (importOriginal) => {
|
|
29
|
-
const actual = await importOriginal<typeof import("../bundler/fs.js")>();
|
|
30
|
-
return {
|
|
31
|
-
...actual,
|
|
32
|
-
nodeFs: {
|
|
33
|
-
...actual.nodeFs,
|
|
34
|
-
exists: vi.fn(),
|
|
35
|
-
readUtf8File: vi.fn(),
|
|
36
|
-
writeUtf8File: vi.fn(),
|
|
37
|
-
mkdir: vi.fn(),
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
vi.mock("./lib/utils/utils.js", async (importOriginal) => {
|
|
43
|
-
const actual = await importOriginal<typeof import("./lib/utils/utils.js")>();
|
|
44
|
-
return {
|
|
45
|
-
...actual,
|
|
46
|
-
bigBrainAPI: vi.fn(),
|
|
47
|
-
bigBrainAPIMaybeThrows: vi.fn(),
|
|
48
|
-
typedPlatformClient: vi.fn(() => ({ GET: mockPlatformGet })),
|
|
49
|
-
typedDeploymentClient: vi.fn(() => ({ GET: mockDeploymentGet })),
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
vi.mock("dotenv", async (importOriginal) => {
|
|
54
|
-
const actual = await importOriginal<typeof import("dotenv")>();
|
|
55
|
-
return {
|
|
56
|
-
...actual,
|
|
57
|
-
config: vi.fn(),
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
vi.mock("@sentry/node", () => ({
|
|
62
|
-
captureException: vi.fn(),
|
|
63
|
-
close: vi.fn(),
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
vi.mock("./deploymentCreate.js", async (importOriginal) => {
|
|
67
|
-
const actual = await importOriginal<typeof import("./deploymentCreate.js")>();
|
|
68
|
-
return {
|
|
69
|
-
...actual,
|
|
70
|
-
createLocalDeployment: mockCreateLocalDeployment,
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
vi.mock("./lib/localDeployment/run.js", async (importOriginal) => {
|
|
75
|
-
const actual =
|
|
76
|
-
await importOriginal<typeof import("./lib/localDeployment/run.js")>();
|
|
77
|
-
return {
|
|
78
|
-
...actual,
|
|
79
|
-
fetchLocalBackendStatus: vi.fn().mockResolvedValue({ kind: "running" }),
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
vi.mock("./lib/localDeployment/bigBrain.js", async (importOriginal) => {
|
|
84
|
-
const actual =
|
|
85
|
-
await importOriginal<typeof import("./lib/localDeployment/bigBrain.js")>();
|
|
86
|
-
return {
|
|
87
|
-
...actual,
|
|
88
|
-
bigBrainStart: vi.fn(),
|
|
89
|
-
bigBrainPause: vi.fn(),
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Routes mock Big Brain API calls by path.
|
|
95
|
-
* Both `bigBrainAPI` and `bigBrainAPIMaybeThrows` delegate to this.
|
|
96
|
-
*/
|
|
97
|
-
function setupBigBrainRoutes(routes: Record<string, (data?: any) => any>) {
|
|
98
|
-
const handler = (args: { path: string; data?: any }) => {
|
|
99
|
-
for (const [routePath, routeHandler] of Object.entries(routes)) {
|
|
100
|
-
if (args.path === routePath || args.path.startsWith(routePath)) {
|
|
101
|
-
return routeHandler(args.data);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
throw new Error(`Unmocked Big Brain route: ${args.path}`);
|
|
105
|
-
};
|
|
106
|
-
vi.mocked(bigBrainAPI).mockImplementation(handler as any);
|
|
107
|
-
vi.mocked(bigBrainAPIMaybeThrows).mockImplementation(handler as any);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
describe("npx convex select", () => {
|
|
111
|
-
let savedEnv: NodeJS.ProcessEnv;
|
|
112
|
-
let savedIsTTY: boolean | undefined;
|
|
113
|
-
|
|
114
|
-
beforeEach(() => {
|
|
115
|
-
savedEnv = { ...process.env };
|
|
116
|
-
savedIsTTY = process.stdin.isTTY;
|
|
117
|
-
process.env = {};
|
|
118
|
-
// Default to interactive TTY for existing tests
|
|
119
|
-
process.stdin.isTTY = true as any;
|
|
120
|
-
|
|
121
|
-
// Start with minimal filesystem: package.json for readProjectConfig fallback
|
|
122
|
-
testFiles = new Map([[path.resolve("package.json"), "{}"]]);
|
|
123
|
-
|
|
124
|
-
vi.resetAllMocks();
|
|
125
|
-
|
|
126
|
-
// Wire up the in-memory filesystem to the nodeFs mock
|
|
127
|
-
vi.mocked(nodeFs.exists).mockImplementation((p: string) =>
|
|
128
|
-
testFiles.has(path.resolve(p)),
|
|
129
|
-
);
|
|
130
|
-
vi.mocked(nodeFs.readUtf8File).mockImplementation((p: string) => {
|
|
131
|
-
const content = testFiles.get(path.resolve(p));
|
|
132
|
-
if (content === undefined) {
|
|
133
|
-
const err: any = new Error(
|
|
134
|
-
`ENOENT: no such file or directory, open '${p}'`,
|
|
135
|
-
);
|
|
136
|
-
err.code = "ENOENT";
|
|
137
|
-
throw err;
|
|
138
|
-
}
|
|
139
|
-
return content;
|
|
140
|
-
});
|
|
141
|
-
vi.mocked(nodeFs.writeUtf8File).mockImplementation(
|
|
142
|
-
(p: string, content: string) => {
|
|
143
|
-
testFiles.set(path.resolve(p), content);
|
|
144
|
-
},
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
// typedDeploymentClient GET is called by fetchDeploymentCanonicalUrls
|
|
148
|
-
mockDeploymentGet.mockResolvedValue({
|
|
149
|
-
data: {
|
|
150
|
-
convexCloudUrl: "https://example.convex.cloud",
|
|
151
|
-
convexSiteUrl: "https://example.convex.site",
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// typedPlatformClient is used for reference-based deployment resolution
|
|
156
|
-
vi.mocked(mockPlatformGet).mockResolvedValue({ data: undefined });
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
afterEach(() => {
|
|
160
|
-
process.env = savedEnv;
|
|
161
|
-
process.stdin.isTTY = savedIsTTY as any;
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// Suppress process.exit and stderr
|
|
165
|
-
beforeEach(() => {
|
|
166
|
-
vi.spyOn(process, "exit").mockImplementation((() => {
|
|
167
|
-
throw new Error("process.exit called");
|
|
168
|
-
}) as any);
|
|
169
|
-
vi.spyOn(process.stderr, "write").mockImplementation(() => true);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
afterEach(() => {
|
|
173
|
-
vi.restoreAllMocks();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
describe("with project configured", () => {
|
|
177
|
-
beforeEach(() => {
|
|
178
|
-
process.env.CONVEX_DEPLOYMENT = "dev:joyful-capybara-123";
|
|
179
|
-
testFiles.set(
|
|
180
|
-
globalConfigPath(),
|
|
181
|
-
JSON.stringify({ accessToken: "test-token" }),
|
|
182
|
-
);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it("selects a dev deployment by name (abc-xyz-123)", async () => {
|
|
186
|
-
// For a deployment name selector, the system looks up the *selected*
|
|
187
|
-
// deployment's team/project (not the current CONVEX_DEPLOYMENT's).
|
|
188
|
-
setupBigBrainRoutes({
|
|
189
|
-
"deployment/clever-otter-890/team_and_project": () => ({
|
|
190
|
-
team: "my-team",
|
|
191
|
-
project: "my-project",
|
|
192
|
-
teamId: 1,
|
|
193
|
-
projectId: 1,
|
|
194
|
-
}),
|
|
195
|
-
"deployment/authorize_within_current_project": () => ({
|
|
196
|
-
adminKey: "dev-key",
|
|
197
|
-
url: "https://clever-otter-890.convex.cloud",
|
|
198
|
-
deploymentName: "clever-otter-890",
|
|
199
|
-
deploymentType: "dev",
|
|
200
|
-
}),
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
await deploymentSelect.parseAsync(["clever-otter-890"], { from: "user" });
|
|
204
|
-
|
|
205
|
-
expect(bigBrainAPI).toHaveBeenCalledWith(
|
|
206
|
-
expect.objectContaining({
|
|
207
|
-
path: "deployment/authorize_within_current_project",
|
|
208
|
-
data: expect.objectContaining({
|
|
209
|
-
selectedDeploymentName: "clever-otter-890",
|
|
210
|
-
}),
|
|
211
|
-
}),
|
|
212
|
-
);
|
|
213
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
214
|
-
expect(envContent).toContain("CONVEX_DEPLOYMENT=dev:clever-otter-890");
|
|
215
|
-
expect(envContent).toContain("team: my-team, project: my-project");
|
|
216
|
-
expect(envContent).toContain(
|
|
217
|
-
"CONVEX_URL=https://clever-otter-890.convex.cloud",
|
|
218
|
-
);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it("selects dev deployment with 'dev' selector", async () => {
|
|
222
|
-
setupBigBrainRoutes({
|
|
223
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
224
|
-
team: "my-team",
|
|
225
|
-
project: "my-project",
|
|
226
|
-
teamId: 1,
|
|
227
|
-
projectId: 1,
|
|
228
|
-
}),
|
|
229
|
-
"teams/my-team/projects/my-project/deployments": () => true,
|
|
230
|
-
"deployment/authorize_within_current_project": () => ({
|
|
231
|
-
adminKey: "dev-key",
|
|
232
|
-
url: "https://joyful-capybara-123.convex.cloud",
|
|
233
|
-
deploymentName: "joyful-capybara-123",
|
|
234
|
-
deploymentType: "dev",
|
|
235
|
-
}),
|
|
236
|
-
});
|
|
237
|
-
mockPlatformGet.mockResolvedValue({
|
|
238
|
-
data: { name: "joyful-capybara-123" },
|
|
239
|
-
error: undefined,
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
await deploymentSelect.parseAsync(["dev"], { from: "user" });
|
|
243
|
-
|
|
244
|
-
expect(mockPlatformGet).toHaveBeenCalledWith(
|
|
245
|
-
"/teams/{team_id_or_slug}/projects/{project_slug}/deployment",
|
|
246
|
-
expect.objectContaining({
|
|
247
|
-
params: expect.objectContaining({
|
|
248
|
-
path: { team_id_or_slug: "my-team", project_slug: "my-project" },
|
|
249
|
-
query: { defaultDev: true },
|
|
250
|
-
}),
|
|
251
|
-
}),
|
|
252
|
-
);
|
|
253
|
-
expect(bigBrainAPI).toHaveBeenCalledWith(
|
|
254
|
-
expect.objectContaining({
|
|
255
|
-
path: "deployment/authorize_within_current_project",
|
|
256
|
-
data: expect.objectContaining({
|
|
257
|
-
selectedDeploymentName: "joyful-capybara-123",
|
|
258
|
-
}),
|
|
259
|
-
}),
|
|
260
|
-
);
|
|
261
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
262
|
-
expect(envContent).toContain("CONVEX_DEPLOYMENT=dev:joyful-capybara-123");
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it("selects dev deployment by reference 'dev/nicolas'", async () => {
|
|
266
|
-
setupBigBrainRoutes({
|
|
267
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
268
|
-
team: "my-team",
|
|
269
|
-
project: "my-project",
|
|
270
|
-
teamId: 1,
|
|
271
|
-
projectId: 1,
|
|
272
|
-
}),
|
|
273
|
-
"teams/my-team/projects/my-project/deployments": () => true,
|
|
274
|
-
"deployment/authorize_within_current_project": () => ({
|
|
275
|
-
adminKey: "nicolas-key",
|
|
276
|
-
url: "https://nicolas-dev-123.convex.cloud",
|
|
277
|
-
deploymentName: "nicolas-dev-123",
|
|
278
|
-
deploymentType: "dev",
|
|
279
|
-
}),
|
|
280
|
-
});
|
|
281
|
-
mockPlatformGet.mockResolvedValue({
|
|
282
|
-
data: { name: "nicolas-dev-123" },
|
|
283
|
-
error: undefined,
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
await deploymentSelect.parseAsync(["dev/nicolas"], { from: "user" });
|
|
287
|
-
|
|
288
|
-
expect(mockPlatformGet).toHaveBeenCalledWith(
|
|
289
|
-
"/teams/{team_id_or_slug}/projects/{project_slug}/deployment",
|
|
290
|
-
expect.objectContaining({
|
|
291
|
-
params: expect.objectContaining({
|
|
292
|
-
path: { team_id_or_slug: "my-team", project_slug: "my-project" },
|
|
293
|
-
query: { reference: "dev/nicolas" },
|
|
294
|
-
}),
|
|
295
|
-
}),
|
|
296
|
-
);
|
|
297
|
-
expect(bigBrainAPI).toHaveBeenCalledWith(
|
|
298
|
-
expect.objectContaining({
|
|
299
|
-
path: "deployment/authorize_within_current_project",
|
|
300
|
-
data: expect.objectContaining({
|
|
301
|
-
selectedDeploymentName: "nicolas-dev-123",
|
|
302
|
-
}),
|
|
303
|
-
}),
|
|
304
|
-
);
|
|
305
|
-
expect(testFiles.has(path.resolve(".env.local"))).toBe(true);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it("selects a preview deployment in another project 'other-project:preview/my-feature'", async () => {
|
|
309
|
-
setupBigBrainRoutes({
|
|
310
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
311
|
-
team: "my-team",
|
|
312
|
-
project: "my-project",
|
|
313
|
-
teamId: 1,
|
|
314
|
-
projectId: 1,
|
|
315
|
-
}),
|
|
316
|
-
"teams/my-team/projects/other-project/deployments": () => true,
|
|
317
|
-
"deployment/authorize_within_current_project": () => ({
|
|
318
|
-
adminKey: "preview-key",
|
|
319
|
-
url: "https://feature-preview-123.convex.cloud",
|
|
320
|
-
deploymentName: "feature-preview-123",
|
|
321
|
-
deploymentType: "preview",
|
|
322
|
-
}),
|
|
323
|
-
});
|
|
324
|
-
mockPlatformGet.mockResolvedValue({
|
|
325
|
-
data: { name: "feature-preview-123" },
|
|
326
|
-
error: undefined,
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
await deploymentSelect.parseAsync(["other-project:preview/my-feature"], {
|
|
330
|
-
from: "user",
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
expect(mockPlatformGet).toHaveBeenCalledWith(
|
|
334
|
-
"/teams/{team_id_or_slug}/projects/{project_slug}/deployment",
|
|
335
|
-
expect.objectContaining({
|
|
336
|
-
params: expect.objectContaining({
|
|
337
|
-
path: {
|
|
338
|
-
team_id_or_slug: "my-team",
|
|
339
|
-
project_slug: "other-project",
|
|
340
|
-
},
|
|
341
|
-
query: { reference: "preview/my-feature" },
|
|
342
|
-
}),
|
|
343
|
-
}),
|
|
344
|
-
);
|
|
345
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
346
|
-
expect(envContent).toContain(
|
|
347
|
-
"CONVEX_DEPLOYMENT=preview:feature-preview-123",
|
|
348
|
-
);
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
describe("prod deployment restrictions", () => {
|
|
352
|
-
it("fails with an error message when 'prod' selector is used", async () => {
|
|
353
|
-
setupBigBrainRoutes({
|
|
354
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
355
|
-
team: "my-team",
|
|
356
|
-
project: "my-project",
|
|
357
|
-
teamId: 1,
|
|
358
|
-
projectId: 1,
|
|
359
|
-
}),
|
|
360
|
-
"deployment/authorize_prod": () => ({
|
|
361
|
-
adminKey: "prod-key",
|
|
362
|
-
url: "https://graceful-puffin-456.convex.cloud",
|
|
363
|
-
deploymentName: "graceful-puffin-456",
|
|
364
|
-
deploymentType: "prod",
|
|
365
|
-
}),
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
await expect(
|
|
369
|
-
deploymentSelect.parseAsync(["prod"], { from: "user" }),
|
|
370
|
-
).rejects.toThrow();
|
|
371
|
-
|
|
372
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
373
|
-
expect.stringContaining("--deployment prod"),
|
|
374
|
-
);
|
|
375
|
-
expect(testFiles.has(path.resolve(".env.local"))).toBe(false);
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
it("fails with an error message when a deployment name resolves to a prod deployment", async () => {
|
|
379
|
-
setupBigBrainRoutes({
|
|
380
|
-
"deployment/graceful-puffin-456/team_and_project": () => ({
|
|
381
|
-
team: "my-team",
|
|
382
|
-
project: "my-project",
|
|
383
|
-
teamId: 1,
|
|
384
|
-
projectId: 1,
|
|
385
|
-
}),
|
|
386
|
-
"deployment/authorize_within_current_project": () => ({
|
|
387
|
-
adminKey: "prod-key",
|
|
388
|
-
url: "https://graceful-puffin-456.convex.cloud",
|
|
389
|
-
deploymentName: "graceful-puffin-456",
|
|
390
|
-
deploymentType: "prod",
|
|
391
|
-
}),
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
await expect(
|
|
395
|
-
deploymentSelect.parseAsync(["graceful-puffin-456"], {
|
|
396
|
-
from: "user",
|
|
397
|
-
}),
|
|
398
|
-
).rejects.toThrow();
|
|
399
|
-
|
|
400
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
401
|
-
expect.stringContaining("--deployment graceful-puffin-456"),
|
|
402
|
-
);
|
|
403
|
-
expect(testFiles.has(path.resolve(".env.local"))).toBe(false);
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
describe("side effects on successful selection", () => {
|
|
408
|
-
it("fetches the canonical URLs using the resolved deployment credentials", async () => {
|
|
409
|
-
setupBigBrainRoutes({
|
|
410
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
411
|
-
team: "my-team",
|
|
412
|
-
project: "my-project",
|
|
413
|
-
teamId: 1,
|
|
414
|
-
projectId: 1,
|
|
415
|
-
}),
|
|
416
|
-
"teams/my-team/projects/my-project/deployments": () => true,
|
|
417
|
-
"deployment/authorize_within_current_project": () => ({
|
|
418
|
-
adminKey: "dev-key",
|
|
419
|
-
url: "https://joyful-capybara-123.convex.cloud",
|
|
420
|
-
deploymentName: "joyful-capybara-123",
|
|
421
|
-
deploymentType: "dev",
|
|
422
|
-
}),
|
|
423
|
-
});
|
|
424
|
-
mockPlatformGet.mockResolvedValue({
|
|
425
|
-
data: { name: "joyful-capybara-123" },
|
|
426
|
-
error: undefined,
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
await deploymentSelect.parseAsync(["dev"], { from: "user" });
|
|
430
|
-
|
|
431
|
-
expect(mockDeploymentGet).toHaveBeenCalledWith("/get_canonical_urls");
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
it("writes the fetched site URL to the env file", async () => {
|
|
435
|
-
mockDeploymentGet.mockResolvedValue({
|
|
436
|
-
data: {
|
|
437
|
-
convexCloudUrl: "https://joyful-capybara-123.convex.cloud",
|
|
438
|
-
convexSiteUrl: "https://joyful-capybara-123.convex.site",
|
|
439
|
-
},
|
|
440
|
-
});
|
|
441
|
-
setupBigBrainRoutes({
|
|
442
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
443
|
-
team: "my-team",
|
|
444
|
-
project: "my-project",
|
|
445
|
-
teamId: 1,
|
|
446
|
-
projectId: 1,
|
|
447
|
-
}),
|
|
448
|
-
"teams/my-team/projects/my-project/deployments": () => true,
|
|
449
|
-
"deployment/authorize_within_current_project": () => ({
|
|
450
|
-
adminKey: "dev-key",
|
|
451
|
-
url: "https://joyful-capybara-123.convex.cloud",
|
|
452
|
-
deploymentName: "joyful-capybara-123",
|
|
453
|
-
deploymentType: "dev",
|
|
454
|
-
}),
|
|
455
|
-
});
|
|
456
|
-
mockPlatformGet.mockResolvedValue({
|
|
457
|
-
data: { name: "joyful-capybara-123" },
|
|
458
|
-
error: undefined,
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
await deploymentSelect.parseAsync(["dev"], { from: "user" });
|
|
462
|
-
|
|
463
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
464
|
-
expect(envContent).toContain(
|
|
465
|
-
"CONVEX_SITE_URL=https://joyful-capybara-123.convex.site",
|
|
466
|
-
);
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
it("uses the existing deployment name to detect unchanged selections", async () => {
|
|
470
|
-
// deploymentNameFromSelection(currentSelection) extracts "joyful-capybara-123"
|
|
471
|
-
// from process.env.CONVEX_DEPLOYMENT ("dev:joyful-capybara-123") and passes
|
|
472
|
-
// it as existingValue to configure so it can detect whether the selection changed.
|
|
473
|
-
// Here we verify the full chain ran: the correct name is written to .env.local.
|
|
474
|
-
setupBigBrainRoutes({
|
|
475
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
476
|
-
team: "my-team",
|
|
477
|
-
project: "my-project",
|
|
478
|
-
teamId: 1,
|
|
479
|
-
projectId: 1,
|
|
480
|
-
}),
|
|
481
|
-
"teams/my-team/projects/my-project/deployments": () => true,
|
|
482
|
-
"deployment/authorize_within_current_project": () => ({
|
|
483
|
-
adminKey: "dev-key",
|
|
484
|
-
url: "https://joyful-capybara-123.convex.cloud",
|
|
485
|
-
deploymentName: "joyful-capybara-123",
|
|
486
|
-
deploymentType: "dev",
|
|
487
|
-
}),
|
|
488
|
-
});
|
|
489
|
-
mockPlatformGet.mockResolvedValue({
|
|
490
|
-
data: { name: "joyful-capybara-123" },
|
|
491
|
-
error: undefined,
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
await deploymentSelect.parseAsync(["dev"], { from: "user" });
|
|
495
|
-
|
|
496
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
497
|
-
expect(envContent).toContain(
|
|
498
|
-
"CONVEX_DEPLOYMENT=dev:joyful-capybara-123",
|
|
499
|
-
);
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
it("selects local deployment with 'local' selector", async () => {
|
|
504
|
-
testFiles.set(
|
|
505
|
-
path.resolve(".convex/local/default/config.json"),
|
|
506
|
-
JSON.stringify({
|
|
507
|
-
ports: { cloud: 3210, site: 3211 },
|
|
508
|
-
adminKey: "local-key",
|
|
509
|
-
backendVersion: "1.0.0",
|
|
510
|
-
deploymentName: "local-my_team-my_project-abc",
|
|
511
|
-
cloudProjectId: 42,
|
|
512
|
-
}),
|
|
513
|
-
);
|
|
514
|
-
// The local deployment name is looked up via Big Brain for project
|
|
515
|
-
// access checks (checkAccessToSelectedProject)
|
|
516
|
-
// FIXME We should probably avoid the Big Brain call here so that it works offline
|
|
517
|
-
setupBigBrainRoutes({
|
|
518
|
-
"deployment/local-my_team-my_project-abc/team_and_project": () => ({
|
|
519
|
-
team: "my-team",
|
|
520
|
-
project: "my-project",
|
|
521
|
-
teamId: 1,
|
|
522
|
-
projectId: 42,
|
|
523
|
-
}),
|
|
524
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
525
|
-
team: "my-team",
|
|
526
|
-
project: "my-project",
|
|
527
|
-
teamId: 1,
|
|
528
|
-
projectId: 42,
|
|
529
|
-
}),
|
|
530
|
-
});
|
|
531
|
-
// Project lookup: CONVEX_DEPLOYMENT → /deployments/{name} → /projects/{id}
|
|
532
|
-
mockPlatformGet.mockImplementation((path: string) => {
|
|
533
|
-
if (path === "/deployments/{deployment_name}") {
|
|
534
|
-
return { data: { projectId: 42 } };
|
|
535
|
-
}
|
|
536
|
-
if (path === "/projects/{project_id}") {
|
|
537
|
-
return {
|
|
538
|
-
data: {
|
|
539
|
-
id: 42,
|
|
540
|
-
teamSlug: "my-team",
|
|
541
|
-
slug: "my-project",
|
|
542
|
-
},
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
return { data: undefined };
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
await deploymentSelect.parseAsync(["local"], { from: "user" });
|
|
549
|
-
|
|
550
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
551
|
-
expect(envContent).toContain(
|
|
552
|
-
"CONVEX_DEPLOYMENT=local:local-my_team-my_project-abc",
|
|
553
|
-
);
|
|
554
|
-
// Site URL fetch should be skipped for local deployments
|
|
555
|
-
expect(envContent).not.toContain("CONVEX_SITE_URL");
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
it("creates a local deployment when user approves the 'Create one now?' prompt", async () => {
|
|
559
|
-
mockCreateLocalDeployment.mockResolvedValue(undefined);
|
|
560
|
-
|
|
561
|
-
const promise = deploymentSelect.parseAsync(["local"], { from: "user" });
|
|
562
|
-
|
|
563
|
-
await screen.next();
|
|
564
|
-
expect(screen.getScreen()).toContain(
|
|
565
|
-
"No local deployment found. Create one now?",
|
|
566
|
-
);
|
|
567
|
-
screen.keypress("y");
|
|
568
|
-
screen.keypress("enter");
|
|
569
|
-
|
|
570
|
-
await promise;
|
|
571
|
-
|
|
572
|
-
expect(mockCreateLocalDeployment).toHaveBeenCalledTimes(1);
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
it("refuses to create a local deployment for 'project:local' when no local config exists (could silently target wrong project)", async () => {
|
|
576
|
-
await expect(
|
|
577
|
-
deploymentSelect.parseAsync(["my-project:local"], { from: "user" }),
|
|
578
|
-
).rejects.toThrow();
|
|
579
|
-
|
|
580
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
581
|
-
expect.stringContaining(
|
|
582
|
-
"npx convex deployment create local --project my-project",
|
|
583
|
-
),
|
|
584
|
-
);
|
|
585
|
-
expect(mockCreateLocalDeployment).not.toHaveBeenCalled();
|
|
586
|
-
expect(testFiles.has(path.resolve(".env.local"))).toBe(false);
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
it("fails with 'No local deployment found' when no local config exists and stdin is not a TTY", async () => {
|
|
590
|
-
const previousIsTTY = process.stdin.isTTY;
|
|
591
|
-
process.stdin.isTTY = false as any;
|
|
592
|
-
try {
|
|
593
|
-
await expect(
|
|
594
|
-
deploymentSelect.parseAsync(["local"], { from: "user" }),
|
|
595
|
-
).rejects.toThrow();
|
|
596
|
-
|
|
597
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
598
|
-
expect.stringContaining("No local deployment found"),
|
|
599
|
-
);
|
|
600
|
-
expect(mockCreateLocalDeployment).not.toHaveBeenCalled();
|
|
601
|
-
} finally {
|
|
602
|
-
process.stdin.isTTY = previousIsTTY as any;
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
describe("project mismatch flow", () => {
|
|
607
|
-
function mockProjectLookup(opts: { projectId: number }) {
|
|
608
|
-
mockPlatformGet.mockImplementation((path: string) => {
|
|
609
|
-
if (path === "/deployments/{deployment_name}") {
|
|
610
|
-
return { data: { projectId: opts.projectId } };
|
|
611
|
-
}
|
|
612
|
-
if (path === "/projects/{project_id}") {
|
|
613
|
-
return {
|
|
614
|
-
data: {
|
|
615
|
-
id: opts.projectId,
|
|
616
|
-
teamSlug: "my-team",
|
|
617
|
-
slug: "my-project",
|
|
618
|
-
},
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
return { data: undefined };
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
it("matching cloudProjectId → selects directly without warn/pause/bigBrainStart", async () => {
|
|
626
|
-
testFiles.set(
|
|
627
|
-
path.resolve(".convex/local/default/config.json"),
|
|
628
|
-
JSON.stringify({
|
|
629
|
-
ports: { cloud: 3210, site: 3211 },
|
|
630
|
-
adminKey: "local-key",
|
|
631
|
-
backendVersion: "1.0.0",
|
|
632
|
-
deploymentName: "local-my_team-my_project-abc",
|
|
633
|
-
cloudProjectId: 42,
|
|
634
|
-
}),
|
|
635
|
-
);
|
|
636
|
-
setupBigBrainRoutes({
|
|
637
|
-
"deployment/local-my_team-my_project-abc/team_and_project": () => ({
|
|
638
|
-
team: "my-team",
|
|
639
|
-
project: "my-project",
|
|
640
|
-
teamId: 1,
|
|
641
|
-
projectId: 42,
|
|
642
|
-
}),
|
|
643
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
644
|
-
team: "my-team",
|
|
645
|
-
project: "my-project",
|
|
646
|
-
teamId: 1,
|
|
647
|
-
projectId: 42,
|
|
648
|
-
}),
|
|
649
|
-
});
|
|
650
|
-
mockProjectLookup({ projectId: 42 });
|
|
651
|
-
|
|
652
|
-
await deploymentSelect.parseAsync(["local"], { from: "user" });
|
|
653
|
-
|
|
654
|
-
// Did NOT call pause or start
|
|
655
|
-
expect(bigBrainPause).not.toHaveBeenCalled();
|
|
656
|
-
expect(bigBrainStart).not.toHaveBeenCalled();
|
|
657
|
-
// config.json untouched
|
|
658
|
-
const config = JSON.parse(
|
|
659
|
-
testFiles.get(path.resolve(".convex/local/default/config.json"))!,
|
|
660
|
-
);
|
|
661
|
-
expect(config.cloudProjectId).toBe(42);
|
|
662
|
-
expect(config.adminKey).toBe("local-key");
|
|
663
|
-
// Selection saved
|
|
664
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
665
|
-
expect(envContent).toContain(
|
|
666
|
-
"CONVEX_DEPLOYMENT=local:local-my_team-my_project-abc",
|
|
667
|
-
);
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
it("missing cloudProjectId → writes resolved id back to config.json and selects", async () => {
|
|
671
|
-
testFiles.set(
|
|
672
|
-
path.resolve(".convex/local/default/config.json"),
|
|
673
|
-
JSON.stringify({
|
|
674
|
-
ports: { cloud: 3210, site: 3211 },
|
|
675
|
-
adminKey: "local-key",
|
|
676
|
-
backendVersion: "1.0.0",
|
|
677
|
-
deploymentName: "local-my_team-my_project-abc",
|
|
678
|
-
}),
|
|
679
|
-
);
|
|
680
|
-
setupBigBrainRoutes({
|
|
681
|
-
"deployment/local-my_team-my_project-abc/team_and_project": () => ({
|
|
682
|
-
team: "my-team",
|
|
683
|
-
project: "my-project",
|
|
684
|
-
teamId: 1,
|
|
685
|
-
projectId: 42,
|
|
686
|
-
}),
|
|
687
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
688
|
-
team: "my-team",
|
|
689
|
-
project: "my-project",
|
|
690
|
-
teamId: 1,
|
|
691
|
-
projectId: 42,
|
|
692
|
-
}),
|
|
693
|
-
});
|
|
694
|
-
mockProjectLookup({ projectId: 42 });
|
|
695
|
-
|
|
696
|
-
await deploymentSelect.parseAsync(["local"], { from: "user" });
|
|
697
|
-
|
|
698
|
-
const config = JSON.parse(
|
|
699
|
-
testFiles.get(path.resolve(".convex/local/default/config.json"))!,
|
|
700
|
-
);
|
|
701
|
-
expect(config.cloudProjectId).toBe(42);
|
|
702
|
-
// No pause / no start
|
|
703
|
-
expect(bigBrainPause).not.toHaveBeenCalled();
|
|
704
|
-
expect(bigBrainStart).not.toHaveBeenCalled();
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
it("mismatching cloudProjectId → warns, pauses old, registers new, rewrites config, selects", async () => {
|
|
708
|
-
testFiles.set(
|
|
709
|
-
path.resolve(".convex/local/default/config.json"),
|
|
710
|
-
JSON.stringify({
|
|
711
|
-
ports: { cloud: 3210, site: 3211 },
|
|
712
|
-
adminKey: "admin-key",
|
|
713
|
-
backendVersion: "1.0.0",
|
|
714
|
-
deploymentName: "local-old_team-old_project-abc",
|
|
715
|
-
cloudProjectId: 100, // old project
|
|
716
|
-
}),
|
|
717
|
-
);
|
|
718
|
-
setupBigBrainRoutes({
|
|
719
|
-
"deployment/local-new_team-new_project-xyz/team_and_project": () => ({
|
|
720
|
-
team: "my-team",
|
|
721
|
-
project: "my-project",
|
|
722
|
-
teamId: 1,
|
|
723
|
-
projectId: 42,
|
|
724
|
-
}),
|
|
725
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
726
|
-
team: "my-team",
|
|
727
|
-
project: "my-project",
|
|
728
|
-
teamId: 1,
|
|
729
|
-
projectId: 42,
|
|
730
|
-
}),
|
|
731
|
-
});
|
|
732
|
-
vi.mocked(bigBrainPause).mockResolvedValue(undefined);
|
|
733
|
-
vi.mocked(bigBrainStart).mockResolvedValue({
|
|
734
|
-
deploymentName: "local-new_team-new_project-xyz",
|
|
735
|
-
adminKey: "admin-key",
|
|
736
|
-
projectId: 42,
|
|
737
|
-
});
|
|
738
|
-
mockPlatformGet.mockImplementation((path: string, args: any) => {
|
|
739
|
-
if (path === "/deployments/{deployment_name}") {
|
|
740
|
-
return { data: { projectId: 42 } };
|
|
741
|
-
}
|
|
742
|
-
if (path === "/projects/{project_id}") {
|
|
743
|
-
const id = args?.params?.path?.project_id;
|
|
744
|
-
if (id === 100) {
|
|
745
|
-
return {
|
|
746
|
-
data: {
|
|
747
|
-
id: 100,
|
|
748
|
-
teamSlug: "old-team",
|
|
749
|
-
slug: "old-project",
|
|
750
|
-
},
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
return {
|
|
754
|
-
data: {
|
|
755
|
-
id: 42,
|
|
756
|
-
teamSlug: "my-team",
|
|
757
|
-
slug: "my-project",
|
|
758
|
-
},
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
return { data: undefined };
|
|
762
|
-
});
|
|
763
|
-
|
|
764
|
-
await deploymentSelect.parseAsync(["local"], { from: "user" });
|
|
765
|
-
|
|
766
|
-
// Warned about the move, using the resolved slugs
|
|
767
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
768
|
-
expect.stringContaining(
|
|
769
|
-
"This local deployment was previously in project old-team:old-project. Moving it to project my-team:my-project.",
|
|
770
|
-
),
|
|
771
|
-
);
|
|
772
|
-
// Paused the old project's local deployment
|
|
773
|
-
expect(bigBrainPause).toHaveBeenCalledWith(expect.anything(), {
|
|
774
|
-
teamSlug: "old-team",
|
|
775
|
-
projectSlug: "old-project",
|
|
776
|
-
});
|
|
777
|
-
// Registered against the new project
|
|
778
|
-
expect(bigBrainStart).toHaveBeenCalledWith(
|
|
779
|
-
expect.anything(),
|
|
780
|
-
expect.objectContaining({
|
|
781
|
-
teamSlug: "my-team",
|
|
782
|
-
projectSlug: "my-project",
|
|
783
|
-
}),
|
|
784
|
-
);
|
|
785
|
-
const config = JSON.parse(
|
|
786
|
-
testFiles.get(path.resolve(".convex/local/default/config.json"))!,
|
|
787
|
-
);
|
|
788
|
-
expect(config.cloudProjectId).toBe(42);
|
|
789
|
-
expect(config.adminKey).toBe("admin-key");
|
|
790
|
-
expect(config.deploymentName).toBe("local-new_team-new_project-xyz");
|
|
791
|
-
expect(config.ports).toEqual({ cloud: 3210, site: 3211 });
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
it("swallows pause failure: still calls start and saves selection", async () => {
|
|
795
|
-
testFiles.set(
|
|
796
|
-
path.resolve(".convex/local/default/config.json"),
|
|
797
|
-
JSON.stringify({
|
|
798
|
-
ports: { cloud: 3210, site: 3211 },
|
|
799
|
-
adminKey: "admin-key",
|
|
800
|
-
backendVersion: "1.0.0",
|
|
801
|
-
deploymentName: "local-old_team-old_project-abc",
|
|
802
|
-
cloudProjectId: 100,
|
|
803
|
-
}),
|
|
804
|
-
);
|
|
805
|
-
setupBigBrainRoutes({
|
|
806
|
-
"deployment/local-new_team-new_project-xyz/team_and_project": () => ({
|
|
807
|
-
team: "my-team",
|
|
808
|
-
project: "my-project",
|
|
809
|
-
teamId: 1,
|
|
810
|
-
projectId: 42,
|
|
811
|
-
}),
|
|
812
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
813
|
-
team: "my-team",
|
|
814
|
-
project: "my-project",
|
|
815
|
-
teamId: 1,
|
|
816
|
-
projectId: 42,
|
|
817
|
-
}),
|
|
818
|
-
});
|
|
819
|
-
vi.mocked(bigBrainPause).mockRejectedValue(new Error("pause failed"));
|
|
820
|
-
vi.mocked(bigBrainStart).mockResolvedValue({
|
|
821
|
-
deploymentName: "local-new_team-new_project-xyz",
|
|
822
|
-
adminKey: "admin-key",
|
|
823
|
-
projectId: 42,
|
|
824
|
-
});
|
|
825
|
-
mockPlatformGet.mockImplementation((path: string, args: any) => {
|
|
826
|
-
if (path === "/deployments/{deployment_name}") {
|
|
827
|
-
return { data: { projectId: 42 } };
|
|
828
|
-
}
|
|
829
|
-
if (path === "/projects/{project_id}") {
|
|
830
|
-
const id = args?.params?.path?.project_id;
|
|
831
|
-
if (id === 100) {
|
|
832
|
-
return {
|
|
833
|
-
data: { id: 100, teamSlug: "old-team", slug: "old-project" },
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
return {
|
|
837
|
-
data: { id: 42, teamSlug: "my-team", slug: "my-project" },
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
return { data: undefined };
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
await deploymentSelect.parseAsync(["local"], { from: "user" });
|
|
844
|
-
|
|
845
|
-
expect(bigBrainStart).toHaveBeenCalled();
|
|
846
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
847
|
-
expect(envContent).toContain(
|
|
848
|
-
"CONVEX_DEPLOYMENT=local:local-new_team-new_project-xyz",
|
|
849
|
-
);
|
|
850
|
-
});
|
|
851
|
-
|
|
852
|
-
it("swallows old-project 404 (deleted cloud project): still registers new project and selects", async () => {
|
|
853
|
-
testFiles.set(
|
|
854
|
-
path.resolve(".convex/local/default/config.json"),
|
|
855
|
-
JSON.stringify({
|
|
856
|
-
ports: { cloud: 3210, site: 3211 },
|
|
857
|
-
adminKey: "admin-key",
|
|
858
|
-
backendVersion: "1.0.0",
|
|
859
|
-
deploymentName: "local-old_team-old_project-abc",
|
|
860
|
-
cloudProjectId: 100,
|
|
861
|
-
}),
|
|
862
|
-
);
|
|
863
|
-
setupBigBrainRoutes({
|
|
864
|
-
"deployment/local-new_team-new_project-xyz/team_and_project": () => ({
|
|
865
|
-
team: "my-team",
|
|
866
|
-
project: "my-project",
|
|
867
|
-
teamId: 1,
|
|
868
|
-
projectId: 42,
|
|
869
|
-
}),
|
|
870
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
871
|
-
team: "my-team",
|
|
872
|
-
project: "my-project",
|
|
873
|
-
teamId: 1,
|
|
874
|
-
projectId: 42,
|
|
875
|
-
}),
|
|
876
|
-
});
|
|
877
|
-
vi.mocked(bigBrainStart).mockResolvedValue({
|
|
878
|
-
deploymentName: "local-new_team-new_project-xyz",
|
|
879
|
-
adminKey: "admin-key",
|
|
880
|
-
projectId: 42,
|
|
881
|
-
});
|
|
882
|
-
mockPlatformGet.mockImplementation((path: string, args: any) => {
|
|
883
|
-
if (path === "/deployments/{deployment_name}") {
|
|
884
|
-
return { data: { projectId: 42 } };
|
|
885
|
-
}
|
|
886
|
-
if (path === "/projects/{project_id}") {
|
|
887
|
-
const id = args?.params?.path?.project_id;
|
|
888
|
-
if (id === 100) {
|
|
889
|
-
const response = new Response(
|
|
890
|
-
JSON.stringify({
|
|
891
|
-
code: "ProjectNotFound",
|
|
892
|
-
message: "...",
|
|
893
|
-
}),
|
|
894
|
-
{ status: 404, statusText: "Not Found" },
|
|
895
|
-
);
|
|
896
|
-
throw new ThrowingFetchError("Error fetching", {
|
|
897
|
-
code: "ProjectNotFound",
|
|
898
|
-
message: "The requested project does not exist",
|
|
899
|
-
response,
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
return {
|
|
903
|
-
data: { id: 42, teamSlug: "my-team", slug: "my-project" },
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
return { data: undefined };
|
|
907
|
-
});
|
|
908
|
-
|
|
909
|
-
await deploymentSelect.parseAsync(["local"], { from: "user" });
|
|
910
|
-
|
|
911
|
-
// Warning falls back to the raw id when the project can't be resolved
|
|
912
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
913
|
-
expect.stringContaining(
|
|
914
|
-
"This local deployment was previously in an unknown cloud project (ID 100). Moving it to project my-team:my-project.",
|
|
915
|
-
),
|
|
916
|
-
);
|
|
917
|
-
expect(bigBrainPause).not.toHaveBeenCalled();
|
|
918
|
-
expect(bigBrainStart).toHaveBeenCalled();
|
|
919
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
920
|
-
expect(envContent).toContain(
|
|
921
|
-
"CONVEX_DEPLOYMENT=local:local-new_team-new_project-xyz",
|
|
922
|
-
);
|
|
923
|
-
const config = JSON.parse(
|
|
924
|
-
testFiles.get(path.resolve(".convex/local/default/config.json"))!,
|
|
925
|
-
);
|
|
926
|
-
expect(config.cloudProjectId).toBe(42);
|
|
927
|
-
expect(config.deploymentName).toBe("local-new_team-new_project-xyz");
|
|
928
|
-
});
|
|
929
|
-
|
|
930
|
-
describe.each([
|
|
931
|
-
{ label: "project:local", selector: "my-project:local" },
|
|
932
|
-
{
|
|
933
|
-
label: "team:project:local",
|
|
934
|
-
selector: "my-team:my-project:local",
|
|
935
|
-
},
|
|
936
|
-
])("select $label", ({ selector }) => {
|
|
937
|
-
function mockPlatformForTargetProject(opts: { projectId: number }) {
|
|
938
|
-
mockPlatformGet.mockImplementation((path: string, args: any) => {
|
|
939
|
-
if (path === "/deployments/{deployment_name}") {
|
|
940
|
-
return { data: { projectId: opts.projectId } };
|
|
941
|
-
}
|
|
942
|
-
if (path === "/projects/{project_id}") {
|
|
943
|
-
const id = args?.params?.path?.project_id;
|
|
944
|
-
if (id === 100) {
|
|
945
|
-
return {
|
|
946
|
-
data: {
|
|
947
|
-
id: 100,
|
|
948
|
-
teamSlug: "old-team",
|
|
949
|
-
slug: "old-project",
|
|
950
|
-
},
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
return {
|
|
954
|
-
data: {
|
|
955
|
-
id: opts.projectId,
|
|
956
|
-
teamSlug: "my-team",
|
|
957
|
-
slug: "my-project",
|
|
958
|
-
},
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
if (path === "/teams/{team_id_or_slug}/projects/{project_slug}") {
|
|
962
|
-
return {
|
|
963
|
-
data: {
|
|
964
|
-
id: opts.projectId,
|
|
965
|
-
teamSlug: "my-team",
|
|
966
|
-
slug: "my-project",
|
|
967
|
-
},
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
return { data: undefined };
|
|
971
|
-
});
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
it("matching cloudProjectId → selects without warn/pause/start", async () => {
|
|
975
|
-
testFiles.set(
|
|
976
|
-
path.resolve(".convex/local/default/config.json"),
|
|
977
|
-
JSON.stringify({
|
|
978
|
-
ports: { cloud: 3210, site: 3211 },
|
|
979
|
-
adminKey: "local-key",
|
|
980
|
-
backendVersion: "1.0.0",
|
|
981
|
-
deploymentName: "local-my_team-my_project-abc",
|
|
982
|
-
cloudProjectId: 42,
|
|
983
|
-
}),
|
|
984
|
-
);
|
|
985
|
-
setupBigBrainRoutes({
|
|
986
|
-
"deployment/local-my_team-my_project-abc/team_and_project": () => ({
|
|
987
|
-
team: "my-team",
|
|
988
|
-
project: "my-project",
|
|
989
|
-
teamId: 1,
|
|
990
|
-
projectId: 42,
|
|
991
|
-
}),
|
|
992
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
993
|
-
team: "my-team",
|
|
994
|
-
project: "my-project",
|
|
995
|
-
teamId: 1,
|
|
996
|
-
projectId: 42,
|
|
997
|
-
}),
|
|
998
|
-
});
|
|
999
|
-
mockPlatformForTargetProject({ projectId: 42 });
|
|
1000
|
-
|
|
1001
|
-
await deploymentSelect.parseAsync([selector], { from: "user" });
|
|
1002
|
-
|
|
1003
|
-
expect(bigBrainPause).not.toHaveBeenCalled();
|
|
1004
|
-
expect(bigBrainStart).not.toHaveBeenCalled();
|
|
1005
|
-
expect(process.stderr.write).not.toHaveBeenCalledWith(
|
|
1006
|
-
expect.stringContaining("Moving it to project"),
|
|
1007
|
-
);
|
|
1008
|
-
const config = JSON.parse(
|
|
1009
|
-
testFiles.get(path.resolve(".convex/local/default/config.json"))!,
|
|
1010
|
-
);
|
|
1011
|
-
expect(config.cloudProjectId).toBe(42);
|
|
1012
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
1013
|
-
expect(envContent).toContain(
|
|
1014
|
-
"CONVEX_DEPLOYMENT=local:local-my_team-my_project-abc",
|
|
1015
|
-
);
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
it("missing cloudProjectId → writes resolved id back and selects", async () => {
|
|
1019
|
-
testFiles.set(
|
|
1020
|
-
path.resolve(".convex/local/default/config.json"),
|
|
1021
|
-
JSON.stringify({
|
|
1022
|
-
ports: { cloud: 3210, site: 3211 },
|
|
1023
|
-
adminKey: "local-key",
|
|
1024
|
-
backendVersion: "1.0.0",
|
|
1025
|
-
deploymentName: "local-my_team-my_project-abc",
|
|
1026
|
-
}),
|
|
1027
|
-
);
|
|
1028
|
-
setupBigBrainRoutes({
|
|
1029
|
-
"deployment/local-my_team-my_project-abc/team_and_project": () => ({
|
|
1030
|
-
team: "my-team",
|
|
1031
|
-
project: "my-project",
|
|
1032
|
-
teamId: 1,
|
|
1033
|
-
projectId: 42,
|
|
1034
|
-
}),
|
|
1035
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
1036
|
-
team: "my-team",
|
|
1037
|
-
project: "my-project",
|
|
1038
|
-
teamId: 1,
|
|
1039
|
-
projectId: 42,
|
|
1040
|
-
}),
|
|
1041
|
-
});
|
|
1042
|
-
mockPlatformForTargetProject({ projectId: 42 });
|
|
1043
|
-
|
|
1044
|
-
await deploymentSelect.parseAsync([selector], { from: "user" });
|
|
1045
|
-
|
|
1046
|
-
const config = JSON.parse(
|
|
1047
|
-
testFiles.get(path.resolve(".convex/local/default/config.json"))!,
|
|
1048
|
-
);
|
|
1049
|
-
expect(config.cloudProjectId).toBe(42);
|
|
1050
|
-
expect(bigBrainPause).not.toHaveBeenCalled();
|
|
1051
|
-
expect(bigBrainStart).not.toHaveBeenCalled();
|
|
1052
|
-
expect(process.stderr.write).not.toHaveBeenCalledWith(
|
|
1053
|
-
expect.stringContaining("Moving it to project"),
|
|
1054
|
-
);
|
|
1055
|
-
});
|
|
1056
|
-
|
|
1057
|
-
it("mismatching cloudProjectId → warns, pauses old, registers new, rewrites config", async () => {
|
|
1058
|
-
testFiles.set(
|
|
1059
|
-
path.resolve(".convex/local/default/config.json"),
|
|
1060
|
-
JSON.stringify({
|
|
1061
|
-
ports: { cloud: 3210, site: 3211 },
|
|
1062
|
-
adminKey: "admin-key",
|
|
1063
|
-
backendVersion: "1.0.0",
|
|
1064
|
-
deploymentName: "local-old_team-old_project-abc",
|
|
1065
|
-
cloudProjectId: 100,
|
|
1066
|
-
}),
|
|
1067
|
-
);
|
|
1068
|
-
setupBigBrainRoutes({
|
|
1069
|
-
"deployment/local-new_team-new_project-xyz/team_and_project":
|
|
1070
|
-
() => ({
|
|
1071
|
-
team: "my-team",
|
|
1072
|
-
project: "my-project",
|
|
1073
|
-
teamId: 1,
|
|
1074
|
-
projectId: 42,
|
|
1075
|
-
}),
|
|
1076
|
-
"deployment/joyful-capybara-123/team_and_project": () => ({
|
|
1077
|
-
team: "my-team",
|
|
1078
|
-
project: "my-project",
|
|
1079
|
-
teamId: 1,
|
|
1080
|
-
projectId: 42,
|
|
1081
|
-
}),
|
|
1082
|
-
});
|
|
1083
|
-
vi.mocked(bigBrainPause).mockResolvedValue(undefined);
|
|
1084
|
-
vi.mocked(bigBrainStart).mockResolvedValue({
|
|
1085
|
-
deploymentName: "local-new_team-new_project-xyz",
|
|
1086
|
-
adminKey: "admin-key",
|
|
1087
|
-
projectId: 42,
|
|
1088
|
-
});
|
|
1089
|
-
mockPlatformForTargetProject({ projectId: 42 });
|
|
1090
|
-
|
|
1091
|
-
await deploymentSelect.parseAsync([selector], { from: "user" });
|
|
1092
|
-
|
|
1093
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
1094
|
-
expect.stringContaining("Moving it to project"),
|
|
1095
|
-
);
|
|
1096
|
-
expect(bigBrainPause).toHaveBeenCalledWith(expect.anything(), {
|
|
1097
|
-
teamSlug: "old-team",
|
|
1098
|
-
projectSlug: "old-project",
|
|
1099
|
-
});
|
|
1100
|
-
expect(bigBrainStart).toHaveBeenCalledWith(
|
|
1101
|
-
expect.anything(),
|
|
1102
|
-
expect.objectContaining({
|
|
1103
|
-
teamSlug: "my-team",
|
|
1104
|
-
projectSlug: "my-project",
|
|
1105
|
-
}),
|
|
1106
|
-
);
|
|
1107
|
-
const config = JSON.parse(
|
|
1108
|
-
testFiles.get(path.resolve(".convex/local/default/config.json"))!,
|
|
1109
|
-
);
|
|
1110
|
-
expect(config.cloudProjectId).toBe(42);
|
|
1111
|
-
expect(config.deploymentName).toBe("local-new_team-new_project-xyz");
|
|
1112
|
-
});
|
|
1113
|
-
});
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
|
|
1117
|
-
describe("without project configured", () => {
|
|
1118
|
-
beforeEach(() => {
|
|
1119
|
-
delete process.env.CONVEX_DEPLOYMENT;
|
|
1120
|
-
testFiles.set(
|
|
1121
|
-
globalConfigPath(),
|
|
1122
|
-
JSON.stringify({ accessToken: "test-token" }),
|
|
1123
|
-
);
|
|
1124
|
-
});
|
|
1125
|
-
|
|
1126
|
-
it("fails with 'No project configured' for the 'dev' selector", async () => {
|
|
1127
|
-
await expect(
|
|
1128
|
-
deploymentSelect.parseAsync(["dev"], { from: "user" }),
|
|
1129
|
-
).rejects.toThrow();
|
|
1130
|
-
|
|
1131
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
1132
|
-
expect.stringContaining("No project configured"),
|
|
1133
|
-
);
|
|
1134
|
-
});
|
|
1135
|
-
|
|
1136
|
-
it("fails with 'No project configured' for a simple reference selector", async () => {
|
|
1137
|
-
await expect(
|
|
1138
|
-
deploymentSelect.parseAsync(["staging"], { from: "user" }),
|
|
1139
|
-
).rejects.toThrow();
|
|
1140
|
-
|
|
1141
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
1142
|
-
expect.stringContaining("No project configured"),
|
|
1143
|
-
);
|
|
1144
|
-
});
|
|
1145
|
-
|
|
1146
|
-
it("fails with 'No project configured' for a project:reference selector (needs team context)", async () => {
|
|
1147
|
-
await expect(
|
|
1148
|
-
deploymentSelect.parseAsync(["my-project:staging"], { from: "user" }),
|
|
1149
|
-
).rejects.toThrow();
|
|
1150
|
-
|
|
1151
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
1152
|
-
expect.stringContaining("No project configured"),
|
|
1153
|
-
);
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
it("succeeds with a fully-qualified 'team:project:ref' selector", async () => {
|
|
1157
|
-
setupBigBrainRoutes({
|
|
1158
|
-
"deployment/authorize_within_current_project": () => ({
|
|
1159
|
-
adminKey: "fq-key",
|
|
1160
|
-
url: "https://fully-qualified-123.convex.cloud",
|
|
1161
|
-
deploymentName: "fully-qualified-123",
|
|
1162
|
-
deploymentType: "dev",
|
|
1163
|
-
}),
|
|
1164
|
-
"teams/my-team/projects/my-project/deployments": () => true,
|
|
1165
|
-
});
|
|
1166
|
-
mockPlatformGet.mockResolvedValue({
|
|
1167
|
-
data: { name: "fully-qualified-123" },
|
|
1168
|
-
error: undefined,
|
|
1169
|
-
});
|
|
1170
|
-
|
|
1171
|
-
await deploymentSelect.parseAsync(["my-team:my-project:staging"], {
|
|
1172
|
-
from: "user",
|
|
1173
|
-
});
|
|
1174
|
-
|
|
1175
|
-
expect(mockPlatformGet).toHaveBeenCalledWith(
|
|
1176
|
-
"/teams/{team_id_or_slug}/projects/{project_slug}/deployment",
|
|
1177
|
-
expect.objectContaining({
|
|
1178
|
-
params: expect.objectContaining({
|
|
1179
|
-
path: { team_id_or_slug: "my-team", project_slug: "my-project" },
|
|
1180
|
-
query: { reference: "staging" },
|
|
1181
|
-
}),
|
|
1182
|
-
}),
|
|
1183
|
-
);
|
|
1184
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
1185
|
-
expect(envContent).toContain("CONVEX_DEPLOYMENT=dev:fully-qualified-123");
|
|
1186
|
-
});
|
|
1187
|
-
|
|
1188
|
-
it("succeeds with a deployment name directly (does not need project context)", async () => {
|
|
1189
|
-
// Deployment names (abc-xyz-123 pattern) don't require a project to
|
|
1190
|
-
// already be configured — they look up their own team/project info.
|
|
1191
|
-
setupBigBrainRoutes({
|
|
1192
|
-
"deployment/clever-otter-890/team_and_project": () => ({
|
|
1193
|
-
team: "my-team",
|
|
1194
|
-
project: "my-project",
|
|
1195
|
-
teamId: 1,
|
|
1196
|
-
projectId: 1,
|
|
1197
|
-
}),
|
|
1198
|
-
"deployment/authorize_within_current_project": () => ({
|
|
1199
|
-
adminKey: "dev-key",
|
|
1200
|
-
url: "https://clever-otter-890.convex.cloud",
|
|
1201
|
-
deploymentName: "clever-otter-890",
|
|
1202
|
-
deploymentType: "dev",
|
|
1203
|
-
}),
|
|
1204
|
-
});
|
|
1205
|
-
|
|
1206
|
-
await deploymentSelect.parseAsync(["clever-otter-890"], { from: "user" });
|
|
1207
|
-
|
|
1208
|
-
// deploymentNameFromSelection(currentSelection) returns null when there
|
|
1209
|
-
// is no CONVEX_DEPLOYMENT configured (kind === "chooseProject"), meaning
|
|
1210
|
-
// configure treats this as a brand-new selection.
|
|
1211
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
1212
|
-
expect(envContent).toContain("CONVEX_DEPLOYMENT=dev:clever-otter-890");
|
|
1213
|
-
});
|
|
1214
|
-
|
|
1215
|
-
it("fails with 'No project configured' for 'local' when no local deployment exists yet", async () => {
|
|
1216
|
-
// No `.convex/local/default/config.json` exists, so we'd normally prompt
|
|
1217
|
-
// "Create one now?". But since creating a local deployment requires a
|
|
1218
|
-
// project, we should fail up-front instead.
|
|
1219
|
-
await expect(
|
|
1220
|
-
deploymentSelect.parseAsync(["local"], { from: "user" }),
|
|
1221
|
-
).rejects.toThrow();
|
|
1222
|
-
|
|
1223
|
-
expect(process.stderr.write).toHaveBeenCalledWith(
|
|
1224
|
-
expect.stringContaining("No project configured"),
|
|
1225
|
-
);
|
|
1226
|
-
expect(process.stderr.write).not.toHaveBeenCalledWith(
|
|
1227
|
-
expect.stringContaining("Create one now?"),
|
|
1228
|
-
);
|
|
1229
|
-
expect(mockCreateLocalDeployment).not.toHaveBeenCalled();
|
|
1230
|
-
});
|
|
1231
|
-
|
|
1232
|
-
it("creates a local deployment for 'team:project:local' even when no project is configured", async () => {
|
|
1233
|
-
// No CONVEX_DEPLOYMENT set (chooseProject) and no on-disk local config,
|
|
1234
|
-
// but the selector itself carries team/project context, so we should
|
|
1235
|
-
// proceed to create one rather than crashing with "No project configured".
|
|
1236
|
-
mockCreateLocalDeployment.mockResolvedValue(undefined);
|
|
1237
|
-
|
|
1238
|
-
const promise = deploymentSelect.parseAsync(
|
|
1239
|
-
["my-team:my-project:local"],
|
|
1240
|
-
{ from: "user" },
|
|
1241
|
-
);
|
|
1242
|
-
|
|
1243
|
-
await screen.next();
|
|
1244
|
-
expect(screen.getScreen()).toContain(
|
|
1245
|
-
"No local deployment found. Create one now?",
|
|
1246
|
-
);
|
|
1247
|
-
screen.keypress("y");
|
|
1248
|
-
screen.keypress("enter");
|
|
1249
|
-
|
|
1250
|
-
await promise;
|
|
1251
|
-
|
|
1252
|
-
expect(mockCreateLocalDeployment).toHaveBeenCalledWith(
|
|
1253
|
-
expect.anything(),
|
|
1254
|
-
expect.anything(),
|
|
1255
|
-
true,
|
|
1256
|
-
{ teamSlug: "my-team", projectSlug: "my-project" },
|
|
1257
|
-
);
|
|
1258
|
-
expect(process.stderr.write).not.toHaveBeenCalledWith(
|
|
1259
|
-
expect.stringContaining("No project configured"),
|
|
1260
|
-
);
|
|
1261
|
-
});
|
|
1262
|
-
|
|
1263
|
-
it("selects local deployment without project configured", async () => {
|
|
1264
|
-
testFiles.set(
|
|
1265
|
-
path.resolve(".convex/local/default/config.json"),
|
|
1266
|
-
JSON.stringify({
|
|
1267
|
-
ports: { cloud: 3210, site: 3211 },
|
|
1268
|
-
adminKey: "local-key",
|
|
1269
|
-
backendVersion: "1.0.0",
|
|
1270
|
-
deploymentName: "local-my_team-my_project-abc",
|
|
1271
|
-
cloudProjectId: 1,
|
|
1272
|
-
}),
|
|
1273
|
-
);
|
|
1274
|
-
setupBigBrainRoutes({
|
|
1275
|
-
"deployment/local-my_team-my_project-abc/team_and_project": () => ({
|
|
1276
|
-
team: "my-team",
|
|
1277
|
-
project: "my-project",
|
|
1278
|
-
teamId: 1,
|
|
1279
|
-
projectId: 1,
|
|
1280
|
-
}),
|
|
1281
|
-
});
|
|
1282
|
-
|
|
1283
|
-
await deploymentSelect.parseAsync(["local"], { from: "user" });
|
|
1284
|
-
|
|
1285
|
-
const envContent = testFiles.get(path.resolve(".env.local"))!;
|
|
1286
|
-
expect(envContent).toContain(
|
|
1287
|
-
"CONVEX_DEPLOYMENT=local:local-my_team-my_project-abc",
|
|
1288
|
-
);
|
|
1289
|
-
});
|
|
1290
|
-
});
|
|
1291
|
-
});
|