@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
@@ -4,13 +4,12 @@ import path from "node:path";
4
4
  import execa from "execa";
5
5
  import { Listr } from "listr2";
6
6
  import { terminalLink } from "termi-link";
7
- import { colors as c } from "@cedarjs/cli-helpers/colors";
7
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
8
8
  import {
9
9
  formatCedarCommand,
10
10
  formatRunWorkspaceScriptCommand
11
11
  } from "@cedarjs/cli-helpers/packageManager/display";
12
12
  import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
13
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
14
13
  import {
15
14
  buildApi,
16
15
  buildApiWithVite,
@@ -1,5 +1,5 @@
1
1
  import { terminalLink } from "termi-link";
2
- import { colors as c } from "@cedarjs/cli-helpers/colors";
2
+ import { colors as c } from "@cedarjs/cli-helpers";
3
3
  import { exitWithError } from "../lib/exit.js";
4
4
  import { workspaces } from "../lib/project.js";
5
5
  import { checkNodeVersion } from "../middleware/checkNodeVersion.js";
@@ -1,5 +1,4 @@
1
- import { colors as c } from "@cedarjs/cli-helpers/colors";
2
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
3
2
  const command = "check";
4
3
  const aliases = ["diagnostics"];
5
4
  const description = "Get structural diagnostics for a Redwood project (experimental)";
@@ -6,37 +6,26 @@ import { Listr } from "listr2";
6
6
  import * as toml from "smol-toml";
7
7
  import { env as envInterpolation } from "string-env-interpolation";
8
8
  import { titleCase } from "title-case";
9
- import { colors as c } from "@cedarjs/cli-helpers/colors";
9
+ import { colors as c } from "@cedarjs/cli-helpers";
10
10
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
11
11
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
12
- import { getConfig, getPaths } from "../../../lib/index.js";
13
- import { MONITOR_ADAPTERS, MONITORS, isMonitor } from "./monitors.js";
12
+ import { getPaths } from "../../../lib/index.js";
14
13
  const CONFIG_FILENAME = "deploy.toml";
15
- const DOCS_URL = "https://cedarjs.com/docs/deploy/baremetal";
16
14
  const SYMLINK_FLAGS = "-nsf";
17
15
  const CURRENT_RELEASE_SYMLINK_NAME = "current";
18
16
  const LIFECYCLE_HOOKS = ["before", "after"];
19
- const DEFAULT_HEALTH_CHECK_PATH = "/graphql/health";
20
- const HEALTH_CHECK_INTERVAL_MS = 2e3;
21
- const HEALTH_CHECK_REQUEST_TIMEOUT_SECONDS = 5;
22
- const WEB_DIST_DIRS = ["web/dist", "web/dist/browser"];
23
- const BUILD_MANIFEST_FILENAME = "client-build-manifest.json";
24
- const LINK_BATCH_SIZE = 100;
25
17
  const RELEASE_DIR_PATTERN = "^[0-9]{14}$";
26
18
  const releaseDirRegExp = new RegExp(RELEASE_DIR_PATTERN);
27
- const DEFAULT_MONITOR = "pm2";
28
19
  const DEFAULT_SERVER_CONFIG = {
29
20
  port: 22,
30
21
  branch: "main",
31
22
  packageManagerCommand: getPackageManager(),
32
- monitor: DEFAULT_MONITOR,
23
+ monitorCommand: "pm2",
33
24
  sides: ["api", "web"],
34
25
  keepReleases: 5,
35
- freeSpaceRequired: 2048,
36
- healthCheckTimeout: 30
26
+ freeSpaceRequired: 2048
37
27
  };
38
28
  const pathJoin = path.posix.join;
39
- const shellQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
40
29
  const throwMissingConfig = (name) => {
41
30
  throw new Error(
42
31
  `"${name}" config option not set. See https://cedarjs.com/docs/deployment/baremetal#deploytoml`
@@ -53,17 +42,6 @@ const verifyConfig = (config, yargs) => {
53
42
  }
54
43
  return true;
55
44
  };
56
- const isHttpUrl = (value) => {
57
- if (typeof value !== "string") {
58
- return false;
59
- }
60
- try {
61
- const { protocol } = new URL(value);
62
- return protocol === "http:" || protocol === "https:";
63
- } catch {
64
- return false;
65
- }
66
- };
67
45
  const verifyServerConfig = (config) => {
68
46
  if (!config.host) {
69
47
  throwMissingConfig("host");
@@ -77,17 +55,6 @@ const verifyServerConfig = (config) => {
77
55
  if (!/^\d+$/.test(String(config.freeSpaceRequired))) {
78
56
  throw new Error('"freeSpaceRequired" must be an integer >= 0');
79
57
  }
80
- if (config.healthCheckUrl !== void 0 && config.healthCheckUrl !== false && !isHttpUrl(config.healthCheckUrl)) {
81
- throw new Error('"healthCheckUrl" must be an http(s) URL or `false`');
82
- }
83
- if (!/^\d+$/.test(String(config.healthCheckTimeout))) {
84
- throw new Error('"healthCheckTimeout" must be an integer >= 0');
85
- }
86
- if (!isMonitor(config.monitor)) {
87
- throw new Error(
88
- `"monitor" must be one of ${MONITORS.map((monitor) => `"${monitor}"`).join(", ")}`
89
- );
90
- }
91
58
  return true;
92
59
  };
93
60
  const symlinkCurrentCommand = async (dir, ssh, deployPath) => {
@@ -97,110 +64,17 @@ const symlinkCurrentCommand = async (dir, ssh, deployPath) => {
97
64
  CURRENT_RELEASE_SYMLINK_NAME
98
65
  ]);
99
66
  };
100
- const monitorAdapter = (serverConfig) => MONITOR_ADAPTERS[serverConfig.monitor];
101
- const runMonitorCommand = async (command, ssh, serverConfig) => {
102
- return await ssh.exec(
103
- serverConfig.path,
104
- serverConfig.monitorCommand,
105
- command.args
106
- );
107
- };
108
- const monitorTask = (command, ssh, serverConfig, skip) => {
109
- return {
110
- title: command.title,
111
- task: async () => {
112
- await runMonitorCommand(command, ssh, serverConfig);
113
- },
114
- ...skip ? { skip } : {}
115
- };
116
- };
117
- const healthCheckUrl = (serverConfig) => {
118
- if (serverConfig.healthCheckUrl === false) {
119
- return void 0;
120
- }
121
- if (serverConfig.healthCheckUrl) {
122
- return serverConfig.healthCheckUrl;
123
- }
124
- if (!serverConfig.sides.includes("api")) {
125
- return void 0;
126
- }
127
- return `http://localhost:${getConfig().api.port}${DEFAULT_HEALTH_CHECK_PATH}`;
128
- };
129
- const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
130
- const waitForHealthCheck = async ({
131
- url,
132
- timeoutSeconds,
133
- ssh,
134
- serverConfig,
135
- nextSteps,
136
- onFailedAttempt
137
- }) => {
138
- const deadline = Date.now() + timeoutSeconds * 1e3;
139
- let lastFailure = "";
140
- let keepTrying = true;
141
- while (keepTrying) {
142
- try {
143
- await ssh.exec(serverConfig.path, "curl", [
144
- "--fail",
145
- "--location",
146
- "--silent",
147
- "--show-error",
148
- "--output",
149
- "/dev/null",
150
- "--max-time",
151
- String(HEALTH_CHECK_REQUEST_TIMEOUT_SECONDS),
152
- shellQuote(url)
153
- ]);
154
- return;
155
- } catch (e) {
156
- lastFailure = e instanceof Error ? e.message : String(e);
157
- onFailedAttempt?.(lastFailure);
158
- }
159
- keepTrying = Date.now() + HEALTH_CHECK_INTERVAL_MS <= deadline;
160
- if (keepTrying) {
161
- await sleep(HEALTH_CHECK_INTERVAL_MS);
162
- }
163
- }
164
- throw new Error(
165
- [
166
- `Health check failed: ${url} did not respond successfully within ${timeoutSeconds} seconds of restarting the ${serverConfig.processNames?.join(", ")} process(es).`,
167
- `Last attempt: ${lastFailure}`,
168
- "",
169
- ...nextSteps,
170
- `If your app serves its health check somewhere else, set \`healthCheckUrl\` in deploy.toml. Set it to \`false\` to skip the check. See ${DOCS_URL}#health-check`
171
- ].join("\n")
172
- );
173
- };
174
- const healthCheckTask = (url, ssh, serverConfig, nextSteps) => {
175
- return {
176
- title: url ? `Checking ${url}...` : "Checking health...",
177
- task: async (_ctx, task) => {
178
- if (!url) {
179
- return;
180
- }
181
- await waitForHealthCheck({
182
- url,
183
- timeoutSeconds: parseInt(String(serverConfig.healthCheckTimeout), 10),
184
- ssh,
185
- serverConfig,
186
- nextSteps,
187
- onFailedAttempt: (reason) => {
188
- task.output = reason;
189
- }
190
- });
191
- },
192
- skip: () => !url
193
- };
67
+ const restartProcessCommand = async (processName, ssh, serverConfig, deployPath) => {
68
+ return await ssh.exec(deployPath, serverConfig.monitorCommand, [
69
+ "restart",
70
+ processName
71
+ ]);
194
72
  };
195
73
  const serverConfigWithDefaults = (serverConfig, yargs) => {
196
- const monitor = serverConfig.monitor ?? DEFAULT_SERVER_CONFIG.monitor;
197
- const monitorCommand = serverConfig.monitorCommand ?? (isMonitor(monitor) ? MONITOR_ADAPTERS[monitor].defaultCommand : "");
198
74
  return {
199
75
  ...DEFAULT_SERVER_CONFIG,
200
76
  ...serverConfig,
201
- branch: yargs.branch || serverConfig.branch || DEFAULT_SERVER_CONFIG.branch,
202
- monitor,
203
- monitorCommand
77
+ branch: yargs.branch || serverConfig.branch || DEFAULT_SERVER_CONFIG.branch
204
78
  };
205
79
  };
206
80
  const maintenanceTasks = (status, ssh, serverConfig) => {
@@ -222,24 +96,26 @@ const maintenanceTasks = (status, ssh, serverConfig) => {
222
96
  }
223
97
  });
224
98
  if (serverConfig.processNames) {
225
- tasks.push(
226
- monitorTask(
227
- monitorAdapter(serverConfig).stop(serverConfig.processNames),
228
- ssh,
229
- serverConfig
230
- )
231
- );
99
+ tasks.push({
100
+ title: `Stopping ${serverConfig.processNames.join(", ")} processes...`,
101
+ task: async () => {
102
+ await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
103
+ "stop",
104
+ serverConfig.processNames.join(" ")
105
+ ]);
106
+ }
107
+ });
232
108
  }
233
109
  } else if (status === "down") {
234
- if (serverConfig.processNames) {
235
- tasks.push(
236
- monitorTask(
237
- monitorAdapter(serverConfig).start(serverConfig.processNames),
238
- ssh,
239
- serverConfig
240
- )
241
- );
242
- }
110
+ tasks.push({
111
+ title: `Starting ${serverConfig.processNames?.join(", ")} processes...`,
112
+ task: async () => {
113
+ await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
114
+ "start",
115
+ serverConfig.processNames.join(" ")
116
+ ]);
117
+ }
118
+ });
243
119
  if (serverConfig.processNames) {
244
120
  tasks.push({
245
121
  title: `Disabling maintenance page...`,
@@ -291,15 +167,19 @@ const rollbackTasks = (count, ssh, serverConfig) => {
291
167
  }
292
168
  ];
293
169
  if (serverConfig.processNames) {
294
- const adapter = monitorAdapter(serverConfig);
295
170
  for (const processName of serverConfig.processNames) {
296
- tasks.push(monitorTask(adapter.restart(processName), ssh, serverConfig));
171
+ tasks.push({
172
+ title: `Restarting ${processName} process...`,
173
+ task: async () => {
174
+ await restartProcessCommand(
175
+ processName,
176
+ ssh,
177
+ serverConfig,
178
+ serverConfig.path
179
+ );
180
+ }
181
+ });
297
182
  }
298
- tasks.push(
299
- healthCheckTask(healthCheckUrl(serverConfig), ssh, serverConfig, [
300
- "The release you rolled back to is live as `current`. Check the process logs on the server, or run the rollback again with `--rollback` to move one more release back."
301
- ])
302
- );
303
183
  }
304
184
  return tasks;
305
185
  };
@@ -330,134 +210,6 @@ const commandWithLifecycleEvents = ({
330
210
  tasks.push(lifecycleTask("after", name, skip, config));
331
211
  return tasks.flat().filter((t) => Boolean(t));
332
212
  };
333
- const manifestAssetFiles = (manifestJson) => {
334
- const manifest = JSON.parse(manifestJson);
335
- const files = /* @__PURE__ */ new Set();
336
- if (!manifest || typeof manifest !== "object") {
337
- return [];
338
- }
339
- for (const entry of Object.values(manifest)) {
340
- if (!entry || typeof entry !== "object") {
341
- continue;
342
- }
343
- if ("file" in entry && typeof entry.file === "string") {
344
- files.add(entry.file);
345
- }
346
- for (const key of ["css", "assets"]) {
347
- if (!(key in entry) || !Array.isArray(entry[key])) {
348
- continue;
349
- }
350
- for (const item of entry[key]) {
351
- if (typeof item === "string") {
352
- files.add(item);
353
- }
354
- }
355
- }
356
- }
357
- return [...files];
358
- };
359
- const readBuildManifest = async (ssh, releasePath) => {
360
- for (const distDir of WEB_DIST_DIRS) {
361
- let stdout;
362
- try {
363
- ;
364
- ({ stdout } = await ssh.exec(pathJoin(releasePath, distDir), "cat", [
365
- BUILD_MANIFEST_FILENAME
366
- ]));
367
- } catch {
368
- continue;
369
- }
370
- const jsonStart = stdout.indexOf("{");
371
- const json = jsonStart === -1 ? stdout : stdout.slice(jsonStart);
372
- try {
373
- return { distDir, files: manifestAssetFiles(json) };
374
- } catch (e) {
375
- const message = e instanceof Error ? e.message : String(e);
376
- throw new Error(
377
- `Could not parse ${pathJoin(releasePath, distDir, BUILD_MANIFEST_FILENAME)}: ${message}`
378
- );
379
- }
380
- }
381
- return void 0;
382
- };
383
- const keepPreviousAssets = async (yargs, ssh, serverConfig) => {
384
- const newReleasePath = pathJoin(serverConfig.path, yargs.releaseDir);
385
- let newRelease;
386
- try {
387
- newRelease = await readBuildManifest(ssh, newReleasePath);
388
- } catch (e) {
389
- const reason = e instanceof Error ? e.message : String(e);
390
- return { status: "skipped", reason };
391
- }
392
- if (!newRelease) {
393
- return {
394
- status: "skipped",
395
- reason: `No ${BUILD_MANIFEST_FILENAME} in ` + WEB_DIST_DIRS.map((dir) => pathJoin(yargs.releaseDir, dir)).join(
396
- " or "
397
- )
398
- };
399
- }
400
- const { stdout } = await ssh.exec(serverConfig.path, "ls");
401
- const previousReleases = stdout.split("\n").map((line) => line.trim()).filter((dir) => releaseDirRegExp.test(dir) && dir !== yargs.releaseDir).sort().reverse().slice(0, Math.max(serverConfig.keepReleases - 1, 0));
402
- const presentFiles = new Set(newRelease.files);
403
- const warnings = [];
404
- let linkedCount = 0;
405
- for (const release of previousReleases) {
406
- const releasePath = pathJoin(serverConfig.path, release);
407
- let previousRelease;
408
- try {
409
- previousRelease = await readBuildManifest(ssh, releasePath);
410
- } catch (e) {
411
- const message = e instanceof Error ? e.message : String(e);
412
- warnings.push(`Skipping the web assets of release ${release}: ${message}`);
413
- continue;
414
- }
415
- if (!previousRelease) {
416
- warnings.push(
417
- `Release ${release} has no web build manifest, skipping its assets`
418
- );
419
- continue;
420
- }
421
- const missingFiles = previousRelease.files.filter(
422
- (file) => !presentFiles.has(file)
423
- );
424
- if (missingFiles.length === 0) {
425
- continue;
426
- }
427
- const filesByDir = /* @__PURE__ */ new Map();
428
- for (const file of missingFiles) {
429
- const dir = path.posix.dirname(file);
430
- filesByDir.set(dir, [...filesByDir.get(dir) ?? [], file]);
431
- }
432
- try {
433
- for (const [dir, files] of filesByDir) {
434
- const targetDir = pathJoin(newReleasePath, newRelease.distDir, dir);
435
- await ssh.exec(newReleasePath, "mkdir", ["-p", shellQuote(targetDir)]);
436
- for (let i = 0; i < files.length; i += LINK_BATCH_SIZE) {
437
- const sources = files.slice(i, i + LINK_BATCH_SIZE).map(
438
- (file) => shellQuote(pathJoin(releasePath, previousRelease.distDir, file))
439
- );
440
- await ssh.exec(newReleasePath, "ln", [
441
- "-f",
442
- ...sources,
443
- shellQuote(targetDir)
444
- ]);
445
- }
446
- }
447
- } catch (e) {
448
- const message = e instanceof Error ? e.message : String(e);
449
- warnings.push(
450
- `Could not keep the web assets of release ${release}: ${message}`
451
- );
452
- continue;
453
- }
454
- for (const file of missingFiles) {
455
- presentFiles.add(file);
456
- }
457
- linkedCount += missingFiles.length;
458
- }
459
- return { status: "done", linkedCount, warnings };
460
- };
461
213
  const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
462
214
  const cmdPath = pathJoin(serverConfig.path, yargs.releaseDir);
463
215
  const config = {
@@ -606,46 +358,6 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
606
358
  })
607
359
  );
608
360
  }
609
- tasks.push(
610
- ...commandWithLifecycleEvents({
611
- name: "keepAssets",
612
- config,
613
- skip: !yargs.keepAssets || !yargs.build || !serverConfig.sides.includes("web"),
614
- command: {
615
- title: `Keeping web assets of previous releases...`,
616
- task: async (_ctx, task) => {
617
- const result = await keepPreviousAssets(yargs, ssh, serverConfig);
618
- if (result.status === "skipped") {
619
- return task.skip(
620
- c.warning(
621
- `Warning: ${result.reason}, not keeping the web assets of previous releases`
622
- )
623
- );
624
- }
625
- task.output = [
626
- `Linked ${result.linkedCount} file(s) from previous releases`,
627
- ...result.warnings.map((warning) => c.warning(warning))
628
- ].join("\n");
629
- }
630
- }
631
- })
632
- );
633
- if (serverConfig.processNames && yargs.firstRun) {
634
- const configFile = monitorAdapter(serverConfig).firstRunConfigFile;
635
- if (configFile) {
636
- tasks.push({
637
- title: `Checking for ${configFile}...`,
638
- task: () => {
639
- if (!fs.existsSync(path.join(getPaths().base, configFile))) {
640
- throw new Error(
641
- `${configFile} is missing. The ${serverConfig.monitor} monitor reads it when starting processes for the first time. Run \`${formatCedarCommand(["setup", "deploy", "baremetal"])}\` to generate it, or deploy without \`--first-run\` if the processes are already running.`
642
- );
643
- }
644
- },
645
- skip: () => !yargs.restart
646
- });
647
- }
648
- }
649
361
  tasks.push(
650
362
  ...commandWithLifecycleEvents({
651
363
  name: "symlinkCurrent",
@@ -661,56 +373,56 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
661
373
  })
662
374
  );
663
375
  if (serverConfig.processNames) {
664
- const adapter = monitorAdapter(serverConfig);
665
- const skipRestart = () => !yargs.restart;
666
- if (yargs.firstRun) {
667
- for (const command of adapter.firstRunSetup) {
668
- tasks.push(monitorTask(command, ssh, serverConfig, skipRestart));
669
- }
670
- }
671
376
  for (const processName of serverConfig.processNames) {
672
377
  if (yargs.firstRun) {
673
- const [firstCommand, ...followUpCommands] = adapter.firstRun(processName);
674
- if (!firstCommand) {
675
- continue;
676
- }
677
378
  tasks.push(
678
379
  ...commandWithLifecycleEvents({
679
380
  name: "restart",
680
381
  config,
681
382
  skip: !yargs.restart,
682
- command: monitorTask(firstCommand, ssh, serverConfig)
383
+ command: {
384
+ title: `Starting ${processName} process for the first time...`,
385
+ task: async () => {
386
+ await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
387
+ "start",
388
+ pathJoin(CURRENT_RELEASE_SYMLINK_NAME, "ecosystem.config.js"),
389
+ "--only",
390
+ processName
391
+ ]);
392
+ }
393
+ }
683
394
  })
684
395
  );
685
- for (const command of followUpCommands) {
686
- tasks.push(monitorTask(command, ssh, serverConfig, skipRestart));
687
- }
396
+ tasks.push({
397
+ title: `Saving ${processName} state for future startup...`,
398
+ task: async () => {
399
+ await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
400
+ "save"
401
+ ]);
402
+ },
403
+ skip: () => !yargs.restart
404
+ });
688
405
  } else {
689
406
  tasks.push(
690
407
  ...commandWithLifecycleEvents({
691
408
  name: "restart",
692
409
  config,
693
410
  skip: !yargs.restart,
694
- command: monitorTask(
695
- adapter.restart(processName),
696
- ssh,
697
- serverConfig
698
- )
411
+ command: {
412
+ title: `Restarting ${processName} process...`,
413
+ task: async () => {
414
+ await restartProcessCommand(
415
+ processName,
416
+ ssh,
417
+ serverConfig,
418
+ serverConfig.path
419
+ );
420
+ }
421
+ }
699
422
  })
700
423
  );
701
424
  }
702
425
  }
703
- const url = healthCheckUrl(serverConfig);
704
- tasks.push(
705
- ...commandWithLifecycleEvents({
706
- name: "healthCheck",
707
- config: { ...config, cmdPath: serverConfig.path },
708
- skip: !yargs.restart || !url,
709
- command: healthCheckTask(url, ssh, serverConfig, [
710
- `The new release is live as \`current\`. Check the process logs on the server, or roll back to the previous release with \`${formatCedarCommand(["deploy", "baremetal", yargs.environment, "--rollback"])}\`.`
711
- ])
712
- })
713
- );
714
426
  }
715
427
  tasks.push(
716
428
  ...commandWithLifecycleEvents({
@@ -847,8 +559,9 @@ const warnIfUnpushedCommits = async () => {
847
559
  };
848
560
  const handler = async (yargs) => {
849
561
  const { SshExecutor } = await import("./SshExecutor.js");
850
- const tomlPath = path.join(getPaths().base, CONFIG_FILENAME);
851
- if (!fs.existsSync(tomlPath)) {
562
+ const tomlPath = path.join(getPaths().base, "deploy.toml");
563
+ const ecosystemPath = path.join(getPaths().base, "ecosystem.config.js");
564
+ if (!fs.existsSync(tomlPath) || !fs.existsSync(ecosystemPath)) {
852
565
  console.error(
853
566
  c.error("\nError: Baremetal deploy has not been properly setup.\n") + `Please run \`${formatCedarCommand(["setup", "deploy", "baremetal"])}\` before deploying`
854
567
  );
@@ -886,17 +599,13 @@ export {
886
599
  commands,
887
600
  deployTasks,
888
601
  handler,
889
- healthCheckUrl,
890
- keepPreviousAssets,
891
602
  lifecycleTask,
892
603
  maintenanceTasks,
893
- manifestAssetFiles,
894
604
  parseConfig,
895
605
  rollbackTasks,
896
606
  serverConfigWithDefaults,
897
607
  throwMissingConfig,
898
608
  verifyConfig,
899
609
  verifyServerConfig,
900
- waitForHealthCheck,
901
610
  warnIfUnpushedCommits
902
611
  };
@@ -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
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
4
4
  const command = "baremetal [environment]";
5
5
  const description = "Deploy to baremetal server(s)";
@@ -48,11 +48,6 @@ const builder = (yargs) => {
48
48
  default: true,
49
49
  type: "boolean"
50
50
  });
51
- yargs.option("keep-assets", {
52
- describe: "Hardlink previous releases' hashed web assets into the new release so open browser tabs keep working after the deploy",
53
- default: true,
54
- type: "boolean"
55
- });
56
51
  yargs.option("releaseDir", {
57
52
  describe: "Directory to create for the latest release, defaults to timestamp",
58
53
  default: (/* @__PURE__ */ new Date()).toISOString().replace(/[:\-TZ]/g, "").replace(/\.\d+$/, ""),
@@ -100,7 +95,6 @@ async function handler(yargs) {
100
95
  build: yargs.build,
101
96
  restart: yargs.restart,
102
97
  cleanup: yargs.cleanup,
103
- keepAssets: yargs.keepAssets,
104
98
  maintenance: yargs.maintenance,
105
99
  rollback: yargs.rollback,
106
100
  verbose: yargs.verbose,
@@ -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";
3
4
  import {
4
5
  runBin,
5
6
  runTransitiveBin,
6
7
  runWithNode
7
8
  } 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/colors";
2
+ import { colors as c } from "@cedarjs/cli-helpers";
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/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  import { deployBuilder } from "./helpers/deployBuilder.js";
3
3
  const command = "netlify [...commands]";
4
4
  const description = "Build command for Netlify deploy";
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
3
4
  import { formatAddRootPackagesCommand } from "@cedarjs/cli-helpers/packageManager/display";
4
5
  import {
5
6
  runBinSync,
@@ -7,7 +8,6 @@ import {
7
8
  runWithNode
8
9
  } from "@cedarjs/cli-helpers/packageManager/exec";
9
10
  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,13 +6,12 @@ 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 { colors as c } from "@cedarjs/cli-helpers/colors";
9
+ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
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";
16
15
  import { getPaths } from "../../lib/index.js";
17
16
  const preRequisites = () => [
18
17
  {
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
2
2
  import { deployBuilder } from "./helpers/deployBuilder.js";
3
3
  const command = "vercel [...commands]";
4
4
  const description = "Build command for Vercel deploy";