@cedarjs/cli 7.0.1-next.467 → 7.1.0-rc.34

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 (194) hide show
  1. package/dist/commands/build/buildHandler.js +1 -2
  2. package/dist/commands/build.js +1 -1
  3. package/dist/commands/check.js +1 -2
  4. package/dist/commands/deploy/baremetal/baremetalHandler.js +73 -364
  5. package/dist/commands/deploy/baremetal.js +1 -7
  6. package/dist/commands/deploy/flightcontrolHandler.js +1 -1
  7. package/dist/commands/deploy/helpers/deployHandler.js +1 -1
  8. package/dist/commands/deploy/netlify.js +1 -1
  9. package/dist/commands/deploy/renderHandler.js +1 -1
  10. package/dist/commands/deploy/serverlessHandler.js +1 -2
  11. package/dist/commands/deploy/vercel.js +1 -1
  12. package/dist/commands/destroy/handlerHelpers.js +1 -1
  13. package/dist/commands/destroy/page/pageHandler.js +1 -2
  14. package/dist/commands/destroy/scaffold/scaffoldHandler.js +26 -65
  15. package/dist/commands/destroy/sdl/sdlHandler.js +1 -2
  16. package/dist/commands/dev/devHandler.js +4 -3
  17. package/dist/commands/dev/packageWatchCommands.js +3 -8
  18. package/dist/commands/dev.js +1 -1
  19. package/dist/commands/execHandler.js +1 -2
  20. package/dist/commands/experimental/live-queries/liveQueries.js +1 -1
  21. package/dist/commands/experimental/live-queries/liveQueriesHandler.js +3 -3
  22. package/dist/commands/experimental/setupInngest.js +1 -1
  23. package/dist/commands/experimental/setupInngestHandler.js +1 -1
  24. package/dist/commands/experimental/setupOpentelemetry.js +1 -1
  25. package/dist/commands/experimental/setupOpentelemetryHandler.js +1 -2
  26. package/dist/commands/experimental/setupReactCompiler.js +1 -1
  27. package/dist/commands/experimental/setupReactCompilerHandler.js +4 -4
  28. package/dist/commands/experimental/setupRsc.js +1 -1
  29. package/dist/commands/experimental/setupRscHandler.js +1 -2
  30. package/dist/commands/experimental/setupStreamingSsr.js +1 -1
  31. package/dist/commands/experimental/setupStreamingSsrHandler.js +2 -3
  32. package/dist/commands/generate/cell/cell.js +0 -20
  33. package/dist/commands/generate/cell/cellHandler.js +20 -68
  34. package/dist/commands/generate/cell/templates/cell.tsx.template +2 -21
  35. package/dist/commands/generate/cell/templates/cellList.tsx.template +2 -21
  36. package/dist/commands/generate/cell/templates/test.js.template +1 -1
  37. package/dist/commands/generate/dataMigration/dataMigration.js +1 -2
  38. package/dist/commands/generate/dbAuth/dbAuth.js +2 -6
  39. package/dist/commands/generate/dbAuth/dbAuthHandler.js +17 -80
  40. package/dist/commands/generate/dbAuth/templates/login.webAuthn.tsx.template +12 -20
  41. package/dist/commands/generate/directive/directiveHandler.js +1 -2
  42. package/dist/commands/generate/function/functionHandler.js +1 -2
  43. package/dist/commands/generate/helpers.js +0 -26
  44. package/dist/commands/generate/job/jobHandler.js +1 -2
  45. package/dist/commands/generate/model/modelHandler.js +1 -2
  46. package/dist/commands/generate/ogImage/ogImageHandler.js +1 -2
  47. package/dist/commands/generate/ogImage/templates/ogImage.og.tsx.template +1 -1
  48. package/dist/commands/generate/package/filesTask.js +12 -9
  49. package/dist/commands/generate/package/packageHandler.js +4 -3
  50. package/dist/commands/generate/package/templates/tsconfig.json.template +0 -1
  51. package/dist/commands/generate/page/pageHandler.js +1 -2
  52. package/dist/commands/generate/realtime/realtime.js +1 -1
  53. package/dist/commands/generate/realtime/realtimeHandler.js +9 -2
  54. package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.service.ts.template +4 -12
  55. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.service.ts.template +2 -2
  56. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +4 -4
  57. package/dist/commands/generate/scaffold/scaffold.js +1 -1
  58. package/dist/commands/generate/scaffold/scaffoldHandler.js +49 -93
  59. package/dist/commands/generate/scaffold/templates/assets/scaffold.tailwind.css.template +7 -12
  60. package/dist/commands/generate/scaffold/templates/components/EditNameCell.tsx.template +7 -5
  61. package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +9 -10
  62. package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +0 -11
  63. package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +4 -16
  64. package/dist/commands/generate/script/scriptHandler.js +1 -2
  65. package/dist/commands/generate/script/templates/tsconfig.json.template +0 -1
  66. package/dist/commands/generate/sdl/sdlHandler.js +4 -10
  67. package/dist/commands/generate/secret/secret.js +1 -1
  68. package/dist/commands/generate/service/serviceHandler.js +49 -79
  69. package/dist/commands/generate/service/templates/service.ts.template +13 -40
  70. package/dist/commands/generate/service/templates/test.ts.template +6 -8
  71. package/dist/commands/generate/yargsCommandHelpers.js +1 -1
  72. package/dist/commands/generate/yargsHandlerHelpers.js +1 -2
  73. package/dist/commands/generate.js +1 -1
  74. package/dist/commands/info.js +1 -1
  75. package/dist/commands/jobsHandler.js +3 -5
  76. package/dist/commands/lint.js +1 -1
  77. package/dist/commands/prerenderHandler.js +4 -11
  78. package/dist/commands/prismaHandler.js +2 -7
  79. package/dist/commands/record/init.js +1 -1
  80. package/dist/commands/serve.js +1 -2
  81. package/dist/commands/setup/auth/auth.js +4 -2
  82. package/dist/commands/setup/cache/cache.js +1 -1
  83. package/dist/commands/setup/cache/cacheHandler.js +1 -2
  84. package/dist/commands/setup/cache/templates/memcached.ts.template +17 -14
  85. package/dist/commands/setup/cache/templates/redis.ts.template +20 -12
  86. package/dist/commands/setup/database/postgres.js +1 -1
  87. package/dist/commands/setup/database/postgresHandler.js +1 -3
  88. package/dist/commands/setup/deploy/providers/baremetal.js +0 -7
  89. package/dist/commands/setup/deploy/providers/baremetalHandler.js +21 -130
  90. package/dist/commands/setup/deploy/providers/coherence.js +1 -1
  91. package/dist/commands/setup/deploy/providers/coherenceHandler.js +6 -7
  92. package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +1 -2
  93. package/dist/commands/setup/deploy/providers/netlifyHandler.js +1 -2
  94. package/dist/commands/setup/deploy/providers/renderHandler.js +1 -2
  95. package/dist/commands/setup/deploy/providers/serverlessHandler.js +1 -2
  96. package/dist/commands/setup/deploy/providers/universalDeployHandler.js +6 -4
  97. package/dist/commands/setup/deploy/providers/vercelHandler.js +1 -2
  98. package/dist/commands/setup/deploy/templates/baremetal.js +9 -119
  99. package/dist/commands/setup/deploy/templates/netlifyUD.js +0 -3
  100. package/dist/commands/setup/docker/docker.js +1 -1
  101. package/dist/commands/setup/docker/dockerHandler.js +1 -2
  102. package/dist/commands/setup/generator/generator.js +1 -1
  103. package/dist/commands/setup/generator/generatorHandler.js +1 -1
  104. package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
  105. package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +5 -3
  106. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
  107. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +1 -2
  108. package/dist/commands/setup/i18n/i18n.js +1 -1
  109. package/dist/commands/setup/i18n/i18nHandler.js +1 -1
  110. package/dist/commands/setup/jobs/jobs.js +1 -1
  111. package/dist/commands/setup/jobs/jobsHandler.js +1 -4
  112. package/dist/commands/setup/mailer/mailer.js +1 -1
  113. package/dist/commands/setup/mailer/mailerHandler.js +1 -2
  114. package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
  115. package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +1 -2
  116. package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
  117. package/dist/commands/setup/monitoring/sentry/sentryHandler.js +9 -13
  118. package/dist/commands/setup/monitoring/sentry/templates/sentryApi.ts.template +4 -1
  119. package/dist/commands/setup/monitoring/sentry/templates/sentryWeb.ts.template +4 -7
  120. package/dist/commands/setup/neon/neon.js +1 -1
  121. package/dist/commands/setup/neon/neonHandler.js +9 -5
  122. package/dist/commands/setup/package/package.js +1 -1
  123. package/dist/commands/setup/package/packageHandler.js +4 -4
  124. package/dist/commands/setup/realtime/addRealtimeToGraphql.js +1 -1
  125. package/dist/commands/setup/realtime/realtime.js +1 -1
  126. package/dist/commands/setup/realtime/realtimeHandler.js +16 -4
  127. package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template +1 -4
  128. package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.ts.template +4 -12
  129. package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
  130. package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +2 -2
  131. package/dist/commands/setup/server-file/serverFile.js +1 -1
  132. package/dist/commands/setup/server-file/serverFileHandler.js +1 -2
  133. package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +1 -2
  134. package/dist/commands/setup/ui/libraries/mantineHandler.js +1 -2
  135. package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +82 -63
  136. package/dist/commands/setup/ui/templates/postcss.config.cjs.template +9 -0
  137. package/dist/commands/setup/uploads/dbCodemod.js +28 -0
  138. package/dist/commands/setup/uploads/templates/signedUrl.ts.template +21 -0
  139. package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +24 -23
  140. package/dist/commands/setup/uploads/uploads.js +7 -49
  141. package/dist/commands/setup/uploads/uploadsHandler.js +69 -277
  142. package/dist/commands/setup.js +1 -2
  143. package/dist/commands/studio.js +1 -1
  144. package/dist/commands/test/testHandler.js +71 -25
  145. package/dist/commands/test/testHandlerEsm.js +109 -0
  146. package/dist/commands/test.js +18 -10
  147. package/dist/commands/testEsm.js +41 -0
  148. package/dist/commands/type-checkHandler.js +1 -1
  149. package/dist/commands/upgrade/preUpgradeScripts.js +3 -3
  150. package/dist/commands/upgrade/upgrade.js +1 -1
  151. package/dist/commands/upgrade/upgradeHandler.js +1 -2
  152. package/dist/index.js +8 -5
  153. package/dist/lib/exit.js +1 -1
  154. package/dist/lib/index.js +31 -16
  155. package/dist/lib/loadEnvFiles.js +1 -1
  156. package/dist/lib/plugin.js +1 -1
  157. package/dist/lib/test.js +1 -1
  158. package/dist/lib/updateCheck.js +4 -4
  159. package/dist/middleware/checkNodeVersion.js +4 -4
  160. package/package.json +27 -27
  161. package/dist/commands/deploy/baremetal/monitors.js +0 -66
  162. package/dist/commands/generate/cell/templates/cellFragment.tsx.template +0 -43
  163. package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +0 -23
  164. package/dist/commands/generate/cell/templates/testFragment.js.template +0 -30
  165. package/dist/commands/generate/dbAuth/templates/changePassword.tsx.template +0 -131
  166. package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +0 -164
  167. package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +0 -147
  168. package/dist/commands/generate/scaffold/templates/layouts/NamesScaffoldLayout.tsx.template +0 -18
  169. package/dist/commands/setup/tenancy/authCodemod.js +0 -66
  170. package/dist/commands/setup/tenancy/dbCodemod.js +0 -64
  171. package/dist/commands/setup/tenancy/graphqlCodemod.js +0 -88
  172. package/dist/commands/setup/tenancy/preflight.js +0 -49
  173. package/dist/commands/setup/tenancy/schemaPrisma.js +0 -81
  174. package/dist/commands/setup/tenancy/signupCodemod.js +0 -154
  175. package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +0 -72
  176. package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +0 -40
  177. package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +0 -39
  178. package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +0 -57
  179. package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +0 -89
  180. package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +0 -381
  181. package/dist/commands/setup/tenancy/templates/organizations.ts.template +0 -394
  182. package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +0 -35
  183. package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +0 -25
  184. package/dist/commands/setup/tenancy/tenancy.js +0 -30
  185. package/dist/commands/setup/tenancy/tenancyHandler.js +0 -425
  186. package/dist/commands/setup/uploads/gitignore.js +0 -17
  187. package/dist/commands/setup/uploads/schemaPrisma.js +0 -41
  188. package/dist/commands/setup/uploads/serverFile.js +0 -217
  189. package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +0 -15
  190. package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +0 -79
  191. package/dist/commands/setup/uploads/templates/uploads.ts.template +0 -98
  192. package/dist/commands/setup/uploads/templates/withDataUri.ts.template +0 -14
  193. package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +0 -16
  194. package/dist/commands/test/viteVersionCheck.js +0 -75
@@ -1,13 +1,9 @@
1
1
  import { terminalLink } from "termi-link";
2
2
  import { getYargsDefaults, createHandler } from "../yargsCommandHelpers.js";
3
3
  const command = "dbAuth";
4
- const description = "Generate Login, Signup, Forgot Password, Reset Password and Change Password pages for dbAuth";
4
+ const description = "Generate Login, Signup and Forgot Password pages for dbAuth";
5
5
  const builder = (yargs) => {
6
- yargs.option("skip-change", {
7
- description: "Skip generating the Change Password page",
8
- type: "boolean",
9
- default: false
10
- }).option("skip-forgot", {
6
+ yargs.option("skip-forgot", {
11
7
  description: "Skip generating the Forgot Password page",
12
8
  type: "boolean",
13
9
  default: false
@@ -4,10 +4,9 @@ import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
4
4
  import { camelCase } from "camel-case";
5
5
  import { Listr } from "listr2";
6
6
  import { titleCase } from "title-case";
7
- import { colors as c } from "@cedarjs/cli-helpers/colors";
7
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
8
8
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
9
9
  import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
10
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
11
10
  import {
12
11
  addRoutesToRouterTask,
13
12
  addScaffoldImport,
@@ -18,25 +17,12 @@ import {
18
17
  } from "../../../lib/index.js";
19
18
  import { prepareForRollback } from "../../../lib/rollback.js";
20
19
  import { templateForComponentFile } from "../yargsHandlerHelpers.js";
21
- function routesFor({
22
- skipChange,
23
- skipForgot,
24
- skipLogin,
25
- skipReset,
26
- skipSignup
27
- }) {
28
- return [
29
- !skipLogin && `<Route path="/login" page={LoginPage} name="login" />`,
30
- !skipSignup && `<Route path="/signup" page={SignupPage} name="signup" />`,
31
- !skipForgot && `<Route path="/forgot-password" page={ForgotPasswordPage} name="forgotPassword" />`,
32
- !skipReset && `<Route path="/reset-password" page={ResetPasswordPage} name="resetPassword" />`,
33
- !skipChange && `<Route path="/change-password" page={ChangePasswordPage} name="changePassword" />`
34
- ].filter((route) => typeof route === "string");
35
- }
36
- function pascalCase(str) {
37
- const camelCased = camelCase(str);
38
- return camelCased.charAt(0).toUpperCase() + camelCased.slice(1);
39
- }
20
+ const ROUTES = [
21
+ `<Route path="/login" page={LoginPage} name="login" />`,
22
+ `<Route path="/signup" page={SignupPage} name="signup" />`,
23
+ `<Route path="/forgot-password" page={ForgotPasswordPage} name="forgotPassword" />`,
24
+ `<Route path="/reset-password" page={ResetPasswordPage} name="resetPassword" />`
25
+ ];
40
26
  function getPostInstallMessage(isDbAuthSetup2) {
41
27
  return [
42
28
  ` ${c.warning("Pages created! But you're not done yet:")}
@@ -48,11 +34,9 @@ function getPostInstallMessage(isDbAuthSetup2) {
48
34
  " navigate(routes.home())",
49
35
  " }\n",
50
36
  " and change the route to where you want them to go if the user is already",
51
- " logged in. Also take a look in the onSubmit() functions in ForgotPasswordPage,",
52
- " ResetPasswordPage and ChangePasswordPage to change where the user redirects",
53
- " to after submitting those forms.\n",
54
- " ChangePasswordPage is for users who are already logged in. Link to it from",
55
- " wherever your app lets users manage their account.\n",
37
+ " logged in. Also take a look in the onSubmit() functions in ForgotPasswordPage",
38
+ " and ResetPasswordPage to change where the user redirects to after submitting",
39
+ " those forms.\n",
56
40
  !isDbAuthSetup2 && ` Oh, and if you haven't already, add the necessary dbAuth functions and
57
41
  app setup by running:
58
42
 
@@ -73,11 +57,9 @@ function getPostInstallWebauthnMessage(isDbAuthSetup2) {
73
57
  " navigate(routes.home())",
74
58
  " }\n",
75
59
  " and change the route to where you want them to go if the user is already",
76
- " logged in. Also take a look in the onSubmit() functions in ForgotPasswordPage,",
77
- " ResetPasswordPage and ChangePasswordPage to change where the user redirects",
78
- " to after submitting those forms.\n",
79
- " ChangePasswordPage is for users who are already logged in. Link to it from",
80
- " wherever your app lets users manage their account.\n",
60
+ " logged in. Also take a look in the onSubmit() functions in ForgotPasswordPage",
61
+ " and ResetPasswordPage to change where the user redirects to after submitting",
62
+ " those forms.\n",
81
63
  !isDbAuthSetup2 && ` Oh, and if you haven't already, add the necessary dbAuth functions and
82
64
  app setup by running:
83
65
 
@@ -88,28 +70,24 @@ function getPostInstallWebauthnMessage(isDbAuthSetup2) {
88
70
  }
89
71
  const files = async ({
90
72
  typescript,
91
- skipChange,
92
73
  skipForgot,
93
74
  skipLogin,
94
75
  skipReset,
95
76
  skipSignup,
96
77
  webauthn,
97
- oauth,
98
78
  usernameLabel,
99
79
  passwordLabel
100
80
  }) => {
101
81
  const filesList = [];
102
82
  usernameLabel = usernameLabel || "username";
103
83
  passwordLabel = passwordLabel || "password";
104
- const oauthEnabled = oauth ?? isOAuthEnabled();
105
84
  const templateVars = {
106
85
  usernameLowerCase: usernameLabel.toLowerCase(),
107
86
  usernameCamelCase: camelCase(usernameLabel),
108
87
  usernameTitleCase: titleCase(usernameLabel),
109
88
  passwordLowerCase: passwordLabel.toLowerCase(),
110
89
  passwordCamelCase: camelCase(passwordLabel),
111
- passwordTitleCase: titleCase(passwordLabel),
112
- passwordPascalCase: pascalCase(passwordLabel)
90
+ passwordTitleCase: titleCase(passwordLabel)
113
91
  };
114
92
  if (!skipForgot) {
115
93
  filesList.push(
@@ -132,7 +110,7 @@ const files = async ({
132
110
  extension: typescript ? ".tsx" : ".jsx",
133
111
  webPathSection: "pages",
134
112
  generator: "dbAuth",
135
- templatePath: loginTemplatePath(webauthn, oauthEnabled),
113
+ templatePath: webauthn ? "login.webAuthn.tsx.template" : "login.tsx.template",
136
114
  templateVars
137
115
  })
138
116
  );
@@ -150,19 +128,6 @@ const files = async ({
150
128
  })
151
129
  );
152
130
  }
153
- if (!skipChange) {
154
- filesList.push(
155
- await templateForComponentFile({
156
- name: "ChangePassword",
157
- suffix: "Page",
158
- extension: typescript ? ".tsx" : ".jsx",
159
- webPathSection: "pages",
160
- generator: "dbAuth",
161
- templatePath: "changePassword.tsx.template",
162
- templateVars
163
- })
164
- );
165
- }
166
131
  if (!skipSignup) {
167
132
  filesList.push(
168
133
  await templateForComponentFile({
@@ -171,7 +136,7 @@ const files = async ({
171
136
  extension: typescript ? ".tsx" : ".jsx",
172
137
  webPathSection: "pages",
173
138
  generator: "dbAuth",
174
- templatePath: oauthEnabled ? "signup.oauth.tsx.template" : "signup.tsx.template",
139
+ templatePath: "signup.tsx.template",
175
140
  templateVars
176
141
  })
177
142
  );
@@ -211,7 +176,6 @@ const tasks = ({
211
176
  listr2,
212
177
  force,
213
178
  typescript,
214
- skipChange,
215
179
  skipForgot,
216
180
  skipLogin,
217
181
  skipReset,
@@ -322,7 +286,6 @@ const tasks = ({
322
286
  task: async () => {
323
287
  const filesObj = await files({
324
288
  typescript,
325
- skipChange,
326
289
  skipForgot,
327
290
  skipLogin,
328
291
  skipReset,
@@ -339,15 +302,7 @@ const tasks = ({
339
302
  {
340
303
  title: "Adding routes...",
341
304
  task: async () => {
342
- addRoutesToRouterTask(
343
- routesFor({
344
- skipChange,
345
- skipForgot,
346
- skipLogin,
347
- skipReset,
348
- skipSignup
349
- })
350
- );
305
+ addRoutesToRouterTask(ROUTES);
351
306
  }
352
307
  },
353
308
  {
@@ -377,7 +332,6 @@ const tasks = ({
377
332
  const handler = async (yargs) => {
378
333
  recordTelemetryAttributes({
379
334
  command: "generate dbAuth",
380
- skipChange: yargs.skipChange,
381
335
  skipForgot: yargs.skipForgot,
382
336
  skipLogin: yargs.skipLogin,
383
337
  skipReset: yargs.skipReset,
@@ -424,23 +378,6 @@ function isWebAuthnEnabled() {
424
378
  );
425
379
  return webPackageJson.includes('"@simplewebauthn/browser": ');
426
380
  }
427
- function isOAuthEnabled() {
428
- const apiPackageJsonPath = path.join(getPaths().base, "api", "package.json");
429
- if (!fs.existsSync(apiPackageJsonPath)) {
430
- return false;
431
- }
432
- const apiPackageJson = fs.readFileSync(apiPackageJsonPath, "utf-8");
433
- return apiPackageJson.includes('"@cedarjs/auth-dbauth-oauth": ');
434
- }
435
- function loginTemplatePath(webauthn, oauth) {
436
- if (webauthn) {
437
- return "login.webAuthn.tsx.template";
438
- }
439
- if (oauth) {
440
- return "login.oauth.tsx.template";
441
- }
442
- return "login.tsx.template";
443
- }
444
381
  export {
445
382
  files,
446
383
  handler
@@ -17,7 +17,7 @@ import { useAuth } from 'src/auth'
17
17
  const WELCOME_MESSAGE = 'Welcome back!'
18
18
  const REDIRECT = routes.home()
19
19
 
20
- const LoginPage = ({ type }: { type?: string }) => {
20
+ const LoginPage = ({ type }) => {
21
21
  const {
22
22
  isAuthenticated,
23
23
  client: webAuthn,
@@ -27,12 +27,12 @@ const LoginPage = ({ type }: { type?: string }) => {
27
27
  } = useAuth()
28
28
  const [shouldShowWebAuthn, setShouldShowWebAuthn] = useState(false)
29
29
  const [showWebAuthn, setShowWebAuthn] = useState(
30
- !!webAuthn?.isEnabled() && type !== 'password'
30
+ webAuthn.isEnabled() && type !== 'password'
31
31
  )
32
32
 
33
33
  // should redirect right after login or wait to show the webAuthn prompts?
34
34
  useEffect(() => {
35
- if (isAuthenticated && (!shouldShowWebAuthn || webAuthn?.isEnabled())) {
35
+ if (isAuthenticated && (!shouldShowWebAuthn || webAuthn.isEnabled())) {
36
36
  navigate(REDIRECT)
37
37
  }
38
38
  }, [isAuthenticated, shouldShowWebAuthn])
@@ -45,13 +45,13 @@ const LoginPage = ({ type }: { type?: string }) => {
45
45
  }, [loading, isAuthenticated])
46
46
 
47
47
  // focus on the ${usernameLowerCase} field as soon as the page loads
48
- const ${usernameCamelCase}Ref = useRef<HTMLInputElement>(null)
48
+ const ${usernameCamelCase}Ref = useRef()
49
49
  useEffect(() => {
50
- ${usernameCamelCase}Ref.current?.focus()
50
+ ${usernameCamelCase}Ref.current && ${usernameCamelCase}Ref.current.focus()
51
51
  }, [])
52
52
 
53
- const onSubmit = async (data: Record<string, string>) => {
54
- const webAuthnSupported = !!(await webAuthn?.isSupported())
53
+ const onSubmit = async (data) => {
54
+ const webAuthnSupported = await webAuthn.isSupported()
55
55
 
56
56
  if (webAuthnSupported) {
57
57
  setShouldShowWebAuthn(true)
@@ -75,38 +75,30 @@ const LoginPage = ({ type }: { type?: string }) => {
75
75
  }
76
76
 
77
77
  const onAuthenticate = async () => {
78
- if (!webAuthn) {
79
- return
80
- }
81
-
82
78
  try {
83
79
  await webAuthn.authenticate()
84
80
  await reauthenticate()
85
81
  toast.success(WELCOME_MESSAGE)
86
82
  navigate(REDIRECT)
87
83
  } catch (e) {
88
- if (e instanceof Error && e.name === 'WebAuthnDeviceNotFoundError') {
84
+ if (e.name === 'WebAuthnDeviceNotFoundError') {
89
85
  toast.error(
90
86
  'Device not found, log in with ${usernameTitleCase}/${passwordTitleCase} to continue'
91
87
  )
92
88
  setShowWebAuthn(false)
93
89
  } else {
94
- toast.error(e instanceof Error ? e.message : String(e))
90
+ toast.error(e.message)
95
91
  }
96
92
  }
97
93
  }
98
94
 
99
95
  const onRegister = async () => {
100
- if (!webAuthn) {
101
- return
102
- }
103
-
104
96
  try {
105
97
  await webAuthn.register()
106
98
  toast.success(WELCOME_MESSAGE)
107
99
  navigate(REDIRECT)
108
100
  } catch (e) {
109
- toast.error(e instanceof Error ? e.message : String(e))
101
+ toast.error(e.message)
110
102
  }
111
103
  }
112
104
 
@@ -208,7 +200,7 @@ const LoginPage = ({ type }: { type?: string }) => {
208
200
 
209
201
  const formToRender = () => {
210
202
  if (showWebAuthn) {
211
- if (webAuthn?.isEnabled()) {
203
+ if (webAuthn.isEnabled()) {
212
204
  return <AuthWebAuthnPrompt />
213
205
  } else {
214
206
  return <RegisterWebAuthnPrompt />
@@ -220,7 +212,7 @@ const LoginPage = ({ type }: { type?: string }) => {
220
212
 
221
213
  const linkToRender = () => {
222
214
  if (showWebAuthn) {
223
- if (webAuthn?.isEnabled()) {
215
+ if (webAuthn.isEnabled()) {
224
216
  return (
225
217
  <div className="rw-login-link">
226
218
  <span>or login with </span>{' '}
@@ -1,9 +1,8 @@
1
1
  import camelcase from "camelcase";
2
2
  import { Listr } from "listr2";
3
3
  import prompts from "prompts";
4
- import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
5
  import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
6
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
7
6
  import { getConfig } from "@cedarjs/project-config";
8
7
  import { writeFilesTask, transformTSToJSMap } from "../../../lib/index.js";
9
8
  import {
@@ -1,7 +1,6 @@
1
1
  import { Listr } from "listr2";
2
2
  import { terminalLink } from "termi-link";
3
- import { colors as c } from "@cedarjs/cli-helpers/colors";
4
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
3
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
4
  import { errorTelemetry } from "@cedarjs/telemetry";
6
5
  import { transformTSToJSMap, writeFilesTask } from "../../../lib/index.js";
7
6
  import { prepareForRollback } from "../../../lib/rollback.js";
@@ -37,33 +37,11 @@ const redactedModelFields = (fieldNames) => {
37
37
  }
38
38
  return sensitive;
39
39
  };
40
- const DEFAULT_IGNORE_FIELDS_FOR_INPUT = ["createdAt", "updatedAt"];
41
- const requiredFieldsInUpdateInput = (model) => {
42
- return inputFields(model).filter((field) => {
43
- return field.isRequired && !field.isList && !field.isId;
44
- }).map((field) => field.name);
45
- };
46
- const nullableJsonFieldsInInput = (model) => {
47
- return inputFields(model).filter((field) => {
48
- return field.type === "Json" && !field.isRequired && !field.isList;
49
- }).map((field) => field.name);
50
- };
51
- const inputFields = (model) => {
52
- const redactedFields = redactedModelFields(
53
- model.fields.map((field) => field.name)
54
- );
55
- return model.fields.filter((field) => {
56
- return field.kind !== "object" && !DEFAULT_IGNORE_FIELDS_FOR_INPUT.includes(field.name) && !redactedFields.includes(field.name);
57
- });
58
- };
59
40
  const relationsForModel = (model) => {
60
41
  return model?.fields.filter((f) => f.relationName).map((field) => {
61
42
  return field.name;
62
43
  });
63
44
  };
64
- const nullableRelationsForModel = (model) => {
65
- return model.fields.filter((f) => f.kind === "object" && !f.isList && !f.isRequired).map((f) => f.name);
66
- };
67
45
  const intForeignKeysForModel = (model) => {
68
46
  return model.fields.filter((f) => f.name.match(/Id$/) && f.type === "Int").map((f) => f.name);
69
47
  };
@@ -96,18 +74,14 @@ const mapPrismaScalarToPagePropTsType = (scalarType) => {
96
74
  return prismaScalarToTsType[scalarType] || "unknown";
97
75
  };
98
76
  export {
99
- DEFAULT_IGNORE_FIELDS_FOR_INPUT,
100
77
  SENSITIVE_FIELDS,
101
78
  forcePluralizeWord,
102
79
  intForeignKeysForModel,
103
80
  mapPrismaScalarToPagePropTsType,
104
81
  mapRouteParamTypeToTsType,
105
- nullableJsonFieldsInInput,
106
- nullableRelationsForModel,
107
82
  pathName,
108
83
  redactedModelFields,
109
84
  relationsForModel,
110
85
  removeGeneratorName,
111
- requiredFieldsInUpdateInput,
112
86
  validateName
113
87
  };
@@ -2,9 +2,8 @@ import path from "node:path";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import * as changeCase from "change-case";
4
4
  import { Listr } from "listr2";
5
- import { colors as c } from "@cedarjs/cli-helpers/colors";
5
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
6
6
  import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
7
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
8
7
  import { errorTelemetry } from "@cedarjs/telemetry";
9
8
  import {
10
9
  getPaths,
@@ -1,7 +1,6 @@
1
1
  import path from "path";
2
2
  import { Listr } from "listr2";
3
- import { colors as c } from "@cedarjs/cli-helpers/colors";
4
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
3
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
4
  import {
6
5
  getPaths,
7
6
  writeFilesTask,
@@ -2,8 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import fg from "fast-glob";
4
4
  import { Listr } from "listr2";
5
- import { colors as c } from "@cedarjs/cli-helpers/colors";
6
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
5
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
7
6
  import { ensurePosixPath } from "@cedarjs/project-config";
8
7
  import { errorTelemetry } from "@cedarjs/telemetry";
9
8
  import {
@@ -2,7 +2,7 @@ export const data = async () => {
2
2
  return new Date()
3
3
  }
4
4
 
5
- export const output = ({ data }: { data: Date }) => {
5
+ export const output = ({ data }) => {
6
6
  return (
7
7
  <>
8
8
  <h1>${pageName} og:image</h1>
@@ -11,6 +11,7 @@ const files = async ({
11
11
  fileName,
12
12
  typescript,
13
13
  tests: generateTests = true,
14
+ esm = false,
14
15
  ...rest
15
16
  }) => {
16
17
  const extension = typescript ? ".ts" : ".js";
@@ -66,15 +67,17 @@ const files = async ({
66
67
  outputPath: path.join(folderName, "src", `${fileName}.test${extension}`)
67
68
  });
68
69
  outputFiles.push(testFile);
69
- const vitestConfigFile = await templateForFile({
70
- name,
71
- side: "packages",
72
- generator: "package",
73
- templatePath: "vitest.config.ts.template",
74
- templateVars: { folderName, ...rest },
75
- outputPath: path.join(folderName, `vitest.config${extension}`)
76
- });
77
- outputFiles.push(vitestConfigFile);
70
+ if (esm) {
71
+ const vitestConfigFile = await templateForFile({
72
+ name,
73
+ side: "packages",
74
+ generator: "package",
75
+ templatePath: "vitest.config.ts.template",
76
+ templateVars: { folderName, ...rest },
77
+ outputPath: path.join(folderName, `vitest.config${extension}`)
78
+ });
79
+ outputFiles.push(vitestConfigFile);
80
+ }
78
81
  }
79
82
  return outputFiles.reduce(async (accP, [outputPath, content]) => {
80
83
  const acc = await accP;
@@ -6,13 +6,12 @@ import { modify, applyEdits } from "jsonc-parser";
6
6
  import { Listr } from "listr2";
7
7
  import { terminalLink } from "termi-link";
8
8
  import ts from "typescript";
9
- import { colors as c } from "@cedarjs/cli-helpers/colors";
9
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
10
10
  import { workspacePackageSpecifier } from "@cedarjs/cli-helpers/packageManager";
11
11
  import { runScript, runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
12
12
  import { installPackages } from "@cedarjs/cli-helpers/packageManager/packages";
13
13
  import { addWorkspaceDir } from "@cedarjs/cli-helpers/packageManager/workspaces";
14
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
15
- import { getConfig } from "@cedarjs/project-config";
14
+ import { getConfig, projectIsEsm } from "@cedarjs/project-config";
16
15
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
17
16
  import { errorTelemetry } from "@cedarjs/telemetry";
18
17
  import { getPaths, writeFilesTask } from "../../../lib/index.js";
@@ -343,6 +342,8 @@ const handler = async ({
343
342
  task: async (ctx) => {
344
343
  packageFiles = await files({
345
344
  ...ctx.nameVariants,
345
+ // Only Vitest projects get a config generated for them
346
+ esm: projectIsEsm(),
346
347
  ...rest
347
348
  });
348
349
  return writeFilesTask(packageFiles, { overwriteExisting: force });
@@ -4,7 +4,6 @@
4
4
  "target": "es2023",
5
5
  "module": "node20",
6
6
  "esModuleInterop": true,
7
- "strict": true,
8
7
  "skipLibCheck": true,
9
8
  "baseUrl": ".",
10
9
  "rootDir": "src",
@@ -2,8 +2,7 @@ import { execSync } from "child_process";
2
2
  import camelcase from "camelcase";
3
3
  import { Listr } from "listr2";
4
4
  import pascalcase from "pascalcase";
5
- import { colors as c } from "@cedarjs/cli-helpers/colors";
6
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
5
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
7
6
  import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
8
7
  import { getConfig } from "@cedarjs/project-config";
9
8
  import { errorTelemetry } from "@cedarjs/telemetry";
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "realtime <name>";
3
3
  const description = "Generate a subscription or live query used with RedwoodJS Realtime";
4
4
  function builder(yargs) {
@@ -4,8 +4,9 @@ import { Listr } from "listr2";
4
4
  import pascalcase from "pascalcase";
5
5
  import pluralize from "pluralize";
6
6
  import prompts from "prompts";
7
- import { colors as c } from "@cedarjs/cli-helpers/colors";
7
+ import { colors as c } from "@cedarjs/cli-helpers";
8
8
  import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
9
+ import { projectIsEsm } from "@cedarjs/project-config";
9
10
  import { errorTelemetry } from "@cedarjs/telemetry";
10
11
  import {
11
12
  generateTemplate,
@@ -119,10 +120,16 @@ async function handler({
119
120
  exampleFile,
120
121
  exampleSubscriptionTemplateContent
121
122
  );
122
- const blankTemplateContent = await generateTemplate(
123
+ let blankTemplateContent = await generateTemplate(
123
124
  setupScriptContent,
124
125
  templateVariables(name)
125
126
  );
127
+ if (projectIsEsm()) {
128
+ blankTemplateContent = blankTemplateContent.replace(
129
+ "import gql from 'graphql-tag'",
130
+ "import { gql } from 'graphql-tag'"
131
+ );
132
+ }
126
133
  return [
127
134
  writeFile(
128
135
  sdlFile,
@@ -1,17 +1,9 @@
1
1
  // api/src/services/${name}s/${name}s.ts
2
- import type { ${typeName}ItemInput } from 'types/graphql'
3
-
4
2
  import type { LiveQueryStorageMechanism } from '@cedarjs/realtime'
5
3
 
6
4
  import { logger } from 'src/lib/logger'
7
5
 
8
- interface ${typeName}Data {
9
- id: string
10
- title: string
11
- items: { amount: number }[]
12
- }
13
-
14
- const ${collectionName}: ${typeName}Data[] = [
6
+ const ${collectionName} = [
15
7
  { id: '1', title: 'First ${modelName}', items: [{ amount: 11 }] },
16
8
  { id: '2', title: '2nd ${modelName}', items: [{ amount: 22 }] },
17
9
  { id: '3', title: 'Third ${modelName}', items: [{ amount: 33 }] },
@@ -43,14 +35,14 @@ const ${collectionName}: ${typeName}Data[] = [
43
35
  * }
44
36
  * }
45
37
  */
46
- export const ${liveQueryName} = async ({ id }: { id: string }) => {
38
+ export const ${liveQueryName} = async ({ id }) => {
47
39
  const found${modelName} = ${collectionName}.find((a) => a.id === id)
48
40
  logger.debug({ id, ${name}: found${modelName} }, `${name} details`)
49
41
  return found${modelName}
50
42
  }
51
43
 
52
44
  export const create${typeName}Item = async (
53
- { input }: { input: ${typeName}ItemInput },
45
+ { input },
54
46
  { context }: { context: { liveQueryStore: LiveQueryStorageMechanism } }
55
47
  ) => {
56
48
  const { ${camelName}Id, amount } = input
@@ -71,7 +63,7 @@ export const create${typeName}Item = async (
71
63
  }
72
64
 
73
65
  export const ${modelName} = {
74
- largest${typeName}Item: (obj: unknown, { root }: { root: ${typeName}Data }) => {
66
+ largest${typeName}Item: (obj, { root }) => {
75
67
  const [largest] = root.items.sort((a, b) => b.amount - a.amount)
76
68
 
77
69
  logger.debug({ obj, root }, 'largest ${typeName}Item')
@@ -1,9 +1,9 @@
1
1
  import type { ${subscriptionInputType} } from 'types/graphql'
2
2
 
3
3
  import { logger } from 'src/lib/logger'
4
- import type { Publish${typeName}ChannelType } from 'src/subscriptions/${name}/${name}.js'
4
+ import type { Publish${typeName}ChannelType } from 'src/subscriptions/${name}/${name}.service.js'
5
5
 
6
- export const ${subscriptionQueryName} = ({ id }: { id: string }) => [id]
6
+ export const ${subscriptionQueryName} = ({ id }) => [id]
7
7
 
8
8
  export const ${subscriptionServiceResolver} = async (
9
9
  { input }: { input: ${subscriptionInputType} },
@@ -1,4 +1,4 @@
1
- import { gql } from 'graphql-tag'
1
+ import gql from 'graphql-tag'
2
2
 
3
3
  import type { PubSub } from '@cedarjs/realtime'
4
4
 
@@ -39,15 +39,15 @@ export type Publish${typeName}ChannelType = PubSub<Publish${typeName}Channel>
39
39
  const ${subscriptionName}Subscription = {
40
40
  ${subscriptionName}: {
41
41
  subscribe: (
42
- _: unknown,
43
- { id }: { id: string },
42
+ _,
43
+ { id },
44
44
  { pubSub }: { pubSub: Publish${typeName}ChannelType }
45
45
  ) => {
46
46
  logger.debug({ id }, '${name} subscription')
47
47
 
48
48
  return pubSub.subscribe('${typeName}', id)
49
49
  },
50
- resolve: (payload: Publish${typeName}Channel['${typeName}'][1]) => {
50
+ resolve: (payload) => {
51
51
  logger.debug({ payload }, '${name} subscription resolve')
52
52
 
53
53
  return payload
@@ -13,7 +13,7 @@ const builder = (yargs) => {
13
13
  description: "Generate test files",
14
14
  type: "boolean"
15
15
  }).option("tailwind", {
16
- description: "Generate TailwindCSS version of scaffold.css (automatically set to `true` if the web side depends on `tailwindcss`)",
16
+ description: "Generate TailwindCSS version of scaffold.css (automatically set to `true` if TailwindCSS config exists)",
17
17
  type: "boolean"
18
18
  }).option("rollback", {
19
19
  description: "Revert all generator actions if an error occurs",