@cedarjs/cli 6.0.2 → 6.0.3-next.227
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 +1 -1
- package/dist/commands/deploy/baremetal.js +1 -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 +2 -1
- 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/experimental/templates/opentelemetry.ts.template +13 -7
- 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/dbAuthHandler.js +23 -3
- 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 +2 -1
- package/dist/commands/generate/function/functionHandler.js +2 -1
- 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/package/filesTask.js +9 -12
- package/dist/commands/generate/package/packageHandler.js +3 -4
- 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/subscriptions/blank/blank.ts.template +1 -1
- package/dist/commands/generate/scaffold/scaffoldHandler.js +2 -1
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +1 -1
- package/dist/commands/generate/script/scriptHandler.js +2 -1
- package/dist/commands/generate/sdl/sdlHandler.js +2 -1
- package/dist/commands/generate/secret/secret.js +1 -1
- package/dist/commands/generate/service/serviceHandler.js +47 -38
- package/dist/commands/generate/service/templates/service.ts.template +22 -8
- package/dist/commands/generate/service/templates/test.ts.template +1 -1
- 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/lint.js +1 -1
- package/dist/commands/prerenderHandler.js +5 -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/database/postgres.js +1 -1
- package/dist/commands/setup/database/postgresHandler.js +3 -1
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +2 -1
- 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/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 +2 -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 +8 -7
- 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/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 +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 +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/libraries/chakra-uiHandler.js +2 -1
- package/dist/commands/setup/ui/libraries/mantineHandler.js +2 -1
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +2 -1
- 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 +256 -69
- package/dist/commands/setup.js +2 -2
- package/dist/commands/studio.js +1 -1
- package/dist/commands/test/testHandler.js +35 -72
- 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 -9
- package/dist/lib/exit.js +1 -1
- package/dist/lib/index.js +6 -25
- package/dist/lib/loadEnvFiles.js +1 -1
- package/dist/lib/plugin.js +1 -2
- package/dist/lib/test.js +1 -1
- package/dist/lib/updateCheck.js +5 -5
- package/dist/middleware/checkNodeVersion.js +4 -4
- package/dist/telemetry/index.js +4 -4
- package/dist/telemetry/resource.js +1 -1
- package/dist/telemetry/send.js +7 -2
- package/package.json +26 -26
- package/dist/commands/setup/tsconfig/tsconfig.js +0 -25
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +0 -62
- 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 -100
- package/dist/commands/testEsm.js +0 -41
- package/dist/commands/ts-to-js.js +0 -20
|
@@ -4,9 +4,8 @@ import { Listr } from "listr2";
|
|
|
4
4
|
import pascalcase from "pascalcase";
|
|
5
5
|
import pluralize from "pluralize";
|
|
6
6
|
import prompts from "prompts";
|
|
7
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
7
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
8
8
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
9
|
-
import { projectIsEsm } from "@cedarjs/project-config";
|
|
10
9
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
11
10
|
import {
|
|
12
11
|
generateTemplate,
|
|
@@ -120,16 +119,10 @@ async function handler({
|
|
|
120
119
|
exampleFile,
|
|
121
120
|
exampleSubscriptionTemplateContent
|
|
122
121
|
);
|
|
123
|
-
|
|
122
|
+
const blankTemplateContent = await generateTemplate(
|
|
124
123
|
setupScriptContent,
|
|
125
124
|
templateVariables(name)
|
|
126
125
|
);
|
|
127
|
-
if (projectIsEsm()) {
|
|
128
|
-
blankTemplateContent = blankTemplateContent.replace(
|
|
129
|
-
"import gql from 'graphql-tag'",
|
|
130
|
-
"import { gql } from 'graphql-tag'"
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
126
|
return [
|
|
134
127
|
writeFile(
|
|
135
128
|
sdlFile,
|
|
@@ -5,12 +5,13 @@ import { paramCase } from "change-case";
|
|
|
5
5
|
import humanize from "humanize-string";
|
|
6
6
|
import { Listr } from "listr2";
|
|
7
7
|
import pascalcase from "pascalcase";
|
|
8
|
-
import {
|
|
8
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
9
9
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
10
10
|
import {
|
|
11
11
|
addWorkspacePackages,
|
|
12
12
|
removeWorkspacePackages
|
|
13
13
|
} from "@cedarjs/cli-helpers/packageManager/packages";
|
|
14
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
14
15
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
15
16
|
import { getConfig } from "@cedarjs/project-config";
|
|
16
17
|
import { pluralize, singularize } from "@cedarjs/utils/cedarPluralize";
|
|
@@ -1,7 +1,8 @@
|
|
|
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
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
6
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
6
7
|
import {
|
|
7
8
|
getPaths,
|
|
@@ -2,8 +2,9 @@ import ansis from "ansis";
|
|
|
2
2
|
import boxen from "boxen";
|
|
3
3
|
import camelcase from "camelcase";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
6
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
7
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
7
8
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
8
9
|
import { getConfig } from "@cedarjs/project-config";
|
|
9
10
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import { terminalLink } from "termi-link";
|
|
3
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
4
4
|
const DEFAULT_LENGTH = 32;
|
|
5
5
|
const generateSecret = (length = DEFAULT_LENGTH) => {
|
|
6
6
|
return crypto.randomBytes(Math.trunc(length)).toString("base64");
|
|
@@ -250,6 +250,10 @@ const getIdName = async (model) => {
|
|
|
250
250
|
if (!isServiceModel(schemaResult)) {
|
|
251
251
|
return void 0;
|
|
252
252
|
}
|
|
253
|
+
if (schemaResult.primaryKey?.fields.length) {
|
|
254
|
+
const { fields, name } = schemaResult.primaryKey;
|
|
255
|
+
return { fields, whereArg: name || fields.join("_") };
|
|
256
|
+
}
|
|
253
257
|
return schemaResult.fields.find((field) => field.isId)?.name;
|
|
254
258
|
};
|
|
255
259
|
const files = async ({
|
|
@@ -262,6 +266,11 @@ const files = async ({
|
|
|
262
266
|
const componentName = camelcase(pluralize(name));
|
|
263
267
|
const model = name;
|
|
264
268
|
const idName = await getIdName(model);
|
|
269
|
+
if (tests && rest.crud && idName !== void 0 && typeof idName !== "string") {
|
|
270
|
+
throw new Error(
|
|
271
|
+
`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\`.`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
265
274
|
const prismaImportSource = "src/lib/db";
|
|
266
275
|
let modelRelations;
|
|
267
276
|
if (relations) {
|
|
@@ -286,46 +295,46 @@ const files = async ({
|
|
|
286
295
|
...rest
|
|
287
296
|
}
|
|
288
297
|
});
|
|
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,
|
|
324
|
-
...rest
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
298
|
const files2 = [serviceFile];
|
|
328
299
|
if (tests) {
|
|
300
|
+
const testFile = await templateForFile({
|
|
301
|
+
name,
|
|
302
|
+
side: "api",
|
|
303
|
+
sidePathSection: "services",
|
|
304
|
+
generator: "service",
|
|
305
|
+
outputPath: path.join(componentName, componentName + ".test.ts"),
|
|
306
|
+
templatePath: "test.ts.template",
|
|
307
|
+
templateVars: {
|
|
308
|
+
relations: relations || [],
|
|
309
|
+
create: await fieldsToInput(model),
|
|
310
|
+
update: await fieldsToUpdate(model),
|
|
311
|
+
types: await fieldTypes(model),
|
|
312
|
+
prismaImport: (await parseSchema(model)).scalarFields.some(
|
|
313
|
+
(field) => field.type === "Decimal"
|
|
314
|
+
),
|
|
315
|
+
prismaModel: model,
|
|
316
|
+
idName,
|
|
317
|
+
prismaImportSource,
|
|
318
|
+
...rest
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
const scenariosFile = await templateForFile({
|
|
322
|
+
name,
|
|
323
|
+
side: "api",
|
|
324
|
+
sidePathSection: "services",
|
|
325
|
+
generator: "service",
|
|
326
|
+
outputPath: path.join(componentName, componentName + ".scenarios.ts"),
|
|
327
|
+
templatePath: "scenarios.ts.template",
|
|
328
|
+
templateVars: {
|
|
329
|
+
scenario: await buildScenario(model),
|
|
330
|
+
stringifiedScenario: await buildStringifiedScenario(model),
|
|
331
|
+
prismaModel: model,
|
|
332
|
+
idName,
|
|
333
|
+
relations: modelRelations,
|
|
334
|
+
prismaImportSource,
|
|
335
|
+
...rest
|
|
336
|
+
}
|
|
337
|
+
});
|
|
329
338
|
files2.push(testFile);
|
|
330
339
|
files2.push(scenariosFile);
|
|
331
340
|
}
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import type { QueryResolvers<% if (crud) { %>, MutationResolvers<% } %><% if (relations.length) { %>, ${singularPascalName}RelationResolvers<% } %> } from 'types/graphql'
|
|
2
2
|
|
|
3
3
|
import { db } from 'src/lib/db'
|
|
4
|
-
|
|
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
|
|
|
@@ -18,21 +32,21 @@ export const create${singularPascalName}: MutationResolvers['create${singularPas
|
|
|
18
32
|
})
|
|
19
33
|
}
|
|
20
34
|
|
|
21
|
-
export const update${singularPascalName}: MutationResolvers['update${singularPascalName}'] = ({ ${
|
|
35
|
+
export const update${singularPascalName}: MutationResolvers['update${singularPascalName}'] = ({ ${idArgs}, input }) => {
|
|
22
36
|
return db.${singularCamelName}.update({
|
|
23
37
|
data: input,
|
|
24
|
-
where: { ${
|
|
38
|
+
where: { ${idWhere} },
|
|
25
39
|
})
|
|
26
40
|
}
|
|
27
41
|
|
|
28
|
-
export const delete${singularPascalName}: MutationResolvers['delete${singularPascalName}'] = ({ ${
|
|
42
|
+
export const delete${singularPascalName}: MutationResolvers['delete${singularPascalName}'] = ({ ${idArgs} }) => {
|
|
29
43
|
return db.${singularCamelName}.delete({
|
|
30
|
-
where: { ${
|
|
44
|
+
where: { ${idWhere} },
|
|
31
45
|
})
|
|
32
46
|
}<% } %><% if (relations.length) { %>
|
|
33
47
|
|
|
34
48
|
export const ${singularPascalName}: ${singularPascalName}RelationResolvers = {<% relations.forEach(relation => { %>
|
|
35
49
|
${relation}: (_obj, { root }) => {
|
|
36
|
-
return db.${singularCamelName}.findUnique({ where: { ${
|
|
50
|
+
return db.${singularCamelName}.findUnique({ where: { ${idWhereFromRoot} } }).${relation}()
|
|
37
51
|
},<% }) %>
|
|
38
52
|
}<% } %>
|
|
@@ -40,7 +40,7 @@ import type { StandardScenario } from './${pluralCamelName}.scenarios.js'
|
|
|
40
40
|
// and can fail without adjustments, e.g. Float.
|
|
41
41
|
// Please refer to the RedwoodJS Testing Docs:
|
|
42
42
|
// https://cedarjs.com/docs/testing#testing-services
|
|
43
|
-
// https://cedarjs.com/docs/testing#
|
|
43
|
+
// https://cedarjs.com/docs/testing#expect-type-considerations
|
|
44
44
|
|
|
45
45
|
describe('${pluralCamelName}', () => {
|
|
46
46
|
scenario('returns all ${pluralCamelName}', async (scenario: StandardScenario) => {
|
|
@@ -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";
|
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, 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) {
|
|
@@ -116,7 +117,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
116
117
|
const expandedRouteParameters = await Promise.all(
|
|
117
118
|
prerenderRoutes.map((route) => expandRouteParameters(route))
|
|
118
119
|
);
|
|
119
|
-
const prerenderer =
|
|
120
|
+
const prerenderer = await import("@cedarjs/prerender");
|
|
120
121
|
const listrTasks = expandedRouteParameters.flatMap((routesToPrerender) => {
|
|
121
122
|
const queryCache = {};
|
|
122
123
|
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";
|
|
@@ -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) {
|
|
@@ -2,7 +2,8 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import prompts from "prompts";
|
|
5
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
8
|
import {
|
|
8
9
|
addPackagesTask,
|
|
@@ -3,16 +3,17 @@ import path from "path";
|
|
|
3
3
|
import prismaInternals from "@prisma/internals";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
5
|
import * as toml from "smol-toml";
|
|
6
|
-
import {
|
|
7
|
-
colors as c,
|
|
8
|
-
isTypeScriptProject,
|
|
9
|
-
getConfigPath
|
|
10
|
-
} from "@cedarjs/cli-helpers";
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
11
7
|
import {
|
|
12
8
|
formatCedarCommand,
|
|
13
9
|
formatRunBinCommand
|
|
14
10
|
} from "@cedarjs/cli-helpers/packageManager/display";
|
|
15
|
-
import {
|
|
11
|
+
import { isTypeScriptProject } from "@cedarjs/cli-helpers/project";
|
|
12
|
+
import {
|
|
13
|
+
getConfigPath,
|
|
14
|
+
getPaths,
|
|
15
|
+
getPrismaSchemas
|
|
16
|
+
} from "@cedarjs/project-config";
|
|
16
17
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
17
18
|
import { printSetupNotes } from "../../../../lib/index.js";
|
|
18
19
|
import { serverFileExists } from "../../../../lib/project.js";
|
|
@@ -3,8 +3,9 @@ import { EOL } from "os";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import prismaInternals from "@prisma/internals";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
|
-
import {
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
7
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
8
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
8
9
|
import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
|
|
9
10
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
10
11
|
import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "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 { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
8
|
import {
|
|
8
9
|
addPackagesTask,
|
|
@@ -2,7 +2,8 @@ import path from "path";
|
|
|
2
2
|
import prismaInternals from "@prisma/internals";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import prompts from "prompts";
|
|
5
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
7
|
import { getPaths, getPrismaSchemas } from "@cedarjs/project-config";
|
|
7
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
9
|
import { writeFilesTask, printSetupNotes } from "../../../../lib/index.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
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
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
6
|
import { getSchemaPath, getConfigPath } from "@cedarjs/project-config";
|
|
6
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
8
|
import {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
recordTelemetryAttributes
|
|
9
|
-
} from "@cedarjs/cli-helpers";
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { getPaths } from "@cedarjs/cli-helpers/paths";
|
|
6
|
+
import { isTypeScriptProject } from "@cedarjs/cli-helpers/project";
|
|
7
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
10
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
11
9
|
import { printSetupNotes } from "../../../../lib/index.js";
|
|
12
10
|
const notes = [
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "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 { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
8
|
import {
|
|
8
9
|
addPackagesTask,
|
|
@@ -3,7 +3,8 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import execa from "execa";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
|
-
import {
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
|
+
import { writeFile } from "@cedarjs/cli-helpers/fileHelpers";
|
|
7
8
|
import { dedupe } from "@cedarjs/cli-helpers/packageManager";
|
|
8
9
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
10
|
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { terminalLink } from "termi-link";
|
|
4
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
5
|
const command = "generator <name>";
|
|
6
6
|
const description = "Copies generator templates locally for customization";
|
|
7
7
|
const EXCLUDE_GENERATORS = ["dataMigration", "dbAuth", "generator", "secret"];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
5
|
import { getPaths } from "../../../lib/index.js";
|
|
6
6
|
const SIDE_MAP = {
|
|
7
7
|
web: ["cell", "component", "layout", "page", "scaffold"],
|