@cedarjs/cli 7.1.0 → 7.1.1-next.469

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 +2 -1
  2. package/dist/commands/build.js +1 -1
  3. package/dist/commands/check.js +2 -1
  4. package/dist/commands/deploy/baremetal/baremetalHandler.js +364 -73
  5. package/dist/commands/deploy/baremetal/monitors.js +66 -0
  6. package/dist/commands/deploy/baremetal.js +7 -1
  7. package/dist/commands/deploy/flightcontrolHandler.js +1 -1
  8. package/dist/commands/deploy/helpers/deployHandler.js +1 -1
  9. package/dist/commands/deploy/netlify.js +1 -1
  10. package/dist/commands/deploy/renderHandler.js +1 -1
  11. package/dist/commands/deploy/serverlessHandler.js +2 -1
  12. package/dist/commands/deploy/vercel.js +1 -1
  13. package/dist/commands/destroy/handlerHelpers.js +1 -1
  14. package/dist/commands/destroy/page/pageHandler.js +2 -1
  15. package/dist/commands/destroy/scaffold/scaffoldHandler.js +65 -26
  16. package/dist/commands/destroy/sdl/sdlHandler.js +2 -1
  17. package/dist/commands/dev/devHandler.js +3 -4
  18. package/dist/commands/dev/packageWatchCommands.js +8 -3
  19. package/dist/commands/dev.js +1 -1
  20. package/dist/commands/execHandler.js +2 -1
  21. package/dist/commands/experimental/live-queries/liveQueries.js +1 -1
  22. package/dist/commands/experimental/live-queries/liveQueriesHandler.js +3 -3
  23. package/dist/commands/experimental/setupInngest.js +1 -1
  24. package/dist/commands/experimental/setupInngestHandler.js +1 -1
  25. package/dist/commands/experimental/setupOpentelemetry.js +1 -1
  26. package/dist/commands/experimental/setupOpentelemetryHandler.js +2 -1
  27. package/dist/commands/experimental/setupReactCompiler.js +1 -1
  28. package/dist/commands/experimental/setupReactCompilerHandler.js +4 -4
  29. package/dist/commands/experimental/setupRsc.js +1 -1
  30. package/dist/commands/experimental/setupRscHandler.js +2 -1
  31. package/dist/commands/experimental/setupStreamingSsr.js +1 -1
  32. package/dist/commands/experimental/setupStreamingSsrHandler.js +3 -2
  33. package/dist/commands/generate/cell/cell.js +20 -0
  34. package/dist/commands/generate/cell/cellHandler.js +68 -20
  35. package/dist/commands/generate/cell/templates/cell.tsx.template +21 -2
  36. package/dist/commands/generate/cell/templates/cellFragment.tsx.template +43 -0
  37. package/dist/commands/generate/cell/templates/cellList.tsx.template +21 -2
  38. package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +23 -0
  39. package/dist/commands/generate/cell/templates/test.js.template +1 -1
  40. package/dist/commands/generate/cell/templates/testFragment.js.template +30 -0
  41. package/dist/commands/generate/dataMigration/dataMigration.js +2 -1
  42. package/dist/commands/generate/dbAuth/dbAuth.js +6 -2
  43. package/dist/commands/generate/dbAuth/dbAuthHandler.js +80 -17
  44. package/dist/commands/generate/dbAuth/templates/changePassword.tsx.template +131 -0
  45. package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +164 -0
  46. package/dist/commands/generate/dbAuth/templates/login.webAuthn.tsx.template +20 -12
  47. package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +147 -0
  48. package/dist/commands/generate/directive/directiveHandler.js +2 -1
  49. package/dist/commands/generate/function/functionHandler.js +2 -1
  50. package/dist/commands/generate/helpers.js +26 -0
  51. package/dist/commands/generate/job/jobHandler.js +2 -1
  52. package/dist/commands/generate/model/modelHandler.js +2 -1
  53. package/dist/commands/generate/ogImage/ogImageHandler.js +2 -1
  54. package/dist/commands/generate/ogImage/templates/ogImage.og.tsx.template +1 -1
  55. package/dist/commands/generate/package/filesTask.js +9 -12
  56. package/dist/commands/generate/package/packageHandler.js +3 -4
  57. package/dist/commands/generate/package/templates/tsconfig.json.template +1 -0
  58. package/dist/commands/generate/page/pageHandler.js +2 -1
  59. package/dist/commands/generate/realtime/realtime.js +1 -1
  60. package/dist/commands/generate/realtime/realtimeHandler.js +2 -9
  61. package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.service.ts.template +12 -4
  62. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.service.ts.template +2 -2
  63. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +4 -4
  64. package/dist/commands/generate/scaffold/scaffold.js +1 -1
  65. package/dist/commands/generate/scaffold/scaffoldHandler.js +93 -49
  66. package/dist/commands/generate/scaffold/templates/assets/scaffold.tailwind.css.template +12 -7
  67. package/dist/commands/generate/scaffold/templates/components/EditNameCell.tsx.template +5 -7
  68. package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +10 -9
  69. package/dist/commands/generate/scaffold/templates/layouts/NamesScaffoldLayout.tsx.template +18 -0
  70. package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +11 -0
  71. package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +16 -4
  72. package/dist/commands/generate/script/scriptHandler.js +2 -1
  73. package/dist/commands/generate/script/templates/tsconfig.json.template +1 -0
  74. package/dist/commands/generate/sdl/sdlHandler.js +10 -4
  75. package/dist/commands/generate/secret/secret.js +1 -1
  76. package/dist/commands/generate/service/serviceHandler.js +79 -49
  77. package/dist/commands/generate/service/templates/service.ts.template +40 -13
  78. package/dist/commands/generate/service/templates/test.ts.template +8 -6
  79. package/dist/commands/generate/yargsCommandHelpers.js +1 -1
  80. package/dist/commands/generate/yargsHandlerHelpers.js +2 -1
  81. package/dist/commands/generate.js +1 -1
  82. package/dist/commands/info.js +1 -1
  83. package/dist/commands/jobsHandler.js +5 -3
  84. package/dist/commands/lint.js +1 -1
  85. package/dist/commands/prerenderHandler.js +11 -4
  86. package/dist/commands/prismaHandler.js +7 -2
  87. package/dist/commands/record/init.js +1 -1
  88. package/dist/commands/serve.js +2 -1
  89. package/dist/commands/setup/auth/auth.js +2 -4
  90. package/dist/commands/setup/cache/cache.js +1 -1
  91. package/dist/commands/setup/cache/cacheHandler.js +2 -1
  92. package/dist/commands/setup/cache/templates/memcached.ts.template +14 -17
  93. package/dist/commands/setup/cache/templates/redis.ts.template +12 -20
  94. package/dist/commands/setup/database/postgres.js +1 -1
  95. package/dist/commands/setup/database/postgresHandler.js +3 -1
  96. package/dist/commands/setup/deploy/providers/baremetal.js +7 -0
  97. package/dist/commands/setup/deploy/providers/baremetalHandler.js +130 -21
  98. package/dist/commands/setup/deploy/providers/coherence.js +1 -1
  99. package/dist/commands/setup/deploy/providers/coherenceHandler.js +7 -6
  100. package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +2 -1
  101. package/dist/commands/setup/deploy/providers/netlifyHandler.js +2 -1
  102. package/dist/commands/setup/deploy/providers/renderHandler.js +2 -1
  103. package/dist/commands/setup/deploy/providers/serverlessHandler.js +2 -1
  104. package/dist/commands/setup/deploy/providers/universalDeployHandler.js +4 -6
  105. package/dist/commands/setup/deploy/providers/vercelHandler.js +2 -1
  106. package/dist/commands/setup/deploy/templates/baremetal.js +119 -9
  107. package/dist/commands/setup/deploy/templates/netlifyUD.js +3 -0
  108. package/dist/commands/setup/docker/docker.js +1 -1
  109. package/dist/commands/setup/docker/dockerHandler.js +2 -1
  110. package/dist/commands/setup/generator/generator.js +1 -1
  111. package/dist/commands/setup/generator/generatorHandler.js +1 -1
  112. package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
  113. package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +3 -5
  114. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
  115. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +2 -1
  116. package/dist/commands/setup/i18n/i18n.js +1 -1
  117. package/dist/commands/setup/i18n/i18nHandler.js +1 -1
  118. package/dist/commands/setup/jobs/jobs.js +1 -1
  119. package/dist/commands/setup/jobs/jobsHandler.js +4 -1
  120. package/dist/commands/setup/mailer/mailer.js +1 -1
  121. package/dist/commands/setup/mailer/mailerHandler.js +2 -1
  122. package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
  123. package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +2 -1
  124. package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
  125. package/dist/commands/setup/monitoring/sentry/sentryHandler.js +13 -9
  126. package/dist/commands/setup/monitoring/sentry/templates/sentryApi.ts.template +1 -4
  127. package/dist/commands/setup/monitoring/sentry/templates/sentryWeb.ts.template +7 -4
  128. package/dist/commands/setup/neon/neon.js +1 -1
  129. package/dist/commands/setup/neon/neonHandler.js +5 -9
  130. package/dist/commands/setup/package/package.js +1 -1
  131. package/dist/commands/setup/package/packageHandler.js +4 -4
  132. package/dist/commands/setup/realtime/addRealtimeToGraphql.js +1 -1
  133. package/dist/commands/setup/realtime/realtime.js +1 -1
  134. package/dist/commands/setup/realtime/realtimeHandler.js +4 -16
  135. package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template +4 -1
  136. package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.ts.template +12 -4
  137. package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
  138. package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +2 -2
  139. package/dist/commands/setup/server-file/serverFile.js +1 -1
  140. package/dist/commands/setup/server-file/serverFileHandler.js +2 -1
  141. package/dist/commands/setup/tenancy/authCodemod.js +66 -0
  142. package/dist/commands/setup/tenancy/dbCodemod.js +64 -0
  143. package/dist/commands/setup/tenancy/graphqlCodemod.js +88 -0
  144. package/dist/commands/setup/tenancy/preflight.js +49 -0
  145. package/dist/commands/setup/tenancy/schemaPrisma.js +81 -0
  146. package/dist/commands/setup/tenancy/signupCodemod.js +154 -0
  147. package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +72 -0
  148. package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +40 -0
  149. package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +39 -0
  150. package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +57 -0
  151. package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +89 -0
  152. package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +381 -0
  153. package/dist/commands/setup/tenancy/templates/organizations.ts.template +394 -0
  154. package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +35 -0
  155. package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +25 -0
  156. package/dist/commands/setup/tenancy/tenancy.js +30 -0
  157. package/dist/commands/setup/tenancy/tenancyHandler.js +425 -0
  158. package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +2 -1
  159. package/dist/commands/setup/ui/libraries/mantineHandler.js +2 -1
  160. package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +63 -82
  161. package/dist/commands/setup/uploads/gitignore.js +17 -0
  162. package/dist/commands/setup/uploads/schemaPrisma.js +41 -0
  163. package/dist/commands/setup/uploads/serverFile.js +217 -0
  164. package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +15 -0
  165. package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +23 -24
  166. package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +79 -0
  167. package/dist/commands/setup/uploads/templates/uploads.ts.template +98 -0
  168. package/dist/commands/setup/uploads/templates/withDataUri.ts.template +14 -0
  169. package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +16 -0
  170. package/dist/commands/setup/uploads/uploads.js +49 -7
  171. package/dist/commands/setup/uploads/uploadsHandler.js +277 -69
  172. package/dist/commands/setup.js +2 -1
  173. package/dist/commands/studio.js +1 -1
  174. package/dist/commands/test/testHandler.js +25 -71
  175. package/dist/commands/test/viteVersionCheck.js +75 -0
  176. package/dist/commands/test.js +10 -18
  177. package/dist/commands/type-checkHandler.js +1 -1
  178. package/dist/commands/upgrade/preUpgradeScripts.js +3 -3
  179. package/dist/commands/upgrade/upgrade.js +1 -1
  180. package/dist/commands/upgrade/upgradeHandler.js +2 -1
  181. package/dist/index.js +5 -8
  182. package/dist/lib/exit.js +1 -1
  183. package/dist/lib/index.js +16 -31
  184. package/dist/lib/loadEnvFiles.js +1 -1
  185. package/dist/lib/plugin.js +1 -1
  186. package/dist/lib/test.js +1 -1
  187. package/dist/lib/updateCheck.js +4 -4
  188. package/dist/middleware/checkNodeVersion.js +4 -4
  189. package/package.json +27 -27
  190. package/dist/commands/setup/ui/templates/postcss.config.cjs.template +0 -9
  191. package/dist/commands/setup/uploads/dbCodemod.js +0 -28
  192. package/dist/commands/setup/uploads/templates/signedUrl.ts.template +0 -21
  193. package/dist/commands/test/testHandlerEsm.js +0 -109
  194. package/dist/commands/testEsm.js +0 -41
@@ -1,11 +1,11 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
4
3
  import {
5
4
  runBin,
6
5
  runTransitiveBin,
7
6
  runWithNode
8
7
  } from "@cedarjs/cli-helpers/packageManager/exec";
8
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
9
9
  import { getPaths } from "@cedarjs/project-config";
10
10
  async function runBinWithThrow(bin, args, options) {
11
11
  const result = await runBin(bin, args, options);
@@ -1,5 +1,5 @@
1
1
  import execa from "execa";
2
- import { colors as c } from "@cedarjs/cli-helpers";
2
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
3
3
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
4
4
  import { getPaths } from "@cedarjs/project-config";
5
5
  const deployHandler = ({
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { deployBuilder } from "./helpers/deployBuilder.js";
3
3
  const command = "netlify [...commands]";
4
4
  const description = "Build command for Netlify deploy";
@@ -1,6 +1,5 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
4
3
  import { formatAddRootPackagesCommand } from "@cedarjs/cli-helpers/packageManager/display";
5
4
  import {
6
5
  runBinSync,
@@ -8,6 +7,7 @@ import {
8
7
  runWithNode
9
8
  } from "@cedarjs/cli-helpers/packageManager/exec";
10
9
  import { installPackages } from "@cedarjs/cli-helpers/packageManager/packages";
10
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
11
11
  import { getPaths } from "@cedarjs/project-config";
12
12
  const handler = async ({
13
13
  side,
@@ -6,12 +6,13 @@ import { config } from "dotenv-defaults";
6
6
  import execa from "execa";
7
7
  import { Listr } from "listr2";
8
8
  import prompts from "prompts";
9
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
9
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
10
10
  import {
11
11
  formatAddRootPackagesCommand,
12
12
  formatRunBinCommand
13
13
  } from "@cedarjs/cli-helpers/packageManager/display";
14
14
  import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
15
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
15
16
  import { getPaths } from "../../lib/index.js";
16
17
  const preRequisites = () => [
17
18
  {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { deployBuilder } from "./helpers/deployBuilder.js";
3
3
  const command = "vercel [...commands]";
4
4
  const description = "Build command for Vercel deploy";
@@ -1,5 +1,5 @@
1
1
  import { Listr } from "listr2";
2
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
3
3
  import { deleteFilesTask } from "../../lib/index.js";
4
4
  function tasks({ componentName, filesFn, name }) {
5
5
  return new Listr(
@@ -1,6 +1,7 @@
1
1
  import camelcase from "camelcase";
2
2
  import { Listr } from "listr2";
3
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
3
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
4
5
  import {
5
6
  deleteFilesTask,
6
7
  removeRoutesFromRouterTask
@@ -1,7 +1,7 @@
1
+ import { parse } from "@babel/parser";
1
2
  import { Listr } from "listr2";
2
- import pascalcase from "pascalcase";
3
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
4
- import { pluralize } from "@cedarjs/utils/cedarPluralize";
3
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
5
5
  import {
6
6
  deleteFilesTask,
7
7
  getPaths,
@@ -12,6 +12,7 @@ import {
12
12
  import { verifyModelName } from "../../../lib/schemaHelpers.js";
13
13
  import {
14
14
  files,
15
+ getScaffoldLayoutNames,
15
16
  routes as scaffoldRoutes,
16
17
  splitPathAndModel
17
18
  } from "../../generate/scaffold/scaffoldHandler.js";
@@ -22,45 +23,83 @@ const removeRoutesWithSet = async ({
22
23
  }) => {
23
24
  const routes = await scaffoldRoutes({ model, path, nestScaffoldByModel });
24
25
  const routeNames = routes.map(extractRouteName);
25
- const pluralPascalName = pascalcase(pluralize(model));
26
- const layoutName = `${pluralPascalName}Layout`;
27
- return removeRoutesFromRouterTask(routeNames, layoutName);
26
+ const { importName } = getScaffoldLayoutNames(model, path);
27
+ return removeRoutesFromRouterTask(routeNames, importName);
28
+ };
29
+ const removeNamedImport = (code, source, name) => {
30
+ const program = parse(code, {
31
+ sourceType: "module",
32
+ plugins: ["jsx", "typescript"]
33
+ }).program;
34
+ for (const statement of program.body) {
35
+ if (statement.type !== "ImportDeclaration" || statement.source.value !== source) {
36
+ continue;
37
+ }
38
+ const specifiers = statement.specifiers;
39
+ const index = specifiers.findIndex(
40
+ (specifier2) => specifier2.type === "ImportSpecifier" && specifier2.imported.type === "Identifier" && specifier2.imported.name === name && specifier2.local.name === name
41
+ );
42
+ if (index === -1) {
43
+ continue;
44
+ }
45
+ const specifier = specifiers[index];
46
+ let start;
47
+ let end;
48
+ if (specifiers.length === 1) {
49
+ start = statement.start ?? 0;
50
+ end = statement.end ?? 0;
51
+ if (code[end] === "\n") {
52
+ end++;
53
+ }
54
+ } else if (index === specifiers.length - 1) {
55
+ start = specifiers[index - 1].end ?? 0;
56
+ end = specifier.end ?? 0;
57
+ } else {
58
+ start = specifier.start ?? 0;
59
+ end = specifiers[index + 1].start ?? 0;
60
+ }
61
+ return code.slice(0, start) + code.slice(end);
62
+ }
63
+ return code;
28
64
  };
29
65
  const removeSetImport = () => {
30
66
  const routesPath = getPaths().web.routes;
31
67
  const routesContent = readFile(routesPath).toString();
32
- if (routesContent.match("<Set")) {
68
+ const unusedNames = ["Set", "PrivateSet"].filter(
69
+ (name) => !new RegExp(`<${name}\\b`).test(routesContent)
70
+ );
71
+ if (unusedNames.length === 0) {
33
72
  return "Skipping removal of Set import in Routes.{jsx,tsx}";
34
73
  }
35
- const cedarRouterImportMatch = routesContent.match(
36
- /import {[^]*} from '@cedarjs\/router'/
37
- );
38
- if (!cedarRouterImportMatch) {
39
- return "No @cedarjs/router import found in Routes.{jsx,tsx}";
74
+ let newRoutesContent = routesContent;
75
+ try {
76
+ for (const name of unusedNames) {
77
+ newRoutesContent = removeNamedImport(
78
+ newRoutesContent,
79
+ "@cedarjs/router",
80
+ name
81
+ );
82
+ }
83
+ } catch {
84
+ return "Skipping removal of Set import, Routes.{jsx,tsx} couldn't be parsed";
85
+ }
86
+ if (newRoutesContent === routesContent) {
87
+ return "No unused Set or PrivateSet import found in Routes.{jsx,tsx}";
40
88
  }
41
- const [cedarRouterImport] = cedarRouterImportMatch;
42
- const removedSetImport = cedarRouterImport.replace(/,*\s*Set,*/, "");
43
- const newRoutesContent = routesContent.replace(
44
- cedarRouterImport,
45
- removedSetImport
46
- );
47
89
  writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
48
- return "Removed Set import in Routes.{jsx,tsx}";
90
+ return "Removed unused Set and PrivateSet imports in Routes.{jsx,tsx}";
49
91
  };
50
92
  const removeLayoutImport = ({
51
93
  model: name,
52
94
  path: scaffoldPath = ""
53
95
  }) => {
54
- const pluralPascalName = pascalcase(pluralize(name));
55
- const pascalScaffoldPath = scaffoldPath === "" ? scaffoldPath : scaffoldPath.split("/").map(pascalcase).join("/") + "/";
56
- const layoutName = `${pluralPascalName}Layout`;
57
- const importLayout = `import ${pluralPascalName}Layout from 'src/layouts/${pascalScaffoldPath}${layoutName}'`;
96
+ const { importName, importPath } = getScaffoldLayoutNames(name, scaffoldPath);
58
97
  const routesPath = getPaths().web.routes;
59
98
  const routesContent = readFile(routesPath).toString();
60
- const newRoutesContent = routesContent.replace(
61
- new RegExp(`\\s*${importLayout}`),
62
- ""
99
+ const importLayout = new RegExp(
100
+ `\\s*import ${importName} from (['"])${importPath}\\1;?`
63
101
  );
102
+ const newRoutesContent = routesContent.replace(importLayout, "");
64
103
  writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
65
104
  return "Removed layout import from Routes.{jsx,tsx}";
66
105
  };
@@ -1,5 +1,6 @@
1
1
  import { Listr } from "listr2";
2
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
2
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
3
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
3
4
  import { deleteFilesTask } from "../../../lib/index.js";
4
5
  import { verifyModelName } from "../../../lib/schemaHelpers.js";
5
6
  import { files } from "../../generate/sdl/sdlHandler.js";
@@ -3,8 +3,9 @@ import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import { Writable } from "node:stream";
5
5
  import concurrently from "concurrently";
6
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
6
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
7
7
  import { formatRunBinCommand } from "@cedarjs/cli-helpers/packageManager/display";
8
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
8
9
  import { shutdownPort } from "@cedarjs/internal/dist/dev";
9
10
  import { generateGqlormArtifacts } from "@cedarjs/internal/dist/generate/gqlormSchema";
10
11
  import { getConfig, getConfigPath } from "@cedarjs/project-config";
@@ -256,15 +257,13 @@ const handler = async ({
256
257
  });
257
258
  } else {
258
259
  if (workspace.includes("api")) {
259
- const isEsm = rootPackageJson.type === "module";
260
- const serverWatchCommand = isEsm ? `cedarjs-api-server-watch` : `cedar-api-server-watch`;
261
260
  const cedarConfigPath = getConfigPath();
262
261
  jobs.push({
263
262
  name: "api",
264
263
  command: formatRunBinCommand("nodemon", [
265
264
  "--quiet",
266
265
  `--watch "${cedarConfigPath}"`,
267
- `--exec "${formatRunBinCommand(serverWatchCommand)} --port ${apiAvailablePort} ${getApiDebugFlag(apiDebugPort, apiAvailablePort)} | ${formatRunBinCommand("cedar-log-formatter")}"`
266
+ `--exec "${formatRunBinCommand("cedar-api-server-watch")} --port ${apiAvailablePort} ${getApiDebugFlag(apiDebugPort, apiAvailablePort)} | ${formatRunBinCommand("cedar-log-formatter")}"`
268
267
  ]),
269
268
  env: {
270
269
  NODE_ENV: "development",
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { colors as c } from "@cedarjs/cli-helpers";
4
- import { importStatementPath } from "@cedarjs/project-config";
3
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { getConfig, importStatementPath } from "@cedarjs/project-config";
5
5
  import { getPaths } from "../../lib/index.js";
6
6
  async function getPackageWatchCommands(packageWorkspaces) {
7
7
  const cedarPaths = getPaths();
@@ -17,6 +17,7 @@ async function getPackageWatchCommands(packageWorkspaces) {
17
17
  }
18
18
  return importStatementPath(workspacePath);
19
19
  });
20
+ const packagesWorkspaceConfig = getConfig().experimental.packagesWorkspace;
20
21
  const watchablePackages = [];
21
22
  const packagesWithoutWatch = [];
22
23
  for (const workspacePath of workspacePaths) {
@@ -29,7 +30,11 @@ async function getPackageWatchCommands(packageWorkspaces) {
29
30
  if (packageJson.scripts?.watch) {
30
31
  watchablePackages.push(workspacePath);
31
32
  } else {
32
- packagesWithoutWatch.push(packageName);
33
+ const packageConfig = packageName && packagesWorkspaceConfig[packageName];
34
+ const skipWatchWarning = typeof packageConfig === "object" && packageConfig.skipWatchWarning;
35
+ if (!skipWatchWarning) {
36
+ packagesWithoutWatch.push(packageName);
37
+ }
33
38
  }
34
39
  }
35
40
  if (packagesWithoutWatch.length > 0) {
@@ -1,5 +1,5 @@
1
1
  import { terminalLink } from "termi-link";
2
- import { colors as c } from "@cedarjs/cli-helpers";
2
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
3
3
  import { workspaces } from "../lib/project.js";
4
4
  import { checkNodeVersion } from "../middleware/checkNodeVersion.js";
5
5
  const command = "dev [workspace..]";
@@ -4,7 +4,8 @@ import { context } from "@opentelemetry/api";
4
4
  import { suppressTracing } from "@opentelemetry/core";
5
5
  import { Listr } from "listr2";
6
6
  import { Parser } from "yargs/helpers";
7
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
7
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
8
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
8
9
  import { findScripts } from "@cedarjs/internal/dist/files";
9
10
  import { runScriptFunction } from "../lib/exec.js";
10
11
  import { generatePrismaClient } from "../lib/generatePrismaClient.js";
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "../util.js";
3
3
  const command = "setup-live-queries";
4
4
  const description = "Setup live query invalidation with Postgres notifications";
@@ -1,11 +1,11 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { Listr } from "listr2";
4
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
4
5
  import {
5
6
  addApiPackages,
6
- addWebPackages,
7
- colors as c
8
- } from "@cedarjs/cli-helpers";
7
+ addWebPackages
8
+ } from "@cedarjs/cli-helpers/installHelpers";
9
9
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
10
10
  import {
11
11
  getConfigPath,
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-inngest";
4
4
  const description = "Setup Inngest for background, scheduled, delayed, multi-step, and fan-out jobs";
@@ -1,5 +1,5 @@
1
1
  import { Listr } from "listr2";
2
- import { colors as c } from "@cedarjs/cli-helpers";
2
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
3
3
  import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
4
4
  import { addRootPackages } from "@cedarjs/cli-helpers/packageManager/packages";
5
5
  import { errorTelemetry } from "@cedarjs/telemetry";
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-opentelemetry";
4
4
  const description = "Setup OpenTelemetry within the API side";
@@ -2,7 +2,8 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
4
4
  import { Listr } from "listr2";
5
- import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
6
7
  import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
7
8
  import {
8
9
  getConfigPath,
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-react-compiler";
4
4
  const description = "Enable the experimental React Compiler";
@@ -1,8 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { Listr } from "listr2";
4
- import semver from "semver";
5
- import { colors as c } from "@cedarjs/cli-helpers";
4
+ import { coerce, isGreaterThanOrEqual } from "verkit";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
6
  import {
7
7
  addRootPackages,
8
8
  addWorkspacePackages
@@ -39,8 +39,8 @@ const handler = async (options) => {
39
39
  )
40
40
  );
41
41
  const reactVersion = webPkgJson["dependencies"]["react"];
42
- const coercedReactVersion = semver.coerce(reactVersion);
43
- if (!coercedReactVersion || !semver.gte(coercedReactVersion, "19.0.0")) {
42
+ const coercedReactVersion = coerce(reactVersion);
43
+ if (!coercedReactVersion || !isGreaterThanOrEqual(coercedReactVersion, "19.0.0")) {
44
44
  throw new Error(
45
45
  "You need to be using at least React version 19 to enable the React Compiler"
46
46
  );
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-rsc";
4
4
  const description = "Enable React Server Components (RSC)";
@@ -2,7 +2,8 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import execa from "execa";
4
4
  import { Listr } from "listr2";
5
- import { prettify, colors as c } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { prettify } from "@cedarjs/cli-helpers/fileHelpers";
6
7
  import { install } from "@cedarjs/cli-helpers/packageManager";
7
8
  import { getConfig, getConfigPath } from "@cedarjs/project-config";
8
9
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  import { getEpilogue } from "./util.js";
3
3
  const command = "setup-streaming-ssr";
4
4
  const description = "Enable React Streaming and Server Side Rendering (SSR)";
@@ -2,7 +2,8 @@ import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
4
4
  import { Listr } from "listr2";
5
- import { addWebPackages, colors as c } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { addWebPackages } from "@cedarjs/cli-helpers/installHelpers";
6
7
  import { getConfigPath } from "@cedarjs/project-config";
7
8
  import { errorTelemetry } from "@cedarjs/telemetry";
8
9
  import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
@@ -183,7 +184,7 @@ You'll manually need to merge it with your existing entry.client${ext} file.`;
183
184
  fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
184
185
  }
185
186
  },
186
- addWebPackages(["@apollo/client-react-streaming@0.10.0"]),
187
+ addWebPackages(["@apollo/client-react-streaming@0.14.5"]),
187
188
  {
188
189
  task: () => {
189
190
  printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
@@ -22,6 +22,26 @@ const builder = createBuilder({
22
22
  default: "",
23
23
  description: "Use to enforce a specific query name within the generated cell - must be unique.",
24
24
  type: "string"
25
+ },
26
+ beforeQuery: {
27
+ default: false,
28
+ description: "Include a typed `beforeQuery` stub for configuring the query (e.g. variables, fetch policy).",
29
+ type: "boolean"
30
+ },
31
+ afterQuery: {
32
+ default: false,
33
+ description: "Include a typed `afterQuery` stub for sanitizing data returned from the query.",
34
+ type: "boolean"
35
+ },
36
+ isEmpty: {
37
+ default: false,
38
+ description: "Include a typed `isEmpty` stub for overriding the default check for the Empty component.",
39
+ type: "boolean"
40
+ },
41
+ fragment: {
42
+ default: "",
43
+ description: "Generate a fragment cell (exports FRAGMENT instead of QUERY) that reads its data from a parent Cell, given the GraphQL type it selects from - e.g. --fragment User.",
44
+ type: "string"
25
45
  }
26
46
  };
27
47
  }
@@ -26,7 +26,11 @@ const files = async ({
26
26
  list = false,
27
27
  query,
28
28
  stories,
29
- tests
29
+ tests,
30
+ beforeQuery = false,
31
+ afterQuery = false,
32
+ isEmpty = false,
33
+ fragment = ""
30
34
  }) => {
31
35
  let cellName = removeGeneratorName(name, "cell");
32
36
  let idName = "id";
@@ -35,22 +39,49 @@ const files = async ({
35
39
  let model = null;
36
40
  let templateNameSuffix = "";
37
41
  let typeName = cellName;
38
- const shouldGenerateList = (isWordPluralizable(cellName) ? isPlural(cellName) : list) || list;
39
- try {
40
- model = await getSchema(pascalcase(singularize(cellName)));
41
- idName = getIdName(model);
42
- idType = getIdType(model);
43
- typeName = model.name;
44
- mockIdValues = idType === "String" ? mockIdValues.map((value) => `'${value}'`) : mockIdValues;
45
- } catch {
46
- idType = "Int";
42
+ if (fragment) {
43
+ if (list) {
44
+ throw new Error(
45
+ "The --list flag cannot be combined with --fragment; fragment cells always render a single item."
46
+ );
47
+ }
48
+ if (beforeQuery) {
49
+ throw new Error(
50
+ "The --before-query flag cannot be combined with --fragment; fragment cells never fire a query of their own."
51
+ );
52
+ }
53
+ if (query) {
54
+ throw new Error(
55
+ "The --query flag cannot be combined with --fragment; fragment cells don't have an operation name."
56
+ );
57
+ }
58
+ }
59
+ const shouldGenerateList = !fragment && ((isWordPluralizable(cellName) ? isPlural(cellName) : list) || list);
60
+ if (!fragment) {
61
+ try {
62
+ model = await getSchema(pascalcase(singularize(cellName)));
63
+ idName = getIdName(model);
64
+ idType = getIdType(model);
65
+ typeName = model.name;
66
+ mockIdValues = idType === "String" ? mockIdValues.map((value) => `'${value}'`) : mockIdValues;
67
+ } catch {
68
+ idType = "Int";
69
+ }
47
70
  }
48
71
  if (shouldGenerateList) {
49
72
  cellName = forcePluralizeWord(cellName);
50
73
  templateNameSuffix = "List";
51
74
  }
52
75
  let operationName = query;
53
- if (operationName) {
76
+ let fragmentName;
77
+ let fragmentOnType;
78
+ let fragmentPropName;
79
+ if (fragment) {
80
+ const fragmentTypeVariants = nameVariants(fragment);
81
+ fragmentOnType = fragmentTypeVariants.pascalName;
82
+ fragmentPropName = fragmentTypeVariants.camelName;
83
+ fragmentName = `${nameVariants(cellName).pascalName}Cell_${fragmentPropName}`;
84
+ } else if (operationName) {
54
85
  const userSpecifiedOperationNameIsUnique = await operationNameIsUnique(operationName);
55
86
  if (!userSpecifiedOperationNameIsUnique) {
56
87
  throw new Error(`Specified query name: "${operationName}" is not unique!`);
@@ -67,11 +98,20 @@ const files = async ({
67
98
  extension,
68
99
  webPathSection: CEDAR_WEB_PATH_NAME,
69
100
  generator: "cell",
70
- templatePath: `cell${templateNameSuffix}.tsx.template`,
71
- templateVars: {
101
+ templatePath: fragment ? "cellFragment.tsx.template" : `cell${templateNameSuffix}.tsx.template`,
102
+ templateVars: fragment ? {
103
+ fragmentName,
104
+ fragmentOnType,
105
+ camelName: fragmentPropName,
106
+ afterQuery,
107
+ isEmpty
108
+ } : {
72
109
  operationName,
73
110
  idName,
74
- idType
111
+ idType,
112
+ beforeQuery,
113
+ afterQuery,
114
+ isEmpty
75
115
  }
76
116
  });
77
117
  const testFile = await templateForComponentFile({
@@ -80,8 +120,8 @@ const files = async ({
80
120
  extension: `.test${extension}`,
81
121
  webPathSection: CEDAR_WEB_PATH_NAME,
82
122
  generator: "cell",
83
- templatePath: "test.js.template",
84
- templateVars: {
123
+ templatePath: fragment ? "testFragment.js.template" : "test.js.template",
124
+ templateVars: fragment ? { camelName: fragmentPropName } : {
85
125
  idName: shouldGenerateList ? void 0 : idName,
86
126
  mockIdValues: shouldGenerateList ? void 0 : mockIdValues
87
127
  }
@@ -92,7 +132,7 @@ const files = async ({
92
132
  extension: `.stories${extension}`,
93
133
  webPathSection: CEDAR_WEB_PATH_NAME,
94
134
  generator: "cell",
95
- templatePath: "stories.tsx.template"
135
+ templatePath: fragment ? "storiesFragment.tsx.template" : "stories.tsx.template"
96
136
  });
97
137
  const mockFile = await templateForComponentFile({
98
138
  name: cellName,
@@ -101,7 +141,12 @@ const files = async ({
101
141
  webPathSection: CEDAR_WEB_PATH_NAME,
102
142
  generator: "cell",
103
143
  templatePath: `mock${templateNameSuffix}.ts.template`,
104
- templateVars: {
144
+ templateVars: fragment ? {
145
+ idName,
146
+ mockIdValues,
147
+ typeName: fragmentOnType,
148
+ camelName: fragmentPropName
149
+ } : {
105
150
  idName,
106
151
  mockIdValues,
107
152
  typeName
@@ -122,7 +167,10 @@ const files = async ({
122
167
  const handler = createHandler({
123
168
  componentName: "cell",
124
169
  filesFn: files,
125
- includeAdditionalTasks: ({ name: cellName }) => {
170
+ includeAdditionalTasks: ({
171
+ name: cellName,
172
+ fragment
173
+ }) => {
126
174
  return [
127
175
  {
128
176
  title: `Generating types ...`,
@@ -130,7 +178,7 @@ const handler = createHandler({
130
178
  const queryFieldName = nameVariants(
131
179
  removeGeneratorName(cellName, "cell")
132
180
  ).camelName;
133
- const projectHasSdl = await checkProjectForQueryField(queryFieldName);
181
+ const projectHasSdl = Boolean(fragment) || await checkProjectForQueryField(queryFieldName);
134
182
  if (projectHasSdl) {
135
183
  const { errors } = await generateTypes();
136
184
  for (const { message, error } of errors) {
@@ -6,7 +6,9 @@ import type {
6
6
  import type {
7
7
  CellSuccessProps,
8
8
  CellFailureProps,
9
- TypedDocumentNode,
9
+ TypedDocumentNode,<% if (beforeQuery) { %>
10
+ CellBeforeQueryResult,<% } %><% if (afterQuery || isEmpty) { %>
11
+ DataObject,<% } %>
10
12
  } from '@cedarjs/web'
11
13
 
12
14
  export const QUERY: TypedDocumentNode<
@@ -19,7 +21,24 @@ export const QUERY: TypedDocumentNode<
19
21
  }
20
22
  }
21
23
  `
22
-
24
+ <% if (beforeQuery) { %>
25
+ export const beforeQuery = (
26
+ props: ${operationName}Variables,
27
+ ): CellBeforeQueryResult<${operationName}Variables> => {
28
+ return { variables: props, fetchPolicy: 'cache-and-network' }
29
+ }
30
+ <% } %><% if (isEmpty) { %>
31
+ export const isEmpty = (
32
+ data: DataObject,
33
+ { isDataEmpty }: { isDataEmpty: (data: DataObject) => boolean },
34
+ ) => {
35
+ return isDataEmpty(data)
36
+ }
37
+ <% } %><% if (afterQuery) { %>
38
+ export const afterQuery = (data: DataObject): DataObject => {
39
+ return data
40
+ }
41
+ <% } %>
23
42
  export const Loading = () => <div>Loading...</div>
24
43
 
25
44
  export const Empty = () => <div>Empty</div>