@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
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { Writable } from "node:stream";
|
|
4
5
|
import concurrently from "concurrently";
|
|
5
|
-
import {
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
|
+
import { formatRunBinCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
8
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
9
|
import { shutdownPort } from "@cedarjs/internal/dist/dev";
|
|
10
|
+
import { generateGqlormArtifacts } from "@cedarjs/internal/dist/generate/gqlormSchema";
|
|
7
11
|
import { getConfig, getConfigPath } from "@cedarjs/project-config";
|
|
12
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
8
13
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
|
-
import c from "../../lib/colors.js";
|
|
10
14
|
import { exitWithError } from "../../lib/exit.js";
|
|
11
15
|
import { generatePrismaClient } from "../../lib/generatePrismaClient.js";
|
|
12
16
|
import { getPaths } from "../../lib/index.js";
|
|
@@ -14,11 +18,39 @@ import { getFreePort } from "../../lib/ports.js";
|
|
|
14
18
|
import { serverFileExists } from "../../lib/project.js";
|
|
15
19
|
import { getApiDebugFlag } from "./apiDebugFlag.js";
|
|
16
20
|
import { getPackageWatchCommands } from "./packageWatchCommands.js";
|
|
21
|
+
const createdRequire = createRequire(import.meta.url);
|
|
22
|
+
function formatViteDevBinCommand(binName, extraNodeArgs = "") {
|
|
23
|
+
let vitePackageJsonPath;
|
|
24
|
+
let vitePackageJson;
|
|
25
|
+
try {
|
|
26
|
+
vitePackageJsonPath = createdRequire.resolve("@cedarjs/vite/package.json");
|
|
27
|
+
vitePackageJson = createdRequire("@cedarjs/vite/package.json");
|
|
28
|
+
} catch (e) {
|
|
29
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Could not resolve @cedarjs/vite, which the dev server needs to run. Is it installed? (${message})`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const binRelativePath = vitePackageJson.bin?.[binName];
|
|
35
|
+
if (!binRelativePath) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`@cedarjs/vite does not declare a "${binName}" bin. This is a bug in CedarJS.`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const binPath = path.join(path.dirname(vitePackageJsonPath), binRelativePath);
|
|
41
|
+
const nodeLauncher = getPackageManager() === "yarn" ? "yarn node" : "node";
|
|
42
|
+
const flags = extraNodeArgs ? `${extraNodeArgs} ` : "";
|
|
43
|
+
return `${nodeLauncher} ${flags}"${binPath}"`;
|
|
44
|
+
}
|
|
17
45
|
const handler = async ({
|
|
18
46
|
workspace = ["api", "web", "packages/*"],
|
|
19
47
|
forward = "",
|
|
20
48
|
generate = true,
|
|
21
|
-
apiDebugPort
|
|
49
|
+
apiDebugPort,
|
|
50
|
+
debugBrk,
|
|
51
|
+
ud = false,
|
|
52
|
+
nodeArgs = "",
|
|
53
|
+
jobs: jobsOption
|
|
22
54
|
}) => {
|
|
23
55
|
recordTelemetryAttributes({
|
|
24
56
|
command: "dev",
|
|
@@ -28,13 +60,8 @@ const handler = async ({
|
|
|
28
60
|
const cedarPaths = getPaths();
|
|
29
61
|
const serverFile = serverFileExists();
|
|
30
62
|
const apiPreferredPort = parseInt(String(getConfig().api.port));
|
|
31
|
-
let webPreferredPort = parseInt(
|
|
32
|
-
String(getConfig().web.port)
|
|
33
|
-
);
|
|
34
63
|
let apiAvailablePort = apiPreferredPort;
|
|
35
64
|
let apiPortChangeNeeded = false;
|
|
36
|
-
let webAvailablePort = webPreferredPort;
|
|
37
|
-
let webPortChangeNeeded = false;
|
|
38
65
|
if (workspace.includes("api") && !serverFile) {
|
|
39
66
|
apiAvailablePort = await getFreePort(apiPreferredPort);
|
|
40
67
|
if (apiAvailablePort === -1) {
|
|
@@ -44,6 +71,11 @@ const handler = async ({
|
|
|
44
71
|
}
|
|
45
72
|
apiPortChangeNeeded = apiAvailablePort !== apiPreferredPort;
|
|
46
73
|
}
|
|
74
|
+
let webPreferredPort = parseInt(
|
|
75
|
+
String(getConfig().web.port)
|
|
76
|
+
);
|
|
77
|
+
let webAvailablePort = webPreferredPort;
|
|
78
|
+
let webPortChangeNeeded = false;
|
|
47
79
|
if (workspace.includes("web")) {
|
|
48
80
|
const forwardedPortMatches = [
|
|
49
81
|
...forward.matchAll(/\-\-port(\=|\s)(?<port>[^\s]*)/g)
|
|
@@ -52,10 +84,10 @@ const handler = async ({
|
|
|
52
84
|
const port = forwardedPortMatches.pop()?.groups?.port;
|
|
53
85
|
webPreferredPort = port ? parseInt(port, 10) : void 0;
|
|
54
86
|
}
|
|
55
|
-
webAvailablePort = await getFreePort(
|
|
56
|
-
|
|
57
|
-
apiAvailablePort
|
|
58
|
-
|
|
87
|
+
webAvailablePort = await getFreePort(
|
|
88
|
+
webPreferredPort,
|
|
89
|
+
apiAvailablePort !== void 0 ? [apiPreferredPort, apiAvailablePort] : [apiPreferredPort]
|
|
90
|
+
);
|
|
59
91
|
if (webAvailablePort === -1) {
|
|
60
92
|
exitWithError(void 0, {
|
|
61
93
|
message: `Could not determine a free port for the web server`
|
|
@@ -63,36 +95,60 @@ const handler = async ({
|
|
|
63
95
|
}
|
|
64
96
|
webPortChangeNeeded = webAvailablePort !== webPreferredPort;
|
|
65
97
|
}
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
98
|
+
if (ud) {
|
|
99
|
+
if (webPortChangeNeeded) {
|
|
100
|
+
const message = [
|
|
101
|
+
"The currently configured port for the development server is",
|
|
102
|
+
"unavailable. Suggested change to your port, which can be changed in",
|
|
103
|
+
"cedar.toml (or redwood.toml):\n",
|
|
104
|
+
` - Web to use port ${webAvailablePort} instead`,
|
|
105
|
+
"of your currently configured",
|
|
106
|
+
`${webPreferredPort}
|
|
74
107
|
`,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
108
|
+
"\nCannot run the development server until your configured port is",
|
|
109
|
+
"changed or becomes available."
|
|
110
|
+
].filter(Boolean).join(" ");
|
|
111
|
+
exitWithError(void 0, { message });
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
if (apiPortChangeNeeded || webPortChangeNeeded) {
|
|
115
|
+
const message = [
|
|
116
|
+
"The currently configured ports for the development server are",
|
|
117
|
+
"unavailable. Suggested changes to your ports, which can be changed in",
|
|
118
|
+
"cedar.toml (or redwood.toml), are:\n",
|
|
119
|
+
apiPortChangeNeeded && ` - API to use port ${apiAvailablePort} instead`,
|
|
120
|
+
apiPortChangeNeeded && "of your currently configured",
|
|
121
|
+
apiPortChangeNeeded && `${apiPreferredPort}
|
|
78
122
|
`,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
123
|
+
webPortChangeNeeded && ` - Web to use port ${webAvailablePort} instead`,
|
|
124
|
+
webPortChangeNeeded && "of your currently configured",
|
|
125
|
+
webPortChangeNeeded && `${webPreferredPort}
|
|
126
|
+
`,
|
|
127
|
+
"\nCannot run the development server until your configured ports are",
|
|
128
|
+
"changed or become available."
|
|
129
|
+
].filter(Boolean).join(" ");
|
|
130
|
+
exitWithError(void 0, { message });
|
|
131
|
+
}
|
|
83
132
|
}
|
|
84
133
|
if (workspace.includes("api")) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
verbose: false
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
134
|
+
if (generate) {
|
|
135
|
+
try {
|
|
136
|
+
await generatePrismaClient({ verbose: false });
|
|
137
|
+
} catch (e) {
|
|
138
|
+
const message = getErrorMessage(e);
|
|
139
|
+
errorTelemetry(
|
|
140
|
+
process.argv,
|
|
141
|
+
`Error generating prisma client: ${message}`
|
|
142
|
+
);
|
|
143
|
+
console.error(c.error(message));
|
|
144
|
+
}
|
|
94
145
|
}
|
|
95
|
-
if (!serverFile) {
|
|
146
|
+
if (!ud && !serverFile) {
|
|
147
|
+
if (typeof apiAvailablePort === "undefined" || apiAvailablePort === -1) {
|
|
148
|
+
exitWithError(void 0, {
|
|
149
|
+
message: `Could not determine a free port for the api server`
|
|
150
|
+
});
|
|
151
|
+
}
|
|
96
152
|
try {
|
|
97
153
|
await shutdownPort(apiAvailablePort);
|
|
98
154
|
} catch (e) {
|
|
@@ -104,7 +160,7 @@ const handler = async ({
|
|
|
104
160
|
}
|
|
105
161
|
}
|
|
106
162
|
}
|
|
107
|
-
if (workspace.includes("web")) {
|
|
163
|
+
if (workspace.includes("web") && webAvailablePort !== void 0) {
|
|
108
164
|
try {
|
|
109
165
|
await shutdownPort(webAvailablePort);
|
|
110
166
|
} catch (e) {
|
|
@@ -115,56 +171,151 @@ const handler = async ({
|
|
|
115
171
|
);
|
|
116
172
|
}
|
|
117
173
|
}
|
|
118
|
-
|
|
174
|
+
if (generate && workspace.includes("web") && getConfig().experimental?.gqlorm?.enabled) {
|
|
175
|
+
try {
|
|
176
|
+
await generateGqlormArtifacts();
|
|
177
|
+
} catch (e) {
|
|
178
|
+
const message = getErrorMessage(e);
|
|
179
|
+
console.error(c.error(`Error generating gqlorm schema: ${message}`));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
119
182
|
const streamingSsrEnabled = getConfig().experimental?.streamingSsr?.enabled;
|
|
120
183
|
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
121
|
-
let webCommand = `yarn cross-env NODE_ENV=development rw-vite-dev ${forward}`;
|
|
122
|
-
if (streamingSsrEnabled) {
|
|
123
|
-
webCommand = `yarn cross-env NODE_ENV=development rw-dev-fe ${forward}`;
|
|
124
|
-
}
|
|
125
184
|
const rootPackageJsonPath = path.join(cedarPaths.base, "package.json");
|
|
126
185
|
const rootPackageJson = JSON.parse(
|
|
127
186
|
fs.readFileSync(rootPackageJsonPath, "utf8")
|
|
128
187
|
);
|
|
129
|
-
const
|
|
130
|
-
|
|
188
|
+
const buildUnifiedDevCommand = () => {
|
|
189
|
+
if (!ud) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
if (streamingSsrEnabled) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
if (!workspace.includes("api") || !workspace.includes("web")) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
if (serverFile) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
if (!fs.existsSync(cedarPaths.api.src) || !fs.existsSync(cedarPaths.web.src)) {
|
|
202
|
+
console.log("api.src or web.src does not exist");
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
return [
|
|
206
|
+
formatViteDevBinCommand("cedar-unified-dev", nodeArgs),
|
|
207
|
+
` --port ${webAvailablePort}`,
|
|
208
|
+
` --apiPort ${apiAvailablePort}`,
|
|
209
|
+
getApiDebugFlag(apiDebugPort, apiAvailablePort),
|
|
210
|
+
debugBrk ? "--debug-brk" : "",
|
|
211
|
+
// `cedar-unified-dev` starts its own in-process jobs worker pool (see
|
|
212
|
+
// `jobsDevMiddleware.ts`) rather than relying on the nodemon-wrapped
|
|
213
|
+
// worker pushed below, so `--no-jobs` has to be forwarded explicitly -
|
|
214
|
+
// it isn't part of `forward` unless the user passed it after `--`.
|
|
215
|
+
jobsOption === false ? "--no-jobs" : "",
|
|
216
|
+
forward
|
|
217
|
+
].join(" ").replace(/\s+/g, " ").trim();
|
|
218
|
+
};
|
|
219
|
+
const unifiedDevCommand = buildUnifiedDevCommand();
|
|
220
|
+
if (!unifiedDevCommand && apiPortChangeNeeded) {
|
|
221
|
+
const message = [
|
|
222
|
+
"The currently configured port for the development server is",
|
|
223
|
+
"unavailable. Suggested change to your port, which can be changed in",
|
|
224
|
+
"cedar.toml (or redwood.toml):\n",
|
|
225
|
+
` - API to use port ${apiAvailablePort} instead`,
|
|
226
|
+
"of your currently configured",
|
|
227
|
+
`${apiPreferredPort}
|
|
228
|
+
`,
|
|
229
|
+
"\nCannot run the development server until your configured port is",
|
|
230
|
+
"changed or becomes available."
|
|
231
|
+
].filter(Boolean).join(" ");
|
|
232
|
+
exitWithError(void 0, { message });
|
|
233
|
+
}
|
|
131
234
|
const jobs = [];
|
|
132
|
-
if (
|
|
235
|
+
if (unifiedDevCommand) {
|
|
133
236
|
jobs.push({
|
|
134
|
-
name: "
|
|
135
|
-
command:
|
|
136
|
-
"yarn nodemon",
|
|
137
|
-
" --quiet",
|
|
138
|
-
` --watch "${cedarConfigPath}"`,
|
|
139
|
-
` --exec "yarn ${serverWatchCommand}`,
|
|
140
|
-
` --port ${apiAvailablePort}`,
|
|
141
|
-
` ${getApiDebugFlag(apiDebugPort)}`,
|
|
142
|
-
' | rw-log-formatter"'
|
|
143
|
-
].join(" ").replace(/\s+/g, " "),
|
|
237
|
+
name: "dev",
|
|
238
|
+
command: unifiedDevCommand,
|
|
144
239
|
env: {
|
|
145
240
|
NODE_ENV: "development",
|
|
146
241
|
NODE_OPTIONS: getDevNodeOptions()
|
|
147
242
|
},
|
|
148
243
|
prefixColor: "cyan",
|
|
149
|
-
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
if (workspace.includes("web")) {
|
|
153
|
-
jobs.push({
|
|
154
|
-
name: "web",
|
|
155
|
-
command: webCommand,
|
|
156
|
-
prefixColor: "blue",
|
|
157
|
-
cwd: cedarPaths.web.base,
|
|
158
|
-
runWhen: () => fs.existsSync(cedarPaths.web.src)
|
|
244
|
+
cwd: cedarPaths.web.base
|
|
159
245
|
});
|
|
246
|
+
} else {
|
|
247
|
+
if (workspace.includes("api")) {
|
|
248
|
+
const cedarConfigPath = getConfigPath();
|
|
249
|
+
jobs.push({
|
|
250
|
+
name: "api",
|
|
251
|
+
command: formatRunBinCommand("nodemon", [
|
|
252
|
+
"--quiet",
|
|
253
|
+
`--watch "${cedarConfigPath}"`,
|
|
254
|
+
`--exec "${formatRunBinCommand("cedar-api-server-watch")} --port ${apiAvailablePort} ${getApiDebugFlag(apiDebugPort, apiAvailablePort)} | ${formatRunBinCommand("cedar-log-formatter")}"`
|
|
255
|
+
]),
|
|
256
|
+
env: {
|
|
257
|
+
NODE_ENV: "development",
|
|
258
|
+
NODE_OPTIONS: getDevNodeOptions()
|
|
259
|
+
},
|
|
260
|
+
prefixColor: "cyan",
|
|
261
|
+
runWhen: () => fs.existsSync(cedarPaths.api.src)
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
if (workspace.includes("web")) {
|
|
265
|
+
let webCommand = `${formatViteDevBinCommand("cedar-vite-dev", nodeArgs)} ${forward}`;
|
|
266
|
+
if (streamingSsrEnabled) {
|
|
267
|
+
webCommand = `${formatViteDevBinCommand("cedar-dev-fe", nodeArgs)} ${forward}`;
|
|
268
|
+
}
|
|
269
|
+
jobs.push({
|
|
270
|
+
name: "web",
|
|
271
|
+
command: webCommand,
|
|
272
|
+
env: {
|
|
273
|
+
NODE_ENV: "development"
|
|
274
|
+
},
|
|
275
|
+
prefixColor: "blue",
|
|
276
|
+
cwd: cedarPaths.web.base,
|
|
277
|
+
runWhen: () => fs.existsSync(cedarPaths.web.src)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
160
280
|
}
|
|
161
281
|
if (generate) {
|
|
162
282
|
jobs.push({
|
|
163
283
|
name: "gen",
|
|
164
|
-
command: "
|
|
284
|
+
command: formatRunBinCommand("cedar-gen-watch"),
|
|
165
285
|
prefixColor: "green"
|
|
166
286
|
});
|
|
167
287
|
}
|
|
288
|
+
const jobsConfigured = jobsOption !== false && workspace.includes("api") && !!cedarPaths.api.jobsConfig && // `getPaths()` resolves `jobsConfig` once and caches it in-process, so
|
|
289
|
+
// if `api/src/lib/jobs.ts` is deleted mid-session the cached path would
|
|
290
|
+
// otherwise still look "configured". Guard against starting a worker
|
|
291
|
+
// that can't load a jobs config that no longer exists.
|
|
292
|
+
fs.existsSync(cedarPaths.api.jobsConfig) && fs.existsSync(cedarPaths.api.jobs) && // Job files always live in `api/src/jobs/<ComponentName>Job/`
|
|
293
|
+
// subdirectories (see `generate/job/jobHandler.ts`), so entries here are
|
|
294
|
+
// directories, not files — only the `.keep` placeholder (and any stray
|
|
295
|
+
// dotfiles, e.g. `.DS_Store`) should be excluded.
|
|
296
|
+
fs.readdirSync(cedarPaths.api.jobs).some((entry) => !entry.startsWith("."));
|
|
297
|
+
if (jobsConfigured && unifiedDevCommand) {
|
|
298
|
+
} else if (jobsConfigured) {
|
|
299
|
+
jobs.push({
|
|
300
|
+
name: "jobs",
|
|
301
|
+
// `cedar-jobs work` loads its config and job files from `api/dist`
|
|
302
|
+
// (compiled output), not `api/src`. That dist output is only written
|
|
303
|
+
// once the `api` watcher's initial build finishes, which happens
|
|
304
|
+
// asynchronously — so on a clean `cedar dev` start there's a window
|
|
305
|
+
// where `api/dist` doesn't exist yet and the worker would exit
|
|
306
|
+
// immediately. Wrapping it in nodemon (same tool the `api` job above
|
|
307
|
+
// uses) means it retries as soon as `api/dist` changes, instead of
|
|
308
|
+
// staying dead for the rest of the session. This also means the
|
|
309
|
+
// worker restarts automatically whenever job code is rebuilt, since
|
|
310
|
+
// Node's ESM cache would otherwise keep serving stale job code.
|
|
311
|
+
command: formatRunBinCommand("nodemon", [
|
|
312
|
+
"--quiet",
|
|
313
|
+
`--watch "${cedarPaths.api.dist}"`,
|
|
314
|
+
`--exec "${formatRunBinCommand("cedar-jobs", ["work"])}"`
|
|
315
|
+
]),
|
|
316
|
+
prefixColor: "magenta"
|
|
317
|
+
});
|
|
318
|
+
}
|
|
168
319
|
const packageWorkspaces = workspace.filter(
|
|
169
320
|
(w) => w !== "api" && w !== "web" && w !== "gen"
|
|
170
321
|
);
|
|
@@ -211,7 +362,7 @@ const handler = async ({
|
|
|
211
362
|
handleInput: true,
|
|
212
363
|
outputStream
|
|
213
364
|
});
|
|
214
|
-
result.catch((e) => {
|
|
365
|
+
result.then(() => process.exit(0)).catch((e) => {
|
|
215
366
|
if (e?.message) {
|
|
216
367
|
errorTelemetry(
|
|
217
368
|
process.argv,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import { getConfig, importStatementPath } from "@cedarjs/project-config";
|
|
5
5
|
import { getPaths } from "../../lib/index.js";
|
|
6
6
|
async function getPackageWatchCommands(packageWorkspaces) {
|
|
7
7
|
const cedarPaths = getPaths();
|
|
@@ -17,6 +17,7 @@ async function getPackageWatchCommands(packageWorkspaces) {
|
|
|
17
17
|
}
|
|
18
18
|
return importStatementPath(workspacePath);
|
|
19
19
|
});
|
|
20
|
+
const packagesWorkspaceConfig = getConfig().experimental.packagesWorkspace;
|
|
20
21
|
const watchablePackages = [];
|
|
21
22
|
const packagesWithoutWatch = [];
|
|
22
23
|
for (const workspacePath of workspacePaths) {
|
|
@@ -29,7 +30,11 @@ async function getPackageWatchCommands(packageWorkspaces) {
|
|
|
29
30
|
if (packageJson.scripts?.watch) {
|
|
30
31
|
watchablePackages.push(workspacePath);
|
|
31
32
|
} else {
|
|
32
|
-
|
|
33
|
+
const packageConfig = packageName && packagesWorkspaceConfig[packageName];
|
|
34
|
+
const skipWatchWarning = typeof packageConfig === "object" && packageConfig.skipWatchWarning;
|
|
35
|
+
if (!skipWatchWarning) {
|
|
36
|
+
packagesWithoutWatch.push(packageName);
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
if (packagesWithoutWatch.length > 0) {
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
import { checkNodeVersion } from "../middleware/checkNodeVersion.js";
|
|
5
5
|
const command = "dev [workspace..]";
|
|
@@ -13,17 +13,27 @@ const builder = (yargs) => {
|
|
|
13
13
|
}).option("forward", {
|
|
14
14
|
alias: "fwd",
|
|
15
15
|
description: 'String of one or more vite dev server config options, for example: `--fwd="--port=1234 --open=false"`',
|
|
16
|
-
type: "string"
|
|
17
|
-
// The reason `forward` is hidden is that it's been broken with Vite and
|
|
18
|
-
// it's not clear how to fix it.
|
|
19
|
-
hidden: true
|
|
16
|
+
type: "string"
|
|
20
17
|
}).option("generate", {
|
|
21
18
|
type: "boolean",
|
|
22
19
|
default: true,
|
|
23
20
|
description: "Generate artifacts"
|
|
24
21
|
}).option("apiDebugPort", {
|
|
25
22
|
type: "number",
|
|
26
|
-
description: "Port on which to expose API server debugger. If you supply the flag with no value it defaults to
|
|
23
|
+
description: "Port on which to expose API server debugger. If you supply the flag with no value it defaults to 1 prepended to the api port (e.g. api port 8913 -> debug port 18913)."
|
|
24
|
+
}).option("debugBrk", {
|
|
25
|
+
type: "boolean",
|
|
26
|
+
description: "Wait for a debugger to connect before starting the API dev server, similar to Node.js --inspect-brk. Only works in --ud mode."
|
|
27
|
+
}).option("ud", {
|
|
28
|
+
type: "boolean",
|
|
29
|
+
default: false,
|
|
30
|
+
description: "Use the unified Vite dev server that handles both web and API in a single process (experimental)."
|
|
31
|
+
}).option("nodeArgs", {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: 'CLI args to pass to the node process running the web dev server, for example: `--node-args="--inspect --max-old-space-size=8192"`.'
|
|
34
|
+
}).option("jobs", {
|
|
35
|
+
type: "boolean",
|
|
36
|
+
description: "Start the background jobs worker alongside the other dev servers when jobs are configured (`cedar setup jobs` + at least one `cedar g job`). Pass `--no-jobs` to opt out and run `cedar jobs work` yourself instead."
|
|
27
37
|
}).middleware(() => {
|
|
28
38
|
const check = checkNodeVersion();
|
|
29
39
|
if (check.ok) {
|
|
@@ -3,25 +3,29 @@ import path from "node:path";
|
|
|
3
3
|
import { context } from "@opentelemetry/api";
|
|
4
4
|
import { suppressTracing } from "@opentelemetry/core";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
|
-
import {
|
|
6
|
+
import { Parser } from "yargs/helpers";
|
|
7
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
8
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
7
9
|
import { findScripts } from "@cedarjs/internal/dist/files";
|
|
8
|
-
import c from "../lib/colors.js";
|
|
9
10
|
import { runScriptFunction } from "../lib/exec.js";
|
|
10
11
|
import { generatePrismaClient } from "../lib/generatePrismaClient.js";
|
|
11
12
|
import { getPaths } from "../lib/index.js";
|
|
12
13
|
const printAvailableScriptsToConsole = () => {
|
|
13
|
-
const scripts = findScripts(getPaths().scripts).reduce(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const scripts = findScripts(getPaths().scripts).reduce(
|
|
15
|
+
(acc, scriptPath) => {
|
|
16
|
+
const relativePath = path.relative(getPaths().scripts, scriptPath);
|
|
17
|
+
const ext = path.parse(relativePath).ext;
|
|
18
|
+
const pathNoExt = relativePath.slice(0, -ext.length);
|
|
19
|
+
acc[pathNoExt] ||= [];
|
|
20
|
+
acc[pathNoExt].push(relativePath);
|
|
21
|
+
return acc;
|
|
22
|
+
},
|
|
23
|
+
{}
|
|
24
|
+
);
|
|
21
25
|
console.log("Available scripts:");
|
|
22
|
-
Object.entries(scripts).forEach(([name,
|
|
23
|
-
if (
|
|
24
|
-
|
|
26
|
+
Object.entries(scripts).forEach(([name, scriptPaths]) => {
|
|
27
|
+
if (scriptPaths.length > 1) {
|
|
28
|
+
scriptPaths.forEach((scriptPath) => {
|
|
25
29
|
console.log(c.info(`- ${scriptPath}`));
|
|
26
30
|
});
|
|
27
31
|
} else {
|
|
@@ -33,19 +37,32 @@ const printAvailableScriptsToConsole = () => {
|
|
|
33
37
|
const handler = async (args) => {
|
|
34
38
|
recordTelemetryAttributes({
|
|
35
39
|
command: "exec",
|
|
36
|
-
prisma: args.prisma,
|
|
37
|
-
list: args.list
|
|
40
|
+
prisma: !!args.prisma,
|
|
41
|
+
list: !!args.list
|
|
38
42
|
});
|
|
39
43
|
const { name, prisma, list, ...scriptArgs } = args;
|
|
40
44
|
if (list || !name) {
|
|
41
45
|
printAvailableScriptsToConsole();
|
|
42
46
|
return;
|
|
43
47
|
}
|
|
44
|
-
|
|
48
|
+
if (Array.isArray(scriptArgs._)) {
|
|
49
|
+
scriptArgs._ = scriptArgs._.slice(1);
|
|
50
|
+
}
|
|
45
51
|
delete scriptArgs.$0;
|
|
46
52
|
delete scriptArgs.l;
|
|
47
53
|
delete scriptArgs.s;
|
|
48
54
|
delete scriptArgs.silent;
|
|
55
|
+
if (Array.isArray(scriptArgs._)) {
|
|
56
|
+
const dashBlockIndex = scriptArgs._.findIndex(
|
|
57
|
+
(arg) => typeof arg === "string" && arg.startsWith("-")
|
|
58
|
+
);
|
|
59
|
+
if (dashBlockIndex !== -1) {
|
|
60
|
+
const unparsedTail = scriptArgs._.splice(dashBlockIndex);
|
|
61
|
+
const { _: reparsedPositionals, ...reparsedFlags } = Parser(unparsedTail);
|
|
62
|
+
scriptArgs._.push(...reparsedPositionals);
|
|
63
|
+
Object.assign(scriptArgs, reparsedFlags);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
49
66
|
const scriptPath = resolveScriptPath(name);
|
|
50
67
|
if (!scriptPath) {
|
|
51
68
|
console.error(
|
|
@@ -59,11 +76,10 @@ No script called \`${name}\` in the ./scripts folder.
|
|
|
59
76
|
const scriptTasks = [
|
|
60
77
|
{
|
|
61
78
|
title: "Generating Prisma client",
|
|
62
|
-
enabled: () => prisma,
|
|
79
|
+
enabled: () => !!prisma,
|
|
63
80
|
task: () => generatePrismaClient({
|
|
64
|
-
force: false,
|
|
65
81
|
verbose: !args.silent,
|
|
66
|
-
silent: args.silent
|
|
82
|
+
silent: !!args.silent
|
|
67
83
|
})
|
|
68
84
|
},
|
|
69
85
|
{
|
|
@@ -75,20 +91,24 @@ No script called \`${name}\` in the ./scripts folder.
|
|
|
75
91
|
functionName: "default",
|
|
76
92
|
args: { args: scriptArgs }
|
|
77
93
|
});
|
|
78
|
-
} catch (
|
|
79
|
-
console.error(c.error(
|
|
80
|
-
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error(c.error("\nError in script:"));
|
|
96
|
+
console.error(error);
|
|
97
|
+
throw error;
|
|
81
98
|
}
|
|
82
99
|
}
|
|
83
100
|
}
|
|
84
101
|
];
|
|
85
102
|
const tasks = new Listr(scriptTasks, {
|
|
86
|
-
rendererOptions: { collapseSubtasks: false },
|
|
87
103
|
renderer: args.silent ? "silent" : "verbose"
|
|
88
104
|
});
|
|
89
|
-
|
|
90
|
-
await
|
|
91
|
-
|
|
105
|
+
try {
|
|
106
|
+
await context.with(suppressTracing(context.active()), async () => {
|
|
107
|
+
await tasks.run();
|
|
108
|
+
});
|
|
109
|
+
} catch {
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
92
112
|
};
|
|
93
113
|
function resolveScriptPath(name) {
|
|
94
114
|
const scriptPath = path.join(getPaths().scripts, name);
|
|
@@ -98,9 +118,9 @@ function resolveScriptPath(name) {
|
|
|
98
118
|
const extensions = [".js", ".jsx", ".ts", ".tsx"];
|
|
99
119
|
const matches = [];
|
|
100
120
|
for (const extension of extensions) {
|
|
101
|
-
const
|
|
102
|
-
if (fs.existsSync(
|
|
103
|
-
matches.push(
|
|
121
|
+
const candidate = scriptPath + extension;
|
|
122
|
+
if (fs.existsSync(candidate)) {
|
|
123
|
+
matches.push(candidate);
|
|
104
124
|
}
|
|
105
125
|
}
|
|
106
126
|
if (matches.length === 1) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
|
+
import { getEpilogue } from "../util.js";
|
|
3
|
+
const command = "setup-live-queries";
|
|
4
|
+
const description = "Setup live query invalidation with Postgres notifications";
|
|
5
|
+
function builder(yargs) {
|
|
6
|
+
return yargs.option("force", {
|
|
7
|
+
alias: "f",
|
|
8
|
+
default: false,
|
|
9
|
+
description: "Overwrite existing configuration",
|
|
10
|
+
type: "boolean"
|
|
11
|
+
}).option("verbose", {
|
|
12
|
+
alias: "v",
|
|
13
|
+
default: false,
|
|
14
|
+
description: "Print more logs",
|
|
15
|
+
type: "boolean"
|
|
16
|
+
}).epilogue(getEpilogue(command, description));
|
|
17
|
+
}
|
|
18
|
+
async function handler(options) {
|
|
19
|
+
recordTelemetryAttributes({
|
|
20
|
+
command: `experimental ${command}`,
|
|
21
|
+
force: options.force,
|
|
22
|
+
verbose: options.verbose
|
|
23
|
+
});
|
|
24
|
+
const { handler: handler2 } = await import("./liveQueriesHandler.js");
|
|
25
|
+
return handler2(options);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
builder,
|
|
29
|
+
command,
|
|
30
|
+
description,
|
|
31
|
+
handler
|
|
32
|
+
};
|