@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,13 +1,11 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import execa from "execa";
4
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
1
  import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
2
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
6
3
  import { ensurePosixPath } from "@cedarjs/project-config";
7
4
  import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
8
5
  import { getPaths } from "../../lib/index.js";
9
6
  import * as project from "../../lib/project.js";
10
7
  import { warnIfNonStandardDatasourceUrl } from "./datasourceWarning.js";
8
+ import { assertSingleViteVersion } from "./viteVersionCheck.js";
11
9
  function hasStringMessage(value) {
12
10
  return typeof value === "object" && value !== null && "message" in value && value.message === "string";
13
11
  }
@@ -17,73 +15,29 @@ function getExitCode(value) {
17
15
  }
18
16
  return value.exitCode;
19
17
  }
20
- function isInGitRepository() {
21
- try {
22
- execa.commandSync("git rev-parse --is-inside-work-tree");
23
- return true;
24
- } catch {
25
- return false;
26
- }
27
- }
28
- function isInMercurialRepository() {
29
- try {
30
- execa.commandSync("hg --cwd . root");
31
- return true;
32
- } catch {
33
- return false;
34
- }
35
- }
36
- function isJestConfigFile(sides) {
37
- for (const side of sides) {
38
- try {
39
- const jestConfigExists = fs.existsSync(path.join(side, "jest.config.js")) || fs.existsSync(path.join(side, "jest.config.ts"));
40
- if (!jestConfigExists) {
41
- console.error(
42
- c.error(
43
- `
44
- Error: Missing Jest config file ${side}/jest.config.js
45
- To add this file, run \`npx @cedarjs/codemods update-jest-config\`
46
- `
47
- )
48
- );
49
- throw new Error(`Error: Jest config file not found in ${side} side`);
50
- }
51
- } catch (error) {
52
- const message = hasStringMessage(error) ? error.message : `Error: Jest config file not found in ${side} side`;
53
- errorTelemetry(process.argv, message);
54
- process.exit(getExitCode(error) ?? 1);
55
- }
56
- }
57
- }
58
18
  const handler = async ({
59
19
  filter: filterParams = [],
60
- watch = true,
61
- collectCoverage = false,
62
20
  dbPush = true,
63
21
  force = false,
64
22
  ...others
65
23
  }) => {
66
24
  recordTelemetryAttributes({
67
25
  command: "test",
68
- watch,
69
- collectCoverage,
70
26
  dbPush
71
27
  });
28
+ let watch = true;
72
29
  const rwjsPaths = getPaths();
73
- const forwardJestFlags = Object.keys(others).flatMap((flagName) => {
74
- if ([
75
- "collect-coverage",
76
- "db-push",
77
- "force",
78
- "loadEnvFiles",
79
- "watch",
80
- "$0",
81
- "_"
82
- ].includes(flagName)) {
30
+ const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
31
+ if (["db-push", "force", "loadEnvFiles", "$0", "_"].includes(flagName)) {
83
32
  return [];
84
33
  }
85
34
  const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
86
35
  const flagValue = others[flagName];
36
+ if (flagName === "watch") {
37
+ watch = flagValue === true;
38
+ } else if (flagName === "run" && flagValue) {
39
+ watch = false;
40
+ }
87
41
  if (Array.isArray(flagValue)) {
88
42
  return flagValue.flatMap((val) => [flag, val]);
89
43
  }
@@ -92,28 +46,25 @@ const handler = async ({
92
46
  const sides = filterParams.filter(
93
47
  (filterString) => project.workspaces().includes(filterString)
94
48
  );
95
- const jestFilterArgs = [
49
+ const vitestFilterArgs = [
96
50
  ...filterParams.filter(
97
51
  (filterString) => !project.workspaces().includes(filterString)
98
52
  )
99
53
  ];
100
- const jestArgs = [
101
- ...jestFilterArgs,
102
- ...forwardJestFlags,
103
- collectCoverage ? "--collectCoverage" : null,
54
+ const vitestArgs = [
55
+ ...vitestFilterArgs,
56
+ ...forwardVitestFlags,
104
57
  "--passWithNoTests"
105
58
  ].filter((flagOrValue) => flagOrValue !== null);
106
- if (watch && !process.env.CI && !collectCoverage) {
107
- const hasSourceControl = isInGitRepository() || isInMercurialRepository();
108
- jestArgs.push(hasSourceControl ? "--watch" : "--watchAll");
59
+ if (process.env.CI) {
60
+ vitestArgs.push("--run");
109
61
  }
110
- if (!sides.length) {
111
- project.workspaces().forEach((side) => sides.push(side));
112
- }
113
- if (sides.length > 0) {
114
- jestArgs.push("--projects", ...sides);
62
+ if (!others["config"]) {
63
+ sides.forEach((side) => vitestArgs.push("--project", side));
64
+ if (!sides.length) {
65
+ project.workspaces().forEach((side) => sides.push(side));
66
+ }
115
67
  }
116
- isJestConfigFile(sides);
117
68
  try {
118
69
  const cacheDirDb = `file:${ensurePosixPath(
119
70
  rwjsPaths.generated.base
@@ -126,8 +77,11 @@ const handler = async ({
126
77
  if (sides.includes("api")) {
127
78
  await warnIfNonStandardDatasourceUrl({ force });
128
79
  }
80
+ if (sides.includes("web")) {
81
+ assertSingleViteVersion();
82
+ }
129
83
  const runCommand = async () => {
130
- await runBin("jest", jestArgs, {
84
+ await runBin("vitest", vitestArgs, {
131
85
  cwd: rwjsPaths.base,
132
86
  stdio: "inherit",
133
87
  env: {
@@ -0,0 +1,75 @@
1
+ import fs from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import { getPaths } from "@cedarjs/project-config";
5
+ function resolvePackage(fromFile, packageName) {
6
+ try {
7
+ const require2 = createRequire(fromFile);
8
+ const packageJsonPath = require2.resolve(`${packageName}/package.json`);
9
+ const packageJson = JSON.parse(
10
+ fs.readFileSync(packageJsonPath, "utf-8")
11
+ );
12
+ if (typeof packageJson !== "object" || packageJson === null || !("version" in packageJson) || typeof packageJson.version !== "string") {
13
+ return void 0;
14
+ }
15
+ return {
16
+ version: packageJson.version,
17
+ dir: path.dirname(packageJsonPath)
18
+ };
19
+ } catch {
20
+ return void 0;
21
+ }
22
+ }
23
+ function resolveViteVersions({
24
+ projectBase,
25
+ webBase
26
+ }) {
27
+ const vitest = resolvePackage(
28
+ path.join(projectBase, "package.json"),
29
+ "vitest"
30
+ );
31
+ const vitestVite = vitest ? resolvePackage(path.join(vitest.dir, "package.json"), "vite") : void 0;
32
+ const cedarVite = resolvePackage(
33
+ path.join(webBase, "package.json"),
34
+ "@cedarjs/vite"
35
+ );
36
+ const frameworkVite = cedarVite ? resolvePackage(path.join(cedarVite.dir, "package.json"), "vite") : void 0;
37
+ return { vitestVite, frameworkVite };
38
+ }
39
+ function getViteVersionMismatchMessage({
40
+ vitestVite,
41
+ frameworkVite
42
+ }) {
43
+ if (!vitestVite || !frameworkVite) {
44
+ return void 0;
45
+ }
46
+ if (vitestVite.version === frameworkVite.version) {
47
+ return void 0;
48
+ }
49
+ return `Vitest is using Vite ${vitestVite.version} from
50
+ ${vitestVite.dir}
51
+ but CedarJS is built against Vite ${frameworkVite.version} from
52
+ ${frameworkVite.dir}
53
+
54
+ The CedarJS Vite plugins only work with the Vite version they're built against, so web tests can't run while Vitest uses a different copy. This happens when the project doesn't pin \`vite\`, because Vitest accepts a wide range of Vite versions and installs the newest one.
55
+
56
+ Please add an override/resolution that pins vite to ${frameworkVite.version}, then reinstall your dependencies.`;
57
+ }
58
+ function assertSingleViteVersion() {
59
+ const cedarPaths = getPaths();
60
+ const message = getViteVersionMismatchMessage(
61
+ resolveViteVersions({
62
+ projectBase: cedarPaths.base,
63
+ webBase: cedarPaths.web.base
64
+ })
65
+ );
66
+ if (message) {
67
+ console.error(message);
68
+ process.exit(1);
69
+ }
70
+ }
71
+ export {
72
+ assertSingleViteVersion,
73
+ getViteVersionMismatchMessage,
74
+ resolveViteVersions
75
+ };
@@ -1,39 +1,31 @@
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
  const command = "test [filter..]";
5
- const description = "Run Jest tests. Defaults to watch mode";
5
+ const description = "Run Vitest tests. Defaults to watch mode";
6
6
  const builder = (yargs) => {
7
+ const cliDocsLink = terminalLink(
8
+ "CedarJS CLI Reference",
9
+ "https://cedarjs.com/docs/cli-commands#test"
10
+ );
11
+ const vitestTip = c.tip("yarn vitest --help");
7
12
  yargs.strict(false).positional("filter", {
8
13
  default: workspaces(),
9
14
  description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
10
15
  type: "string",
11
16
  array: true
12
- }).option("watch", {
13
- describe: "Run tests related to changed files based on hg/git. Specify the name or path to a file to focus on a specific set of tests",
14
- type: "boolean",
15
- default: true
16
- }).option("collect-coverage", {
17
- describe: "Show test coverage summary and output info to coverage directory",
18
- type: "boolean",
19
- default: false
20
17
  }).option("db-push", {
21
18
  describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
22
19
  type: "boolean",
23
20
  default: true
24
21
  }).option("force", {
25
- describe: "Run tests without prompting for confirmation, even when a non-standard datasource url env var is detected.",
22
+ describe: "Skip any confirmation prompts and run tests without interruption. Useful in CI or scripted environments.",
26
23
  type: "boolean",
27
24
  default: false
28
25
  }).epilogue(
29
- `For all available flags, run jest cli directly ${c.tip(
30
- "yarn jest --help"
31
- )}
26
+ `For all available flags, run vitest cli directly ${vitestTip}
32
27
 
33
- Also see the ${terminalLink(
34
- "CedarJS CLI Reference",
35
- "https://cedarjs.com/docs/cli-commands#test"
36
- )}
28
+ Also see the ${cliDocsLink}
37
29
  `
38
30
  );
39
31
  };
@@ -1,9 +1,9 @@
1
1
  import path from "node:path";
2
2
  import concurrently from "concurrently";
3
3
  import { Listr } from "listr2";
4
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
5
4
  import { formatRunBinCommand } from "@cedarjs/cli-helpers/packageManager/display";
6
5
  import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
6
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
7
7
  import { generatePrismaClient } from "../lib/generatePrismaClient.js";
8
8
  import { getPaths } from "../lib/index.js";
9
9
  const isConcurrentlyErrorArray = (value) => {
@@ -3,7 +3,7 @@ import { builtinModules } from "node:module";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import execa from "execa";
6
- import semver from "semver";
6
+ import { tryParse } from "verkit";
7
7
  const MAIN_BRANCH_PRERELEASE_TAGS = ["canary"];
8
8
  function isExecaError(e) {
9
9
  return e instanceof Error && ("stdout" in e || "stderr" in e || "exitCode" in e);
@@ -13,7 +13,7 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
13
13
  return;
14
14
  }
15
15
  const version = typeof ctx.versionToUpgradeTo === "string" ? ctx.versionToUpgradeTo : void 0;
16
- const parsed = semver.parse(version);
16
+ const parsed = version ? tryParse(version) : null;
17
17
  const baseUrl = "https://raw.githubusercontent.com/cedarjs/cedar/main/upgrade-scripts/";
18
18
  const manifestUrl = `${baseUrl}manifest.json`;
19
19
  let manifest = [];
@@ -34,7 +34,7 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
34
34
  if (!Array.isArray(manifest) || manifest.length === 0) {
35
35
  return;
36
36
  }
37
- const prereleaseTag = parsed?.prerelease[0];
37
+ const prereleaseTag = parsed?.prerelease?.[0];
38
38
  const isMainBranchPrerelease = typeof prereleaseTag === "string" && MAIN_BRANCH_PRERELEASE_TAGS.includes(prereleaseTag);
39
39
  const checkLevels = [];
40
40
  if (parsed && isMainBranchPrerelease) {
@@ -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 { dedupeIsSupported } from "@cedarjs/cli-helpers/packageManager";
4
4
  import { isValidCedarJSTag } from "./tags.js";
5
5
  const SEMVER_REGEX = /(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(?=$|\s)/i;
@@ -5,7 +5,7 @@ import execa from "execa";
5
5
  import latestVersion from "latest-version";
6
6
  import { Listr } from "listr2";
7
7
  import { terminalLink } from "termi-link";
8
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
8
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
9
9
  import {
10
10
  dedupe,
11
11
  dedupeIsSupported,
@@ -13,6 +13,7 @@ import {
13
13
  installationErrorMessage,
14
14
  prettyPrintCedarCommand
15
15
  } from "@cedarjs/cli-helpers/packageManager";
16
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
16
17
  import { getConfig } from "@cedarjs/project-config";
17
18
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
18
19
  import { generatePrismaClient } from "../../lib/generatePrismaClient.js";
package/dist/index.js CHANGED
@@ -4,12 +4,10 @@ import path from "path";
4
4
  import { trace, SpanStatusCode } from "@opentelemetry/api";
5
5
  import { hideBin, Parser } from "yargs/helpers";
6
6
  import yargs from "yargs/yargs";
7
- import {
8
- loadEnvFiles,
9
- recordTelemetryAttributes,
10
- colors as c
11
- } from "@cedarjs/cli-helpers";
12
- import { findUp, projectIsEsm, getConfigPath } from "@cedarjs/project-config";
7
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
8
+ import { loadEnvFiles } from "@cedarjs/cli-helpers/loadEnvFiles";
9
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
10
+ import { findUp, getConfigPath } from "@cedarjs/project-config";
13
11
  import { telemetryMiddleware } from "@cedarjs/telemetry";
14
12
  import * as buildCommand from "./commands/build.js";
15
13
  import * as checkCommand from "./commands/check.js";
@@ -30,7 +28,6 @@ import * as serveCommand from "./commands/serve.js";
30
28
  import * as setupCommand from "./commands/setup.js";
31
29
  import * as studioCommand from "./commands/studio.js";
32
30
  import * as testCommand from "./commands/test.js";
33
- import * as testCommandEsm from "./commands/testEsm.js";
34
31
  import * as typeCheckCommand from "./commands/type-check.js";
35
32
  import * as upgradeCommand from "./commands/upgrade/upgrade.js";
36
33
  import { exitWithError } from "./lib/exit.js";
@@ -134,7 +131,7 @@ async function runYargs() {
134
131
  }).example(
135
132
  "yarn cedar g page home /",
136
133
  "Create a page component named 'Home' at path '/'"
137
- ).demandCommand().strict().exitProcess(false).alias("h", "help").command(buildCommand).command(checkCommand).command(consoleCommand).command(deployCommand).command(destroyCommand).command(devCommand).command(execCommand).command(experimentalCommand).command(generateCommand).command(infoCommand).command(jobsCommand).command(lintCommand).command(prerenderCommand).command(prismaCommand).command(recordCommand).command(serveCommand).command(setupCommand).command(studioCommand).command(projectIsEsm() ? testCommandEsm : testCommand).command(typeCheckCommand).command(upgradeCommand);
134
+ ).demandCommand().strict().exitProcess(false).alias("h", "help").command(buildCommand).command(checkCommand).command(consoleCommand).command(deployCommand).command(destroyCommand).command(devCommand).command(execCommand).command(experimentalCommand).command(generateCommand).command(infoCommand).command(jobsCommand).command(lintCommand).command(prerenderCommand).command(prismaCommand).command(recordCommand).command(serveCommand).command(setupCommand).command(studioCommand).command(testCommand).command(typeCheckCommand).command(upgradeCommand);
138
135
  await loadPlugins(yarg);
139
136
  const pkgJson = await import("../package.json", { with: { type: "json" } });
140
137
  yarg.version(pkgJson.default["version"]);
package/dist/lib/exit.js CHANGED
@@ -4,7 +4,7 @@ import { v4 as uuidv4 } from "uuid";
4
4
  import {
5
5
  recordTelemetryAttributes,
6
6
  recordTelemetryError
7
- } from "@cedarjs/cli-helpers";
7
+ } from "@cedarjs/cli-helpers/telemetry";
8
8
  const discordLink = terminalLink("Discord", "https://cedarjs.com/discord");
9
9
  const githubLink = terminalLink("GitHub", "https://github.com/cedarjs/cedar");
10
10
  const DEFAULT_ERROR_EPILOGUE = [
package/dist/lib/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import https from "node:https";
3
3
  import path from "node:path";
4
- import * as babel from "@babel/core";
5
4
  import boxen from "boxen";
6
5
  import camelcase from "camelcase";
7
6
  import { paramCase } from "change-case";
@@ -12,11 +11,12 @@ import memoize from "lodash/memoize.js";
12
11
  import template from "lodash/template.js";
13
12
  import pascalcase from "pascalcase";
14
13
  import { format } from "prettier";
15
- import { colors as c } from "@cedarjs/cli-helpers";
14
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
16
15
  import {
17
16
  addRootPackages,
18
17
  addWorkspacePackages
19
18
  } from "@cedarjs/cli-helpers/packageManager/packages";
19
+ import { transpileTSToJS } from "@cedarjs/cli-helpers/transpileTSToJS";
20
20
  import {
21
21
  getConfig as getCedarConfig,
22
22
  getPaths as getCedarPaths,
@@ -206,29 +206,10 @@ const getPrettierOptions = async () => {
206
206
  }
207
207
  };
208
208
  const transformTSToJS = async (filename, content) => {
209
- const result = babel.transform(content, {
210
- filename,
211
- // If you ran `yarn cedar generate` in `./web` transformSync would import
212
- // the `.babelrc.js` file, in `./web` despite us setting `configFile: false`
213
- cwd: process.env.NODE_ENV === "test" ? void 0 : getPaths().base,
214
- configFile: false,
215
- plugins: [
216
- [
217
- "@babel/plugin-transform-typescript",
218
- {
219
- isTSX: true,
220
- allExtensions: true
221
- }
222
- ]
223
- ],
224
- retainLines: true
225
- });
226
- if (result?.code == null) {
227
- throw new Error(
228
- `Could not transform ${filename} from TypeScript to JavaScript`
229
- );
230
- }
231
- return prettify(filename.replace(/\.ts(x)?$/, ".js$1"), result.code);
209
+ return prettify(
210
+ filename.replace(/\.ts(x)?$/, ".js$1"),
211
+ transpileTSToJS(filename, content)
212
+ );
232
213
  };
233
214
  const transformTSToJSMap = async (files, typescript) => {
234
215
  return files.reduce(
@@ -305,18 +286,17 @@ const cleanupEmptyDirsTask = (files) => {
305
286
  })
306
287
  );
307
288
  };
308
- function wrapWithSet(routesContent, layout, routes, newLineAndIndent, props = {}, privateSetProps) {
289
+ function wrapWithSet(routesContent, layout, routes, newLineAndIndent, privateSetProps) {
309
290
  const [_, indentOne, indentTwo] = routesContent.match(
310
291
  /([ \t]*)<Router.*?>[^<]*[\r\n]+([ \t]+)/
311
292
  ) || ["", "", ""];
312
293
  const oneLevelIndent = indentTwo.slice(0, indentTwo.length - indentOne.length);
313
- const propsString = Object.entries(props).map((values) => `${values[0]}="${values[1]}"`).join(" ");
314
294
  if (!privateSetProps) {
315
295
  const newRoutesWithExtraIndent2 = routes.map(
316
296
  (route) => oneLevelIndent + route
317
297
  );
318
298
  return [
319
- `<Set wrap={${layout}}${propsString && " " + propsString}>`,
299
+ `<Set wrap={${layout}}>`,
320
300
  ...newRoutesWithExtraIndent2,
321
301
  `</Set>`
322
302
  ].join(newLineAndIndent);
@@ -327,13 +307,13 @@ function wrapWithSet(routesContent, layout, routes, newLineAndIndent, props = {}
327
307
  );
328
308
  return [
329
309
  `<PrivateSet${privateSetPropsString && " " + privateSetPropsString}>`,
330
- `${oneLevelIndent}<Set wrap={${layout}}${propsString && " " + propsString}>`,
310
+ `${oneLevelIndent}<Set wrap={${layout}}>`,
331
311
  ...newRoutesWithExtraIndent,
332
312
  `${oneLevelIndent}</Set>`,
333
313
  `</PrivateSet>`
334
314
  ].join(newLineAndIndent);
335
315
  }
336
- function addRoutesToRouterTask(routes, layout, setProps = {}, privateSetProps) {
316
+ function addRoutesToRouterTask(routes, layout, privateSetProps) {
337
317
  const cedarPaths = getPaths();
338
318
  const routesContent = readFile(cedarPaths.web.routes).toString();
339
319
  let newRoutes = routes.filter((route) => !routesContent.match(route));
@@ -357,7 +337,6 @@ ${route}`);
357
337
  layout,
358
338
  newRoutes,
359
339
  newLineAndIndent,
360
- setProps,
361
340
  privateSetProps
362
341
  ) : newRoutes.join(newLineAndIndent);
363
342
  const newRoutesContent = routesContent.replace(
@@ -396,6 +375,12 @@ function removeEmtpySet(routesContent, layout) {
396
375
  if (child.length > 0) {
397
376
  return routesContent;
398
377
  }
378
+ const privateSetWithLayoutReg = new RegExp(
379
+ `\\s*<PrivateSet[^>]*>\\s*<Set[^>]*wrap={${layout}}[^<]*>\\s*</Set>\\s*</PrivateSet>`
380
+ );
381
+ if (privateSetWithLayoutReg.test(routesContent)) {
382
+ return routesContent.replace(privateSetWithLayoutReg, "");
383
+ }
399
384
  return routesContent.replace(setWithLayoutReg, "");
400
385
  }
401
386
  function removeRoutesFromRouterTask(routes, layout) {
@@ -3,7 +3,7 @@ import {
3
3
  loadDefaultEnvFiles,
4
4
  loadNodeEnvDerivedEnvFile,
5
5
  loadUserSpecifiedEnvFiles
6
- } from "@cedarjs/cli-helpers";
6
+ } from "@cedarjs/cli-helpers/loadEnvFiles";
7
7
  export {
8
8
  loadDefaultEnvFiles,
9
9
  loadEnvFiles,
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import path from "path";
3
3
  import ansis from "ansis";
4
4
  import enquirer from "enquirer";
5
- import { getCompatibilityData } from "@cedarjs/cli-helpers";
5
+ import { getCompatibilityData } from "@cedarjs/cli-helpers/version";
6
6
  import { installModule, isModuleInstalled } from "./packages.js";
7
7
  import { getPaths } from "./index.js";
8
8
  const { Select } = enquirer;
package/dist/lib/test.js CHANGED
@@ -80,7 +80,7 @@ vi.mock("@cedarjs/project-config/packageManager", () => ({
80
80
  getPackageManager: vi.fn(() => "yarn"),
81
81
  resetPackageManagerCache: vi.fn()
82
82
  }));
83
- vi.mock("@cedarjs/cli-helpers", async (importOriginal) => {
83
+ vi.mock("@cedarjs/cli-helpers/project", async (importOriginal) => {
84
84
  const originalCliHelpers = await importOriginal();
85
85
  return {
86
86
  ...originalCliHelpers,
@@ -3,7 +3,7 @@ import path from "path";
3
3
  import ansis from "ansis";
4
4
  import boxen from "boxen";
5
5
  import latestVersion from "latest-version";
6
- import semver from "semver";
6
+ import { isGreaterThan, isValid } from "verkit";
7
7
  import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
8
8
  import { getNodeRunnerArgs } from "@cedarjs/cli-helpers/packageManager/exec";
9
9
  import { getConfig } from "@cedarjs/project-config";
@@ -34,7 +34,7 @@ function getLocalVersion() {
34
34
  } catch {
35
35
  return void 0;
36
36
  }
37
- if (typeof version === "string" && semver.valid(version)) {
37
+ if (typeof version === "string" && isValid(version)) {
38
38
  return version;
39
39
  }
40
40
  return void 0;
@@ -106,7 +106,7 @@ function shouldShow() {
106
106
  const data = readUpdateDataFile();
107
107
  let newerVersion = false;
108
108
  data.remoteVersions.forEach((version) => {
109
- newerVersion ||= semver.gt(version, localVersion);
109
+ newerVersion ||= isGreaterThan(version, localVersion);
110
110
  });
111
111
  return data.shownAt < (/* @__PURE__ */ new Date()).getTime() - SHOW_PERIOD && newerVersion;
112
112
  }
@@ -120,7 +120,7 @@ function getUpdateMessage() {
120
120
  let updateCount = 0;
121
121
  let message = ` New updates to Cedar are available via \`${formatCedarCommand(["upgrade#REPLACEME#"])}\` `;
122
122
  data.remoteVersions.forEach((version, tag) => {
123
- if (semver.gt(version, data.localVersion)) {
123
+ if (isGreaterThan(version, data.localVersion)) {
124
124
  updateCount += 1;
125
125
  if (tag === localTag) {
126
126
  message += `
@@ -1,16 +1,16 @@
1
- import semver from "semver";
2
- import { colors as c } from "@cedarjs/cli-helpers";
1
+ import { clean, isGreaterThanOrEqual } from "verkit";
2
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
3
3
  function checkNodeVersion() {
4
4
  const checks = { ok: true };
5
5
  const pVersion = process.version;
6
- const pVersionC = semver.clean(pVersion);
6
+ const pVersionC = clean(pVersion);
7
7
  const LOWER_BOUND = "v24.0.0";
8
8
  if (!pVersionC) {
9
9
  checks.ok = false;
10
10
  checks.message = `Invalid Node.js version: ${pVersion}`;
11
11
  return checks;
12
12
  }
13
- if (semver.gte(pVersionC, LOWER_BOUND)) {
13
+ if (isGreaterThanOrEqual(pVersionC, LOWER_BOUND)) {
14
14
  return checks;
15
15
  }
16
16
  checks.ok = false;