@cedarjs/cli 4.2.1-next.0 → 4.2.1-next.258
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/dist/cfw.js +8 -6
- package/dist/commands/build/buildHandler.js +43 -42
- package/dist/commands/build/buildPackagesTask.js +6 -6
- package/dist/commands/build.js +7 -1
- package/dist/commands/deploy/baremetal/SshExecutor.js +13 -4
- package/dist/commands/deploy/baremetal/baremetalHandler.js +117 -65
- package/dist/commands/deploy/baremetal.js +24 -3
- package/dist/commands/deploy/flightcontrolHandler.js +16 -14
- package/dist/commands/deploy/helpers/deployHandler.js +10 -5
- package/dist/commands/deploy/packing/nft.js +1 -2
- package/dist/commands/deploy/render.js +1 -1
- package/dist/commands/deploy/renderHandler.js +22 -12
- package/dist/commands/deploy/serverlessHandler.js +67 -25
- 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 +16 -16
- package/dist/commands/destroy/helpers.js +8 -2
- package/dist/commands/destroy/layout/layout.js +1 -2
- package/dist/commands/destroy/page/pageHandler.js +1 -1
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +28 -9
- package/dist/commands/destroy/sdl/sdlHandler.js +1 -1
- package/dist/commands/dev/devHandler.js +25 -25
- package/dist/commands/dev.js +3 -0
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +110 -4
- package/dist/commands/experimental/setupInngest.js +1 -1
- package/dist/commands/experimental/setupInngestHandler.js +12 -11
- package/dist/commands/experimental/setupOpentelemetry.js +1 -1
- package/dist/commands/experimental/setupOpentelemetryHandler.js +11 -7
- package/dist/commands/experimental/setupReactCompiler.js +1 -1
- package/dist/commands/experimental/setupReactCompilerHandler.js +45 -30
- package/dist/commands/experimental/setupRscHandler.js +14 -11
- package/dist/commands/experimental/setupStreamingSsr.js +1 -1
- package/dist/commands/experimental/setupStreamingSsrHandler.js +46 -31
- 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/util.js +3 -2
- package/dist/commands/generate/cell/cellHandler.js +22 -21
- package/dist/commands/generate/component/componentHandler.js +14 -16
- package/dist/commands/generate/dataMigration/dataMigration.js +24 -13
- package/dist/commands/generate/dbAuth/dbAuth.js +1 -0
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +40 -30
- package/dist/commands/generate/directive/directiveHandler.js +12 -14
- package/dist/commands/generate/function/function.js +1 -0
- package/dist/commands/generate/function/functionHandler.js +12 -17
- package/dist/commands/generate/helpers.js +17 -17
- package/dist/commands/generate/job/job.js +1 -0
- package/dist/commands/generate/job/jobHandler.js +15 -17
- 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 +9 -3
- package/dist/commands/generate/ogImage/ogImage.js +1 -0
- package/dist/commands/generate/ogImage/ogImageHandler.js +16 -9
- package/dist/commands/generate/package/packageHandler.js +32 -49
- package/dist/commands/generate/page/pageHandler.js +25 -22
- package/dist/commands/generate/realtime/realtime.js +1 -1
- package/dist/commands/generate/realtime/realtimeHandler.js +46 -20
- package/dist/commands/generate/scaffold/scaffold.js +1 -0
- package/dist/commands/generate/scaffold/scaffoldHandler.js +35 -27
- package/dist/commands/generate/script/script.js +1 -0
- package/dist/commands/generate/script/templates/tsconfig.json.template +14 -0
- package/dist/commands/generate/sdl/sdl.js +4 -3
- package/dist/commands/generate/sdl/sdlHandler.js +38 -18
- package/dist/commands/generate/secret/secret.js +19 -19
- package/dist/commands/generate/service/service.js +5 -5
- package/dist/commands/generate/service/serviceHandler.js +59 -22
- package/dist/commands/generate/yargsCommandHelpers.js +6 -1
- package/dist/commands/generate/yargsHandlerHelpers.js +18 -10
- package/dist/commands/generate.js +3 -10
- package/dist/commands/jobsHandler.js +3 -2
- package/dist/commands/prismaHandler.js +10 -9
- package/dist/commands/serve.js +84 -137
- package/dist/commands/serveApiHandler.js +5 -5
- package/dist/commands/serveBothHandler.js +10 -7
- package/dist/commands/serveWebHandler.js +2 -2
- package/dist/commands/setup/auth/auth.js +12 -6
- package/dist/commands/setup/cache/cacheHandler.js +11 -6
- 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 +157 -5
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +26 -4
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +53 -25
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +33 -23
- package/dist/commands/setup/deploy/providers/netlify.js +6 -0
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +112 -11
- package/dist/commands/setup/deploy/providers/renderHandler.js +10 -5
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +5 -3
- package/dist/commands/setup/deploy/providers/universal-deploy.js +11 -0
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +188 -0
- package/dist/commands/setup/deploy/providers/vercel.js +6 -0
- package/dist/commands/setup/deploy/providers/vercelHandler.js +113 -12
- 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/docker/docker.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +72 -37
- 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} +1 -1
- package/dist/commands/setup/docker/templates/docker-compose.dev.yml +2 -2
- package/dist/commands/setup/generator/generatorHandler.js +4 -3
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +2 -2
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +2 -2
- package/dist/commands/setup/i18n/i18nHandler.js +18 -15
- package/dist/commands/setup/jobs/jobsHandler.js +10 -5
- package/dist/commands/setup/mailer/mailerHandler.js +11 -9
- package/dist/commands/setup/package/packageHandler.js +14 -10
- package/dist/commands/setup/realtime/realtimeHandler.js +22 -20
- package/dist/commands/setup/server-file/serverFileHandler.js +16 -8
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +5 -3
- package/dist/commands/setup/ui/helpers/helpers.js +5 -1
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +11 -5
- package/dist/commands/setup/ui/libraries/mantineHandler.js +21 -13
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +38 -26
- package/dist/commands/setup/uploads/uploadsHandler.js +7 -4
- package/dist/commands/setup.js +1 -2
- package/dist/commands/test/testHandler.js +2 -1
- package/dist/commands/test/testHandlerEsm.js +2 -2
- package/dist/commands/type-checkHandler.js +4 -6
- package/dist/commands/upgrade/upgradeHandler.js +2 -4
- package/dist/index.js +10 -4
- package/dist/lib/configureStorybook.js +2 -2
- package/dist/lib/exec.js +36 -24
- package/dist/lib/exit.js +19 -4
- package/dist/lib/extendFile.js +22 -12
- package/dist/lib/index.js +119 -85
- package/dist/lib/merge/algorithms.js +4 -1
- package/dist/lib/merge/index.js +76 -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 +12 -5
- package/dist/lib/pluralHelpers.js +1 -1
- package/dist/lib/project.js +3 -1
- package/dist/lib/rollback.js +7 -7
- package/dist/lib/schemaHelpers.js +12 -12
- package/dist/lib/test.js +4 -0
- package/dist/lib/updateCheck.js +6 -4
- package/dist/middleware/checkNodeVersion.js +5 -0
- 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 -5
- package/dist/telemetry/send.js +14 -10
- package/package.json +15 -12
- 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 -82
- /package/dist/{index.d.js → global.d.js} +0 -0
|
@@ -2,10 +2,11 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
4
4
|
import { camelCase } from "camel-case";
|
|
5
|
-
import execa from "execa";
|
|
6
5
|
import { Listr } from "listr2";
|
|
7
6
|
import { titleCase } from "title-case";
|
|
8
7
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
8
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
9
10
|
import {
|
|
10
11
|
addRoutesToRouterTask,
|
|
11
12
|
addScaffoldImport,
|
|
@@ -36,7 +37,11 @@ function getPostInstallMessage(isDbAuthSetup2) {
|
|
|
36
37
|
" logged in. Also take a look in the onSubmit() functions in ForgotPasswordPage",
|
|
37
38
|
" and ResetPasswordPage to change where the user redirects to after submitting",
|
|
38
39
|
" those forms.\n",
|
|
39
|
-
!isDbAuthSetup2 &&
|
|
40
|
+
!isDbAuthSetup2 && ` Oh, and if you haven't already, add the necessary dbAuth functions and
|
|
41
|
+
app setup by running:
|
|
42
|
+
|
|
43
|
+
${formatCedarCommand(["setup", "auth", "dbAuth"])}
|
|
44
|
+
`,
|
|
40
45
|
" Happy authenticating!"
|
|
41
46
|
].filter(Boolean).join("\n");
|
|
42
47
|
}
|
|
@@ -55,12 +60,15 @@ function getPostInstallWebauthnMessage(isDbAuthSetup2) {
|
|
|
55
60
|
" logged in. Also take a look in the onSubmit() functions in ForgotPasswordPage",
|
|
56
61
|
" and ResetPasswordPage to change where the user redirects to after submitting",
|
|
57
62
|
" those forms.\n",
|
|
58
|
-
!isDbAuthSetup2 &&
|
|
63
|
+
!isDbAuthSetup2 && ` Oh, and if you haven't already, add the necessary dbAuth functions and
|
|
64
|
+
app setup by running:
|
|
65
|
+
|
|
66
|
+
${formatCedarCommand(["setup", "auth", "dbAuth"])}
|
|
67
|
+
`,
|
|
59
68
|
" Happy authenticating!"
|
|
60
69
|
].filter(Boolean).join("\n");
|
|
61
70
|
}
|
|
62
71
|
const files = async ({
|
|
63
|
-
_tests,
|
|
64
72
|
typescript,
|
|
65
73
|
skipForgot,
|
|
66
74
|
skipLogin,
|
|
@@ -70,7 +78,7 @@ const files = async ({
|
|
|
70
78
|
usernameLabel,
|
|
71
79
|
passwordLabel
|
|
72
80
|
}) => {
|
|
73
|
-
const
|
|
81
|
+
const filesList = [];
|
|
74
82
|
usernameLabel = usernameLabel || "username";
|
|
75
83
|
passwordLabel = passwordLabel || "password";
|
|
76
84
|
const templateVars = {
|
|
@@ -82,7 +90,7 @@ const files = async ({
|
|
|
82
90
|
passwordTitleCase: titleCase(passwordLabel)
|
|
83
91
|
};
|
|
84
92
|
if (!skipForgot) {
|
|
85
|
-
|
|
93
|
+
filesList.push(
|
|
86
94
|
await templateForComponentFile({
|
|
87
95
|
name: "ForgotPassword",
|
|
88
96
|
suffix: "Page",
|
|
@@ -95,7 +103,7 @@ const files = async ({
|
|
|
95
103
|
);
|
|
96
104
|
}
|
|
97
105
|
if (!skipLogin) {
|
|
98
|
-
|
|
106
|
+
filesList.push(
|
|
99
107
|
await templateForComponentFile({
|
|
100
108
|
name: "Login",
|
|
101
109
|
suffix: "Page",
|
|
@@ -108,7 +116,7 @@ const files = async ({
|
|
|
108
116
|
);
|
|
109
117
|
}
|
|
110
118
|
if (!skipReset) {
|
|
111
|
-
|
|
119
|
+
filesList.push(
|
|
112
120
|
await templateForComponentFile({
|
|
113
121
|
name: "ResetPassword",
|
|
114
122
|
suffix: "Page",
|
|
@@ -121,7 +129,7 @@ const files = async ({
|
|
|
121
129
|
);
|
|
122
130
|
}
|
|
123
131
|
if (!skipSignup) {
|
|
124
|
-
|
|
132
|
+
filesList.push(
|
|
125
133
|
await templateForComponentFile({
|
|
126
134
|
name: "Signup",
|
|
127
135
|
suffix: "Page",
|
|
@@ -133,7 +141,7 @@ const files = async ({
|
|
|
133
141
|
})
|
|
134
142
|
);
|
|
135
143
|
}
|
|
136
|
-
if (
|
|
144
|
+
if (filesList.length === 0) {
|
|
137
145
|
console.info(c.error("\nNo files to generate.\n"));
|
|
138
146
|
process.exit(0);
|
|
139
147
|
}
|
|
@@ -146,25 +154,27 @@ const files = async ({
|
|
|
146
154
|
),
|
|
147
155
|
{ name: "scaffold" }
|
|
148
156
|
);
|
|
149
|
-
|
|
157
|
+
filesList.push([scaffoldOutputPath, scaffoldTemplate]);
|
|
150
158
|
}
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
return filesList.reduce(
|
|
160
|
+
async (accP, [outputPath, content]) => {
|
|
161
|
+
const acc = await accP;
|
|
162
|
+
let template = content;
|
|
163
|
+
if (outputPath.match(/\.[jt]sx?/) && !typescript) {
|
|
164
|
+
template = await transformTSToJS(outputPath, content);
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
[outputPath]: template,
|
|
168
|
+
...acc
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
Promise.resolve({})
|
|
172
|
+
);
|
|
162
173
|
};
|
|
163
174
|
const tasks = ({
|
|
164
175
|
enquirer,
|
|
165
176
|
listr2,
|
|
166
177
|
force,
|
|
167
|
-
tests,
|
|
168
178
|
typescript,
|
|
169
179
|
skipForgot,
|
|
170
180
|
skipLogin,
|
|
@@ -275,7 +285,6 @@ const tasks = ({
|
|
|
275
285
|
title: "Creating pages...",
|
|
276
286
|
task: async () => {
|
|
277
287
|
const filesObj = await files({
|
|
278
|
-
tests,
|
|
279
288
|
typescript,
|
|
280
289
|
skipForgot,
|
|
281
290
|
skipLogin,
|
|
@@ -303,7 +312,7 @@ const tasks = ({
|
|
|
303
312
|
{
|
|
304
313
|
title: "Generate types...",
|
|
305
314
|
task: () => {
|
|
306
|
-
|
|
315
|
+
runBinSync("cedar", ["g", "types"]);
|
|
307
316
|
}
|
|
308
317
|
},
|
|
309
318
|
{
|
|
@@ -313,7 +322,7 @@ const tasks = ({
|
|
|
313
322
|
}
|
|
314
323
|
],
|
|
315
324
|
{
|
|
316
|
-
silentRendererCondition: () => listr2?.silentRendererCondition,
|
|
325
|
+
silentRendererCondition: () => listr2?.silentRendererCondition ?? false,
|
|
317
326
|
rendererOptions: { collapseSubtasks: false },
|
|
318
327
|
ctx: { enquirer },
|
|
319
328
|
exitOnError: true
|
|
@@ -327,7 +336,7 @@ const handler = async (yargs) => {
|
|
|
327
336
|
skipLogin: yargs.skipLogin,
|
|
328
337
|
skipReset: yargs.skipReset,
|
|
329
338
|
skipSignup: yargs.skipSignup,
|
|
330
|
-
webauthn: yargs.webauthn,
|
|
339
|
+
webauthn: yargs.webauthn ?? void 0,
|
|
331
340
|
force: yargs.force,
|
|
332
341
|
rollback: yargs.rollback
|
|
333
342
|
});
|
|
@@ -339,10 +348,11 @@ const handler = async (yargs) => {
|
|
|
339
348
|
await t.run();
|
|
340
349
|
console.log("");
|
|
341
350
|
console.log(
|
|
342
|
-
yargs.webauthn || t.ctx
|
|
351
|
+
yargs.webauthn || t.ctx?.webauthn ? getPostInstallWebauthnMessage(isDbAuthSetup()) : getPostInstallMessage(isDbAuthSetup())
|
|
343
352
|
);
|
|
344
353
|
} catch (e) {
|
|
345
|
-
|
|
354
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
355
|
+
console.log(c.error(msg));
|
|
346
356
|
}
|
|
347
357
|
};
|
|
348
358
|
function isDbAuthSetup() {
|
|
@@ -356,7 +366,7 @@ function isDbAuthSetup() {
|
|
|
356
366
|
"auth." + webAuthExtension
|
|
357
367
|
);
|
|
358
368
|
return /^import (.*) from ['"]@cedarjs\/auth-dbauth-web['"]/m.test(
|
|
359
|
-
fs.readFileSync(webAuthPath)
|
|
369
|
+
fs.readFileSync(webAuthPath, "utf-8")
|
|
360
370
|
);
|
|
361
371
|
}
|
|
362
372
|
return false;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import camelcase from "camelcase";
|
|
2
|
-
import execa from "execa";
|
|
3
2
|
import { Listr } from "listr2";
|
|
4
3
|
import prompts from "prompts";
|
|
5
4
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
6
6
|
import { getConfig } from "@cedarjs/project-config";
|
|
7
|
-
import { writeFilesTask,
|
|
7
|
+
import { writeFilesTask, transformTSToJSMap } from "../../../lib/index.js";
|
|
8
8
|
import {
|
|
9
9
|
prepareForRollback,
|
|
10
10
|
addFunctionToRollback
|
|
11
11
|
} from "../../../lib/rollback.js";
|
|
12
12
|
import { validateName } from "../helpers.js";
|
|
13
13
|
import { templateForComponentFile } from "../yargsHandlerHelpers.js";
|
|
14
|
-
const files = async ({
|
|
14
|
+
const files = async ({
|
|
15
|
+
name,
|
|
16
|
+
typescript = false,
|
|
17
|
+
type,
|
|
18
|
+
tests
|
|
19
|
+
}) => {
|
|
15
20
|
if (tests === void 0) {
|
|
16
21
|
tests = getConfig().generate.tests;
|
|
17
22
|
}
|
|
@@ -40,14 +45,7 @@ const files = async ({ name, typescript = false, type, tests }) => {
|
|
|
40
45
|
});
|
|
41
46
|
files2.push(testFile);
|
|
42
47
|
}
|
|
43
|
-
return files2
|
|
44
|
-
const acc = await accP;
|
|
45
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
46
|
-
return {
|
|
47
|
-
[outputPath]: template,
|
|
48
|
-
...acc
|
|
49
|
-
};
|
|
50
|
-
}, Promise.resolve({}));
|
|
48
|
+
return transformTSToJSMap(files2, typescript);
|
|
51
49
|
};
|
|
52
50
|
const handler = async (args) => {
|
|
53
51
|
recordTelemetryAttributes({
|
|
@@ -109,9 +107,9 @@ const handler = async (args) => {
|
|
|
109
107
|
title: "Generating TypeScript definitions and GraphQL schemas ...",
|
|
110
108
|
task: () => {
|
|
111
109
|
addFunctionToRollback(async () => {
|
|
112
|
-
await
|
|
110
|
+
await runBin("cedar-gen", [], { stdio: "pipe" });
|
|
113
111
|
}, true);
|
|
114
|
-
return
|
|
112
|
+
return runBin("cedar-gen", [], { stdio: "inherit" });
|
|
115
113
|
}
|
|
116
114
|
},
|
|
117
115
|
{
|
|
@@ -132,7 +130,7 @@ const handler = async (args) => {
|
|
|
132
130
|
console.log(notes);
|
|
133
131
|
}
|
|
134
132
|
} catch (e) {
|
|
135
|
-
console.log(c.error(e.message));
|
|
133
|
+
console.log(c.error(e instanceof Error ? e.message : String(e)));
|
|
136
134
|
process.exit(1);
|
|
137
135
|
}
|
|
138
136
|
};
|
|
@@ -2,17 +2,17 @@ import { Listr } from "listr2";
|
|
|
2
2
|
import { terminalLink } from "termi-link";
|
|
3
3
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
4
4
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
5
|
-
import {
|
|
5
|
+
import { transformTSToJSMap, writeFilesTask } from "../../../lib/index.js";
|
|
6
6
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
7
7
|
import { validateName } from "../helpers.js";
|
|
8
8
|
import { templateForComponentFile } from "../yargsHandlerHelpers.js";
|
|
9
9
|
const files = async ({
|
|
10
10
|
name,
|
|
11
|
-
typescript
|
|
12
|
-
tests
|
|
11
|
+
typescript = false,
|
|
12
|
+
tests = true,
|
|
13
13
|
...rest
|
|
14
14
|
}) => {
|
|
15
|
-
const extension =
|
|
15
|
+
const extension = typescript ? ".ts" : ".js";
|
|
16
16
|
const outputFiles = [];
|
|
17
17
|
const functionFiles = await templateForComponentFile({
|
|
18
18
|
name,
|
|
@@ -20,10 +20,10 @@ const files = async ({
|
|
|
20
20
|
apiPathSection: "functions",
|
|
21
21
|
generator: "function",
|
|
22
22
|
templatePath: "function.ts.template",
|
|
23
|
-
templateVars: { ...rest, typescript
|
|
23
|
+
templateVars: { ...rest, typescript }
|
|
24
24
|
});
|
|
25
25
|
outputFiles.push(functionFiles);
|
|
26
|
-
if (
|
|
26
|
+
if (tests) {
|
|
27
27
|
const testFile = await templateForComponentFile({
|
|
28
28
|
name,
|
|
29
29
|
extension: `.test${extension}`,
|
|
@@ -43,14 +43,7 @@ const files = async ({
|
|
|
43
43
|
outputFiles.push(testFile);
|
|
44
44
|
outputFiles.push(scenarioFile);
|
|
45
45
|
}
|
|
46
|
-
return outputFiles
|
|
47
|
-
const acc = await accP;
|
|
48
|
-
const template = generateTypescript ? content : await transformTSToJS(outputPath, content);
|
|
49
|
-
return {
|
|
50
|
-
[outputPath]: template,
|
|
51
|
-
...acc
|
|
52
|
-
};
|
|
53
|
-
}, Promise.resolve({}));
|
|
46
|
+
return transformTSToJSMap(outputFiles, typescript);
|
|
54
47
|
};
|
|
55
48
|
const handler = async ({ name, force, ...rest }) => {
|
|
56
49
|
recordTelemetryAttributes({
|
|
@@ -94,9 +87,11 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
94
87
|
);
|
|
95
88
|
console.info("");
|
|
96
89
|
} catch (e) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
process.
|
|
90
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
91
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
92
|
+
errorTelemetry(process.argv, message);
|
|
93
|
+
console.error(c.error(message));
|
|
94
|
+
process.exit(exitCode);
|
|
100
95
|
}
|
|
101
96
|
};
|
|
102
97
|
export {
|
|
@@ -24,7 +24,7 @@ const validateName = (name) => {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
const relationsForModel = (model) => {
|
|
27
|
-
return model
|
|
27
|
+
return model?.fields.filter((f) => f.relationName).map((field) => {
|
|
28
28
|
return field.name;
|
|
29
29
|
});
|
|
30
30
|
};
|
|
@@ -37,26 +37,26 @@ const forcePluralizeWord = (word) => {
|
|
|
37
37
|
}
|
|
38
38
|
return pluralize(word);
|
|
39
39
|
};
|
|
40
|
+
const routeParamToTsType = {
|
|
41
|
+
Int: "number",
|
|
42
|
+
Float: "number",
|
|
43
|
+
Boolean: "boolean",
|
|
44
|
+
String: "string"
|
|
45
|
+
};
|
|
40
46
|
const mapRouteParamTypeToTsType = (paramType) => {
|
|
41
|
-
const routeParamToTsType = {
|
|
42
|
-
Int: "number",
|
|
43
|
-
Float: "number",
|
|
44
|
-
Boolean: "boolean",
|
|
45
|
-
String: "string"
|
|
46
|
-
};
|
|
47
47
|
return routeParamToTsType[paramType] || "unknown";
|
|
48
48
|
};
|
|
49
|
+
const prismaScalarToTsType = {
|
|
50
|
+
String: "string",
|
|
51
|
+
Boolean: "boolean",
|
|
52
|
+
Int: "number",
|
|
53
|
+
BigInt: "number",
|
|
54
|
+
Float: "number",
|
|
55
|
+
Decimal: "number",
|
|
56
|
+
DateTime: "string",
|
|
57
|
+
Bytes: "Uint8Array"
|
|
58
|
+
};
|
|
49
59
|
const mapPrismaScalarToPagePropTsType = (scalarType) => {
|
|
50
|
-
const prismaScalarToTsType = {
|
|
51
|
-
String: "string",
|
|
52
|
-
Boolean: "boolean",
|
|
53
|
-
Int: "number",
|
|
54
|
-
BigInt: "number",
|
|
55
|
-
Float: "number",
|
|
56
|
-
Decimal: "number",
|
|
57
|
-
DateTime: "string",
|
|
58
|
-
Bytes: "Uint8Array"
|
|
59
|
-
};
|
|
60
60
|
return prismaScalarToTsType[scalarType] || "unknown";
|
|
61
61
|
};
|
|
62
62
|
export {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import * as changeCase from "change-case";
|
|
4
|
-
import execa from "execa";
|
|
5
4
|
import { Listr } from "listr2";
|
|
6
5
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
8
|
import {
|
|
9
9
|
getPaths,
|
|
10
|
-
|
|
10
|
+
transformTSToJSMap,
|
|
11
11
|
writeFilesTask
|
|
12
12
|
} from "../../../lib/index.js";
|
|
13
13
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
@@ -64,16 +64,13 @@ const files = async ({
|
|
|
64
64
|
outputFiles.push(testFile);
|
|
65
65
|
outputFiles.push(scenarioFile);
|
|
66
66
|
}
|
|
67
|
-
return outputFiles
|
|
68
|
-
const acc = await accP;
|
|
69
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
70
|
-
return {
|
|
71
|
-
[outputPath]: template,
|
|
72
|
-
...acc
|
|
73
|
-
};
|
|
74
|
-
}, Promise.resolve({}));
|
|
67
|
+
return transformTSToJSMap(outputFiles, typescript);
|
|
75
68
|
};
|
|
76
|
-
const handler = async ({
|
|
69
|
+
const handler = async ({
|
|
70
|
+
name,
|
|
71
|
+
force,
|
|
72
|
+
...rest
|
|
73
|
+
}) => {
|
|
77
74
|
recordTelemetryAttributes({
|
|
78
75
|
command: "generate job",
|
|
79
76
|
force,
|
|
@@ -85,7 +82,7 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
85
82
|
const jobsManagerFile = getPaths().api.distJobsConfig;
|
|
86
83
|
const jobManager = await import(pathToFileURL(jobsManagerFile).href);
|
|
87
84
|
queueName = jobManager.jobs?.queues[0] ?? "default";
|
|
88
|
-
} catch
|
|
85
|
+
} catch {
|
|
89
86
|
}
|
|
90
87
|
let jobFiles = {};
|
|
91
88
|
const tasks = new Listr(
|
|
@@ -100,8 +97,7 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
100
97
|
{
|
|
101
98
|
title: "Cleaning up...",
|
|
102
99
|
task: () => {
|
|
103
|
-
|
|
104
|
-
"eslint",
|
|
100
|
+
runBinSync("eslint", [
|
|
105
101
|
"--fix",
|
|
106
102
|
"--config",
|
|
107
103
|
`${getPaths().base}/node_modules/@cedarjs/eslint-config/shared.js`,
|
|
@@ -119,9 +115,11 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
119
115
|
}
|
|
120
116
|
await tasks.run();
|
|
121
117
|
} catch (e) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
process.
|
|
118
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
119
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
120
|
+
errorTelemetry(process.argv, message);
|
|
121
|
+
console.error(c.error(message));
|
|
122
|
+
process.exit(exitCode);
|
|
125
123
|
}
|
|
126
124
|
};
|
|
127
125
|
export {
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { transformTSToJSMap } from "../../../lib/index.js";
|
|
2
2
|
import { removeGeneratorName } from "../helpers.js";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
createHandler,
|
|
5
|
+
templateForComponentFile
|
|
6
6
|
} from "../yargsHandlerHelpers.js";
|
|
7
7
|
const COMPONENT_SUFFIX = "Layout";
|
|
8
|
-
const
|
|
9
|
-
const files = async ({
|
|
8
|
+
const CEDAR_WEB_PATH_NAME = "layouts";
|
|
9
|
+
const files = async ({
|
|
10
|
+
name,
|
|
11
|
+
typescript = false,
|
|
12
|
+
...options
|
|
13
|
+
}) => {
|
|
10
14
|
const layoutName = removeGeneratorName(name, "layout");
|
|
11
15
|
const extension = typescript ? ".tsx" : ".jsx";
|
|
12
16
|
const layoutFile = await templateForComponentFile({
|
|
13
17
|
name: layoutName,
|
|
14
18
|
suffix: COMPONENT_SUFFIX,
|
|
15
|
-
webPathSection:
|
|
19
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
16
20
|
extension,
|
|
17
21
|
generator: "layout",
|
|
18
22
|
templatePath: options.skipLink ? "layout.tsx.a11y.template" : "layout.tsx.template"
|
|
@@ -21,7 +25,7 @@ const files = async ({ name, typescript = false, ...options }) => {
|
|
|
21
25
|
name: layoutName,
|
|
22
26
|
suffix: COMPONENT_SUFFIX,
|
|
23
27
|
extension: `.test${extension}`,
|
|
24
|
-
webPathSection:
|
|
28
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
25
29
|
generator: "layout",
|
|
26
30
|
templatePath: "test.tsx.template"
|
|
27
31
|
});
|
|
@@ -29,7 +33,7 @@ const files = async ({ name, typescript = false, ...options }) => {
|
|
|
29
33
|
name: layoutName,
|
|
30
34
|
suffix: COMPONENT_SUFFIX,
|
|
31
35
|
extension: `.stories${extension}`,
|
|
32
|
-
webPathSection:
|
|
36
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
33
37
|
generator: "layout",
|
|
34
38
|
templatePath: "stories.tsx.template"
|
|
35
39
|
});
|
|
@@ -40,14 +44,7 @@ const files = async ({ name, typescript = false, ...options }) => {
|
|
|
40
44
|
if (options.tests) {
|
|
41
45
|
files2.push(testFile);
|
|
42
46
|
}
|
|
43
|
-
return files2
|
|
44
|
-
const acc = await accP;
|
|
45
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
46
|
-
return {
|
|
47
|
-
[outputPath]: template,
|
|
48
|
-
...acc
|
|
49
|
-
};
|
|
50
|
-
}, Promise.resolve({}));
|
|
47
|
+
return transformTSToJSMap(files2, typescript);
|
|
51
48
|
};
|
|
52
49
|
const handler = createHandler({
|
|
53
50
|
componentName: "layout",
|
|
@@ -14,14 +14,20 @@ const TEMPLATE_PATH = path.resolve(
|
|
|
14
14
|
"templates",
|
|
15
15
|
"model.js.template"
|
|
16
16
|
);
|
|
17
|
-
const files = async ({
|
|
17
|
+
const files = async ({
|
|
18
|
+
name,
|
|
19
|
+
typescript = false
|
|
20
|
+
}) => {
|
|
18
21
|
const outputFilename = `${name}.${typescript ? "ts" : "js"}`;
|
|
19
22
|
const outputPath = path.join(getPaths().api.models, outputFilename);
|
|
20
23
|
return {
|
|
21
24
|
[outputPath]: await generateTemplate(TEMPLATE_PATH, { name })
|
|
22
25
|
};
|
|
23
26
|
};
|
|
24
|
-
const handler = async ({
|
|
27
|
+
const handler = async ({
|
|
28
|
+
force,
|
|
29
|
+
...args
|
|
30
|
+
}) => {
|
|
25
31
|
recordTelemetryAttributes({
|
|
26
32
|
command: "generate model",
|
|
27
33
|
force,
|
|
@@ -53,7 +59,7 @@ const handler = async ({ force, ...args }) => {
|
|
|
53
59
|
}
|
|
54
60
|
await tasks.run();
|
|
55
61
|
} catch (e) {
|
|
56
|
-
console.log(c.error(e.message));
|
|
62
|
+
console.log(c.error(e instanceof Error ? e.message : String(e)));
|
|
57
63
|
process.exit(1);
|
|
58
64
|
}
|
|
59
65
|
};
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
} from "../../../lib/index.js";
|
|
14
14
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
15
15
|
import { customOrDefaultTemplatePath } from "../yargsHandlerHelpers.js";
|
|
16
|
-
const files = async ({
|
|
16
|
+
const files = async ({
|
|
17
|
+
pagePath,
|
|
18
|
+
typescript = false
|
|
19
|
+
}) => {
|
|
17
20
|
const extension = typescript ? ".tsx" : ".jsx";
|
|
18
21
|
const componentOutputPath = path.join(
|
|
19
22
|
getPaths().web.pages,
|
|
@@ -73,6 +76,10 @@ const handler = async (options) => {
|
|
|
73
76
|
const extension = options.typescript ? "tsx" : "jsx";
|
|
74
77
|
try {
|
|
75
78
|
await validatePath(normalizedPagePath, extension);
|
|
79
|
+
const listrOptions = {
|
|
80
|
+
exitOnError: true,
|
|
81
|
+
...options.verbose ? { renderer: "verbose" } : { rendererOptions: { collapseSubtasks: false } }
|
|
82
|
+
};
|
|
76
83
|
const tasks = new Listr(
|
|
77
84
|
[
|
|
78
85
|
{
|
|
@@ -86,22 +93,22 @@ const handler = async (options) => {
|
|
|
86
93
|
}
|
|
87
94
|
}
|
|
88
95
|
],
|
|
89
|
-
|
|
90
|
-
rendererOptions: { collapseSubtasks: false },
|
|
91
|
-
exitOnError: true,
|
|
92
|
-
renderer: options.verbose && "verbose"
|
|
93
|
-
}
|
|
96
|
+
listrOptions
|
|
94
97
|
);
|
|
95
98
|
if (options.rollback && !options.force) {
|
|
96
99
|
prepareForRollback(tasks);
|
|
97
100
|
}
|
|
98
101
|
await tasks.run();
|
|
99
102
|
} catch (e) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
104
|
+
errorTelemetry(process.argv, message);
|
|
105
|
+
console.error(c.error(message));
|
|
106
|
+
process.exit(errorExitCode(e));
|
|
103
107
|
}
|
|
104
108
|
};
|
|
109
|
+
function errorExitCode(e) {
|
|
110
|
+
return typeof e === "object" && e !== null && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
111
|
+
}
|
|
105
112
|
export {
|
|
106
113
|
files,
|
|
107
114
|
handler,
|