@cedarjs/cli 9.0.0-canary.1784 → 9.0.0-canary.3124
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/README.md +7 -10
- package/dist/cfw.js +10 -6
- package/dist/commands/build/buildHandler.js +220 -45
- package/dist/commands/build/buildPackagesTask.js +21 -20
- package/dist/commands/build.js +13 -2
- package/dist/commands/check.js +4 -6
- package/dist/commands/console.js +6 -4
- package/dist/commands/deploy/baremetal/SshExecutor.js +13 -4
- package/dist/commands/deploy/baremetal/baremetalHandler.js +116 -50
- package/dist/commands/deploy/baremetal.js +11 -4
- package/dist/commands/deploy/flightcontrolHandler.js +28 -15
- package/dist/commands/deploy/helpers/deployHandler.js +11 -6
- package/dist/commands/deploy/netlify.js +1 -1
- package/dist/commands/deploy/packing/nft.js +1 -2
- package/dist/commands/deploy/render.js +1 -1
- package/dist/commands/deploy/renderHandler.js +24 -13
- package/dist/commands/deploy/serverlessHandler.js +69 -27
- package/dist/commands/deploy/vercel.js +1 -1
- package/dist/commands/destroy/component/component.js +2 -3
- package/dist/commands/destroy/directive/directive.js +1 -3
- package/dist/commands/destroy/directive/directiveHandler.js +2 -4
- package/dist/commands/destroy/function/function.js +1 -3
- package/dist/commands/destroy/handlerHelpers.js +17 -17
- package/dist/commands/destroy/helpers.js +8 -2
- package/dist/commands/destroy/layout/layout.js +1 -2
- package/dist/commands/destroy/page/pageHandler.js +3 -3
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +31 -12
- package/dist/commands/destroy/sdl/sdlHandler.js +3 -3
- package/dist/commands/dev/apiDebugFlag.js +5 -4
- package/dist/commands/dev/devHandler.js +219 -68
- package/dist/commands/dev/packageWatchCommands.js +8 -3
- package/dist/commands/dev.js +16 -6
- package/dist/commands/execHandler.js +49 -29
- package/dist/commands/experimental/live-queries/liveQueries.js +32 -0
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +448 -0
- package/dist/commands/experimental/live-queries/templates/liveQueriesListener.ts.template +153 -0
- package/dist/commands/experimental/live-queries/templates/migration.sql.template +100 -0
- package/dist/commands/experimental/setupInngest.js +2 -2
- package/dist/commands/experimental/setupInngestHandler.js +13 -12
- package/dist/commands/experimental/setupOpentelemetry.js +2 -2
- package/dist/commands/experimental/setupOpentelemetryHandler.js +14 -10
- package/dist/commands/experimental/setupReactCompiler.js +2 -2
- package/dist/commands/experimental/setupReactCompilerHandler.js +48 -33
- package/dist/commands/experimental/setupRsc.js +1 -1
- package/dist/commands/experimental/setupRscHandler.js +20 -16
- package/dist/commands/experimental/setupStreamingSsr.js +2 -2
- package/dist/commands/experimental/setupStreamingSsrHandler.js +49 -34
- package/dist/commands/experimental/templates/opentelemetry.ts.template +2 -1
- package/dist/commands/experimental/templates/rsc/Document.tsx.template +1 -1
- package/dist/commands/experimental/templates/rsc/entry.client.tsx.template +8 -8
- package/dist/commands/experimental/templates/streamingSsr/Document.tsx.template +1 -1
- package/dist/commands/experimental/templates/streamingSsr/entry.client.tsx.template +6 -6
- package/dist/commands/experimental/templates/streamingSsr/tsconfig.json.template +6 -6
- package/dist/commands/experimental/util.js +27 -25
- package/dist/commands/experimental.js +3 -2
- package/dist/commands/generate/cell/cell.js +20 -0
- package/dist/commands/generate/cell/cellHandler.js +89 -40
- package/dist/commands/generate/cell/templates/cell.tsx.template +21 -2
- package/dist/commands/generate/cell/templates/cellFragment.tsx.template +43 -0
- package/dist/commands/generate/cell/templates/cellList.tsx.template +21 -2
- package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +23 -0
- package/dist/commands/generate/cell/templates/test.js.template +1 -1
- package/dist/commands/generate/cell/templates/testFragment.js.template +30 -0
- package/dist/commands/generate/component/componentHandler.js +14 -16
- package/dist/commands/generate/dataMigration/dataMigration.js +36 -18
- package/dist/commands/generate/dataMigration/templates/dataMigration.js.template +1 -1
- package/dist/commands/generate/dataMigration/templates/dataMigration.ts.template +1 -1
- package/dist/commands/generate/dbAuth/dbAuth.js +1 -0
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +63 -34
- package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +164 -0
- package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +147 -0
- package/dist/commands/generate/directive/directiveHandler.js +14 -16
- package/dist/commands/generate/function/function.js +1 -0
- package/dist/commands/generate/function/functionHandler.js +14 -19
- package/dist/commands/generate/helpers.js +34 -18
- package/dist/commands/generate/job/job.js +1 -0
- package/dist/commands/generate/job/jobHandler.js +20 -24
- package/dist/commands/generate/layout/layoutHandler.js +13 -16
- package/dist/commands/generate/model/model.js +1 -0
- package/dist/commands/generate/model/modelHandler.js +11 -5
- package/dist/commands/generate/ogImage/ogImage.js +1 -0
- package/dist/commands/generate/ogImage/ogImageHandler.js +18 -11
- package/dist/commands/generate/package/filesTask.js +9 -0
- package/dist/commands/generate/package/packageHandler.js +50 -61
- package/dist/commands/generate/package/templates/test.ts.template +2 -2
- package/dist/commands/generate/package/templates/vitest.config.ts.template +9 -0
- package/dist/commands/generate/page/pageHandler.js +27 -24
- package/dist/commands/generate/realtime/realtime.js +2 -2
- package/dist/commands/generate/realtime/realtimeHandler.js +51 -32
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +1 -1
- package/dist/commands/generate/scaffold/scaffold.js +1 -0
- package/dist/commands/generate/scaffold/scaffoldHandler.js +176 -49
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +1 -1
- package/dist/commands/generate/script/script.js +1 -0
- package/dist/commands/generate/script/scriptHandler.js +10 -6
- package/dist/commands/generate/script/templates/script.ts.template +9 -4
- package/dist/commands/generate/script/templates/tsconfig.json.template +16 -2
- package/dist/commands/generate/sdl/sdl.js +4 -3
- package/dist/commands/generate/sdl/sdlHandler.js +135 -46
- package/dist/commands/generate/sdl/stubFiles.js +132 -0
- package/dist/commands/generate/sdl/templates/sdl.js.template +2 -1
- package/dist/commands/generate/sdl/templates/sdl.ts.template +2 -1
- package/dist/commands/generate/secret/secret.js +20 -20
- package/dist/commands/generate/service/service.js +5 -5
- package/dist/commands/generate/service/serviceHandler.js +126 -61
- package/dist/commands/generate/service/templates/scenarios.ts.template +4 -2
- package/dist/commands/generate/service/templates/service.ts.template +22 -8
- package/dist/commands/generate/service/templates/test.ts.template +2 -2
- package/dist/commands/generate/yargsCommandHelpers.js +7 -2
- package/dist/commands/generate/yargsHandlerHelpers.js +20 -18
- package/dist/commands/generate.js +4 -4
- package/dist/commands/info.js +2 -2
- package/dist/commands/jobsHandler.js +7 -4
- package/dist/commands/lint.js +26 -69
- package/dist/commands/prerenderHandler.js +95 -58
- package/dist/commands/prismaHandler.js +51 -26
- package/dist/commands/record/init.js +2 -2
- package/dist/commands/record.js +4 -3
- package/dist/commands/serve.js +245 -31
- package/dist/commands/serveApiHandler.js +7 -6
- package/dist/commands/serveBothHandler.js +22 -13
- package/dist/commands/serveWebHandler.js +3 -2
- package/dist/commands/setup/auth/auth.js +15 -11
- package/dist/commands/setup/cache/cache.js +1 -1
- package/dist/commands/setup/cache/cacheHandler.js +15 -9
- package/dist/commands/setup/database/database.js +15 -0
- package/dist/commands/setup/database/postgres.js +19 -0
- package/dist/commands/setup/database/postgresHandler.js +196 -0
- package/dist/commands/setup/database/templates/db.ts.template +32 -0
- package/dist/commands/setup/deploy/deploy.js +4 -3
- package/dist/commands/setup/deploy/helpers/helpers.js +5 -1
- package/dist/commands/setup/deploy/helpers/index.js +132 -6
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +28 -6
- package/dist/commands/setup/deploy/providers/coherence.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +60 -31
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +69 -51
- package/dist/commands/setup/deploy/providers/netlify.js +6 -0
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +114 -13
- package/dist/commands/setup/deploy/providers/renderHandler.js +44 -41
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +7 -5
- package/dist/commands/setup/deploy/providers/universal-deploy.js +11 -0
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +186 -0
- package/dist/commands/setup/deploy/providers/vercel.js +6 -0
- package/dist/commands/setup/deploy/providers/vercelHandler.js +115 -14
- package/dist/commands/setup/deploy/templates/baremetal.js +3 -2
- package/dist/commands/setup/deploy/templates/flightcontrol.js +60 -49
- package/dist/commands/setup/deploy/templates/netlify.js +2 -1
- package/dist/commands/setup/deploy/templates/netlifyUD.js +31 -0
- package/dist/commands/setup/deploy/templates/render.js +32 -17
- package/dist/commands/setup/docker/docker.js +2 -2
- package/dist/commands/setup/docker/dockerHandler.js +74 -39
- package/dist/commands/setup/docker/templates/Dockerfile.npm +119 -0
- package/dist/commands/setup/docker/templates/Dockerfile.pnpm +112 -0
- package/dist/commands/setup/docker/templates/{Dockerfile → Dockerfile.yarn} +4 -7
- package/dist/commands/setup/docker/templates/docker-compose.dev.yml +3 -3
- package/dist/commands/setup/docker/templates/docker-compose.prod.yml +2 -5
- package/dist/commands/setup/docker/templates/dockerignore +1 -0
- package/dist/commands/setup/generator/generator.js +1 -1
- package/dist/commands/setup/generator/generatorHandler.js +5 -4
- package/dist/commands/setup/graphql/features/fragments/appGqlConfigTransform.js +6 -3
- package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +5 -7
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +4 -3
- package/dist/commands/setup/i18n/i18n.js +1 -1
- package/dist/commands/setup/i18n/i18nHandler.js +21 -17
- package/dist/commands/setup/jobs/jobs.js +1 -1
- package/dist/commands/setup/jobs/jobsHandler.js +17 -12
- package/dist/commands/setup/mailer/mailer.js +1 -1
- package/dist/commands/setup/mailer/mailerHandler.js +13 -11
- package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
- package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +2 -1
- package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
- package/dist/commands/setup/monitoring/sentry/sentryHandler.js +18 -12
- package/dist/commands/setup/neon/neon.js +35 -0
- package/dist/commands/setup/neon/neonHandler.js +264 -0
- package/dist/commands/setup/package/package.js +1 -1
- package/dist/commands/setup/package/packageHandler.js +18 -14
- 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 +26 -37
- package/dist/commands/setup/realtime/templates/realtime.ts.template +1 -1
- 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 +18 -10
- package/dist/commands/setup/tenancy/authCodemod.js +66 -0
- package/dist/commands/setup/tenancy/dbCodemod.js +64 -0
- package/dist/commands/setup/tenancy/graphqlCodemod.js +88 -0
- package/dist/commands/setup/tenancy/preflight.js +49 -0
- package/dist/commands/setup/tenancy/schemaPrisma.js +81 -0
- package/dist/commands/setup/tenancy/signupCodemod.js +153 -0
- package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +63 -0
- package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +40 -0
- package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +39 -0
- package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +59 -0
- package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +89 -0
- package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +389 -0
- package/dist/commands/setup/tenancy/templates/organizations.ts.template +394 -0
- package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +35 -0
- package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +25 -0
- package/dist/commands/setup/tenancy/tenancy.js +30 -0
- package/dist/commands/setup/tenancy/tenancyHandler.js +425 -0
- package/dist/commands/setup/ui/helpers/helpers.js +5 -1
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +16 -8
- package/dist/commands/setup/ui/libraries/mantineHandler.js +26 -16
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +40 -29
- package/dist/commands/setup/uploads/schemaPrisma.js +41 -0
- package/dist/commands/setup/uploads/serverFile.js +151 -0
- package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +15 -0
- package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +23 -24
- package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +79 -0
- package/dist/commands/setup/uploads/templates/uploads.ts.template +89 -0
- package/dist/commands/setup/uploads/templates/withDataUri.ts.template +14 -0
- package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +16 -0
- package/dist/commands/setup/uploads/uploads.js +49 -7
- package/dist/commands/setup/uploads/uploadsHandler.js +266 -72
- package/dist/commands/setup.js +5 -4
- package/dist/commands/studio.js +1 -1
- package/dist/commands/studioHandler.js +2 -2
- package/dist/commands/test/datasourceWarning.js +42 -0
- package/dist/commands/test/testHandler.js +104 -0
- package/dist/commands/test/viteVersionCheck.js +75 -0
- package/dist/commands/test.js +16 -19
- package/dist/commands/type-check.js +2 -1
- package/dist/commands/type-checkHandler.js +25 -18
- package/dist/commands/upgrade/preUpgradeScripts.js +11 -11
- package/dist/commands/upgrade/upgrade.js +4 -2
- package/dist/commands/upgrade/upgradeHandler.js +97 -73
- package/dist/index.js +15 -11
- package/dist/lib/background.js +22 -1
- package/dist/lib/configureStorybook.js +2 -2
- package/dist/lib/exec.js +68 -63
- package/dist/lib/exit.js +20 -5
- package/dist/lib/extendFile.js +23 -13
- package/dist/lib/generatePrismaClient.js +48 -12
- package/dist/lib/index.js +137 -106
- package/dist/lib/loadEnvFiles.js +1 -1
- package/dist/lib/locking.js +8 -4
- package/dist/lib/merge/algorithms.js +4 -1
- package/dist/lib/merge/index.js +78 -41
- package/dist/lib/merge/semanticIdentity.js +18 -6
- package/dist/lib/merge/strategy.js +86 -36
- package/dist/lib/packages.js +23 -13
- package/dist/lib/plugin.js +13 -7
- package/dist/lib/pluralHelpers.js +6 -2
- package/dist/lib/project.js +3 -1
- package/dist/lib/rollback.js +7 -7
- package/dist/lib/schemaHelpers.js +16 -19
- package/dist/lib/test.js +20 -5
- package/dist/lib/updateCheck.js +47 -18
- package/dist/middleware/checkNodeVersion.js +9 -4
- package/dist/middleware/{detectProjectRxVersion.js → detectProjectCedarVersion.js} +2 -2
- package/dist/plugin.js +18 -12
- package/dist/telemetry/exporter.js +12 -5
- package/dist/telemetry/index.js +4 -3
- package/dist/telemetry/resource.js +9 -12
- package/dist/telemetry/send.js +14 -10
- package/dist/testLib/cells.js +5 -3
- package/package.json +44 -41
- package/LICENSE +0 -21
- package/dist/commands/consoleHandler.js +0 -68
- package/dist/commands/setup/tsconfig/tsconfig.js +0 -25
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +0 -59
- package/dist/commands/setup/uploads/dbCodemod.js +0 -28
- package/dist/commands/setup/uploads/templates/signedUrl.ts.template +0 -21
- package/dist/commands/setup/vite/templates/vite.config.ts.template +0 -19
- package/dist/commands/setup/vite/vite.js +0 -38
- package/dist/commands/setup/vite/viteHandler.js +0 -83
- package/dist/commands/testEsm.js +0 -36
- package/dist/commands/testHandler.js +0 -137
- package/dist/commands/testHandlerEsm.js +0 -85
- package/dist/commands/ts-to-js.js +0 -20
- package/dist/lib/cedarPluralize.js +0 -56
- package/dist/lib/colors.js +0 -18
- package/dist/testLib/getFilesWithPattern.js +0 -21
- /package/dist/{index.d.js → global.d.js} +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
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
|
+
import { assertSingleViteVersion } from "./viteVersionCheck.js";
|
|
9
|
+
function hasStringMessage(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
11
|
+
}
|
|
12
|
+
function getExitCode(value) {
|
|
13
|
+
if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
return value.exitCode;
|
|
17
|
+
}
|
|
18
|
+
const handler = async ({
|
|
19
|
+
filter: filterParams = [],
|
|
20
|
+
dbPush = true,
|
|
21
|
+
force = false,
|
|
22
|
+
...others
|
|
23
|
+
}) => {
|
|
24
|
+
recordTelemetryAttributes({
|
|
25
|
+
command: "test",
|
|
26
|
+
dbPush
|
|
27
|
+
});
|
|
28
|
+
let watch = true;
|
|
29
|
+
const rwjsPaths = getPaths();
|
|
30
|
+
const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
|
|
31
|
+
if (["db-push", "force", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
35
|
+
const flagValue = others[flagName];
|
|
36
|
+
if (flagName === "watch") {
|
|
37
|
+
watch = flagValue === true;
|
|
38
|
+
} else if (flagName === "run" && flagValue) {
|
|
39
|
+
watch = false;
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(flagValue)) {
|
|
42
|
+
return flagValue.flatMap((val) => [flag, val]);
|
|
43
|
+
}
|
|
44
|
+
return [flag, flagValue];
|
|
45
|
+
});
|
|
46
|
+
const sides = filterParams.filter(
|
|
47
|
+
(filterString) => project.workspaces().includes(filterString)
|
|
48
|
+
);
|
|
49
|
+
const vitestFilterArgs = [
|
|
50
|
+
...filterParams.filter(
|
|
51
|
+
(filterString) => !project.workspaces().includes(filterString)
|
|
52
|
+
)
|
|
53
|
+
];
|
|
54
|
+
const vitestArgs = [
|
|
55
|
+
...vitestFilterArgs,
|
|
56
|
+
...forwardVitestFlags,
|
|
57
|
+
"--passWithNoTests"
|
|
58
|
+
].filter((flagOrValue) => flagOrValue !== null);
|
|
59
|
+
if (process.env.CI) {
|
|
60
|
+
vitestArgs.push("--run");
|
|
61
|
+
}
|
|
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
|
+
}
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const cacheDirDb = `file:${ensurePosixPath(
|
|
70
|
+
rwjsPaths.generated.base
|
|
71
|
+
)}/test.db`;
|
|
72
|
+
const DATABASE_URL = process.env.TEST_DATABASE_URL || cacheDirDb;
|
|
73
|
+
if (sides.includes("api") && !dbPush) {
|
|
74
|
+
process.env.SKIP_DB_PUSH = "1";
|
|
75
|
+
}
|
|
76
|
+
if (sides.includes("api")) {
|
|
77
|
+
await warnIfNonStandardDatasourceUrl({ force });
|
|
78
|
+
}
|
|
79
|
+
if (sides.includes("web")) {
|
|
80
|
+
assertSingleViteVersion();
|
|
81
|
+
}
|
|
82
|
+
const runCommand = async () => {
|
|
83
|
+
await runBin("vitest", vitestArgs, {
|
|
84
|
+
cwd: rwjsPaths.base,
|
|
85
|
+
stdio: "inherit",
|
|
86
|
+
env: { ...process.env, DATABASE_URL }
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
if (watch) {
|
|
90
|
+
await runCommand();
|
|
91
|
+
} else {
|
|
92
|
+
await timedTelemetry(process.argv, { type: "test" }, async () => {
|
|
93
|
+
await runCommand();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
const message = hasStringMessage(error) ? error.message : "Test command failed";
|
|
98
|
+
errorTelemetry(process.argv, message);
|
|
99
|
+
process.exit(getExitCode(error) ?? 1);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
handler
|
|
104
|
+
};
|
|
@@ -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
|
+
};
|
package/dist/commands/test.js
CHANGED
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import c from "
|
|
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
|
|
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
|
-
type: "
|
|
11
|
-
|
|
12
|
-
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",
|
|
13
|
-
type: "boolean",
|
|
14
|
-
default: true
|
|
15
|
-
}).option("collect-coverage", {
|
|
16
|
-
describe: "Show test coverage summary and output info to coverage directory",
|
|
17
|
-
type: "boolean",
|
|
18
|
-
default: false
|
|
15
|
+
type: "string",
|
|
16
|
+
array: true
|
|
19
17
|
}).option("db-push", {
|
|
20
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.",
|
|
21
19
|
type: "boolean",
|
|
22
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
|
|
23
25
|
}).epilogue(
|
|
24
|
-
`For all available flags, run
|
|
25
|
-
"yarn jest --help"
|
|
26
|
-
)}
|
|
26
|
+
`For all available flags, run vitest cli directly ${vitestTip}
|
|
27
27
|
|
|
28
|
-
Also see the ${
|
|
29
|
-
"CedarJS CLI Reference",
|
|
30
|
-
"https://cedarjs.com/docs/cli-commands#test"
|
|
31
|
-
)}
|
|
28
|
+
Also see the ${cliDocsLink}
|
|
32
29
|
`
|
|
33
30
|
);
|
|
34
31
|
};
|
|
35
32
|
const handler = async (options) => {
|
|
36
|
-
const { handler: handler2 } = await import("./testHandler.js");
|
|
33
|
+
const { handler: handler2 } = await import("./test/testHandler.js");
|
|
37
34
|
return handler2(options);
|
|
38
35
|
};
|
|
39
36
|
export {
|
|
@@ -7,7 +7,8 @@ const builder = (yargs) => {
|
|
|
7
7
|
yargs.strict(false).positional("sides", {
|
|
8
8
|
default: workspaces(),
|
|
9
9
|
description: "Which side(s) to run a typecheck on",
|
|
10
|
-
type: "
|
|
10
|
+
type: "string",
|
|
11
|
+
array: true
|
|
11
12
|
}).option("prisma", {
|
|
12
13
|
type: "boolean",
|
|
13
14
|
default: true,
|
|
@@ -1,25 +1,37 @@
|
|
|
1
|
-
import path from "path";
|
|
1
|
+
import path from "node:path";
|
|
2
2
|
import concurrently from "concurrently";
|
|
3
|
-
import execa from "execa";
|
|
4
3
|
import { Listr } from "listr2";
|
|
5
|
-
import {
|
|
4
|
+
import { formatRunBinCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
5
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
7
|
import { generatePrismaClient } from "../lib/generatePrismaClient.js";
|
|
7
8
|
import { getPaths } from "../lib/index.js";
|
|
8
|
-
const
|
|
9
|
+
const isConcurrentlyErrorArray = (value) => {
|
|
10
|
+
return Array.isArray(value);
|
|
11
|
+
};
|
|
12
|
+
const handler = async ({
|
|
13
|
+
sides,
|
|
14
|
+
verbose = false,
|
|
15
|
+
prisma = true,
|
|
16
|
+
generate = true
|
|
17
|
+
}) => {
|
|
18
|
+
const selectedSides = (Array.isArray(sides) ? sides : []).filter(
|
|
19
|
+
(side) => typeof side === "string"
|
|
20
|
+
);
|
|
9
21
|
recordTelemetryAttributes({
|
|
10
22
|
command: "type-check",
|
|
11
|
-
sides: JSON.stringify(
|
|
23
|
+
sides: JSON.stringify(selectedSides),
|
|
12
24
|
verbose,
|
|
13
25
|
prisma,
|
|
14
26
|
generate
|
|
15
27
|
});
|
|
16
28
|
const typeCheck = async () => {
|
|
17
29
|
let conclusiveExitCode = 0;
|
|
18
|
-
const tscForAllSides =
|
|
30
|
+
const tscForAllSides = selectedSides.map((side) => {
|
|
19
31
|
const projectDir = path.join(getPaths().base, side);
|
|
20
32
|
return {
|
|
21
33
|
cwd: projectDir,
|
|
22
|
-
command:
|
|
34
|
+
command: formatRunBinCommand("tsc", ["--noEmit", "--skipLibCheck"])
|
|
23
35
|
};
|
|
24
36
|
});
|
|
25
37
|
const { result } = concurrently(tscForAllSides, {
|
|
@@ -28,32 +40,27 @@ const handler = async ({ sides, verbose, prisma, generate }) => {
|
|
|
28
40
|
});
|
|
29
41
|
try {
|
|
30
42
|
await result;
|
|
31
|
-
} catch (
|
|
32
|
-
if (
|
|
33
|
-
const exitCodes =
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (isConcurrentlyErrorArray(error)) {
|
|
45
|
+
const exitCodes = error.map((entry) => entry.exitCode).filter((exitCode2) => Boolean(exitCode2));
|
|
34
46
|
conclusiveExitCode = Math.max(...exitCodes);
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
49
|
return conclusiveExitCode;
|
|
38
50
|
};
|
|
39
51
|
if (generate && prisma) {
|
|
40
|
-
await generatePrismaClient({
|
|
41
|
-
verbose
|
|
42
|
-
});
|
|
52
|
+
await generatePrismaClient({ verbose });
|
|
43
53
|
}
|
|
44
54
|
if (generate) {
|
|
45
55
|
await new Listr(
|
|
46
56
|
[
|
|
47
57
|
{
|
|
48
58
|
title: "Generating types",
|
|
49
|
-
task: () =>
|
|
50
|
-
shell: true,
|
|
51
|
-
stdio: verbose ? "inherit" : "ignore"
|
|
52
|
-
})
|
|
59
|
+
task: () => runBin("cedar-gen", [], { stdio: verbose ? "inherit" : "ignore" })
|
|
53
60
|
}
|
|
54
61
|
],
|
|
55
62
|
{
|
|
56
|
-
renderer: verbose
|
|
63
|
+
renderer: verbose ? "verbose" : "default",
|
|
57
64
|
rendererOptions: { collapseSubtasks: false }
|
|
58
65
|
}
|
|
59
66
|
).run();
|
|
@@ -3,7 +3,8 @@ 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 { tryParse } from "verkit";
|
|
7
|
+
const MAIN_BRANCH_PRERELEASE_TAGS = ["canary"];
|
|
7
8
|
function isExecaError(e) {
|
|
8
9
|
return e instanceof Error && ("stdout" in e || "stderr" in e || "exitCode" in e);
|
|
9
10
|
}
|
|
@@ -12,7 +13,7 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
15
|
const version = typeof ctx.versionToUpgradeTo === "string" ? ctx.versionToUpgradeTo : void 0;
|
|
15
|
-
const parsed =
|
|
16
|
+
const parsed = version ? tryParse(version) : null;
|
|
16
17
|
const baseUrl = "https://raw.githubusercontent.com/cedarjs/cedar/main/upgrade-scripts/";
|
|
17
18
|
const manifestUrl = `${baseUrl}manifest.json`;
|
|
18
19
|
let manifest = [];
|
|
@@ -33,8 +34,15 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
33
34
|
if (!Array.isArray(manifest) || manifest.length === 0) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
37
|
+
const prereleaseTag = parsed?.prerelease?.[0];
|
|
38
|
+
const isMainBranchPrerelease = typeof prereleaseTag === "string" && MAIN_BRANCH_PRERELEASE_TAGS.includes(prereleaseTag);
|
|
36
39
|
const checkLevels = [];
|
|
37
|
-
if (parsed &&
|
|
40
|
+
if (parsed && isMainBranchPrerelease) {
|
|
41
|
+
checkLevels.push({
|
|
42
|
+
id: "tag",
|
|
43
|
+
candidates: [`${prereleaseTag}.ts`, `${prereleaseTag}/index.ts`]
|
|
44
|
+
});
|
|
45
|
+
} else if (parsed) {
|
|
38
46
|
checkLevels.push({
|
|
39
47
|
id: "exact",
|
|
40
48
|
candidates: [`${version}.ts`, `${version}/index.ts`]
|
|
@@ -50,14 +58,6 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
50
58
|
id: "minor",
|
|
51
59
|
candidates: [`${parsed.major}.x.ts`, `${parsed.major}.x/index.ts`]
|
|
52
60
|
});
|
|
53
|
-
} else if (parsed && parsed.prerelease.length > 0) {
|
|
54
|
-
checkLevels.push({
|
|
55
|
-
id: "tag",
|
|
56
|
-
candidates: [
|
|
57
|
-
`${parsed.prerelease[0]}.ts`,
|
|
58
|
-
`${parsed.prerelease[0]}/index.ts`
|
|
59
|
-
]
|
|
60
|
-
});
|
|
61
61
|
}
|
|
62
62
|
const scriptsToRun = [];
|
|
63
63
|
for (const level of checkLevels) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import c from "
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
3
|
+
import { dedupeIsSupported } from "@cedarjs/cli-helpers/packageManager";
|
|
3
4
|
import { isValidCedarJSTag } from "./tags.js";
|
|
4
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
6
|
const isValidSemver = (string) => {
|
|
@@ -40,7 +41,8 @@ const builder = (yargs) => {
|
|
|
40
41
|
}).option("dedupe", {
|
|
41
42
|
description: "Skip dedupe check with --no-dedupe",
|
|
42
43
|
type: "boolean",
|
|
43
|
-
default: true
|
|
44
|
+
default: true,
|
|
45
|
+
hidden: !dedupeIsSupported()
|
|
44
46
|
}).option("yes", {
|
|
45
47
|
alias: "y",
|
|
46
48
|
describe: "Skip prompts and use defaults",
|