convex 1.37.0 → 1.38.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 (218) hide show
  1. package/CHANGELOG.md +14 -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 +2 -1
  5. package/dist/cjs/bundler/debugBundle.js.map +2 -2
  6. package/dist/cjs/bundler/index.js +6 -3
  7. package/dist/cjs/bundler/index.js.map +2 -2
  8. package/dist/cjs/bundler/serverOnly.js +37 -0
  9. package/dist/cjs/bundler/serverOnly.js.map +7 -0
  10. package/dist/cjs/cli/configure.js +5 -32
  11. package/dist/cjs/cli/configure.js.map +2 -2
  12. package/dist/cjs/cli/deploy.js +1 -1
  13. package/dist/cjs/cli/deploy.js.map +1 -1
  14. package/dist/cjs/cli/deploymentCreate.js +21 -9
  15. package/dist/cjs/cli/deploymentCreate.js.map +2 -2
  16. package/dist/cjs/cli/deploymentSelect.js +25 -0
  17. package/dist/cjs/cli/deploymentSelect.js.map +2 -2
  18. package/dist/cjs/cli/deploymentTokenCreate.js +1 -1
  19. package/dist/cjs/cli/deploymentTokenCreate.js.map +2 -2
  20. package/dist/cjs/cli/deploymentTokenDelete.js +1 -1
  21. package/dist/cjs/cli/deploymentTokenDelete.js.map +2 -2
  22. package/dist/cjs/cli/index.js +5 -2
  23. package/dist/cjs/cli/index.js.map +2 -2
  24. package/dist/cjs/cli/lib/deploymentSelection.js +4 -7
  25. package/dist/cjs/cli/lib/deploymentSelection.js.map +2 -2
  26. package/dist/cjs/cli/lib/env.js +1 -0
  27. package/dist/cjs/cli/lib/env.js.map +2 -2
  28. package/dist/cjs/cli/lib/localDeployment/anonymous.js +4 -4
  29. package/dist/cjs/cli/lib/localDeployment/anonymous.js.map +2 -2
  30. package/dist/cjs/cli/lib/localDeployment/errors.js +1 -1
  31. package/dist/cjs/cli/lib/localDeployment/errors.js.map +2 -2
  32. package/dist/cjs/cli/lib/localDeployment/localDeployment.js +64 -9
  33. package/dist/cjs/cli/lib/localDeployment/localDeployment.js.map +2 -2
  34. package/dist/cjs/cli/lib/localDeployment/utils.js +19 -7
  35. package/dist/cjs/cli/lib/localDeployment/utils.js.map +3 -3
  36. package/dist/cjs/cli/lib/utils/globalConfig.js +1 -2
  37. package/dist/cjs/cli/lib/utils/globalConfig.js.map +2 -2
  38. package/dist/cjs/cli/lib/utils/utils.js +8 -0
  39. package/dist/cjs/cli/lib/utils/utils.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/server/audit_logging.js +3 -1
  43. package/dist/cjs/server/audit_logging.js.map +2 -2
  44. package/dist/cjs/server/components/index.js +1 -12
  45. package/dist/cjs/server/components/index.js.map +2 -2
  46. package/dist/cjs/server/impl/registration_impl.js +8 -5
  47. package/dist/cjs/server/impl/registration_impl.js.map +2 -2
  48. package/dist/cjs/server/index.js.map +2 -2
  49. package/dist/cjs/server/log.js.map +2 -2
  50. package/dist/cjs/server/logVars.js.map +2 -2
  51. package/dist/cjs/server/meta.js.map +1 -1
  52. package/dist/cjs-types/bundler/debugBundle.d.ts.map +1 -1
  53. package/dist/cjs-types/bundler/index.d.ts.map +1 -1
  54. package/dist/cjs-types/bundler/serverOnly.d.ts +3 -0
  55. package/dist/cjs-types/bundler/serverOnly.d.ts.map +1 -0
  56. package/dist/cjs-types/cli/configure.d.ts.map +1 -1
  57. package/dist/cjs-types/cli/deploymentCreate.d.ts +4 -0
  58. package/dist/cjs-types/cli/deploymentCreate.d.ts.map +1 -1
  59. package/dist/cjs-types/cli/deploymentSelect.d.ts.map +1 -1
  60. package/dist/cjs-types/cli/deploymentTokenCreate.d.ts.map +1 -1
  61. package/dist/cjs-types/cli/deploymentTokenDelete.d.ts.map +1 -1
  62. package/dist/cjs-types/cli/lib/deployApi/componentDefinition.d.ts +6 -6
  63. package/dist/cjs-types/cli/lib/deployApi/modules.d.ts +6 -6
  64. package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts +8 -8
  65. package/dist/cjs-types/cli/lib/deploymentSelection.d.ts.map +1 -1
  66. package/dist/cjs-types/cli/lib/env.d.ts.map +1 -1
  67. package/dist/cjs-types/cli/lib/localDeployment/anonymous.d.ts.map +1 -1
  68. package/dist/cjs-types/cli/lib/localDeployment/errors.d.ts.map +1 -1
  69. package/dist/cjs-types/cli/lib/localDeployment/localDeployment.d.ts +8 -0
  70. package/dist/cjs-types/cli/lib/localDeployment/localDeployment.d.ts.map +1 -1
  71. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +13 -4
  72. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  73. package/dist/cjs-types/cli/lib/utils/globalConfig.d.ts +0 -1
  74. package/dist/cjs-types/cli/lib/utils/globalConfig.d.ts.map +1 -1
  75. package/dist/cjs-types/cli/lib/utils/utils.d.ts +7 -0
  76. package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
  77. package/dist/cjs-types/index.d.ts +1 -1
  78. package/dist/cjs-types/server/audit_logging.d.ts +1 -0
  79. package/dist/cjs-types/server/audit_logging.d.ts.map +1 -1
  80. package/dist/cjs-types/server/components/index.d.ts.map +1 -1
  81. package/dist/cjs-types/server/impl/registration_impl.d.ts.map +1 -1
  82. package/dist/cjs-types/server/index.d.ts +2 -0
  83. package/dist/cjs-types/server/index.d.ts.map +1 -1
  84. package/dist/cjs-types/server/log.d.ts +28 -0
  85. package/dist/cjs-types/server/log.d.ts.map +1 -1
  86. package/dist/cjs-types/server/logVars.d.ts +1 -0
  87. package/dist/cjs-types/server/logVars.d.ts.map +1 -1
  88. package/dist/cjs-types/server/meta.d.ts +2 -0
  89. package/dist/cjs-types/server/meta.d.ts.map +1 -1
  90. package/dist/cli.bundle.cjs +1583 -1520
  91. package/dist/cli.bundle.cjs.map +4 -4
  92. package/dist/esm/bundler/debugBundle.js +2 -1
  93. package/dist/esm/bundler/debugBundle.js.map +2 -2
  94. package/dist/esm/bundler/index.js +6 -3
  95. package/dist/esm/bundler/index.js.map +2 -2
  96. package/dist/esm/bundler/serverOnly.js +15 -0
  97. package/dist/esm/bundler/serverOnly.js.map +7 -0
  98. package/dist/esm/cli/configure.js +5 -32
  99. package/dist/esm/cli/configure.js.map +2 -2
  100. package/dist/esm/cli/deploy.js +1 -1
  101. package/dist/esm/cli/deploy.js.map +1 -1
  102. package/dist/esm/cli/deploymentCreate.js +21 -10
  103. package/dist/esm/cli/deploymentCreate.js.map +2 -2
  104. package/dist/esm/cli/deploymentSelect.js +25 -0
  105. package/dist/esm/cli/deploymentSelect.js.map +2 -2
  106. package/dist/esm/cli/deploymentTokenCreate.js +2 -1
  107. package/dist/esm/cli/deploymentTokenCreate.js.map +2 -2
  108. package/dist/esm/cli/deploymentTokenDelete.js +2 -1
  109. package/dist/esm/cli/deploymentTokenDelete.js.map +2 -2
  110. package/dist/esm/cli/index.js +5 -2
  111. package/dist/esm/cli/index.js.map +2 -2
  112. package/dist/esm/cli/lib/deploymentSelection.js +5 -7
  113. package/dist/esm/cli/lib/deploymentSelection.js.map +2 -2
  114. package/dist/esm/cli/lib/env.js +2 -0
  115. package/dist/esm/cli/lib/env.js.map +2 -2
  116. package/dist/esm/cli/lib/localDeployment/anonymous.js +4 -4
  117. package/dist/esm/cli/lib/localDeployment/anonymous.js.map +2 -2
  118. package/dist/esm/cli/lib/localDeployment/errors.js +1 -1
  119. package/dist/esm/cli/lib/localDeployment/errors.js.map +2 -2
  120. package/dist/esm/cli/lib/localDeployment/localDeployment.js +70 -11
  121. package/dist/esm/cli/lib/localDeployment/localDeployment.js.map +2 -2
  122. package/dist/esm/cli/lib/localDeployment/utils.js +19 -7
  123. package/dist/esm/cli/lib/localDeployment/utils.js.map +3 -3
  124. package/dist/esm/cli/lib/utils/globalConfig.js +1 -2
  125. package/dist/esm/cli/lib/utils/globalConfig.js.map +2 -2
  126. package/dist/esm/cli/lib/utils/utils.js +6 -0
  127. package/dist/esm/cli/lib/utils/utils.js.map +2 -2
  128. package/dist/esm/index.js +1 -1
  129. package/dist/esm/index.js.map +1 -1
  130. package/dist/esm/server/audit_logging.js +3 -1
  131. package/dist/esm/server/audit_logging.js.map +2 -2
  132. package/dist/esm/server/components/index.js +1 -12
  133. package/dist/esm/server/components/index.js.map +2 -2
  134. package/dist/esm/server/impl/registration_impl.js +8 -5
  135. package/dist/esm/server/impl/registration_impl.js.map +2 -2
  136. package/dist/esm/server/index.js.map +2 -2
  137. package/dist/esm/server/log.js.map +2 -2
  138. package/dist/esm/server/logVars.js.map +2 -2
  139. package/dist/esm-types/bundler/debugBundle.d.ts.map +1 -1
  140. package/dist/esm-types/bundler/index.d.ts.map +1 -1
  141. package/dist/esm-types/bundler/serverOnly.d.ts +3 -0
  142. package/dist/esm-types/bundler/serverOnly.d.ts.map +1 -0
  143. package/dist/esm-types/cli/configure.d.ts.map +1 -1
  144. package/dist/esm-types/cli/deploymentCreate.d.ts +4 -0
  145. package/dist/esm-types/cli/deploymentCreate.d.ts.map +1 -1
  146. package/dist/esm-types/cli/deploymentSelect.d.ts.map +1 -1
  147. package/dist/esm-types/cli/deploymentTokenCreate.d.ts.map +1 -1
  148. package/dist/esm-types/cli/deploymentTokenDelete.d.ts.map +1 -1
  149. package/dist/esm-types/cli/lib/deployApi/componentDefinition.d.ts +6 -6
  150. package/dist/esm-types/cli/lib/deployApi/modules.d.ts +6 -6
  151. package/dist/esm-types/cli/lib/deployApi/startPush.d.ts +8 -8
  152. package/dist/esm-types/cli/lib/deploymentSelection.d.ts.map +1 -1
  153. package/dist/esm-types/cli/lib/env.d.ts.map +1 -1
  154. package/dist/esm-types/cli/lib/localDeployment/anonymous.d.ts.map +1 -1
  155. package/dist/esm-types/cli/lib/localDeployment/errors.d.ts.map +1 -1
  156. package/dist/esm-types/cli/lib/localDeployment/localDeployment.d.ts +8 -0
  157. package/dist/esm-types/cli/lib/localDeployment/localDeployment.d.ts.map +1 -1
  158. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +13 -4
  159. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  160. package/dist/esm-types/cli/lib/utils/globalConfig.d.ts +0 -1
  161. package/dist/esm-types/cli/lib/utils/globalConfig.d.ts.map +1 -1
  162. package/dist/esm-types/cli/lib/utils/utils.d.ts +7 -0
  163. package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
  164. package/dist/esm-types/index.d.ts +1 -1
  165. package/dist/esm-types/server/audit_logging.d.ts +1 -0
  166. package/dist/esm-types/server/audit_logging.d.ts.map +1 -1
  167. package/dist/esm-types/server/components/index.d.ts.map +1 -1
  168. package/dist/esm-types/server/impl/registration_impl.d.ts.map +1 -1
  169. package/dist/esm-types/server/index.d.ts +2 -0
  170. package/dist/esm-types/server/index.d.ts.map +1 -1
  171. package/dist/esm-types/server/log.d.ts +28 -0
  172. package/dist/esm-types/server/log.d.ts.map +1 -1
  173. package/dist/esm-types/server/logVars.d.ts +1 -0
  174. package/dist/esm-types/server/logVars.d.ts.map +1 -1
  175. package/dist/esm-types/server/meta.d.ts +2 -0
  176. package/dist/esm-types/server/meta.d.ts.map +1 -1
  177. package/dist/react.bundle.js +1 -1
  178. package/dist/react.bundle.js.map +1 -1
  179. package/package.json +1 -1
  180. package/schemas/convex.schema.json +1 -1
  181. package/src/bundler/debugBundle.ts +2 -1
  182. package/src/bundler/index.ts +7 -3
  183. package/src/bundler/serverOnly.ts +18 -0
  184. package/src/cli/configure.ts +2 -35
  185. package/src/cli/deploy.ts +1 -1
  186. package/src/cli/deploymentCreate.test.ts +4 -0
  187. package/src/cli/deploymentCreate.ts +23 -9
  188. package/src/cli/deploymentSelect.test.ts +60 -6
  189. package/src/cli/deploymentSelect.ts +34 -0
  190. package/src/cli/deploymentSelection.test.ts +72 -19
  191. package/src/cli/deploymentTokenCreate.ts +4 -1
  192. package/src/cli/deploymentTokenDelete.ts +9 -1
  193. package/src/cli/index.ts +6 -2
  194. package/src/cli/lib/deploymentSelection.ts +5 -7
  195. package/src/cli/lib/env.ts +2 -0
  196. package/src/cli/lib/localDeployment/anonymous.ts +5 -4
  197. package/src/cli/lib/localDeployment/errors.ts +1 -3
  198. package/src/cli/lib/localDeployment/localDeployment.ts +85 -10
  199. package/src/cli/lib/localDeployment/utils.ts +31 -7
  200. package/src/cli/lib/utils/globalConfig.ts +0 -3
  201. package/src/cli/lib/utils/utils.ts +15 -0
  202. package/src/index.ts +1 -1
  203. package/src/server/audit_logging.ts +2 -3
  204. package/src/server/components/index.ts +3 -15
  205. package/src/server/impl/registration_impl.ts +13 -7
  206. package/src/server/index.ts +0 -6
  207. package/src/server/log.ts +21 -3
  208. package/src/server/logVars.ts +0 -3
  209. package/src/server/meta.ts +0 -7
  210. package/dist/cjs/cli/disableLocalDev.js +0 -121
  211. package/dist/cjs/cli/disableLocalDev.js.map +0 -7
  212. package/dist/cjs-types/cli/disableLocalDev.d.ts +0 -6
  213. package/dist/cjs-types/cli/disableLocalDev.d.ts.map +0 -1
  214. package/dist/esm/cli/disableLocalDev.js +0 -105
  215. package/dist/esm/cli/disableLocalDev.js.map +0 -7
  216. package/dist/esm-types/cli/disableLocalDev.d.ts +0 -6
  217. package/dist/esm-types/cli/disableLocalDev.d.ts.map +0 -1
  218. package/src/cli/disableLocalDev.ts +0 -134
@@ -9,6 +9,7 @@ import {
9
9
  logMessage
10
10
  } from "./log.js";
11
11
  import { wasmPlugin } from "./wasm.js";
12
+ import { serverOnlyPlugin } from "./serverOnly.js";
12
13
  import dependencyTrackerPlugin from "./depgraph.js";
13
14
  export async function innerEsbuild({
14
15
  entryPoints,
@@ -81,7 +82,7 @@ export async function debugIsolateBundlesSerially(ctx, {
81
82
  chunksFolder: "_deps",
82
83
  extraConditions,
83
84
  dir,
84
- plugins: [plugin, wasmPlugin],
85
+ plugins: [serverOnlyPlugin, plugin, wasmPlugin],
85
86
  logLevel: "silent"
86
87
  });
87
88
  } catch (error) {
@@ -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 = false,\n splitting = 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 splitting?: boolean | undefined;\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,\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/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AAK,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;",
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 { serverOnlyPlugin } from \"./serverOnly.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 splitting = 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 splitting?: boolean | undefined;\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,\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: [serverOnlyPlugin, 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
+ "mappings": ";AAAA,OAAO,UAAU;AACjB,OAAO,aAAiD;AAExD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,OAAO,6BAA6B;AAEpC,sBAAsB,aAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,YAAY;AACd,GAWG;AACD,QAAM,SAAS,MAAM,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,gBAAgB;AAAA,IAChB;AAAA,IACA,YAAY,KAAK,KAAK,cAAc,QAAQ;AAAA,IAC5C,aAAa;AAAA,IACb,cAAc;AAAA,IACd,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA,IAKnB,kBAAkB;AAAA;AAAA,IAClB,WAAW;AAAA,IACX,QAAQ;AAAA,MACN,wBAAwB;AAAA,IAC1B;AAAA,IACA,UAAU;AAAA,IACV,UAAU,YAAY;AAAA,EACxB,CAAC;AACD,SAAO;AACT;AAEO,gBAAS,oBAAoB,GAA2B;AAC7D,SACE,YAAY,KACZ,cAAc,KACd,MAAM,QAAQ,EAAE,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;AAGlD,QAAM,eACJ,UAAU,WAAW,SAAS,KAC9B,UAAU,SAAS,UAAU,KAC7B,KAAK,QAAQ,SAAS,MAAM;AAE9B,MAAI,cAAc;AAEhB,QAAI,UAAU,WAAW,SAAS,GAAG;AACnC,aAAO;AAAA,IACT;AAGA,QAAI,KAAK,QAAQ,SAAS,MAAM,UAAU;AACxC,YAAM,WAAW,KAAK,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": ["i", "cleanPath"]
7
7
  }
@@ -6,6 +6,7 @@ import * as Sentry from "@sentry/node";
6
6
  import { consistentPathSort } from "./fs.js";
7
7
  import { logVerbose, logWarning } from "./log.js";
8
8
  import { wasmPlugin } from "./wasm.js";
9
+ import { serverOnlyPlugin } from "./serverOnly.js";
9
10
  import {
10
11
  computeExternalPackages,
11
12
  createExternalPlugin,
@@ -50,13 +51,15 @@ async function doEsbuild({
50
51
  chunksFolder,
51
52
  extraConditions,
52
53
  dir,
53
- // The wasmPlugin should be last so it doesn't run on external modules.
54
- plugins: [external.plugin, wasmPlugin],
54
+ // serverOnlyPlugin runs first so `server-only` is always stubbed,
55
+ // even if it appears in the external packages list.
56
+ // wasmPlugin runs last so it doesn't run on external modules.
57
+ plugins: [serverOnlyPlugin, external.plugin, wasmPlugin],
55
58
  includeSourcesContent,
56
59
  splitting
57
60
  });
58
61
  for (const [relPath, input] of Object.entries(result.metafile.inputs)) {
59
- if (relPath.indexOf("(disabled):") !== -1 || relPath.startsWith("wasm-binary:") || relPath.startsWith("wasm-stub:")) {
62
+ if (relPath.indexOf("(disabled):") !== -1 || relPath.startsWith("wasm-binary:") || relPath.startsWith("wasm-stub:") || relPath.startsWith("server-only-stub:")) {
60
63
  continue;
61
64
  }
62
65
  const absPath = path.resolve(relPath);
@@ -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,\n dir,\n entryPoints,\n generateSourceMaps,\n platform,\n chunksFolder,\n externalPackages,\n extraConditions,\n includeSourcesContent,\n splitting,\n}: {\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 splitting?: boolean | undefined;\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 splitting,\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 splitting,\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 splitting?: 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 externalPackages: availableExternalPackages,\n extraConditions,\n includeSourcesContent,\n splitting,\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 // The auth config must be one module\n splitting: false,\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 {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AAc,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;",
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 { serverOnlyPlugin } from \"./serverOnly.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,\n dir,\n entryPoints,\n generateSourceMaps,\n platform,\n chunksFolder,\n externalPackages,\n extraConditions,\n includeSourcesContent,\n splitting,\n}: {\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 splitting?: boolean | undefined;\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 // serverOnlyPlugin runs first so `server-only` is always stubbed,\n // even if it appears in the external packages list.\n // wasmPlugin runs last so it doesn't run on external modules.\n plugins: [serverOnlyPlugin, external.plugin, wasmPlugin],\n includeSourcesContent,\n splitting,\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 relPath.startsWith(\"server-only-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 splitting,\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 splitting?: 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 externalPackages: availableExternalPackages,\n extraConditions,\n includeSourcesContent,\n splitting,\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 // The auth config must be one module\n splitting: false,\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
+ "mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,mBAAmB;AAE5B,SAAS,SAAS,gBAAgB;AAElC,YAAY,YAAY;AACxB,SAAqB,0BAA0B;AAE/C,SAAS,YAAY,kBAAkB;AACvC,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,2BAA2B;AAClD,SAAS,QAAQ,mBAAmB;AAG7B,aAAM,aAAa;AAKnB,iBAAU,QACf,IACA,SACA,eACA,OACwE;AACxE,UAAQ,SAAS;AACjB,aAAW,YAAY,GAAG,QAAQ,OAAO,EAAE,KAAK,kBAAkB,GAAG;AACnE,UAAM,YAAY,KAAK,KAAK,SAAS,SAAS,IAAI;AAClD,QAAI,SAAS,YAAY,GAAG;AAC1B,UAAI,iBAAiB,cAAc,SAAS,GAAG;AAC7C;AAAA,MACF;AACA,YAAM,EAAE,OAAO,MAAM,MAAM,WAAW,MAAM;AAC5C,aAAO,QAAQ,IAAI,WAAW,eAAe,QAAQ,CAAC;AAAA,IACxD,WAAW,SAAS,OAAO,GAAG;AAC5B,YAAM,EAAE,OAAO,OAAO,MAAM,WAAW,MAAM;AAAA,IAC/C;AAAA,EACF;AACF;AA0BA,eAAe,UAAU;AAAA,EACvB;AAAA,EACA;AAAA,EACA,aAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAW2B;AACzB,QAAM,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;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,aAAa,KAAK;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,sBAAsB,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": ["entryPoints"]
7
7
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ export const serverOnlyPlugin = {
3
+ name: "convex-server-only",
4
+ setup(build) {
5
+ build.onResolve({ filter: /^server-only$/ }, (args) => ({
6
+ path: args.path,
7
+ namespace: "server-only-stub"
8
+ }));
9
+ build.onLoad({ filter: /.*/, namespace: "server-only-stub" }, () => ({
10
+ contents: "",
11
+ loader: "js"
12
+ }));
13
+ }
14
+ };
15
+ //# sourceMappingURL=serverOnly.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/bundler/serverOnly.ts"],
4
+ "sourcesContent": ["import { Plugin } from \"esbuild\";\n\n// Stub `import \"server-only\"` to an empty module so user code that uses\n// Next.js's server-only can be bundled and analyzed correctly:\n// https://nextjs.org/docs/app/getting-started/server-and-client-components#preventing-environment-poisoning\nexport const serverOnlyPlugin: Plugin = {\n name: \"convex-server-only\",\n setup(build) {\n build.onResolve({ filter: /^server-only$/ }, (args) => ({\n path: args.path,\n namespace: \"server-only-stub\",\n }));\n build.onLoad({ filter: /.*/, namespace: \"server-only-stub\" }, () => ({\n contents: \"\",\n loader: \"js\",\n }));\n },\n};\n"],
5
+ "mappings": ";AAKO,aAAM,mBAA2B;AAAA,EACtC,MAAM;AAAA,EACN,MAAM,OAAO;AACX,UAAM,UAAU,EAAE,QAAQ,gBAAgB,GAAG,CAAC,UAAU;AAAA,MACtD,MAAM,KAAK;AAAA,MACX,WAAW;AAAA,IACb,EAAE;AACF,UAAM,OAAO,EAAE,QAAQ,MAAM,WAAW,mBAAmB,GAAG,OAAO;AAAA,MACnE,UAAU;AAAA,MACV,QAAQ;AAAA,IACV,EAAE;AAAA,EACJ;AACF;",
6
+ "names": []
7
+ }
@@ -39,7 +39,6 @@ import {
39
39
  promptString,
40
40
  promptYesNo
41
41
  } from "./lib/utils/prompts.js";
42
- import { readGlobalConfig } from "./lib/utils/globalConfig.js";
43
42
  import { attemptSetupAiFiles } from "./lib/aiFiles/index.js";
44
43
  import {
45
44
  deploymentNameFromSelection,
@@ -86,15 +85,6 @@ export async function deploymentCredentialsOrConfigure(ctx, deploymentSelection,
86
85
  };
87
86
  }
88
87
  export async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection, chosenConfiguration, cmdOptions) {
89
- const config = readGlobalConfig(ctx);
90
- const globallyForceCloud = !!config?.optOutOfLocalDevDeploymentsUntilBetaOver;
91
- if (globallyForceCloud && cmdOptions.local) {
92
- return await ctx.crash({
93
- exitCode: 1,
94
- errorType: "fatal",
95
- printedMessage: "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."
96
- });
97
- }
98
88
  switch (deploymentSelection.kind) {
99
89
  case "existingDeployment":
100
90
  return {
@@ -113,9 +103,6 @@ export async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection
113
103
  ctx,
114
104
  chosenConfiguration,
115
105
  deploymentSelection.selectionWithinProject,
116
- {
117
- globallyForceCloud
118
- },
119
106
  cmdOptions
120
107
  );
121
108
  }
@@ -129,8 +116,7 @@ export async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection
129
116
  return await handleDeploymentWithinProject(ctx, {
130
117
  chosenConfiguration,
131
118
  deploymentSelection,
132
- cmdOptions,
133
- globallyForceCloud
119
+ cmdOptions
134
120
  });
135
121
  }
136
122
  case "anonymous": {
@@ -145,9 +131,6 @@ export async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection
145
131
  ctx,
146
132
  chosenConfiguration,
147
133
  deploymentSelection.selectionWithinProject,
148
- {
149
- globallyForceCloud
150
- },
151
134
  cmdOptions
152
135
  );
153
136
  }
@@ -192,9 +175,6 @@ export async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection
192
175
  ctx,
193
176
  chosenConfiguration,
194
177
  deploymentSelection.selectionWithinProject,
195
- {
196
- globallyForceCloud
197
- },
198
178
  cmdOptions
199
179
  );
200
180
  }
@@ -203,8 +183,7 @@ export async function _deploymentCredentialsOrConfigure(ctx, deploymentSelection
203
183
  async function handleDeploymentWithinProject(ctx, {
204
184
  chosenConfiguration,
205
185
  deploymentSelection,
206
- cmdOptions,
207
- globallyForceCloud
186
+ cmdOptions
208
187
  }) {
209
188
  const hasAuth = ctx.bigBrainAuth() !== null;
210
189
  const loginMessage = hasAuth && shouldAllowAnonymousDevelopment() ? void 0 : `Tip: You can try out Convex without creating an account by clearing the ${CONVEX_DEPLOYMENT_ENV_VAR_NAME} environment variable (often in .env.local).`;
@@ -220,9 +199,6 @@ async function handleDeploymentWithinProject(ctx, {
220
199
  ctx,
221
200
  chosenConfiguration,
222
201
  deploymentSelection.selectionWithinProject,
223
- {
224
- globallyForceCloud
225
- },
226
202
  cmdOptions
227
203
  );
228
204
  return result;
@@ -237,9 +213,6 @@ async function handleDeploymentWithinProject(ctx, {
237
213
  ctx,
238
214
  chosenConfiguration,
239
215
  deploymentSelection.selectionWithinProject,
240
- {
241
- globallyForceCloud
242
- },
243
216
  cmdOptions
244
217
  );
245
218
  return result;
@@ -270,7 +243,7 @@ async function handleDeploymentWithinProject(ctx, {
270
243
  deploymentFields: selectedDeployment.deploymentFields
271
244
  };
272
245
  }
273
- async function handleChooseProject(ctx, chosenConfiguration, selectionWithinProject, args, cmdOptions) {
246
+ async function handleChooseProject(ctx, chosenConfiguration, selectionWithinProject, cmdOptions) {
274
247
  await ensureLoggedIn(ctx, {
275
248
  overrideAuthUrl: cmdOptions.overrideAuthUrl,
276
249
  overrideAuthClient: cmdOptions.overrideAuthClient,
@@ -281,8 +254,8 @@ async function handleChooseProject(ctx, chosenConfiguration, selectionWithinProj
281
254
  team: cmdOptions.team,
282
255
  project: cmdOptions.project,
283
256
  devDeployment: cmdOptions.devDeployment,
284
- local: args.globallyForceCloud ? false : cmdOptions.local,
285
- cloud: args.globallyForceCloud ? true : cmdOptions.cloud
257
+ local: cmdOptions.local,
258
+ cloud: cmdOptions.cloud
286
259
  });
287
260
  const deploymentOptions = selectionWithinProject.kind === "prod" ? { kind: "prod" } : project.devDeployment === "local" ? { kind: "local", ...cmdOptions.localOptions } : { kind: "dev" };
288
261
  const {
@@ -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 loadSelectedDeploymentCredentials,\n checkAccessToSelectedProject,\n DeploymentSelectionWithinProject,\n} from \"./lib/api.js\";\nimport { readProjectConfig, ensureConvexFunctionsDir } 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 selectRegionOrUseDefault,\n validateOrSelectProject,\n validateOrSelectTeam,\n} from \"./lib/utils/utils.js\";\nimport { writeUrlsToEnvFile } 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 { attemptSetupAiFiles } from \"./lib/aiFiles/index.js\";\nimport {\n DeploymentSelection,\n deploymentNameFromSelection,\n shouldAllowAnonymousDevelopment,\n} from \"./lib/deploymentSelection.js\";\nimport { ensureLoggedIn } from \"./lib/login.js\";\nimport { handleAnonymousDeployment } from \"./lib/localDeployment/anonymous.js\";\nimport { fetchDeploymentCanonicalUrls } from \"./lib/deploy2.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 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 siteUrl: string | null;\n } | null;\n }\n> {\n const selectedDeployment = await _deploymentCredentialsOrConfigure(\n ctx,\n deploymentSelection,\n chosenConfiguration,\n cmdOptions,\n );\n const { convexSiteUrl: siteUrl } = await fetchDeploymentCanonicalUrls(ctx, {\n adminKey: selectedDeployment.adminKey,\n deploymentUrl: selectedDeployment.url,\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 siteUrl,\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` and\n // `CONVEX_SITE_URL` env vars.\n await handleManuallySetUrlAndAdminKey(ctx, {\n url: selectedDeployment.url,\n siteUrl,\n adminKey: selectedDeployment.adminKey,\n });\n }\n return {\n url: selectedDeployment.url,\n adminKey: selectedDeployment.adminKey,\n deploymentFields:\n selectedDeployment.deploymentFields === null\n ? null\n : { ...selectedDeployment.deploymentFields, siteUrl: siteUrl },\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 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 deploymentSelection.selectionWithinProject,\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 deploymentSelection,\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 process.stdin.isTTY &&\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 link it now?`,\n }));\n if (shouldConfigure) {\n return await handleChooseProject(\n ctx,\n chosenConfiguration,\n deploymentSelection.selectionWithinProject,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\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 =\n isAgentMode || !process.stdin.isTTY\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 deploymentSelection.selectionWithinProject,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n }\n }\n}\n\nasync function handleDeploymentWithinProject(\n ctx: Context,\n {\n chosenConfiguration,\n deploymentSelection,\n cmdOptions,\n globallyForceCloud,\n }: {\n chosenConfiguration: ChosenConfiguration;\n deploymentSelection: DeploymentSelection & {\n kind: \"deploymentWithinProject\";\n };\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 \" +\n `${CONVEX_DEPLOYMENT_ENV_VAR_NAME} environment variable (often in .env.local).`;\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 deploymentSelection.selectionWithinProject,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n return result;\n }\n\n const accessResult = await checkAccessToSelectedProject(\n ctx,\n deploymentSelection.targetProject,\n );\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 deploymentSelection.selectionWithinProject,\n {\n globallyForceCloud,\n },\n cmdOptions,\n );\n return result;\n }\n\n const selectedDeployment = await loadSelectedDeploymentCredentials(\n ctx,\n deploymentSelection,\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, which may bind to different ports\n // than what was saved from a previous run.\n const localDeployment = 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 return {\n url: localDeployment.deploymentUrl,\n adminKey: localDeployment.adminKey,\n deploymentFields: selectedDeployment.deploymentFields,\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 selectionWithinProject: DeploymentSelectionWithinProject,\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 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\nasync function handleManuallySetUrlAndAdminKey(\n ctx: Context,\n cmdOptions: { url: string; siteUrl: string; adminKey: string },\n) {\n const { url, siteUrl, 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 envFileConfig = await writeUrlsToEnvFile(ctx, {\n convexUrl: url,\n siteUrl,\n });\n if (\n envFileConfig !== null &&\n (envFileConfig.convexUrlEnvVar || envFileConfig.siteUrlEnvVar)\n ) {\n // Join both names with \" and \" if both exist, otherwise just use one of them.\n const updatedVars = [\n envFileConfig.convexUrlEnvVar,\n envFileConfig.siteUrlEnvVar,\n ]\n .filter(Boolean)\n .join(\" and \");\n logMessage(\n chalkStderr.green(`Saved ${updatedVars} to ${envFileConfig.envFile}`),\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 { team: 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.slug,\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 const region =\n devDeployment === \"cloud\"\n ? await selectRegionOrUseDefault(ctx, selectedTeam, \"dev\")\n : null;\n\n showSpinner(\"Creating new Convex project...\");\n\n const deploymentToProvision =\n devDeployment === \"cloud\"\n ? {\n deploymentType: \"dev\" as const,\n region,\n }\n : null;\n\n let projectSlug, teamSlug;\n try {\n ({ projectSlug, teamSlug } = await createProject(ctx, {\n teamSlug: selectedTeam.slug,\n projectName,\n deploymentToProvision,\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 await doInitConvexFolder(ctx);\n const { configPath, projectConfig } = await readProjectConfig(ctx);\n const folder = functionsDir(configPath, projectConfig);\n await attemptSetupAiFiles({\n ctx,\n aiFilesConfig: projectConfig.aiFiles,\n convexDir: path.resolve(folder),\n projectDir: path.resolve(path.dirname(configPath)),\n });\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 {\n team: { slug: teamSlug },\n chosen,\n } = await validateOrSelectTeam(ctx, config.team, \"Team:\");\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\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 siteUrl?: string | null;\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 options.deploymentType !== \"prod\"\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 : { wroteToGitIgnore: false, changedDeploymentEnvVar: false };\n await ensureConvexFunctionsDir(ctx, projectConfig);\n await finalizeConfiguration(ctx, {\n deploymentType: options.deploymentType,\n deploymentName: options.deploymentName,\n url: options.url,\n siteUrl: options.siteUrl,\n wroteToGitIgnore,\n changedDeploymentEnvVar,\n functionsPath: functionsDir(configPath, projectConfig),\n });\n}\n"],
5
- "mappings": ";AAAA,SAAS,mBAAmB;AAE5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,mBAAmB,gCAAgC;AAC5D;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,OAAO,UAAU;AACjB,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SA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AE,YAAY,cAAc,IAAI,MAAM,kBAAkB,GAAG;AAEjE,QAAM,EAAE,kBAAkB,wBAAwB,IAChD,QAAQ,mBAAmB,SACvB,MAAM;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,IACA,EAAE,kBAAkB,OAAO,yBAAyB,MAAM;AAChE,QAAM,yBAAyB,KAAK,aAAa;AACjD,QAAM,sBAAsB,KAAK;AAAA,IAC/B,gBAAgB,QAAQ;AAAA,IACxB,gBAAgB,QAAQ;AAAA,IACxB,KAAK,QAAQ;AAAA,IACb,SAAS,QAAQ;AAAA,IACjB;AAAA,IACA;AAAA,IACA,eAAe,aAAa,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 loadSelectedDeploymentCredentials,\n checkAccessToSelectedProject,\n DeploymentSelectionWithinProject,\n} from \"./lib/api.js\";\nimport { readProjectConfig, ensureConvexFunctionsDir } 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 selectRegionOrUseDefault,\n validateOrSelectProject,\n validateOrSelectTeam,\n} from \"./lib/utils/utils.js\";\nimport { writeUrlsToEnvFile } 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 { attemptSetupAiFiles } from \"./lib/aiFiles/index.js\";\nimport {\n DeploymentSelection,\n deploymentNameFromSelection,\n shouldAllowAnonymousDevelopment,\n} from \"./lib/deploymentSelection.js\";\nimport { ensureLoggedIn } from \"./lib/login.js\";\nimport { handleAnonymousDeployment } from \"./lib/localDeployment/anonymous.js\";\nimport { fetchDeploymentCanonicalUrls } from \"./lib/deploy2.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 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 siteUrl: string | null;\n } | null;\n }\n> {\n const selectedDeployment = await _deploymentCredentialsOrConfigure(\n ctx,\n deploymentSelection,\n chosenConfiguration,\n cmdOptions,\n );\n const { convexSiteUrl: siteUrl } = await fetchDeploymentCanonicalUrls(ctx, {\n adminKey: selectedDeployment.adminKey,\n deploymentUrl: selectedDeployment.url,\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 siteUrl,\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` and\n // `CONVEX_SITE_URL` env vars.\n await handleManuallySetUrlAndAdminKey(ctx, {\n url: selectedDeployment.url,\n siteUrl,\n adminKey: selectedDeployment.adminKey,\n });\n }\n return {\n url: selectedDeployment.url,\n adminKey: selectedDeployment.adminKey,\n deploymentFields:\n selectedDeployment.deploymentFields === null\n ? null\n : { ...selectedDeployment.deploymentFields, siteUrl: siteUrl },\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 switch (deploymentSelection.kind) {\n case \"existingDeployment\":\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 deploymentSelection.selectionWithinProject,\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 deploymentSelection,\n cmdOptions,\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 process.stdin.isTTY &&\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 link it now?`,\n }));\n if (shouldConfigure) {\n return await handleChooseProject(\n ctx,\n chosenConfiguration,\n deploymentSelection.selectionWithinProject,\n cmdOptions,\n );\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 =\n isAgentMode || !process.stdin.isTTY\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 deploymentSelection.selectionWithinProject,\n cmdOptions,\n );\n }\n }\n}\n\nasync function handleDeploymentWithinProject(\n ctx: Context,\n {\n chosenConfiguration,\n deploymentSelection,\n cmdOptions,\n }: {\n chosenConfiguration: ChosenConfiguration;\n deploymentSelection: DeploymentSelection & {\n kind: \"deploymentWithinProject\";\n };\n cmdOptions: ConfigureCmdOptions;\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 \" +\n `${CONVEX_DEPLOYMENT_ENV_VAR_NAME} environment variable (often in .env.local).`;\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 deploymentSelection.selectionWithinProject,\n cmdOptions,\n );\n return result;\n }\n\n const accessResult = await checkAccessToSelectedProject(\n ctx,\n deploymentSelection.targetProject,\n );\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 deploymentSelection.selectionWithinProject,\n cmdOptions,\n );\n return result;\n }\n\n const selectedDeployment = await loadSelectedDeploymentCredentials(\n ctx,\n deploymentSelection,\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, which may bind to different ports\n // than what was saved from a previous run.\n const localDeployment = 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 return {\n url: localDeployment.deploymentUrl,\n adminKey: localDeployment.adminKey,\n deploymentFields: selectedDeployment.deploymentFields,\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 selectionWithinProject: DeploymentSelectionWithinProject,\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: cmdOptions.local,\n cloud: 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 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\nasync function handleManuallySetUrlAndAdminKey(\n ctx: Context,\n cmdOptions: { url: string; siteUrl: string; adminKey: string },\n) {\n const { url, siteUrl, 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 envFileConfig = await writeUrlsToEnvFile(ctx, {\n convexUrl: url,\n siteUrl,\n });\n if (\n envFileConfig !== null &&\n (envFileConfig.convexUrlEnvVar || envFileConfig.siteUrlEnvVar)\n ) {\n // Join both names with \" and \" if both exist, otherwise just use one of them.\n const updatedVars = [\n envFileConfig.convexUrlEnvVar,\n envFileConfig.siteUrlEnvVar,\n ]\n .filter(Boolean)\n .join(\" and \");\n logMessage(\n chalkStderr.green(`Saved ${updatedVars} to ${envFileConfig.envFile}`),\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 { team: 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.slug,\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 const region =\n devDeployment === \"cloud\"\n ? await selectRegionOrUseDefault(ctx, selectedTeam, \"dev\")\n : null;\n\n showSpinner(\"Creating new Convex project...\");\n\n const deploymentToProvision =\n devDeployment === \"cloud\"\n ? {\n deploymentType: \"dev\" as const,\n region,\n }\n : null;\n\n let projectSlug, teamSlug;\n try {\n ({ projectSlug, teamSlug } = await createProject(ctx, {\n teamSlug: selectedTeam.slug,\n projectName,\n deploymentToProvision,\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 await doInitConvexFolder(ctx);\n const { configPath, projectConfig } = await readProjectConfig(ctx);\n const folder = functionsDir(configPath, projectConfig);\n await attemptSetupAiFiles({\n ctx,\n aiFilesConfig: projectConfig.aiFiles,\n convexDir: path.resolve(folder),\n projectDir: path.resolve(path.dirname(configPath)),\n });\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 {\n team: { slug: teamSlug },\n chosen,\n } = await validateOrSelectTeam(ctx, config.team, \"Team:\");\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\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 siteUrl?: string | null;\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 options.deploymentType !== \"prod\"\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 : { wroteToGitIgnore: false, changedDeploymentEnvVar: false };\n await ensureConvexFunctionsDir(ctx, projectConfig);\n await finalizeConfiguration(ctx, {\n deploymentType: options.deploymentType,\n deploymentName: options.deploymentName,\n url: options.url,\n siteUrl: options.siteUrl,\n wroteToGitIgnore,\n changedDeploymentEnvVar,\n functions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,kBAA0B,IAAI;AAAA,MACnF,CAAC;AAAA,EACL;AACF;AAEA,sBAAsB,yCACpB,KACA,SAQA,eACA;AACA,QAAM,EAAE,YAAY,cAAc,IAAI,MAAM,kBAAkB,GAAG;AAEjE,QAAM,EAAE,kBAAkB,wBAAwB,IAChD,QAAQ,mBAAmB,SACvB,MAAM;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,IACA,EAAE,kBAAkB,OAAO,yBAAyB,MAAM;AAChE,QAAM,yBAAyB,KAAK,aAAa;AACjD,QAAM,sBAAsB,KAAK;AAAA,IAC/B,gBAAgB,QAAQ;AAAA,IACxB,gBAAgB,QAAQ;AAAA,IACxB,KAAK,QAAQ;AAAA,IACb,SAAS,QAAQ;AAAA,IACjB;AAAA,IACA;AAAA,IACA,eAAe,aAAa,YAAY,aAAa;AAAA,EACvD,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -145,7 +145,7 @@ async function deployToNewPreviewDeployment(ctx, deploymentSelection, options) {
145
145
  await ctx.crash({
146
146
  exitCode: 1,
147
147
  errorType: "fatal",
148
- printedMessage: "`npx convex deploy` to a preview deployment could not determine the preview name. Provide one using `--preview-create`"
148
+ printedMessage: "`npx convex deploy` to a preview deployment could not determine the preview name. Provide one using `--preview-name`"
149
149
  });
150
150
  }
151
151
  if (options.dryRun) {