@cedarjs/cli 7.1.0 → 7.1.1-next.469
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/commands/build/buildHandler.js +2 -1
- package/dist/commands/build.js +1 -1
- package/dist/commands/check.js +2 -1
- package/dist/commands/deploy/baremetal/baremetalHandler.js +364 -73
- package/dist/commands/deploy/baremetal/monitors.js +66 -0
- package/dist/commands/deploy/baremetal.js +7 -1
- package/dist/commands/deploy/flightcontrolHandler.js +1 -1
- package/dist/commands/deploy/helpers/deployHandler.js +1 -1
- package/dist/commands/deploy/netlify.js +1 -1
- package/dist/commands/deploy/renderHandler.js +1 -1
- package/dist/commands/deploy/serverlessHandler.js +2 -1
- package/dist/commands/deploy/vercel.js +1 -1
- package/dist/commands/destroy/handlerHelpers.js +1 -1
- package/dist/commands/destroy/page/pageHandler.js +2 -1
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +65 -26
- package/dist/commands/destroy/sdl/sdlHandler.js +2 -1
- package/dist/commands/dev/devHandler.js +3 -4
- package/dist/commands/dev/packageWatchCommands.js +8 -3
- package/dist/commands/dev.js +1 -1
- package/dist/commands/execHandler.js +2 -1
- package/dist/commands/experimental/live-queries/liveQueries.js +1 -1
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +3 -3
- package/dist/commands/experimental/setupInngest.js +1 -1
- package/dist/commands/experimental/setupInngestHandler.js +1 -1
- package/dist/commands/experimental/setupOpentelemetry.js +1 -1
- package/dist/commands/experimental/setupOpentelemetryHandler.js +2 -1
- package/dist/commands/experimental/setupReactCompiler.js +1 -1
- package/dist/commands/experimental/setupReactCompilerHandler.js +4 -4
- package/dist/commands/experimental/setupRsc.js +1 -1
- package/dist/commands/experimental/setupRscHandler.js +2 -1
- package/dist/commands/experimental/setupStreamingSsr.js +1 -1
- package/dist/commands/experimental/setupStreamingSsrHandler.js +3 -2
- package/dist/commands/generate/cell/cell.js +20 -0
- package/dist/commands/generate/cell/cellHandler.js +68 -20
- 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/dataMigration/dataMigration.js +2 -1
- package/dist/commands/generate/dbAuth/dbAuth.js +6 -2
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +80 -17
- package/dist/commands/generate/dbAuth/templates/changePassword.tsx.template +131 -0
- package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +164 -0
- package/dist/commands/generate/dbAuth/templates/login.webAuthn.tsx.template +20 -12
- package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +147 -0
- package/dist/commands/generate/directive/directiveHandler.js +2 -1
- package/dist/commands/generate/function/functionHandler.js +2 -1
- package/dist/commands/generate/helpers.js +26 -0
- package/dist/commands/generate/job/jobHandler.js +2 -1
- package/dist/commands/generate/model/modelHandler.js +2 -1
- package/dist/commands/generate/ogImage/ogImageHandler.js +2 -1
- package/dist/commands/generate/ogImage/templates/ogImage.og.tsx.template +1 -1
- package/dist/commands/generate/package/filesTask.js +9 -12
- package/dist/commands/generate/package/packageHandler.js +3 -4
- package/dist/commands/generate/package/templates/tsconfig.json.template +1 -0
- package/dist/commands/generate/page/pageHandler.js +2 -1
- package/dist/commands/generate/realtime/realtime.js +1 -1
- package/dist/commands/generate/realtime/realtimeHandler.js +2 -9
- package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.service.ts.template +12 -4
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.service.ts.template +2 -2
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +4 -4
- package/dist/commands/generate/scaffold/scaffold.js +1 -1
- package/dist/commands/generate/scaffold/scaffoldHandler.js +93 -49
- package/dist/commands/generate/scaffold/templates/assets/scaffold.tailwind.css.template +12 -7
- package/dist/commands/generate/scaffold/templates/components/EditNameCell.tsx.template +5 -7
- package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +10 -9
- package/dist/commands/generate/scaffold/templates/layouts/NamesScaffoldLayout.tsx.template +18 -0
- package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +11 -0
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +16 -4
- package/dist/commands/generate/script/scriptHandler.js +2 -1
- package/dist/commands/generate/script/templates/tsconfig.json.template +1 -0
- package/dist/commands/generate/sdl/sdlHandler.js +10 -4
- package/dist/commands/generate/secret/secret.js +1 -1
- package/dist/commands/generate/service/serviceHandler.js +79 -49
- package/dist/commands/generate/service/templates/service.ts.template +40 -13
- package/dist/commands/generate/service/templates/test.ts.template +8 -6
- package/dist/commands/generate/yargsCommandHelpers.js +1 -1
- package/dist/commands/generate/yargsHandlerHelpers.js +2 -1
- package/dist/commands/generate.js +1 -1
- package/dist/commands/info.js +1 -1
- package/dist/commands/jobsHandler.js +5 -3
- package/dist/commands/lint.js +1 -1
- package/dist/commands/prerenderHandler.js +11 -4
- package/dist/commands/prismaHandler.js +7 -2
- package/dist/commands/record/init.js +1 -1
- package/dist/commands/serve.js +2 -1
- package/dist/commands/setup/auth/auth.js +2 -4
- package/dist/commands/setup/cache/cache.js +1 -1
- package/dist/commands/setup/cache/cacheHandler.js +2 -1
- package/dist/commands/setup/cache/templates/memcached.ts.template +14 -17
- package/dist/commands/setup/cache/templates/redis.ts.template +12 -20
- package/dist/commands/setup/database/postgres.js +1 -1
- package/dist/commands/setup/database/postgresHandler.js +3 -1
- package/dist/commands/setup/deploy/providers/baremetal.js +7 -0
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +130 -21
- package/dist/commands/setup/deploy/providers/coherence.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +7 -6
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/renderHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +4 -6
- package/dist/commands/setup/deploy/providers/vercelHandler.js +2 -1
- package/dist/commands/setup/deploy/templates/baremetal.js +119 -9
- package/dist/commands/setup/deploy/templates/netlifyUD.js +3 -0
- package/dist/commands/setup/docker/docker.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +2 -1
- package/dist/commands/setup/generator/generator.js +1 -1
- package/dist/commands/setup/generator/generatorHandler.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +3 -5
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +2 -1
- package/dist/commands/setup/i18n/i18n.js +1 -1
- package/dist/commands/setup/i18n/i18nHandler.js +1 -1
- package/dist/commands/setup/jobs/jobs.js +1 -1
- package/dist/commands/setup/jobs/jobsHandler.js +4 -1
- package/dist/commands/setup/mailer/mailer.js +1 -1
- package/dist/commands/setup/mailer/mailerHandler.js +2 -1
- 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 +13 -9
- package/dist/commands/setup/monitoring/sentry/templates/sentryApi.ts.template +1 -4
- package/dist/commands/setup/monitoring/sentry/templates/sentryWeb.ts.template +7 -4
- package/dist/commands/setup/neon/neon.js +1 -1
- package/dist/commands/setup/neon/neonHandler.js +5 -9
- package/dist/commands/setup/package/package.js +1 -1
- package/dist/commands/setup/package/packageHandler.js +4 -4
- 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 +4 -16
- package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template +4 -1
- package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.ts.template +12 -4
- package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +2 -2
- package/dist/commands/setup/server-file/serverFile.js +1 -1
- package/dist/commands/setup/server-file/serverFileHandler.js +2 -1
- 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 +154 -0
- package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +72 -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 +57 -0
- package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +89 -0
- package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +381 -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/libraries/chakra-uiHandler.js +2 -1
- package/dist/commands/setup/ui/libraries/mantineHandler.js +2 -1
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +63 -82
- package/dist/commands/setup/uploads/gitignore.js +17 -0
- package/dist/commands/setup/uploads/schemaPrisma.js +41 -0
- package/dist/commands/setup/uploads/serverFile.js +217 -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 +98 -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 +277 -69
- package/dist/commands/setup.js +2 -1
- package/dist/commands/studio.js +1 -1
- package/dist/commands/test/testHandler.js +25 -71
- package/dist/commands/test/viteVersionCheck.js +75 -0
- package/dist/commands/test.js +10 -18
- package/dist/commands/type-checkHandler.js +1 -1
- package/dist/commands/upgrade/preUpgradeScripts.js +3 -3
- package/dist/commands/upgrade/upgrade.js +1 -1
- package/dist/commands/upgrade/upgradeHandler.js +2 -1
- package/dist/index.js +5 -8
- package/dist/lib/exit.js +1 -1
- package/dist/lib/index.js +16 -31
- package/dist/lib/loadEnvFiles.js +1 -1
- package/dist/lib/plugin.js +1 -1
- package/dist/lib/test.js +1 -1
- package/dist/lib/updateCheck.js +4 -4
- package/dist/middleware/checkNodeVersion.js +4 -4
- package/package.json +27 -27
- package/dist/commands/setup/ui/templates/postcss.config.cjs.template +0 -9
- package/dist/commands/setup/uploads/dbCodemod.js +0 -28
- package/dist/commands/setup/uploads/templates/signedUrl.ts.template +0 -21
- package/dist/commands/test/testHandlerEsm.js +0 -109
- package/dist/commands/testEsm.js +0 -41
|
@@ -3,7 +3,14 @@ import camelcase from "camelcase";
|
|
|
3
3
|
import { pluralize, singularize } from "@cedarjs/utils/cedarPluralize";
|
|
4
4
|
import { transformTSToJS } from "../../../lib/index.js";
|
|
5
5
|
import { getSchema, verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
DEFAULT_IGNORE_FIELDS_FOR_INPUT,
|
|
8
|
+
nullableJsonFieldsInInput,
|
|
9
|
+
nullableRelationsForModel,
|
|
10
|
+
redactedModelFields,
|
|
11
|
+
relationsForModel,
|
|
12
|
+
requiredFieldsInUpdateInput
|
|
13
|
+
} from "../helpers.js";
|
|
7
14
|
import { createHandler, templateForFile } from "../yargsHandlerHelpers.js";
|
|
8
15
|
function isServiceModel(schema) {
|
|
9
16
|
return typeof schema === "object" && schema !== null && "fields" in schema && "name" in schema;
|
|
@@ -59,11 +66,13 @@ function scenarioFieldValue(field) {
|
|
|
59
66
|
return randInt;
|
|
60
67
|
case "Json":
|
|
61
68
|
return { foo: "bar" };
|
|
62
|
-
case "String":
|
|
69
|
+
case "String": {
|
|
70
|
+
const isUnique = field.isUnique || field.isId;
|
|
63
71
|
if (field.name?.toLowerCase().includes("email")) {
|
|
64
|
-
return
|
|
72
|
+
return isUnique ? `foo${randInt}@bar.com` : "foo@bar.com";
|
|
65
73
|
}
|
|
66
|
-
return
|
|
74
|
+
return isUnique ? `String${randInt}` : "String";
|
|
75
|
+
}
|
|
67
76
|
case "Bytes":
|
|
68
77
|
return `new Uint8Array([${randIntArray}])`;
|
|
69
78
|
default: {
|
|
@@ -152,11 +161,14 @@ const fieldsToInput = async (model) => {
|
|
|
152
161
|
const modelName = camelcase(singularize(model));
|
|
153
162
|
const inputObj = {};
|
|
154
163
|
if (scalarFields.some(
|
|
155
|
-
(field) => redactedFields.includes(field.name)
|
|
164
|
+
(field) => redactedFields.includes(field.name) || DEFAULT_IGNORE_FIELDS_FOR_INPUT.includes(field.name) && !field.isUpdatedAt
|
|
156
165
|
)) {
|
|
157
166
|
return false;
|
|
158
167
|
}
|
|
159
168
|
scalarFields.forEach((field) => {
|
|
169
|
+
if (DEFAULT_IGNORE_FIELDS_FOR_INPUT.includes(field.name)) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
160
172
|
if (foreignKeys.includes(field.name)) {
|
|
161
173
|
inputObj[field.name] = `scenario.${modelName}.two.${field.name}`;
|
|
162
174
|
} else {
|
|
@@ -174,7 +186,7 @@ const fieldsToUpdate = async (model) => {
|
|
|
174
186
|
const modelName = camelcase(singularize(model));
|
|
175
187
|
let field, newValue, fieldName;
|
|
176
188
|
const updatableFields = scalarFields.filter(
|
|
177
|
-
(scalar) => !redactedFields.includes(scalar.name)
|
|
189
|
+
(scalar) => !redactedFields.includes(scalar.name) && !DEFAULT_IGNORE_FIELDS_FOR_INPUT.includes(scalar.name)
|
|
178
190
|
);
|
|
179
191
|
field = updatableFields.find(
|
|
180
192
|
(scalar) => !foreignKeys.includes(scalar.name)
|
|
@@ -250,6 +262,10 @@ const getIdName = async (model) => {
|
|
|
250
262
|
if (!isServiceModel(schemaResult)) {
|
|
251
263
|
return void 0;
|
|
252
264
|
}
|
|
265
|
+
if (schemaResult.primaryKey?.fields.length) {
|
|
266
|
+
const { fields, name } = schemaResult.primaryKey;
|
|
267
|
+
return { fields, whereArg: name || fields.join("_") };
|
|
268
|
+
}
|
|
253
269
|
return schemaResult.fields.find((field) => field.isId)?.name;
|
|
254
270
|
};
|
|
255
271
|
const files = async ({
|
|
@@ -262,15 +278,26 @@ const files = async ({
|
|
|
262
278
|
const componentName = camelcase(pluralize(name));
|
|
263
279
|
const model = name;
|
|
264
280
|
const idName = await getIdName(model);
|
|
281
|
+
if (tests && rest.crud && idName !== void 0 && typeof idName !== "string") {
|
|
282
|
+
throw new Error(
|
|
283
|
+
`Cannot generate CRUD tests for "${model}": it has a compound primary key (@@id([${idName.fields.join(", ")}])), which isn't supported by the generated test file yet. Re-run with \`--tests=false\`.`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
265
286
|
const prismaImportSource = "src/lib/db";
|
|
266
287
|
let modelRelations;
|
|
288
|
+
let updateInputRequiredFields = [];
|
|
289
|
+
let nullableJsonFields = [];
|
|
290
|
+
let nullableRelations = [];
|
|
291
|
+
const schemaResult = await getSchema(model);
|
|
292
|
+
if (isServiceModel(schemaResult)) {
|
|
293
|
+
updateInputRequiredFields = requiredFieldsInUpdateInput(schemaResult);
|
|
294
|
+
nullableJsonFields = nullableJsonFieldsInInput(schemaResult);
|
|
295
|
+
nullableRelations = nullableRelationsForModel(schemaResult);
|
|
296
|
+
}
|
|
267
297
|
if (relations) {
|
|
268
298
|
modelRelations = relations;
|
|
269
|
-
} else {
|
|
270
|
-
|
|
271
|
-
if (isServiceModel(schemaResult)) {
|
|
272
|
-
modelRelations = relationsForModel(schemaResult);
|
|
273
|
-
}
|
|
299
|
+
} else if (isServiceModel(schemaResult)) {
|
|
300
|
+
modelRelations = relationsForModel(schemaResult);
|
|
274
301
|
}
|
|
275
302
|
const serviceFile = await templateForFile({
|
|
276
303
|
name,
|
|
@@ -283,49 +310,52 @@ const files = async ({
|
|
|
283
310
|
relations: modelRelations,
|
|
284
311
|
idName,
|
|
285
312
|
prismaImportSource,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const testFile = await templateForFile({
|
|
290
|
-
name,
|
|
291
|
-
side: "api",
|
|
292
|
-
sidePathSection: "services",
|
|
293
|
-
generator: "service",
|
|
294
|
-
outputPath: path.join(componentName, componentName + ".test.ts"),
|
|
295
|
-
templatePath: "test.ts.template",
|
|
296
|
-
templateVars: {
|
|
297
|
-
relations: relations || [],
|
|
298
|
-
create: await fieldsToInput(model),
|
|
299
|
-
update: await fieldsToUpdate(model),
|
|
300
|
-
types: await fieldTypes(model),
|
|
301
|
-
prismaImport: (await parseSchema(model)).scalarFields.some(
|
|
302
|
-
(field) => field.type === "Decimal"
|
|
303
|
-
),
|
|
304
|
-
prismaModel: model,
|
|
305
|
-
idName,
|
|
306
|
-
prismaImportSource,
|
|
307
|
-
...rest
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
const scenariosFile = await templateForFile({
|
|
311
|
-
name,
|
|
312
|
-
side: "api",
|
|
313
|
-
sidePathSection: "services",
|
|
314
|
-
generator: "service",
|
|
315
|
-
outputPath: path.join(componentName, componentName + ".scenarios.ts"),
|
|
316
|
-
templatePath: "scenarios.ts.template",
|
|
317
|
-
templateVars: {
|
|
318
|
-
scenario: await buildScenario(model),
|
|
319
|
-
stringifiedScenario: await buildStringifiedScenario(model),
|
|
320
|
-
prismaModel: model,
|
|
321
|
-
idName,
|
|
322
|
-
relations: modelRelations,
|
|
323
|
-
prismaImportSource,
|
|
313
|
+
updateInputRequiredFields,
|
|
314
|
+
nullableJsonFields,
|
|
315
|
+
nullableRelations,
|
|
324
316
|
...rest
|
|
325
317
|
}
|
|
326
318
|
});
|
|
327
319
|
const files2 = [serviceFile];
|
|
328
320
|
if (tests) {
|
|
321
|
+
const testFile = await templateForFile({
|
|
322
|
+
name,
|
|
323
|
+
side: "api",
|
|
324
|
+
sidePathSection: "services",
|
|
325
|
+
generator: "service",
|
|
326
|
+
outputPath: path.join(componentName, componentName + ".test.ts"),
|
|
327
|
+
templatePath: "test.ts.template",
|
|
328
|
+
templateVars: {
|
|
329
|
+
relations: relations || [],
|
|
330
|
+
create: await fieldsToInput(model),
|
|
331
|
+
update: await fieldsToUpdate(model),
|
|
332
|
+
types: await fieldTypes(model),
|
|
333
|
+
prismaImport: (await parseSchema(model)).scalarFields.some(
|
|
334
|
+
(field) => field.type === "Decimal"
|
|
335
|
+
),
|
|
336
|
+
prismaModel: model,
|
|
337
|
+
idName,
|
|
338
|
+
prismaImportSource,
|
|
339
|
+
...rest
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
const scenariosFile = await templateForFile({
|
|
343
|
+
name,
|
|
344
|
+
side: "api",
|
|
345
|
+
sidePathSection: "services",
|
|
346
|
+
generator: "service",
|
|
347
|
+
outputPath: path.join(componentName, componentName + ".scenarios.ts"),
|
|
348
|
+
templatePath: "scenarios.ts.template",
|
|
349
|
+
templateVars: {
|
|
350
|
+
scenario: await buildScenario(model),
|
|
351
|
+
stringifiedScenario: await buildStringifiedScenario(model),
|
|
352
|
+
prismaModel: model,
|
|
353
|
+
idName,
|
|
354
|
+
relations: modelRelations,
|
|
355
|
+
prismaImportSource,
|
|
356
|
+
...rest
|
|
357
|
+
}
|
|
358
|
+
});
|
|
329
359
|
files2.push(testFile);
|
|
330
360
|
files2.push(scenariosFile);
|
|
331
361
|
}
|
|
@@ -1,38 +1,65 @@
|
|
|
1
1
|
import type { QueryResolvers<% if (crud) { %>, MutationResolvers<% } %><% if (relations.length) { %>, ${singularPascalName}RelationResolvers<% } %> } from 'types/graphql'
|
|
2
2
|
|
|
3
|
-
import { db } from 'src/lib/db'
|
|
4
|
-
|
|
3
|
+
import { db<% if (crud && nullableJsonFields.length) { %>, Prisma<% } %> } from 'src/lib/db'
|
|
4
|
+
<%
|
|
5
|
+
// A compound `@@id([...])` key comes through as `{ fields, whereArg }`
|
|
6
|
+
// instead of a single field name -- build the destructure/where-clause
|
|
7
|
+
// snippets for both shapes here so the rest of the template can stay
|
|
8
|
+
// shape-agnostic.
|
|
9
|
+
const idIsComposite = idName != null && typeof idName === 'object'
|
|
10
|
+
const idFields = idIsComposite ? idName.fields : [idName]
|
|
11
|
+
const idArgs = idFields.join(', ')
|
|
12
|
+
const idWhere = idIsComposite
|
|
13
|
+
? `${idName.whereArg}: { ${idFields.join(', ')} }`
|
|
14
|
+
: idName
|
|
15
|
+
const idWhereFromRoot = idIsComposite
|
|
16
|
+
? `${idName.whereArg}: { ${idFields.map((f) => `${f}: root.${f}`).join(', ')} }`
|
|
17
|
+
: `${idName}: root.${idName}`
|
|
18
|
+
%>
|
|
5
19
|
export const ${pluralCamelName}: QueryResolvers['${pluralCamelName}'] = () => {
|
|
6
20
|
return db.${singularCamelName}.findMany()
|
|
7
21
|
}<% if (crud || relations.length) { %>
|
|
8
22
|
|
|
9
|
-
export const ${singularCamelName}: QueryResolvers['${singularCamelName}'] = ({ ${
|
|
23
|
+
export const ${singularCamelName}: QueryResolvers['${singularCamelName}'] = ({ ${idArgs} }) => {
|
|
10
24
|
return db.${singularCamelName}.findUnique({
|
|
11
|
-
where: { ${
|
|
25
|
+
where: { ${idWhere} },
|
|
12
26
|
})
|
|
13
27
|
}<% } %><% if (crud) { %>
|
|
14
28
|
|
|
15
29
|
export const create${singularPascalName}: MutationResolvers['create${singularPascalName}'] = ({ input }) => {
|
|
16
|
-
return db.${singularCamelName}.create({
|
|
17
|
-
data:
|
|
30
|
+
return db.${singularCamelName}.create({<% if (nullableJsonFields.length) { %>
|
|
31
|
+
data: {
|
|
32
|
+
...input,
|
|
33
|
+
// Prisma uses Prisma.DbNull, not null, to set a Json field to NULL<% nullableJsonFields.forEach((field) => { %>
|
|
34
|
+
${field}: input.${field} === null ? Prisma.DbNull : input.${field},<% }) %>
|
|
35
|
+
},<% } else { %>
|
|
36
|
+
data: input,<% } %>
|
|
18
37
|
})
|
|
19
38
|
}
|
|
20
39
|
|
|
21
|
-
export const update${singularPascalName}: MutationResolvers['update${singularPascalName}'] = ({ ${
|
|
22
|
-
return db.${singularCamelName}.update({
|
|
23
|
-
data:
|
|
24
|
-
|
|
40
|
+
export const update${singularPascalName}: MutationResolvers['update${singularPascalName}'] = ({ ${idArgs}, input }) => {
|
|
41
|
+
return db.${singularCamelName}.update({<% if (updateInputRequiredFields.length || nullableJsonFields.length) { %>
|
|
42
|
+
data: {
|
|
43
|
+
...input,<% if (updateInputRequiredFields.length) { %>
|
|
44
|
+
// Every field in the GraphQL input is nullable, but Prisma doesn't
|
|
45
|
+
// accept null for required fields. undefined leaves the field unchanged<% updateInputRequiredFields.forEach((field) => { %>
|
|
46
|
+
${field}: input.${field} ?? undefined,<% }) %><% } %><% if (nullableJsonFields.length) { %>
|
|
47
|
+
// Prisma uses Prisma.DbNull, not null, to set a Json field to NULL<% nullableJsonFields.forEach((field) => { %>
|
|
48
|
+
${field}: input.${field} === null ? Prisma.DbNull : input.${field},<% }) %><% } %>
|
|
49
|
+
},<% } else { %>
|
|
50
|
+
data: input,<% } %>
|
|
51
|
+
where: { ${idWhere} },
|
|
25
52
|
})
|
|
26
53
|
}
|
|
27
54
|
|
|
28
|
-
export const delete${singularPascalName}: MutationResolvers['delete${singularPascalName}'] = ({ ${
|
|
55
|
+
export const delete${singularPascalName}: MutationResolvers['delete${singularPascalName}'] = ({ ${idArgs} }) => {
|
|
29
56
|
return db.${singularCamelName}.delete({
|
|
30
|
-
where: { ${
|
|
57
|
+
where: { ${idWhere} },
|
|
31
58
|
})
|
|
32
59
|
}<% } %><% if (relations.length) { %>
|
|
33
60
|
|
|
34
61
|
export const ${singularPascalName}: ${singularPascalName}RelationResolvers = {<% relations.forEach(relation => { %>
|
|
35
62
|
${relation}: (_obj, { root }) => {
|
|
36
|
-
return db.${singularCamelName}.findUnique({ where: { ${
|
|
63
|
+
return db.${singularCamelName}.findUnique<%= nullableRelations.includes(relation) ? '' : 'OrThrow' %>({ where: { ${idWhereFromRoot} } }).${relation}()
|
|
37
64
|
},<% }) %>
|
|
38
65
|
}<% } %>
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
// Looks for quoted strings, either by single (') or double (") quotes.
|
|
8
8
|
// When found
|
|
9
9
|
// - Removes the quotes around `scenario` variables.
|
|
10
|
-
// - Removes the quotes around `BigInt` fields.
|
|
11
|
-
|
|
10
|
+
// - Removes the quotes around `BigInt` fields. GraphQL inputs type BigInt
|
|
11
|
+
// values as numbers, so the `n` suffix is also removed when `asInput` is
|
|
12
|
+
// set
|
|
13
|
+
const transformValue = (obj, type, asInput = false) => {
|
|
12
14
|
if (type === 'DateTime') {
|
|
13
15
|
return `new Date('${obj.toISOString()}')`
|
|
14
16
|
} else if (type === 'Decimal') {
|
|
@@ -22,7 +24,7 @@
|
|
|
22
24
|
|
|
23
25
|
// BigInt
|
|
24
26
|
if (string.match(/^\"\d+n\"$/)) {
|
|
25
|
-
return string.slice(1, string.length - 1)
|
|
27
|
+
return string.slice(1, string.length - (asInput ? 2 : 1))
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
return string
|
|
@@ -40,7 +42,7 @@ import type { StandardScenario } from './${pluralCamelName}.scenarios.js'
|
|
|
40
42
|
// and can fail without adjustments, e.g. Float.
|
|
41
43
|
// Please refer to the RedwoodJS Testing Docs:
|
|
42
44
|
// https://cedarjs.com/docs/testing#testing-services
|
|
43
|
-
// https://cedarjs.com/docs/testing#
|
|
45
|
+
// https://cedarjs.com/docs/testing#expect-type-considerations
|
|
44
46
|
|
|
45
47
|
describe('${pluralCamelName}', () => {
|
|
46
48
|
scenario('returns all ${pluralCamelName}', async (scenario: StandardScenario) => {
|
|
@@ -57,7 +59,7 @@ describe('${pluralCamelName}', () => {
|
|
|
57
59
|
|
|
58
60
|
<% if (create) { %>scenario('creates a ${singularCamelName}', async (${transformValue(create).includes('scenario.') ? 'scenario: StandardScenario' : ''}) => {
|
|
59
61
|
const result = await create${singularPascalName}({
|
|
60
|
-
input: ${transformValue(create)},
|
|
62
|
+
input: ${transformValue(create, undefined, true)},
|
|
61
63
|
})
|
|
62
64
|
|
|
63
65
|
<% for (const [name, value] of Object.entries(create)) { %>
|
|
@@ -68,7 +70,7 @@ describe('${pluralCamelName}', () => {
|
|
|
68
70
|
const original = await (${singularCamelName}({ ${idName}: scenario.${singularCamelName}.one.${idName} })) as ${prismaModel}
|
|
69
71
|
const result = await update${singularPascalName}({
|
|
70
72
|
${idName}: original.${idName},
|
|
71
|
-
input: ${transformValue(update)},
|
|
73
|
+
input: ${transformValue(update, undefined, true)},
|
|
72
74
|
})
|
|
73
75
|
|
|
74
76
|
<% for (const [name, value] of Object.entries(update)) { %>
|
|
@@ -3,7 +3,8 @@ import path from "node:path";
|
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
5
|
import pascalcase from "pascalcase";
|
|
6
|
-
import {
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
7
8
|
import { ensurePosixPath, getConfig } from "@cedarjs/project-config";
|
|
8
9
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
10
|
import { generateTemplate, getPaths, writeFilesTask } from "../../lib/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
2
|
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
4
4
|
import * as generateCell from "./generate/cell/cell.js";
|
|
5
5
|
import * as generateComponent from "./generate/component/component.js";
|
|
6
6
|
import * as generateDataMigration from "./generate/dataMigration/dataMigration.js";
|
package/dist/commands/info.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import envinfo from "envinfo";
|
|
4
4
|
import { terminalLink } from "termi-link";
|
|
5
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
6
|
import { getConfigPath } from "@cedarjs/project-config";
|
|
7
7
|
const command = "info";
|
|
8
8
|
const description = "Print your system environment information";
|
|
@@ -7,9 +7,11 @@ const handler = async ({
|
|
|
7
7
|
commands: _commands,
|
|
8
8
|
...options
|
|
9
9
|
}) => {
|
|
10
|
-
const positionalArgs = Array.isArray(_) ?
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const positionalArgs = (Array.isArray(_) ? _ : []).map(String);
|
|
11
|
+
if (positionalArgs[0] === "jobs") {
|
|
12
|
+
positionalArgs.shift();
|
|
13
|
+
}
|
|
14
|
+
const args = positionalArgs.length > 0 ? positionalArgs : [""];
|
|
13
15
|
for (const [name, value] of Object.entries(options)) {
|
|
14
16
|
args.push(name.length > 1 ? `--${name}` : `-${name}`);
|
|
15
17
|
args.push(String(value));
|
package/dist/commands/lint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { terminalLink } from "termi-link";
|
|
3
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
3
|
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
5
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
6
|
const command = "lint [paths..]";
|
|
7
7
|
const description = "Lint your files";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import {
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
5
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
6
|
-
import {
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
7
|
+
import { getConfig, getParsedScalars, getPaths } from "@cedarjs/project-config";
|
|
7
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
9
|
import { runScriptFunction } from "../lib/exec.js";
|
|
9
10
|
import { configureBabel } from "../lib/execBabel.js";
|
|
@@ -93,7 +94,7 @@ async function expandRouteParameters(route) {
|
|
|
93
94
|
return [route];
|
|
94
95
|
}
|
|
95
96
|
const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
96
|
-
const detector =
|
|
97
|
+
const detector = await import("@cedarjs/prerender/detection");
|
|
97
98
|
const detectedRoutes = detector.detectPrerenderRoutes();
|
|
98
99
|
const prerenderRoutes = detectedRoutes.filter(hasPath).map(normalizeRoute);
|
|
99
100
|
if (prerenderRoutes.length === 0) {
|
|
@@ -105,6 +106,12 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
105
106
|
);
|
|
106
107
|
return [];
|
|
107
108
|
}
|
|
109
|
+
const parsedScalars = Object.keys(getParsedScalars());
|
|
110
|
+
if (parsedScalars.length > 0) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
"Prerendering does not support `graphql.parsedScalars` yet. A prerendered Cell gets the raw GraphQL response, so " + parsedScalars.join(", ") + " would be a string when prerendering and parsed in the browser. Either remove the `prerender` prop from your routes, or remove `graphql.parsedScalars` from cedar.toml."
|
|
113
|
+
);
|
|
114
|
+
}
|
|
108
115
|
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
109
116
|
if (!fs.existsSync(indexHtmlPath)) {
|
|
110
117
|
console.error(
|
|
@@ -116,7 +123,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
116
123
|
const expandedRouteParameters = await Promise.all(
|
|
117
124
|
prerenderRoutes.map((route) => expandRouteParameters(route))
|
|
118
125
|
);
|
|
119
|
-
const prerenderer =
|
|
126
|
+
const prerenderer = await import("@cedarjs/prerender");
|
|
120
127
|
const listrTasks = expandedRouteParameters.flatMap((routesToPrerender) => {
|
|
121
128
|
const queryCache = {};
|
|
122
129
|
const shouldFold = routesToPrerender.length > 16;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import boxen from "boxen";
|
|
3
|
-
import {
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
4
|
import {
|
|
5
5
|
formatCedarCommand,
|
|
6
6
|
formatRunBinCommand,
|
|
7
7
|
formatRunTransitiveBinCommand
|
|
8
8
|
} from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
9
|
import { runTransitiveBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
10
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
10
11
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
11
12
|
import { getPaths } from "../lib/index.js";
|
|
12
13
|
const getErrorMessage = (error) => {
|
|
@@ -62,7 +63,11 @@ const handler = async ({
|
|
|
62
63
|
try {
|
|
63
64
|
runTransitiveBinSync("prisma", args, {
|
|
64
65
|
cwd: cedarPaths.base,
|
|
65
|
-
stdio:
|
|
66
|
+
stdio: [
|
|
67
|
+
process.stdin.isTTY && !process.env.CI ? "inherit" : "pipe",
|
|
68
|
+
"inherit",
|
|
69
|
+
"inherit"
|
|
70
|
+
]
|
|
66
71
|
});
|
|
67
72
|
if (hasHelpOption || args.length === 0) {
|
|
68
73
|
printWrapInfo();
|
package/dist/commands/serve.js
CHANGED
|
@@ -5,7 +5,8 @@ import { serve as serveSrvx } from "srvx";
|
|
|
5
5
|
import { terminalLink } from "termi-link";
|
|
6
6
|
import * as apiServerCLIConfig from "@cedarjs/api-server/apiCliConfig";
|
|
7
7
|
import * as bothServerCLIConfig from "@cedarjs/api-server/bothCliConfig";
|
|
8
|
-
import {
|
|
8
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
9
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
9
10
|
import * as webServerCLIConfig from "@cedarjs/web-server";
|
|
10
11
|
import { getPaths, getConfig } from "../lib/index.js";
|
|
11
12
|
import { serverFileExists } from "../lib/project.js";
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { terminalLink } from "termi-link";
|
|
4
|
-
import {
|
|
5
|
-
recordTelemetryAttributes,
|
|
6
|
-
standardAuthBuilder
|
|
7
|
-
} from "@cedarjs/cli-helpers";
|
|
4
|
+
import { standardAuthBuilder } from "@cedarjs/cli-helpers/auth/setupHelpers";
|
|
8
5
|
import { addRootPackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
9
7
|
import { getPaths } from "../../../lib/index.js";
|
|
10
8
|
const command = "auth <provider>";
|
|
11
9
|
const description = "Set up an auth configuration";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
3
3
|
const command = "cache <client>";
|
|
4
4
|
const description = "Sets up an init file for service caching";
|
|
5
5
|
const builder = (yargs) => {
|
|
@@ -2,7 +2,8 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { terminalLink } from "termi-link";
|
|
5
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { addEnvVarTask } from "@cedarjs/cli-helpers/project";
|
|
6
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
8
|
import { addPackagesTask, getPaths, writeFile } from "../../../lib/index.js";
|
|
8
9
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
@@ -10,21 +10,18 @@ const memJsFormattedLogger = {
|
|
|
10
10
|
log: (msg: string) => logger.error(msg),
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// The client connects to Memcached the first time it's used. If it can't
|
|
14
|
+
// connect, the error is logged and `cache()` runs the uncached function
|
|
15
|
+
// instead
|
|
16
|
+
export const client =
|
|
17
|
+
process.env.NODE_ENV === 'test'
|
|
18
|
+
? new InMemoryClient()
|
|
19
|
+
: new MemcachedClient(process.env.CACHE_HOST, {
|
|
20
|
+
logger: memJsFormattedLogger,
|
|
21
|
+
})
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
client
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
logger: memJsFormattedLogger,
|
|
21
|
-
})
|
|
22
|
-
} catch (e) {
|
|
23
|
-
logger.error(`Could not connect to cache: ${e.message}`)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const { cache, cacheFindMany, cacheClient, deleteCacheKey } = createCache(client, {
|
|
28
|
-
logger,
|
|
29
|
-
timeout: 500,
|
|
30
|
-
})
|
|
23
|
+
export const { cache, cacheFindMany, cacheClient, deleteCacheKey } =
|
|
24
|
+
createCache(client, {
|
|
25
|
+
logger,
|
|
26
|
+
timeout: 500,
|
|
27
|
+
})
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createCache,
|
|
3
|
-
InMemoryClient,
|
|
4
|
-
RedisClient,
|
|
5
|
-
} from '@cedarjs/api/cache'
|
|
1
|
+
import { createCache, InMemoryClient, RedisClient } from '@cedarjs/api/cache'
|
|
6
2
|
|
|
7
3
|
import { logger } from './logger'
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
// The client connects to Redis the first time it's used. If it can't connect,
|
|
6
|
+
// the error is logged and `cache()` runs the uncached function instead
|
|
7
|
+
export const client =
|
|
8
|
+
process.env.NODE_ENV === 'test'
|
|
9
|
+
? new InMemoryClient()
|
|
10
|
+
: new RedisClient({ url: process.env.CACHE_HOST, logger })
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
client
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} catch (e) {
|
|
17
|
-
logger.error(`Could not connect to cache: ${e.message}`)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const { cache, cacheFindMany, cacheClient, deleteCacheKey } = createCache(client, {
|
|
22
|
-
logger,
|
|
23
|
-
timeout: 500,
|
|
24
|
-
})
|
|
12
|
+
export const { cache, cacheFindMany, cacheClient, deleteCacheKey } =
|
|
13
|
+
createCache(client, {
|
|
14
|
+
logger,
|
|
15
|
+
timeout: 500,
|
|
16
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
const command = "postgres";
|
|
3
3
|
const description = "Switch your project from SQLite to PostgreSQL (schema, dependencies, and database adapter)";
|
|
4
4
|
function builder(yargs) {
|
|
@@ -2,9 +2,11 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
|
-
import { colors
|
|
5
|
+
import { colors } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { installPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
6
7
|
import { prettyPrintCedarCommand } from "@cedarjs/cli-helpers/packageManager";
|
|
7
8
|
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
9
|
+
import { getPaths } from "@cedarjs/cli-helpers/paths";
|
|
8
10
|
import { resolveFile } from "@cedarjs/project-config";
|
|
9
11
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
10
12
|
function checkProjectShape(cedarPaths) {
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { MONITORS } from "../../../deploy/baremetal/monitors.js";
|
|
1
2
|
import { createHandler } from "../helpers/helpers.js";
|
|
2
3
|
const command = "baremetal";
|
|
3
4
|
const description = "Setup Baremetal deploy";
|
|
5
|
+
const builder = (yargs) => yargs.option("monitor", {
|
|
6
|
+
description: "Process monitor to generate config for. Asks when not given. pm2 gets an ecosystem.config.js, systemd gets unit files in systemd/",
|
|
7
|
+
choices: MONITORS,
|
|
8
|
+
type: "string"
|
|
9
|
+
});
|
|
4
10
|
const handler = createHandler("baremetal");
|
|
5
11
|
export {
|
|
12
|
+
builder,
|
|
6
13
|
command,
|
|
7
14
|
description,
|
|
8
15
|
handler
|