@wasp.sh/wasp-cli-darwin-x64-unknown 0.25.0 → 0.26.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 (255) hide show
  1. package/data/Cli/starters/README.md +2 -0
  2. package/data/Cli/starters/basic/README.md +3 -3
  3. package/data/Cli/starters/basic/src/tags/components/CreateTagForm.tsx +2 -3
  4. package/data/Cli/starters/basic/vite.config.ts +0 -3
  5. package/data/Cli/starters/minimal/package.json +4 -1
  6. package/data/Cli/starters/minimal/vite.config.ts +0 -3
  7. package/data/Cli/starters/skeleton/AGENTS.md +6 -0
  8. package/data/Cli/starters/skeleton/CLAUDE.md +6 -0
  9. package/data/Cli/starters/skeleton/tsconfig.src.json +1 -11
  10. package/data/Generator/libs/auth/wasp.sh-lib-auth-0.26.0.tgz +0 -0
  11. package/data/Generator/libs/sdk-core/node_modules/@wasp.sh/lib-auth/wasp.sh-lib-auth-0.26.0.tgz +0 -0
  12. package/data/Generator/libs/sdk-core/wasp.sh-lib-sdk-core-0.26.0.tgz +0 -0
  13. package/data/Generator/libs/vite-ssr/{wasp.sh-lib-vite-ssr-0.25.0.tgz → wasp.sh-lib-vite-ssr-0.26.0.tgz} +0 -0
  14. package/data/Generator/templates/Dockerfile +1 -0
  15. package/data/Generator/templates/sdk/wasp/api/index.ts +5 -86
  16. package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +2 -2
  17. package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +1 -1
  18. package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +7 -6
  19. package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +1 -1
  20. package/data/Generator/templates/sdk/wasp/auth/forms/Auth.tsx +12 -6
  21. package/data/Generator/templates/sdk/wasp/auth/forms/ForgotPassword.tsx +2 -1
  22. package/data/Generator/templates/sdk/wasp/auth/forms/Login.tsx +2 -1
  23. package/data/Generator/templates/sdk/wasp/auth/forms/ResetPassword.tsx +2 -1
  24. package/data/Generator/templates/sdk/wasp/auth/forms/Signup.tsx +5 -5
  25. package/data/Generator/templates/sdk/wasp/auth/forms/VerifyEmail.tsx +2 -1
  26. package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.tsx +34 -33
  27. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.module.css +11 -0
  28. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.tsx +17 -0
  29. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ForgotPasswordForm.tsx +9 -13
  30. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ResetPasswordForm.tsx +8 -9
  31. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/VerifyEmailForm.tsx +4 -8
  32. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/useEmail.ts +5 -5
  33. package/data/Generator/templates/sdk/wasp/auth/forms/internal/usernameAndPassword/useUsernameAndPassword.ts +6 -5
  34. package/data/Generator/templates/sdk/wasp/auth/forms/types.ts +0 -59
  35. package/data/Generator/templates/sdk/wasp/auth/helpers/_Provider.tsx +2 -2
  36. package/data/Generator/templates/sdk/wasp/auth/index.ts +1 -1
  37. package/data/Generator/templates/sdk/wasp/auth/logout.ts +1 -1
  38. package/data/Generator/templates/sdk/wasp/auth/providers/index.ts +4 -4
  39. package/data/Generator/templates/sdk/wasp/auth/providers/types.ts +20 -24
  40. package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +5 -5
  41. package/data/Generator/templates/sdk/wasp/auth/user.ts +147 -14
  42. package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +2 -2
  43. package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +6 -5
  44. package/data/Generator/templates/sdk/wasp/auth/validation.ts +1 -83
  45. package/data/Generator/templates/sdk/wasp/client/app/pages/OAuthCallback.tsx +8 -5
  46. package/data/Generator/templates/sdk/wasp/client/app/pages/createAuthRequiredPage.jsx +6 -4
  47. package/data/Generator/templates/sdk/wasp/client/app/router.tsx +2 -2
  48. package/data/Generator/templates/sdk/wasp/client/auth/ui.ts +2 -2
  49. package/data/Generator/templates/sdk/wasp/client/auth/username.ts +2 -2
  50. package/data/Generator/templates/sdk/wasp/client/config.ts +1 -6
  51. package/data/Generator/templates/sdk/wasp/client/crud/_crud.ts +129 -75
  52. package/data/Generator/templates/sdk/wasp/client/env/schema.ts +14 -7
  53. package/data/Generator/templates/sdk/wasp/client/env.ts +4 -3
  54. package/data/Generator/templates/sdk/wasp/client/index.ts +3 -12
  55. package/data/Generator/templates/sdk/wasp/client/operations/actions/core.ts +14 -10
  56. package/data/Generator/templates/sdk/wasp/client/operations/actions/index.ts +7 -4
  57. package/data/Generator/templates/sdk/wasp/client/operations/index.ts +5 -5
  58. package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +1 -8
  59. package/data/Generator/templates/sdk/wasp/client/operations/queries/core.ts +13 -55
  60. package/data/Generator/templates/sdk/wasp/client/operations/queries/index.ts +7 -7
  61. package/data/Generator/templates/sdk/wasp/client/router/Link.tsx +8 -8
  62. package/data/Generator/templates/sdk/wasp/client/router/NavLink.tsx +8 -8
  63. package/data/Generator/templates/sdk/wasp/client/router/index.ts +15 -15
  64. package/data/Generator/templates/sdk/wasp/client/test/index.ts +2 -1
  65. package/data/Generator/templates/sdk/wasp/client/test/vitest/helpers.tsx +5 -36
  66. package/data/Generator/templates/sdk/wasp/client/vite/index.ts +2 -1
  67. package/data/Generator/templates/sdk/wasp/client/vite/plugins/virtualUserModules.ts +43 -0
  68. package/data/Generator/templates/sdk/wasp/client/vite/plugins/{virtualModules.ts → virtualWaspModules.ts} +4 -4
  69. package/data/Generator/templates/sdk/wasp/client/vite/plugins/wasp.ts +17 -14
  70. package/data/Generator/templates/sdk/wasp/client/vite/plugins/waspConfig.ts +60 -18
  71. package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/client-entry.tsx +1 -1
  72. package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/routes.tsx +1 -1
  73. package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/ssr-entry.tsx +1 -1
  74. package/data/Generator/templates/sdk/wasp/client/webSocket/WebSocketProvider.tsx +3 -3
  75. package/data/Generator/templates/sdk/wasp/client/webSocket/index.ts +1 -1
  76. package/data/Generator/templates/sdk/wasp/core/serialization/index.ts +2 -47
  77. package/data/Generator/templates/sdk/wasp/core/serialization/prisma.ts +0 -1
  78. package/data/Generator/templates/sdk/wasp/entities/index.ts +6 -6
  79. package/data/Generator/templates/sdk/wasp/env/index.ts +1 -9
  80. package/data/Generator/templates/sdk/wasp/package.json +150 -104
  81. package/data/Generator/templates/sdk/wasp/server/_types/index.ts +8 -10
  82. package/data/Generator/templates/sdk/wasp/server/_types/taggedEntities.ts +4 -4
  83. package/data/Generator/templates/sdk/wasp/server/api/index.ts +5 -5
  84. package/data/Generator/templates/sdk/wasp/server/auth/email/index.ts +2 -12
  85. package/data/Generator/templates/sdk/wasp/server/auth/email/utils.ts +8 -30
  86. package/data/Generator/templates/sdk/wasp/server/auth/hooks.ts +5 -2
  87. package/data/Generator/templates/sdk/wasp/server/auth/index.ts +3 -3
  88. package/data/Generator/templates/sdk/wasp/{auth → server/auth}/jwt.ts +1 -1
  89. package/data/Generator/templates/sdk/wasp/{auth → server/auth}/lucia.ts +4 -4
  90. package/data/Generator/templates/sdk/wasp/server/auth/oauth/oneTimeCode.ts +1 -1
  91. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/discord.ts +1 -1
  92. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/github.ts +1 -1
  93. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/google.ts +1 -1
  94. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/keycloak.ts +1 -1
  95. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/microsoft.ts +1 -1
  96. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/slack.ts +1 -1
  97. package/data/Generator/templates/sdk/wasp/{auth → server/auth}/session.ts +17 -6
  98. package/data/Generator/templates/sdk/wasp/{auth → server/auth}/utils.ts +40 -183
  99. package/data/Generator/templates/sdk/wasp/server/config.ts +1 -1
  100. package/data/Generator/templates/sdk/wasp/{core → server/core}/auth.ts +3 -3
  101. package/data/Generator/templates/sdk/wasp/server/crud/_operationTypes.ts +16 -63
  102. package/data/Generator/templates/sdk/wasp/server/dbClient.ts +15 -17
  103. package/data/Generator/templates/sdk/wasp/server/email/core/helpers.ts +3 -20
  104. package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +2 -2
  105. package/data/Generator/templates/sdk/wasp/server/email/core/providers/resend.ts +2 -1
  106. package/data/Generator/templates/sdk/wasp/server/email/core/providers/smtp.ts +2 -1
  107. package/data/Generator/templates/sdk/wasp/server/email/core/types.ts +2 -45
  108. package/data/Generator/templates/sdk/wasp/server/email/index.ts +1 -1
  109. package/data/Generator/templates/sdk/wasp/server/env.ts +20 -11
  110. package/data/Generator/templates/sdk/wasp/server/index.ts +3 -3
  111. package/data/Generator/templates/sdk/wasp/server/jobs/_job.ts +1 -1
  112. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/index.ts +1 -1
  113. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBossJob.ts +4 -4
  114. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/types.ts +1 -1
  115. package/data/Generator/templates/sdk/wasp/server/middleware/index.ts +1 -1
  116. package/data/Generator/templates/sdk/wasp/server/operations/actions/index.ts +14 -8
  117. package/data/Generator/templates/sdk/wasp/server/operations/actions/types.ts +5 -5
  118. package/data/Generator/templates/sdk/wasp/server/operations/queries/index.ts +14 -8
  119. package/data/Generator/templates/sdk/wasp/server/operations/queries/types.ts +5 -5
  120. package/data/Generator/templates/sdk/wasp/server/operations/wrappers.ts +40 -14
  121. package/data/Generator/templates/sdk/wasp/server/types/index.ts +1 -11
  122. package/data/Generator/templates/sdk/wasp/server/utils.ts +5 -20
  123. package/data/Generator/templates/sdk/wasp/server/webSocket/index.ts +7 -7
  124. package/data/Generator/templates/sdk/wasp/tsconfig.json +20 -46
  125. package/data/Generator/templates/sdk/wasp/types/index.ts +8 -0
  126. package/data/Generator/templates/sdk/wasp/types/register.ts +21 -0
  127. package/data/Generator/templates/sdk/wasp/vite-env.d.ts +0 -9
  128. package/data/Generator/templates/sdk/wasp/wasp-ssr.d.ts +8 -0
  129. package/data/Generator/templates/sdk/wasp/wasp-user-virtual-modules.d.ts +20 -0
  130. package/data/Generator/templates/server/package.json +2 -1
  131. package/data/Generator/templates/server/rollup.config.js +2 -43
  132. package/data/Generator/templates/server/rollup.dbSeed.config.js +3 -0
  133. package/data/Generator/templates/server/src/app.js +2 -2
  134. package/data/Generator/templates/server/src/auth/providers/config/email.ts +5 -5
  135. package/data/Generator/templates/server/src/auth/providers/email/login.ts +4 -4
  136. package/data/Generator/templates/server/src/auth/providers/email/requestPasswordReset.ts +4 -4
  137. package/data/Generator/templates/server/src/auth/providers/email/resetPassword.ts +13 -5
  138. package/data/Generator/templates/server/src/auth/providers/email/signup.ts +29 -18
  139. package/data/Generator/templates/server/src/auth/providers/email/verifyEmail.ts +7 -2
  140. package/data/Generator/templates/server/src/auth/providers/oauth/cookies.ts +5 -1
  141. package/data/Generator/templates/server/src/auth/providers/oauth/handler.ts +1 -1
  142. package/data/Generator/templates/server/src/auth/providers/oauth/oneTimeCode.ts +2 -2
  143. package/data/Generator/templates/server/src/auth/providers/oauth/state.ts +55 -13
  144. package/data/Generator/templates/server/src/auth/providers/oauth/user.ts +6 -3
  145. package/data/Generator/templates/server/src/auth/providers/username/login.ts +4 -4
  146. package/data/Generator/templates/server/src/auth/providers/username/signup.ts +12 -4
  147. package/data/Generator/templates/server/src/createRollupBundle.js +47 -0
  148. package/data/Generator/templates/server/src/crud/_operations.ts +16 -16
  149. package/data/Generator/templates/server/src/plugins/virtualUserModules.js +40 -0
  150. package/data/Generator/templates/server/src/routes/apis/index.ts +3 -3
  151. package/data/Generator/templates/server/src/routes/auth/index.js +1 -1
  152. package/data/Generator/templates/server/src/routes/auth/logout.ts +2 -2
  153. package/data/Generator/templates/server/src/routes/crud/_crud.ts +1 -1
  154. package/data/Generator/templates/server/src/routes/index.js +18 -18
  155. package/data/Generator/templates/server/src/routes/operations/index.js +1 -1
  156. package/data/Generator/templates/server/src/webSocket/initialization.ts +1 -1
  157. package/data/Generator/templates/server/tsconfig.json +7 -13
  158. package/data/Generator/templates/types/app/sdk/register.ts +57 -0
  159. package/data/packages/deploy/dist/common/cliVersion.js +17 -0
  160. package/data/packages/deploy/dist/common/waspProject.js +1 -1
  161. package/data/packages/deploy/dist/common/zx.js +24 -6
  162. package/data/packages/deploy/dist/providers/fly/commands/createDb/createDb.js +13 -5
  163. package/data/packages/deploy/dist/providers/fly/flyCli.js +29 -17
  164. package/data/packages/deploy/dist/providers/fly/index.js +16 -8
  165. package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +19 -31
  166. package/data/packages/deploy/dist/providers/railway/index.js +11 -2
  167. package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +19 -34
  168. package/data/packages/deploy/dist/providers/railway/railwayCli.js +11 -20
  169. package/data/packages/deploy/dist/providers/railway/railwayEnvironment/cli.js +20 -0
  170. package/data/packages/deploy/dist/providers/railway/railwayProject/RailwayProject.js +4 -1
  171. package/data/packages/deploy/dist/providers/railway/railwayProject/cli.js +6 -14
  172. package/data/packages/deploy/dist/providers/railway/railwayService/database.js +88 -0
  173. package/data/packages/deploy/dist/providers/railway/railwayService/deployment.js +12 -25
  174. package/data/packages/deploy/dist/providers/railway/railwayService/nameGenerator.js +5 -4
  175. package/data/packages/deploy/dist/providers/railway/railwayService/serviceInstance.js +48 -0
  176. package/data/packages/deploy/dist/providers/railway/railwayService/url.js +9 -30
  177. package/data/packages/deploy/package-lock.json +2 -2
  178. package/data/packages/deploy/package.json +1 -1
  179. package/data/packages/prisma/package-lock.json +2 -2
  180. package/data/packages/prisma/package.json +1 -1
  181. package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.js +19 -15
  182. package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.js +6 -0
  183. package/data/packages/spec/dist/src/appSpec.d.ts +15 -2
  184. package/data/packages/spec/dist/src/appSpec.d.ts.map +1 -1
  185. package/data/packages/spec/dist/src/spec/mapper/app.d.ts +1 -0
  186. package/data/packages/spec/dist/src/spec/mapper/app.d.ts.map +1 -1
  187. package/data/packages/spec/dist/src/spec/mapper/app.js +8 -2
  188. package/data/packages/spec/dist/src/spec/mapper/context.js +4 -4
  189. package/data/packages/spec/dist/src/spec/mapper/specElements.js +9 -9
  190. package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts +11 -11
  191. package/data/packages/spec/dist/src/spec/publicApi/constructors.js +11 -11
  192. package/data/packages/spec/dist/src/spec/publicApi/register.d.ts +1 -1
  193. package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts +58 -38
  194. package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts.map +1 -1
  195. package/data/packages/spec/package-lock.json +2 -2
  196. package/data/packages/spec/package.json +1 -1
  197. package/data/packages/studio/package-lock.json +15 -23
  198. package/data/packages/studio/package.json +2 -2
  199. package/package.json +1 -1
  200. package/wasp-bin +0 -0
  201. package/data/Generator/libs/auth/wasp.sh-lib-auth-0.25.0.tgz +0 -0
  202. package/data/Generator/templates/sdk/wasp/api/events.ts +0 -11
  203. package/data/Generator/templates/sdk/wasp/auth/email/index.ts +0 -5
  204. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.module.css +0 -99
  205. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.tsx +0 -74
  206. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.module.css +0 -22
  207. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.tsx +0 -34
  208. package/data/Generator/templates/sdk/wasp/auth/forms/internal/auth-styles.css +0 -30
  209. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.module.css +0 -33
  210. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.tsx +0 -14
  211. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.module.css +0 -4
  212. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.tsx +0 -85
  213. package/data/Generator/templates/sdk/wasp/auth/forms/internal/util.ts +0 -16
  214. package/data/Generator/templates/sdk/wasp/auth/helpers/user.ts +0 -15
  215. package/data/Generator/templates/sdk/wasp/auth/responseSchemas.ts +0 -10
  216. package/data/Generator/templates/sdk/wasp/auth/types.ts +0 -2
  217. package/data/Generator/templates/sdk/wasp/auth/username/index.ts +0 -2
  218. package/data/Generator/templates/sdk/wasp/client/app/components/DefaultRootErrorBoundary.tsx +0 -16
  219. package/data/Generator/templates/sdk/wasp/client/app/components/FullPageWrapper.tsx +0 -21
  220. package/data/Generator/templates/sdk/wasp/client/app/components/Loader.module.css +0 -37
  221. package/data/Generator/templates/sdk/wasp/client/app/components/Loader.tsx +0 -12
  222. package/data/Generator/templates/sdk/wasp/client/app/components/Message.tsx +0 -86
  223. package/data/Generator/templates/sdk/wasp/client/crud/operationsHelpers.ts +0 -21
  224. package/data/Generator/templates/sdk/wasp/client/hooks.ts +0 -19
  225. package/data/Generator/templates/sdk/wasp/client/operations/hooks.ts +0 -347
  226. package/data/Generator/templates/sdk/wasp/client/operations/internal/resources.js +0 -85
  227. package/data/Generator/templates/sdk/wasp/client/operations/internal/updateHandlersMap.js +0 -37
  228. package/data/Generator/templates/sdk/wasp/client/operations/queryClient.ts +0 -34
  229. package/data/Generator/templates/sdk/wasp/client/operations/rpc.ts +0 -96
  230. package/data/Generator/templates/sdk/wasp/client/router/linkHelpers.ts +0 -48
  231. package/data/Generator/templates/sdk/wasp/client/router/types.ts +0 -98
  232. package/data/Generator/templates/sdk/wasp/client/vite/plugins/detectServerImports.ts +0 -50
  233. package/data/Generator/templates/sdk/wasp/client/vite/plugins/envFile.ts +0 -112
  234. package/data/Generator/templates/sdk/wasp/client/vite/plugins/typescriptCheck.ts +0 -36
  235. package/data/Generator/templates/sdk/wasp/client/vite/plugins/validateEnv.ts +0 -88
  236. package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/resolver.ts +0 -35
  237. package/data/Generator/templates/sdk/wasp/core/serialization/custom-register.ts +0 -21
  238. package/data/Generator/templates/sdk/wasp/core/storage.ts +0 -73
  239. package/data/Generator/templates/sdk/wasp/env/validation.ts +0 -44
  240. package/data/Generator/templates/sdk/wasp/server/HttpError.ts +0 -30
  241. package/data/Generator/templates/sdk/wasp/server/auth/oauth/provider.ts +0 -20
  242. package/data/Generator/templates/sdk/wasp/server/auth/user.ts +0 -154
  243. package/data/Generator/templates/sdk/wasp/server/auth/username.ts +0 -1
  244. package/data/Generator/templates/sdk/wasp/server/jobs/core/job.ts +0 -28
  245. package/data/Generator/templates/sdk/wasp/server/middleware/globalMiddleware.ts +0 -8
  246. package/data/Generator/templates/sdk/wasp/universal/ansiColors.ts +0 -58
  247. package/data/Generator/templates/sdk/wasp/universal/predicates.ts +0 -3
  248. package/data/Generator/templates/sdk/wasp/universal/types.ts +0 -74
  249. package/data/Generator/templates/sdk/wasp/universal/url.ts +0 -9
  250. package/data/Generator/templates/sdk/wasp/universal/validators.ts +0 -21
  251. package/data/packages/ts-inspect/dist/exports.js +0 -82
  252. package/data/packages/ts-inspect/dist/index.js +0 -28
  253. package/data/packages/ts-inspect/package-lock.json +0 -4724
  254. package/data/packages/ts-inspect/package.json +0 -31
  255. /package/data/Generator/templates/sdk/wasp/{auth → server/auth}/password.ts +0 -0
@@ -0,0 +1,40 @@
1
+ {{={= =}=}}
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const serverRootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
6
+
7
+ /**
8
+ * Maps virtual module IDs (pointing to user's server modules)
9
+ * to their relative import paths from the server project root.
10
+ *
11
+ * @example
12
+ * serverVirtualUserModuleMap["virtual:wasp/user/env"] // => "../../../src/env"
13
+ *
14
+ * @type {{ [virtualUserModule: string]: string }}
15
+ */
16
+ const serverVirtualUserModuleMap = {
17
+ {=# virtualUserModules =}
18
+ {=& virtualModuleId =}: {=& importJson.importPath =},
19
+ {=/ virtualUserModules =}
20
+ };
21
+
22
+ /**
23
+ * Resolves virtual modules pointing to user's modules.
24
+ * Virtual user modules allow Wasp code to depend on user code at runtime,
25
+ * without depending on the user's project during compile time.
26
+ *
27
+ * @returns {import("rollup").Plugin}
28
+ */
29
+ export function virtualUserModules() {
30
+ return {
31
+ name: "wasp:virtual-user-modules",
32
+ async resolveId(id) {
33
+ if (Object.hasOwn(serverVirtualUserModuleMap, id)) {
34
+ const absPath = path.resolve(serverRootDir, serverVirtualUserModuleMap[id]);
35
+ return await this.resolve(absPath, undefined, { skipSelf: true });
36
+ }
37
+ return null;
38
+ },
39
+ };
40
+ }
@@ -4,7 +4,7 @@ import { prisma } from 'wasp/server'
4
4
  import { defineHandler } from 'wasp/server/utils'
5
5
  import { MiddlewareConfigFn, globalMiddlewareConfigForExpress } from '../../middleware/index.js'
6
6
  {=# isAuthEnabled =}
7
- import auth from 'wasp/core/auth'
7
+ import auth from 'wasp/server/core/auth'
8
8
  import { type AuthUserData, makeAuthUserIfPossible } from 'wasp/auth/user'
9
9
  {=/ isAuthEnabled =}
10
10
 
@@ -30,13 +30,13 @@ const {=& routeMiddlewareConfigFn.importAlias =} = idFn
30
30
  const router = express.Router()
31
31
 
32
32
  {=# apiNamespaces =}
33
- router.use('{= namespacePath =}', globalMiddlewareConfigForExpress({= namespaceMiddlewareConfigFnImportAlias =}))
33
+ router.use({=& namespacePath =}, globalMiddlewareConfigForExpress({= namespaceMiddlewareConfigFnImportAlias =}))
34
34
  {=/ apiNamespaces =}
35
35
 
36
36
  {=# apiRoutes =}
37
37
  const {= apiName =}Middleware = globalMiddlewareConfigForExpress({= routeMiddlewareConfigFn.importAlias =})
38
38
  router.{= routeMethod =}(
39
- '{= routePath =}',
39
+ {=& routePath =},
40
40
  {=# usesAuth =}
41
41
  [auth, ...{= apiName =}Middleware],
42
42
  {=/ usesAuth =}
@@ -1,7 +1,7 @@
1
1
  {{={= =}=}}
2
2
  import express from 'express'
3
3
 
4
- import auth from 'wasp/core/auth'
4
+ import auth from 'wasp/server/core/auth'
5
5
  import me from './me.js'
6
6
  import logout from './logout.js'
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { defineHandler } from 'wasp/server/utils'
2
- import { createInvalidCredentialsError } from 'wasp/auth/utils'
3
- import { invalidateSession } from 'wasp/auth/session'
2
+ import { createInvalidCredentialsError } from 'wasp/server/auth/utils'
3
+ import { invalidateSession } from 'wasp/server/auth/session'
4
4
 
5
5
  export default defineHandler(async (req, res) => {
6
6
  if (req.sessionId) {
@@ -3,7 +3,7 @@ import express from 'express'
3
3
  import * as crud from '../../crud/{= crud.name =}.js'
4
4
  import { createAction, createQuery } from '../../middleware/operations.js'
5
5
  {=# isAuthEnabled =}
6
- import auth from 'wasp/core/auth'
6
+ import auth from 'wasp/server/core/auth'
7
7
  {=/ isAuthEnabled =}
8
8
 
9
9
  const _waspRouter = express.Router()
@@ -20,24 +20,6 @@ import { makeWrongPortPage } from '../views/wrong-port.js'
20
20
  const router = express.Router()
21
21
  const middleware = globalMiddlewareConfigForExpress()
22
22
 
23
- router.get('/', middleware,
24
- {=# isDevelopment =}
25
- function (_req, res) {
26
- const data = {
27
- appName: "{= appName =}",
28
- frontendUrl: config.frontendUrl
29
- };
30
- const wrongPortPage = makeWrongPortPage(data);
31
- res.status(200).type('html').send(wrongPortPage);
32
- }
33
- {=/ isDevelopment =}
34
- {=^ isDevelopment =}
35
- function (_req, res) {
36
- res.status(200).send();
37
- }
38
- {=/ isDevelopment =}
39
- )
40
-
41
23
  {=# isAuthEnabled =}
42
24
  router.use('/auth', middleware, auth)
43
25
  {=/ isAuthEnabled =}
@@ -45,6 +27,10 @@ router.use('/{= operationsRouteInRootRouter =}', middleware, operations)
45
27
  {=# areThereAnyCrudRoutes =}
46
28
  router.use('/{= crudRouteInRootRouter =}', middleware, rootCrudRouter)
47
29
  {=/ areThereAnyCrudRoutes =}
30
+ router.get('/{= upRouteInRootRouter =}', middleware, function (_req, res) {
31
+ res.status(200).json({ status: 'ok' })
32
+ })
33
+
48
34
  {=# areThereAnyCustomApiRoutes =}
49
35
  // NOTE: Keep user-defined api routes last so they cannot override our routes.
50
36
  // Additionally, do not add middleware to these routes here. Instead, we add
@@ -52,4 +38,18 @@ router.use('/{= crudRouteInRootRouter =}', middleware, rootCrudRouter)
52
38
  router.use(apis)
53
39
  {=/ areThereAnyCustomApiRoutes =}
54
40
 
41
+ {=# isDevelopment =}
42
+ // A page for people who open the server's URL in the browser by mistake.
43
+ // Registered last, so an `api` at `/` answers instead of it, and without the
44
+ // global middleware, since it's only ever read by a human in a browser.
45
+ router.get('/', function (_req, res) {
46
+ const data = {
47
+ appName: "{= appName =}",
48
+ frontendUrl: config.frontendUrl
49
+ };
50
+ const wrongPortPage = makeWrongPortPage(data);
51
+ res.status(200).type('html').send(wrongPortPage);
52
+ })
53
+ {=/ isDevelopment =}
54
+
55
55
  export default router
@@ -2,7 +2,7 @@
2
2
  import express from 'express'
3
3
 
4
4
  {=# isAuthEnabled =}
5
- import auth from 'wasp/core/auth'
5
+ import auth from 'wasp/server/core/auth'
6
6
  {=/ isAuthEnabled =}
7
7
 
8
8
  {=# operationRoutes =}
@@ -7,7 +7,7 @@ import type { ServerType } from 'wasp/server/webSocket'
7
7
  import { config, prisma } from 'wasp/server'
8
8
 
9
9
  {=# isAuthEnabled =}
10
- import { getSessionAndUserFromSessionId } from 'wasp/auth/session'
10
+ import { getSessionAndUserFromSessionId } from 'wasp/server/auth/session'
11
11
  import { makeAuthUserIfPossible } from 'wasp/auth/user'
12
12
  {=/ isAuthEnabled =}
13
13
 
@@ -4,19 +4,11 @@
4
4
  "compilerOptions": {
5
5
  // Overriding this until we implement more complete TypeScript support.
6
6
  "strict": false,
7
+ "useUnknownInCatchVariables": true,
7
8
  "allowJs": true,
8
-
9
- // This property currently doesn't matter because we haven't been running
10
- // TSC on server code since https://github.com/wasp-lang/wasp/pull/1714.
11
- //
12
- // When we start running TSC again (after we fix all current errors and
13
- // make project references work for the TS config), then I believe the
14
- // correct configuration is "rootDir": "." (the project reference should
15
- // take care of the user code), but we should double-check.
16
- //
17
- // Before changing this property, ensure you're aware of the implications:
18
- // - https://github.com/wasp-lang/wasp/pull/1584#discussion_r1404019301
19
- // - https://github.com/wasp-lang/wasp/pull/1713/files#diff-58191eecd9cc55f71c73de89420df8b1866dce38ad35f4ef0f6f8874616eda77R32
9
+ "checkJs": true,
10
+ // The project reference takes care of the user project,
11
+ // so `rootDir` only needs to include the server files.
20
12
  "rootDir": ".",
21
13
  // Enable source map for debugging
22
14
  "sourceMap": true,
@@ -34,7 +26,9 @@
34
26
  "types": ["node"]
35
27
  },
36
28
  "include": [
37
- "src"
29
+ "src",
30
+ "rollup.config.js",
31
+ "rollup.dbSeed.config.js"
38
32
  ],
39
33
  "references": [
40
34
  { "path": "{= srcTsConfigPath =}" }
@@ -0,0 +1,57 @@
1
+ {{={= =}=}}
2
+ /**
3
+ * This module augments SDK's `Register` type with the user project types.
4
+ */
5
+
6
+ // The import ensures the module is always loaded into the bundle.
7
+ // Otherwise, module augmentation can fail if it wasn't loaded.
8
+ import "wasp/types"
9
+
10
+ declare module "wasp/types" {
11
+ interface Register {
12
+ {=# prismaSetupFn.isDefined =}
13
+ prismaSetupFn: typeof {=& prismaSetupFn.dynamicImportExpression =}
14
+ {=/ prismaSetupFn.isDefined =}
15
+ {=# serverEnvValidationSchema.isDefined =}
16
+ serverEnvValidationSchema: typeof {=& serverEnvValidationSchema.dynamicImportExpression =}
17
+ {=/ serverEnvValidationSchema.isDefined =}
18
+ {=# clientEnvValidationSchema.isDefined =}
19
+ clientEnvValidationSchema: typeof {=& clientEnvValidationSchema.dynamicImportExpression =}
20
+ {=/ clientEnvValidationSchema.isDefined =}
21
+ {=# webSocketFn.isDefined =}
22
+ webSocketFn: typeof {=& webSocketFn.dynamicImportExpression =}
23
+ {=/ webSocketFn.isDefined =}
24
+ {=# emailUserSignupFields.isDefined =}
25
+ emailUserSignupFields: typeof {=& emailUserSignupFields.dynamicImportExpression =}
26
+ {=/ emailUserSignupFields.isDefined =}
27
+ {=# usernameAndPasswordUserSignupFields.isDefined =}
28
+ usernameAndPasswordUserSignupFields: typeof {=& usernameAndPasswordUserSignupFields.dynamicImportExpression =}
29
+ {=/ usernameAndPasswordUserSignupFields.isDefined =}
30
+ operations: {
31
+ {=# operations =}
32
+ '{= operationName =}': typeof {=& jsFn.dynamicImportExpression =}
33
+ {=/ operations =}
34
+ }
35
+ crudOverrides: {
36
+ {=# cruds =}
37
+ '{= name =}': {
38
+ {=# overrides.GetAll.isDefined =}
39
+ GetAll: typeof {=& overrides.GetAll.dynamicImportExpression =}
40
+ {=/ overrides.GetAll.isDefined =}
41
+ {=# overrides.Get.isDefined =}
42
+ Get: typeof {=& overrides.Get.dynamicImportExpression =}
43
+ {=/ overrides.Get.isDefined =}
44
+ {=# overrides.Create.isDefined =}
45
+ Create: typeof {=& overrides.Create.dynamicImportExpression =}
46
+ {=/ overrides.Create.isDefined =}
47
+ {=# overrides.Update.isDefined =}
48
+ Update: typeof {=& overrides.Update.dynamicImportExpression =}
49
+ {=/ overrides.Update.isDefined =}
50
+ {=# overrides.Delete.isDefined =}
51
+ Delete: typeof {=& overrides.Delete.dynamicImportExpression =}
52
+ {=/ overrides.Delete.isDefined =}
53
+ }
54
+ {=/ cruds =}
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,17 @@
1
+ import semver from "semver";
2
+ export function parseCliVersion(cliName, rawVersion) {
3
+ const version = semver.parse(rawVersion);
4
+ if (version === null) {
5
+ throw new Error(`Unable to parse ${cliName} version "${rawVersion}".`);
6
+ }
7
+ return version;
8
+ }
9
+ export function assertCliVersionMeetsMinimum({ cliName, currentVersion, minimumVersion, updateInstructions, }) {
10
+ if (!semver.gte(currentVersion, minimumVersion)) {
11
+ throw new Error([
12
+ `Wasp expects at least ${cliName} version ${minimumVersion}.`,
13
+ updateInstructions,
14
+ ].join("\n"));
15
+ }
16
+ }
17
+ //# sourceMappingURL=cliVersion.js.map
@@ -4,7 +4,7 @@ import { assertDirExists, assertDirPathIsAbsolute } from "./validation.js";
4
4
  import { createCommandWithCwd } from "./zx.js";
5
5
  export async function assertValidWaspProject(waspProjectDir, waspExe) {
6
6
  const waspCli = createCommandWithCwd(waspExe, waspProjectDir);
7
- const result = await waspCli(["info"], {
7
+ const result = await waspCli(["show", "spec", "--json"], {
8
8
  quiet: true,
9
9
  nothrow: true,
10
10
  });
@@ -1,10 +1,28 @@
1
- import { $ } from "zx";
2
- export function createCommandWithCwd(command, cwd) {
1
+ import { $, } from "zx";
2
+ export function createCommand(command, defaultOptions = {}) {
3
3
  return (commandArgs, options) => {
4
- return $({
5
- cwd,
6
- ...(options ?? {}),
7
- }) `${command} ${commandArgs}`;
4
+ return $({ ...defaultOptions, ...options }) `${command} ${commandArgs}`;
8
5
  };
9
6
  }
7
+ export function createCommandWithCwd(command, cwd) {
8
+ return createCommand(command, { cwd });
9
+ }
10
+ export async function runJsonCommand(command, commandArgs, schema) {
11
+ const result = await command(commandArgs, { verbose: false });
12
+ return schema.parse(parseJsonFromStdout(result));
13
+ }
14
+ export async function tryRunJsonCommand(command, commandArgs, schema) {
15
+ const result = await command(commandArgs, { verbose: false, nothrow: true });
16
+ if (result.exitCode !== 0) {
17
+ return null;
18
+ }
19
+ return schema.parse(parseJsonFromStdout(result));
20
+ }
21
+ // zx's `ProcessOutput.json()` parses the combined stdout and stderr, but CLIs
22
+ // write progress messages to stderr (e.g. `railway add --json` echoes the
23
+ // prompt answers there), which would corrupt the JSON.
24
+ // Reported to zx: https://github.com/google/zx/issues/1505
25
+ function parseJsonFromStdout(output) {
26
+ return JSON.parse(output.stdout);
27
+ }
10
28
  //# sourceMappingURL=zx.js.map
@@ -25,14 +25,22 @@ export async function createDb(region, cmdOptions) {
25
25
  "--region",
26
26
  deploymentInstructions.region,
27
27
  "--vm-size",
28
- cmdOptions.vmSize,
28
+ cmdOptions.dbVmSize,
29
29
  "--initial-cluster-size",
30
- cmdOptions.initialClusterSize,
30
+ cmdOptions.dbInitialClusterSize,
31
31
  "--volume-size",
32
- cmdOptions.volumeSize,
32
+ cmdOptions.dbVolumeSize,
33
+ "--image-ref",
34
+ cmdOptions.dbImage,
33
35
  ];
34
- if (cmdOptions.dbImage) {
35
- createArgs.push("--image-ref", cmdOptions.dbImage);
36
+ if (cmdOptions.dbVmMemory) {
37
+ createArgs.push("--vm-memory", cmdOptions.dbVmMemory);
38
+ }
39
+ if (cmdOptions.dbVmCpus) {
40
+ createArgs.push("--vm-cpus", cmdOptions.dbVmCpus);
41
+ }
42
+ if (cmdOptions.dbVmCpuKind) {
43
+ createArgs.push("--vm-cpu-kind", cmdOptions.dbVmCpuKind);
36
44
  }
37
45
  if (deploymentInstructions.cmdOptions.org) {
38
46
  createArgs.push("--org", deploymentInstructions.cmdOptions.org);
@@ -1,17 +1,12 @@
1
1
  import { confirm } from "@inquirer/prompts";
2
+ import { SemVer } from "semver";
2
3
  import { $ } from "zx";
4
+ import { assertCliVersionMeetsMinimum, parseCliVersion, } from "../../common/cliVersion.js";
3
5
  import { getFullCommandName } from "../../common/commander.js";
6
+ import { createCommand, runJsonCommand } from "../../common/zx.js";
4
7
  import { executeFlyCommand } from "./index.js";
5
8
  import { FlyRegionListSchema, FlySecretListSchema, } from "./jsonOutputSchemas.js";
6
- export async function flyctlExists() {
7
- try {
8
- await $ `flyctl version`;
9
- return true;
10
- }
11
- catch {
12
- return false;
13
- }
14
- }
9
+ const minSupportedFlyCliVersion = new SemVer("0.4.82");
15
10
  export async function isUserLoggedIn() {
16
11
  try {
17
12
  await $ `flyctl auth whoami`;
@@ -40,12 +35,29 @@ async function ensureUserLoggedIn() {
40
35
  }
41
36
  }
42
37
  export async function ensureFlyReady() {
43
- const doesFlyctlExist = await flyctlExists();
44
- if (!doesFlyctlExist) {
45
- throw new Error(`The Fly.io CLI is not available on this system.\nPlease install the flyctl here: https://fly.io/docs/hands-on/install-flyctl`);
46
- }
38
+ const flyCliVersion = await getFlyCliVersion();
39
+ assertCliVersionMeetsMinimum({
40
+ cliName: "Fly CLI",
41
+ currentVersion: flyCliVersion,
42
+ minimumVersion: minSupportedFlyCliVersion,
43
+ updateInstructions: "Read how to update the Fly CLI here: https://fly.io/docs/hands-on/install-flyctl",
44
+ });
47
45
  await ensureUserLoggedIn();
48
46
  }
47
+ async function getFlyCliVersion() {
48
+ const result = await $({ nothrow: true }) `flyctl version`;
49
+ if (result.exitCode !== 0) {
50
+ throw new Error([
51
+ "Failed to get Fly CLI version. Most likely the Fly CLI is not installed.",
52
+ "Read how to install the Fly CLI here: https://fly.io/docs/hands-on/install-flyctl",
53
+ ].join("\n"));
54
+ }
55
+ const match = result.stdout.match(/flyctl(?:\.exe)? v?(\S+)/);
56
+ if (match === null) {
57
+ throw new Error(`Failed to get Fly CLI version from output "${result.stdout.trim()}".`);
58
+ }
59
+ return parseCliVersion("Fly CLI", match[1]);
60
+ }
49
61
  export async function assertRegionIsValid(region) {
50
62
  const validRegion = await regionExists(region);
51
63
  if (!validRegion) {
@@ -57,15 +69,15 @@ export async function assertRegionIsValid(region) {
57
69
  }
58
70
  }
59
71
  async function regionExists(regionCode) {
60
- const proc = await $ `flyctl platform regions -j`.verbose(false);
61
- const regions = FlyRegionListSchema.parse(proc.json());
72
+ const flyCli = createCommand("flyctl");
73
+ const regions = await runJsonCommand(flyCli, ["platform", "regions", "-j"], FlyRegionListSchema);
62
74
  return regions.some((r) => {
63
75
  return r.code === regionCode;
64
76
  });
65
77
  }
66
78
  export async function secretExists(secretName) {
67
- const proc = await $ `flyctl secrets list -j`;
68
- const secrets = FlySecretListSchema.parse(proc.json());
79
+ const flyCli = createCommand("flyctl");
80
+ const secrets = await runJsonCommand(flyCli, ["secrets", "list", "-j"], FlySecretListSchema);
69
81
  return secrets.some((s) => s.name === secretName);
70
82
  }
71
83
  //# sourceMappingURL=flyCli.js.map
@@ -8,18 +8,26 @@ import { setup as setupFn } from "./commands/setup/setup.js";
8
8
  import { ContextOption } from "./CommonOps.js";
9
9
  import { assertRegionIsValid, ensureFlyReady } from "./flyCli.js";
10
10
  import { assertFlyTomlDirIsAbsoluteAndPresent } from "./tomlFile.js";
11
+ // Pinned to the same Postgres major as Wasp's dev database (keep in sync with
12
+ // Wasp.Db.Postgres.defaultPostgresDockerImageSpec). Without an explicit image,
13
+ // flyctl uses a server-side default that Fly can bump across majors
14
+ // (wasp-lang/wasp#4564).
15
+ const defaultDbImage = "flyio/postgres-flex:18";
11
16
  class FlyCommand extends Command {
12
17
  addBasenameArgument() {
13
18
  return this.argument("<basename>", "base app name to use on Fly.io (must be unique)");
14
19
  }
15
20
  addRegionArgument() {
16
- return this.argument("<region>", "3 letter deployment region to use on Fly.io");
21
+ return this.argument("<region>", "3 letter deployment region to use on Fly.io", (region) => region.toLowerCase());
17
22
  }
18
23
  addDbOptions() {
19
- return this.option("--vm-size <vmSize>", "flyctl postgres create option", "shared-cpu-1x")
20
- .option("--initial-cluster-size <initialClusterSize>", "flyctl postgres create option", "1")
21
- .option("--volume-size <volumeSize>", "flyctl postgres create option", "1")
22
- .option("--db-image <dbImage>", "custom Docker image for the PostgreSQL database");
24
+ return this.option("--db-vm-size <vmSize>", "Fly Postgres VM size", "shared-cpu-1x")
25
+ .option("--db-vm-memory <vmMemory>", "Fly Postgres VM memory in MB")
26
+ .option("--db-vm-cpus <vmCpus>", "Fly Postgres VM CPU count")
27
+ .option("--db-vm-cpu-kind <vmCpuKind>", "Fly Postgres VM CPU kind")
28
+ .option("--db-initial-cluster-size <initialClusterSize>", "Fly Postgres initial cluster size", "1")
29
+ .option("--db-volume-size <volumeSize>", "Fly Postgres volume size in GB", "1")
30
+ .option("--db-image <dbImage>", "Fly Postgres Docker image", defaultDbImage);
23
31
  }
24
32
  addLocalBuildOption() {
25
33
  return this.option("--build-locally", "build Docker containers locally instead of remotely", false);
@@ -73,9 +81,9 @@ export function createFlyCommand() {
73
81
  });
74
82
  });
75
83
  // Add command-specific hooks.
76
- flyLaunchCommand.hook("preAction", (_thisCommand, actionCommand) => assertRegionIsValid(actionCommand.args[1]));
77
- flySetupCommand.hook("preAction", (_thisCommand, actionCommand) => assertRegionIsValid(actionCommand.args[1]));
78
- createFlyDbCommand.hook("preAction", (_thisCommand, actionCommand) => assertRegionIsValid(actionCommand.args[0]));
84
+ flyLaunchCommand.hook("preAction", (_thisCommand, actionCommand) => assertRegionIsValid(actionCommand.processedArgs[1]));
85
+ flySetupCommand.hook("preAction", (_thisCommand, actionCommand) => assertRegionIsValid(actionCommand.processedArgs[1]));
86
+ createFlyDbCommand.hook("preAction", (_thisCommand, actionCommand) => assertRegionIsValid(actionCommand.processedArgs[0]));
79
87
  return fly;
80
88
  }
81
89
  function makeFlyLaunchCommand() {
@@ -7,8 +7,10 @@ import { createCommandWithCwd } from "../../../../common/zx.js";
7
7
  import { createDeploymentInstructions, } from "../../DeploymentInstructions.js";
8
8
  import { getRailwayEnvVarValueReference } from "../../env.js";
9
9
  import { clientAppPort, serverAppPort } from "../../ports.js";
10
+ import { getLinkedEnvironmentId } from "../../railwayEnvironment/cli.js";
10
11
  import { initRailwayProject, linkRailwayProjectToWaspProjectDir, } from "../../railwayProject/cli.js";
11
12
  import { getRailwayProjectStatus, ProjectStatus, } from "../../railwayProject/index.js";
13
+ import { assertDatabaseServiceHasVolume, createDatabaseService, } from "../../railwayService/database.js";
12
14
  import { waitForServiceDeploymentSuccess } from "../../railwayService/deployment.js";
13
15
  import { generateServiceUrl } from "../../railwayService/url.js";
14
16
  export async function setup(projectName, options) {
@@ -22,8 +24,10 @@ export async function setup(projectName, options) {
22
24
  workspace: options.workspace,
23
25
  });
24
26
  await ensureWaspProjectIsBuilt(options);
25
- if (project.doesServiceExist(deploymentInstructions.dbServiceName)) {
26
- waspSays("Postgres service already exists. Skipping database setup.");
27
+ const dbService = project.findService(deploymentInstructions.dbServiceName);
28
+ if (dbService) {
29
+ waspSays("Postgres service already exists. Skipping database creation.");
30
+ await assertDatabaseServiceHasVolume(dbService, options.dbVolumeMountPath, options);
27
31
  }
28
32
  else {
29
33
  await setupDb(deploymentInstructions);
@@ -72,39 +76,23 @@ async function setupRailwayProjectForDirectory({ railwayExe, projectName, waspPr
72
76
  }
73
77
  }
74
78
  async function setupDb({ cmdOptions: options, dbServiceName, }) {
75
- waspSays("Setting up database");
76
- const railwayCli = createCommandWithCwd(options.railwayExe, options.waspProjectDir);
77
- if (options.dbImage) {
78
- waspSays(`Using custom database image: ${options.dbImage}`);
79
- // When using a custom database image, Railway doesn't automatically set the default
80
- // Postgres-related environment variables, so we need to set them ourselves.
81
- await railwayCli([
82
- "add",
83
- ...["--service", dbServiceName],
84
- ...["--image", options.dbImage],
85
- ...["--variables", "POSTGRES_DB=railway"],
86
- ...["--variables", "POSTGRES_USER=postgres"],
87
- ...[
88
- "--variables",
89
- `POSTGRES_PASSWORD=${getRailwayEnvVarValueReference("secret()")}`,
90
- ],
91
- ...["--variables", "PORT=5432"],
92
- ...["--variables", "PGDATA=/var/lib/postgresql/data/pgdata"],
93
- ...[
94
- "--variables",
95
- `DATABASE_URL=postgresql://${getRailwayEnvVarValueReference("POSTGRES_USER")}:${getRailwayEnvVarValueReference("POSTGRES_PASSWORD")}@${getRailwayEnvVarValueReference("RAILWAY_PRIVATE_DOMAIN")}:${getRailwayEnvVarValueReference("PORT")}/${getRailwayEnvVarValueReference("POSTGRES_DB")}`,
96
- ],
97
- ]);
98
- }
99
- else {
100
- // Use the default Railway Postgres template.
101
- await railwayCli(["add", "-d", "postgres"]);
102
- }
79
+ waspSays(`Setting up database using image: ${options.dbImage}`);
80
+ const environmentId = await getLinkedEnvironmentId(options);
81
+ const dbService = await createDatabaseService({
82
+ serviceName: dbServiceName,
83
+ imageSpec: {
84
+ image: options.dbImage,
85
+ volumeMountPath: options.dbVolumeMountPath,
86
+ },
87
+ environmentId,
88
+ railwayExe: options.railwayExe,
89
+ waspProjectDir: options.waspProjectDir,
90
+ });
103
91
  // The database service deploys asynchronously and `railway add` doesn't wait
104
92
  // for it. The server service references the database's DATABASE_URL env
105
93
  // variable, and Railway references to a service that isn't fully set up
106
94
  // silently resolve to an empty string and never recover.
107
- await waitForServiceDeploymentSuccess(dbServiceName, options);
95
+ await waitForServiceDeploymentSuccess(dbService, options);
108
96
  }
109
97
  async function setupServer({ cmdOptions: options, serverServiceName, clientServiceName, dbServiceName, }) {
110
98
  waspSays(`Setting up server app with name ${serverServiceName}`);
@@ -5,6 +5,12 @@ import { launch as launchFn } from "./commands/launch/launch.js";
5
5
  import { setup as setupFn } from "./commands/setup/setup.js";
6
6
  import { assertRailwayProjectNameIsValid, ensureRailwayCliReady, } from "./railwayCli.js";
7
7
  import { retryOnRailwayAPIError } from "./retry.js";
8
+ // Pinned to the same Postgres major as Wasp's dev database. Keep in sync with
9
+ // Wasp.Db.Postgres.defaultPostgresDockerImageSpec.
10
+ const defaultDbOptions = {
11
+ image: "ghcr.io/railwayapp-templates/postgres-ssl:18",
12
+ volumeMountPath: "/var/lib/postgresql/data",
13
+ };
8
14
  class RailwayCommand extends Command {
9
15
  addProjectNameArgument() {
10
16
  return this.argument("<project-name>", "project name to use on Railway");
@@ -18,6 +24,9 @@ class RailwayCommand extends Command {
18
24
  addCustomServerUrlOption() {
19
25
  return this.option("--custom-server-url <url>", "URL of the server that the client will connect to");
20
26
  }
27
+ addDbOptions() {
28
+ return this.option("--db-image <dbImage>", "Docker image for the PostgreSQL database", defaultDbOptions.image).option("--db-volume-mount-path <dbVolumeMountPath>", "Path inside the PostgreSQL container where the volume is mounted", defaultDbOptions.volumeMountPath);
29
+ }
21
30
  }
22
31
  export const railwaySetupCommand = makeRailwaySetupCommand();
23
32
  export const railwayDeployCommand = makeRailwayDeployCommand();
@@ -62,7 +71,7 @@ function makeRailwaySetupCommand() {
62
71
  .addSecretsOptions()
63
72
  .option("--existing-project-id [projectId]", "use existing project instead of creating a new one")
64
73
  .option("--workspace [workspace]", "the Railway workspace to use if a new project needs to be created (if not provided, will ask interactively)")
65
- .option("--db-image <dbImage>", "custom Docker image for the PostgreSQL database")
74
+ .addDbOptions()
66
75
  .action((...args) => retryOnRailwayAPIError(() => setupFn(...args)));
67
76
  }
68
77
  function makeRailwayDeployCommand() {
@@ -82,7 +91,7 @@ function makeRailwayLaunchCommand() {
82
91
  .addSecretsOptions()
83
92
  .option("--existing-project-id [projectId]", "use existing project instead of creating a new one")
84
93
  .option("--workspace [workspace]", "the Railway workspace to use if a new project needs to be created (if not provided, will ask interactively)")
85
- .option("--db-image <dbImage>", "custom Docker image for the PostgreSQL database")
94
+ .addDbOptions()
86
95
  .addCustomServerUrlOption()
87
96
  .action(launchFn);
88
97
  }