@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
|
@@ -6,24 +6,40 @@ import { config } from "dotenv-defaults";
|
|
|
6
6
|
import execa from "execa";
|
|
7
7
|
import { Listr } from "listr2";
|
|
8
8
|
import prompts from "prompts";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
9
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
10
|
+
import {
|
|
11
|
+
formatAddRootPackagesCommand,
|
|
12
|
+
formatRunBinCommand
|
|
13
|
+
} from "@cedarjs/cli-helpers/packageManager/display";
|
|
14
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
15
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
11
16
|
import { getPaths } from "../../lib/index.js";
|
|
12
17
|
const preRequisites = () => [
|
|
13
18
|
{
|
|
14
19
|
title: "Checking if Serverless framework is installed...",
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
task: async () => {
|
|
21
|
+
try {
|
|
22
|
+
await runBin("serverless", ["--version"], { shell: true });
|
|
23
|
+
} catch (error) {
|
|
24
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
25
|
+
throw new Error(
|
|
26
|
+
`${msg}
|
|
27
|
+
Looks like Serverless is not installed.
|
|
28
|
+
Please run ${formatAddRootPackagesCommand(["serverless"], true)}.`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
33
|
];
|
|
22
|
-
const buildCommands = ({
|
|
34
|
+
const buildCommands = ({
|
|
35
|
+
sides
|
|
36
|
+
}) => {
|
|
23
37
|
return [
|
|
24
38
|
{
|
|
25
39
|
title: `Building ${sides.join(" & ")}...`,
|
|
26
|
-
|
|
40
|
+
task: async () => {
|
|
41
|
+
await runBin("cedar", ["build", ...sides], { shell: true });
|
|
42
|
+
}
|
|
27
43
|
},
|
|
28
44
|
{
|
|
29
45
|
title: "Packing Functions...",
|
|
@@ -35,13 +51,18 @@ const buildCommands = ({ sides }) => {
|
|
|
35
51
|
}
|
|
36
52
|
];
|
|
37
53
|
};
|
|
38
|
-
const deployCommands = ({
|
|
54
|
+
const deployCommands = ({
|
|
55
|
+
stage,
|
|
56
|
+
sides,
|
|
57
|
+
firstRun,
|
|
58
|
+
packOnly
|
|
59
|
+
}) => {
|
|
39
60
|
const slsStage = stage ? ["--stage", stage] : [];
|
|
40
61
|
return sides.map((side) => {
|
|
41
62
|
return {
|
|
42
63
|
title: `Deploying ${side}....`,
|
|
43
64
|
task: async () => {
|
|
44
|
-
await
|
|
65
|
+
await runBin("serverless", ["deploy", ...slsStage], {
|
|
45
66
|
cwd: path.join(getPaths().base, side),
|
|
46
67
|
shell: true,
|
|
47
68
|
stdio: "inherit",
|
|
@@ -55,6 +76,7 @@ const deployCommands = ({ stage, sides, firstRun, packOnly }) => {
|
|
|
55
76
|
if (packOnly) {
|
|
56
77
|
return "Finishing early due to --pack-only flag. Your Redwood project is packaged and ready to deploy";
|
|
57
78
|
}
|
|
79
|
+
return false;
|
|
58
80
|
}
|
|
59
81
|
};
|
|
60
82
|
});
|
|
@@ -79,13 +101,13 @@ const handler = async (yargs) => {
|
|
|
79
101
|
loadDotEnvForStage(dotEnvPath);
|
|
80
102
|
const tasks = new Listr(
|
|
81
103
|
[
|
|
82
|
-
...preRequisites(
|
|
104
|
+
...preRequisites().map(mapCommandsToListr),
|
|
83
105
|
...buildCommands(yargs).map(mapCommandsToListr),
|
|
84
106
|
...deployCommands(yargs).map(mapCommandsToListr)
|
|
85
107
|
],
|
|
86
108
|
{
|
|
87
109
|
exitOnError: true,
|
|
88
|
-
renderer: yargs.verbose
|
|
110
|
+
renderer: yargs.verbose ? "verbose" : void 0
|
|
89
111
|
}
|
|
90
112
|
);
|
|
91
113
|
try {
|
|
@@ -94,14 +116,21 @@ const handler = async (yargs) => {
|
|
|
94
116
|
const SETUP_MARKER = ansis.bgBlue.black("First Setup ");
|
|
95
117
|
console.log();
|
|
96
118
|
console.log(SETUP_MARKER, c.success("Starting first setup wizard..."));
|
|
97
|
-
const { stdout: slsInfo } = await
|
|
98
|
-
|
|
119
|
+
const { stdout: slsInfo } = await runBin(
|
|
120
|
+
"serverless",
|
|
121
|
+
["info", "--verbose", `--stage=${yargs.stage}`],
|
|
99
122
|
{
|
|
100
123
|
shell: true,
|
|
101
124
|
cwd: getPaths().api.base
|
|
102
125
|
}
|
|
103
126
|
);
|
|
104
|
-
const
|
|
127
|
+
const apiMatch = slsInfo.match(/HttpApiUrl: (https:\/\/.*)/);
|
|
128
|
+
if (!apiMatch) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
"Could not find HttpApiUrl in serverless info output. Deploy may have failed."
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
const deployedApiUrl = apiMatch[1];
|
|
105
134
|
console.log();
|
|
106
135
|
console.log(SETUP_MARKER, `Found ${c.success(deployedApiUrl)}`);
|
|
107
136
|
console.log();
|
|
@@ -125,7 +154,7 @@ const handler = async (yargs) => {
|
|
|
125
154
|
const webDeployTasks = new Listr(
|
|
126
155
|
[
|
|
127
156
|
// Rebuild web with the new API_URL
|
|
128
|
-
...buildCommands({ ...yargs, sides: ["web"]
|
|
157
|
+
...buildCommands({ ...yargs, sides: ["web"] }).map(
|
|
129
158
|
mapCommandsToListr
|
|
130
159
|
),
|
|
131
160
|
...deployCommands({
|
|
@@ -136,25 +165,32 @@ const handler = async (yargs) => {
|
|
|
136
165
|
],
|
|
137
166
|
{
|
|
138
167
|
exitOnError: true,
|
|
139
|
-
renderer: yargs.verbose
|
|
168
|
+
renderer: yargs.verbose ? "verbose" : void 0
|
|
140
169
|
}
|
|
141
170
|
);
|
|
142
171
|
await webDeployTasks.run();
|
|
143
|
-
const { stdout:
|
|
144
|
-
|
|
172
|
+
const { stdout: webSlsInfo } = await runBin(
|
|
173
|
+
"serverless",
|
|
174
|
+
["info", "--verbose", `--stage=${yargs.stage}`],
|
|
145
175
|
{
|
|
146
176
|
shell: true,
|
|
147
177
|
cwd: getPaths().web.base
|
|
148
178
|
}
|
|
149
179
|
);
|
|
150
|
-
const
|
|
180
|
+
const webMatch = webSlsInfo.match(/url: (https:\/\/.*)/);
|
|
181
|
+
if (!webMatch) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
"Could not find url in serverless info output. Deploy may have failed."
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const deployedWebUrl = webMatch[1];
|
|
151
187
|
const message = [
|
|
152
188
|
c.bold("Successful first deploy!"),
|
|
153
189
|
"",
|
|
154
190
|
`View your deployed site at: ${c.success(deployedWebUrl)}`,
|
|
155
191
|
"",
|
|
156
192
|
"You can use serverless.com CI/CD by connecting/creating an app",
|
|
157
|
-
|
|
193
|
+
`To do this run \`${formatRunBinCommand("serverless")}\` on each of the sides, and connect your account`,
|
|
158
194
|
"",
|
|
159
195
|
"Find more information in our docs:",
|
|
160
196
|
c.underline("https://cedarjs.com/docs/deploy#serverless")
|
|
@@ -169,8 +205,9 @@ const handler = async (yargs) => {
|
|
|
169
205
|
}
|
|
170
206
|
}
|
|
171
207
|
} catch (e) {
|
|
172
|
-
console.error(c.error(e.message));
|
|
173
|
-
|
|
208
|
+
console.error(c.error(e instanceof Error ? e.message : String(e)));
|
|
209
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
210
|
+
process.exit(exitCode);
|
|
174
211
|
}
|
|
175
212
|
};
|
|
176
213
|
const mapCommandsToListr = ({
|
|
@@ -186,14 +223,19 @@ const mapCommandsToListr = ({
|
|
|
186
223
|
title,
|
|
187
224
|
task: task ? task : async () => {
|
|
188
225
|
try {
|
|
189
|
-
|
|
226
|
+
if (!command) {
|
|
227
|
+
throw new Error(
|
|
228
|
+
"No command or task provided to mapCommandsToListr"
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
const executingCommand = execa(command[0], command[1], {
|
|
190
232
|
cwd: cwd || getPaths().base,
|
|
191
233
|
shell: true
|
|
192
234
|
});
|
|
193
|
-
executingCommand.stdout
|
|
235
|
+
executingCommand.stdout?.pipe(process.stdout);
|
|
194
236
|
await executingCommand;
|
|
195
237
|
} catch (error) {
|
|
196
|
-
if (errorMessage) {
|
|
238
|
+
if (errorMessage && error instanceof Error) {
|
|
197
239
|
error.message = error.message + "\n" + errorMessage.join(" ");
|
|
198
240
|
}
|
|
199
241
|
throw error;
|
|
@@ -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 = "vercel [...commands]";
|
|
4
4
|
const description = "Build command for Vercel deploy";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHandler, createYargsForComponentDestroy } from "../helpers.js";
|
|
2
2
|
const description = "Destroy a component";
|
|
3
|
-
const { command, builder
|
|
3
|
+
const { command, builder } = createYargsForComponentDestroy({
|
|
4
4
|
componentName: "component"
|
|
5
5
|
});
|
|
6
6
|
const handler = createHandler("component");
|
|
@@ -8,6 +8,5 @@ export {
|
|
|
8
8
|
builder,
|
|
9
9
|
command,
|
|
10
10
|
description,
|
|
11
|
-
handler
|
|
12
|
-
tasks
|
|
11
|
+
handler
|
|
13
12
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { files as directiveFiles } from "../../generate/directive/directiveHandler.js";
|
|
2
1
|
import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
|
|
3
2
|
const description = "Destroy a directive";
|
|
4
3
|
const { command, builder } = createYargsForComponentDestroy({
|
|
5
|
-
componentName: "directive"
|
|
6
|
-
filesFn: (args) => directiveFiles({ ...args, type: "validator" })
|
|
4
|
+
componentName: "directive"
|
|
7
5
|
});
|
|
8
6
|
const handler = createHandler("directive");
|
|
9
7
|
export {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { files as directiveFiles } from "../../generate/directive/directiveHandler.js";
|
|
2
2
|
import { createHandler } from "../handlerHelpers.js";
|
|
3
|
-
const
|
|
4
|
-
const { builder, tasks } = createHandler({
|
|
3
|
+
const { handler, tasks } = createHandler({
|
|
5
4
|
componentName: "directive",
|
|
6
5
|
filesFn: (args) => directiveFiles({ ...args, type: "validator" })
|
|
7
6
|
});
|
|
8
7
|
export {
|
|
9
|
-
|
|
10
|
-
description,
|
|
8
|
+
handler,
|
|
11
9
|
tasks
|
|
12
10
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { files as functionFiles } from "../../generate/function/functionHandler.js";
|
|
2
1
|
import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
|
|
3
2
|
const description = "Destroy a Function";
|
|
4
3
|
const builder = (yargs) => {
|
|
@@ -8,8 +7,7 @@ const builder = (yargs) => {
|
|
|
8
7
|
});
|
|
9
8
|
};
|
|
10
9
|
const { command } = createYargsForComponentDestroy({
|
|
11
|
-
componentName: "function"
|
|
12
|
-
filesFn: functionFiles
|
|
10
|
+
componentName: "function"
|
|
13
11
|
});
|
|
14
12
|
const handler = createHandler("function");
|
|
15
13
|
export {
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { Listr } from "listr2";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
3
3
|
import { deleteFilesTask } from "../../lib/index.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
function tasks({ componentName, filesFn, name }) {
|
|
5
|
+
return new Listr(
|
|
6
|
+
[
|
|
7
|
+
{
|
|
8
|
+
title: `Destroying ${componentName} files...`,
|
|
9
|
+
task: async () => {
|
|
10
|
+
const f = await filesFn({ name, stories: true, tests: true });
|
|
11
|
+
return deleteFilesTask(f);
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
],
|
|
15
|
+
{ rendererOptions: { collapseSubtasks: false }, exitOnError: true }
|
|
16
|
+
);
|
|
17
|
+
}
|
|
16
18
|
function createHandler({
|
|
17
19
|
componentName,
|
|
18
20
|
preTasksFn = (options) => options,
|
|
@@ -20,11 +22,9 @@ function createHandler({
|
|
|
20
22
|
}) {
|
|
21
23
|
return {
|
|
22
24
|
handler: async (options) => {
|
|
23
|
-
recordTelemetryAttributes({
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
options = await preTasksFn({ ...options, isDestroyer: true });
|
|
27
|
-
await tasks({ componentName, filesFn, name: options.name }).run();
|
|
25
|
+
recordTelemetryAttributes({ command: `destroy ${componentName}` });
|
|
26
|
+
const { name } = await preTasksFn({ ...options, isDestroyer: true });
|
|
27
|
+
await tasks({ componentName, filesFn, name }).run();
|
|
28
28
|
},
|
|
29
29
|
tasks
|
|
30
30
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
const createYargsForComponentDestroy = ({
|
|
1
|
+
const createYargsForComponentDestroy = ({
|
|
2
|
+
componentName
|
|
3
|
+
}) => {
|
|
2
4
|
return {
|
|
3
5
|
command: `${componentName} <name>`,
|
|
4
6
|
description: `Destroy a ${componentName} component`,
|
|
@@ -12,7 +14,11 @@ const createYargsForComponentDestroy = ({ componentName }) => {
|
|
|
12
14
|
};
|
|
13
15
|
function createHandler(componentName) {
|
|
14
16
|
return async (argv) => {
|
|
15
|
-
const
|
|
17
|
+
const { existsSync } = await import("node:fs");
|
|
18
|
+
const tsPath = `./${componentName}/${componentName}Handler.ts`;
|
|
19
|
+
const jsPath = `./${componentName}/${componentName}Handler.js`;
|
|
20
|
+
const resolvedPath = existsSync(new URL(tsPath, import.meta.url)) ? tsPath : jsPath;
|
|
21
|
+
const importedHandler = await import(resolvedPath);
|
|
16
22
|
const fn = importedHandler.default ?? importedHandler.handler ?? importedHandler;
|
|
17
23
|
return typeof fn === "function" ? fn(argv) : fn;
|
|
18
24
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { files as layoutFiles } from "../../generate/layout/layoutHandler.js";
|
|
2
1
|
import { createYargsForComponentDestroy, createHandler } from "../helpers.js";
|
|
3
2
|
const { command, description, builder } = createYargsForComponentDestroy(
|
|
4
|
-
{ componentName: "layout"
|
|
3
|
+
{ componentName: "layout" }
|
|
5
4
|
);
|
|
6
5
|
const handler = createHandler("layout");
|
|
7
6
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import camelcase from "camelcase";
|
|
2
2
|
import { Listr } from "listr2";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
5
|
import {
|
|
6
6
|
deleteFilesTask,
|
|
7
7
|
removeRoutesFromRouterTask
|
|
@@ -42,7 +42,7 @@ const handler = async ({ name, path }) => {
|
|
|
42
42
|
try {
|
|
43
43
|
await t.run();
|
|
44
44
|
} catch (e) {
|
|
45
|
-
console.log(c.error(e.message));
|
|
45
|
+
console.log(c.error(e instanceof Error ? e.message : String(e)));
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
export {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Listr } from "listr2";
|
|
2
2
|
import pascalcase from "pascalcase";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
|
+
import { pluralize } from "@cedarjs/utils/cedarPluralize";
|
|
6
6
|
import {
|
|
7
7
|
deleteFilesTask,
|
|
8
8
|
getPaths,
|
|
@@ -16,7 +16,11 @@ import {
|
|
|
16
16
|
routes as scaffoldRoutes,
|
|
17
17
|
splitPathAndModel
|
|
18
18
|
} from "../../generate/scaffold/scaffoldHandler.js";
|
|
19
|
-
const removeRoutesWithSet = async ({
|
|
19
|
+
const removeRoutesWithSet = async ({
|
|
20
|
+
model,
|
|
21
|
+
path,
|
|
22
|
+
nestScaffoldByModel
|
|
23
|
+
}) => {
|
|
20
24
|
const routes = await scaffoldRoutes({ model, path, nestScaffoldByModel });
|
|
21
25
|
const routeNames = routes.map(extractRouteName);
|
|
22
26
|
const pluralPascalName = pascalcase(pluralize(model));
|
|
@@ -29,18 +33,25 @@ const removeSetImport = () => {
|
|
|
29
33
|
if (routesContent.match("<Set")) {
|
|
30
34
|
return "Skipping removal of Set import in Routes.{jsx,tsx}";
|
|
31
35
|
}
|
|
32
|
-
const
|
|
36
|
+
const cedarRouterImportMatch = routesContent.match(
|
|
33
37
|
/import {[^]*} from '@cedarjs\/router'/
|
|
34
38
|
);
|
|
35
|
-
|
|
39
|
+
if (!cedarRouterImportMatch) {
|
|
40
|
+
return "No @cedarjs/router import found in Routes.{jsx,tsx}";
|
|
41
|
+
}
|
|
42
|
+
const [cedarRouterImport] = cedarRouterImportMatch;
|
|
43
|
+
const removedSetImport = cedarRouterImport.replace(/,*\s*Set,*/, "");
|
|
36
44
|
const newRoutesContent = routesContent.replace(
|
|
37
|
-
|
|
45
|
+
cedarRouterImport,
|
|
38
46
|
removedSetImport
|
|
39
47
|
);
|
|
40
48
|
writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
|
|
41
49
|
return "Removed Set import in Routes.{jsx,tsx}";
|
|
42
50
|
};
|
|
43
|
-
const removeLayoutImport = ({
|
|
51
|
+
const removeLayoutImport = ({
|
|
52
|
+
model: name,
|
|
53
|
+
path: scaffoldPath = ""
|
|
54
|
+
}) => {
|
|
44
55
|
const pluralPascalName = pascalcase(pluralize(name));
|
|
45
56
|
const pascalScaffoldPath = scaffoldPath === "" ? scaffoldPath : scaffoldPath.split("/").map(pascalcase).join("/") + "/";
|
|
46
57
|
const layoutName = `${pluralPascalName}Layout`;
|
|
@@ -54,7 +65,12 @@ const removeLayoutImport = ({ model: name, path: scaffoldPath = "" }) => {
|
|
|
54
65
|
writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
|
|
55
66
|
return "Removed layout import from Routes.{jsx,tsx}";
|
|
56
67
|
};
|
|
57
|
-
const tasks = ({
|
|
68
|
+
const tasks = ({
|
|
69
|
+
model,
|
|
70
|
+
path,
|
|
71
|
+
tests,
|
|
72
|
+
nestScaffoldByModel
|
|
73
|
+
}) => new Listr(
|
|
58
74
|
[
|
|
59
75
|
{
|
|
60
76
|
title: "Destroying scaffold files...",
|
|
@@ -92,12 +108,15 @@ const handler = async ({ model: modelArg }) => {
|
|
|
92
108
|
const { name } = await verifyModelName({ name: model, isDestroyer: true });
|
|
93
109
|
await tasks({ model: name, path }).run();
|
|
94
110
|
} catch (e) {
|
|
95
|
-
console.log(c.error(e.message));
|
|
111
|
+
console.log(c.error(e instanceof Error ? e.message : String(e)));
|
|
96
112
|
}
|
|
97
113
|
};
|
|
98
114
|
const extractRouteName = (route) => {
|
|
99
|
-
const
|
|
100
|
-
|
|
115
|
+
const match = route.match(/.*name="?(?<routeName>\w+)"?/);
|
|
116
|
+
if (!match?.groups?.routeName) {
|
|
117
|
+
throw new Error(`Could not extract route name from route: ${route}`);
|
|
118
|
+
}
|
|
119
|
+
return match.groups.routeName;
|
|
101
120
|
};
|
|
102
121
|
export {
|
|
103
122
|
handler,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Listr } from "listr2";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
4
4
|
import { deleteFilesTask } from "../../../lib/index.js";
|
|
5
5
|
import { verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
6
6
|
import { files } from "../../generate/sdl/sdlHandler.js";
|
|
@@ -24,7 +24,7 @@ const handler = async ({ model }) => {
|
|
|
24
24
|
const { name } = await verifyModelName({ name: model, isDestroyer: true });
|
|
25
25
|
await tasks({ model: name }).run();
|
|
26
26
|
} catch (e) {
|
|
27
|
-
console.log(c.error(e.message));
|
|
27
|
+
console.log(c.error(e instanceof Error ? e.message : String(e)));
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
export {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { argv } from "node:process";
|
|
2
2
|
import { getConfig } from "@cedarjs/project-config";
|
|
3
|
-
|
|
4
|
-
function getApiDebugFlag(apiDebugPort) {
|
|
3
|
+
function getApiDebugFlag(apiDebugPort, apiAvailablePort) {
|
|
5
4
|
if (apiDebugPort) {
|
|
6
5
|
return `--debug-port ${apiDebugPort}`;
|
|
7
6
|
} else if (argv.includes("--apiDebugPort")) {
|
|
8
|
-
return `--debug-port ${
|
|
7
|
+
return `--debug-port ${"1" + apiAvailablePort}`;
|
|
9
8
|
}
|
|
10
9
|
const apiDebugPortInConfig = getConfig().api.debugPort;
|
|
11
10
|
if (apiDebugPortInConfig) {
|
|
12
11
|
return `--debug-port ${apiDebugPortInConfig}`;
|
|
12
|
+
} else if (apiDebugPortInConfig === false) {
|
|
13
|
+
return "";
|
|
13
14
|
}
|
|
14
|
-
return ""
|
|
15
|
+
return `--debug-port ${"1" + apiAvailablePort}`;
|
|
15
16
|
}
|
|
16
17
|
export {
|
|
17
18
|
getApiDebugFlag
|