@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
|
@@ -3,17 +3,22 @@ import path from "path";
|
|
|
3
3
|
import prismaInternals from "@prisma/internals";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
5
|
import * as toml from "smol-toml";
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
+
formatCedarCommand,
|
|
9
|
+
formatRunBinCommand
|
|
10
|
+
} from "@cedarjs/cli-helpers/packageManager/display";
|
|
11
|
+
import { isTypeScriptProject } from "@cedarjs/cli-helpers/project";
|
|
12
|
+
import {
|
|
13
|
+
getConfigPath,
|
|
8
14
|
getPaths,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "@cedarjs/cli-helpers";
|
|
15
|
+
getPrismaSchemas
|
|
16
|
+
} from "@cedarjs/project-config";
|
|
12
17
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
13
18
|
import { printSetupNotes } from "../../../../lib/index.js";
|
|
14
19
|
import { serverFileExists } from "../../../../lib/project.js";
|
|
15
20
|
import { addFilesTask } from "../helpers/index.js";
|
|
16
|
-
const {
|
|
21
|
+
const { getConfig } = prismaInternals;
|
|
17
22
|
const cedarPaths = getPaths();
|
|
18
23
|
const EXTENSION = isTypeScriptProject ? "ts" : "js";
|
|
19
24
|
async function handler({ force }) {
|
|
@@ -34,9 +39,11 @@ async function handler({ force }) {
|
|
|
34
39
|
);
|
|
35
40
|
await tasks.run();
|
|
36
41
|
} catch (e) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
43
|
+
errorTelemetry(process.argv, message);
|
|
44
|
+
console.error(c.error(message));
|
|
45
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
46
|
+
process.exit(exitCode);
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
49
|
async function getAddCoherenceFilesTask(force) {
|
|
@@ -46,11 +53,11 @@ async function getAddCoherenceFilesTask(force) {
|
|
|
46
53
|
content: coherenceFiles.healthCheck
|
|
47
54
|
}
|
|
48
55
|
];
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
const coherenceConfigContent = await getCoherenceConfigFileContent();
|
|
57
|
+
files.push({
|
|
58
|
+
path: path.join(cedarPaths.base, "coherence.yml"),
|
|
59
|
+
content: coherenceConfigContent
|
|
60
|
+
});
|
|
54
61
|
return addFilesTask({
|
|
55
62
|
title: `Adding coherence.yml and health.${EXTENSION}`,
|
|
56
63
|
files,
|
|
@@ -58,7 +65,7 @@ async function getAddCoherenceFilesTask(force) {
|
|
|
58
65
|
});
|
|
59
66
|
}
|
|
60
67
|
async function getCoherenceConfigFileContent() {
|
|
61
|
-
const result = await
|
|
68
|
+
const result = await getPrismaSchemas();
|
|
62
69
|
const prismaConfig = await getConfig({ datamodel: result.schemas });
|
|
63
70
|
let db = prismaConfig.datasources[0].activeProvider;
|
|
64
71
|
if (!SUPPORTED_DATABASES.includes(db)) {
|
|
@@ -74,20 +81,34 @@ async function getCoherenceConfigFileContent() {
|
|
|
74
81
|
if (db === "postgresql") {
|
|
75
82
|
db = "postgres";
|
|
76
83
|
}
|
|
77
|
-
const
|
|
84
|
+
const apiProdCommandSegments = [formatCedarCommand(["build", "api"]), "&&"];
|
|
78
85
|
if (serverFileExists()) {
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
"node",
|
|
82
|
-
"api/dist/server.js",
|
|
83
|
-
"--apiRootPath=/api"
|
|
86
|
+
apiProdCommandSegments.push(
|
|
87
|
+
formatRunBinCommand("node", ["api/dist/server.js", "--apiRootPath=/api"])
|
|
84
88
|
);
|
|
85
89
|
} else {
|
|
86
|
-
|
|
90
|
+
apiProdCommandSegments.push(
|
|
91
|
+
formatCedarCommand(["serve", "api", "--apiRootPath=/api"])
|
|
92
|
+
);
|
|
87
93
|
}
|
|
94
|
+
const apiDevCommandSegments = [
|
|
95
|
+
formatCedarCommand(["build", "api"]),
|
|
96
|
+
"&&",
|
|
97
|
+
formatCedarCommand(["dev", "api", "--apiRootPath=/api"])
|
|
98
|
+
];
|
|
99
|
+
const migrationCommandSegments = [
|
|
100
|
+
formatCedarCommand(["prisma", "migrate", "deploy"]),
|
|
101
|
+
"&&",
|
|
102
|
+
formatCedarCommand(["data-migrate", "up"])
|
|
103
|
+
];
|
|
88
104
|
return coherenceFiles.yamlTemplate({
|
|
89
105
|
db,
|
|
90
|
-
apiProdCommand: `[${
|
|
106
|
+
apiProdCommand: `[${apiProdCommandSegments.map((cmd) => `"${cmd}"`).join(", ")}]`,
|
|
107
|
+
apiDevCommand: `[${apiDevCommandSegments.map((cmd) => `"${cmd}"`).join(", ")}]`,
|
|
108
|
+
migrationCommand: `[${migrationCommandSegments.map((cmd) => `"${cmd}"`).join(", ")}]`,
|
|
109
|
+
webProdCommand: `["${formatCedarCommand(["serve", "web"])}"]`,
|
|
110
|
+
webDevCommand: `["${formatCedarCommand(["dev", "web", '--fwd=\\"--allowed-hosts all\\"'])}"]`,
|
|
111
|
+
webBuildCommand: `["${formatCedarCommand(["build", "web", "--no-prerender"])}"]`
|
|
91
112
|
});
|
|
92
113
|
}
|
|
93
114
|
const SUPPORTED_DATABASES = ["mysql", "postgresql"];
|
|
@@ -117,13 +138,13 @@ function updateConfigTomlTask() {
|
|
|
117
138
|
}
|
|
118
139
|
configContent = configContent.replaceAll(
|
|
119
140
|
HOST_REGEXP,
|
|
120
|
-
(
|
|
141
|
+
(_match, spaceBeforeAssign, spaceAfterAssign) => ["host", spaceBeforeAssign, "=", spaceAfterAssign, '"0.0.0.0"'].join(
|
|
121
142
|
""
|
|
122
143
|
)
|
|
123
144
|
);
|
|
124
145
|
configContent = configContent.replace(
|
|
125
146
|
API_URL_REGEXP,
|
|
126
|
-
(
|
|
147
|
+
(_match, spaceBeforeAssign, spaceAfterAssign) => ["apiUrl", spaceBeforeAssign, "=", spaceAfterAssign, '"/api"'].join(
|
|
127
148
|
""
|
|
128
149
|
)
|
|
129
150
|
);
|
|
@@ -145,14 +166,22 @@ const HOST_REGEXP = /host(\s*)=(\s*)\".+\"/g;
|
|
|
145
166
|
const API_URL_REGEXP = /apiUrl(\s*)=(\s*)\".+\"/;
|
|
146
167
|
const PORT_REGEXP = /port(\s*)=(\s*)(?<port>\d{4})/g;
|
|
147
168
|
const coherenceFiles = {
|
|
148
|
-
yamlTemplate({
|
|
169
|
+
yamlTemplate({
|
|
170
|
+
db,
|
|
171
|
+
apiProdCommand,
|
|
172
|
+
apiDevCommand,
|
|
173
|
+
migrationCommand,
|
|
174
|
+
webProdCommand,
|
|
175
|
+
webDevCommand,
|
|
176
|
+
webBuildCommand
|
|
177
|
+
}) {
|
|
149
178
|
return `api:
|
|
150
179
|
type: backend
|
|
151
180
|
url_path: "/api"
|
|
152
181
|
prod:
|
|
153
182
|
command: ${apiProdCommand}
|
|
154
183
|
dev:
|
|
155
|
-
command:
|
|
184
|
+
command: ${apiDevCommand}
|
|
156
185
|
local_packages: ["node_modules"]
|
|
157
186
|
|
|
158
187
|
system:
|
|
@@ -168,20 +197,20 @@ const coherenceFiles = {
|
|
|
168
197
|
${db === "postgres" ? "adapter: postgresql" : ""}
|
|
169
198
|
|
|
170
199
|
# If you use data migrations, use the following instead:
|
|
171
|
-
# migration: ["
|
|
172
|
-
migration:
|
|
200
|
+
# migration: ["${formatCedarCommand(["prisma", "migrate", "deploy"])}", "&&", "${formatCedarCommand(["data-migrate", "up"])}"]
|
|
201
|
+
migration: ${migrationCommand}
|
|
173
202
|
|
|
174
203
|
web:
|
|
175
204
|
type: frontend
|
|
176
205
|
assets_path: "web/dist"
|
|
177
206
|
prod:
|
|
178
|
-
command:
|
|
207
|
+
command: ${webProdCommand}
|
|
179
208
|
dev:
|
|
180
|
-
command:
|
|
209
|
+
command: ${webDevCommand}
|
|
181
210
|
|
|
182
211
|
# Heads up: Redwood's prerender doesn't work with Coherence yet.
|
|
183
212
|
# For current status and updates, see https://github.com/redwoodjs/redwood/issues/8333.
|
|
184
|
-
build:
|
|
213
|
+
build: ${webBuildCommand}
|
|
185
214
|
local_packages: ["node_modules"]
|
|
186
215
|
|
|
187
216
|
system:
|
|
@@ -3,35 +3,33 @@ import { EOL } from "os";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import prismaInternals from "@prisma/internals";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
|
-
import {
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
8
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
9
|
+
import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
|
|
7
10
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
-
import
|
|
11
|
+
import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
|
|
12
|
+
import { getUserApiUrl, updateApiURLTask } from "../helpers/index.js";
|
|
9
13
|
import {
|
|
10
|
-
|
|
11
|
-
writeFilesTask,
|
|
12
|
-
printSetupNotes
|
|
13
|
-
} from "../../../../lib/index.js";
|
|
14
|
-
import { updateApiURLTask } from "../helpers/index.js";
|
|
15
|
-
import {
|
|
16
|
-
flightcontrolConfig,
|
|
14
|
+
getFlightcontrolConfig,
|
|
17
15
|
databaseEnvVariables,
|
|
18
16
|
postgresDatabaseService,
|
|
19
17
|
mysqlDatabaseService
|
|
20
18
|
} from "../templates/flightcontrol.js";
|
|
21
|
-
const {
|
|
19
|
+
const { getConfig } = prismaInternals;
|
|
20
|
+
const APOLLO_PROVIDER_COMPONENT_NAMES = [
|
|
21
|
+
"CedarApolloProvider",
|
|
22
|
+
"RedwoodApolloProvider"
|
|
23
|
+
];
|
|
22
24
|
const getFlightcontrolJson = async (database) => {
|
|
25
|
+
const flightcontrolConfig = getFlightcontrolConfig();
|
|
23
26
|
if (database === "none") {
|
|
24
27
|
return {
|
|
25
28
|
path: path.join(getPaths().base, "flightcontrol.json"),
|
|
26
29
|
content: flightcontrolConfig
|
|
27
30
|
};
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
throw new Error("Could not find prisma schema at 'api/db/schema.prisma'");
|
|
31
|
-
}
|
|
32
|
-
const result = await getSchemaWithPath(
|
|
33
|
-
path.join(getPaths().base, "api/db/schema.prisma")
|
|
34
|
-
);
|
|
32
|
+
const result = await getPrismaSchemas();
|
|
35
33
|
const config = await getConfig({ datamodel: result.schemas });
|
|
36
34
|
const detectedDatabase = config.datasources[0].activeProvider;
|
|
37
35
|
if (detectedDatabase === database) {
|
|
@@ -55,18 +53,20 @@ const getFlightcontrolJson = async (database) => {
|
|
|
55
53
|
{
|
|
56
54
|
...flightcontrolConfig.environments[0],
|
|
57
55
|
services: [
|
|
58
|
-
...flightcontrolConfig.environments[0].services.map(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
...flightcontrolConfig.environments[0].services.map(
|
|
57
|
+
(service) => {
|
|
58
|
+
if (service.id === "cedar-api") {
|
|
59
|
+
return {
|
|
60
|
+
...service,
|
|
61
|
+
envVariables: {
|
|
62
|
+
...service.envVariables,
|
|
63
|
+
...databaseEnvVariables
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return service;
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
}),
|
|
69
|
+
),
|
|
70
70
|
dbService
|
|
71
71
|
]
|
|
72
72
|
}
|
|
@@ -78,15 +78,15 @@ const getFlightcontrolJson = async (database) => {
|
|
|
78
78
|
Prisma datasource provider is detected to be ${detectedDatabase}.
|
|
79
79
|
|
|
80
80
|
Update your schema.prisma provider to be postgresql or mysql, then run
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
${formatCedarCommand(["prisma", "migrate", "dev"])}
|
|
82
|
+
${formatCedarCommand(["setup", "deploy", "flightcontrol"])}
|
|
83
83
|
`);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
const updateGraphQLFunction = () => {
|
|
87
87
|
return {
|
|
88
88
|
title: "Adding CORS config to createGraphQLHandler...",
|
|
89
|
-
task: (
|
|
89
|
+
task: () => {
|
|
90
90
|
const graphqlTsPath = path.join(
|
|
91
91
|
getPaths().base,
|
|
92
92
|
"api/src/functions/graphql.ts"
|
|
@@ -105,7 +105,7 @@ const updateGraphQLFunction = () => {
|
|
|
105
105
|
Couldn't find graphql handler in api/src/functions/graphql.js.
|
|
106
106
|
You'll have to add the following cors config manually:
|
|
107
107
|
|
|
108
|
-
cors: { origin: process.env.
|
|
108
|
+
cors: { origin: process.env.CEDAR_WEB_URL, credentials: true}
|
|
109
109
|
`);
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
@@ -118,14 +118,14 @@ const updateGraphQLFunction = () => {
|
|
|
118
118
|
Couldn't find graphql handler in api/src/functions/graphql.js.
|
|
119
119
|
You'll have to add the following cors config manually:
|
|
120
120
|
|
|
121
|
-
cors: { origin: process.env.
|
|
121
|
+
cors: { origin: process.env.CEDAR_WEB_URL, credentials: true}
|
|
122
122
|
`);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
graphqlContent.splice(
|
|
126
126
|
graphqlHanderIndex + 1,
|
|
127
127
|
0,
|
|
128
|
-
" cors: { origin: process.env.
|
|
128
|
+
" cors: { origin: process.env.CEDAR_WEB_URL, credentials: true },"
|
|
129
129
|
);
|
|
130
130
|
fs.writeFileSync(graphqlFunctionsPath, graphqlContent.join(EOL));
|
|
131
131
|
}
|
|
@@ -134,7 +134,7 @@ const updateGraphQLFunction = () => {
|
|
|
134
134
|
const updateDbAuth = () => {
|
|
135
135
|
return {
|
|
136
136
|
title: "Updating dbAuth cookie config (if used)...",
|
|
137
|
-
task: (
|
|
137
|
+
task: () => {
|
|
138
138
|
const authTsPath = path.join(getPaths().base, "api/src/functions/auth.ts");
|
|
139
139
|
const authJsPath = path.join(getPaths().base, "api/src/functions/auth.js");
|
|
140
140
|
let authFnPath;
|
|
@@ -167,14 +167,14 @@ const updateDbAuth = () => {
|
|
|
167
167
|
Couldn't find DbAuthHandler in api/src/functions/auth.js.
|
|
168
168
|
You'll have to add the following cors config manually:
|
|
169
169
|
|
|
170
|
-
cors: { origin: process.env.
|
|
170
|
+
cors: { origin: process.env.CEDAR_WEB_URL, credentials: true}
|
|
171
171
|
`);
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
authContent.splice(
|
|
175
175
|
dbHandlerIndex + 1,
|
|
176
176
|
0,
|
|
177
|
-
" cors: { origin: process.env.
|
|
177
|
+
" cors: { origin: process.env.CEDAR_WEB_URL, credentials: true },"
|
|
178
178
|
);
|
|
179
179
|
fs.writeFileSync(authFnPath, authContent.join(EOL));
|
|
180
180
|
}
|
|
@@ -183,7 +183,7 @@ const updateDbAuth = () => {
|
|
|
183
183
|
const updateApp = () => {
|
|
184
184
|
return {
|
|
185
185
|
title: "Updating App.jsx fetch config...",
|
|
186
|
-
task: (
|
|
186
|
+
task: () => {
|
|
187
187
|
const appTsPath = path.join(getPaths().base, "web/src/App.tsx");
|
|
188
188
|
const appJsPath = path.join(getPaths().base, "web/src/App.jsx");
|
|
189
189
|
let appPath;
|
|
@@ -210,18 +210,26 @@ const updateApp = () => {
|
|
|
210
210
|
appContent[authLineIndex] = ` <AuthProvider type="dbAuth" config={{ fetchConfig: { credentials: 'include' } }}>
|
|
211
211
|
`;
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
)
|
|
213
|
+
let gqlLineIndex = -1;
|
|
214
|
+
let apolloProviderComponentName = "";
|
|
215
|
+
for (const componentName of APOLLO_PROVIDER_COMPONENT_NAMES) {
|
|
216
|
+
gqlLineIndex = appContent.findIndex(
|
|
217
|
+
(line) => line.includes(`<${componentName}`)
|
|
218
|
+
);
|
|
219
|
+
if (gqlLineIndex !== -1) {
|
|
220
|
+
apolloProviderComponentName = componentName;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
216
224
|
if (gqlLineIndex === -1) {
|
|
217
225
|
console.log(`
|
|
218
|
-
Couldn't find <
|
|
226
|
+
Couldn't find <CedarApolloProvider in web/src/App.js
|
|
219
227
|
If (and when) you use *dbAuth*, you'll have to add the following fetch config manually:
|
|
220
228
|
|
|
221
229
|
graphQLClientConfig={{ httpLinkConfig: { credentials: 'include' }}}
|
|
222
230
|
`);
|
|
223
231
|
} else if (appContent.toString().match(/dbAuth/)) {
|
|
224
|
-
appContent[gqlLineIndex] = `
|
|
232
|
+
appContent[gqlLineIndex] = ` <${apolloProviderComponentName} graphQLClientConfig={{ httpLinkConfig: { credentials: 'include' }}} >
|
|
225
233
|
`;
|
|
226
234
|
}
|
|
227
235
|
fs.writeFileSync(appPath, appContent.join(EOL));
|
|
@@ -238,13 +246,18 @@ const addToDotEnvDefaultTask = () => {
|
|
|
238
246
|
|
|
239
247
|
You'll have to add the following env var manually:
|
|
240
248
|
|
|
241
|
-
|
|
249
|
+
CEDAR_API_URL=${getUserApiUrl()}
|
|
242
250
|
`;
|
|
243
251
|
}
|
|
252
|
+
return void 0;
|
|
244
253
|
},
|
|
245
|
-
task: async (
|
|
254
|
+
task: async () => {
|
|
246
255
|
const env = path.resolve(getPaths().base, ".env.defaults");
|
|
247
|
-
const
|
|
256
|
+
const apiUrl = getUserApiUrl();
|
|
257
|
+
const line = `
|
|
258
|
+
|
|
259
|
+
CEDAR_API_URL=${apiUrl}
|
|
260
|
+
`;
|
|
248
261
|
fs.appendFileSync(env, line);
|
|
249
262
|
}
|
|
250
263
|
};
|
|
@@ -255,7 +268,10 @@ const notes = [
|
|
|
255
268
|
"Check out the deployment docs at https://app.flightcontrol.dev/docs for detailed instructions\n",
|
|
256
269
|
"NOTE: If you are using yarn v1, remove the installCommand's from flightcontrol.json"
|
|
257
270
|
];
|
|
258
|
-
const handler = async ({
|
|
271
|
+
const handler = async ({
|
|
272
|
+
force,
|
|
273
|
+
database
|
|
274
|
+
}) => {
|
|
259
275
|
recordTelemetryAttributes({
|
|
260
276
|
command: "setup deploy flightcontrol",
|
|
261
277
|
force,
|
|
@@ -267,7 +283,7 @@ const handler = async ({ force, database }) => {
|
|
|
267
283
|
title: "Adding flightcontrol.json",
|
|
268
284
|
task: async () => {
|
|
269
285
|
const fileData = await getFlightcontrolJson(database);
|
|
270
|
-
|
|
286
|
+
const files = {};
|
|
271
287
|
files[fileData.path] = JSON.stringify(fileData.content, null, 2);
|
|
272
288
|
return writeFilesTask(files, { overwriteExisting: force });
|
|
273
289
|
}
|
|
@@ -275,7 +291,7 @@ const handler = async ({ force, database }) => {
|
|
|
275
291
|
updateGraphQLFunction(),
|
|
276
292
|
updateDbAuth(),
|
|
277
293
|
updateApp(),
|
|
278
|
-
updateApiURLTask("${
|
|
294
|
+
updateApiURLTask("${CEDAR_API_URL}"),
|
|
279
295
|
addToDotEnvDefaultTask(),
|
|
280
296
|
printSetupNotes(notes)
|
|
281
297
|
],
|
|
@@ -284,9 +300,11 @@ const handler = async ({ force, database }) => {
|
|
|
284
300
|
try {
|
|
285
301
|
await tasks.run();
|
|
286
302
|
} catch (e) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
303
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
304
|
+
errorTelemetry(process.argv, message);
|
|
305
|
+
console.error(c.error(message));
|
|
306
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
307
|
+
process.exit(exitCode);
|
|
290
308
|
}
|
|
291
309
|
};
|
|
292
310
|
export {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { createHandler } from "../helpers/helpers.js";
|
|
2
2
|
const command = "netlify";
|
|
3
3
|
const description = "Setup Netlify deploy";
|
|
4
|
+
const builder = (yargs) => yargs.option("ud", {
|
|
5
|
+
description: "Setup for use with Universal Deploy",
|
|
6
|
+
type: "boolean",
|
|
7
|
+
default: false
|
|
8
|
+
});
|
|
4
9
|
const handler = createHandler("netlify");
|
|
5
10
|
export {
|
|
11
|
+
builder,
|
|
6
12
|
command,
|
|
7
13
|
description,
|
|
8
14
|
handler
|
|
@@ -1,40 +1,141 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "path";
|
|
2
3
|
import { Listr } from "listr2";
|
|
3
|
-
import {
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
4
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
import {
|
|
9
|
+
addPackagesTask,
|
|
10
|
+
getPaths,
|
|
11
|
+
printSetupNotes
|
|
12
|
+
} from "../../../../lib/index.js";
|
|
13
|
+
import {
|
|
14
|
+
addFilesTask,
|
|
15
|
+
insertPluginsBeforeCedar,
|
|
16
|
+
updateApiURLTask,
|
|
17
|
+
verifyUDSetupTask
|
|
18
|
+
} from "../helpers/index.js";
|
|
8
19
|
import { NETLIFY_TOML } from "../templates/netlify.js";
|
|
20
|
+
import { NETLIFY_UD_TOML } from "../templates/netlifyUD.js";
|
|
9
21
|
const files = [
|
|
10
22
|
{
|
|
11
23
|
path: path.join(getPaths().base, "netlify.toml"),
|
|
12
24
|
content: NETLIFY_TOML
|
|
13
25
|
}
|
|
14
26
|
];
|
|
27
|
+
const filesUd = [
|
|
28
|
+
{
|
|
29
|
+
path: path.join(getPaths().base, "netlify.toml"),
|
|
30
|
+
content: NETLIFY_UD_TOML
|
|
31
|
+
}
|
|
32
|
+
];
|
|
15
33
|
const notes = [
|
|
16
34
|
"You are ready to deploy to Netlify!",
|
|
17
35
|
"See: https://cedarjs.com/docs/deploy/netlify"
|
|
18
36
|
];
|
|
19
|
-
const
|
|
37
|
+
const udNotes = [
|
|
38
|
+
"You are ready to deploy to Netlify with Universal Deploy!",
|
|
39
|
+
`Build with: ${formatCedarCommand(["build", "--ud"])}`,
|
|
40
|
+
"See: https://cedarjs.com/docs/deploy/netlify"
|
|
41
|
+
];
|
|
42
|
+
function addNetlifyPluginsToViteConfigTask() {
|
|
43
|
+
return {
|
|
44
|
+
title: "Adding Netlify plugins to vite config...",
|
|
45
|
+
task: async (_ctx, task) => {
|
|
46
|
+
const paths = getPaths();
|
|
47
|
+
const viteConfigTs = path.join(paths.web.base, "vite.config.ts");
|
|
48
|
+
const viteConfigJs = path.join(paths.web.base, "vite.config.js");
|
|
49
|
+
const viteConfigPath = fs.existsSync(viteConfigTs) ? viteConfigTs : viteConfigJs;
|
|
50
|
+
if (!fs.existsSync(viteConfigPath)) {
|
|
51
|
+
task.skip(`${viteConfigPath} not found`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
let content = fs.readFileSync(viteConfigPath, "utf-8");
|
|
55
|
+
const hasNetlifyPlugin = content.includes("@netlify/vite-plugin");
|
|
56
|
+
const hasNetlifyCompat = content.includes(
|
|
57
|
+
"@universal-deploy/netlify/vite"
|
|
58
|
+
);
|
|
59
|
+
if (hasNetlifyPlugin && hasNetlifyCompat && content.includes("netlifyCompat(")) {
|
|
60
|
+
task.skip("Netlify plugins are already configured.");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!hasNetlifyPlugin || !hasNetlifyCompat) {
|
|
64
|
+
const newContent = content.replace(
|
|
65
|
+
/(import\s+\{[^}]*\}\s+from\s+['"]vite['"];?)/,
|
|
66
|
+
(match) => {
|
|
67
|
+
let result = match;
|
|
68
|
+
if (!hasNetlifyPlugin) {
|
|
69
|
+
result = `import netlify from '@netlify/vite-plugin'
|
|
70
|
+
${result}`;
|
|
71
|
+
}
|
|
72
|
+
if (!hasNetlifyCompat) {
|
|
73
|
+
result = `import netlifyCompat from '@universal-deploy/netlify/vite'
|
|
74
|
+
${result}`;
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
if (newContent === content) {
|
|
80
|
+
let prepend = "";
|
|
81
|
+
if (!hasNetlifyPlugin) {
|
|
82
|
+
prepend += "import netlify from '@netlify/vite-plugin'\n";
|
|
83
|
+
}
|
|
84
|
+
if (!hasNetlifyCompat) {
|
|
85
|
+
prepend += "import netlifyCompat from '@universal-deploy/netlify/vite'\n";
|
|
86
|
+
}
|
|
87
|
+
content = prepend + content;
|
|
88
|
+
} else {
|
|
89
|
+
content = newContent;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!content.includes("netlifyCompat(")) {
|
|
93
|
+
const result = insertPluginsBeforeCedar({
|
|
94
|
+
content,
|
|
95
|
+
pluginCodes: [
|
|
96
|
+
"netlify({ build: { enabled: true } })",
|
|
97
|
+
"netlifyCompat()"
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
if (result) {
|
|
101
|
+
content = result;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
fs.writeFileSync(viteConfigPath, content);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function installNetlifyPackagesTask() {
|
|
109
|
+
return addPackagesTask({
|
|
110
|
+
packages: ["@netlify/vite-plugin", "@universal-deploy/netlify"],
|
|
111
|
+
devDependency: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const handler = async ({ force, ud }) => {
|
|
20
115
|
recordTelemetryAttributes({
|
|
21
116
|
command: "setup deploy netlify",
|
|
22
|
-
force
|
|
117
|
+
force,
|
|
118
|
+
ud
|
|
23
119
|
});
|
|
24
120
|
const tasks = new Listr(
|
|
25
121
|
[
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
122
|
+
ud && verifyUDSetupTask(),
|
|
123
|
+
ud && await installNetlifyPackagesTask(),
|
|
124
|
+
ud && addNetlifyPluginsToViteConfigTask(),
|
|
125
|
+
!ud && updateApiURLTask("/.netlify/functions"),
|
|
126
|
+
addFilesTask({ files: ud ? filesUd : files, force }),
|
|
127
|
+
printSetupNotes(ud ? udNotes : notes)
|
|
128
|
+
].filter((task) => Boolean(task)),
|
|
30
129
|
{ rendererOptions: { collapseSubtasks: false } }
|
|
31
130
|
);
|
|
32
131
|
try {
|
|
33
132
|
await tasks.run();
|
|
34
133
|
} catch (e) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
134
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
135
|
+
errorTelemetry(process.argv, message);
|
|
136
|
+
console.error(c.error(message));
|
|
137
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
138
|
+
process.exit(exitCode);
|
|
38
139
|
}
|
|
39
140
|
};
|
|
40
141
|
export {
|