@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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
3
|
import {
|
|
5
4
|
runBin,
|
|
6
5
|
runTransitiveBin,
|
|
7
6
|
runWithNode
|
|
8
7
|
} from "@cedarjs/cli-helpers/packageManager/exec";
|
|
8
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
9
9
|
import { getPaths } from "@cedarjs/project-config";
|
|
10
10
|
async function runBinWithThrow(bin, args, options) {
|
|
11
11
|
const result = await runBin(bin, args, options);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import execa from "execa";
|
|
2
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
3
3
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
5
|
const deployHandler = ({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { deployBuilder } from "./helpers/deployBuilder.js";
|
|
3
3
|
const command = "netlify [...commands]";
|
|
4
4
|
const description = "Build command for Netlify deploy";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
3
|
import { formatAddRootPackagesCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
5
4
|
import {
|
|
6
5
|
runBinSync,
|
|
@@ -8,6 +7,7 @@ import {
|
|
|
8
7
|
runWithNode
|
|
9
8
|
} from "@cedarjs/cli-helpers/packageManager/exec";
|
|
10
9
|
import { installPackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
10
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
11
11
|
import { getPaths } from "@cedarjs/project-config";
|
|
12
12
|
const handler = async ({
|
|
13
13
|
side,
|
|
@@ -6,12 +6,13 @@ import { config } from "dotenv-defaults";
|
|
|
6
6
|
import execa from "execa";
|
|
7
7
|
import { Listr } from "listr2";
|
|
8
8
|
import prompts from "prompts";
|
|
9
|
-
import {
|
|
9
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
10
10
|
import {
|
|
11
11
|
formatAddRootPackagesCommand,
|
|
12
12
|
formatRunBinCommand
|
|
13
13
|
} from "@cedarjs/cli-helpers/packageManager/display";
|
|
14
14
|
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
15
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
15
16
|
import { getPaths } from "../../lib/index.js";
|
|
16
17
|
const preRequisites = () => [
|
|
17
18
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { deployBuilder } from "./helpers/deployBuilder.js";
|
|
3
3
|
const command = "vercel [...commands]";
|
|
4
4
|
const description = "Build command for Vercel deploy";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Listr } from "listr2";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
3
3
|
import { deleteFilesTask } from "../../lib/index.js";
|
|
4
4
|
function tasks({ componentName, filesFn, name }) {
|
|
5
5
|
return new Listr(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import camelcase from "camelcase";
|
|
2
2
|
import { Listr } from "listr2";
|
|
3
|
-
import {
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
4
5
|
import {
|
|
5
6
|
deleteFilesTask,
|
|
6
7
|
removeRoutesFromRouterTask
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
1
2
|
import { Listr } from "listr2";
|
|
2
|
-
import
|
|
3
|
-
import { recordTelemetryAttributes
|
|
4
|
-
import { pluralize } from "@cedarjs/utils/cedarPluralize";
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
5
|
import {
|
|
6
6
|
deleteFilesTask,
|
|
7
7
|
getPaths,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
13
13
|
import {
|
|
14
14
|
files,
|
|
15
|
+
getScaffoldLayoutNames,
|
|
15
16
|
routes as scaffoldRoutes,
|
|
16
17
|
splitPathAndModel
|
|
17
18
|
} from "../../generate/scaffold/scaffoldHandler.js";
|
|
@@ -22,45 +23,83 @@ const removeRoutesWithSet = async ({
|
|
|
22
23
|
}) => {
|
|
23
24
|
const routes = await scaffoldRoutes({ model, path, nestScaffoldByModel });
|
|
24
25
|
const routeNames = routes.map(extractRouteName);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const { importName } = getScaffoldLayoutNames(model, path);
|
|
27
|
+
return removeRoutesFromRouterTask(routeNames, importName);
|
|
28
|
+
};
|
|
29
|
+
const removeNamedImport = (code, source, name) => {
|
|
30
|
+
const program = parse(code, {
|
|
31
|
+
sourceType: "module",
|
|
32
|
+
plugins: ["jsx", "typescript"]
|
|
33
|
+
}).program;
|
|
34
|
+
for (const statement of program.body) {
|
|
35
|
+
if (statement.type !== "ImportDeclaration" || statement.source.value !== source) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const specifiers = statement.specifiers;
|
|
39
|
+
const index = specifiers.findIndex(
|
|
40
|
+
(specifier2) => specifier2.type === "ImportSpecifier" && specifier2.imported.type === "Identifier" && specifier2.imported.name === name && specifier2.local.name === name
|
|
41
|
+
);
|
|
42
|
+
if (index === -1) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const specifier = specifiers[index];
|
|
46
|
+
let start;
|
|
47
|
+
let end;
|
|
48
|
+
if (specifiers.length === 1) {
|
|
49
|
+
start = statement.start ?? 0;
|
|
50
|
+
end = statement.end ?? 0;
|
|
51
|
+
if (code[end] === "\n") {
|
|
52
|
+
end++;
|
|
53
|
+
}
|
|
54
|
+
} else if (index === specifiers.length - 1) {
|
|
55
|
+
start = specifiers[index - 1].end ?? 0;
|
|
56
|
+
end = specifier.end ?? 0;
|
|
57
|
+
} else {
|
|
58
|
+
start = specifier.start ?? 0;
|
|
59
|
+
end = specifiers[index + 1].start ?? 0;
|
|
60
|
+
}
|
|
61
|
+
return code.slice(0, start) + code.slice(end);
|
|
62
|
+
}
|
|
63
|
+
return code;
|
|
28
64
|
};
|
|
29
65
|
const removeSetImport = () => {
|
|
30
66
|
const routesPath = getPaths().web.routes;
|
|
31
67
|
const routesContent = readFile(routesPath).toString();
|
|
32
|
-
|
|
68
|
+
const unusedNames = ["Set", "PrivateSet"].filter(
|
|
69
|
+
(name) => !new RegExp(`<${name}\\b`).test(routesContent)
|
|
70
|
+
);
|
|
71
|
+
if (unusedNames.length === 0) {
|
|
33
72
|
return "Skipping removal of Set import in Routes.{jsx,tsx}";
|
|
34
73
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
74
|
+
let newRoutesContent = routesContent;
|
|
75
|
+
try {
|
|
76
|
+
for (const name of unusedNames) {
|
|
77
|
+
newRoutesContent = removeNamedImport(
|
|
78
|
+
newRoutesContent,
|
|
79
|
+
"@cedarjs/router",
|
|
80
|
+
name
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
return "Skipping removal of Set import, Routes.{jsx,tsx} couldn't be parsed";
|
|
85
|
+
}
|
|
86
|
+
if (newRoutesContent === routesContent) {
|
|
87
|
+
return "No unused Set or PrivateSet import found in Routes.{jsx,tsx}";
|
|
40
88
|
}
|
|
41
|
-
const [cedarRouterImport] = cedarRouterImportMatch;
|
|
42
|
-
const removedSetImport = cedarRouterImport.replace(/,*\s*Set,*/, "");
|
|
43
|
-
const newRoutesContent = routesContent.replace(
|
|
44
|
-
cedarRouterImport,
|
|
45
|
-
removedSetImport
|
|
46
|
-
);
|
|
47
89
|
writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
|
|
48
|
-
return "Removed Set
|
|
90
|
+
return "Removed unused Set and PrivateSet imports in Routes.{jsx,tsx}";
|
|
49
91
|
};
|
|
50
92
|
const removeLayoutImport = ({
|
|
51
93
|
model: name,
|
|
52
94
|
path: scaffoldPath = ""
|
|
53
95
|
}) => {
|
|
54
|
-
const
|
|
55
|
-
const pascalScaffoldPath = scaffoldPath === "" ? scaffoldPath : scaffoldPath.split("/").map(pascalcase).join("/") + "/";
|
|
56
|
-
const layoutName = `${pluralPascalName}Layout`;
|
|
57
|
-
const importLayout = `import ${pluralPascalName}Layout from 'src/layouts/${pascalScaffoldPath}${layoutName}'`;
|
|
96
|
+
const { importName, importPath } = getScaffoldLayoutNames(name, scaffoldPath);
|
|
58
97
|
const routesPath = getPaths().web.routes;
|
|
59
98
|
const routesContent = readFile(routesPath).toString();
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
""
|
|
99
|
+
const importLayout = new RegExp(
|
|
100
|
+
`\\s*import ${importName} from (['"])${importPath}\\1;?`
|
|
63
101
|
);
|
|
102
|
+
const newRoutesContent = routesContent.replace(importLayout, "");
|
|
64
103
|
writeFile(routesPath, newRoutesContent, { overwriteExisting: true });
|
|
65
104
|
return "Removed layout import from Routes.{jsx,tsx}";
|
|
66
105
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Listr } from "listr2";
|
|
2
|
-
import {
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
3
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
3
4
|
import { deleteFilesTask } from "../../../lib/index.js";
|
|
4
5
|
import { verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
5
6
|
import { files } from "../../generate/sdl/sdlHandler.js";
|
|
@@ -3,8 +3,9 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Writable } from "node:stream";
|
|
5
5
|
import concurrently from "concurrently";
|
|
6
|
-
import {
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
7
|
import { formatRunBinCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
8
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
8
9
|
import { shutdownPort } from "@cedarjs/internal/dist/dev";
|
|
9
10
|
import { generateGqlormArtifacts } from "@cedarjs/internal/dist/generate/gqlormSchema";
|
|
10
11
|
import { getConfig, getConfigPath } from "@cedarjs/project-config";
|
|
@@ -256,15 +257,13 @@ const handler = async ({
|
|
|
256
257
|
});
|
|
257
258
|
} else {
|
|
258
259
|
if (workspace.includes("api")) {
|
|
259
|
-
const isEsm = rootPackageJson.type === "module";
|
|
260
|
-
const serverWatchCommand = isEsm ? `cedarjs-api-server-watch` : `cedar-api-server-watch`;
|
|
261
260
|
const cedarConfigPath = getConfigPath();
|
|
262
261
|
jobs.push({
|
|
263
262
|
name: "api",
|
|
264
263
|
command: formatRunBinCommand("nodemon", [
|
|
265
264
|
"--quiet",
|
|
266
265
|
`--watch "${cedarConfigPath}"`,
|
|
267
|
-
`--exec "${formatRunBinCommand(
|
|
266
|
+
`--exec "${formatRunBinCommand("cedar-api-server-watch")} --port ${apiAvailablePort} ${getApiDebugFlag(apiDebugPort, apiAvailablePort)} | ${formatRunBinCommand("cedar-log-formatter")}"`
|
|
268
267
|
]),
|
|
269
268
|
env: {
|
|
270
269
|
NODE_ENV: "development",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
4
|
-
import { importStatementPath } from "@cedarjs/project-config";
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import { getConfig, importStatementPath } from "@cedarjs/project-config";
|
|
5
5
|
import { getPaths } from "../../lib/index.js";
|
|
6
6
|
async function getPackageWatchCommands(packageWorkspaces) {
|
|
7
7
|
const cedarPaths = getPaths();
|
|
@@ -17,6 +17,7 @@ async function getPackageWatchCommands(packageWorkspaces) {
|
|
|
17
17
|
}
|
|
18
18
|
return importStatementPath(workspacePath);
|
|
19
19
|
});
|
|
20
|
+
const packagesWorkspaceConfig = getConfig().experimental.packagesWorkspace;
|
|
20
21
|
const watchablePackages = [];
|
|
21
22
|
const packagesWithoutWatch = [];
|
|
22
23
|
for (const workspacePath of workspacePaths) {
|
|
@@ -29,7 +30,11 @@ async function getPackageWatchCommands(packageWorkspaces) {
|
|
|
29
30
|
if (packageJson.scripts?.watch) {
|
|
30
31
|
watchablePackages.push(workspacePath);
|
|
31
32
|
} else {
|
|
32
|
-
|
|
33
|
+
const packageConfig = packageName && packagesWorkspaceConfig[packageName];
|
|
34
|
+
const skipWatchWarning = typeof packageConfig === "object" && packageConfig.skipWatchWarning;
|
|
35
|
+
if (!skipWatchWarning) {
|
|
36
|
+
packagesWithoutWatch.push(packageName);
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
if (packagesWithoutWatch.length > 0) {
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
3
3
|
import { workspaces } from "../lib/project.js";
|
|
4
4
|
import { checkNodeVersion } from "../middleware/checkNodeVersion.js";
|
|
5
5
|
const command = "dev [workspace..]";
|
|
@@ -4,7 +4,8 @@ import { context } from "@opentelemetry/api";
|
|
|
4
4
|
import { suppressTracing } from "@opentelemetry/core";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
6
|
import { Parser } from "yargs/helpers";
|
|
7
|
-
import {
|
|
7
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
8
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
8
9
|
import { findScripts } from "@cedarjs/internal/dist/files";
|
|
9
10
|
import { runScriptFunction } from "../lib/exec.js";
|
|
10
11
|
import { generatePrismaClient } from "../lib/generatePrismaClient.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { getEpilogue } from "../util.js";
|
|
3
3
|
const command = "setup-live-queries";
|
|
4
4
|
const description = "Setup live query invalidation with Postgres notifications";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
5
|
import {
|
|
5
6
|
addApiPackages,
|
|
6
|
-
addWebPackages
|
|
7
|
-
|
|
8
|
-
} from "@cedarjs/cli-helpers";
|
|
7
|
+
addWebPackages
|
|
8
|
+
} from "@cedarjs/cli-helpers/installHelpers";
|
|
9
9
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
10
10
|
import {
|
|
11
11
|
getConfigPath,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { getEpilogue } from "./util.js";
|
|
3
3
|
const command = "setup-inngest";
|
|
4
4
|
const description = "Setup Inngest for background, scheduled, delayed, multi-step, and fan-out jobs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Listr } from "listr2";
|
|
2
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
3
3
|
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
4
4
|
import { addRootPackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
5
5
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { getEpilogue } from "./util.js";
|
|
3
3
|
const command = "setup-opentelemetry";
|
|
4
4
|
const description = "Setup OpenTelemetry within the API side";
|
|
@@ -2,7 +2,8 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
6
7
|
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
8
|
import {
|
|
8
9
|
getConfigPath,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { getEpilogue } from "./util.js";
|
|
3
3
|
const command = "setup-react-compiler";
|
|
4
4
|
const description = "Enable the experimental React Compiler";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import
|
|
5
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
4
|
+
import { coerce, isGreaterThanOrEqual } from "verkit";
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
6
|
import {
|
|
7
7
|
addRootPackages,
|
|
8
8
|
addWorkspacePackages
|
|
@@ -39,8 +39,8 @@ const handler = async (options) => {
|
|
|
39
39
|
)
|
|
40
40
|
);
|
|
41
41
|
const reactVersion = webPkgJson["dependencies"]["react"];
|
|
42
|
-
const coercedReactVersion =
|
|
43
|
-
if (!coercedReactVersion || !
|
|
42
|
+
const coercedReactVersion = coerce(reactVersion);
|
|
43
|
+
if (!coercedReactVersion || !isGreaterThanOrEqual(coercedReactVersion, "19.0.0")) {
|
|
44
44
|
throw new Error(
|
|
45
45
|
"You need to be using at least React version 19 to enable the React Compiler"
|
|
46
46
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { getEpilogue } from "./util.js";
|
|
3
3
|
const command = "setup-rsc";
|
|
4
4
|
const description = "Enable React Server Components (RSC)";
|
|
@@ -2,7 +2,8 @@ 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 {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { prettify } from "@cedarjs/cli-helpers/fileHelpers";
|
|
6
7
|
import { install } from "@cedarjs/cli-helpers/packageManager";
|
|
7
8
|
import { getConfig, getConfigPath } from "@cedarjs/project-config";
|
|
8
9
|
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
import { getEpilogue } from "./util.js";
|
|
3
3
|
const command = "setup-streaming-ssr";
|
|
4
4
|
const description = "Enable React Streaming and Server Side Rendering (SSR)";
|
|
@@ -2,7 +2,8 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { addWebPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
6
7
|
import { getConfigPath } from "@cedarjs/project-config";
|
|
7
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
9
|
import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
|
|
@@ -183,7 +184,7 @@ You'll manually need to merge it with your existing entry.client${ext} file.`;
|
|
|
183
184
|
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
184
185
|
}
|
|
185
186
|
},
|
|
186
|
-
addWebPackages(["@apollo/client-react-streaming@0.
|
|
187
|
+
addWebPackages(["@apollo/client-react-streaming@0.14.5"]),
|
|
187
188
|
{
|
|
188
189
|
task: () => {
|
|
189
190
|
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID);
|
|
@@ -22,6 +22,26 @@ const builder = createBuilder({
|
|
|
22
22
|
default: "",
|
|
23
23
|
description: "Use to enforce a specific query name within the generated cell - must be unique.",
|
|
24
24
|
type: "string"
|
|
25
|
+
},
|
|
26
|
+
beforeQuery: {
|
|
27
|
+
default: false,
|
|
28
|
+
description: "Include a typed `beforeQuery` stub for configuring the query (e.g. variables, fetch policy).",
|
|
29
|
+
type: "boolean"
|
|
30
|
+
},
|
|
31
|
+
afterQuery: {
|
|
32
|
+
default: false,
|
|
33
|
+
description: "Include a typed `afterQuery` stub for sanitizing data returned from the query.",
|
|
34
|
+
type: "boolean"
|
|
35
|
+
},
|
|
36
|
+
isEmpty: {
|
|
37
|
+
default: false,
|
|
38
|
+
description: "Include a typed `isEmpty` stub for overriding the default check for the Empty component.",
|
|
39
|
+
type: "boolean"
|
|
40
|
+
},
|
|
41
|
+
fragment: {
|
|
42
|
+
default: "",
|
|
43
|
+
description: "Generate a fragment cell (exports FRAGMENT instead of QUERY) that reads its data from a parent Cell, given the GraphQL type it selects from - e.g. --fragment User.",
|
|
44
|
+
type: "string"
|
|
25
45
|
}
|
|
26
46
|
};
|
|
27
47
|
}
|
|
@@ -26,7 +26,11 @@ const files = async ({
|
|
|
26
26
|
list = false,
|
|
27
27
|
query,
|
|
28
28
|
stories,
|
|
29
|
-
tests
|
|
29
|
+
tests,
|
|
30
|
+
beforeQuery = false,
|
|
31
|
+
afterQuery = false,
|
|
32
|
+
isEmpty = false,
|
|
33
|
+
fragment = ""
|
|
30
34
|
}) => {
|
|
31
35
|
let cellName = removeGeneratorName(name, "cell");
|
|
32
36
|
let idName = "id";
|
|
@@ -35,22 +39,49 @@ const files = async ({
|
|
|
35
39
|
let model = null;
|
|
36
40
|
let templateNameSuffix = "";
|
|
37
41
|
let typeName = cellName;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
if (fragment) {
|
|
43
|
+
if (list) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
"The --list flag cannot be combined with --fragment; fragment cells always render a single item."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (beforeQuery) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
"The --before-query flag cannot be combined with --fragment; fragment cells never fire a query of their own."
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (query) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
"The --query flag cannot be combined with --fragment; fragment cells don't have an operation name."
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const shouldGenerateList = !fragment && ((isWordPluralizable(cellName) ? isPlural(cellName) : list) || list);
|
|
60
|
+
if (!fragment) {
|
|
61
|
+
try {
|
|
62
|
+
model = await getSchema(pascalcase(singularize(cellName)));
|
|
63
|
+
idName = getIdName(model);
|
|
64
|
+
idType = getIdType(model);
|
|
65
|
+
typeName = model.name;
|
|
66
|
+
mockIdValues = idType === "String" ? mockIdValues.map((value) => `'${value}'`) : mockIdValues;
|
|
67
|
+
} catch {
|
|
68
|
+
idType = "Int";
|
|
69
|
+
}
|
|
47
70
|
}
|
|
48
71
|
if (shouldGenerateList) {
|
|
49
72
|
cellName = forcePluralizeWord(cellName);
|
|
50
73
|
templateNameSuffix = "List";
|
|
51
74
|
}
|
|
52
75
|
let operationName = query;
|
|
53
|
-
|
|
76
|
+
let fragmentName;
|
|
77
|
+
let fragmentOnType;
|
|
78
|
+
let fragmentPropName;
|
|
79
|
+
if (fragment) {
|
|
80
|
+
const fragmentTypeVariants = nameVariants(fragment);
|
|
81
|
+
fragmentOnType = fragmentTypeVariants.pascalName;
|
|
82
|
+
fragmentPropName = fragmentTypeVariants.camelName;
|
|
83
|
+
fragmentName = `${nameVariants(cellName).pascalName}Cell_${fragmentPropName}`;
|
|
84
|
+
} else if (operationName) {
|
|
54
85
|
const userSpecifiedOperationNameIsUnique = await operationNameIsUnique(operationName);
|
|
55
86
|
if (!userSpecifiedOperationNameIsUnique) {
|
|
56
87
|
throw new Error(`Specified query name: "${operationName}" is not unique!`);
|
|
@@ -67,11 +98,20 @@ const files = async ({
|
|
|
67
98
|
extension,
|
|
68
99
|
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
69
100
|
generator: "cell",
|
|
70
|
-
templatePath: `cell${templateNameSuffix}.tsx.template`,
|
|
71
|
-
templateVars: {
|
|
101
|
+
templatePath: fragment ? "cellFragment.tsx.template" : `cell${templateNameSuffix}.tsx.template`,
|
|
102
|
+
templateVars: fragment ? {
|
|
103
|
+
fragmentName,
|
|
104
|
+
fragmentOnType,
|
|
105
|
+
camelName: fragmentPropName,
|
|
106
|
+
afterQuery,
|
|
107
|
+
isEmpty
|
|
108
|
+
} : {
|
|
72
109
|
operationName,
|
|
73
110
|
idName,
|
|
74
|
-
idType
|
|
111
|
+
idType,
|
|
112
|
+
beforeQuery,
|
|
113
|
+
afterQuery,
|
|
114
|
+
isEmpty
|
|
75
115
|
}
|
|
76
116
|
});
|
|
77
117
|
const testFile = await templateForComponentFile({
|
|
@@ -80,8 +120,8 @@ const files = async ({
|
|
|
80
120
|
extension: `.test${extension}`,
|
|
81
121
|
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
82
122
|
generator: "cell",
|
|
83
|
-
templatePath: "test.js.template",
|
|
84
|
-
templateVars: {
|
|
123
|
+
templatePath: fragment ? "testFragment.js.template" : "test.js.template",
|
|
124
|
+
templateVars: fragment ? { camelName: fragmentPropName } : {
|
|
85
125
|
idName: shouldGenerateList ? void 0 : idName,
|
|
86
126
|
mockIdValues: shouldGenerateList ? void 0 : mockIdValues
|
|
87
127
|
}
|
|
@@ -92,7 +132,7 @@ const files = async ({
|
|
|
92
132
|
extension: `.stories${extension}`,
|
|
93
133
|
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
94
134
|
generator: "cell",
|
|
95
|
-
templatePath: "stories.tsx.template"
|
|
135
|
+
templatePath: fragment ? "storiesFragment.tsx.template" : "stories.tsx.template"
|
|
96
136
|
});
|
|
97
137
|
const mockFile = await templateForComponentFile({
|
|
98
138
|
name: cellName,
|
|
@@ -101,7 +141,12 @@ const files = async ({
|
|
|
101
141
|
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
102
142
|
generator: "cell",
|
|
103
143
|
templatePath: `mock${templateNameSuffix}.ts.template`,
|
|
104
|
-
templateVars: {
|
|
144
|
+
templateVars: fragment ? {
|
|
145
|
+
idName,
|
|
146
|
+
mockIdValues,
|
|
147
|
+
typeName: fragmentOnType,
|
|
148
|
+
camelName: fragmentPropName
|
|
149
|
+
} : {
|
|
105
150
|
idName,
|
|
106
151
|
mockIdValues,
|
|
107
152
|
typeName
|
|
@@ -122,7 +167,10 @@ const files = async ({
|
|
|
122
167
|
const handler = createHandler({
|
|
123
168
|
componentName: "cell",
|
|
124
169
|
filesFn: files,
|
|
125
|
-
includeAdditionalTasks: ({
|
|
170
|
+
includeAdditionalTasks: ({
|
|
171
|
+
name: cellName,
|
|
172
|
+
fragment
|
|
173
|
+
}) => {
|
|
126
174
|
return [
|
|
127
175
|
{
|
|
128
176
|
title: `Generating types ...`,
|
|
@@ -130,7 +178,7 @@ const handler = createHandler({
|
|
|
130
178
|
const queryFieldName = nameVariants(
|
|
131
179
|
removeGeneratorName(cellName, "cell")
|
|
132
180
|
).camelName;
|
|
133
|
-
const projectHasSdl = await checkProjectForQueryField(queryFieldName);
|
|
181
|
+
const projectHasSdl = Boolean(fragment) || await checkProjectForQueryField(queryFieldName);
|
|
134
182
|
if (projectHasSdl) {
|
|
135
183
|
const { errors } = await generateTypes();
|
|
136
184
|
for (const { message, error } of errors) {
|
|
@@ -6,7 +6,9 @@ import type {
|
|
|
6
6
|
import type {
|
|
7
7
|
CellSuccessProps,
|
|
8
8
|
CellFailureProps,
|
|
9
|
-
TypedDocumentNode
|
|
9
|
+
TypedDocumentNode,<% if (beforeQuery) { %>
|
|
10
|
+
CellBeforeQueryResult,<% } %><% if (afterQuery || isEmpty) { %>
|
|
11
|
+
DataObject,<% } %>
|
|
10
12
|
} from '@cedarjs/web'
|
|
11
13
|
|
|
12
14
|
export const QUERY: TypedDocumentNode<
|
|
@@ -19,7 +21,24 @@ export const QUERY: TypedDocumentNode<
|
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
`
|
|
22
|
-
|
|
24
|
+
<% if (beforeQuery) { %>
|
|
25
|
+
export const beforeQuery = (
|
|
26
|
+
props: ${operationName}Variables,
|
|
27
|
+
): CellBeforeQueryResult<${operationName}Variables> => {
|
|
28
|
+
return { variables: props, fetchPolicy: 'cache-and-network' }
|
|
29
|
+
}
|
|
30
|
+
<% } %><% if (isEmpty) { %>
|
|
31
|
+
export const isEmpty = (
|
|
32
|
+
data: DataObject,
|
|
33
|
+
{ isDataEmpty }: { isDataEmpty: (data: DataObject) => boolean },
|
|
34
|
+
) => {
|
|
35
|
+
return isDataEmpty(data)
|
|
36
|
+
}
|
|
37
|
+
<% } %><% if (afterQuery) { %>
|
|
38
|
+
export const afterQuery = (data: DataObject): DataObject => {
|
|
39
|
+
return data
|
|
40
|
+
}
|
|
41
|
+
<% } %>
|
|
23
42
|
export const Loading = () => <div>Loading...</div>
|
|
24
43
|
|
|
25
44
|
export const Empty = () => <div>Empty</div>
|