@cedarjs/cli 7.0.0-canary.3260 → 7.0.0-rc.123
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.
- package/dist/commands/build/buildHandler.js +1 -2
- package/dist/commands/build.js +1 -1
- package/dist/commands/check.js +1 -2
- package/dist/commands/deploy/baremetal/baremetalHandler.js +1 -1
- package/dist/commands/deploy/baremetal.js +1 -1
- package/dist/commands/deploy/flightcontrolHandler.js +1 -1
- package/dist/commands/deploy/helpers/deployHandler.js +1 -1
- package/dist/commands/deploy/netlify.js +1 -1
- package/dist/commands/deploy/renderHandler.js +1 -1
- package/dist/commands/deploy/serverlessHandler.js +1 -2
- package/dist/commands/deploy/vercel.js +1 -1
- package/dist/commands/destroy/handlerHelpers.js +1 -1
- package/dist/commands/destroy/page/pageHandler.js +1 -2
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +1 -2
- package/dist/commands/destroy/sdl/sdlHandler.js +1 -2
- package/dist/commands/dev/devHandler.js +4 -3
- package/dist/commands/dev/packageWatchCommands.js +3 -8
- package/dist/commands/dev.js +1 -1
- package/dist/commands/execHandler.js +1 -2
- package/dist/commands/experimental/live-queries/liveQueries.js +1 -1
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +3 -3
- package/dist/commands/experimental/setupInngest.js +1 -1
- package/dist/commands/experimental/setupInngestHandler.js +1 -1
- package/dist/commands/experimental/setupOpentelemetry.js +1 -1
- package/dist/commands/experimental/setupOpentelemetryHandler.js +1 -2
- package/dist/commands/experimental/setupReactCompiler.js +1 -1
- package/dist/commands/experimental/setupReactCompilerHandler.js +4 -4
- package/dist/commands/experimental/setupRsc.js +1 -1
- package/dist/commands/experimental/setupRscHandler.js +1 -2
- package/dist/commands/experimental/setupStreamingSsr.js +1 -1
- package/dist/commands/experimental/setupStreamingSsrHandler.js +2 -3
- package/dist/commands/generate/cell/cell.js +0 -20
- package/dist/commands/generate/cell/cellHandler.js +20 -68
- package/dist/commands/generate/cell/templates/cell.tsx.template +2 -21
- package/dist/commands/generate/cell/templates/cellList.tsx.template +2 -21
- package/dist/commands/generate/cell/templates/test.js.template +1 -1
- package/dist/commands/generate/dataMigration/dataMigration.js +1 -2
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +3 -23
- package/dist/commands/generate/directive/directiveHandler.js +1 -2
- package/dist/commands/generate/function/functionHandler.js +1 -2
- package/dist/commands/generate/job/jobHandler.js +1 -2
- package/dist/commands/generate/model/modelHandler.js +1 -2
- package/dist/commands/generate/ogImage/ogImageHandler.js +1 -2
- package/dist/commands/generate/package/filesTask.js +12 -9
- package/dist/commands/generate/package/packageHandler.js +4 -3
- package/dist/commands/generate/page/pageHandler.js +1 -2
- package/dist/commands/generate/realtime/realtime.js +1 -1
- package/dist/commands/generate/realtime/realtimeHandler.js +9 -2
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +1 -1
- package/dist/commands/generate/scaffold/scaffoldHandler.js +5 -10
- package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +3 -3
- package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +0 -11
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +1 -13
- package/dist/commands/generate/script/scriptHandler.js +1 -2
- package/dist/commands/generate/sdl/sdlHandler.js +1 -2
- package/dist/commands/generate/secret/secret.js +1 -1
- package/dist/commands/generate/service/serviceHandler.js +38 -47
- package/dist/commands/generate/service/templates/service.ts.template +8 -22
- package/dist/commands/generate/service/templates/test.ts.template +1 -1
- package/dist/commands/generate/yargsCommandHelpers.js +1 -1
- package/dist/commands/generate/yargsHandlerHelpers.js +1 -2
- package/dist/commands/generate.js +1 -1
- package/dist/commands/info.js +1 -1
- package/dist/commands/lint.js +1 -1
- package/dist/commands/prerenderHandler.js +4 -11
- package/dist/commands/prismaHandler.js +2 -7
- package/dist/commands/record/init.js +1 -1
- package/dist/commands/serve.js +1 -2
- package/dist/commands/setup/auth/auth.js +4 -2
- package/dist/commands/setup/cache/cache.js +1 -1
- package/dist/commands/setup/cache/cacheHandler.js +1 -2
- package/dist/commands/setup/database/postgres.js +1 -1
- package/dist/commands/setup/database/postgresHandler.js +1 -3
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/coherence.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +6 -7
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/renderHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +6 -4
- package/dist/commands/setup/deploy/providers/vercelHandler.js +1 -2
- package/dist/commands/setup/docker/docker.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +1 -2
- package/dist/commands/setup/generator/generator.js +1 -1
- package/dist/commands/setup/generator/generatorHandler.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +5 -3
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +1 -2
- package/dist/commands/setup/i18n/i18n.js +1 -1
- package/dist/commands/setup/i18n/i18nHandler.js +1 -1
- package/dist/commands/setup/jobs/jobs.js +1 -1
- package/dist/commands/setup/jobs/jobsHandler.js +1 -2
- package/dist/commands/setup/mailer/mailer.js +1 -1
- package/dist/commands/setup/mailer/mailerHandler.js +1 -2
- package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
- package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +1 -2
- package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
- package/dist/commands/setup/monitoring/sentry/sentryHandler.js +7 -8
- package/dist/commands/setup/neon/neon.js +1 -1
- package/dist/commands/setup/neon/neonHandler.js +9 -5
- package/dist/commands/setup/package/package.js +1 -1
- package/dist/commands/setup/package/packageHandler.js +4 -4
- package/dist/commands/setup/realtime/addRealtimeToGraphql.js +1 -1
- package/dist/commands/setup/realtime/realtime.js +1 -1
- package/dist/commands/setup/realtime/realtimeHandler.js +16 -4
- package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +1 -1
- package/dist/commands/setup/server-file/serverFile.js +1 -1
- package/dist/commands/setup/server-file/serverFileHandler.js +1 -2
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +1 -2
- package/dist/commands/setup/ui/libraries/mantineHandler.js +1 -2
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +1 -2
- package/dist/commands/setup/uploads/dbCodemod.js +28 -0
- package/dist/commands/setup/uploads/templates/signedUrl.ts.template +21 -0
- package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +24 -23
- package/dist/commands/setup/uploads/uploads.js +7 -49
- package/dist/commands/setup/uploads/uploadsHandler.js +69 -256
- package/dist/commands/setup.js +1 -2
- package/dist/commands/studio.js +1 -1
- package/dist/commands/test/testHandler.js +71 -25
- package/dist/commands/test/testHandlerEsm.js +100 -0
- package/dist/commands/test.js +18 -10
- package/dist/commands/testEsm.js +41 -0
- package/dist/commands/type-checkHandler.js +1 -1
- package/dist/commands/upgrade/preUpgradeScripts.js +3 -3
- package/dist/commands/upgrade/upgrade.js +1 -1
- package/dist/commands/upgrade/upgradeHandler.js +1 -2
- package/dist/index.js +8 -5
- package/dist/lib/exit.js +1 -1
- package/dist/lib/index.js +25 -6
- package/dist/lib/loadEnvFiles.js +1 -1
- package/dist/lib/plugin.js +1 -1
- package/dist/lib/test.js +1 -1
- package/dist/lib/updateCheck.js +4 -4
- package/dist/middleware/checkNodeVersion.js +4 -4
- package/package.json +18 -18
- package/dist/commands/generate/cell/templates/cellFragment.tsx.template +0 -43
- package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +0 -23
- package/dist/commands/generate/cell/templates/testFragment.js.template +0 -30
- package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +0 -164
- package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +0 -147
- package/dist/commands/setup/tenancy/authCodemod.js +0 -66
- package/dist/commands/setup/tenancy/dbCodemod.js +0 -64
- package/dist/commands/setup/tenancy/graphqlCodemod.js +0 -88
- package/dist/commands/setup/tenancy/preflight.js +0 -49
- package/dist/commands/setup/tenancy/schemaPrisma.js +0 -81
- package/dist/commands/setup/tenancy/signupCodemod.js +0 -153
- package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +0 -63
- package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +0 -40
- package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +0 -39
- package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +0 -59
- package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +0 -89
- package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +0 -389
- package/dist/commands/setup/tenancy/templates/organizations.ts.template +0 -394
- package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +0 -35
- package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +0 -25
- package/dist/commands/setup/tenancy/tenancy.js +0 -30
- package/dist/commands/setup/tenancy/tenancyHandler.js +0 -425
- package/dist/commands/setup/uploads/schemaPrisma.js +0 -41
- package/dist/commands/setup/uploads/serverFile.js +0 -151
- package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +0 -15
- package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +0 -79
- package/dist/commands/setup/uploads/templates/uploads.ts.template +0 -89
- package/dist/commands/setup/uploads/templates/withDataUri.ts.template +0 -14
- package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +0 -16
- package/dist/commands/test/viteVersionCheck.js +0 -75
|
@@ -1,11 +1,13 @@
|
|
|
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";
|
|
1
5
|
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
3
6
|
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
4
7
|
import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
|
5
8
|
import { getPaths } from "../../lib/index.js";
|
|
6
9
|
import * as project from "../../lib/project.js";
|
|
7
10
|
import { warnIfNonStandardDatasourceUrl } from "./datasourceWarning.js";
|
|
8
|
-
import { assertSingleViteVersion } from "./viteVersionCheck.js";
|
|
9
11
|
function hasStringMessage(value) {
|
|
10
12
|
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
11
13
|
}
|
|
@@ -15,29 +17,73 @@ function getExitCode(value) {
|
|
|
15
17
|
}
|
|
16
18
|
return value.exitCode;
|
|
17
19
|
}
|
|
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
|
+
}
|
|
18
58
|
const handler = async ({
|
|
19
59
|
filter: filterParams = [],
|
|
60
|
+
watch = true,
|
|
61
|
+
collectCoverage = false,
|
|
20
62
|
dbPush = true,
|
|
21
63
|
force = false,
|
|
22
64
|
...others
|
|
23
65
|
}) => {
|
|
24
66
|
recordTelemetryAttributes({
|
|
25
67
|
command: "test",
|
|
68
|
+
watch,
|
|
69
|
+
collectCoverage,
|
|
26
70
|
dbPush
|
|
27
71
|
});
|
|
28
|
-
let watch = true;
|
|
29
72
|
const rwjsPaths = getPaths();
|
|
30
|
-
const
|
|
31
|
-
if ([
|
|
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)) {
|
|
32
83
|
return [];
|
|
33
84
|
}
|
|
34
85
|
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
35
86
|
const flagValue = others[flagName];
|
|
36
|
-
if (flagName === "watch") {
|
|
37
|
-
watch = flagValue === true;
|
|
38
|
-
} else if (flagName === "run" && flagValue) {
|
|
39
|
-
watch = false;
|
|
40
|
-
}
|
|
41
87
|
if (Array.isArray(flagValue)) {
|
|
42
88
|
return flagValue.flatMap((val) => [flag, val]);
|
|
43
89
|
}
|
|
@@ -46,25 +92,28 @@ const handler = async ({
|
|
|
46
92
|
const sides = filterParams.filter(
|
|
47
93
|
(filterString) => project.workspaces().includes(filterString)
|
|
48
94
|
);
|
|
49
|
-
const
|
|
95
|
+
const jestFilterArgs = [
|
|
50
96
|
...filterParams.filter(
|
|
51
97
|
(filterString) => !project.workspaces().includes(filterString)
|
|
52
98
|
)
|
|
53
99
|
];
|
|
54
|
-
const
|
|
55
|
-
...
|
|
56
|
-
...
|
|
100
|
+
const jestArgs = [
|
|
101
|
+
...jestFilterArgs,
|
|
102
|
+
...forwardJestFlags,
|
|
103
|
+
collectCoverage ? "--collectCoverage" : null,
|
|
57
104
|
"--passWithNoTests"
|
|
58
105
|
].filter((flagOrValue) => flagOrValue !== null);
|
|
59
|
-
if (process.env.CI) {
|
|
60
|
-
|
|
106
|
+
if (watch && !process.env.CI && !collectCoverage) {
|
|
107
|
+
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
|
|
108
|
+
jestArgs.push(hasSourceControl ? "--watch" : "--watchAll");
|
|
61
109
|
}
|
|
62
|
-
if (!
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
110
|
+
if (!sides.length) {
|
|
111
|
+
project.workspaces().forEach((side) => sides.push(side));
|
|
112
|
+
}
|
|
113
|
+
if (sides.length > 0) {
|
|
114
|
+
jestArgs.push("--projects", ...sides);
|
|
67
115
|
}
|
|
116
|
+
isJestConfigFile(sides);
|
|
68
117
|
try {
|
|
69
118
|
const cacheDirDb = `file:${ensurePosixPath(
|
|
70
119
|
rwjsPaths.generated.base
|
|
@@ -77,11 +126,8 @@ const handler = async ({
|
|
|
77
126
|
if (sides.includes("api")) {
|
|
78
127
|
await warnIfNonStandardDatasourceUrl({ force });
|
|
79
128
|
}
|
|
80
|
-
if (sides.includes("web")) {
|
|
81
|
-
assertSingleViteVersion();
|
|
82
|
-
}
|
|
83
129
|
const runCommand = async () => {
|
|
84
|
-
await runBin("
|
|
130
|
+
await runBin("jest", jestArgs, {
|
|
85
131
|
cwd: rwjsPaths.base,
|
|
86
132
|
stdio: "inherit",
|
|
87
133
|
env: {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
3
|
+
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
4
|
+
import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
|
5
|
+
import { getPaths } from "../../lib/index.js";
|
|
6
|
+
import * as project from "../../lib/project.js";
|
|
7
|
+
import { warnIfNonStandardDatasourceUrl } from "./datasourceWarning.js";
|
|
8
|
+
function hasStringMessage(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
10
|
+
}
|
|
11
|
+
function getExitCode(value) {
|
|
12
|
+
if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
return value.exitCode;
|
|
16
|
+
}
|
|
17
|
+
const handler = async ({
|
|
18
|
+
filter: filterParams = [],
|
|
19
|
+
dbPush = true,
|
|
20
|
+
force = false,
|
|
21
|
+
...others
|
|
22
|
+
}) => {
|
|
23
|
+
recordTelemetryAttributes({
|
|
24
|
+
command: "test",
|
|
25
|
+
dbPush
|
|
26
|
+
});
|
|
27
|
+
let watch = true;
|
|
28
|
+
const rwjsPaths = getPaths();
|
|
29
|
+
const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
|
|
30
|
+
if (["db-push", "force", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
34
|
+
const flagValue = others[flagName];
|
|
35
|
+
if (flagName === "watch") {
|
|
36
|
+
watch = flagValue === true;
|
|
37
|
+
} else if (flagName === "run" && flagValue) {
|
|
38
|
+
watch = false;
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(flagValue)) {
|
|
41
|
+
return flagValue.flatMap((val) => [flag, val]);
|
|
42
|
+
}
|
|
43
|
+
return [flag, flagValue];
|
|
44
|
+
});
|
|
45
|
+
const sides = filterParams.filter(
|
|
46
|
+
(filterString) => project.workspaces().includes(filterString)
|
|
47
|
+
);
|
|
48
|
+
const vitestFilterArgs = [
|
|
49
|
+
...filterParams.filter(
|
|
50
|
+
(filterString) => !project.workspaces().includes(filterString)
|
|
51
|
+
)
|
|
52
|
+
];
|
|
53
|
+
const vitestArgs = [
|
|
54
|
+
...vitestFilterArgs,
|
|
55
|
+
...forwardVitestFlags,
|
|
56
|
+
"--passWithNoTests"
|
|
57
|
+
].filter((flagOrValue) => flagOrValue !== null);
|
|
58
|
+
if (process.env.CI) {
|
|
59
|
+
vitestArgs.push("--run");
|
|
60
|
+
}
|
|
61
|
+
if (!others["config"]) {
|
|
62
|
+
sides.forEach((side) => vitestArgs.push("--project", side));
|
|
63
|
+
if (!sides.length) {
|
|
64
|
+
project.workspaces().forEach((side) => sides.push(side));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const cacheDirDb = `file:${ensurePosixPath(
|
|
69
|
+
rwjsPaths.generated.base
|
|
70
|
+
)}/test.db`;
|
|
71
|
+
const DATABASE_URL = process.env.TEST_DATABASE_URL || cacheDirDb;
|
|
72
|
+
if (sides.includes("api") && !dbPush) {
|
|
73
|
+
process.env.SKIP_DB_PUSH = "1";
|
|
74
|
+
}
|
|
75
|
+
if (sides.includes("api")) {
|
|
76
|
+
await warnIfNonStandardDatasourceUrl({ force });
|
|
77
|
+
}
|
|
78
|
+
const runCommand = async () => {
|
|
79
|
+
await runBin("vitest", vitestArgs, {
|
|
80
|
+
cwd: rwjsPaths.base,
|
|
81
|
+
stdio: "inherit",
|
|
82
|
+
env: { ...process.env, DATABASE_URL }
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
if (watch) {
|
|
86
|
+
await runCommand();
|
|
87
|
+
} else {
|
|
88
|
+
await timedTelemetry(process.argv, { type: "test" }, async () => {
|
|
89
|
+
await runCommand();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
const message = hasStringMessage(error) ? error.message : "Test command failed";
|
|
94
|
+
errorTelemetry(process.argv, message);
|
|
95
|
+
process.exit(getExitCode(error) ?? 1);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
handler
|
|
100
|
+
};
|
package/dist/commands/test.js
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
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";
|
|
3
3
|
import { workspaces } from "../lib/project.js";
|
|
4
4
|
const command = "test [filter..]";
|
|
5
|
-
const description = "Run
|
|
5
|
+
const description = "Run Jest 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");
|
|
12
7
|
yargs.strict(false).positional("filter", {
|
|
13
8
|
default: workspaces(),
|
|
14
9
|
description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
|
|
15
10
|
type: "string",
|
|
16
11
|
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
|
|
17
20
|
}).option("db-push", {
|
|
18
21
|
describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
|
|
19
22
|
type: "boolean",
|
|
20
23
|
default: true
|
|
21
24
|
}).option("force", {
|
|
22
|
-
describe: "
|
|
25
|
+
describe: "Run tests without prompting for confirmation, even when a non-standard datasource url env var is detected.",
|
|
23
26
|
type: "boolean",
|
|
24
27
|
default: false
|
|
25
28
|
}).epilogue(
|
|
26
|
-
`For all available flags, run
|
|
29
|
+
`For all available flags, run jest cli directly ${c.tip(
|
|
30
|
+
"yarn jest --help"
|
|
31
|
+
)}
|
|
27
32
|
|
|
28
|
-
Also see the ${
|
|
33
|
+
Also see the ${terminalLink(
|
|
34
|
+
"CedarJS CLI Reference",
|
|
35
|
+
"https://cedarjs.com/docs/cli-commands#test"
|
|
36
|
+
)}
|
|
29
37
|
`
|
|
30
38
|
);
|
|
31
39
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { terminalLink } from "termi-link";
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers";
|
|
3
|
+
import { workspaces } from "../lib/project.js";
|
|
4
|
+
const command = "test [filter..]";
|
|
5
|
+
const description = "Run Vitest tests. Defaults to watch mode";
|
|
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");
|
|
12
|
+
yargs.strict(false).positional("filter", {
|
|
13
|
+
default: workspaces(),
|
|
14
|
+
description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
|
|
15
|
+
type: "string",
|
|
16
|
+
array: true
|
|
17
|
+
}).option("db-push", {
|
|
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.",
|
|
19
|
+
type: "boolean",
|
|
20
|
+
default: true
|
|
21
|
+
}).option("force", {
|
|
22
|
+
describe: "Skip any confirmation prompts and run tests without interruption. Useful in CI or scripted environments.",
|
|
23
|
+
type: "boolean",
|
|
24
|
+
default: false
|
|
25
|
+
}).epilogue(
|
|
26
|
+
`For all available flags, run vitest cli directly ${vitestTip}
|
|
27
|
+
|
|
28
|
+
Also see the ${cliDocsLink}
|
|
29
|
+
`
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
const handler = async (options) => {
|
|
33
|
+
const { handler: handler2 } = await import("./test/testHandlerEsm.js");
|
|
34
|
+
return handler2(options);
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
builder,
|
|
38
|
+
command,
|
|
39
|
+
description,
|
|
40
|
+
handler
|
|
41
|
+
};
|
|
@@ -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";
|
|
4
5
|
import { formatRunBinCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
5
6
|
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
|
|
6
|
+
import semver from "semver";
|
|
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 =
|
|
16
|
+
const parsed = semver.parse(version);
|
|
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
|
|
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";
|
|
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 { colors as c } from "@cedarjs/cli-helpers
|
|
8
|
+
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
9
9
|
import {
|
|
10
10
|
dedupe,
|
|
11
11
|
dedupeIsSupported,
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
installationErrorMessage,
|
|
14
14
|
prettyPrintCedarCommand
|
|
15
15
|
} from "@cedarjs/cli-helpers/packageManager";
|
|
16
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
17
16
|
import { getConfig } from "@cedarjs/project-config";
|
|
18
17
|
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
19
18
|
import { generatePrismaClient } from "../../lib/generatePrismaClient.js";
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,12 @@ 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {
|
|
8
|
+
loadEnvFiles,
|
|
9
|
+
recordTelemetryAttributes,
|
|
10
|
+
colors as c
|
|
11
|
+
} from "@cedarjs/cli-helpers";
|
|
12
|
+
import { findUp, projectIsEsm, getConfigPath } from "@cedarjs/project-config";
|
|
11
13
|
import { telemetryMiddleware } from "@cedarjs/telemetry";
|
|
12
14
|
import * as buildCommand from "./commands/build.js";
|
|
13
15
|
import * as checkCommand from "./commands/check.js";
|
|
@@ -28,6 +30,7 @@ import * as serveCommand from "./commands/serve.js";
|
|
|
28
30
|
import * as setupCommand from "./commands/setup.js";
|
|
29
31
|
import * as studioCommand from "./commands/studio.js";
|
|
30
32
|
import * as testCommand from "./commands/test.js";
|
|
33
|
+
import * as testCommandEsm from "./commands/testEsm.js";
|
|
31
34
|
import * as typeCheckCommand from "./commands/type-check.js";
|
|
32
35
|
import * as upgradeCommand from "./commands/upgrade/upgrade.js";
|
|
33
36
|
import { exitWithError } from "./lib/exit.js";
|
|
@@ -131,7 +134,7 @@ async function runYargs() {
|
|
|
131
134
|
}).example(
|
|
132
135
|
"yarn cedar g page home /",
|
|
133
136
|
"Create a page component named 'Home' at path '/'"
|
|
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);
|
|
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);
|
|
135
138
|
await loadPlugins(yarg);
|
|
136
139
|
const pkgJson = await import("../package.json", { with: { type: "json" } });
|
|
137
140
|
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";
|
|
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,6 +1,7 @@
|
|
|
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";
|
|
4
5
|
import boxen from "boxen";
|
|
5
6
|
import camelcase from "camelcase";
|
|
6
7
|
import { paramCase } from "change-case";
|
|
@@ -11,12 +12,11 @@ import memoize from "lodash/memoize.js";
|
|
|
11
12
|
import template from "lodash/template.js";
|
|
12
13
|
import pascalcase from "pascalcase";
|
|
13
14
|
import { format } from "prettier";
|
|
14
|
-
import { colors as c } from "@cedarjs/cli-helpers
|
|
15
|
+
import { colors as c } from "@cedarjs/cli-helpers";
|
|
15
16
|
import {
|
|
16
17
|
addRootPackages,
|
|
17
18
|
addWorkspacePackages
|
|
18
19
|
} 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,10 +206,29 @@ const getPrettierOptions = async () => {
|
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
const transformTSToJS = async (filename, content) => {
|
|
209
|
-
|
|
210
|
-
filename
|
|
211
|
-
|
|
212
|
-
|
|
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);
|
|
213
232
|
};
|
|
214
233
|
const transformTSToJSMap = async (files, typescript) => {
|
|
215
234
|
return files.reduce(
|
package/dist/lib/loadEnvFiles.js
CHANGED
package/dist/lib/plugin.js
CHANGED
|
@@ -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";
|
|
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
|
|
83
|
+
vi.mock("@cedarjs/cli-helpers", async (importOriginal) => {
|
|
84
84
|
const originalCliHelpers = await importOriginal();
|
|
85
85
|
return {
|
|
86
86
|
...originalCliHelpers,
|
package/dist/lib/updateCheck.js
CHANGED
|
@@ -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
|
|
6
|
+
import semver from "semver";
|
|
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" &&
|
|
37
|
+
if (typeof version === "string" && semver.valid(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 ||=
|
|
109
|
+
newerVersion ||= semver.gt(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 (
|
|
123
|
+
if (semver.gt(version, data.localVersion)) {
|
|
124
124
|
updateCount += 1;
|
|
125
125
|
if (tag === localTag) {
|
|
126
126
|
message += `
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { colors as c } from "@cedarjs/cli-helpers
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers";
|
|
3
3
|
function checkNodeVersion() {
|
|
4
4
|
const checks = { ok: true };
|
|
5
5
|
const pVersion = process.version;
|
|
6
|
-
const pVersionC = clean(pVersion);
|
|
6
|
+
const pVersionC = semver.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 (
|
|
13
|
+
if (semver.gte(pVersionC, LOWER_BOUND)) {
|
|
14
14
|
return checks;
|
|
15
15
|
}
|
|
16
16
|
checks.ok = false;
|