convex 1.31.4 → 1.31.6-alpha.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.
Files changed (179) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/browser.bundle.js +1 -1
  3. package/dist/browser.bundle.js.map +1 -1
  4. package/dist/cjs/bundler/debugBundle.js +1 -1
  5. package/dist/cjs/bundler/debugBundle.js.map +1 -1
  6. package/dist/cjs/bundler/index.js +1 -1
  7. package/dist/cjs/bundler/index.js.map +1 -1
  8. package/dist/cjs/cli/configure.js +2 -10
  9. package/dist/cjs/cli/configure.js.map +2 -2
  10. package/dist/cjs/cli/deploy.js +16 -2
  11. package/dist/cjs/cli/deploy.js.map +2 -2
  12. package/dist/cjs/cli/dev.js +4 -1
  13. package/dist/cjs/cli/dev.js.map +2 -2
  14. package/dist/cjs/cli/generatedApi.js.map +1 -1
  15. package/dist/cjs/cli/integration.js +198 -10
  16. package/dist/cjs/cli/integration.js.map +2 -2
  17. package/dist/cjs/cli/lib/command.js +9 -4
  18. package/dist/cjs/cli/lib/command.js.map +2 -2
  19. package/dist/cjs/cli/lib/components/definition/bundle.js +1 -1
  20. package/dist/cjs/cli/lib/components/definition/bundle.js.map +1 -1
  21. package/dist/cjs/cli/lib/components.js +2 -1
  22. package/dist/cjs/cli/lib/components.js.map +2 -2
  23. package/dist/cjs/cli/lib/config.js +87 -212
  24. package/dist/cjs/cli/lib/config.js.map +3 -3
  25. package/dist/cjs/cli/lib/deploy2.js +27 -4
  26. package/dist/cjs/cli/lib/deploy2.js.map +2 -2
  27. package/dist/cjs/cli/lib/deploymentSelection.js +0 -12
  28. package/dist/cjs/cli/lib/deploymentSelection.js.map +2 -2
  29. package/dist/cjs/cli/lib/dev.js +30 -0
  30. package/dist/cjs/cli/lib/dev.js.map +2 -2
  31. package/dist/cjs/cli/lib/mcp/tools/index.js.map +2 -2
  32. package/dist/cjs/cli/lib/utils/prompts.js +1 -1
  33. package/dist/cjs/cli/lib/utils/prompts.js.map +2 -2
  34. package/dist/cjs/cli/lib/workos/environmentApi.js +27 -1
  35. package/dist/cjs/cli/lib/workos/environmentApi.js.map +2 -2
  36. package/dist/cjs/cli/lib/workos/platformApi.js +41 -7
  37. package/dist/cjs/cli/lib/workos/platformApi.js.map +2 -2
  38. package/dist/cjs/cli/lib/workos/workos.js +532 -93
  39. package/dist/cjs/cli/lib/workos/workos.js.map +2 -2
  40. package/dist/cjs/index.js +1 -1
  41. package/dist/cjs/index.js.map +1 -1
  42. package/dist/cjs-types/bundler/debugBundle.d.ts.map +1 -1
  43. package/dist/cjs-types/bundler/index.d.ts.map +1 -1
  44. package/dist/cjs-types/cli/configure.d.ts.map +1 -1
  45. package/dist/cjs-types/cli/deploy.d.ts.map +1 -1
  46. package/dist/cjs-types/cli/dev.d.ts.map +1 -1
  47. package/dist/cjs-types/cli/generatedApi.d.ts +260 -1
  48. package/dist/cjs-types/cli/generatedApi.d.ts.map +1 -1
  49. package/dist/cjs-types/cli/integration.d.ts.map +1 -1
  50. package/dist/cjs-types/cli/lib/command.d.ts +7 -1
  51. package/dist/cjs-types/cli/lib/command.d.ts.map +1 -1
  52. package/dist/cjs-types/cli/lib/components/definition/bundle.d.ts.map +1 -1
  53. package/dist/cjs-types/cli/lib/components.d.ts +2 -0
  54. package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
  55. package/dist/cjs-types/cli/lib/config.d.ts +38 -26
  56. package/dist/cjs-types/cli/lib/config.d.ts.map +1 -1
  57. package/dist/cjs-types/cli/lib/deploy2.d.ts +5 -0
  58. package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
  59. package/dist/cjs-types/cli/lib/deployment.d.ts +1 -1
  60. package/dist/cjs-types/cli/lib/deploymentSelection.d.ts.map +1 -1
  61. package/dist/cjs-types/cli/lib/dev.d.ts +2 -0
  62. package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
  63. package/dist/cjs-types/cli/lib/mcp/tools/index.d.ts.map +1 -1
  64. package/dist/cjs-types/cli/lib/utils/prompts.d.ts +1 -0
  65. package/dist/cjs-types/cli/lib/utils/prompts.d.ts.map +1 -1
  66. package/dist/cjs-types/cli/lib/workos/environmentApi.d.ts +4 -0
  67. package/dist/cjs-types/cli/lib/workos/environmentApi.d.ts.map +1 -1
  68. package/dist/cjs-types/cli/lib/workos/platformApi.d.ts +9 -1
  69. package/dist/cjs-types/cli/lib/workos/platformApi.d.ts.map +1 -1
  70. package/dist/cjs-types/cli/lib/workos/workos.d.ts +39 -8
  71. package/dist/cjs-types/cli/lib/workos/workos.d.ts.map +1 -1
  72. package/dist/cjs-types/cli/lib/workos/workos.test.d.ts +2 -0
  73. package/dist/cjs-types/cli/lib/workos/workos.test.d.ts.map +1 -0
  74. package/dist/cjs-types/cli/network_test.d.ts +1 -0
  75. package/dist/cjs-types/cli/network_test.d.ts.map +1 -1
  76. package/dist/cjs-types/index.d.ts +1 -1
  77. package/dist/cjs-types/index.d.ts.map +1 -1
  78. package/dist/cli.bundle.cjs +3337 -5468
  79. package/dist/cli.bundle.cjs.map +4 -4
  80. package/dist/esm/bundler/debugBundle.js +1 -1
  81. package/dist/esm/bundler/debugBundle.js.map +1 -1
  82. package/dist/esm/bundler/index.js +1 -1
  83. package/dist/esm/bundler/index.js.map +1 -1
  84. package/dist/esm/cli/configure.js +3 -16
  85. package/dist/esm/cli/configure.js.map +2 -2
  86. package/dist/esm/cli/deploy.js +16 -2
  87. package/dist/esm/cli/deploy.js.map +2 -2
  88. package/dist/esm/cli/dev.js +4 -1
  89. package/dist/esm/cli/dev.js.map +2 -2
  90. package/dist/esm/cli/integration.js +209 -12
  91. package/dist/esm/cli/integration.js.map +2 -2
  92. package/dist/esm/cli/lib/command.js +9 -4
  93. package/dist/esm/cli/lib/command.js.map +2 -2
  94. package/dist/esm/cli/lib/components/definition/bundle.js +1 -1
  95. package/dist/esm/cli/lib/components/definition/bundle.js.map +1 -1
  96. package/dist/esm/cli/lib/components.js +2 -1
  97. package/dist/esm/cli/lib/components.js.map +2 -2
  98. package/dist/esm/cli/lib/config.js +86 -210
  99. package/dist/esm/cli/lib/config.js.map +3 -3
  100. package/dist/esm/cli/lib/deploy2.js +32 -5
  101. package/dist/esm/cli/lib/deploy2.js.map +2 -2
  102. package/dist/esm/cli/lib/deploymentSelection.js +0 -12
  103. package/dist/esm/cli/lib/deploymentSelection.js.map +2 -2
  104. package/dist/esm/cli/lib/dev.js +33 -0
  105. package/dist/esm/cli/lib/dev.js.map +2 -2
  106. package/dist/esm/cli/lib/mcp/tools/index.js.map +2 -2
  107. package/dist/esm/cli/lib/utils/prompts.js +1 -1
  108. package/dist/esm/cli/lib/utils/prompts.js.map +2 -2
  109. package/dist/esm/cli/lib/workos/environmentApi.js +25 -0
  110. package/dist/esm/cli/lib/workos/environmentApi.js.map +2 -2
  111. package/dist/esm/cli/lib/workos/platformApi.js +36 -6
  112. package/dist/esm/cli/lib/workos/platformApi.js.map +2 -2
  113. package/dist/esm/cli/lib/workos/workos.js +535 -94
  114. package/dist/esm/cli/lib/workos/workos.js.map +2 -2
  115. package/dist/esm/index.js +1 -1
  116. package/dist/esm/index.js.map +1 -1
  117. package/dist/esm-types/bundler/debugBundle.d.ts.map +1 -1
  118. package/dist/esm-types/bundler/index.d.ts.map +1 -1
  119. package/dist/esm-types/cli/configure.d.ts.map +1 -1
  120. package/dist/esm-types/cli/deploy.d.ts.map +1 -1
  121. package/dist/esm-types/cli/dev.d.ts.map +1 -1
  122. package/dist/esm-types/cli/generatedApi.d.ts +260 -1
  123. package/dist/esm-types/cli/generatedApi.d.ts.map +1 -1
  124. package/dist/esm-types/cli/integration.d.ts.map +1 -1
  125. package/dist/esm-types/cli/lib/command.d.ts +7 -1
  126. package/dist/esm-types/cli/lib/command.d.ts.map +1 -1
  127. package/dist/esm-types/cli/lib/components/definition/bundle.d.ts.map +1 -1
  128. package/dist/esm-types/cli/lib/components.d.ts +2 -0
  129. package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
  130. package/dist/esm-types/cli/lib/config.d.ts +38 -26
  131. package/dist/esm-types/cli/lib/config.d.ts.map +1 -1
  132. package/dist/esm-types/cli/lib/deploy2.d.ts +5 -0
  133. package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
  134. package/dist/esm-types/cli/lib/deployment.d.ts +1 -1
  135. package/dist/esm-types/cli/lib/deploymentSelection.d.ts.map +1 -1
  136. package/dist/esm-types/cli/lib/dev.d.ts +2 -0
  137. package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
  138. package/dist/esm-types/cli/lib/mcp/tools/index.d.ts.map +1 -1
  139. package/dist/esm-types/cli/lib/utils/prompts.d.ts +1 -0
  140. package/dist/esm-types/cli/lib/utils/prompts.d.ts.map +1 -1
  141. package/dist/esm-types/cli/lib/workos/environmentApi.d.ts +4 -0
  142. package/dist/esm-types/cli/lib/workos/environmentApi.d.ts.map +1 -1
  143. package/dist/esm-types/cli/lib/workos/platformApi.d.ts +9 -1
  144. package/dist/esm-types/cli/lib/workos/platformApi.d.ts.map +1 -1
  145. package/dist/esm-types/cli/lib/workos/workos.d.ts +39 -8
  146. package/dist/esm-types/cli/lib/workos/workos.d.ts.map +1 -1
  147. package/dist/esm-types/cli/lib/workos/workos.test.d.ts +2 -0
  148. package/dist/esm-types/cli/lib/workos/workos.test.d.ts.map +1 -0
  149. package/dist/esm-types/cli/network_test.d.ts +1 -0
  150. package/dist/esm-types/cli/network_test.d.ts.map +1 -1
  151. package/dist/esm-types/index.d.ts +1 -1
  152. package/dist/esm-types/index.d.ts.map +1 -1
  153. package/dist/react.bundle.js +1 -1
  154. package/dist/react.bundle.js.map +1 -1
  155. package/package.json +5 -5
  156. package/schemas/convex.schema.json +2 -1
  157. package/src/bundler/debugBundle.ts +1 -1
  158. package/src/bundler/index.ts +1 -1
  159. package/src/cli/configure.ts +3 -18
  160. package/src/cli/deploy.ts +23 -1
  161. package/src/cli/dev.ts +6 -0
  162. package/src/cli/generatedApi.ts +260 -1
  163. package/src/cli/integration.ts +289 -15
  164. package/src/cli/lib/command.ts +19 -6
  165. package/src/cli/lib/components/definition/bundle.ts +1 -1
  166. package/src/cli/lib/components.ts +7 -1
  167. package/src/cli/lib/config.test.ts +444 -547
  168. package/src/cli/lib/config.ts +166 -309
  169. package/src/cli/lib/deploy2.ts +47 -4
  170. package/src/cli/lib/deploymentSelection.ts +0 -14
  171. package/src/cli/lib/dev.ts +58 -0
  172. package/src/cli/lib/mcp/tools/index.ts +1 -2
  173. package/src/cli/lib/utils/prompts.ts +4 -1
  174. package/src/cli/lib/workos/environmentApi.ts +38 -0
  175. package/src/cli/lib/workos/platformApi.ts +69 -6
  176. package/src/cli/lib/workos/workos.test.ts +242 -0
  177. package/src/cli/lib/workos/workos.ts +807 -134
  178. package/src/cli/network_test.ts +1 -1
  179. package/src/index.ts +1 -1
@@ -47,7 +47,7 @@ async function innerEsbuild({
47
47
  plugins,
48
48
  chunksFolder,
49
49
  logLevel,
50
- includeSourcesContent = true
50
+ includeSourcesContent = false
51
51
  }) {
52
52
  const result = await import_esbuild.default.build({
53
53
  entryPoints,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/bundler/debugBundle.ts"],
4
- "sourcesContent": ["import path from \"path\";\nimport esbuild, { BuildFailure, LogLevel, Plugin } from \"esbuild\";\nimport { Context } from \"./context.js\";\nimport {\n logError,\n changeSpinner,\n logFailure,\n logVerbose,\n logMessage,\n} from \"./log.js\";\nimport { wasmPlugin } from \"./wasm.js\";\nimport dependencyTrackerPlugin from \"./depgraph.js\";\n\nexport async function innerEsbuild({\n entryPoints,\n platform,\n dir,\n extraConditions,\n generateSourceMaps,\n plugins,\n chunksFolder,\n logLevel,\n includeSourcesContent = true,\n}: {\n entryPoints: string[];\n platform: esbuild.Platform;\n dir: string;\n extraConditions: string[];\n generateSourceMaps: boolean;\n plugins: Plugin[];\n chunksFolder: string;\n logLevel?: LogLevel;\n includeSourcesContent?: boolean;\n}) {\n const result = await esbuild.build({\n entryPoints,\n bundle: true,\n platform: platform,\n format: \"esm\",\n target: \"esnext\",\n jsx: \"automatic\",\n outdir: \"out\",\n outbase: dir,\n conditions: [\"convex\", \"module\", ...extraConditions],\n plugins,\n write: false,\n sourcemap: generateSourceMaps,\n sourcesContent: includeSourcesContent,\n splitting: true,\n chunkNames: path.join(chunksFolder, \"[hash]\"),\n treeShaking: true,\n minifySyntax: true,\n minifyIdentifiers: true,\n // Enabling minifyWhitespace breaks sourcemaps on convex backends.\n // The sourcemaps produced are valid on https://evanw.github.io/source-map-visualization\n // but something we're doing (perhaps involving https://github.com/getsentry/rust-sourcemap)\n // makes everything map to the same line.\n minifyWhitespace: false, // false is the default, just showing for clarify.\n keepNames: true,\n define: {\n \"process.env.NODE_ENV\": '\"production\"',\n },\n metafile: true,\n logLevel: logLevel || \"warning\",\n });\n return result;\n}\n\nexport function isEsbuildBuildError(e: any): e is BuildFailure {\n return (\n \"errors\" in e &&\n \"warnings\" in e &&\n Array.isArray(e.errors) &&\n Array.isArray(e.warnings)\n );\n}\n\n/**\n * Bundle non-\"use node\" entry points one at a time to track down the first file with an error\n * is being imported.\n */\nexport async function debugIsolateBundlesSerially(\n ctx: Context,\n {\n entryPoints,\n extraConditions,\n dir,\n }: {\n entryPoints: string[];\n extraConditions: string[];\n dir: string;\n },\n): Promise<void> {\n logMessage(\n `Bundling convex entry points one at a time to track down things that can't be bundled for the Convex JS runtime.`,\n );\n let i = 1;\n for (const entryPoint of entryPoints) {\n changeSpinner(\n `bundling entry point ${entryPoint} (${i++}/${entryPoints.length})...`,\n );\n\n const { plugin, tracer } = dependencyTrackerPlugin();\n try {\n await innerEsbuild({\n entryPoints: [entryPoint],\n platform: \"browser\",\n generateSourceMaps: true,\n chunksFolder: \"_deps\",\n extraConditions,\n dir,\n plugins: [plugin, wasmPlugin],\n logLevel: \"silent\",\n });\n } catch (error) {\n if (!isEsbuildBuildError(error) || !error.errors[0]) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: null,\n });\n }\n\n const buildError = error.errors[0];\n const errorFile = buildError.location?.file;\n if (!errorFile) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: null,\n });\n }\n\n const importedPath = buildError.text.match(/\"([^\"]+)\"/)?.[1];\n if (!importedPath) continue;\n\n const full = path.resolve(errorFile);\n logError(\"\");\n logError(\n `Bundling ${entryPoint} resulted in ${error.errors.length} esbuild errors.`,\n );\n logError(`One of the bundling errors occurred while bundling ${full}:\\n`);\n logError(\n esbuild\n .formatMessagesSync([buildError], {\n kind: \"error\",\n color: true,\n })\n .join(\"\\n\"),\n );\n logError(\"It would help to avoid importing this file.\");\n const chains = tracer.traceImportChains(entryPoint, full);\n const chain: string[] = chains[0];\n chain.reverse();\n\n logError(``);\n if (chain.length > 0) {\n const problematicFileRelative = formatFilePath(dir, chain[0]);\n\n if (chain.length === 1) {\n logError(` ${problematicFileRelative}`);\n } else {\n logError(` ${problematicFileRelative} is imported by`);\n\n for (let i = 1; i < chain.length - 1; i++) {\n const fileRelative = formatFilePath(dir, chain[i]);\n logError(` ${fileRelative}, which is imported by`);\n }\n\n const entryPointFile = chain[chain.length - 1];\n const entryPointRelative = formatFilePath(dir, entryPointFile);\n\n logError(` ${entryPointRelative}, which doesn't use \"use node\"\\n`);\n logError(\n ` For registered action functions to use Node.js APIs in any code they run they must be defined\\n` +\n ` in a file with 'use node' at the top. See https://docs.convex.dev/functions/runtimes#nodejs-runtime\\n`,\n );\n }\n }\n\n logFailure(\"Bundling failed\");\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: \"Bundling failed.\",\n });\n }\n logVerbose(`${entryPoint} bundled`);\n }\n}\n\n// Helper function to format file paths consistently\nfunction formatFilePath(baseDir: string, filePath: string): string {\n // If it's already a relative path like \"./shared\", just return it\n if (!path.isAbsolute(filePath)) {\n // For relative paths, ensure they start with \"convex/\"\n if (!filePath.startsWith(\"convex/\")) {\n // If it's a path like \"./subdir/file.ts\" or \"subdir/file.ts\"\n const cleanPath = filePath.replace(/^\\.\\//, \"\");\n return `convex/${cleanPath}`;\n }\n return filePath;\n }\n\n // Get the path relative to the base directory\n const relativePath = path.relative(baseDir, filePath);\n\n // Remove any leading \"./\" that path.relative might add\n const cleanPath = relativePath.replace(/^\\.\\//, \"\");\n\n // Check if this is a path within the convex directory\n const isConvexPath =\n cleanPath.startsWith(\"convex/\") ||\n cleanPath.includes(\"/convex/\") ||\n path.dirname(cleanPath) === \"convex\";\n\n if (isConvexPath) {\n // If it already starts with convex/, return it as is\n if (cleanPath.startsWith(\"convex/\")) {\n return cleanPath;\n }\n\n // For files in the convex directory\n if (path.dirname(cleanPath) === \"convex\") {\n const filename = path.basename(cleanPath);\n return `convex/${filename}`;\n }\n\n // For files in subdirectories of convex\n const convexIndex = cleanPath.indexOf(\"convex/\");\n if (convexIndex >= 0) {\n return cleanPath.substring(convexIndex);\n }\n }\n\n // For any other path, assume it's in the convex directory\n // This handles cases where the file is in a subdirectory of convex\n // but the path doesn't include \"convex/\" explicitly\n return `convex/${cleanPath}`;\n}\n"],
4
+ "sourcesContent": ["import path from \"path\";\nimport esbuild, { BuildFailure, LogLevel, Plugin } from \"esbuild\";\nimport { Context } from \"./context.js\";\nimport {\n logError,\n changeSpinner,\n logFailure,\n logVerbose,\n logMessage,\n} from \"./log.js\";\nimport { wasmPlugin } from \"./wasm.js\";\nimport dependencyTrackerPlugin from \"./depgraph.js\";\n\nexport async function innerEsbuild({\n entryPoints,\n platform,\n dir,\n extraConditions,\n generateSourceMaps,\n plugins,\n chunksFolder,\n logLevel,\n includeSourcesContent = false,\n}: {\n entryPoints: string[];\n platform: esbuild.Platform;\n dir: string;\n extraConditions: string[];\n generateSourceMaps: boolean;\n plugins: Plugin[];\n chunksFolder: string;\n logLevel?: LogLevel;\n includeSourcesContent?: boolean;\n}) {\n const result = await esbuild.build({\n entryPoints,\n bundle: true,\n platform: platform,\n format: \"esm\",\n target: \"esnext\",\n jsx: \"automatic\",\n outdir: \"out\",\n outbase: dir,\n conditions: [\"convex\", \"module\", ...extraConditions],\n plugins,\n write: false,\n sourcemap: generateSourceMaps,\n sourcesContent: includeSourcesContent,\n splitting: true,\n chunkNames: path.join(chunksFolder, \"[hash]\"),\n treeShaking: true,\n minifySyntax: true,\n minifyIdentifiers: true,\n // Enabling minifyWhitespace breaks sourcemaps on convex backends.\n // The sourcemaps produced are valid on https://evanw.github.io/source-map-visualization\n // but something we're doing (perhaps involving https://github.com/getsentry/rust-sourcemap)\n // makes everything map to the same line.\n minifyWhitespace: false, // false is the default, just showing for clarify.\n keepNames: true,\n define: {\n \"process.env.NODE_ENV\": '\"production\"',\n },\n metafile: true,\n logLevel: logLevel || \"warning\",\n });\n return result;\n}\n\nexport function isEsbuildBuildError(e: any): e is BuildFailure {\n return (\n \"errors\" in e &&\n \"warnings\" in e &&\n Array.isArray(e.errors) &&\n Array.isArray(e.warnings)\n );\n}\n\n/**\n * Bundle non-\"use node\" entry points one at a time to track down the first file with an error\n * is being imported.\n */\nexport async function debugIsolateBundlesSerially(\n ctx: Context,\n {\n entryPoints,\n extraConditions,\n dir,\n }: {\n entryPoints: string[];\n extraConditions: string[];\n dir: string;\n },\n): Promise<void> {\n logMessage(\n `Bundling convex entry points one at a time to track down things that can't be bundled for the Convex JS runtime.`,\n );\n let i = 1;\n for (const entryPoint of entryPoints) {\n changeSpinner(\n `bundling entry point ${entryPoint} (${i++}/${entryPoints.length})...`,\n );\n\n const { plugin, tracer } = dependencyTrackerPlugin();\n try {\n await innerEsbuild({\n entryPoints: [entryPoint],\n platform: \"browser\",\n generateSourceMaps: true,\n chunksFolder: \"_deps\",\n extraConditions,\n dir,\n plugins: [plugin, wasmPlugin],\n logLevel: \"silent\",\n });\n } catch (error) {\n if (!isEsbuildBuildError(error) || !error.errors[0]) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: null,\n });\n }\n\n const buildError = error.errors[0];\n const errorFile = buildError.location?.file;\n if (!errorFile) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: null,\n });\n }\n\n const importedPath = buildError.text.match(/\"([^\"]+)\"/)?.[1];\n if (!importedPath) continue;\n\n const full = path.resolve(errorFile);\n logError(\"\");\n logError(\n `Bundling ${entryPoint} resulted in ${error.errors.length} esbuild errors.`,\n );\n logError(`One of the bundling errors occurred while bundling ${full}:\\n`);\n logError(\n esbuild\n .formatMessagesSync([buildError], {\n kind: \"error\",\n color: true,\n })\n .join(\"\\n\"),\n );\n logError(\"It would help to avoid importing this file.\");\n const chains = tracer.traceImportChains(entryPoint, full);\n const chain: string[] = chains[0];\n chain.reverse();\n\n logError(``);\n if (chain.length > 0) {\n const problematicFileRelative = formatFilePath(dir, chain[0]);\n\n if (chain.length === 1) {\n logError(` ${problematicFileRelative}`);\n } else {\n logError(` ${problematicFileRelative} is imported by`);\n\n for (let i = 1; i < chain.length - 1; i++) {\n const fileRelative = formatFilePath(dir, chain[i]);\n logError(` ${fileRelative}, which is imported by`);\n }\n\n const entryPointFile = chain[chain.length - 1];\n const entryPointRelative = formatFilePath(dir, entryPointFile);\n\n logError(` ${entryPointRelative}, which doesn't use \"use node\"\\n`);\n logError(\n ` For registered action functions to use Node.js APIs in any code they run they must be defined\\n` +\n ` in a file with 'use node' at the top. See https://docs.convex.dev/functions/runtimes#nodejs-runtime\\n`,\n );\n }\n }\n\n logFailure(\"Bundling failed\");\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: \"Bundling failed.\",\n });\n }\n logVerbose(`${entryPoint} bundled`);\n }\n}\n\n// Helper function to format file paths consistently\nfunction formatFilePath(baseDir: string, filePath: string): string {\n // If it's already a relative path like \"./shared\", just return it\n if (!path.isAbsolute(filePath)) {\n // For relative paths, ensure they start with \"convex/\"\n if (!filePath.startsWith(\"convex/\")) {\n // If it's a path like \"./subdir/file.ts\" or \"subdir/file.ts\"\n const cleanPath = filePath.replace(/^\\.\\//, \"\");\n return `convex/${cleanPath}`;\n }\n return filePath;\n }\n\n // Get the path relative to the base directory\n const relativePath = path.relative(baseDir, filePath);\n\n // Remove any leading \"./\" that path.relative might add\n const cleanPath = relativePath.replace(/^\\.\\//, \"\");\n\n // Check if this is a path within the convex directory\n const isConvexPath =\n cleanPath.startsWith(\"convex/\") ||\n cleanPath.includes(\"/convex/\") ||\n path.dirname(cleanPath) === \"convex\";\n\n if (isConvexPath) {\n // If it already starts with convex/, return it as is\n if (cleanPath.startsWith(\"convex/\")) {\n return cleanPath;\n }\n\n // For files in the convex directory\n if (path.dirname(cleanPath) === \"convex\") {\n const filename = path.basename(cleanPath);\n return `convex/${filename}`;\n }\n\n // For files in subdirectories of convex\n const convexIndex = cleanPath.indexOf(\"convex/\");\n if (convexIndex >= 0) {\n return cleanPath.substring(convexIndex);\n }\n }\n\n // For any other path, assume it's in the convex directory\n // This handles cases where the file is in a subdirectory of convex\n // but the path doesn't include \"convex/\" explicitly\n return `convex/${cleanPath}`;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAAwD;AAExD,iBAMO;AACP,kBAA2B;AAC3B,sBAAoC;AAEpC,eAAsB,aAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAC1B,GAUG;AACD,QAAM,SAAS,MAAM,eAAAA,QAAQ,MAAM;AAAA,IACjC;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY,CAAC,UAAU,UAAU,GAAG,eAAe;AAAA,IACnD;AAAA,IACA,OAAO;AAAA,IACP,WAAW;AAAA,IACX,gBAA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,QACV,WAAW;AAAA,QACX,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH;AACA,+BAAW,GAAG,UAAU,UAAU;AAAA,EACpC;AACF;AAGA,SAAS,eAAe,SAAiB,UAA0B;AAEjE,MAAI,CAAC,YAAAF,QAAK,WAAW,QAAQ,GAAG;AAE9B,QAAI,CAAC,SAAS,WAAW,SAAS,GAAG;AAEnC,YAAMG,aAAY,SAAS,QAAQ,SAAS,EAAE;AAC9C,aAAO,UAAUA,UAAS;AAAA,IAC5B;AACA,WAAO;AAAA,EACT;AAGA,QAAM,eAAe,YAAAH,QAAK,SAAS,SAAS,QAAQ;AAGpD,QAAM,YAAY,aAAa,QAAQ,SAAS,EAAE;AAGlD,QAAM,eACJ,UAAU,WAAW,SAAS,KAC9B,UAAU,SAAS,UAAU,KAC7B,YAAAA,QAAK,QAAQ,SAAS,MAAM;AAE9B,MAAI,cAAc;AAEhB,QAAI,UAAU,WAAW,SAAS,GAAG;AACnC,aAAO;AAAA,IACT;AAGA,QAAI,YAAAA,QAAK,QAAQ,SAAS,MAAM,UAAU;AACxC,YAAM,WAAW,YAAAA,QAAK,SAAS,SAAS;AACxC,aAAO,UAAU,QAAQ;AAAA,IAC3B;AAGA,UAAM,cAAc,UAAU,QAAQ,SAAS;AAC/C,QAAI,eAAe,GAAG;AACpB,aAAO,UAAU,UAAU,WAAW;AAAA,IACxC;AAAA,EACF;AAKA,SAAO,UAAU,SAAS;AAC5B;",
6
6
  "names": ["esbuild", "path", "dependencyTrackerPlugin", "i", "cleanPath"]
7
7
  }
@@ -143,7 +143,7 @@ async function bundle({
143
143
  chunksFolder = "_deps",
144
144
  externalPackagesAllowList = [],
145
145
  extraConditions = [],
146
- includeSourcesContent = true
146
+ includeSourcesContent = false
147
147
  }) {
148
148
  const availableExternalPackages = await (0, import_external.computeExternalPackages)(
149
149
  ctx,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/bundler/index.ts"],
4
- "sourcesContent": ["import path from \"path\";\nimport { chalkStderr } from \"chalk\";\nimport esbuild from \"esbuild\";\nimport { parse as parseAST } from \"@babel/parser\";\nimport { Identifier, ImportSpecifier } from \"@babel/types\";\nimport * as Sentry from \"@sentry/node\";\nimport { Filesystem, consistentPathSort } from \"./fs.js\";\nimport { Context } from \"./context.js\";\nimport { logVerbose, logWarning } from \"./log.js\";\nimport { wasmPlugin } from \"./wasm.js\";\nimport {\n ExternalPackage,\n computeExternalPackages,\n createExternalPlugin,\n findExactVersionAndDependencies,\n} from \"./external.js\";\nimport { innerEsbuild, isEsbuildBuildError } from \"./debugBundle.js\";\nexport { nodeFs, RecordingFs } from \"./fs.js\";\nexport type { Filesystem } from \"./fs.js\";\n\nexport const actionsDir = \"actions\";\n\n// Returns a generator of { isDir, path, depth } for all paths\n// within dirPath in some topological order (not including\n// dirPath itself).\nexport function* walkDir(\n fs: Filesystem,\n dirPath: string,\n shouldSkipDir?: (dirPath: string) => boolean,\n depth?: number,\n): Generator<{ isDir: boolean; path: string; depth: number }, void, void> {\n depth = depth ?? 0;\n for (const dirEntry of fs.listDir(dirPath).sort(consistentPathSort)) {\n const childPath = path.join(dirPath, dirEntry.name);\n if (dirEntry.isDirectory()) {\n if (shouldSkipDir && shouldSkipDir(childPath)) {\n continue;\n }\n yield { isDir: true, path: childPath, depth };\n yield* walkDir(fs, childPath, shouldSkipDir, depth + 1);\n } else if (dirEntry.isFile()) {\n yield { isDir: false, path: childPath, depth };\n }\n }\n}\n\n// Convex specific module environment.\ntype ModuleEnvironment = \"node\" | \"isolate\";\n\nexport interface Bundle {\n path: string;\n source: string;\n sourceMap?: string | undefined;\n environment: ModuleEnvironment;\n}\n\nexport interface BundleHash {\n path: string;\n hash: string;\n environment: ModuleEnvironment;\n}\n\ntype EsBuildResult = esbuild.BuildResult & {\n outputFiles: esbuild.OutputFile[];\n // Set of referenced external modules.\n externalModuleNames: Set<string>;\n // Set of bundled modules.\n bundledModuleNames: Set<string>;\n};\n\nasync function doEsbuild(\n ctx: Context,\n dir: string,\n entryPoints: string[],\n generateSourceMaps: boolean,\n platform: esbuild.Platform,\n chunksFolder: string,\n externalPackages: Map<string, ExternalPackage>,\n extraConditions: string[],\n includeSourcesContent: boolean,\n): Promise<EsBuildResult> {\n const external = createExternalPlugin(ctx, externalPackages);\n try {\n const result = await innerEsbuild({\n entryPoints,\n platform,\n generateSourceMaps,\n chunksFolder,\n extraConditions,\n dir,\n // The wasmPlugin should be last so it doesn't run on external modules.\n plugins: [external.plugin, wasmPlugin],\n includeSourcesContent,\n });\n\n for (const [relPath, input] of Object.entries(result.metafile!.inputs)) {\n // TODO: esbuild outputs paths prefixed with \"(disabled)\"\" when bundling our internal\n // udf-runtime package. The files do actually exist locally, though.\n if (\n relPath.indexOf(\"(disabled):\") !== -1 ||\n relPath.startsWith(\"wasm-binary:\") ||\n relPath.startsWith(\"wasm-stub:\")\n ) {\n continue;\n }\n const absPath = path.resolve(relPath);\n const st = ctx.fs.stat(absPath);\n if (st.size !== input.bytes) {\n logWarning(\n `Bundled file ${absPath} changed right after esbuild invocation`,\n );\n // Consider this a transient error so we'll try again and hopefully\n // no files change right after esbuild next time.\n return await ctx.crash({\n exitCode: 1,\n errorType: \"transient\",\n printedMessage: null,\n });\n }\n ctx.fs.registerPath(absPath, st);\n }\n return {\n ...result,\n externalModuleNames: external.externalModuleNames,\n bundledModuleNames: external.bundledModuleNames,\n };\n } catch (e: unknown) {\n // esbuild sometimes throws a build error instead of returning a result\n // containing an array of errors. Syntax errors are one of these cases.\n let recommendUseNode = false;\n if (isEsbuildBuildError(e)) {\n for (const error of e.errors) {\n if (error.location) {\n const absPath = path.resolve(error.location.file);\n const st = ctx.fs.stat(absPath);\n ctx.fs.registerPath(absPath, st);\n }\n if (\n platform !== \"node\" &&\n !recommendUseNode &&\n error.notes.some((note) =>\n note.text.includes(\"Are you trying to bundle for node?\"),\n )\n ) {\n recommendUseNode = true;\n }\n }\n }\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n // We don't print any error because esbuild already printed\n // all the relevant information.\n printedMessage: recommendUseNode\n ? `\\nIt looks like you are using Node APIs from a file without the \"use node\" directive.\\n` +\n `Split out actions using Node.js APIs like this into a new file only containing actions that uses \"use node\" ` +\n `so these actions will run in a Node.js environment.\\n` +\n `For more information see https://docs.convex.dev/functions/runtimes#nodejs-runtime\\n`\n : null,\n });\n }\n}\n\nexport async function bundle({\n ctx,\n dir,\n entryPoints,\n generateSourceMaps,\n platform,\n chunksFolder = \"_deps\",\n externalPackagesAllowList = [],\n extraConditions = [],\n includeSourcesContent = true,\n}: {\n ctx: Context;\n dir: string;\n entryPoints: string[];\n generateSourceMaps: boolean;\n platform: esbuild.Platform;\n chunksFolder?: string;\n externalPackagesAllowList?: string[];\n extraConditions?: string[];\n includeSourcesContent?: boolean;\n}): Promise<{\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n bundledModuleNames: Set<string>;\n}> {\n const availableExternalPackages = await computeExternalPackages(\n ctx,\n externalPackagesAllowList,\n );\n const result = await doEsbuild(\n ctx,\n dir,\n entryPoints,\n generateSourceMaps,\n platform,\n chunksFolder,\n availableExternalPackages,\n extraConditions,\n includeSourcesContent,\n );\n // Some ESBuild errors won't show up here, instead crashing in doEsbuild().\n if (result.errors.length) {\n const errorMessage = result.errors\n .map((e) => `esbuild error: ${e.text}`)\n .join(\"\\n\");\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: errorMessage,\n });\n }\n for (const warning of result.warnings) {\n logWarning(chalkStderr.yellow(`esbuild warning: ${warning.text}`));\n }\n const sourceMaps = new Map();\n const modules: Bundle[] = [];\n const environment = platform === \"node\" ? \"node\" : \"isolate\";\n for (const outputFile of result.outputFiles) {\n const relPath = path.relative(path.normalize(\"out\"), outputFile.path);\n if (path.extname(relPath) === \".map\") {\n sourceMaps.set(relPath, outputFile.text);\n continue;\n }\n const posixRelPath = relPath.split(path.sep).join(path.posix.sep);\n modules.push({ path: posixRelPath, source: outputFile.text, environment });\n }\n for (const module of modules) {\n const sourceMapPath = module.path + \".map\";\n const sourceMap = sourceMaps.get(sourceMapPath);\n if (sourceMap) {\n module.sourceMap = sourceMap;\n }\n }\n\n return {\n modules,\n externalDependencies: await externalPackageVersions(\n ctx,\n availableExternalPackages,\n result.externalModuleNames,\n ),\n bundledModuleNames: result.bundledModuleNames,\n };\n}\n\n// We could return the full list of availableExternalPackages, but this would be\n// installing more packages that we need. Instead, we collect all external\n// dependencies we found during bundling the /convex function, as well as their\n// respective peer and optional dependencies.\nasync function externalPackageVersions(\n ctx: Context,\n availableExternalPackages: Map<string, ExternalPackage>,\n referencedPackages: Set<string>,\n): Promise<Map<string, string>> {\n const versions = new Map<string, string>();\n const referencedPackagesQueue = Array.from(referencedPackages.keys());\n\n for (let i = 0; i < referencedPackagesQueue.length; i++) {\n const moduleName = referencedPackagesQueue[i];\n // This assertion is safe because referencedPackages can only contain\n // packages in availableExternalPackages.\n const modulePath = availableExternalPackages.get(moduleName)!.path;\n // Since we don't support lock files and different install commands yet, we\n // pick up the exact version installed on the local filesystem.\n const { version, peerAndOptionalDependencies } =\n await findExactVersionAndDependencies(ctx, moduleName, modulePath);\n versions.set(moduleName, version);\n\n for (const dependency of peerAndOptionalDependencies) {\n if (\n availableExternalPackages.has(dependency) &&\n !referencedPackages.has(dependency)\n ) {\n referencedPackagesQueue.push(dependency);\n referencedPackages.add(dependency);\n }\n }\n }\n\n return versions;\n}\n\nexport async function bundleSchema(\n ctx: Context,\n dir: string,\n extraConditions: string[],\n) {\n let target = path.resolve(dir, \"schema.ts\");\n if (!ctx.fs.exists(target)) {\n target = path.resolve(dir, \"schema.js\");\n }\n const result = await bundle({\n ctx,\n dir,\n entryPoints: [target],\n generateSourceMaps: true,\n platform: \"browser\",\n extraConditions,\n });\n return result.modules;\n}\n\nexport async function bundleAuthConfig(ctx: Context, dir: string) {\n const authConfigPath = path.resolve(dir, \"auth.config.js\");\n const authConfigTsPath = path.resolve(dir, \"auth.config.ts\");\n if (ctx.fs.exists(authConfigPath) && ctx.fs.exists(authConfigTsPath)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Found both ${authConfigPath} and ${authConfigTsPath}, choose one.`,\n });\n }\n const chosenPath = ctx.fs.exists(authConfigTsPath)\n ? authConfigTsPath\n : authConfigPath;\n if (!ctx.fs.exists(chosenPath)) {\n logVerbose(\n chalkStderr.yellow(\n `Found no auth config file at ${authConfigTsPath} or ${authConfigPath} so there are no configured auth providers`,\n ),\n );\n return [];\n }\n logVerbose(chalkStderr.yellow(`Bundling auth config found at ${chosenPath}`));\n const result = await bundle({\n ctx,\n dir,\n entryPoints: [chosenPath],\n generateSourceMaps: true,\n platform: \"browser\",\n });\n return result.modules;\n}\n\nexport async function doesImportConvexHttpRouter(source: string) {\n try {\n const ast = parseAST(source, {\n sourceType: \"module\",\n plugins: [\"typescript\"],\n });\n return ast.program.body.some((node) => {\n if (node.type !== \"ImportDeclaration\") return false;\n return node.specifiers.some((s) => {\n const specifier = s as ImportSpecifier;\n const imported = specifier.imported as Identifier;\n return imported.name === \"httpRouter\";\n });\n });\n } catch {\n return (\n source.match(\n /import\\s*\\{\\s*httpRouter.*\\}\\s*from\\s*\"\\s*convex\\/server\\s*\"/,\n ) !== null\n );\n }\n}\n\nconst ENTRY_POINT_EXTENSIONS = [\n // ESBuild js loader\n \".js\",\n \".mjs\",\n \".cjs\",\n // ESBuild ts loader\n \".ts\",\n \".tsx\",\n \".mts\",\n \".cts\",\n // ESBuild jsx loader\n \".jsx\",\n // ESBuild supports css, text, json, and more but these file types are not\n // allowed to define entry points.\n];\n\nexport async function entryPoints(\n ctx: Context,\n dir: string,\n): Promise<string[]> {\n const entryPoints = [];\n\n // Don't deploy directories in convex/ that define components\n // as this leads to double-deploying.\n const looksLikeNestedComponent = (dirPath: string): boolean => {\n const config = path.join(dirPath, \"convex.config.ts\");\n const isComponentDefinition = ctx.fs.exists(config);\n if (isComponentDefinition) {\n logVerbose(chalkStderr.yellow(`Skipping component directory ${dirPath}`));\n }\n return isComponentDefinition;\n };\n\n for (const { isDir, path: fpath, depth } of walkDir(\n ctx.fs,\n dir,\n looksLikeNestedComponent,\n )) {\n if (isDir) {\n continue;\n }\n const relPath = path.relative(dir, fpath);\n const parsedPath = path.parse(fpath);\n const base = parsedPath.base;\n const extension = parsedPath.ext.toLowerCase();\n\n if (relPath.startsWith(\"_deps\" + path.sep)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `The path \"${fpath}\" is within the \"_deps\" directory, which is reserved for dependencies. Please move your code to another directory.`,\n });\n }\n\n if (depth === 0 && base.toLowerCase().startsWith(\"https.\")) {\n const source = ctx.fs.readUtf8File(fpath);\n if (await doesImportConvexHttpRouter(source))\n logWarning(\n chalkStderr.yellow(\n `Found ${fpath}. HTTP action routes will not be imported from this file. Did you mean to include http${extension}?`,\n ),\n );\n Sentry.captureMessage(\n `User code top level directory contains file ${base} which imports httpRouter.`,\n \"warning\",\n );\n }\n\n // This should match isEntryPoint in the convex eslint plugin.\n if (!ENTRY_POINT_EXTENSIONS.some((ext) => relPath.endsWith(ext))) {\n logVerbose(chalkStderr.yellow(`Skipping non-JS file ${fpath}`));\n } else if (relPath.startsWith(\"_generated\" + path.sep)) {\n logVerbose(chalkStderr.yellow(`Skipping ${fpath}`));\n } else if (base.startsWith(\".\")) {\n logVerbose(chalkStderr.yellow(`Skipping dotfile ${fpath}`));\n } else if (base.startsWith(\"#\")) {\n logVerbose(chalkStderr.yellow(`Skipping likely emacs tempfile ${fpath}`));\n } else if (base === \"schema.ts\" || base === \"schema.js\") {\n logVerbose(chalkStderr.yellow(`Skipping ${fpath}`));\n } else if ((base.match(/\\./g) || []).length > 1) {\n // `auth.config.ts` and `convex.config.ts` are important not to bundle.\n // `*.test.ts` `*.spec.ts` are common in developer code.\n logVerbose(\n chalkStderr.yellow(`Skipping ${fpath} that contains multiple dots`),\n );\n } else if (relPath.includes(\" \")) {\n logVerbose(\n chalkStderr.yellow(`Skipping ${relPath} because it contains a space`),\n );\n } else {\n logVerbose(chalkStderr.green(`Preparing ${fpath}`));\n entryPoints.push(fpath);\n }\n }\n\n // If using TypeScript, require that at least one line starts with `export` or `import`,\n // a TypeScript requirement. This prevents confusing type errors from empty .ts files.\n const nonEmptyEntryPoints = entryPoints.filter((fpath) => {\n // This check only makes sense for TypeScript files\n if (!fpath.endsWith(\".ts\") && !fpath.endsWith(\".tsx\")) {\n return true;\n }\n const contents = ctx.fs.readUtf8File(fpath);\n if (/^\\s{0,100}(import|export)/m.test(contents)) {\n return true;\n }\n logVerbose(\n chalkStderr.yellow(\n `Skipping ${fpath} because it has no export or import to make it a valid TypeScript module`,\n ),\n );\n });\n\n return nonEmptyEntryPoints;\n}\n\n// A fallback regex in case we fail to parse the AST.\nexport const useNodeDirectiveRegex = /^\\s*(\"|')use node(\"|');?\\s*$/;\n\nfunction hasUseNodeDirective(ctx: Context, fpath: string): boolean {\n // Do a quick check for the exact string. If it doesn't exist, don't\n // bother parsing.\n const source = ctx.fs.readUtf8File(fpath);\n if (source.indexOf(\"use node\") === -1) {\n return false;\n }\n\n // We parse the AST here to extract the \"use node\" declaration. This is more\n // robust than doing a regex. We only use regex as a fallback.\n try {\n const ast = parseAST(source, {\n // parse in strict mode and allow module declarations\n sourceType: \"module\",\n\n // esbuild supports jsx and typescript by default. Allow the same plugins\n // here too.\n plugins: [\"jsx\", \"typescript\"],\n });\n return ast.program.directives\n .map((d) => d.value.value)\n .includes(\"use node\");\n } catch (error: any) {\n // Given that we have failed to parse, we are most likely going to fail in\n // the esbuild step, which seem to return better formatted error messages.\n // We don't throw here and fallback to regex.\n let lineMatches = false;\n for (const line of source.split(\"\\n\")) {\n if (line.match(useNodeDirectiveRegex)) {\n lineMatches = true;\n break;\n }\n }\n\n // Log that we failed to parse in verbose node if we need this for debugging.\n logVerbose(\n `Failed to parse ${fpath}. Use node is set to ${lineMatches} based on regex. Parse error: ${error.toString()}.`,\n );\n\n return lineMatches;\n }\n}\n\nexport function mustBeIsolate(relPath: string): boolean {\n // Check if the path without extension matches any of the static paths.\n return [\"http\", \"crons\", \"schema\", \"auth.config\"].includes(\n relPath.replace(/\\.[^/.]+$/, \"\"),\n );\n}\n\nasync function determineEnvironment(\n ctx: Context,\n dir: string,\n fpath: string,\n): Promise<ModuleEnvironment> {\n const relPath = path.relative(dir, fpath);\n\n const useNodeDirectiveFound = hasUseNodeDirective(ctx, fpath);\n if (useNodeDirectiveFound) {\n if (mustBeIsolate(relPath)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `\"use node\" directive is not allowed for ${relPath}.`,\n });\n }\n return \"node\";\n }\n\n const actionsPrefix = actionsDir + path.sep;\n if (relPath.startsWith(actionsPrefix)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `${relPath} is in /actions subfolder but has no \"use node\"; directive. You can now define actions in any folder and indicate they should run in node by adding \"use node\" directive. /actions is a deprecated way to choose Node.js environment, and we require \"use node\" for all files within that folder to avoid unexpected errors during the migration. See https://docs.convex.dev/functions/actions for more details`,\n });\n }\n\n return \"isolate\";\n}\n\nexport async function entryPointsByEnvironment(ctx: Context, dir: string) {\n const isolate = [];\n const node = [];\n for (const entryPoint of await entryPoints(ctx, dir)) {\n const environment = await determineEnvironment(ctx, dir, entryPoint);\n if (environment === \"node\") {\n node.push(entryPoint);\n } else {\n isolate.push(entryPoint);\n }\n }\n\n return { isolate, node };\n}\n"],
4
+ "sourcesContent": ["import path from \"path\";\nimport { chalkStderr } from \"chalk\";\nimport esbuild from \"esbuild\";\nimport { parse as parseAST } from \"@babel/parser\";\nimport { Identifier, ImportSpecifier } from \"@babel/types\";\nimport * as Sentry from \"@sentry/node\";\nimport { Filesystem, consistentPathSort } from \"./fs.js\";\nimport { Context } from \"./context.js\";\nimport { logVerbose, logWarning } from \"./log.js\";\nimport { wasmPlugin } from \"./wasm.js\";\nimport {\n ExternalPackage,\n computeExternalPackages,\n createExternalPlugin,\n findExactVersionAndDependencies,\n} from \"./external.js\";\nimport { innerEsbuild, isEsbuildBuildError } from \"./debugBundle.js\";\nexport { nodeFs, RecordingFs } from \"./fs.js\";\nexport type { Filesystem } from \"./fs.js\";\n\nexport const actionsDir = \"actions\";\n\n// Returns a generator of { isDir, path, depth } for all paths\n// within dirPath in some topological order (not including\n// dirPath itself).\nexport function* walkDir(\n fs: Filesystem,\n dirPath: string,\n shouldSkipDir?: (dirPath: string) => boolean,\n depth?: number,\n): Generator<{ isDir: boolean; path: string; depth: number }, void, void> {\n depth = depth ?? 0;\n for (const dirEntry of fs.listDir(dirPath).sort(consistentPathSort)) {\n const childPath = path.join(dirPath, dirEntry.name);\n if (dirEntry.isDirectory()) {\n if (shouldSkipDir && shouldSkipDir(childPath)) {\n continue;\n }\n yield { isDir: true, path: childPath, depth };\n yield* walkDir(fs, childPath, shouldSkipDir, depth + 1);\n } else if (dirEntry.isFile()) {\n yield { isDir: false, path: childPath, depth };\n }\n }\n}\n\n// Convex specific module environment.\ntype ModuleEnvironment = \"node\" | \"isolate\";\n\nexport interface Bundle {\n path: string;\n source: string;\n sourceMap?: string | undefined;\n environment: ModuleEnvironment;\n}\n\nexport interface BundleHash {\n path: string;\n hash: string;\n environment: ModuleEnvironment;\n}\n\ntype EsBuildResult = esbuild.BuildResult & {\n outputFiles: esbuild.OutputFile[];\n // Set of referenced external modules.\n externalModuleNames: Set<string>;\n // Set of bundled modules.\n bundledModuleNames: Set<string>;\n};\n\nasync function doEsbuild(\n ctx: Context,\n dir: string,\n entryPoints: string[],\n generateSourceMaps: boolean,\n platform: esbuild.Platform,\n chunksFolder: string,\n externalPackages: Map<string, ExternalPackage>,\n extraConditions: string[],\n includeSourcesContent: boolean,\n): Promise<EsBuildResult> {\n const external = createExternalPlugin(ctx, externalPackages);\n try {\n const result = await innerEsbuild({\n entryPoints,\n platform,\n generateSourceMaps,\n chunksFolder,\n extraConditions,\n dir,\n // The wasmPlugin should be last so it doesn't run on external modules.\n plugins: [external.plugin, wasmPlugin],\n includeSourcesContent,\n });\n\n for (const [relPath, input] of Object.entries(result.metafile!.inputs)) {\n // TODO: esbuild outputs paths prefixed with \"(disabled)\"\" when bundling our internal\n // udf-runtime package. The files do actually exist locally, though.\n if (\n relPath.indexOf(\"(disabled):\") !== -1 ||\n relPath.startsWith(\"wasm-binary:\") ||\n relPath.startsWith(\"wasm-stub:\")\n ) {\n continue;\n }\n const absPath = path.resolve(relPath);\n const st = ctx.fs.stat(absPath);\n if (st.size !== input.bytes) {\n logWarning(\n `Bundled file ${absPath} changed right after esbuild invocation`,\n );\n // Consider this a transient error so we'll try again and hopefully\n // no files change right after esbuild next time.\n return await ctx.crash({\n exitCode: 1,\n errorType: \"transient\",\n printedMessage: null,\n });\n }\n ctx.fs.registerPath(absPath, st);\n }\n return {\n ...result,\n externalModuleNames: external.externalModuleNames,\n bundledModuleNames: external.bundledModuleNames,\n };\n } catch (e: unknown) {\n // esbuild sometimes throws a build error instead of returning a result\n // containing an array of errors. Syntax errors are one of these cases.\n let recommendUseNode = false;\n if (isEsbuildBuildError(e)) {\n for (const error of e.errors) {\n if (error.location) {\n const absPath = path.resolve(error.location.file);\n const st = ctx.fs.stat(absPath);\n ctx.fs.registerPath(absPath, st);\n }\n if (\n platform !== \"node\" &&\n !recommendUseNode &&\n error.notes.some((note) =>\n note.text.includes(\"Are you trying to bundle for node?\"),\n )\n ) {\n recommendUseNode = true;\n }\n }\n }\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n // We don't print any error because esbuild already printed\n // all the relevant information.\n printedMessage: recommendUseNode\n ? `\\nIt looks like you are using Node APIs from a file without the \"use node\" directive.\\n` +\n `Split out actions using Node.js APIs like this into a new file only containing actions that uses \"use node\" ` +\n `so these actions will run in a Node.js environment.\\n` +\n `For more information see https://docs.convex.dev/functions/runtimes#nodejs-runtime\\n`\n : null,\n });\n }\n}\n\nexport async function bundle({\n ctx,\n dir,\n entryPoints,\n generateSourceMaps,\n platform,\n chunksFolder = \"_deps\",\n externalPackagesAllowList = [],\n extraConditions = [],\n includeSourcesContent = false,\n}: {\n ctx: Context;\n dir: string;\n entryPoints: string[];\n generateSourceMaps: boolean;\n platform: esbuild.Platform;\n chunksFolder?: string;\n externalPackagesAllowList?: string[];\n extraConditions?: string[];\n includeSourcesContent?: boolean;\n}): Promise<{\n modules: Bundle[];\n externalDependencies: Map<string, string>;\n bundledModuleNames: Set<string>;\n}> {\n const availableExternalPackages = await computeExternalPackages(\n ctx,\n externalPackagesAllowList,\n );\n const result = await doEsbuild(\n ctx,\n dir,\n entryPoints,\n generateSourceMaps,\n platform,\n chunksFolder,\n availableExternalPackages,\n extraConditions,\n includeSourcesContent,\n );\n // Some ESBuild errors won't show up here, instead crashing in doEsbuild().\n if (result.errors.length) {\n const errorMessage = result.errors\n .map((e) => `esbuild error: ${e.text}`)\n .join(\"\\n\");\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: errorMessage,\n });\n }\n for (const warning of result.warnings) {\n logWarning(chalkStderr.yellow(`esbuild warning: ${warning.text}`));\n }\n const sourceMaps = new Map();\n const modules: Bundle[] = [];\n const environment = platform === \"node\" ? \"node\" : \"isolate\";\n for (const outputFile of result.outputFiles) {\n const relPath = path.relative(path.normalize(\"out\"), outputFile.path);\n if (path.extname(relPath) === \".map\") {\n sourceMaps.set(relPath, outputFile.text);\n continue;\n }\n const posixRelPath = relPath.split(path.sep).join(path.posix.sep);\n modules.push({ path: posixRelPath, source: outputFile.text, environment });\n }\n for (const module of modules) {\n const sourceMapPath = module.path + \".map\";\n const sourceMap = sourceMaps.get(sourceMapPath);\n if (sourceMap) {\n module.sourceMap = sourceMap;\n }\n }\n\n return {\n modules,\n externalDependencies: await externalPackageVersions(\n ctx,\n availableExternalPackages,\n result.externalModuleNames,\n ),\n bundledModuleNames: result.bundledModuleNames,\n };\n}\n\n// We could return the full list of availableExternalPackages, but this would be\n// installing more packages that we need. Instead, we collect all external\n// dependencies we found during bundling the /convex function, as well as their\n// respective peer and optional dependencies.\nasync function externalPackageVersions(\n ctx: Context,\n availableExternalPackages: Map<string, ExternalPackage>,\n referencedPackages: Set<string>,\n): Promise<Map<string, string>> {\n const versions = new Map<string, string>();\n const referencedPackagesQueue = Array.from(referencedPackages.keys());\n\n for (let i = 0; i < referencedPackagesQueue.length; i++) {\n const moduleName = referencedPackagesQueue[i];\n // This assertion is safe because referencedPackages can only contain\n // packages in availableExternalPackages.\n const modulePath = availableExternalPackages.get(moduleName)!.path;\n // Since we don't support lock files and different install commands yet, we\n // pick up the exact version installed on the local filesystem.\n const { version, peerAndOptionalDependencies } =\n await findExactVersionAndDependencies(ctx, moduleName, modulePath);\n versions.set(moduleName, version);\n\n for (const dependency of peerAndOptionalDependencies) {\n if (\n availableExternalPackages.has(dependency) &&\n !referencedPackages.has(dependency)\n ) {\n referencedPackagesQueue.push(dependency);\n referencedPackages.add(dependency);\n }\n }\n }\n\n return versions;\n}\n\nexport async function bundleSchema(\n ctx: Context,\n dir: string,\n extraConditions: string[],\n) {\n let target = path.resolve(dir, \"schema.ts\");\n if (!ctx.fs.exists(target)) {\n target = path.resolve(dir, \"schema.js\");\n }\n const result = await bundle({\n ctx,\n dir,\n entryPoints: [target],\n generateSourceMaps: true,\n platform: \"browser\",\n extraConditions,\n });\n return result.modules;\n}\n\nexport async function bundleAuthConfig(ctx: Context, dir: string) {\n const authConfigPath = path.resolve(dir, \"auth.config.js\");\n const authConfigTsPath = path.resolve(dir, \"auth.config.ts\");\n if (ctx.fs.exists(authConfigPath) && ctx.fs.exists(authConfigTsPath)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Found both ${authConfigPath} and ${authConfigTsPath}, choose one.`,\n });\n }\n const chosenPath = ctx.fs.exists(authConfigTsPath)\n ? authConfigTsPath\n : authConfigPath;\n if (!ctx.fs.exists(chosenPath)) {\n logVerbose(\n chalkStderr.yellow(\n `Found no auth config file at ${authConfigTsPath} or ${authConfigPath} so there are no configured auth providers`,\n ),\n );\n return [];\n }\n logVerbose(chalkStderr.yellow(`Bundling auth config found at ${chosenPath}`));\n const result = await bundle({\n ctx,\n dir,\n entryPoints: [chosenPath],\n generateSourceMaps: true,\n platform: \"browser\",\n });\n return result.modules;\n}\n\nexport async function doesImportConvexHttpRouter(source: string) {\n try {\n const ast = parseAST(source, {\n sourceType: \"module\",\n plugins: [\"typescript\"],\n });\n return ast.program.body.some((node) => {\n if (node.type !== \"ImportDeclaration\") return false;\n return node.specifiers.some((s) => {\n const specifier = s as ImportSpecifier;\n const imported = specifier.imported as Identifier;\n return imported.name === \"httpRouter\";\n });\n });\n } catch {\n return (\n source.match(\n /import\\s*\\{\\s*httpRouter.*\\}\\s*from\\s*\"\\s*convex\\/server\\s*\"/,\n ) !== null\n );\n }\n}\n\nconst ENTRY_POINT_EXTENSIONS = [\n // ESBuild js loader\n \".js\",\n \".mjs\",\n \".cjs\",\n // ESBuild ts loader\n \".ts\",\n \".tsx\",\n \".mts\",\n \".cts\",\n // ESBuild jsx loader\n \".jsx\",\n // ESBuild supports css, text, json, and more but these file types are not\n // allowed to define entry points.\n];\n\nexport async function entryPoints(\n ctx: Context,\n dir: string,\n): Promise<string[]> {\n const entryPoints = [];\n\n // Don't deploy directories in convex/ that define components\n // as this leads to double-deploying.\n const looksLikeNestedComponent = (dirPath: string): boolean => {\n const config = path.join(dirPath, \"convex.config.ts\");\n const isComponentDefinition = ctx.fs.exists(config);\n if (isComponentDefinition) {\n logVerbose(chalkStderr.yellow(`Skipping component directory ${dirPath}`));\n }\n return isComponentDefinition;\n };\n\n for (const { isDir, path: fpath, depth } of walkDir(\n ctx.fs,\n dir,\n looksLikeNestedComponent,\n )) {\n if (isDir) {\n continue;\n }\n const relPath = path.relative(dir, fpath);\n const parsedPath = path.parse(fpath);\n const base = parsedPath.base;\n const extension = parsedPath.ext.toLowerCase();\n\n if (relPath.startsWith(\"_deps\" + path.sep)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `The path \"${fpath}\" is within the \"_deps\" directory, which is reserved for dependencies. Please move your code to another directory.`,\n });\n }\n\n if (depth === 0 && base.toLowerCase().startsWith(\"https.\")) {\n const source = ctx.fs.readUtf8File(fpath);\n if (await doesImportConvexHttpRouter(source))\n logWarning(\n chalkStderr.yellow(\n `Found ${fpath}. HTTP action routes will not be imported from this file. Did you mean to include http${extension}?`,\n ),\n );\n Sentry.captureMessage(\n `User code top level directory contains file ${base} which imports httpRouter.`,\n \"warning\",\n );\n }\n\n // This should match isEntryPoint in the convex eslint plugin.\n if (!ENTRY_POINT_EXTENSIONS.some((ext) => relPath.endsWith(ext))) {\n logVerbose(chalkStderr.yellow(`Skipping non-JS file ${fpath}`));\n } else if (relPath.startsWith(\"_generated\" + path.sep)) {\n logVerbose(chalkStderr.yellow(`Skipping ${fpath}`));\n } else if (base.startsWith(\".\")) {\n logVerbose(chalkStderr.yellow(`Skipping dotfile ${fpath}`));\n } else if (base.startsWith(\"#\")) {\n logVerbose(chalkStderr.yellow(`Skipping likely emacs tempfile ${fpath}`));\n } else if (base === \"schema.ts\" || base === \"schema.js\") {\n logVerbose(chalkStderr.yellow(`Skipping ${fpath}`));\n } else if ((base.match(/\\./g) || []).length > 1) {\n // `auth.config.ts` and `convex.config.ts` are important not to bundle.\n // `*.test.ts` `*.spec.ts` are common in developer code.\n logVerbose(\n chalkStderr.yellow(`Skipping ${fpath} that contains multiple dots`),\n );\n } else if (relPath.includes(\" \")) {\n logVerbose(\n chalkStderr.yellow(`Skipping ${relPath} because it contains a space`),\n );\n } else {\n logVerbose(chalkStderr.green(`Preparing ${fpath}`));\n entryPoints.push(fpath);\n }\n }\n\n // If using TypeScript, require that at least one line starts with `export` or `import`,\n // a TypeScript requirement. This prevents confusing type errors from empty .ts files.\n const nonEmptyEntryPoints = entryPoints.filter((fpath) => {\n // This check only makes sense for TypeScript files\n if (!fpath.endsWith(\".ts\") && !fpath.endsWith(\".tsx\")) {\n return true;\n }\n const contents = ctx.fs.readUtf8File(fpath);\n if (/^\\s{0,100}(import|export)/m.test(contents)) {\n return true;\n }\n logVerbose(\n chalkStderr.yellow(\n `Skipping ${fpath} because it has no export or import to make it a valid TypeScript module`,\n ),\n );\n });\n\n return nonEmptyEntryPoints;\n}\n\n// A fallback regex in case we fail to parse the AST.\nexport const useNodeDirectiveRegex = /^\\s*(\"|')use node(\"|');?\\s*$/;\n\nfunction hasUseNodeDirective(ctx: Context, fpath: string): boolean {\n // Do a quick check for the exact string. If it doesn't exist, don't\n // bother parsing.\n const source = ctx.fs.readUtf8File(fpath);\n if (source.indexOf(\"use node\") === -1) {\n return false;\n }\n\n // We parse the AST here to extract the \"use node\" declaration. This is more\n // robust than doing a regex. We only use regex as a fallback.\n try {\n const ast = parseAST(source, {\n // parse in strict mode and allow module declarations\n sourceType: \"module\",\n\n // esbuild supports jsx and typescript by default. Allow the same plugins\n // here too.\n plugins: [\"jsx\", \"typescript\"],\n });\n return ast.program.directives\n .map((d) => d.value.value)\n .includes(\"use node\");\n } catch (error: any) {\n // Given that we have failed to parse, we are most likely going to fail in\n // the esbuild step, which seem to return better formatted error messages.\n // We don't throw here and fallback to regex.\n let lineMatches = false;\n for (const line of source.split(\"\\n\")) {\n if (line.match(useNodeDirectiveRegex)) {\n lineMatches = true;\n break;\n }\n }\n\n // Log that we failed to parse in verbose node if we need this for debugging.\n logVerbose(\n `Failed to parse ${fpath}. Use node is set to ${lineMatches} based on regex. Parse error: ${error.toString()}.`,\n );\n\n return lineMatches;\n }\n}\n\nexport function mustBeIsolate(relPath: string): boolean {\n // Check if the path without extension matches any of the static paths.\n return [\"http\", \"crons\", \"schema\", \"auth.config\"].includes(\n relPath.replace(/\\.[^/.]+$/, \"\"),\n );\n}\n\nasync function determineEnvironment(\n ctx: Context,\n dir: string,\n fpath: string,\n): Promise<ModuleEnvironment> {\n const relPath = path.relative(dir, fpath);\n\n const useNodeDirectiveFound = hasUseNodeDirective(ctx, fpath);\n if (useNodeDirectiveFound) {\n if (mustBeIsolate(relPath)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `\"use node\" directive is not allowed for ${relPath}.`,\n });\n }\n return \"node\";\n }\n\n const actionsPrefix = actionsDir + path.sep;\n if (relPath.startsWith(actionsPrefix)) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `${relPath} is in /actions subfolder but has no \"use node\"; directive. You can now define actions in any folder and indicate they should run in node by adding \"use node\" directive. /actions is a deprecated way to choose Node.js environment, and we require \"use node\" for all files within that folder to avoid unexpected errors during the migration. See https://docs.convex.dev/functions/actions for more details`,\n });\n }\n\n return \"isolate\";\n}\n\nexport async function entryPointsByEnvironment(ctx: Context, dir: string) {\n const isolate = [];\n const node = [];\n for (const entryPoint of await entryPoints(ctx, dir)) {\n const environment = await determineEnvironment(ctx, dir, entryPoint);\n if (environment === \"node\") {\n node.push(entryPoint);\n } else {\n isolate.push(entryPoint);\n }\n }\n\n return { isolate, node };\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,mBAA4B;AAE5B,oBAAkC;AAElC,aAAwB;AACxB,gBAA+C;AAE/C,iBAAuC;AACvC,kBAA2B;AAC3B,sBAKO;AACP,yBAAkD;AAClD,IAAAA,aAAoC;AAG7B,MAAM,aAAa;AAKnB,UAAU,QACf,IACA,SACA,eACA,OACwE;AACxE,UAAQ,SAAS;AACjB,aAAW,YAAY,GAAG,QAAQ,OAAO,EAAE,KAAK,4BAAkB,GAAG;AACnE,UAAM,YAAY,YAAAC,QAAK,KAAK,SAAS,SAAS,IAAI;AAClD,QAAI,SAAS,YAAY,GAAG;AAC1B,UAAI,iBAAi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,aAAa,EAAE;AAAA,IAChD,QAAQ,QAAQ,aAAa,EAAE;AAAA,EACjC;AACF;AAEA,eAAe,qBACb,KACA,KACA,OAC4B;AAC5B,QAAM,UAAU,YAAAH,QAAK,SAAS,KAAK,KAAK;AAExC,QAAM,wBAAwB,oBAAoB,KAAK,KAAK;AAC5D,MAAI,uBAAuB;AACzB,QAAI,cAAc,OAAO,GAAG;AAC1B,aAAO,MAAM,IAAI,MAAM;AAAA,QACrB,UAAU;AAAA,QACV,WAAW;AAAA,QACX,gBAAgB,2CAA2C,OAAO;AAAA,MACpE,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,aAAa,YAAAA,QAAK;AACxC,MAAI,QAAQ,WAAW,aAAa,GAAG;AACrC,WAAO,MAAM,IAAI,MAAM;AAAA,MACrB,UAAU;AAAA,MACV,WAAW;AAAA,MACX,gBAAgB,GAAG,OAAO;AAAA,IAC5B,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEA,eAAsB,yBAAyB,KAAc,KAAa;AACxE,QAAM,UAAU,CAAC;AACjB,QAAM,OAAO,CAAC;AACd,aAAW,cAAc,MAAM,YAAY,KAAK,GAAG,GAAG;AACpD,UAAM,cAAc,MAAM,qBAAqB,KAAK,KAAK,UAAU;AACnE,QAAI,gBAAgB,QAAQ;AAC1B,WAAK,KAAK,UAAU;AAAA,IACtB,OAAO;AACL,cAAQ,KAAK,UAAU;AAAA,IACzB;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,KAAK;AACzB;",
6
6
  "names": ["import_fs", "path", "entryPoints", "module", "parseAST"]
7
7
  }
@@ -478,8 +478,7 @@ async function ensureDeploymentProvisioned(ctx, options) {
478
478
  }
479
479
  }
480
480
  async function updateEnvAndConfigForDeploymentSelection(ctx, options, existingValue) {
481
- const { configPath, projectConfig: existingProjectConfig } = await (0, import_config.readProjectConfig)(ctx);
482
- const functionsPath = (0, import_utils.functionsDir)((0, import_config.configName)(), existingProjectConfig);
481
+ const { configPath, projectConfig } = await (0, import_config.readProjectConfig)(ctx);
483
482
  const { wroteToGitIgnore, changedDeploymentEnvVar } = await (0, import_deployment.writeDeploymentEnvVar)(
484
483
  ctx,
485
484
  options.deploymentType,
@@ -490,14 +489,7 @@ async function updateEnvAndConfigForDeploymentSelection(ctx, options, existingVa
490
489
  },
491
490
  existingValue
492
491
  );
493
- const projectConfig = await (0, import_config.upgradeOldAuthInfoToAuthConfig)(
494
- ctx,
495
- existingProjectConfig,
496
- functionsPath
497
- );
498
- await (0, import_config.writeProjectConfig)(ctx, projectConfig, {
499
- deleteIfAllDefault: true
500
- });
492
+ await (0, import_config.writeProjectConfig)(ctx, projectConfig);
501
493
  await (0, import_init.finalizeConfiguration)(ctx, {
502
494
  deploymentType: options.deploymentType,
503
495
  deploymentName: options.deploymentName,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/configure.ts"],
4
- "sourcesContent": ["import { chalkStderr } from \"chalk\";\nimport { Context } from \"../bundler/context.js\";\nimport {\n logFailure,\n logFinishedStep,\n logMessage,\n logWarning,\n showSpinner,\n} from \"../bundler/log.js\";\nimport {\n DeploymentType,\n DeploymentName,\n fetchDeploymentCredentialsProvisioningDevOrProdMaybeThrows,\n createProject,\n DeploymentSelectionWithinProject,\n loadSelectedDeploymentCredentials,\n checkAccessToSelectedProject,\n validateDeploymentSelectionForExistingDeployment,\n} from \"./lib/api.js\";\nimport {\n configName,\n readProjectConfig,\n upgradeOldAuthInfoToAuthConfig,\n writeProjectConfig,\n} from \"./lib/config.js\";\nimport {\n DeploymentDetails,\n eraseDeploymentEnvVar,\n writeDeploymentEnvVar,\n} from \"./lib/deployment.js\";\nimport { finalizeConfiguration } from \"./lib/init.js\";\nimport {\n CONVEX_DEPLOYMENT_ENV_VAR_NAME,\n functionsDir,\n hasProjects,\n logAndHandleFetchError,\n selectDevDeploymentType,\n validateOrSelectProject,\n validateOrSelectTeam,\n} from \"./lib/utils/utils.js\";\nimport { writeConvexUrlToEnvFile } from \"./lib/envvars.js\";\nimport path from \"path\";\nimport { projectDashboardUrl } from \"./lib/dashboard.js\";\nimport { doInitConvexFolder } from \"./lib/codegen.js\";\nimport { handleLocalDeployment } from \"./lib/localDeployment/localDeployment.js\";\nimport {\n promptOptions,\n promptString,\n promptYesNo,\n} from \"./lib/utils/prompts.js\";\nimport { readGlobalConfig } from \"./lib/utils/globalConfig.js\";\nimport {\n DeploymentSelection,\n ProjectSelection,\n deploymentNameFromSelection,\n shouldAllowAnonymousDevelopment,\n} from \"./lib/deploymentSelection.js\";\nimport { ensureLoggedIn } from \"./lib/login.js\";\nimport { handleAnonymousDeployment } from \"./lib/localDeployment/anonymous.js\";\ntype DeploymentCredentials = {\n url: string;\n adminKey: string;\n};\n\ntype ChosenConfiguration =\n // `--configure new`\n | \"new\"\n // `--configure existing`\n | \"existing\"\n // `--configure`\n | \"ask\"\n // `--configure` was not specified\n | null;\n\ntype ConfigureCmdOptions = {\n selectionWithinProject: DeploymentSelectionWithinProject;\n prod: boolean;\n localOptions: {\n ports?: {\n cloud: number;\n site: number;\n };\n backendVersion?: string | undefined;\n dashboardVersion?: string | undefined;\n forceUpgrade: boolean;\n };\n team?: string | undefined;\n project?: string | undefined;\n devDeployment?: \"cloud\" | \"local\" | undefined;\n local?: boolean | undefined;\n cloud?: boolean | undefined;\n url?: string | undefined;\n adminKey?: string | undefined;\n envFile?: string | undefined;\n overrideAuthUrl?: string | undefined;\n overrideAuthClient?: string | undefined;\n overrideAuthUsername?: string | undefined;\n overrideAuthPassword?: string | undefined;\n};\n\n/**\n * As of writing, this is used by:\n * - `npx convex dev`\n * - `npx convex codegen`\n *\n * But is not used by `npx convex deploy` or other commands.\n */\nexport async function deploymentCredentialsOrConfigure(\n ctx: Context,\n deploymentSelection: DeploymentSelection,\n chosenConfiguration: ChosenConfiguration,\n cmdOptions: ConfigureCmdOptions,\n): Promise<\n DeploymentCredentials & {\n deploymentFields: {\n deploymentName: DeploymentName;\n deploymentType: DeploymentType;\n projectSlug: string | null;\n teamSlug: string | null;\n } | null;\n }\n> {\n const selectedDeployment = await _deploymentCredentialsOrConfigure(\n ctx,\n deploymentSelection,\n chosenConfiguration,\n cmdOptions,\n );\n\n if (selectedDeployment.deploymentFields !== null) {\n // Set the `CONVEX_DEPLOYMENT` env var + the `CONVEX_URL` env var\n await updateEnvAndConfigForDeploymentSelection(\n ctx,\n {\n url: selectedDeployment.url,\n deploymentName: selectedDeployment.deploymentFields.deploymentName,\n teamSlug: selectedDeployment.deploymentFields.teamSlug,\n projectSlug: selectedDeployment.deploymentFields.projectSlug,\n deploymentType: selectedDeployment.deploymentFields.deploymentType,\n },\n deploymentNameFromSelection(deploymentSelection),\n );\n } else {\n // Clear the `CONVEX_DEPLOYMENT` env var + set the `CONVEX_URL` env var\n await handleManuallySetUrlAndAdminKey(ctx, {\n url: selectedDeployment.url,\n adminKey: selectedDeployment.adminKey,\n });\n }\n return {\n url: selectedDeployment.url,\n adminKey: selectedDeployment.adminKey,\n deploymentFields: selectedDeployment.deploymentFields,\n };\n}\n\nexport async function _deploymentCredentialsOrConfigure(\n ctx: Context,\n deploymentSelection: DeploymentSelection,\n chosenConfiguration: ChosenConfiguration,\n cmdOptions: ConfigureCmdOptions,\n): Promise<\n DeploymentCredentials & {\n deploymentFields: {\n deploymentName: DeploymentName;\n deploymentType: DeploymentType;\n projectSlug: string | null;\n teamSlug: string | null;\n } | null;\n }\n> {\n const config = readGlobalConfig(ctx);\n const globallyForceCloud = !!config?.optOutOfLocalDevDeploymentsUntilBetaOver;\n if (globallyForceCloud && cmdOptions.local) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"Can't specify --local when local deployments are disabled on this machine. Run `npx convex disable-local-deployments --undo-global` to allow use of --local.\",\n });\n }\n\n switch (deploymentSelection.kind) {\n case \"existingDeployment\":\n await validateDeploymentSelectionForExistingDeployment(\n ctx,\n cmdOptions.selectionWithinProject,\n deploymentSelection.deploymentToActOn.source,\n );\n if (deploymentSelection.deploymentToActOn.deploymentFields === null) {\n // erase `CONVEX_DEPLOYMENT` from .env.local + set the url env var\n await handleManuallySetUrlAndAdminKey(ctx, {\n url: deploymentSelection.deploymentToActOn.url,\n adminKey: deploymentSelection.deploymentToActOn.adminKey,\n });\n }\n return {\n url: deploymentSelection.deploymentToActOn.url,\n adminKey: deploymentSelection.deploymentToActOn.adminKey,\n deploymentFields:\n deploymentSelection.deploymentToActOn.deploymentFields,\n };\n case \"chooseProject\": {\n await ensureLoggedIn(ctx, {\n overrideAuthUrl: cmdOptions.overrideAuthUrl,\n overrideAuthClient: cmdOptions.overrideAuthClient,\n overrideAuthUsername: cmdOptions.overrideAuthUsername,\n overrideAuthPassword: cmdOptions.overrideAuthPassword,\n });\n return await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n }\n case \"preview\":\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"Use `npx convex deploy` to use preview deployments.\",\n });\n case \"deploymentWithinProject\": {\n return await handleDeploymentWithinProject(ctx, {\n chosenConfiguration,\n targetProject: deploymentSelection.targetProject,\n cmdOptions,\n globallyForceCloud,\n });\n }\n case \"anonymous\": {\n const hasAuth = ctx.bigBrainAuth() !== null;\n const isAgentMode = process.env.CONVEX_AGENT_MODE === \"anonymous\";\n if (\n !isAgentMode &&\n hasAuth &&\n deploymentSelection.deploymentName !== null\n ) {\n const shouldConfigure =\n chosenConfiguration !== null ||\n (await promptYesNo(ctx, {\n message: `${CONVEX_DEPLOYMENT_ENV_VAR_NAME} is configured with deployment ${deploymentSelection.deploymentName}, which is not linked with your account. Would you like to choose a different project instead?`,\n }));\n if (!shouldConfigure) {\n return await ctx.crash({\n exitCode: 0,\n errorType: \"fatal\",\n printedMessage: `Run \\`npx convex login --link-deployments\\` first to link this deployment to your account, and then run \\`npx convex dev\\` again.`,\n });\n }\n return await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n }\n const alreadyHasConfiguredAnonymousDeployment =\n deploymentSelection.deploymentName !== null &&\n chosenConfiguration === null;\n if (isAgentMode) {\n logWarning(\n chalkStderr.yellow.bold(\n \"CONVEX_AGENT_MODE=anonymous mode is in beta, functionality may change in the future.\",\n ),\n );\n }\n\n const shouldPromptForLogin = isAgentMode\n ? \"no\"\n : alreadyHasConfiguredAnonymousDeployment\n ? \"no\"\n : await promptOptions(ctx, {\n message:\n \"Welcome to Convex! Would you like to login to your account?\",\n choices: [\n {\n name: \"Start without an account (run Convex locally)\",\n value: \"no\",\n },\n { name: \"Login or create an account\", value: \"yes\" },\n ],\n default: \"no\",\n });\n if (shouldPromptForLogin === \"no\") {\n const result = await handleAnonymousDeployment(ctx, {\n chosenConfiguration,\n deploymentName: deploymentSelection.deploymentName,\n ...cmdOptions.localOptions,\n });\n return {\n adminKey: result.adminKey,\n url: result.deploymentUrl,\n deploymentFields: {\n deploymentName: result.deploymentName,\n deploymentType: \"anonymous\",\n projectSlug: null,\n teamSlug: null,\n },\n };\n }\n return await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n }\n }\n}\n\nasync function handleDeploymentWithinProject(\n ctx: Context,\n {\n chosenConfiguration,\n targetProject,\n cmdOptions,\n globallyForceCloud,\n }: {\n chosenConfiguration: ChosenConfiguration;\n targetProject: ProjectSelection;\n cmdOptions: ConfigureCmdOptions;\n globallyForceCloud: boolean;\n },\n) {\n const hasAuth = ctx.bigBrainAuth() !== null;\n const loginMessage =\n hasAuth && shouldAllowAnonymousDevelopment()\n ? undefined\n : `Tip: You can try out Convex without creating an account by clearing the ${CONVEX_DEPLOYMENT_ENV_VAR_NAME} environment variable.`;\n await ensureLoggedIn(ctx, {\n message: loginMessage,\n overrideAuthUrl: cmdOptions.overrideAuthUrl,\n overrideAuthClient: cmdOptions.overrideAuthClient,\n overrideAuthUsername: cmdOptions.overrideAuthUsername,\n overrideAuthPassword: cmdOptions.overrideAuthPassword,\n });\n if (chosenConfiguration !== null) {\n const result = await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n return result;\n }\n\n const accessResult = await checkAccessToSelectedProject(ctx, targetProject);\n if (accessResult.kind === \"noAccess\") {\n logMessage(\"You don't have access to the selected project.\");\n const result = await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n return result;\n }\n\n const selectedDeployment = await loadSelectedDeploymentCredentials(\n ctx,\n {\n kind: \"deploymentWithinProject\",\n targetProject,\n },\n cmdOptions.selectionWithinProject,\n // We'll start running it below\n { ensureLocalRunning: false },\n );\n if (\n selectedDeployment.deploymentFields !== null &&\n selectedDeployment.deploymentFields.deploymentType === \"local\"\n ) {\n // Start running the local backend\n await handleLocalDeployment(ctx, {\n teamSlug: selectedDeployment.deploymentFields.teamSlug!,\n projectSlug: selectedDeployment.deploymentFields.projectSlug!,\n forceUpgrade: cmdOptions.localOptions.forceUpgrade,\n ports: cmdOptions.localOptions.ports,\n backendVersion: cmdOptions.localOptions.backendVersion,\n });\n }\n return {\n url: selectedDeployment.url,\n adminKey: selectedDeployment.adminKey,\n deploymentFields: selectedDeployment.deploymentFields,\n };\n}\n\nasync function handleChooseProject(\n ctx: Context,\n chosenConfiguration: ChosenConfiguration,\n args: {\n globallyForceCloud: boolean;\n },\n cmdOptions: ConfigureCmdOptions,\n): Promise<\n DeploymentCredentials & {\n deploymentFields: {\n deploymentName: DeploymentName;\n deploymentType: DeploymentType;\n projectSlug: string;\n teamSlug: string;\n };\n }\n> {\n await ensureLoggedIn(ctx, {\n overrideAuthUrl: cmdOptions.overrideAuthUrl,\n overrideAuthClient: cmdOptions.overrideAuthClient,\n overrideAuthUsername: cmdOptions.overrideAuthUsername,\n overrideAuthPassword: cmdOptions.overrideAuthPassword,\n });\n const project = await selectProject(ctx, chosenConfiguration, {\n team: cmdOptions.team,\n project: cmdOptions.project,\n devDeployment: cmdOptions.devDeployment,\n local: args.globallyForceCloud ? false : cmdOptions.local,\n cloud: args.globallyForceCloud ? true : cmdOptions.cloud,\n });\n // TODO complain about any non-default cmdOptions.localOptions here\n // because we're ignoring them if this isn't a local development.\n\n const deploymentOptions: DeploymentOptions =\n cmdOptions.selectionWithinProject.kind === \"prod\"\n ? { kind: \"prod\" }\n : project.devDeployment === \"local\"\n ? { kind: \"local\", ...cmdOptions.localOptions }\n : { kind: \"dev\" };\n const {\n deploymentName,\n deploymentUrl: url,\n adminKey,\n } = await ensureDeploymentProvisioned(ctx, {\n teamSlug: project.teamSlug,\n projectSlug: project.projectSlug,\n deploymentOptions,\n });\n return {\n url,\n adminKey,\n deploymentFields: {\n deploymentName,\n deploymentType: deploymentOptions.kind,\n projectSlug: project.projectSlug,\n teamSlug: project.teamSlug,\n },\n };\n}\n\nexport async function handleManuallySetUrlAndAdminKey(\n ctx: Context,\n cmdOptions: { url: string; adminKey: string },\n) {\n const { url, adminKey } = cmdOptions;\n const didErase = await eraseDeploymentEnvVar(ctx);\n if (didErase) {\n logMessage(\n chalkStderr.yellowBright(\n `Removed the CONVEX_DEPLOYMENT environment variable from .env.local`,\n ),\n );\n }\n const envVarWrite = await writeConvexUrlToEnvFile(ctx, url);\n if (envVarWrite !== null) {\n logMessage(\n chalkStderr.green(\n `Saved the given --url as ${envVarWrite.envVar} to ${envVarWrite.envFile}`,\n ),\n );\n }\n return { url, adminKey };\n}\n\nexport async function selectProject(\n ctx: Context,\n chosenConfiguration: ChosenConfiguration,\n cmdOptions: {\n team?: string | undefined;\n project?: string | undefined;\n devDeployment?: \"cloud\" | \"local\" | undefined;\n local?: boolean | undefined;\n cloud?: boolean | undefined;\n defaultProjectName?: string | undefined;\n },\n): Promise<{\n teamSlug: string;\n projectSlug: string;\n devDeployment: \"cloud\" | \"local\";\n}> {\n // Prompt the user to select a project.\n const choice =\n chosenConfiguration !== \"ask\" && chosenConfiguration !== null\n ? chosenConfiguration\n : await askToConfigure(ctx);\n switch (choice) {\n case \"new\":\n return selectNewProject(ctx, chosenConfiguration, cmdOptions);\n case \"existing\":\n return selectExistingProject(ctx, chosenConfiguration, cmdOptions);\n default:\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"No project selected.\",\n });\n }\n}\n\nconst cwd = path.basename(process.cwd());\nasync function selectNewProject(\n ctx: Context,\n chosenConfiguration: ChosenConfiguration,\n config: {\n team?: string | undefined;\n project?: string | undefined;\n devDeployment?: \"cloud\" | \"local\" | undefined;\n cloud?: boolean | undefined;\n local?: boolean | undefined;\n defaultProjectName?: string | undefined;\n },\n) {\n const { teamSlug: selectedTeam, chosen: didChooseBetweenTeams } =\n await validateOrSelectTeam(ctx, config.team, \"Team:\");\n let projectName: string = config.project || cwd;\n let choseProjectInteractively = false;\n if (!config.project) {\n projectName = await promptString(ctx, {\n message: \"Project name:\",\n default: config.defaultProjectName || cwd,\n });\n choseProjectInteractively = true;\n }\n\n const { devDeployment } = await selectDevDeploymentType(ctx, {\n chosenConfiguration,\n newOrExisting: \"new\",\n teamSlug: selectedTeam,\n userHasChosenSomethingInteractively:\n didChooseBetweenTeams || choseProjectInteractively,\n projectSlug: undefined,\n devDeploymentFromFlag: config.devDeployment,\n forceDevDeployment: config.local\n ? \"local\"\n : config.cloud\n ? \"cloud\"\n : undefined,\n });\n\n showSpinner(\"Creating new Convex project...\");\n\n let projectSlug, teamSlug, projectsRemaining;\n try {\n ({ projectSlug, teamSlug, projectsRemaining } = await createProject(ctx, {\n teamSlug: selectedTeam,\n projectName,\n // We have to create some deployment initially for a project.\n deploymentTypeToProvision: devDeployment === \"local\" ? \"prod\" : \"dev\",\n }));\n } catch (err) {\n logFailure(\"Unable to create project.\");\n return await logAndHandleFetchError(ctx, err);\n }\n const teamMessage = didChooseBetweenTeams\n ? \" in team \" + chalkStderr.bold(teamSlug)\n : \"\";\n logFinishedStep(\n `Created project ${chalkStderr.bold(\n projectSlug,\n )}${teamMessage}, manage it at ${chalkStderr.bold(\n projectDashboardUrl(teamSlug, projectSlug),\n )}`,\n );\n\n if (projectsRemaining <= 2) {\n logWarning(\n chalkStderr.yellow.bold(\n `Your account now has ${projectsRemaining} project${\n projectsRemaining === 1 ? \"\" : \"s\"\n } remaining.`,\n ),\n );\n }\n\n await doInitConvexFolder(ctx);\n return { teamSlug, projectSlug, devDeployment };\n}\n\nasync function selectExistingProject(\n ctx: Context,\n chosenConfiguration: ChosenConfiguration,\n config: {\n team?: string | undefined;\n project?: string | undefined;\n devDeployment?: \"cloud\" | \"local\" | undefined;\n local?: boolean | undefined;\n cloud?: boolean | undefined;\n },\n): Promise<{\n teamSlug: string;\n projectSlug: string;\n devDeployment: \"cloud\" | \"local\";\n}> {\n const { teamSlug, chosen } = await validateOrSelectTeam(\n ctx,\n config.team,\n \"Team:\",\n );\n\n const projectSlug = await validateOrSelectProject(\n ctx,\n config.project,\n teamSlug,\n \"Configure project\",\n \"Project:\",\n );\n if (projectSlug === null) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"Run the command again to create a new project instead.\",\n });\n }\n const { devDeployment } = await selectDevDeploymentType(ctx, {\n chosenConfiguration,\n newOrExisting: \"existing\",\n teamSlug,\n projectSlug,\n userHasChosenSomethingInteractively: chosen || !config.project,\n devDeploymentFromFlag: config.devDeployment,\n forceDevDeployment: config.local\n ? \"local\"\n : config.cloud\n ? \"cloud\"\n : undefined,\n });\n\n logFinishedStep(`Reinitialized project ${chalkStderr.bold(projectSlug)}`);\n return { teamSlug, projectSlug, devDeployment };\n}\n\nasync function askToConfigure(ctx: Context): Promise<\"new\" | \"existing\"> {\n if (!(await hasProjects(ctx))) {\n return \"new\";\n }\n return await promptOptions(ctx, {\n message: \"What would you like to configure?\",\n default: \"new\",\n choices: [\n { name: \"create a new project\", value: \"new\" },\n { name: \"choose an existing project\", value: \"existing\" },\n ],\n });\n}\n\ntype DeploymentOptions =\n | {\n kind: \"prod\";\n }\n | { kind: \"dev\" }\n | {\n kind: \"local\";\n ports?:\n | {\n cloud: number;\n site: number;\n }\n | undefined;\n backendVersion?: string | undefined;\n forceUpgrade: boolean;\n };\n\n/**\n * This method assumes that the member has access to the selected project.\n */\nasync function ensureDeploymentProvisioned(\n ctx: Context,\n options: {\n teamSlug: string;\n projectSlug: string;\n deploymentOptions: DeploymentOptions;\n },\n): Promise<DeploymentDetails> {\n switch (options.deploymentOptions.kind) {\n case \"dev\":\n case \"prod\": {\n const credentials =\n await fetchDeploymentCredentialsProvisioningDevOrProdMaybeThrows(\n ctx,\n {\n kind: \"teamAndProjectSlugs\",\n teamSlug: options.teamSlug,\n projectSlug: options.projectSlug,\n },\n options.deploymentOptions.kind,\n );\n return {\n ...credentials,\n onActivity: null,\n };\n }\n case \"local\": {\n const credentials = await handleLocalDeployment(ctx, {\n teamSlug: options.teamSlug,\n projectSlug: options.projectSlug,\n ...options.deploymentOptions,\n });\n return credentials;\n }\n default:\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `Invalid deployment type: ${(options.deploymentOptions as any).kind}`,\n errForSentry: `Invalid deployment type: ${(options.deploymentOptions as any).kind}`,\n });\n }\n}\n\nexport async function updateEnvAndConfigForDeploymentSelection(\n ctx: Context,\n options: {\n url: string;\n deploymentName: string;\n teamSlug: string | null;\n projectSlug: string | null;\n deploymentType: DeploymentType;\n },\n existingValue: string | null,\n) {\n const { configPath, projectConfig: existingProjectConfig } =\n await readProjectConfig(ctx);\n\n const functionsPath = functionsDir(configName(), existingProjectConfig);\n\n const { wroteToGitIgnore, changedDeploymentEnvVar } =\n await writeDeploymentEnvVar(\n ctx,\n options.deploymentType,\n {\n team: options.teamSlug,\n project: options.projectSlug,\n deploymentName: options.deploymentName,\n },\n existingValue,\n );\n const projectConfig = await upgradeOldAuthInfoToAuthConfig(\n ctx,\n existingProjectConfig,\n functionsPath,\n );\n await writeProjectConfig(ctx, projectConfig, {\n deleteIfAllDefault: true,\n });\n await finalizeConfiguration(ctx, {\n deploymentType: options.deploymentType,\n deploymentName: options.deploymentName,\n url: options.url,\n wroteToGitIgnore,\n changedDeploymentEnvVar,\n functionsPath: functionsDir(configPath, projectConfig),\n });\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4B;AAE5B,iBAMO;AACP,iBASO;AACP,oBAKO;AACP,wBAIO;AACP,kBAAsC;AACtC,mBAQO;AACP,qBAAwC;AACxC,kBAAiB;AACjB,uBAAoC;AACpC,qBAAmC;AACnC,6BAAsC;AACtC,qBAIO;AACP,0BAAiC;AACjC,iCAKO;AACP,mBAA+B;AAC/B,uBAA0C;AAiD1C,eAAsB,iCACpB,KACA,qBACA,qBACA,YAUA;AACA,QAAM,qBAAqB,MAAM;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,mBAAmB,qBAAqB,MAAM;AAEhD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,QACE,KAAK,mBAAmB;AAAA,QACxB,gBAAgB,mBAAmB,iBAAiB;AAAA,QACpD,UAAU,mBAAmB,iBAAiB;AAAA,QAC9C,aAAa,mBAAmB,iBAAiB;AAAA,QACjD,gBAAgB,mBAAmB,iBAAiB;AAAA,MACtD;AAAA,UACA,wDAA4B,mBAAmB;AAAA,IACjD;AAAA,EACF,OAAO;AAEL,UAAM,gCAAgC,KAAK;AAAA,MACzC,KAAK,mBAAmB;AAAA,MACxB,UAAU,mBAAmB;AAAA,IAC/B,CAAC;AAAA,EACH;AACA,SAAO;AAAA,IACL,KAAK,mBAAmB;AAAA,IACxB,UAAU,mBAAmB;AAAA,IAC7B,kBAAkB,mBAAmB;AAAA,EACvC;AACF;AAEA,eAAsB,kCACpB,KACA,qBACA,qBACA,YAUA;AACA,QAAM,aAAS,sCAAiB,GAAG;AACnC,QAAM,qBAAqB,CAAC,CAAC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,oBAAgB,+BAAa,0BAAW,GAAG,qBAAqB;AAEtE,QAAM,EAAE,kBAAkB,wBAAwB,IAChD,UAAM;AAAA,IACJ;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,MACE,MAAM,QAAQ;AAAA,MACd,SAAS,QAAQ;AAAA,MACjB,gBAAgB,QAAQ;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AACF,QAAM,gBAAgB,UAAM;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,YAAM,kCAAmB,KAAK,eAAe;AAAA,IAC3C,oBAAoB;AAAA,EACtB,CAAC;AACD,YAAM,mCAAsB,KAAK;AAAA,IAC/B,gBAAgB,QAAQ;AAAA,IACxB,gBAAgB,QAAQ;AAAA,IACxB,KAAK,QAAQ;AAAA,IACb;AAAA,IACA;AAAA,IACA,mBAAe,2BAAa,YAAY,aAAa;AAAA,EACvD,CAAC;AACH;",
4
+ "sourcesContent": ["import { chalkStderr } from \"chalk\";\nimport { Context } from \"../bundler/context.js\";\nimport {\n logFailure,\n logFinishedStep,\n logMessage,\n logWarning,\n showSpinner,\n} from \"../bundler/log.js\";\nimport {\n DeploymentType,\n DeploymentName,\n fetchDeploymentCredentialsProvisioningDevOrProdMaybeThrows,\n createProject,\n DeploymentSelectionWithinProject,\n loadSelectedDeploymentCredentials,\n checkAccessToSelectedProject,\n validateDeploymentSelectionForExistingDeployment,\n} from \"./lib/api.js\";\nimport { readProjectConfig, writeProjectConfig } from \"./lib/config.js\";\nimport {\n DeploymentDetails,\n eraseDeploymentEnvVar,\n writeDeploymentEnvVar,\n} from \"./lib/deployment.js\";\nimport { finalizeConfiguration } from \"./lib/init.js\";\nimport {\n CONVEX_DEPLOYMENT_ENV_VAR_NAME,\n functionsDir,\n hasProjects,\n logAndHandleFetchError,\n selectDevDeploymentType,\n validateOrSelectProject,\n validateOrSelectTeam,\n} from \"./lib/utils/utils.js\";\nimport { writeConvexUrlToEnvFile } from \"./lib/envvars.js\";\nimport path from \"path\";\nimport { projectDashboardUrl } from \"./lib/dashboard.js\";\nimport { doInitConvexFolder } from \"./lib/codegen.js\";\nimport { handleLocalDeployment } from \"./lib/localDeployment/localDeployment.js\";\nimport {\n promptOptions,\n promptString,\n promptYesNo,\n} from \"./lib/utils/prompts.js\";\nimport { readGlobalConfig } from \"./lib/utils/globalConfig.js\";\nimport {\n DeploymentSelection,\n ProjectSelection,\n deploymentNameFromSelection,\n shouldAllowAnonymousDevelopment,\n} from \"./lib/deploymentSelection.js\";\nimport { ensureLoggedIn } from \"./lib/login.js\";\nimport { handleAnonymousDeployment } from \"./lib/localDeployment/anonymous.js\";\ntype DeploymentCredentials = {\n url: string;\n adminKey: string;\n};\n\ntype ChosenConfiguration =\n // `--configure new`\n | \"new\"\n // `--configure existing`\n | \"existing\"\n // `--configure`\n | \"ask\"\n // `--configure` was not specified\n | null;\n\ntype ConfigureCmdOptions = {\n selectionWithinProject: DeploymentSelectionWithinProject;\n prod: boolean;\n localOptions: {\n ports?: {\n cloud: number;\n site: number;\n };\n backendVersion?: string | undefined;\n dashboardVersion?: string | undefined;\n forceUpgrade: boolean;\n };\n team?: string | undefined;\n project?: string | undefined;\n devDeployment?: \"cloud\" | \"local\" | undefined;\n local?: boolean | undefined;\n cloud?: boolean | undefined;\n url?: string | undefined;\n adminKey?: string | undefined;\n envFile?: string | undefined;\n overrideAuthUrl?: string | undefined;\n overrideAuthClient?: string | undefined;\n overrideAuthUsername?: string | undefined;\n overrideAuthPassword?: string | undefined;\n};\n\n/**\n * As of writing, this is used by:\n * - `npx convex dev`\n * - `npx convex codegen`\n *\n * But is not used by `npx convex deploy` or other commands.\n */\nexport async function deploymentCredentialsOrConfigure(\n ctx: Context,\n deploymentSelection: DeploymentSelection,\n chosenConfiguration: ChosenConfiguration,\n cmdOptions: ConfigureCmdOptions,\n): Promise<\n DeploymentCredentials & {\n deploymentFields: {\n deploymentName: DeploymentName;\n deploymentType: DeploymentType;\n projectSlug: string | null;\n teamSlug: string | null;\n } | null;\n }\n> {\n const selectedDeployment = await _deploymentCredentialsOrConfigure(\n ctx,\n deploymentSelection,\n chosenConfiguration,\n cmdOptions,\n );\n\n if (selectedDeployment.deploymentFields !== null) {\n // Set the `CONVEX_DEPLOYMENT` env var + the `CONVEX_URL` env var\n await updateEnvAndConfigForDeploymentSelection(\n ctx,\n {\n url: selectedDeployment.url,\n deploymentName: selectedDeployment.deploymentFields.deploymentName,\n teamSlug: selectedDeployment.deploymentFields.teamSlug,\n projectSlug: selectedDeployment.deploymentFields.projectSlug,\n deploymentType: selectedDeployment.deploymentFields.deploymentType,\n },\n deploymentNameFromSelection(deploymentSelection),\n );\n } else {\n // Clear the `CONVEX_DEPLOYMENT` env var + set the `CONVEX_URL` env var\n await handleManuallySetUrlAndAdminKey(ctx, {\n url: selectedDeployment.url,\n adminKey: selectedDeployment.adminKey,\n });\n }\n return {\n url: selectedDeployment.url,\n adminKey: selectedDeployment.adminKey,\n deploymentFields: selectedDeployment.deploymentFields,\n };\n}\n\nexport async function _deploymentCredentialsOrConfigure(\n ctx: Context,\n deploymentSelection: DeploymentSelection,\n chosenConfiguration: ChosenConfiguration,\n cmdOptions: ConfigureCmdOptions,\n): Promise<\n DeploymentCredentials & {\n deploymentFields: {\n deploymentName: DeploymentName;\n deploymentType: DeploymentType;\n projectSlug: string | null;\n teamSlug: string | null;\n } | null;\n }\n> {\n const config = readGlobalConfig(ctx);\n const globallyForceCloud = !!config?.optOutOfLocalDevDeploymentsUntilBetaOver;\n if (globallyForceCloud && cmdOptions.local) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"Can't specify --local when local deployments are disabled on this machine. Run `npx convex disable-local-deployments --undo-global` to allow use of --local.\",\n });\n }\n\n switch (deploymentSelection.kind) {\n case \"existingDeployment\":\n await validateDeploymentSelectionForExistingDeployment(\n ctx,\n cmdOptions.selectionWithinProject,\n deploymentSelection.deploymentToActOn.source,\n );\n if (deploymentSelection.deploymentToActOn.deploymentFields === null) {\n // erase `CONVEX_DEPLOYMENT` from .env.local + set the url env var\n await handleManuallySetUrlAndAdminKey(ctx, {\n url: deploymentSelection.deploymentToActOn.url,\n adminKey: deploymentSelection.deploymentToActOn.adminKey,\n });\n }\n return {\n url: deploymentSelection.deploymentToActOn.url,\n adminKey: deploymentSelection.deploymentToActOn.adminKey,\n deploymentFields:\n deploymentSelection.deploymentToActOn.deploymentFields,\n };\n case \"chooseProject\": {\n await ensureLoggedIn(ctx, {\n overrideAuthUrl: cmdOptions.overrideAuthUrl,\n overrideAuthClient: cmdOptions.overrideAuthClient,\n overrideAuthUsername: cmdOptions.overrideAuthUsername,\n overrideAuthPassword: cmdOptions.overrideAuthPassword,\n });\n return await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n }\n case \"preview\":\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"Use `npx convex deploy` to use preview deployments.\",\n });\n case \"deploymentWithinProject\": {\n return await handleDeploymentWithinProject(ctx, {\n chosenConfiguration,\n targetProject: deploymentSelection.targetProject,\n cmdOptions,\n globallyForceCloud,\n });\n }\n case \"anonymous\": {\n const hasAuth = ctx.bigBrainAuth() !== null;\n const isAgentMode = process.env.CONVEX_AGENT_MODE === \"anonymous\";\n if (\n !isAgentMode &&\n hasAuth &&\n deploymentSelection.deploymentName !== null\n ) {\n const shouldConfigure =\n chosenConfiguration !== null ||\n (await promptYesNo(ctx, {\n message: `${CONVEX_DEPLOYMENT_ENV_VAR_NAME} is configured with deployment ${deploymentSelection.deploymentName}, which is not linked with your account. Would you like to choose a different project instead?`,\n }));\n if (!shouldConfigure) {\n return await ctx.crash({\n exitCode: 0,\n errorType: \"fatal\",\n printedMessage: `Run \\`npx convex login --link-deployments\\` first to link this deployment to your account, and then run \\`npx convex dev\\` again.`,\n });\n }\n return await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n }\n const alreadyHasConfiguredAnonymousDeployment =\n deploymentSelection.deploymentName !== null &&\n chosenConfiguration === null;\n if (isAgentMode) {\n logWarning(\n chalkStderr.yellow.bold(\n \"CONVEX_AGENT_MODE=anonymous mode is in beta, functionality may change in the future.\",\n ),\n );\n }\n\n const shouldPromptForLogin = isAgentMode\n ? \"no\"\n : alreadyHasConfiguredAnonymousDeployment\n ? \"no\"\n : await promptOptions(ctx, {\n message:\n \"Welcome to Convex! Would you like to login to your account?\",\n choices: [\n {\n name: \"Start without an account (run Convex locally)\",\n value: \"no\",\n },\n { name: \"Login or create an account\", value: \"yes\" },\n ],\n default: \"no\",\n });\n if (shouldPromptForLogin === \"no\") {\n const result = await handleAnonymousDeployment(ctx, {\n chosenConfiguration,\n deploymentName: deploymentSelection.deploymentName,\n ...cmdOptions.localOptions,\n });\n return {\n adminKey: result.adminKey,\n url: result.deploymentUrl,\n deploymentFields: {\n deploymentName: result.deploymentName,\n deploymentType: \"anonymous\",\n projectSlug: null,\n teamSlug: null,\n },\n };\n }\n return await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n }\n }\n}\n\nasync function handleDeploymentWithinProject(\n ctx: Context,\n {\n chosenConfiguration,\n targetProject,\n cmdOptions,\n globallyForceCloud,\n }: {\n chosenConfiguration: ChosenConfiguration;\n targetProject: ProjectSelection;\n cmdOptions: ConfigureCmdOptions;\n globallyForceCloud: boolean;\n },\n) {\n const hasAuth = ctx.bigBrainAuth() !== null;\n const loginMessage =\n hasAuth && shouldAllowAnonymousDevelopment()\n ? undefined\n : `Tip: You can try out Convex without creating an account by clearing the ${CONVEX_DEPLOYMENT_ENV_VAR_NAME} environment variable.`;\n await ensureLoggedIn(ctx, {\n message: loginMessage,\n overrideAuthUrl: cmdOptions.overrideAuthUrl,\n overrideAuthClient: cmdOptions.overrideAuthClient,\n overrideAuthUsername: cmdOptions.overrideAuthUsername,\n overrideAuthPassword: cmdOptions.overrideAuthPassword,\n });\n if (chosenConfiguration !== null) {\n const result = await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n return result;\n }\n\n const accessResult = await checkAccessToSelectedProject(ctx, targetProject);\n if (accessResult.kind === \"noAccess\") {\n logMessage(\"You don't have access to the selected project.\");\n const result = await handleChooseProject(\n ctx,\n chosenConfiguration,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n return result;\n }\n\n const selectedDeployment = await loadSelectedDeploymentCredentials(\n ctx,\n {\n kind: \"deploymentWithinProject\",\n targetProject,\n },\n cmdOptions.selectionWithinProject,\n // We'll start running it below\n { ensureLocalRunning: false },\n );\n if (\n selectedDeployment.deploymentFields !== null &&\n selectedDeployment.deploymentFields.deploymentType === \"local\"\n ) {\n // Start running the local backend\n await handleLocalDeployment(ctx, {\n teamSlug: selectedDeployment.deploymentFields.teamSlug!,\n projectSlug: selectedDeployment.deploymentFields.projectSlug!,\n forceUpgrade: cmdOptions.localOptions.forceUpgrade,\n ports: cmdOptions.localOptions.ports,\n backendVersion: cmdOptions.localOptions.backendVersion,\n });\n }\n return {\n url: selectedDeployment.url,\n adminKey: selectedDeployment.adminKey,\n deploymentFields: selectedDeployment.deploymentFields,\n };\n}\n\nasync function handleChooseProject(\n ctx: Context,\n chosenConfiguration: ChosenConfiguration,\n args: {\n globallyForceCloud: boolean;\n },\n cmdOptions: ConfigureCmdOptions,\n): Promise<\n DeploymentCredentials & {\n deploymentFields: {\n deploymentName: DeploymentName;\n deploymentType: DeploymentType;\n projectSlug: string;\n teamSlug: string;\n };\n }\n> {\n await ensureLoggedIn(ctx, {\n overrideAuthUrl: cmdOptions.overrideAuthUrl,\n overrideAuthClient: cmdOptions.overrideAuthClient,\n overrideAuthUsername: cmdOptions.overrideAuthUsername,\n overrideAuthPassword: cmdOptions.overrideAuthPassword,\n });\n const project = await selectProject(ctx, chosenConfiguration, {\n team: cmdOptions.team,\n project: cmdOptions.project,\n devDeployment: cmdOptions.devDeployment,\n local: args.globallyForceCloud ? false : cmdOptions.local,\n cloud: args.globallyForceCloud ? true : cmdOptions.cloud,\n });\n // TODO complain about any non-default cmdOptions.localOptions here\n // because we're ignoring them if this isn't a local development.\n\n const deploymentOptions: DeploymentOptions =\n cmdOptions.selectionWithinProject.kind === \"prod\"\n ? { kind: \"prod\" }\n : project.devDeployment === \"local\"\n ? { kind: \"local\", ...cmdOptions.localOptions }\n : { kind: \"dev\" };\n const {\n deploymentName,\n deploymentUrl: url,\n adminKey,\n } = await ensureDeploymentProvisioned(ctx, {\n teamSlug: project.teamSlug,\n projectSlug: project.projectSlug,\n deploymentOptions,\n });\n return {\n url,\n adminKey,\n deploymentFields: {\n deploymentName,\n deploymentType: deploymentOptions.kind,\n projectSlug: project.projectSlug,\n teamSlug: project.teamSlug,\n },\n };\n}\n\nexport async function handleManuallySetUrlAndAdminKey(\n ctx: Context,\n cmdOptions: { url: string; adminKey: string },\n) {\n const { url, adminKey } = cmdOptions;\n const didErase = await eraseDeploymentEnvVar(ctx);\n if (didErase) {\n logMessage(\n chalkStderr.yellowBright(\n `Removed the CONVEX_DEPLOYMENT environment variable from .env.local`,\n ),\n );\n }\n const envVarWrite = await writeConvexUrlToEnvFile(ctx, url);\n if (envVarWrite !== null) {\n logMessage(\n chalkStderr.green(\n `Saved the given --url as ${envVarWrite.envVar} to ${envVarWrite.envFile}`,\n ),\n );\n }\n return { url, adminKey };\n}\n\nexport async function selectProject(\n ctx: Context,\n chosenConfiguration: ChosenConfiguration,\n cmdOptions: {\n team?: string | undefined;\n project?: string | undefined;\n devDeployment?: \"cloud\" | \"local\" | undefined;\n local?: boolean | undefined;\n cloud?: boolean | undefined;\n defaultProjectName?: string | undefined;\n },\n): Promise<{\n teamSlug: string;\n projectSlug: string;\n devDeployment: \"cloud\" | \"local\";\n}> {\n // Prompt the user to select a project.\n const choice =\n chosenConfiguration !== \"ask\" && chosenConfiguration !== null\n ? chosenConfiguration\n : await askToConfigure(ctx);\n switch (choice) {\n case \"new\":\n return selectNewProject(ctx, chosenConfiguration, cmdOptions);\n case \"existing\":\n return selectExistingProject(ctx, chosenConfiguration, cmdOptions);\n default:\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"No project selected.\",\n });\n }\n}\n\nconst cwd = path.basename(process.cwd());\nasync function selectNewProject(\n ctx: Context,\n chosenConfiguration: ChosenConfiguration,\n config: {\n team?: string | undefined;\n project?: string | undefined;\n devDeployment?: \"cloud\" | \"local\" | undefined;\n cloud?: boolean | undefined;\n local?: boolean | undefined;\n defaultProjectName?: string | undefined;\n },\n) {\n const { teamSlug: selectedTeam, chosen: didChooseBetweenTeams } =\n await validateOrSelectTeam(ctx, config.team, \"Team:\");\n let projectName: string = config.project || cwd;\n let choseProjectInteractively = false;\n if (!config.project) {\n projectName = await promptString(ctx, {\n message: \"Project name:\",\n default: config.defaultProjectName || cwd,\n });\n choseProjectInteractively = true;\n }\n\n const { devDeployment } = await selectDevDeploymentType(ctx, {\n chosenConfiguration,\n newOrExisting: \"new\",\n teamSlug: selectedTeam,\n userHasChosenSomethingInteractively:\n didChooseBetweenTeams || choseProjectInteractively,\n projectSlug: undefined,\n devDeploymentFromFlag: config.devDeployment,\n forceDevDeployment: config.local\n ? \"local\"\n : config.cloud\n ? \"cloud\"\n : undefined,\n });\n\n showSpinner(\"Creating new Convex project...\");\n\n let projectSlug, teamSlug, projectsRemaining;\n try {\n ({ projectSlug, teamSlug, projectsRemaining } = await createProject(ctx, {\n teamSlug: selectedTeam,\n projectName,\n // We have to create some deployment initially for a project.\n deploymentTypeToProvision: devDeployment === \"local\" ? \"prod\" : \"dev\",\n }));\n } catch (err) {\n logFailure(\"Unable to create project.\");\n return await logAndHandleFetchError(ctx, err);\n }\n const teamMessage = didChooseBetweenTeams\n ? \" in team \" + chalkStderr.bold(teamSlug)\n : \"\";\n logFinishedStep(\n `Created project ${chalkStderr.bold(\n projectSlug,\n )}${teamMessage}, manage it at ${chalkStderr.bold(\n projectDashboardUrl(teamSlug, projectSlug),\n )}`,\n );\n\n if (projectsRemaining <= 2) {\n logWarning(\n chalkStderr.yellow.bold(\n `Your account now has ${projectsRemaining} project${\n projectsRemaining === 1 ? \"\" : \"s\"\n } remaining.`,\n ),\n );\n }\n\n await doInitConvexFolder(ctx);\n return { teamSlug, projectSlug, devDeployment };\n}\n\nasync function selectExistingProject(\n ctx: Context,\n chosenConfiguration: ChosenConfiguration,\n config: {\n team?: string | undefined;\n project?: string | undefined;\n devDeployment?: \"cloud\" | \"local\" | undefined;\n local?: boolean | undefined;\n cloud?: boolean | undefined;\n },\n): Promise<{\n teamSlug: string;\n projectSlug: string;\n devDeployment: \"cloud\" | \"local\";\n}> {\n const { teamSlug, chosen } = await validateOrSelectTeam(\n ctx,\n config.team,\n \"Team:\",\n );\n\n const projectSlug = await validateOrSelectProject(\n ctx,\n config.project,\n teamSlug,\n \"Configure project\",\n \"Project:\",\n );\n if (projectSlug === null) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"Run the command again to create a new project instead.\",\n });\n }\n const { devDeployment } = await selectDevDeploymentType(ctx, {\n chosenConfiguration,\n newOrExisting: \"existing\",\n teamSlug,\n projectSlug,\n userHasChosenSomethingInteractively: chosen || !config.project,\n devDeploymentFromFlag: config.devDeployment,\n forceDevDeployment: config.local\n ? \"local\"\n : config.cloud\n ? \"cloud\"\n : undefined,\n });\n\n logFinishedStep(`Reinitialized project ${chalkStderr.bold(projectSlug)}`);\n return { teamSlug, projectSlug, devDeployment };\n}\n\nasync function askToConfigure(ctx: Context): Promise<\"new\" | \"existing\"> {\n if (!(await hasProjects(ctx))) {\n return \"new\";\n }\n return await promptOptions(ctx, {\n message: \"What would you like to configure?\",\n default: \"new\",\n choices: [\n { name: \"create a new project\", value: \"new\" },\n { name: \"choose an existing project\", value: \"existing\" },\n ],\n });\n}\n\ntype DeploymentOptions =\n | {\n kind: \"prod\";\n }\n | { kind: \"dev\" }\n | {\n kind: \"local\";\n ports?:\n | {\n cloud: number;\n site: number;\n }\n | undefined;\n backendVersion?: string | undefined;\n forceUpgrade: boolean;\n };\n\n/**\n * This method assumes that the member has access to the selected project.\n */\nasync function ensureDeploymentProvisioned(\n ctx: Context,\n options: {\n teamSlug: string;\n projectSlug: string;\n deploymentOptions: DeploymentOptions;\n },\n): Promise<DeploymentDetails> {\n switch (options.deploymentOptions.kind) {\n case \"dev\":\n case \"prod\": {\n const credentials =\n await fetchDeploymentCredentialsProvisioningDevOrProdMaybeThrows(\n ctx,\n {\n kind: \"teamAndProjectSlugs\",\n teamSlug: options.teamSlug,\n projectSlug: options.projectSlug,\n },\n options.deploymentOptions.kind,\n );\n return {\n ...credentials,\n onActivity: null,\n };\n }\n case \"local\": {\n const credentials = await handleLocalDeployment(ctx, {\n teamSlug: options.teamSlug,\n projectSlug: options.projectSlug,\n ...options.deploymentOptions,\n });\n return credentials;\n }\n default:\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `Invalid deployment type: ${(options.deploymentOptions as any).kind}`,\n errForSentry: `Invalid deployment type: ${(options.deploymentOptions as any).kind}`,\n });\n }\n}\n\nexport async function updateEnvAndConfigForDeploymentSelection(\n ctx: Context,\n options: {\n url: string;\n deploymentName: string;\n teamSlug: string | null;\n projectSlug: string | null;\n deploymentType: DeploymentType;\n },\n existingValue: string | null,\n) {\n const { configPath, projectConfig } = await readProjectConfig(ctx);\n\n const { wroteToGitIgnore, changedDeploymentEnvVar } =\n await writeDeploymentEnvVar(\n ctx,\n options.deploymentType,\n {\n team: options.teamSlug,\n project: options.projectSlug,\n deploymentName: options.deploymentName,\n },\n existingValue,\n );\n await writeProjectConfig(ctx, projectConfig);\n await finalizeConfiguration(ctx, {\n deploymentType: options.deploymentType,\n deploymentName: options.deploymentName,\n url: options.url,\n wroteToGitIgnore,\n changedDeploymentEnvVar,\n functionsPath: functionsDir(configPath, projectConfig),\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;A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kCAAmB,KAAK,aAAa;AAC3C,YAAM,mCAAsB,KAAK;AAAA,IAC/B,gBAAgB,QAAQ;AAAA,IACxB,gBAAgB,QAAQ;AAAA,IACxB,KAAK,QAAQ;AAAA,IACb;AAAA,IACA;AAAA,IACA,mBAAe,2BAAa,YAAY,aAAa;AAAA,EACvD,CAAC;AACH;",
6
6
  "names": ["path"]
7
7
  }
@@ -37,6 +37,8 @@ var import_deploy2 = require("./lib/deploy2.js");
37
37
  var import_deploymentSelection = require("./lib/deploymentSelection.js");
38
38
  var import_deploymentSelection2 = require("./lib/deploymentSelection.js");
39
39
  var import_updates = require("./lib/updates.js");
40
+ var import_config = require("./lib/config.js");
41
+ var import_workos = require("./lib/workos/workos.js");
40
42
  const deploy = new import_extra_typings.Command("deploy").summary("Deploy to your prod deployment").description(
41
43
  `Deploy to your deployment. By default, this deploys to your prod deployment.
42
44
 
@@ -171,13 +173,24 @@ async function deployToNewPreviewDeployment(ctx, deploymentSelection, options) {
171
173
  });
172
174
  const previewAdminKey = data.adminKey;
173
175
  const previewUrl = data.instanceUrl;
176
+ const deploymentNameForWorkOS = previewUrl.match(/https:\/\/([^.]+)\.convex\.cloud/)?.[1] ?? null;
177
+ const { projectConfig } = await (0, import_config.readProjectConfig)(ctx);
178
+ const authKitConfig = await (0, import_config.getAuthKitConfig)(ctx, projectConfig);
179
+ if (authKitConfig && deploymentNameForWorkOS) {
180
+ await (0, import_workos.ensureAuthKitProvisionedBeforeBuild)(
181
+ ctx,
182
+ deploymentNameForWorkOS,
183
+ { deploymentUrl: previewUrl, adminKey: previewAdminKey },
184
+ "preview"
185
+ );
186
+ }
174
187
  await (0, import_deploy2.runCommand)(ctx, {
175
188
  ...options,
176
189
  url: previewUrl,
177
190
  adminKey: previewAdminKey
178
191
  });
179
192
  const pushOptions = {
180
- deploymentName: data.deploymentName,
193
+ deploymentName: null,
181
194
  adminKey: previewAdminKey,
182
195
  verbose: !!options.verbose,
183
196
  dryRun: false,
@@ -249,7 +262,8 @@ async function deployToExistingDeployment(ctx, options) {
249
262
  {
250
263
  url: deploymentToActOn.url,
251
264
  adminKey: deploymentToActOn.adminKey,
252
- deploymentName: deploymentFields?.deploymentName ?? null
265
+ deploymentName: deploymentFields?.deploymentName ?? null,
266
+ ...deploymentFields?.deploymentType !== void 0 ? { deploymentType: deploymentFields.deploymentType } : {}
253
267
  },
254
268
  options
255
269
  ),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/deploy.ts"],
4
- "sourcesContent": ["import { chalkStderr } from \"chalk\";\nimport { Command, Option } from \"@commander-js/extra-typings\";\nimport { Context, oneoffContext } from \"../bundler/context.js\";\nimport { logFinishedStep, logMessage, showSpinner } from \"../bundler/log.js\";\nimport {\n deploymentSelectionWithinProjectFromOptions,\n loadSelectedDeploymentCredentials,\n} from \"./lib/api.js\";\nimport {\n gitBranchFromEnvironment,\n isNonProdBuildEnvironment,\n suggestedEnvVarName,\n} from \"./lib/envvars.js\";\nimport { PushOptions } from \"./lib/components.js\";\nimport {\n CONVEX_DEPLOY_KEY_ENV_VAR_NAME,\n CONVEX_SELF_HOSTED_URL_VAR_NAME,\n CONVEX_DEPLOYMENT_ENV_VAR_NAME,\n bigBrainAPI,\n} from \"./lib/utils/utils.js\";\nimport { runFunctionAndLog } from \"./lib/run.js\";\nimport { usageStateWarning } from \"./lib/usage.js\";\nimport { getTeamAndProjectFromPreviewAdminKey } from \"./lib/deployment.js\";\nimport { runPush } from \"./lib/components.js\";\nimport { promptYesNo } from \"./lib/utils/prompts.js\";\nimport { deployToDeployment, runCommand } from \"./lib/deploy2.js\";\nimport { getDeploymentSelection } from \"./lib/deploymentSelection.js\";\nimport { deploymentNameAndTypeFromSelection } from \"./lib/deploymentSelection.js\";\nimport { checkVersion } from \"./lib/updates.js\";\nexport const deploy = new Command(\"deploy\")\n .summary(\"Deploy to your prod deployment\")\n .description(\n \"Deploy to your deployment. By default, this deploys to your prod deployment.\\n\\n\" +\n `Deploys to a preview deployment if the \\`${CONVEX_DEPLOY_KEY_ENV_VAR_NAME}\\` environment variable is set to a Preview Deploy Key.`,\n )\n .allowExcessArguments(false)\n .addDeployOptions()\n .addOption(\n new Option(\n \"--preview-run <functionName>\",\n \"Function to run if deploying to a preview deployment. This is ignored if deploying to a production deployment.\",\n ),\n )\n .addOption(\n new Option(\n \"--preview-create <name>\",\n \"The name to associate with this deployment if deploying to a newly created preview deployment. Defaults to the current Git branch name in Vercel, Netlify and GitHub CI. This parameter can only be used with a preview deploy key (when used with another type of key, the command will return an error).\",\n ).conflicts(\"preview-name\"),\n )\n .addOption(\n new Option(\n \"--check-build-environment <mode>\",\n \"Whether to check for a non-production build environment before deploying to a production Convex deployment.\",\n )\n .choices([\"enable\", \"disable\"] as const)\n .default(\"enable\" as const)\n .hideHelp(),\n )\n // Hidden options to pass in admin key and url for tests and local development\n .addOption(new Option(\"--admin-key <adminKey>\").hideHelp())\n .addOption(new Option(\"--url <url>\").hideHelp())\n .addOption(\n new Option(\n \"--preview-name <name>\",\n \"[deprecated] Use `--preview-create` instead. The name to associate with this deployment if deploying to a preview deployment.\",\n )\n .hideHelp()\n .conflicts(\"preview-create\"),\n )\n .addOption(\n new Option(\n \"--env-file <envFile>\",\n `Path to a custom file of environment variables, for choosing the \\\ndeployment, e.g. ${CONVEX_DEPLOYMENT_ENV_VAR_NAME} or ${CONVEX_SELF_HOSTED_URL_VAR_NAME}. \\\nSame format as .env.local or .env files, and overrides them.`,\n ),\n )\n .addOption(\n new Option(\"--allow-deleting-large-indexes\")\n .hideHelp()\n .conflicts(\"preview-create\")\n .conflicts(\"preview-name\"),\n )\n .showHelpAfterError()\n .action(async (cmdOptions) => {\n const ctx = await oneoffContext(cmdOptions);\n\n const deploymentSelection = await getDeploymentSelection(ctx, cmdOptions);\n if (\n cmdOptions.checkBuildEnvironment === \"enable\" &&\n isNonProdBuildEnvironment() &&\n deploymentSelection.kind === \"existingDeployment\" &&\n deploymentSelection.deploymentToActOn.source === \"deployKey\" &&\n deploymentSelection.deploymentToActOn.deploymentFields?.deploymentType ===\n \"prod\"\n ) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Detected a non-production build environment and \"${CONVEX_DEPLOY_KEY_ENV_VAR_NAME}\" for a production Convex deployment.\\n\n This is probably unintentional.\n `,\n });\n }\n\n if (deploymentSelection.kind === \"anonymous\") {\n logMessage(\n \"You are currently developing anonymously with a locally running project.\\n\" +\n \"To deploy your Convex app to the cloud, log in by running `npx convex login`.\\n\" +\n \"See https://docs.convex.dev/production for more information on how Convex cloud works and instructions on how to set up hosting.\",\n );\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: null,\n });\n }\n\n if (deploymentSelection.kind === \"preview\") {\n // TODO -- add usage state warnings here too once we can do it without a deployment name\n // await usageStateWarning(ctx);\n if (cmdOptions.previewName !== undefined) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"The `--preview-name` flag has been deprecated in favor of `--preview-create`. Please re-run the command using `--preview-create` instead.\",\n });\n }\n\n const teamAndProjectSlugs = await getTeamAndProjectFromPreviewAdminKey(\n ctx,\n deploymentSelection.previewDeployKey,\n );\n await deployToNewPreviewDeployment(\n ctx,\n {\n previewDeployKey: deploymentSelection.previewDeployKey,\n projectSelection: {\n kind: \"teamAndProjectSlugs\",\n teamSlug: teamAndProjectSlugs.teamSlug,\n projectSlug: teamAndProjectSlugs.projectSlug,\n },\n },\n {\n ...cmdOptions,\n },\n );\n } else {\n if (cmdOptions.previewCreate !== undefined) {\n const source =\n deploymentSelection.kind === \"deploymentWithinProject\" &&\n deploymentSelection.targetProject.kind === \"deploymentName\"\n ? `at ${chalkStderr.blue.underline(`https://dashboard.convex.dev/dp/${deploymentSelection.targetProject.deploymentName}/settings#preview-deploy-keys`)}`\n : deploymentSelection.kind === \"existingDeployment\" &&\n deploymentSelection.deploymentToActOn.deploymentFields !== null\n ? `at ${chalkStderr.blue.underline(`https://dashboard.convex.dev/dp/${deploymentSelection.deploymentToActOn.deploymentFields.deploymentName}/settings#preview-deploy-keys`)}`\n : \"on the dashboard\";\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `Preview deployments can only be created with preview deploy keys. Generate a preview deploy key ${source} and set the ${chalkStderr.bold(`CONVEX_DEPLOY_KEY`)} environment variable with it.`,\n });\n }\n\n await deployToExistingDeployment(ctx, {\n ...cmdOptions,\n allowDeletingLargeIndexes:\n cmdOptions.allowDeletingLargeIndexes ?? false,\n });\n }\n });\n\nasync function deployToNewPreviewDeployment(\n ctx: Context,\n deploymentSelection: {\n previewDeployKey: string;\n projectSelection: {\n kind: \"teamAndProjectSlugs\";\n teamSlug: string;\n projectSlug: string;\n };\n },\n options: {\n dryRun?: boolean | undefined;\n previewCreate?: string | undefined;\n previewRun?: string | undefined;\n cmdUrlEnvVarName?: string | undefined;\n cmd?: string | undefined;\n verbose?: boolean | undefined;\n typecheck: \"enable\" | \"try\" | \"disable\";\n typecheckComponents: boolean;\n codegen: \"enable\" | \"disable\";\n\n debug?: boolean | undefined;\n debugBundlePath?: string | undefined;\n },\n) {\n const previewName = options.previewCreate ?? gitBranchFromEnvironment();\n if (previewName === null) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"`npx convex deploy` to a preview deployment could not determine the preview name. Provide one using `--preview-create`\",\n });\n }\n\n if (options.dryRun) {\n logFinishedStep(\n `Would have claimed preview deployment for \"${previewName}\"`,\n );\n await runCommand(ctx, {\n cmdUrlEnvVarName: options.cmdUrlEnvVarName,\n cmd: options.cmd,\n dryRun: !!options.dryRun,\n url: \"https://<PREVIEW DEPLOYMENT>.convex.cloud\",\n adminKey: \"preview-deployment-admin-key\",\n });\n logFinishedStep(\n `Would have deployed Convex functions to preview deployment for \"${previewName}\"`,\n );\n if (options.previewRun !== undefined) {\n logMessage(`Would have run function \"${options.previewRun}\"`);\n }\n return;\n }\n const data = await bigBrainAPI({\n ctx,\n method: \"POST\",\n url: \"claim_preview_deployment\",\n data: {\n projectSelection: deploymentSelection.projectSelection,\n identifier: previewName,\n },\n });\n\n const previewAdminKey = data.adminKey;\n const previewUrl = data.instanceUrl;\n\n await runCommand(ctx, {\n ...options,\n url: previewUrl,\n adminKey: previewAdminKey,\n });\n\n const pushOptions: PushOptions = {\n deploymentName: data.deploymentName,\n adminKey: previewAdminKey,\n verbose: !!options.verbose,\n dryRun: false,\n typecheck: options.typecheck,\n typecheckComponents: options.typecheckComponents,\n debug: !!options.debug,\n debugBundlePath: options.debugBundlePath,\n debugNodeApis: false,\n codegen: options.codegen === \"enable\",\n url: previewUrl,\n liveComponentSources: false,\n largeIndexDeletionCheck: \"no verification\", // fine for preview deployments\n };\n showSpinner(`Deploying to ${previewUrl}...`);\n await runPush(ctx, pushOptions);\n logFinishedStep(`Deployed Convex functions to ${previewUrl}`);\n\n if (options.previewRun !== undefined) {\n await runFunctionAndLog(ctx, {\n deploymentUrl: previewUrl,\n adminKey: previewAdminKey,\n functionName: options.previewRun,\n argsString: \"{}\",\n componentPath: undefined,\n callbacks: {\n onSuccess: () => {\n logFinishedStep(`Finished running function \"${options.previewRun}\"`);\n },\n },\n });\n }\n}\n\nasync function deployToExistingDeployment(\n ctx: Context,\n options: {\n verbose?: boolean | undefined;\n dryRun?: boolean | undefined;\n yes?: boolean | undefined;\n typecheck: \"enable\" | \"try\" | \"disable\";\n typecheckComponents: boolean;\n codegen: \"enable\" | \"disable\";\n cmd?: string | undefined;\n cmdUrlEnvVarName?: string | undefined;\n\n debugBundlePath?: string | undefined;\n debug?: boolean | undefined;\n adminKey?: string | undefined;\n url?: string | undefined;\n writePushRequest?: string | undefined;\n liveComponentSources?: boolean | undefined;\n envFile?: string | undefined;\n allowDeletingLargeIndexes: boolean;\n },\n) {\n const selectionWithinProject = deploymentSelectionWithinProjectFromOptions({\n ...options,\n implicitProd: true,\n });\n const deploymentSelection = await getDeploymentSelection(ctx, options);\n const deploymentToActOn = await loadSelectedDeploymentCredentials(\n ctx,\n deploymentSelection,\n selectionWithinProject,\n );\n const { deploymentFields } = deploymentToActOn;\n\n const configuredDeployment =\n deploymentNameAndTypeFromSelection(deploymentSelection);\n if (configuredDeployment !== null && configuredDeployment.name !== null) {\n const shouldPushToProd =\n configuredDeployment.name === deploymentFields?.deploymentName ||\n (options.yes ??\n (await askToConfirmPush(\n ctx,\n {\n configuredName: configuredDeployment.name,\n configuredType: configuredDeployment.type,\n requestedName: deploymentFields?.deploymentName!,\n requestedType: deploymentFields?.deploymentType!,\n },\n deploymentToActOn.url,\n )));\n if (!shouldPushToProd) {\n await ctx.crash({\n exitCode: 1,\n printedMessage: null,\n errorType: \"fatal\",\n });\n }\n }\n\n const isCloudDeployment = deploymentFields !== null;\n await Promise.all([\n deployToDeployment(\n ctx,\n {\n url: deploymentToActOn.url,\n adminKey: deploymentToActOn.adminKey,\n deploymentName: deploymentFields?.deploymentName ?? null,\n },\n options,\n ),\n ...(isCloudDeployment\n ? [\n usageStateWarning(ctx, deploymentFields.deploymentName),\n checkVersion(),\n ]\n : []),\n ]);\n}\n\nasync function askToConfirmPush(\n ctx: Context,\n deployment: {\n configuredName: string;\n configuredType: string | null;\n requestedName: string;\n requestedType: string;\n },\n prodUrl: string,\n) {\n logMessage(\n `\\\nYou're currently developing against your ${chalkStderr.bold(\n deployment.configuredType ?? \"dev\",\n )} deployment\n\n ${deployment.configuredName} (set in CONVEX_DEPLOYMENT)\n\nYour ${chalkStderr.bold(deployment.requestedType)} deployment ${chalkStderr.bold(\n deployment.requestedName,\n )} serves traffic at:\n\n ${(await suggestedEnvVarName(ctx)).envVar}=${chalkStderr.bold(prodUrl)}\n\nMake sure that your published client is configured with this URL (for instructions see https://docs.convex.dev/hosting)\\n`,\n );\n return promptYesNo(ctx, {\n message: `Do you want to push your code to your ${deployment.requestedType} deployment ${deployment.requestedName} now?`,\n default: true,\n });\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AA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A,kBAAkB;AAAA,IACpB;AACJ,QAAI,CAAC,kBAAkB;AACrB,YAAM,IAAI,MAAM;AAAA,QACd,UAAU;AAAA,QACV,gBAAgB;AAAA,QAChB,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,QAAQ,IAAI;AAAA,QAChB;AAAA,MACE;AAAA,MACA;AAAA,QACE,KAAK,kBAAkB;AAAA,QACvB,UAAU,kBAAkB;AAAA,QAC5B,gBAAgB,kBAAkB,kBAAkB;AAAA,MACtD;AAAA,MACA;AAAA,IACF;AAAA,IACA,GAAI,oBACA;AAAA,UACE,gCAAkB,KAAK,iBAAiB,cAAc;AAAA,UACtD,6BAAa;AAAA,IACf,IACA,CAAC;AAAA,EACP,CAAC;AACH;AAEA,eAAe,iBACb,KACA,YAMA,SACA;AACA;AAAA,IACE,4CACuC,yBAAY;AAAA,MACjD,WAAW,kBAAkB;AAAA,IAC/B,CAAC;AAAA;AAAA,IAED,WAAW,cAAc;AAAA;AAAA,OAEtB,yBAAY,KAAK,WAAW,aAAa,CAAC,eAAe,yBAAY;AAAA,MACtE,WAAW;AAAA,IACb,CAAC;AAAA;AAAA,KAEA,UAAM,oCAAoB,GAAG,GAAG,MAAM,IAAI,yBAAY,KAAK,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA,EAGtE;AACA,aAAO,4BAAY,KAAK;AAAA,IACtB,SAAS,yCAAyC,WAAW,aAAa,eAAe,WAAW,aAAa;AAAA,IACjH,SAAS;AAAA,EACX,CAAC;AACH;",
4
+ "sourcesContent": ["import { chalkStderr } from \"chalk\";\nimport { Command, Option } from \"@commander-js/extra-typings\";\nimport { Context, oneoffContext } from \"../bundler/context.js\";\nimport { logFinishedStep, logMessage, showSpinner } from \"../bundler/log.js\";\nimport {\n deploymentSelectionWithinProjectFromOptions,\n loadSelectedDeploymentCredentials,\n} from \"./lib/api.js\";\nimport {\n gitBranchFromEnvironment,\n isNonProdBuildEnvironment,\n suggestedEnvVarName,\n} from \"./lib/envvars.js\";\nimport { PushOptions } from \"./lib/components.js\";\nimport {\n CONVEX_DEPLOY_KEY_ENV_VAR_NAME,\n CONVEX_SELF_HOSTED_URL_VAR_NAME,\n CONVEX_DEPLOYMENT_ENV_VAR_NAME,\n bigBrainAPI,\n} from \"./lib/utils/utils.js\";\nimport { runFunctionAndLog } from \"./lib/run.js\";\nimport { usageStateWarning } from \"./lib/usage.js\";\nimport { getTeamAndProjectFromPreviewAdminKey } from \"./lib/deployment.js\";\nimport { runPush } from \"./lib/components.js\";\nimport { promptYesNo } from \"./lib/utils/prompts.js\";\nimport { deployToDeployment, runCommand } from \"./lib/deploy2.js\";\nimport { getDeploymentSelection } from \"./lib/deploymentSelection.js\";\nimport { deploymentNameAndTypeFromSelection } from \"./lib/deploymentSelection.js\";\nimport { checkVersion } from \"./lib/updates.js\";\nimport { readProjectConfig, getAuthKitConfig } from \"./lib/config.js\";\nimport { ensureAuthKitProvisionedBeforeBuild } from \"./lib/workos/workos.js\";\nexport const deploy = new Command(\"deploy\")\n .summary(\"Deploy to your prod deployment\")\n .description(\n \"Deploy to your deployment. By default, this deploys to your prod deployment.\\n\\n\" +\n `Deploys to a preview deployment if the \\`${CONVEX_DEPLOY_KEY_ENV_VAR_NAME}\\` environment variable is set to a Preview Deploy Key.`,\n )\n .allowExcessArguments(false)\n .addDeployOptions()\n .addOption(\n new Option(\n \"--preview-run <functionName>\",\n \"Function to run if deploying to a preview deployment. This is ignored if deploying to a production deployment.\",\n ),\n )\n .addOption(\n new Option(\n \"--preview-create <name>\",\n \"The name to associate with this deployment if deploying to a newly created preview deployment. Defaults to the current Git branch name in Vercel, Netlify and GitHub CI. This parameter can only be used with a preview deploy key (when used with another type of key, the command will return an error).\",\n ).conflicts(\"preview-name\"),\n )\n .addOption(\n new Option(\n \"--check-build-environment <mode>\",\n \"Whether to check for a non-production build environment before deploying to a production Convex deployment.\",\n )\n .choices([\"enable\", \"disable\"] as const)\n .default(\"enable\" as const)\n .hideHelp(),\n )\n // Hidden options to pass in admin key and url for tests and local development\n .addOption(new Option(\"--admin-key <adminKey>\").hideHelp())\n .addOption(new Option(\"--url <url>\").hideHelp())\n .addOption(\n new Option(\n \"--preview-name <name>\",\n \"[deprecated] Use `--preview-create` instead. The name to associate with this deployment if deploying to a preview deployment.\",\n )\n .hideHelp()\n .conflicts(\"preview-create\"),\n )\n .addOption(\n new Option(\n \"--env-file <envFile>\",\n `Path to a custom file of environment variables, for choosing the \\\ndeployment, e.g. ${CONVEX_DEPLOYMENT_ENV_VAR_NAME} or ${CONVEX_SELF_HOSTED_URL_VAR_NAME}. \\\nSame format as .env.local or .env files, and overrides them.`,\n ),\n )\n .addOption(\n new Option(\"--allow-deleting-large-indexes\")\n .hideHelp()\n .conflicts(\"preview-create\")\n .conflicts(\"preview-name\"),\n )\n .showHelpAfterError()\n .action(async (cmdOptions) => {\n const ctx = await oneoffContext(cmdOptions);\n\n const deploymentSelection = await getDeploymentSelection(ctx, cmdOptions);\n if (\n cmdOptions.checkBuildEnvironment === \"enable\" &&\n isNonProdBuildEnvironment() &&\n deploymentSelection.kind === \"existingDeployment\" &&\n deploymentSelection.deploymentToActOn.source === \"deployKey\" &&\n deploymentSelection.deploymentToActOn.deploymentFields?.deploymentType ===\n \"prod\"\n ) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"invalid filesystem data\",\n printedMessage: `Detected a non-production build environment and \"${CONVEX_DEPLOY_KEY_ENV_VAR_NAME}\" for a production Convex deployment.\\n\n This is probably unintentional.\n `,\n });\n }\n\n if (deploymentSelection.kind === \"anonymous\") {\n logMessage(\n \"You are currently developing anonymously with a locally running project.\\n\" +\n \"To deploy your Convex app to the cloud, log in by running `npx convex login`.\\n\" +\n \"See https://docs.convex.dev/production for more information on how Convex cloud works and instructions on how to set up hosting.\",\n );\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: null,\n });\n }\n\n if (deploymentSelection.kind === \"preview\") {\n // TODO -- add usage state warnings here too once we can do it without a deployment name\n // await usageStateWarning(ctx);\n if (cmdOptions.previewName !== undefined) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"The `--preview-name` flag has been deprecated in favor of `--preview-create`. Please re-run the command using `--preview-create` instead.\",\n });\n }\n\n const teamAndProjectSlugs = await getTeamAndProjectFromPreviewAdminKey(\n ctx,\n deploymentSelection.previewDeployKey,\n );\n await deployToNewPreviewDeployment(\n ctx,\n {\n previewDeployKey: deploymentSelection.previewDeployKey,\n projectSelection: {\n kind: \"teamAndProjectSlugs\",\n teamSlug: teamAndProjectSlugs.teamSlug,\n projectSlug: teamAndProjectSlugs.projectSlug,\n },\n },\n {\n ...cmdOptions,\n },\n );\n } else {\n if (cmdOptions.previewCreate !== undefined) {\n const source =\n deploymentSelection.kind === \"deploymentWithinProject\" &&\n deploymentSelection.targetProject.kind === \"deploymentName\"\n ? `at ${chalkStderr.blue.underline(`https://dashboard.convex.dev/dp/${deploymentSelection.targetProject.deploymentName}/settings#preview-deploy-keys`)}`\n : deploymentSelection.kind === \"existingDeployment\" &&\n deploymentSelection.deploymentToActOn.deploymentFields !== null\n ? `at ${chalkStderr.blue.underline(`https://dashboard.convex.dev/dp/${deploymentSelection.deploymentToActOn.deploymentFields.deploymentName}/settings#preview-deploy-keys`)}`\n : \"on the dashboard\";\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `Preview deployments can only be created with preview deploy keys. Generate a preview deploy key ${source} and set the ${chalkStderr.bold(`CONVEX_DEPLOY_KEY`)} environment variable with it.`,\n });\n }\n\n await deployToExistingDeployment(ctx, {\n ...cmdOptions,\n allowDeletingLargeIndexes:\n cmdOptions.allowDeletingLargeIndexes ?? false,\n });\n }\n });\n\nasync function deployToNewPreviewDeployment(\n ctx: Context,\n deploymentSelection: {\n previewDeployKey: string;\n projectSelection: {\n kind: \"teamAndProjectSlugs\";\n teamSlug: string;\n projectSlug: string;\n };\n },\n options: {\n dryRun?: boolean | undefined;\n previewCreate?: string | undefined;\n previewRun?: string | undefined;\n cmdUrlEnvVarName?: string | undefined;\n cmd?: string | undefined;\n verbose?: boolean | undefined;\n typecheck: \"enable\" | \"try\" | \"disable\";\n typecheckComponents: boolean;\n codegen: \"enable\" | \"disable\";\n\n debug?: boolean | undefined;\n debugBundlePath?: string | undefined;\n },\n) {\n const previewName = options.previewCreate ?? gitBranchFromEnvironment();\n if (previewName === null) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"`npx convex deploy` to a preview deployment could not determine the preview name. Provide one using `--preview-create`\",\n });\n }\n\n if (options.dryRun) {\n logFinishedStep(\n `Would have claimed preview deployment for \"${previewName}\"`,\n );\n await runCommand(ctx, {\n cmdUrlEnvVarName: options.cmdUrlEnvVarName,\n cmd: options.cmd,\n dryRun: !!options.dryRun,\n url: \"https://<PREVIEW DEPLOYMENT>.convex.cloud\",\n adminKey: \"preview-deployment-admin-key\",\n });\n logFinishedStep(\n `Would have deployed Convex functions to preview deployment for \"${previewName}\"`,\n );\n if (options.previewRun !== undefined) {\n logMessage(`Would have run function \"${options.previewRun}\"`);\n }\n return;\n }\n const data = await bigBrainAPI({\n ctx,\n method: \"POST\",\n url: \"claim_preview_deployment\",\n data: {\n projectSelection: deploymentSelection.projectSelection,\n identifier: previewName,\n },\n });\n\n const previewAdminKey = data.adminKey;\n const previewUrl = data.instanceUrl;\n\n // Extract deployment name from URL for WorkOS provisioning\n const deploymentNameForWorkOS =\n previewUrl.match(/https:\\/\\/([^.]+)\\.convex\\.cloud/)?.[1] ?? null;\n\n // Provision WorkOS before building the client bundle (if configured)\n const { projectConfig } = await readProjectConfig(ctx);\n const authKitConfig = await getAuthKitConfig(ctx, projectConfig);\n\n if (authKitConfig && deploymentNameForWorkOS) {\n await ensureAuthKitProvisionedBeforeBuild(\n ctx,\n deploymentNameForWorkOS,\n { deploymentUrl: previewUrl, adminKey: previewAdminKey },\n \"preview\",\n );\n }\n\n await runCommand(ctx, {\n ...options,\n url: previewUrl,\n adminKey: previewAdminKey,\n });\n\n const pushOptions: PushOptions = {\n deploymentName: null,\n adminKey: previewAdminKey,\n verbose: !!options.verbose,\n dryRun: false,\n typecheck: options.typecheck,\n typecheckComponents: options.typecheckComponents,\n debug: !!options.debug,\n debugBundlePath: options.debugBundlePath,\n debugNodeApis: false,\n codegen: options.codegen === \"enable\",\n url: previewUrl,\n liveComponentSources: false,\n largeIndexDeletionCheck: \"no verification\", // fine for preview deployments\n };\n showSpinner(`Deploying to ${previewUrl}...`);\n await runPush(ctx, pushOptions);\n logFinishedStep(`Deployed Convex functions to ${previewUrl}`);\n\n if (options.previewRun !== undefined) {\n await runFunctionAndLog(ctx, {\n deploymentUrl: previewUrl,\n adminKey: previewAdminKey,\n functionName: options.previewRun,\n argsString: \"{}\",\n componentPath: undefined,\n callbacks: {\n onSuccess: () => {\n logFinishedStep(`Finished running function \"${options.previewRun}\"`);\n },\n },\n });\n }\n}\n\nasync function deployToExistingDeployment(\n ctx: Context,\n options: {\n verbose?: boolean | undefined;\n dryRun?: boolean | undefined;\n yes?: boolean | undefined;\n typecheck: \"enable\" | \"try\" | \"disable\";\n typecheckComponents: boolean;\n codegen: \"enable\" | \"disable\";\n cmd?: string | undefined;\n cmdUrlEnvVarName?: string | undefined;\n\n debugBundlePath?: string | undefined;\n debug?: boolean | undefined;\n adminKey?: string | undefined;\n url?: string | undefined;\n writePushRequest?: string | undefined;\n liveComponentSources?: boolean | undefined;\n envFile?: string | undefined;\n allowDeletingLargeIndexes: boolean;\n },\n) {\n const selectionWithinProject = deploymentSelectionWithinProjectFromOptions({\n ...options,\n implicitProd: true,\n });\n const deploymentSelection = await getDeploymentSelection(ctx, options);\n const deploymentToActOn = await loadSelectedDeploymentCredentials(\n ctx,\n deploymentSelection,\n selectionWithinProject,\n );\n const { deploymentFields } = deploymentToActOn;\n\n const configuredDeployment =\n deploymentNameAndTypeFromSelection(deploymentSelection);\n if (configuredDeployment !== null && configuredDeployment.name !== null) {\n const shouldPushToProd =\n configuredDeployment.name === deploymentFields?.deploymentName ||\n (options.yes ??\n (await askToConfirmPush(\n ctx,\n {\n configuredName: configuredDeployment.name,\n configuredType: configuredDeployment.type,\n requestedName: deploymentFields?.deploymentName!,\n requestedType: deploymentFields?.deploymentType!,\n },\n deploymentToActOn.url,\n )));\n if (!shouldPushToProd) {\n await ctx.crash({\n exitCode: 1,\n printedMessage: null,\n errorType: \"fatal\",\n });\n }\n }\n\n const isCloudDeployment = deploymentFields !== null;\n await Promise.all([\n deployToDeployment(\n ctx,\n {\n url: deploymentToActOn.url,\n adminKey: deploymentToActOn.adminKey,\n deploymentName: deploymentFields?.deploymentName ?? null,\n ...(deploymentFields?.deploymentType !== undefined\n ? { deploymentType: deploymentFields.deploymentType }\n : {}),\n },\n options,\n ),\n ...(isCloudDeployment\n ? [\n usageStateWarning(ctx, deploymentFields.deploymentName),\n checkVersion(),\n ]\n : []),\n ]);\n}\n\nasync function askToConfirmPush(\n ctx: Context,\n deployment: {\n configuredName: string;\n configuredType: string | null;\n requestedName: string;\n requestedType: string;\n },\n prodUrl: string,\n) {\n logMessage(\n `\\\nYou're currently developing against your ${chalkStderr.bold(\n deployment.configuredType ?? \"dev\",\n )} deployment\n\n ${deployment.configuredName} (set in CONVEX_DEPLOYMENT)\n\nYour ${chalkStderr.bold(deployment.requestedType)} deployment ${chalkStderr.bold(\n deployment.requestedName,\n )} serves traffic at:\n\n ${(await suggestedEnvVarName(ctx)).envVar}=${chalkStderr.bold(prodUrl)}\n\nMake sure that your published client is configured with this URL (for instructions see https://docs.convex.dev/hosting)\\n`,\n );\n return promptYesNo(ctx, {\n message: `Do you want to push your code to your ${deployment.requestedType} deployment ${deployment.requestedName} now?`,\n default: true,\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4B;AAC5B,2BAAgC;AAChC,qBAAuC;AACvC,iBAAyD;AACzD,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AAW,aAAa,eAAe,WAAW,aAAa;AAAA,IACjH,SAAS;AAAA,EACX,CAAC;AACH;",
6
6
  "names": ["import_components", "import_deploymentSelection"]
7
7
  }
@@ -177,7 +177,10 @@ const dev = new import_extra_typings.Command("dev").summary("Develop against a d
177
177
  {
178
178
  url: credentials.url,
179
179
  adminKey: credentials.adminKey,
180
- deploymentName: credentials.deploymentFields?.deploymentName ?? null
180
+ deploymentName: credentials.deploymentFields?.deploymentName ?? null,
181
+ ...credentials.deploymentFields?.deploymentType !== void 0 ? {
182
+ deploymentType: credentials.deploymentFields.deploymentType
183
+ } : {}
181
184
  },
182
185
  devOptions
183
186
  )