@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
package/README.md
CHANGED
|
@@ -238,12 +238,9 @@ export const builder = (yargs) => {
|
|
|
238
238
|
|
|
239
239
|
...
|
|
240
240
|
|
|
241
|
-
.option('
|
|
242
|
-
default:
|
|
243
|
-
description:
|
|
244
|
-
'Webpack Bundle Analyzer',
|
|
245
|
-
'https://github.com/webpack-contrib/webpack-bundle-analyzer'
|
|
246
|
-
)}`,
|
|
241
|
+
.option('prerender', {
|
|
242
|
+
default: true,
|
|
243
|
+
description: 'Prerender after building web',
|
|
247
244
|
type: 'boolean',
|
|
248
245
|
})
|
|
249
246
|
.option('verbose', {
|
|
@@ -258,11 +255,11 @@ export const builder = (yargs) => {
|
|
|
258
255
|
}
|
|
259
256
|
```
|
|
260
257
|
|
|
261
|
-
These two calls to `options` configure this command to have options `--
|
|
258
|
+
These two calls to `options` configure this command to have options `--prerender` and `--verbose`:
|
|
262
259
|
|
|
263
260
|
```terminal
|
|
264
|
-
yarn
|
|
265
|
-
yarn
|
|
261
|
+
yarn cedar build --no-prerender
|
|
262
|
+
yarn cedar build --verbose
|
|
266
263
|
```
|
|
267
264
|
|
|
268
265
|
For the full list of what properties you can use to compose the options object, see [options(key, [opt])](https://yargs.js.org/docs/#api-optionskey-opt).
|
|
@@ -280,8 +277,8 @@ While `build`'s `handler` is too long to reproduce here in full, to get the poin
|
|
|
280
277
|
|
|
281
278
|
export const handler = async ({
|
|
282
279
|
side = ['api', 'web'],
|
|
280
|
+
prerender = true,
|
|
283
281
|
verbose = false,
|
|
284
|
-
stats = false,
|
|
285
282
|
}) => {
|
|
286
283
|
|
|
287
284
|
...
|
package/dist/cfw.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import Configstore from "configstore";
|
|
5
|
-
import execa from "execa";
|
|
6
5
|
import { terminalLink } from "termi-link";
|
|
6
|
+
import { runScriptSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
7
|
import { getConfigPath } from "@cedarjs/project-config";
|
|
8
8
|
const config = new Configstore("@cedarjs/cli");
|
|
9
|
-
const CFW_PATH = process.env.CFW_PATH ||
|
|
9
|
+
const CFW_PATH = process.env.CFW_PATH || config.get("CFW_PATH");
|
|
10
10
|
if (!CFW_PATH) {
|
|
11
11
|
console.error("Error: You must specify the path to Cedar Framework");
|
|
12
12
|
console.error("Usage: `CFW_PATH=~/gh/cedarjs/cedar yarn cfw <command>");
|
|
@@ -30,14 +30,18 @@ const helpCommands = ["help", "--help"];
|
|
|
30
30
|
if (!command.length || command.some((cmd) => helpCommands.includes(cmd))) {
|
|
31
31
|
command = ["run"];
|
|
32
32
|
}
|
|
33
|
+
const script = command[0];
|
|
34
|
+
const args = command.slice(1);
|
|
33
35
|
try {
|
|
34
|
-
|
|
36
|
+
runScriptSync(script, args, {
|
|
35
37
|
stdio: "inherit",
|
|
36
38
|
cwd: absCfwPath,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
39
|
+
// @ts-expect-error - testUtils.d.ts augments ProcessEnv with
|
|
40
|
+
// CEDAR_DISABLE_TELEMETRY
|
|
41
|
+
env: { CEDAR_CWD: projectPath }
|
|
40
42
|
});
|
|
41
43
|
} catch (e) {
|
|
42
44
|
console.log();
|
|
45
|
+
const exitCode = e && typeof e === "object" && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
46
|
+
process.exit(exitCode);
|
|
43
47
|
}
|
|
@@ -4,39 +4,103 @@ import path from "node:path";
|
|
|
4
4
|
import execa from "execa";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
6
|
import { terminalLink } from "termi-link";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
8
|
+
import {
|
|
9
|
+
formatCedarCommand,
|
|
10
|
+
formatRunWorkspaceScriptCommand
|
|
11
|
+
} from "@cedarjs/cli-helpers/packageManager/display";
|
|
12
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
13
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
14
|
+
import {
|
|
15
|
+
buildApi,
|
|
16
|
+
buildApiWithVite,
|
|
17
|
+
cleanApiBuild
|
|
18
|
+
} from "@cedarjs/internal/dist/build/api";
|
|
9
19
|
import { generate } from "@cedarjs/internal/dist/generate/generate";
|
|
20
|
+
import { generateGqlormArtifacts } from "@cedarjs/internal/dist/generate/gqlormSchema";
|
|
10
21
|
import { loadAndValidateSdls } from "@cedarjs/internal/dist/validateSchema";
|
|
11
22
|
import { detectPrerenderRoutes } from "@cedarjs/prerender/detection";
|
|
12
23
|
import { timedTelemetry } from "@cedarjs/telemetry";
|
|
24
|
+
import { buildCedarApp } from "@cedarjs/vite/build";
|
|
13
25
|
import { generatePrismaCommand } from "../../lib/generatePrismaClient.js";
|
|
14
26
|
import { getPaths, getConfig } from "../../lib/index.js";
|
|
15
27
|
import { buildPackagesTask } from "./buildPackagesTask.js";
|
|
28
|
+
function checkWorkspacePackageEntryPoints(cedarPaths) {
|
|
29
|
+
const packagesDir = cedarPaths.packages;
|
|
30
|
+
if (!packagesDir || !fs.existsSync(packagesDir)) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const problems = [];
|
|
34
|
+
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
35
|
+
for (const entry of packageDirs) {
|
|
36
|
+
if (!entry.isDirectory()) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const pkgJsonPath = path.join(packagesDir, entry.name, "package.json");
|
|
40
|
+
if (!fs.existsSync(pkgJsonPath)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const pkgJson = JSON.parse(
|
|
44
|
+
fs.readFileSync(pkgJsonPath, "utf8")
|
|
45
|
+
);
|
|
46
|
+
const pkgName = pkgJson.name || entry.name;
|
|
47
|
+
const pkgDir = path.join(packagesDir, entry.name);
|
|
48
|
+
const entryFiles = /* @__PURE__ */ new Set();
|
|
49
|
+
if (pkgJson.main) {
|
|
50
|
+
entryFiles.add(path.normalize(pkgJson.main));
|
|
51
|
+
}
|
|
52
|
+
if (pkgJson.exports) {
|
|
53
|
+
const collectPaths = (obj) => {
|
|
54
|
+
if (typeof obj === "string") {
|
|
55
|
+
if (!obj.endsWith(".d.ts")) {
|
|
56
|
+
entryFiles.add(path.normalize(obj));
|
|
57
|
+
}
|
|
58
|
+
} else if (obj && typeof obj === "object") {
|
|
59
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
60
|
+
if (key !== "types") {
|
|
61
|
+
collectPaths(value);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
collectPaths(pkgJson.exports);
|
|
67
|
+
}
|
|
68
|
+
for (const entryFile of entryFiles) {
|
|
69
|
+
const resolvedPath = path.resolve(pkgDir, entryFile);
|
|
70
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
71
|
+
problems.push({ pkgName, entryFile, pkgDir });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return problems;
|
|
76
|
+
}
|
|
16
77
|
const handler = async ({
|
|
17
78
|
workspace = ["api", "web", "packages/*"],
|
|
18
79
|
verbose = false,
|
|
19
80
|
prisma = true,
|
|
20
|
-
prerender = true
|
|
81
|
+
prerender = true,
|
|
82
|
+
ud = false,
|
|
83
|
+
apiRootPath
|
|
21
84
|
}) => {
|
|
22
85
|
recordTelemetryAttributes({
|
|
23
86
|
command: "build",
|
|
24
87
|
workspace: JSON.stringify(workspace),
|
|
25
88
|
verbose,
|
|
26
89
|
prisma,
|
|
27
|
-
prerender
|
|
90
|
+
prerender,
|
|
91
|
+
apiRootPath
|
|
28
92
|
});
|
|
29
93
|
const cedarPaths = getPaths();
|
|
30
94
|
const cedarConfig = getConfig();
|
|
31
95
|
const useFragments = cedarConfig.graphql?.fragments;
|
|
32
96
|
const useTrustedDocuments = cedarConfig.graphql?.trustedDocuments;
|
|
97
|
+
const usePackagesWorkspace = cedarConfig.experimental?.packagesWorkspace?.enabled;
|
|
33
98
|
const prismaSchemaExists = fs.existsSync(cedarPaths.api.prismaConfig);
|
|
34
99
|
const prerenderRoutes = prerender && workspace.includes("web") ? detectPrerenderRoutes() : [];
|
|
35
100
|
const shouldGeneratePrismaClient = prisma && prismaSchemaExists && (workspace.includes("api") || prerenderRoutes.length > 0);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const nonApiWebWorkspaces = Array.isArray(packageJsonWorkspaces) && packageJsonWorkspaces.length > 2 ? workspace.filter((w) => w !== "api" && w !== "web") : [];
|
|
101
|
+
const nonApiWebWorkspaces = workspace.filter(
|
|
102
|
+
(w) => w !== "api" && w !== "web"
|
|
103
|
+
);
|
|
40
104
|
const gqlFeaturesTaskTitle = `Generating types needed for ${[
|
|
41
105
|
useFragments && "GraphQL Fragments",
|
|
42
106
|
useTrustedDocuments && "Trusted Documents"
|
|
@@ -52,10 +116,31 @@ const handler = async ({
|
|
|
52
116
|
});
|
|
53
117
|
}
|
|
54
118
|
},
|
|
55
|
-
nonApiWebWorkspaces.length > 0 && {
|
|
119
|
+
nonApiWebWorkspaces.length > 0 && usePackagesWorkspace && {
|
|
56
120
|
title: "Building Packages...",
|
|
57
121
|
task: (_ctx, task) => buildPackagesTask(task, nonApiWebWorkspaces)
|
|
58
122
|
},
|
|
123
|
+
(workspace.includes("web") || workspace.includes("api")) && usePackagesWorkspace && {
|
|
124
|
+
title: "Checking workspace packages...",
|
|
125
|
+
task: () => {
|
|
126
|
+
const problems = checkWorkspacePackageEntryPoints(cedarPaths);
|
|
127
|
+
if (problems.length === 0) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const details = problems.map(
|
|
131
|
+
({ pkgName, entryFile, pkgDir }) => ` \u2022 ${c.error(pkgName)}: missing "${entryFile}" (in ${pkgDir})`
|
|
132
|
+
).join("\n");
|
|
133
|
+
throw new Error(
|
|
134
|
+
`The following workspace package entry points are missing:
|
|
135
|
+
${details}
|
|
136
|
+
|
|
137
|
+
This usually means the package has not been built yet.
|
|
138
|
+
Run ` + c.info(formatCedarCommand(["build"])) + " (without specifying a workspace) to build everything,\nor build the package manually first, e.g. " + c.info(
|
|
139
|
+
formatRunWorkspaceScriptCommand(problems[0].pkgName, "build")
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
59
144
|
// If using GraphQL Fragments or Trusted Documents, then we need to use
|
|
60
145
|
// codegen to generate the types needed for possible types and the trusted
|
|
61
146
|
// document store hashes
|
|
@@ -63,43 +148,125 @@ const handler = async ({
|
|
|
63
148
|
title: gqlFeaturesTaskTitle,
|
|
64
149
|
task: generate
|
|
65
150
|
},
|
|
151
|
+
workspace.includes("web") && cedarConfig.experimental?.gqlorm?.enabled && {
|
|
152
|
+
title: "Generating gqlorm schema...",
|
|
153
|
+
task: async () => {
|
|
154
|
+
const { errors } = await generateGqlormArtifacts();
|
|
155
|
+
if (errors.length > 0) {
|
|
156
|
+
for (const { message } of errors) {
|
|
157
|
+
console.warn(`Warning: ${message}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
66
162
|
workspace.includes("api") && {
|
|
67
163
|
title: "Verifying graphql schema...",
|
|
68
164
|
task: loadAndValidateSdls
|
|
69
165
|
},
|
|
70
|
-
|
|
166
|
+
// When streaming SSR is enabled, fall back to the legacy separate build
|
|
167
|
+
// paths because streaming SSR has its own complex build orchestration.
|
|
168
|
+
// Phase 7 (SSR/RSC rebuild) will address unifying this path.
|
|
169
|
+
workspace.includes("api") && getConfig().experimental?.streamingSsr?.enabled && {
|
|
71
170
|
title: "Building API...",
|
|
72
171
|
task: async () => {
|
|
73
172
|
await cleanApiBuild();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
173
|
+
await buildApiWithVite();
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
workspace.includes("web") && getConfig().experimental?.streamingSsr?.enabled && {
|
|
177
|
+
title: "Building Web...",
|
|
178
|
+
task: async () => {
|
|
179
|
+
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
180
|
+
const createdRequire = createRequire(import.meta.url);
|
|
181
|
+
const buildBinPath = createdRequire.resolve(
|
|
182
|
+
"@cedarjs/vite/bins/cedar-vite-build.mjs"
|
|
183
|
+
);
|
|
184
|
+
await execa(
|
|
185
|
+
"node",
|
|
186
|
+
[
|
|
187
|
+
buildBinPath,
|
|
188
|
+
`--webDir=${cedarPaths.web.base}`,
|
|
189
|
+
`--verbose=${verbose}`
|
|
190
|
+
],
|
|
191
|
+
{
|
|
192
|
+
stdio: verbose ? "inherit" : "pipe",
|
|
193
|
+
cwd: cedarPaths.web.base
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
if (!getConfig().experimental?.streamingSsr?.enabled) {
|
|
197
|
+
console.log("Creating 200.html...");
|
|
198
|
+
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
199
|
+
fs.copyFileSync(
|
|
200
|
+
indexHtmlPath,
|
|
201
|
+
path.join(getPaths().web.dist, "200.html")
|
|
202
|
+
);
|
|
77
203
|
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
// Legacy separate build path (default when not --ud, non-streaming-SSR)
|
|
207
|
+
workspace.includes("api") && !ud && !getConfig().experimental?.streamingSsr?.enabled && {
|
|
208
|
+
title: "Building API...",
|
|
209
|
+
task: async () => {
|
|
210
|
+
await cleanApiBuild();
|
|
211
|
+
const { errors, warnings } = await buildApi();
|
|
78
212
|
if (warnings.length) {
|
|
79
213
|
console.warn(warnings);
|
|
80
214
|
}
|
|
215
|
+
if (errors.length) {
|
|
216
|
+
throw new Error(
|
|
217
|
+
`API build failed with ${errors.length} error(s). See output above for details.`
|
|
218
|
+
);
|
|
219
|
+
}
|
|
81
220
|
}
|
|
82
221
|
},
|
|
83
|
-
workspace.includes("web") && {
|
|
222
|
+
workspace.includes("web") && !ud && !getConfig().experimental?.streamingSsr?.enabled && {
|
|
84
223
|
title: "Building Web...",
|
|
85
224
|
task: async () => {
|
|
86
225
|
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
87
226
|
const createdRequire = createRequire(import.meta.url);
|
|
88
227
|
const buildBinPath = createdRequire.resolve(
|
|
89
|
-
"@cedarjs/vite/bins/
|
|
228
|
+
"@cedarjs/vite/bins/cedar-vite-build.mjs"
|
|
90
229
|
);
|
|
91
230
|
await execa(
|
|
92
|
-
|
|
231
|
+
"node",
|
|
232
|
+
[
|
|
233
|
+
buildBinPath,
|
|
234
|
+
`--webDir=${cedarPaths.web.base}`,
|
|
235
|
+
`--verbose=${verbose}`
|
|
236
|
+
],
|
|
93
237
|
{
|
|
94
238
|
stdio: verbose ? "inherit" : "pipe",
|
|
95
|
-
|
|
96
|
-
//
|
|
239
|
+
// `cwd` makes postcss/tailwind config resolution work (see the
|
|
240
|
+
// @NOTE above)
|
|
97
241
|
// It won't change process.cwd for anything else here, in this
|
|
98
242
|
// process
|
|
99
243
|
cwd: cedarPaths.web.base
|
|
100
244
|
}
|
|
101
245
|
);
|
|
102
|
-
|
|
246
|
+
console.log("Creating 200.html...");
|
|
247
|
+
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
248
|
+
fs.copyFileSync(
|
|
249
|
+
indexHtmlPath,
|
|
250
|
+
path.join(getPaths().web.dist, "200.html")
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
// Unified build path (experimental, non-streaming-SSR, --ud)
|
|
255
|
+
(workspace.includes("api") || workspace.includes("web")) && ud && !getConfig().experimental?.streamingSsr?.enabled && {
|
|
256
|
+
title: workspace.includes("api") && workspace.includes("web") ? "Building App..." : workspace.includes("api") ? "Building API..." : "Building Web...",
|
|
257
|
+
task: async () => {
|
|
258
|
+
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
259
|
+
if (workspace.includes("api")) {
|
|
260
|
+
await cleanApiBuild();
|
|
261
|
+
}
|
|
262
|
+
const originalCwd = process.cwd();
|
|
263
|
+
process.chdir(cedarPaths.web.base);
|
|
264
|
+
try {
|
|
265
|
+
await buildCedarApp({ verbose, workspace, ud: true });
|
|
266
|
+
} finally {
|
|
267
|
+
process.chdir(originalCwd);
|
|
268
|
+
}
|
|
269
|
+
if (workspace.includes("web")) {
|
|
103
270
|
console.log("Creating 200.html...");
|
|
104
271
|
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
105
272
|
fs.copyFileSync(
|
|
@@ -109,34 +276,42 @@ const handler = async ({
|
|
|
109
276
|
}
|
|
110
277
|
}
|
|
111
278
|
}
|
|
112
|
-
]
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
shell: true,
|
|
127
|
-
cwd: cedarPaths.web.base
|
|
279
|
+
];
|
|
280
|
+
if (apiRootPath !== void 0) {
|
|
281
|
+
process.env.CEDAR_API_ROOT_PATH = apiRootPath;
|
|
282
|
+
}
|
|
283
|
+
try {
|
|
284
|
+
await timedTelemetry(process.argv, { type: "build" }, async () => {
|
|
285
|
+
const listrTasks = tasks.filter((t) => Boolean(t));
|
|
286
|
+
const jobs = new Listr(listrTasks, {
|
|
287
|
+
renderer: verbose ? "verbose" : void 0
|
|
288
|
+
});
|
|
289
|
+
await jobs.run();
|
|
290
|
+
if (workspace.includes("web") && prerender && prismaSchemaExists) {
|
|
291
|
+
await triggerPrerender(prerenderRoutes);
|
|
292
|
+
}
|
|
128
293
|
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
133
|
-
await timedTelemetry(process.argv, { type: "build" }, async () => {
|
|
134
|
-
await jobs.run();
|
|
135
|
-
if (workspace.includes("web") && prerender && prismaSchemaExists) {
|
|
136
|
-
await triggerPrerender();
|
|
137
|
-
}
|
|
138
|
-
});
|
|
294
|
+
} finally {
|
|
295
|
+
delete process.env.CEDAR_API_ROOT_PATH;
|
|
296
|
+
}
|
|
139
297
|
};
|
|
298
|
+
async function triggerPrerender(prerenderRoutes) {
|
|
299
|
+
const cedarPaths = getPaths();
|
|
300
|
+
console.log("Starting prerendering...");
|
|
301
|
+
if (prerenderRoutes.length === 0) {
|
|
302
|
+
console.log(
|
|
303
|
+
`You have not marked any routes to "prerender" in your ${terminalLink(
|
|
304
|
+
"Routes",
|
|
305
|
+
"file://" + cedarPaths.web.routes
|
|
306
|
+
)}.`
|
|
307
|
+
);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
await runBin("cedar", ["prerender"], {
|
|
311
|
+
stdio: "inherit",
|
|
312
|
+
cwd: cedarPaths.web.base
|
|
313
|
+
});
|
|
314
|
+
}
|
|
140
315
|
export {
|
|
141
316
|
handler
|
|
142
317
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import { runScript } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
4
4
|
import { importStatementPath } from "@cedarjs/project-config";
|
|
5
5
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
6
|
-
import { exitWithError } from "../../lib/exit.js";
|
|
7
6
|
import { getPaths } from "../../lib/index.js";
|
|
8
7
|
async function buildPackagesTask(task, nonApiWebWorkspaces) {
|
|
9
8
|
const cedarPaths = getPaths();
|
|
@@ -11,7 +10,7 @@ async function buildPackagesTask(task, nonApiWebWorkspaces) {
|
|
|
11
10
|
const workspacePaths = nonApiWebWorkspaces.some((w) => w === "packages/*") ? await Array.fromAsync(fs.promises.glob(globPattern)) : nonApiWebWorkspaces.map((w) => {
|
|
12
11
|
const workspacePath = path.join(
|
|
13
12
|
cedarPaths.packages,
|
|
14
|
-
w.split("/").at(-1)
|
|
13
|
+
w.split("/").at(-1) ?? ""
|
|
15
14
|
);
|
|
16
15
|
if (!fs.existsSync(workspacePath)) {
|
|
17
16
|
return "";
|
|
@@ -22,28 +21,30 @@ async function buildPackagesTask(task, nonApiWebWorkspaces) {
|
|
|
22
21
|
task.skip("No packages to build at " + nonApiWebWorkspaces.join(", "));
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
return task.newListr(
|
|
26
25
|
workspacePaths.map((workspacePath) => {
|
|
26
|
+
const name = workspacePath.split("/").at(-1);
|
|
27
27
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
title: name,
|
|
29
|
+
task: async () => {
|
|
30
|
+
try {
|
|
31
|
+
await runScript("build", [], { cwd: workspacePath });
|
|
32
|
+
} catch (e) {
|
|
33
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
34
|
+
const stderr = e instanceof Error && "stderr" in e && typeof e.stderr === "string" ? e.stderr : void 0;
|
|
35
|
+
errorTelemetry(
|
|
36
|
+
process.argv,
|
|
37
|
+
`Error building package "${name}": ${message}`
|
|
38
|
+
);
|
|
39
|
+
throw new Error(`Building "${name}" failed
|
|
40
|
+
|
|
41
|
+
${stderr || message}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
31
44
|
};
|
|
32
45
|
}),
|
|
33
|
-
{
|
|
34
|
-
prefix: "{name} |",
|
|
35
|
-
timestampFormat: "HH:mm:ss"
|
|
36
|
-
}
|
|
46
|
+
{ concurrent: true, rendererOptions: { collapseSubtasks: false } }
|
|
37
47
|
);
|
|
38
|
-
await result.catch((e) => {
|
|
39
|
-
if (e?.message) {
|
|
40
|
-
errorTelemetry(
|
|
41
|
-
process.argv,
|
|
42
|
-
`Error concurrently building sides: ${e.message}`
|
|
43
|
-
);
|
|
44
|
-
exitWithError(e);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
48
|
}
|
|
48
49
|
export {
|
|
49
50
|
buildPackagesTask
|
package/dist/commands/build.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 { exitWithError } from "../lib/exit.js";
|
|
4
4
|
import { workspaces } from "../lib/project.js";
|
|
5
5
|
import { checkNodeVersion } from "../middleware/checkNodeVersion.js";
|
|
@@ -9,7 +9,8 @@ const builder = (yargs) => {
|
|
|
9
9
|
yargs.positional("workspace", {
|
|
10
10
|
default: ["api", "web", "packages/*"],
|
|
11
11
|
description: "What workspace(s) to build. Valid values are: web, api, packages/*, <package-name>",
|
|
12
|
-
type: "
|
|
12
|
+
type: "string",
|
|
13
|
+
array: true
|
|
13
14
|
}).option("verbose", {
|
|
14
15
|
alias: "v",
|
|
15
16
|
default: false,
|
|
@@ -24,6 +25,13 @@ const builder = (yargs) => {
|
|
|
24
25
|
alias: "db",
|
|
25
26
|
default: true,
|
|
26
27
|
description: "Generate the Prisma client"
|
|
28
|
+
}).option("ud", {
|
|
29
|
+
type: "boolean",
|
|
30
|
+
default: false,
|
|
31
|
+
description: "Build the Universal Deploy server entry (api/dist/ud/)."
|
|
32
|
+
}).option("apiRootPath", {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: 'Root path where API functions are served. Overrides the apiRootPath option on cedarUniversalDeployPlugin() in your vite config. Defaults to "/".'
|
|
27
35
|
}).middleware(() => {
|
|
28
36
|
const check = checkNodeVersion();
|
|
29
37
|
if (check.ok) {
|
|
@@ -38,6 +46,9 @@ const builder = (yargs) => {
|
|
|
38
46
|
if (!Array.isArray(workspacesArg)) {
|
|
39
47
|
return "Workspace must be an array";
|
|
40
48
|
}
|
|
49
|
+
if (argv.apiRootPath && !argv.ud) {
|
|
50
|
+
return c.error("Error:") + " --apiRootPath requires --ud.\n Use --ud to build the Universal Deploy server entry.";
|
|
51
|
+
}
|
|
41
52
|
const filtered = workspacesArg.filter(
|
|
42
53
|
(item) => item !== "api" && item !== "web" && item !== "packages/*"
|
|
43
54
|
);
|
package/dist/commands/check.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { getPaths } from "../lib/index.js";
|
|
1
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
4
3
|
const command = "check";
|
|
5
4
|
const aliases = ["diagnostics"];
|
|
6
5
|
const description = "Get structural diagnostics for a Redwood project (experimental)";
|
|
7
6
|
const handler = async () => {
|
|
8
7
|
recordTelemetryAttributes({ command: "check" });
|
|
9
|
-
const { printDiagnostics, DiagnosticSeverity } =
|
|
10
|
-
|
|
11
|
-
printDiagnostics(getPaths().base, {
|
|
8
|
+
const { printDiagnostics, DiagnosticSeverity } = await import("@cedarjs/structure");
|
|
9
|
+
printDiagnostics({
|
|
12
10
|
getSeverityLabel: (severity) => {
|
|
13
11
|
if (severity === DiagnosticSeverity.Error) {
|
|
14
12
|
return c.error("error");
|
package/dist/commands/console.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const command = "console";
|
|
2
2
|
const aliases = ["c"];
|
|
3
|
-
const description = "Launch an interactive
|
|
4
|
-
const handler = async (
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const description = "Launch an interactive Cedar shell";
|
|
4
|
+
const handler = async () => {
|
|
5
|
+
console.log(
|
|
6
|
+
"`cedar console` has been removed from the Cedar CLI.\nRun it as a standalone tool instead:\n\n yarn dlx @cedarjs/console\n npx @cedarjs/console\n pnpm dlx @cedarjs/console\n"
|
|
7
|
+
);
|
|
8
|
+
process.exit(1);
|
|
7
9
|
};
|
|
8
10
|
export {
|
|
9
11
|
aliases,
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { NodeSSH } from "node-ssh";
|
|
2
|
+
class ExecError extends Error {
|
|
3
|
+
exitCode;
|
|
4
|
+
constructor(message, exitCode) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "ExecError";
|
|
7
|
+
this.exitCode = exitCode;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
2
10
|
class SshExecutor {
|
|
11
|
+
ssh;
|
|
12
|
+
verbose;
|
|
3
13
|
constructor(verbose) {
|
|
4
14
|
this.ssh = new NodeSSH();
|
|
5
15
|
this.verbose = verbose;
|
|
@@ -20,12 +30,11 @@ class SshExecutor {
|
|
|
20
30
|
cwd: path
|
|
21
31
|
});
|
|
22
32
|
if (result.code !== 0) {
|
|
23
|
-
|
|
33
|
+
throw new ExecError(
|
|
24
34
|
`Error while running command \`${sshCommand}\` in ${path}
|
|
25
|
-
` + result.stderr
|
|
35
|
+
` + result.stderr,
|
|
36
|
+
result.code
|
|
26
37
|
);
|
|
27
|
-
error.exitCode = result.code;
|
|
28
|
-
throw error;
|
|
29
38
|
}
|
|
30
39
|
return result;
|
|
31
40
|
}
|