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

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
@@ -2,144 +2,45 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { Listr } from "listr2";
4
4
  import prompts from "prompts";
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 { errorTelemetry } from "@cedarjs/telemetry";
8
7
  import {
9
8
  addPackagesTask,
10
9
  getPaths,
11
10
  printSetupNotes
12
11
  } from "../../../../lib/index.js";
13
- import { MONITORS, isMonitor } from "../../../deploy/baremetal/monitors.js";
14
12
  import { addFilesTask } from "../helpers/index.js";
15
- import {
16
- MAINTENANCE,
17
- SYSTEMD_DIR,
18
- deployToml,
19
- ecosystemConfig,
20
- systemdJobsUnit,
21
- systemdServiceUnit
22
- } from "../templates/baremetal.js";
13
+ import { DEPLOY, ECOSYSTEM, MAINTENANCE } from "../templates/baremetal.js";
23
14
  const configFilename = "deploy.toml";
24
- const MONITOR_CHOICES = [
15
+ const files = [
25
16
  {
26
- title: "pm2",
27
- description: "Node process manager, configured in ecosystem.config.js",
28
- value: "pm2"
17
+ path: path.join(getPaths().base, configFilename),
18
+ content: DEPLOY
29
19
  },
30
20
  {
31
- title: "systemd (user units)",
32
- description: "Units in ~/.config/systemd/user, managed by the deploy user without sudo",
33
- value: "systemd-user"
21
+ path: path.join(getPaths().base, "ecosystem.config.js"),
22
+ content: ECOSYSTEM
34
23
  },
35
24
  {
36
- title: "systemd (system units)",
37
- description: "Units in /etc/systemd/system, managed with sudo systemctl",
38
- value: "systemd-system"
39
- }
40
- ];
41
- const appNameFromPath = (projectPath) => {
42
- const name = path.basename(projectPath).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
43
- return name || "cedar";
44
- };
45
- const setupFiles = ({
46
- monitor,
47
- jobs,
48
- appName,
49
- basePath,
50
- webSrcPath
51
- }) => {
52
- const files = [];
53
- let processNames;
54
- if (monitor === "pm2") {
55
- processNames = jobs ? ["serve", "jobs"] : ["serve"];
56
- files.push({
57
- path: path.join(basePath, "ecosystem.config.js"),
58
- content: ecosystemConfig({ jobs })
59
- });
60
- } else {
61
- const jobsUnit = `${appName}-jobs`;
62
- processNames = jobs ? [appName, `${jobsUnit}@0`] : [appName];
63
- files.push({
64
- path: path.join(basePath, SYSTEMD_DIR, `${appName}.service`),
65
- content: systemdServiceUnit({ appName, monitor })
66
- });
67
- if (jobs) {
68
- files.push({
69
- path: path.join(basePath, SYSTEMD_DIR, `${jobsUnit}@.service`),
70
- content: systemdJobsUnit({ appName, monitor })
71
- });
72
- }
73
- }
74
- files.unshift({
75
- path: path.join(basePath, configFilename),
76
- content: deployToml({ monitor, processNames })
77
- });
78
- files.push({
79
- path: path.join(webSrcPath, "maintenance.html"),
25
+ path: path.join(getPaths().web.src, "maintenance.html"),
80
26
  content: MAINTENANCE
81
- });
82
- return { files, processNames };
83
- };
84
- const notesFor = (monitor, jobs, processNames) => {
85
- const notes = ["You are almost ready to go BAREMETAL!", ""];
86
- if (monitor !== "pm2") {
87
- notes.push(
88
- `Copy the unit files in ${SYSTEMD_DIR}/ to the server before your first`,
89
- "deploy. The comments at the top of each file say where they go.",
90
- ""
91
- );
92
27
  }
93
- if (jobs) {
94
- notes.push(
95
- `Background jobs are set up, so deploy.toml lists a jobs worker process`,
96
- `(${processNames[processNames.length - 1]}). Add one per entry in the`,
97
- "`workers` array of api/src/lib/jobs.ts.",
98
- ""
99
- );
100
- }
101
- notes.push(
102
- "See https://cedarjs.com/docs/deploy/baremetal for the remaining",
103
- "config and setup required before you can perform your first deploy."
104
- );
105
- return notes;
106
- };
107
- const promptForMonitor = async () => {
108
- const { monitor } = await prompts({
109
- type: "select",
110
- name: "monitor",
111
- message: "Which process monitor will run your app on the server?",
112
- choices: MONITOR_CHOICES
113
- });
114
- return isMonitor(monitor) ? monitor : void 0;
115
- };
116
- const handler = async ({
117
- force,
118
- monitor: monitorOption
119
- }) => {
28
+ ];
29
+ const notes = [
30
+ "You are almost ready to go BAREMETAL!",
31
+ "",
32
+ "See https://cedarjs.com/docs/deploy/baremetal for the remaining",
33
+ "config and setup required before you can perform your first deploy."
34
+ ];
35
+ const handler = async ({ force }) => {
120
36
  recordTelemetryAttributes({
121
37
  command: "setup deploy baremetal",
122
- force,
123
- monitor: monitorOption
38
+ force
124
39
  });
125
- if (monitorOption !== void 0 && !isMonitor(monitorOption)) {
126
- console.error(
127
- c.error(
128
- `Unknown monitor "${monitorOption}". Use one of ${MONITORS.join(", ")}.`
129
- )
130
- );
131
- process.exit(1);
132
- }
133
- const monitor = monitorOption ?? await promptForMonitor();
134
- if (!monitor) {
135
- console.log("Aborting baremetal setup.");
136
- return;
137
- }
138
- const paths = getPaths();
139
- if (fs.existsSync(path.join(paths.base, ".pnp.cjs"))) {
40
+ if (fs.existsSync(path.join(getPaths().base, ".pnp.cjs"))) {
140
41
  console.warn(
141
42
  c.warning(
142
- "Your project uses Yarn PnP (Plug'n'Play), which is not officially supported for Baremetal deployments. The generated process config starts the app with node_modules/.bin/cedar, which will most likely not work under PnP.\n\nYou will need to manually configure the server. See also the packageManagerCommand field in deploy.toml."
43
+ "Your project uses Yarn PnP (Plug'n'Play), which is not officially supported for Baremetal deployments. The generated ecosystem.config.js file uses node_modules/.bin/cedar as the PM2 script path, which will most likely not work under PnP.\n\nYou will need to manually configure the server. See also the packageManagerCommand field in deploy.toml."
143
44
  )
144
45
  );
145
46
  console.log();
@@ -154,14 +55,6 @@ const handler = async ({
154
55
  }
155
56
  console.log();
156
57
  }
157
- const jobs = Boolean(paths.api.jobsConfig);
158
- const { files, processNames } = setupFiles({
159
- monitor,
160
- jobs,
161
- appName: appNameFromPath(paths.base),
162
- basePath: paths.base,
163
- webSrcPath: paths.web.src
164
- });
165
58
  const tasks = new Listr(
166
59
  [
167
60
  await addPackagesTask({
@@ -172,7 +65,7 @@ const handler = async ({
172
65
  files,
173
66
  force
174
67
  }),
175
- printSetupNotes(notesFor(monitor, jobs, processNames))
68
+ printSetupNotes(notes)
176
69
  ],
177
70
  { rendererOptions: { collapseSubtasks: false } }
178
71
  );
@@ -187,8 +80,6 @@ const handler = async ({
187
80
  }
188
81
  };
189
82
  export {
190
- appNameFromPath,
191
83
  configFilename,
192
- handler,
193
- setupFiles
84
+ handler
194
85
  };
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "coherence";
3
3
  const description = "Setup Coherence deploy";
4
4
  function builder(yargs) {
@@ -3,17 +3,16 @@ import path from "path";
3
3
  import prismaInternals from "@prisma/internals";
4
4
  import { Listr } from "listr2";
5
5
  import * as toml from "smol-toml";
6
- import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import {
7
+ colors as c,
8
+ isTypeScriptProject,
9
+ getConfigPath
10
+ } from "@cedarjs/cli-helpers";
7
11
  import {
8
12
  formatCedarCommand,
9
13
  formatRunBinCommand
10
14
  } from "@cedarjs/cli-helpers/packageManager/display";
11
- import { isTypeScriptProject } from "@cedarjs/cli-helpers/project";
12
- import {
13
- getConfigPath,
14
- getPaths,
15
- getPrismaSchemas
16
- } from "@cedarjs/project-config";
15
+ import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
17
16
  import { errorTelemetry } from "@cedarjs/telemetry";
18
17
  import { printSetupNotes } from "../../../../lib/index.js";
19
18
  import { serverFileExists } from "../../../../lib/project.js";
@@ -3,9 +3,8 @@ import { EOL } from "os";
3
3
  import path from "path";
4
4
  import prismaInternals from "@prisma/internals";
5
5
  import { Listr } from "listr2";
6
- import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
7
7
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
8
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
9
8
  import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
10
9
  import { errorTelemetry } from "@cedarjs/telemetry";
11
10
  import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
@@ -1,9 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { Listr } from "listr2";
4
- import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
5
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
6
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
7
6
  import { errorTelemetry } from "@cedarjs/telemetry";
8
7
  import {
9
8
  addPackagesTask,
@@ -2,8 +2,7 @@ import path from "path";
2
2
  import prismaInternals from "@prisma/internals";
3
3
  import { Listr } from "listr2";
4
4
  import prompts from "prompts";
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 { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
8
7
  import { errorTelemetry } from "@cedarjs/telemetry";
9
8
  import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
@@ -1,8 +1,7 @@
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";
5
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
4
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
6
5
  import { getSchemaPath, getConfigPath } from "@cedarjs/project-config";
7
6
  import { errorTelemetry } from "@cedarjs/telemetry";
8
7
  import {
@@ -1,10 +1,12 @@
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";
5
- import { getPaths } from "@cedarjs/cli-helpers/paths";
6
- import { isTypeScriptProject } from "@cedarjs/cli-helpers/project";
7
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
4
+ import {
5
+ colors as c,
6
+ getPaths,
7
+ isTypeScriptProject,
8
+ recordTelemetryAttributes
9
+ } from "@cedarjs/cli-helpers";
8
10
  import { errorTelemetry } from "@cedarjs/telemetry";
9
11
  import { printSetupNotes } from "../../../../lib/index.js";
10
12
  const notes = [
@@ -1,9 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { Listr } from "listr2";
4
- import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
5
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
6
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
7
6
  import { errorTelemetry } from "@cedarjs/telemetry";
8
7
  import {
9
8
  addPackagesTask,
@@ -1,26 +1,5 @@
1
1
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
2
- const SYSTEMD_DIR = "systemd";
3
- const JOBS_WORKER_BIN = "api/node_modules/.bin/cedar-jobs-worker";
4
- const WORKER_STOP_TIMEOUT_SECONDS = 600;
5
- const JOBS_WORKER_COMMENT = `# Runs one background jobs worker. \`--index\` picks the entry of the \`workers\`
6
- # array in api/src/lib/jobs.ts and \`--id\` numbers the worker within that
7
- # entry, so an entry with \`count: 2\` needs a second worker with \`--id=1\`.`;
8
- const ecosystemConfig = ({ jobs }) => {
9
- const jobsApp = jobs ? `
10
- {
11
- // Runs one background jobs worker. \`--index\` picks the entry of the
12
- // \`workers\` array in api/src/lib/jobs.ts and \`--id\` numbers the worker
13
- // within that entry, so an entry with \`count: 2\` needs a second app
14
- // with \`--id=1\`.
15
- name: 'jobs',
16
- cwd: 'current',
17
- script: '${JOBS_WORKER_BIN}',
18
- args: '--index=0 --id=0',
19
- // pm2 stops the worker with SIGINT, which lets it finish the job it is
20
- // running. This is how long pm2 waits for that (in ms) before killing it.
21
- kill_timeout: ${WORKER_STOP_TIMEOUT_SECONDS * 1e3},
22
- },` : "";
23
- return `module.exports = {
2
+ const ECOSYSTEM = `module.exports = {
24
3
  apps: [
25
4
  {
26
5
  name: 'serve',
@@ -31,79 +10,10 @@ const ecosystemConfig = ({ jobs }) => {
31
10
  exec_mode: 'cluster',
32
11
  wait_ready: true,
33
12
  listen_timeout: 10000,
34
- },${jobsApp}
13
+ },
35
14
  ],
36
- }
37
- `;
38
- };
39
- const unitHeader = (appName, monitor) => {
40
- const install = monitor === "systemd-system" ? `# sudo cp ${SYSTEMD_DIR}/*.service /etc/systemd/system/` : `# mkdir -p ~/.config/systemd/user && cp ${SYSTEMD_DIR}/*.service ~/.config/systemd/user/`;
41
- const linger = monitor === "systemd-system" ? "" : `#
42
- # User units only run while the user has a session, so let them run after a
43
- # reboot too:
44
- # sudo loginctl enable-linger $(whoami)
45
- `;
46
- return `# systemd unit for the ${appName} Cedar app, generated by \`cedar setup deploy baremetal\`.
47
- #
48
- # Copy the unit files to the server once, before the first deploy:
49
- ${install}
50
- ${linger}#
51
- # Then deploy with \`--first-run\`, which reloads the unit files and enables and
52
- # starts every process listed in deploy.toml.
53
- #
54
- # WorkingDirectory must be the \`path\` from deploy.toml followed by \`/current\`.`;
55
- };
56
- const unitService = (monitor, execStart, extraDirectives = "") => {
57
- const user = monitor === "systemd-system" ? "\nUser=deploy" : "";
58
- return `[Service]
59
- WorkingDirectory=/var/www/app/current
60
- # A login shell puts node and ${getPackageManager()} from a version manager such as nvm on the PATH
61
- ExecStart=/bin/bash -lc '${execStart}'
62
- Restart=always
63
- RestartSec=5
64
- Environment=NODE_ENV=production${user}${extraDirectives}`;
65
- };
66
- const JOBS_STOP_DIRECTIVES = `
67
- # Stopping sends SIGINT so the worker finishes the job it is running before it
68
- # exits. systemd waits this long for that before killing the worker.
69
- KillSignal=SIGINT
70
- TimeoutStopSec=${WORKER_STOP_TIMEOUT_SECONDS}`;
71
- const unitInstall = (monitor) => `[Install]
72
- WantedBy=${monitor === "systemd-system" ? "multi-user.target" : "default.target"}`;
73
- const systemdServiceUnit = ({
74
- appName,
75
- monitor
76
- }) => `${unitHeader(appName, monitor)}
77
-
78
- [Unit]
79
- Description=${appName} (Cedar)
80
- After=network.target
81
-
82
- ${unitService(monitor, "exec node_modules/.bin/cedar serve")}
83
-
84
- ${unitInstall(monitor)}
85
- `;
86
- const systemdJobsUnit = ({
87
- appName,
88
- monitor
89
- }) => `${unitHeader(appName, monitor)}
90
- #
91
- ${JOBS_WORKER_COMMENT}
92
- # Start one instance per \`workers\` entry: \`${appName}-jobs@0\`, \`${appName}-jobs@1\`
93
- # and so on, and list each one in \`processNames\` in deploy.toml.
94
-
95
- [Unit]
96
- Description=${appName} background jobs worker %i (Cedar)
97
- After=network.target
98
-
99
- ${unitService(monitor, `exec ${JOBS_WORKER_BIN} --index=%i --id=0`, JOBS_STOP_DIRECTIVES)}
100
-
101
- ${unitInstall(monitor)}
102
- `;
103
- const deployToml = ({
104
- monitor,
105
- processNames
106
- }) => `# This file contains config for a baremetal deployment
15
+ }`;
16
+ const DEPLOY = `# This file contains config for a baremetal deployment
107
17
  #
108
18
  # SSH connection options include:
109
19
  #
@@ -116,22 +26,6 @@ const deployToml = ({
116
26
  # * passphrase - used if your private key has a passphrase
117
27
  # * agentForward - set to \`true\` to forward the client machine's ssh credentials
118
28
  #
119
- # Process monitor options:
120
- #
121
- # * monitor - "pm2", "systemd-user" or "systemd-system". Decides how processes
122
- # are started for the first time, restarted and stopped
123
- # * monitorCommand - overrides the command the monitor is invoked with. Defaults
124
- # to \`pm2\`, \`systemctl --user\` or \`sudo systemctl\` depending on \`monitor\`,
125
- # for example \`doppler run -- pm2\`
126
- # * processNames - the pm2 app names or systemd unit names to (re)start
127
- #
128
- # After restarting the processes, the deploy requests the api side's health
129
- # check endpoint on the server and fails if it doesn't respond in time:
130
- #
131
- # * healthCheckUrl - defaults to http://localhost:<[api].port>/graphql/health
132
- # on servers that host the api side. Set to \`false\` to skip the check
133
- # * healthCheckTimeout - seconds to keep retrying, defaults to 30
134
- #
135
29
  # See https://cedarjs.com/docs/deploy/baremetal for more info
136
30
 
137
31
  [[production.servers]]
@@ -140,14 +34,13 @@ username = "user"
140
34
  agentForward = true
141
35
  sides = ["api","web"]
142
36
  packageManagerCommand = "${getPackageManager()}"
143
- monitor = "${monitor}"
37
+ monitorCommand = "pm2"
144
38
  path = "/var/www/app"
145
- processNames = [${processNames.map((name) => `"${name}"`).join(", ")}]
39
+ processNames = ["serve"]
146
40
  repo = "git@github.com:myorg/myapp.git"
147
41
  branch = "main"
148
42
  keepReleases = 5
149
43
  freeSpaceRequired = 2048
150
- healthCheckTimeout = 30
151
44
 
152
45
  # If you have separate api and web servers:
153
46
  #
@@ -230,10 +123,7 @@ And take it back down with:
230
123
  </html>
231
124
  `;
232
125
  export {
233
- MAINTENANCE,
234
- SYSTEMD_DIR,
235
- deployToml,
236
- ecosystemConfig,
237
- systemdJobsUnit,
238
- systemdServiceUnit
126
+ DEPLOY,
127
+ ECOSYSTEM,
128
+ MAINTENANCE
239
129
  };
@@ -10,9 +10,6 @@ NODE_VERSION = "24"
10
10
 
11
11
  [functions]
12
12
  directory = "api/dist/ud"
13
- # Sandboxed child scripts (\`@cedarjs/api/sandbox\`) and the packages they
14
- # import. Nothing imports them, so Netlify's file tracing can't find them
15
- included_files = ["api/dist/ud/sandbox-children/**"]
16
13
 
17
14
  # To use Netlify Dev, install Netlify's CLI (\`netlify-cli\`) from NPM and use
18
15
  # \`netlify link\` to connect your local project to a site on Netlify. Then run
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "docker";
3
3
  const description = "Setup the default Cedar Dockerfile";
4
4
  function builder(yargs) {
@@ -3,8 +3,7 @@ import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import execa from "execa";
5
5
  import { Listr } from "listr2";
6
- import { colors as c } from "@cedarjs/cli-helpers/colors";
7
- import { writeFile } from "@cedarjs/cli-helpers/fileHelpers";
6
+ import { writeFile, colors as c } from "@cedarjs/cli-helpers";
8
7
  import { dedupe } from "@cedarjs/cli-helpers/packageManager";
9
8
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
10
9
  import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { terminalLink } from "termi-link";
4
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
4
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
5
5
  const command = "generator <name>";
6
6
  const description = "Copies generator templates locally for customization";
7
7
  const EXCLUDE_GENERATORS = ["dataMigration", "dbAuth", "generator", "secret"];
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { Listr } from "listr2";
4
- import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { colors as c } from "@cedarjs/cli-helpers";
5
5
  import { getPaths } from "../../../lib/index.js";
6
6
  const SIDE_MAP = {
7
7
  web: ["cell", "component", "layout", "page", "scaffold"],
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "fragments";
3
3
  const description = "Set up Fragments for GraphQL";
4
4
  function builder(yargs) {
@@ -2,10 +2,12 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { Listr } from "listr2";
4
4
  import { format } from "prettier";
5
- import { colors } from "@cedarjs/cli-helpers/colors";
6
- import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
5
+ import {
6
+ colors,
7
+ getPrettierOptions,
8
+ setTomlSetting
9
+ } from "@cedarjs/cli-helpers";
7
10
  import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
8
- import { setTomlSetting } from "@cedarjs/cli-helpers/project";
9
11
  import { getConfig, getPaths } from "@cedarjs/project-config";
10
12
  import { runTransform } from "../../../../../lib/runTransform.js";
11
13
  const command = "fragments";
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "trusted-documents";
3
3
  const description = "Set up Trusted Documents for GraphQL";
4
4
  function builder(yargs) {
@@ -2,9 +2,8 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { Listr } from "listr2";
4
4
  import { format } from "prettier";
5
- import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
5
+ import { getPrettierOptions, setTomlSetting } from "@cedarjs/cli-helpers";
6
6
  import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
7
- import { setTomlSetting } from "@cedarjs/cli-helpers/project";
8
7
  import { getConfig, getPaths, resolveFile } from "@cedarjs/project-config";
9
8
  import { runTransform } from "../../../../../lib/runTransform.js";
10
9
  async function handler({ force }) {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "i18n";
3
3
  const description = "Set up i18n";
4
4
  const builder = (yargs) => {
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import path from "path";
3
3
  import { Listr } from "listr2";
4
4
  import { terminalLink } from "termi-link";
5
- import { colors as c } from "@cedarjs/cli-helpers/colors";
5
+ import { colors as c } from "@cedarjs/cli-helpers";
6
6
  import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
7
7
  import { errorTelemetry } from "@cedarjs/telemetry";
8
8
  import extendStorybookConfiguration from "../../../lib/configureStorybook.js";
@@ -1,5 +1,5 @@
1
1
  import { terminalLink } from "termi-link";
2
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
3
3
  const command = "jobs";
4
4
  const description = "Sets up the config file and parent directory for background jobs";
5
5
  const builder = (yargs) => {
@@ -3,8 +3,7 @@ import * as path from "node:path";
3
3
  import prismaInternals from "@prisma/internals";
4
4
  import { Listr } from "listr2";
5
5
  import { terminalLink } from "termi-link";
6
- import { colors as c } from "@cedarjs/cli-helpers/colors";
7
- import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
6
+ import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
8
7
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
9
8
  import { getSchemaPath, getPrismaSchemas } from "@cedarjs/project-config";
10
9
  import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
@@ -23,8 +22,6 @@ model BackgroundJob {
23
22
  lockedBy String?
24
23
  lastError String?
25
24
  failedAt DateTime?
26
- key String? @unique
27
- pausedAt DateTime?
28
25
  createdAt DateTime @default(now())
29
26
  updatedAt DateTime @updatedAt
30
27
  }
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "mailer";
3
3
  const description = "Setup the Cedar mailer. This will install the required packages and add the required initial configuration to your Cedar app.";
4
4
  const builder = (yargs) => {
@@ -1,8 +1,7 @@
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";
5
- import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
4
+ import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
6
5
  import { errorTelemetry } from "@cedarjs/telemetry";
7
6
  import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
8
7
  import { isTypeScriptProject } from "../../../lib/project.js";
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "og-image";
3
3
  const aliases = ["ogImage", "ogimage"];
4
4
  const description = "Set up OG Image generation middleware";
@@ -2,8 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { Listr } from "listr2";
4
4
  import { format } from "prettier";
5
- import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
6
- import { addWebPackages } from "@cedarjs/cli-helpers/installHelpers";
5
+ import { addWebPackages, getPrettierOptions } from "@cedarjs/cli-helpers";
7
6
  import { getConfig, getPaths } from "@cedarjs/project-config";
8
7
  import { runTransform } from "../../../../lib/runTransform.js";
9
8
  async function handler({ force }) {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  const command = "sentry";
3
3
  const description = "Setup Sentry error and performance tracking";
4
4
  const builder = (yargs) => {