@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,11 +1,14 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import boxen from "boxen";
|
|
4
|
+
import execa from "execa";
|
|
4
5
|
import { Listr } from "listr2";
|
|
5
6
|
import * as toml from "smol-toml";
|
|
6
7
|
import { env as envInterpolation } from "string-env-interpolation";
|
|
7
8
|
import { titleCase } from "title-case";
|
|
8
|
-
import c from "
|
|
9
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
10
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
11
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
9
12
|
import { getPaths } from "../../../lib/index.js";
|
|
10
13
|
const CONFIG_FILENAME = "deploy.toml";
|
|
11
14
|
const SYMLINK_FLAGS = "-nsf";
|
|
@@ -14,7 +17,7 @@ const LIFECYCLE_HOOKS = ["before", "after"];
|
|
|
14
17
|
const DEFAULT_SERVER_CONFIG = {
|
|
15
18
|
port: 22,
|
|
16
19
|
branch: "main",
|
|
17
|
-
packageManagerCommand:
|
|
20
|
+
packageManagerCommand: getPackageManager(),
|
|
18
21
|
monitorCommand: "pm2",
|
|
19
22
|
sides: ["api", "web"],
|
|
20
23
|
keepReleases: 5,
|
|
@@ -29,7 +32,7 @@ const throwMissingConfig = (name) => {
|
|
|
29
32
|
const verifyConfig = (config, yargs) => {
|
|
30
33
|
if (!yargs.environment) {
|
|
31
34
|
throw new Error(
|
|
32
|
-
|
|
35
|
+
`Must specify an environment to deploy to, ex: \`${formatCedarCommand(["deploy", "baremetal", "production"])}\``
|
|
33
36
|
);
|
|
34
37
|
}
|
|
35
38
|
if (!config[yargs.environment]) {
|
|
@@ -47,20 +50,20 @@ const verifyServerConfig = (config) => {
|
|
|
47
50
|
if (!config.repo) {
|
|
48
51
|
throwMissingConfig("repo");
|
|
49
52
|
}
|
|
50
|
-
if (!/^\d+$/.test(config.freeSpaceRequired)) {
|
|
53
|
+
if (!/^\d+$/.test(String(config.freeSpaceRequired))) {
|
|
51
54
|
throw new Error('"freeSpaceRequired" must be an integer >= 0');
|
|
52
55
|
}
|
|
53
56
|
return true;
|
|
54
57
|
};
|
|
55
|
-
const symlinkCurrentCommand = async (dir, ssh,
|
|
56
|
-
return await ssh.exec(
|
|
58
|
+
const symlinkCurrentCommand = async (dir, ssh, deployPath) => {
|
|
59
|
+
return await ssh.exec(deployPath, "ln", [
|
|
57
60
|
SYMLINK_FLAGS,
|
|
58
61
|
dir,
|
|
59
62
|
CURRENT_RELEASE_SYMLINK_NAME
|
|
60
63
|
]);
|
|
61
64
|
};
|
|
62
|
-
const restartProcessCommand = async (processName, ssh, serverConfig,
|
|
63
|
-
return await ssh.exec(
|
|
65
|
+
const restartProcessCommand = async (processName, ssh, serverConfig, deployPath) => {
|
|
66
|
+
return await ssh.exec(deployPath, serverConfig.monitorCommand, [
|
|
64
67
|
"restart",
|
|
65
68
|
processName
|
|
66
69
|
]);
|
|
@@ -103,7 +106,7 @@ const maintenanceTasks = (status, ssh, serverConfig) => {
|
|
|
103
106
|
}
|
|
104
107
|
} else if (status === "down") {
|
|
105
108
|
tasks.push({
|
|
106
|
-
title: `Starting ${serverConfig.processNames
|
|
109
|
+
title: `Starting ${serverConfig.processNames?.join(", ")} processes...`,
|
|
107
110
|
task: async () => {
|
|
108
111
|
await ssh.exec(serverConfig.path, serverConfig.monitorCommand, [
|
|
109
112
|
"start",
|
|
@@ -130,7 +133,7 @@ const maintenanceTasks = (status, ssh, serverConfig) => {
|
|
|
130
133
|
};
|
|
131
134
|
const rollbackTasks = (count, ssh, serverConfig) => {
|
|
132
135
|
let rollbackCount = 1;
|
|
133
|
-
if (parseInt(count) === count) {
|
|
136
|
+
if (parseInt(String(count)) === count) {
|
|
134
137
|
rollbackCount = count;
|
|
135
138
|
}
|
|
136
139
|
const tasks = [
|
|
@@ -139,7 +142,7 @@ const rollbackTasks = (count, ssh, serverConfig) => {
|
|
|
139
142
|
task: async () => {
|
|
140
143
|
const currentLink = (await ssh.exec(serverConfig.path, "readlink", ["-f", "current"])).stdout.split("/").pop();
|
|
141
144
|
const dirs = (await ssh.exec(serverConfig.path, "ls", ["-t"])).stdout.split("\n").filter((dirs2) => !dirs2.match(/current/));
|
|
142
|
-
const deployedIndex = dirs.indexOf(currentLink);
|
|
145
|
+
const deployedIndex = dirs.indexOf(currentLink ?? "");
|
|
143
146
|
const rollbackIndex = deployedIndex + rollbackCount;
|
|
144
147
|
if (dirs[rollbackIndex]) {
|
|
145
148
|
console.info("Setting symlink");
|
|
@@ -150,7 +153,7 @@ const rollbackTasks = (count, ssh, serverConfig) => {
|
|
|
150
153
|
);
|
|
151
154
|
} else {
|
|
152
155
|
throw new Error(
|
|
153
|
-
`Cannot rollback ${rollbackCount} release(s): ${dirs.length - dirs.indexOf(currentLink) - 1} previous release(s) available`
|
|
156
|
+
`Cannot rollback ${rollbackCount} release(s): ${dirs.length - dirs.indexOf(currentLink ?? "") - 1} previous release(s) available`
|
|
154
157
|
);
|
|
155
158
|
}
|
|
156
159
|
}
|
|
@@ -188,19 +191,30 @@ const lifecycleTask = (lifecycle, task, skip, { serverLifecycle, ssh, cmdPath })
|
|
|
188
191
|
return tasks;
|
|
189
192
|
}
|
|
190
193
|
};
|
|
191
|
-
const commandWithLifecycleEvents = ({
|
|
194
|
+
const commandWithLifecycleEvents = ({
|
|
195
|
+
name,
|
|
196
|
+
config,
|
|
197
|
+
skip,
|
|
198
|
+
command
|
|
199
|
+
}) => {
|
|
192
200
|
const tasks = [];
|
|
193
201
|
tasks.push(lifecycleTask("before", name, skip, config));
|
|
194
202
|
tasks.push({ ...command, skip: () => skip });
|
|
195
203
|
tasks.push(lifecycleTask("after", name, skip, config));
|
|
196
|
-
return tasks.flat().filter((t) => t);
|
|
204
|
+
return tasks.flat().filter((t) => Boolean(t));
|
|
197
205
|
};
|
|
198
206
|
const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
199
207
|
const cmdPath = pathJoin(serverConfig.path, yargs.releaseDir);
|
|
200
|
-
const config = {
|
|
208
|
+
const config = {
|
|
209
|
+
yargs,
|
|
210
|
+
ssh,
|
|
211
|
+
serverConfig,
|
|
212
|
+
serverLifecycle,
|
|
213
|
+
cmdPath
|
|
214
|
+
};
|
|
201
215
|
const tasks = [];
|
|
202
216
|
tasks.push(
|
|
203
|
-
commandWithLifecycleEvents({
|
|
217
|
+
...commandWithLifecycleEvents({
|
|
204
218
|
name: "df",
|
|
205
219
|
config: { ...config, cmdPath: serverConfig.path },
|
|
206
220
|
skip: !yargs.df || serverConfig.freeSpaceRequired === 0 || serverConfig.freeSpaceRequired === "0",
|
|
@@ -227,7 +241,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
227
241
|
}
|
|
228
242
|
task.output = `Available disk space: ${dfMb}MB`;
|
|
229
243
|
const freeSpaceRequired = parseInt(
|
|
230
|
-
serverConfig.freeSpaceRequired ?? 2048,
|
|
244
|
+
String(serverConfig.freeSpaceRequired ?? 2048),
|
|
231
245
|
10
|
|
232
246
|
);
|
|
233
247
|
if (dfMb < freeSpaceRequired) {
|
|
@@ -240,7 +254,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
240
254
|
})
|
|
241
255
|
);
|
|
242
256
|
tasks.push(
|
|
243
|
-
commandWithLifecycleEvents({
|
|
257
|
+
...commandWithLifecycleEvents({
|
|
244
258
|
name: "update",
|
|
245
259
|
config: { ...config, cmdPath: serverConfig.path },
|
|
246
260
|
skip: !yargs.update,
|
|
@@ -259,7 +273,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
259
273
|
})
|
|
260
274
|
);
|
|
261
275
|
tasks.push(
|
|
262
|
-
commandWithLifecycleEvents({
|
|
276
|
+
...commandWithLifecycleEvents({
|
|
263
277
|
name: "symlinkEnv",
|
|
264
278
|
config,
|
|
265
279
|
skip: !yargs.update,
|
|
@@ -272,7 +286,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
272
286
|
})
|
|
273
287
|
);
|
|
274
288
|
tasks.push(
|
|
275
|
-
commandWithLifecycleEvents({
|
|
289
|
+
...commandWithLifecycleEvents({
|
|
276
290
|
name: "install",
|
|
277
291
|
config,
|
|
278
292
|
skip: !yargs.install,
|
|
@@ -287,7 +301,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
287
301
|
})
|
|
288
302
|
);
|
|
289
303
|
tasks.push(
|
|
290
|
-
commandWithLifecycleEvents({
|
|
304
|
+
...commandWithLifecycleEvents({
|
|
291
305
|
name: "migrate",
|
|
292
306
|
config,
|
|
293
307
|
skip: !yargs.migrate || serverConfig?.migrate === false,
|
|
@@ -295,17 +309,20 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
295
309
|
title: `DB Migrations...`,
|
|
296
310
|
task: async () => {
|
|
297
311
|
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
312
|
+
"exec",
|
|
298
313
|
"cedar",
|
|
299
314
|
"prisma",
|
|
300
315
|
"migrate",
|
|
301
316
|
"deploy"
|
|
302
317
|
]);
|
|
303
318
|
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
319
|
+
"exec",
|
|
304
320
|
"cedar",
|
|
305
321
|
"prisma",
|
|
306
322
|
"generate"
|
|
307
323
|
]);
|
|
308
324
|
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
325
|
+
"exec",
|
|
309
326
|
"cedar",
|
|
310
327
|
"dataMigrate",
|
|
311
328
|
"up"
|
|
@@ -316,7 +333,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
316
333
|
);
|
|
317
334
|
for (const side of serverConfig.sides) {
|
|
318
335
|
tasks.push(
|
|
319
|
-
commandWithLifecycleEvents({
|
|
336
|
+
...commandWithLifecycleEvents({
|
|
320
337
|
name: "build",
|
|
321
338
|
config,
|
|
322
339
|
skip: !yargs.build,
|
|
@@ -324,6 +341,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
324
341
|
title: `Building ${side}...`,
|
|
325
342
|
task: async () => {
|
|
326
343
|
await ssh.exec(cmdPath, serverConfig.packageManagerCommand, [
|
|
344
|
+
"exec",
|
|
327
345
|
"cedar",
|
|
328
346
|
"build",
|
|
329
347
|
side
|
|
@@ -334,7 +352,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
334
352
|
);
|
|
335
353
|
}
|
|
336
354
|
tasks.push(
|
|
337
|
-
commandWithLifecycleEvents({
|
|
355
|
+
...commandWithLifecycleEvents({
|
|
338
356
|
name: "symlinkCurrent",
|
|
339
357
|
config,
|
|
340
358
|
skip: !yargs.update,
|
|
@@ -351,7 +369,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
351
369
|
for (const processName of serverConfig.processNames) {
|
|
352
370
|
if (yargs.firstRun) {
|
|
353
371
|
tasks.push(
|
|
354
|
-
commandWithLifecycleEvents({
|
|
372
|
+
...commandWithLifecycleEvents({
|
|
355
373
|
name: "restart",
|
|
356
374
|
config,
|
|
357
375
|
skip: !yargs.restart,
|
|
@@ -379,7 +397,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
379
397
|
});
|
|
380
398
|
} else {
|
|
381
399
|
tasks.push(
|
|
382
|
-
commandWithLifecycleEvents({
|
|
400
|
+
...commandWithLifecycleEvents({
|
|
383
401
|
name: "restart",
|
|
384
402
|
config,
|
|
385
403
|
skip: !yargs.restart,
|
|
@@ -400,7 +418,7 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
400
418
|
}
|
|
401
419
|
}
|
|
402
420
|
tasks.push(
|
|
403
|
-
commandWithLifecycleEvents({
|
|
421
|
+
...commandWithLifecycleEvents({
|
|
404
422
|
name: "cleanup",
|
|
405
423
|
config: { ...config, cmdPath: serverConfig.path },
|
|
406
424
|
skip: !yargs.cleanup,
|
|
@@ -416,14 +434,15 @@ const deployTasks = (yargs, ssh, serverConfig, serverLifecycle) => {
|
|
|
416
434
|
}
|
|
417
435
|
})
|
|
418
436
|
);
|
|
419
|
-
return tasks
|
|
437
|
+
return tasks;
|
|
420
438
|
};
|
|
421
439
|
const mergeLifecycleEvents = (lifecycle, other) => {
|
|
422
|
-
|
|
440
|
+
const lifecycleCopy = JSON.parse(JSON.stringify(lifecycle));
|
|
423
441
|
for (const hook of LIFECYCLE_HOOKS) {
|
|
424
|
-
|
|
442
|
+
const otherHook = other[hook] ?? {};
|
|
443
|
+
for (const key in otherHook) {
|
|
425
444
|
lifecycleCopy[hook][key] = (lifecycleCopy[hook][key] || []).concat(
|
|
426
|
-
|
|
445
|
+
otherHook[key]
|
|
427
446
|
);
|
|
428
447
|
}
|
|
429
448
|
}
|
|
@@ -432,26 +451,26 @@ const mergeLifecycleEvents = (lifecycle, other) => {
|
|
|
432
451
|
const parseConfig = (yargs, rawConfigToml) => {
|
|
433
452
|
const configToml = envInterpolation(rawConfigToml);
|
|
434
453
|
const config = toml.parse(configToml);
|
|
435
|
-
|
|
436
|
-
const emptyLifecycle = {};
|
|
454
|
+
const emptyLifecycle = { before: {}, after: {} };
|
|
437
455
|
verifyConfig(config, yargs);
|
|
438
|
-
for (const hook of LIFECYCLE_HOOKS) {
|
|
439
|
-
emptyLifecycle[hook] = {};
|
|
440
|
-
}
|
|
441
456
|
let envLifecycle = mergeLifecycleEvents(emptyLifecycle, config);
|
|
442
|
-
envConfig = config[yargs.environment];
|
|
457
|
+
const envConfig = config[yargs.environment];
|
|
443
458
|
envLifecycle = mergeLifecycleEvents(envLifecycle, envConfig);
|
|
444
459
|
return { envConfig, envLifecycle };
|
|
445
460
|
};
|
|
446
461
|
const commands = (yargs, ssh) => {
|
|
447
462
|
const deployConfig = fs.readFileSync(pathJoin(getPaths().base, CONFIG_FILENAME)).toString();
|
|
448
|
-
|
|
449
|
-
|
|
463
|
+
const { envConfig, envLifecycle } = parseConfig(yargs, deployConfig);
|
|
464
|
+
const servers = [];
|
|
450
465
|
let tasks = [];
|
|
451
|
-
|
|
466
|
+
const serverList = envConfig.servers ?? [];
|
|
467
|
+
for (const config of serverList) {
|
|
452
468
|
const serverConfig = serverConfigWithDefaults(config, yargs);
|
|
453
469
|
verifyServerConfig(serverConfig);
|
|
454
|
-
const serverLifecycle = mergeLifecycleEvents(
|
|
470
|
+
const serverLifecycle = mergeLifecycleEvents(
|
|
471
|
+
envLifecycle,
|
|
472
|
+
serverConfig
|
|
473
|
+
);
|
|
455
474
|
tasks.push({
|
|
456
475
|
title: "Connecting...",
|
|
457
476
|
task: () => ssh.connect({
|
|
@@ -460,9 +479,10 @@ const commands = (yargs, ssh) => {
|
|
|
460
479
|
username: serverConfig.username,
|
|
461
480
|
password: serverConfig.password,
|
|
462
481
|
privateKey: serverConfig.privateKey,
|
|
482
|
+
// @ts-expect-error - node-ssh Config doesn't expose privateKeyPath but it is supported at runtime
|
|
463
483
|
privateKeyPath: serverConfig.privateKeyPath,
|
|
464
484
|
passphrase: serverConfig.passphrase,
|
|
465
|
-
agent: serverConfig.agentForward
|
|
485
|
+
agent: serverConfig.agentForward ? process.env.SSH_AUTH_SOCK : void 0,
|
|
466
486
|
agentForward: serverConfig.agentForward
|
|
467
487
|
})
|
|
468
488
|
});
|
|
@@ -481,43 +501,88 @@ const commands = (yargs, ssh) => {
|
|
|
481
501
|
title: "Disconnecting...",
|
|
482
502
|
task: () => ssh.dispose()
|
|
483
503
|
});
|
|
504
|
+
const tasksCopy = [...tasks];
|
|
484
505
|
servers.push({
|
|
485
506
|
title: serverConfig.host,
|
|
486
507
|
task: () => {
|
|
487
|
-
return new Listr(
|
|
508
|
+
return new Listr(tasksCopy);
|
|
488
509
|
}
|
|
489
510
|
});
|
|
511
|
+
tasks = [];
|
|
490
512
|
}
|
|
491
513
|
return servers;
|
|
492
514
|
};
|
|
515
|
+
const warnIfUnpushedCommits = async () => {
|
|
516
|
+
try {
|
|
517
|
+
const { stdout } = await execa("git", ["log", "@{u}..", "--oneline"], {
|
|
518
|
+
cwd: getPaths().base
|
|
519
|
+
});
|
|
520
|
+
const unpushedCommits = stdout.trim();
|
|
521
|
+
if (!unpushedCommits) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
console.warn(
|
|
525
|
+
c.warning("\nWarning: You have local commits that have not been pushed:")
|
|
526
|
+
);
|
|
527
|
+
console.warn(
|
|
528
|
+
unpushedCommits.split("\n").map((line) => ` ${line}`).join("\n")
|
|
529
|
+
);
|
|
530
|
+
console.warn(
|
|
531
|
+
c.warning(
|
|
532
|
+
"The server will pull from the remote, so these commits will not be deployed.\n"
|
|
533
|
+
)
|
|
534
|
+
);
|
|
535
|
+
const { default: prompts } = await import("prompts");
|
|
536
|
+
const { confirmed } = await prompts({
|
|
537
|
+
type: "confirm",
|
|
538
|
+
name: "confirmed",
|
|
539
|
+
message: "Deploy anyway?",
|
|
540
|
+
initial: false
|
|
541
|
+
});
|
|
542
|
+
if (!confirmed) {
|
|
543
|
+
console.log("Aborting deploy. Push your commits and try again.");
|
|
544
|
+
process.exit(1);
|
|
545
|
+
}
|
|
546
|
+
} catch (e) {
|
|
547
|
+
console.error(
|
|
548
|
+
c.error("\nCould not check for unpushed commits before deploying.")
|
|
549
|
+
);
|
|
550
|
+
throw e;
|
|
551
|
+
}
|
|
552
|
+
};
|
|
493
553
|
const handler = async (yargs) => {
|
|
494
554
|
const { SshExecutor } = await import("./SshExecutor.js");
|
|
495
555
|
const tomlPath = path.join(getPaths().base, "deploy.toml");
|
|
496
556
|
const ecosystemPath = path.join(getPaths().base, "ecosystem.config.js");
|
|
497
557
|
if (!fs.existsSync(tomlPath) || !fs.existsSync(ecosystemPath)) {
|
|
498
558
|
console.error(
|
|
499
|
-
c.error("\nError: Baremetal deploy has not been properly setup.\n") +
|
|
559
|
+
c.error("\nError: Baremetal deploy has not been properly setup.\n") + `Please run \`${formatCedarCommand(["setup", "deploy", "baremetal"])}\` before deploying`
|
|
500
560
|
);
|
|
501
561
|
process.exit(1);
|
|
502
562
|
}
|
|
503
|
-
|
|
563
|
+
if (yargs.gitCheck) {
|
|
564
|
+
await warnIfUnpushedCommits();
|
|
565
|
+
}
|
|
566
|
+
const ssh = new SshExecutor(yargs.verbose ?? false);
|
|
504
567
|
try {
|
|
505
|
-
const
|
|
568
|
+
const listrTasks = new Listr(commands(yargs, ssh), {
|
|
506
569
|
concurrent: true,
|
|
507
570
|
exitOnError: true,
|
|
508
|
-
renderer: yargs.verbose
|
|
571
|
+
renderer: yargs.verbose ? "verbose" : void 0
|
|
509
572
|
});
|
|
510
|
-
await
|
|
573
|
+
await listrTasks.run();
|
|
511
574
|
} catch (e) {
|
|
512
575
|
console.error(c.error("\nDeploy failed:"));
|
|
576
|
+
const errMessage = e instanceof Error && "stderr" in e ? e.stderr ?? e.message : e instanceof Error ? e.message : String(e);
|
|
577
|
+
const exitCode = e instanceof Error && "exitCode" in e ? e.exitCode ?? 1 : 1;
|
|
513
578
|
console.error(
|
|
514
|
-
boxen(
|
|
579
|
+
boxen(errMessage, {
|
|
515
580
|
padding: { top: 0, bottom: 0, right: 1, left: 1 },
|
|
516
581
|
margin: 0,
|
|
517
582
|
borderColor: "red"
|
|
518
583
|
})
|
|
519
584
|
);
|
|
520
|
-
process.exit(
|
|
585
|
+
process.exit(exitCode);
|
|
521
586
|
}
|
|
522
587
|
};
|
|
523
588
|
export {
|
|
@@ -533,5 +598,6 @@ export {
|
|
|
533
598
|
serverConfigWithDefaults,
|
|
534
599
|
throwMissingConfig,
|
|
535
600
|
verifyConfig,
|
|
536
|
-
verifyServerConfig
|
|
601
|
+
verifyServerConfig,
|
|
602
|
+
warnIfUnpushedCommits
|
|
537
603
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
3
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
3
4
|
const command = "baremetal [environment]";
|
|
4
5
|
const description = "Deploy to baremetal server(s)";
|
|
5
6
|
const builder = (yargs) => {
|
|
@@ -23,7 +24,7 @@ const builder = (yargs) => {
|
|
|
23
24
|
type: "boolean"
|
|
24
25
|
});
|
|
25
26
|
yargs.option("install", {
|
|
26
|
-
describe:
|
|
27
|
+
describe: `Run \`${getPackageManager()} install\``,
|
|
27
28
|
default: true,
|
|
28
29
|
type: "boolean"
|
|
29
30
|
});
|
|
@@ -70,9 +71,14 @@ const builder = (yargs) => {
|
|
|
70
71
|
default: false,
|
|
71
72
|
type: "boolean"
|
|
72
73
|
});
|
|
74
|
+
yargs.option("git-check", {
|
|
75
|
+
describe: "Check for unpushed commits before deploying",
|
|
76
|
+
default: true,
|
|
77
|
+
type: "boolean"
|
|
78
|
+
});
|
|
73
79
|
yargs.epilogue(
|
|
74
80
|
`Also see the ${terminalLink(
|
|
75
|
-
"
|
|
81
|
+
"Cedar Baremetal Deploy Reference",
|
|
76
82
|
"https://cedarjs.com/docs/cli-commands#deploy"
|
|
77
83
|
)}
|
|
78
84
|
`
|
|
@@ -91,7 +97,8 @@ async function handler(yargs) {
|
|
|
91
97
|
cleanup: yargs.cleanup,
|
|
92
98
|
maintenance: yargs.maintenance,
|
|
93
99
|
rollback: yargs.rollback,
|
|
94
|
-
verbose: yargs.verbose
|
|
100
|
+
verbose: yargs.verbose,
|
|
101
|
+
gitCheck: yargs.gitCheck
|
|
95
102
|
});
|
|
96
103
|
const { handler: baremetalHandler } = await import("./baremetal/baremetalHandler.js");
|
|
97
104
|
return baremetalHandler(yargs);
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
runBin,
|
|
5
|
+
runTransitiveBin,
|
|
6
|
+
runWithNode
|
|
7
|
+
} from "@cedarjs/cli-helpers/packageManager/exec";
|
|
8
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
9
|
import { getPaths } from "@cedarjs/project-config";
|
|
10
|
+
async function runBinWithThrow(bin, args, options) {
|
|
11
|
+
const result = await runBin(bin, args, options);
|
|
12
|
+
if (result.failed) {
|
|
13
|
+
throw new Error(`Command (${bin} ${args.join(" ")}) failed`);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
async function runTransitiveBinWithThrow(bin, args, options) {
|
|
18
|
+
const result = await runTransitiveBin(bin, args, options);
|
|
19
|
+
if (result.failed) {
|
|
20
|
+
throw new Error(`Command (${bin} ${args.join(" ")}) failed`);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
6
24
|
const handler = async ({
|
|
7
25
|
side,
|
|
8
26
|
serve,
|
|
@@ -22,33 +40,28 @@ const handler = async ({
|
|
|
22
40
|
shell: true,
|
|
23
41
|
stdio: "inherit"
|
|
24
42
|
};
|
|
25
|
-
async function runExecaCommand(command) {
|
|
26
|
-
const result = await execa.command(command, execaConfig);
|
|
27
|
-
if (result.failed) {
|
|
28
|
-
throw new Error(`Command (${command}) failed`);
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
43
|
async function runApiCommands() {
|
|
33
44
|
if (!serve) {
|
|
34
45
|
console.log("Building api...");
|
|
35
|
-
await
|
|
46
|
+
await runBinWithThrow("cedar", ["build", "api", "--verbose"], execaConfig);
|
|
36
47
|
if (prisma) {
|
|
37
48
|
console.log("Running database migrations...");
|
|
38
|
-
await
|
|
39
|
-
|
|
49
|
+
await runTransitiveBinWithThrow(
|
|
50
|
+
"prisma",
|
|
51
|
+
["migrate", "deploy", "--config", cedarPaths.api.prismaConfig],
|
|
52
|
+
execaConfig
|
|
40
53
|
);
|
|
41
54
|
}
|
|
42
55
|
if (dataMigrate) {
|
|
43
56
|
console.log("Running data migrations...");
|
|
44
|
-
await
|
|
57
|
+
await runBinWithThrow("cedar", ["dataMigrate", "up"], execaConfig);
|
|
45
58
|
}
|
|
46
59
|
return;
|
|
47
60
|
}
|
|
48
61
|
const serverFilePath = path.join(cedarPaths.api.dist, "server.js");
|
|
49
62
|
const hasServerFile = fs.existsSync(serverFilePath);
|
|
50
63
|
if (hasServerFile) {
|
|
51
|
-
|
|
64
|
+
runWithNode(serverFilePath, execaConfig);
|
|
52
65
|
} else {
|
|
53
66
|
const { handler: handler2 } = await import("@cedarjs/api-server/apiCliConfigHandler");
|
|
54
67
|
handler2();
|
|
@@ -56,7 +69,7 @@ const handler = async ({
|
|
|
56
69
|
}
|
|
57
70
|
async function runWebCommands() {
|
|
58
71
|
console.log("Building web...");
|
|
59
|
-
await
|
|
72
|
+
await runBinWithThrow("cedar", ["build", "web", "--verbose"], execaConfig);
|
|
60
73
|
}
|
|
61
74
|
if (side === "api") {
|
|
62
75
|
await runApiCommands();
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import execa from "execa";
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
3
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
2
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
const deployHandler = ({
|
|
6
|
+
build,
|
|
7
|
+
prisma,
|
|
8
|
+
dm: dataMigrate
|
|
9
|
+
}) => {
|
|
5
10
|
const paths = getPaths();
|
|
6
|
-
|
|
11
|
+
const commandSet = [];
|
|
7
12
|
if (build) {
|
|
8
|
-
commandSet.push("
|
|
13
|
+
commandSet.push(formatCedarCommand(["build", "--verbose"]));
|
|
9
14
|
}
|
|
10
15
|
if (prisma) {
|
|
11
|
-
commandSet.push("
|
|
16
|
+
commandSet.push(formatCedarCommand(["prisma", "migrate", "deploy"]));
|
|
12
17
|
}
|
|
13
18
|
if (dataMigrate) {
|
|
14
|
-
commandSet.push("
|
|
19
|
+
commandSet.push(formatCedarCommand(["data-migrate", "up"]));
|
|
15
20
|
}
|
|
16
21
|
const joinedCommands = commandSet.join(" && ");
|
|
17
22
|
console.log(c.note("\nRunning:\n") + `${joinedCommands}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { deployBuilder } from "./helpers/deployBuilder.js";
|
|
3
3
|
const command = "netlify [...commands]";
|
|
4
4
|
const description = "Build command for Netlify deploy";
|
|
@@ -52,10 +52,9 @@ async function packageSingleFunction(functionFile) {
|
|
|
52
52
|
recursive: true,
|
|
53
53
|
force: true
|
|
54
54
|
});
|
|
55
|
-
return;
|
|
56
55
|
}
|
|
57
56
|
function nftPack() {
|
|
58
|
-
const filesToBePacked = findApiDistFunctions();
|
|
57
|
+
const filesToBePacked = findApiDistFunctions({ cwd: getPaths().api.base });
|
|
59
58
|
return Promise.all(filesToBePacked.map(nftPacker.packageSingleFunction));
|
|
60
59
|
}
|
|
61
60
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
2
|
if (process.argv.slice(2).includes("api")) {
|
|
3
|
-
process.env.
|
|
3
|
+
process.env.CEDAR_DISABLE_TELEMETRY = "1";
|
|
4
4
|
}
|
|
5
5
|
const command = "render <side>";
|
|
6
6
|
const description = "Build, migrate, and serve command for Render deploy";
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { formatAddRootPackagesCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
4
|
+
import {
|
|
5
|
+
runBinSync,
|
|
6
|
+
runTransitiveBinSync,
|
|
7
|
+
runWithNode
|
|
8
|
+
} from "@cedarjs/cli-helpers/packageManager/exec";
|
|
9
|
+
import { installPackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
10
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
11
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
|
-
const handler = async ({
|
|
12
|
+
const handler = async ({
|
|
13
|
+
side,
|
|
14
|
+
prisma,
|
|
15
|
+
dataMigrate
|
|
16
|
+
}) => {
|
|
7
17
|
recordTelemetryAttributes({
|
|
8
18
|
command: "deploy render",
|
|
9
19
|
side,
|
|
@@ -19,8 +29,9 @@ const handler = async ({ side, prisma, dataMigrate }) => {
|
|
|
19
29
|
async function runApiCommands() {
|
|
20
30
|
if (prisma) {
|
|
21
31
|
console.log("Running database migrations...");
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
runTransitiveBinSync(
|
|
33
|
+
"prisma",
|
|
34
|
+
["migrate", "deploy", "--config", cedarPaths.api.prismaConfig],
|
|
24
35
|
execaConfig
|
|
25
36
|
);
|
|
26
37
|
}
|
|
@@ -29,7 +40,7 @@ const handler = async ({ side, prisma, dataMigrate }) => {
|
|
|
29
40
|
const packageJson = JSON.parse(
|
|
30
41
|
fs.readFileSync(path.join(cedarPaths.base, "package.json"), "utf-8")
|
|
31
42
|
);
|
|
32
|
-
const hasDataMigratePackage = !!packageJson.devDependencies["@cedarjs/cli-data-migrate"];
|
|
43
|
+
const hasDataMigratePackage = !!packageJson.devDependencies?.["@cedarjs/cli-data-migrate"];
|
|
33
44
|
if (!hasDataMigratePackage) {
|
|
34
45
|
console.error(
|
|
35
46
|
[
|
|
@@ -38,26 +49,26 @@ const handler = async ({ side, prisma, dataMigrate }) => {
|
|
|
38
49
|
"If you want to run data migrations, add the package to your project's root package.json and deploy again:",
|
|
39
50
|
"",
|
|
40
51
|
"```",
|
|
41
|
-
"
|
|
52
|
+
formatAddRootPackagesCommand(["@cedarjs/cli-data-migrate"], true),
|
|
42
53
|
"```"
|
|
43
54
|
].join("\n")
|
|
44
55
|
);
|
|
45
56
|
} else {
|
|
46
|
-
|
|
57
|
+
runBinSync("cedar", ["dataMigrate", "up"], execaConfig);
|
|
47
58
|
}
|
|
48
59
|
}
|
|
49
60
|
const serverFilePath = path.join(cedarPaths.api.dist, "server.js");
|
|
50
61
|
const hasServerFile = fs.existsSync(serverFilePath);
|
|
51
62
|
if (hasServerFile) {
|
|
52
|
-
|
|
63
|
+
runWithNode(serverFilePath, execaConfig);
|
|
53
64
|
} else {
|
|
54
|
-
const { handler:
|
|
55
|
-
|
|
65
|
+
const { handler: apiHandler } = await import("@cedarjs/api-server/apiCliConfigHandler");
|
|
66
|
+
apiHandler();
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
69
|
async function runWebCommands() {
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
await installPackages(execaConfig);
|
|
71
|
+
runBinSync("cedar", ["build", "web", "--verbose"], execaConfig);
|
|
61
72
|
}
|
|
62
73
|
if (side === "api") {
|
|
63
74
|
runApiCommands();
|