@cedarjs/cli 9.0.0-canary.1784 → 9.0.0-canary.3124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -10
- package/dist/cfw.js +10 -6
- package/dist/commands/build/buildHandler.js +220 -45
- package/dist/commands/build/buildPackagesTask.js +21 -20
- package/dist/commands/build.js +13 -2
- package/dist/commands/check.js +4 -6
- package/dist/commands/console.js +6 -4
- package/dist/commands/deploy/baremetal/SshExecutor.js +13 -4
- package/dist/commands/deploy/baremetal/baremetalHandler.js +116 -50
- package/dist/commands/deploy/baremetal.js +11 -4
- package/dist/commands/deploy/flightcontrolHandler.js +28 -15
- package/dist/commands/deploy/helpers/deployHandler.js +11 -6
- package/dist/commands/deploy/netlify.js +1 -1
- package/dist/commands/deploy/packing/nft.js +1 -2
- package/dist/commands/deploy/render.js +1 -1
- package/dist/commands/deploy/renderHandler.js +24 -13
- package/dist/commands/deploy/serverlessHandler.js +69 -27
- package/dist/commands/deploy/vercel.js +1 -1
- package/dist/commands/destroy/component/component.js +2 -3
- package/dist/commands/destroy/directive/directive.js +1 -3
- package/dist/commands/destroy/directive/directiveHandler.js +2 -4
- package/dist/commands/destroy/function/function.js +1 -3
- package/dist/commands/destroy/handlerHelpers.js +17 -17
- package/dist/commands/destroy/helpers.js +8 -2
- package/dist/commands/destroy/layout/layout.js +1 -2
- package/dist/commands/destroy/page/pageHandler.js +3 -3
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +31 -12
- package/dist/commands/destroy/sdl/sdlHandler.js +3 -3
- package/dist/commands/dev/apiDebugFlag.js +5 -4
- package/dist/commands/dev/devHandler.js +219 -68
- package/dist/commands/dev/packageWatchCommands.js +8 -3
- package/dist/commands/dev.js +16 -6
- package/dist/commands/execHandler.js +49 -29
- package/dist/commands/experimental/live-queries/liveQueries.js +32 -0
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +448 -0
- package/dist/commands/experimental/live-queries/templates/liveQueriesListener.ts.template +153 -0
- package/dist/commands/experimental/live-queries/templates/migration.sql.template +100 -0
- package/dist/commands/experimental/setupInngest.js +2 -2
- package/dist/commands/experimental/setupInngestHandler.js +13 -12
- package/dist/commands/experimental/setupOpentelemetry.js +2 -2
- package/dist/commands/experimental/setupOpentelemetryHandler.js +14 -10
- package/dist/commands/experimental/setupReactCompiler.js +2 -2
- package/dist/commands/experimental/setupReactCompilerHandler.js +48 -33
- package/dist/commands/experimental/setupRsc.js +1 -1
- package/dist/commands/experimental/setupRscHandler.js +20 -16
- package/dist/commands/experimental/setupStreamingSsr.js +2 -2
- package/dist/commands/experimental/setupStreamingSsrHandler.js +49 -34
- package/dist/commands/experimental/templates/opentelemetry.ts.template +2 -1
- package/dist/commands/experimental/templates/rsc/Document.tsx.template +1 -1
- package/dist/commands/experimental/templates/rsc/entry.client.tsx.template +8 -8
- package/dist/commands/experimental/templates/streamingSsr/Document.tsx.template +1 -1
- package/dist/commands/experimental/templates/streamingSsr/entry.client.tsx.template +6 -6
- package/dist/commands/experimental/templates/streamingSsr/tsconfig.json.template +6 -6
- package/dist/commands/experimental/util.js +27 -25
- package/dist/commands/experimental.js +3 -2
- package/dist/commands/generate/cell/cell.js +20 -0
- package/dist/commands/generate/cell/cellHandler.js +89 -40
- package/dist/commands/generate/cell/templates/cell.tsx.template +21 -2
- package/dist/commands/generate/cell/templates/cellFragment.tsx.template +43 -0
- package/dist/commands/generate/cell/templates/cellList.tsx.template +21 -2
- package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +23 -0
- package/dist/commands/generate/cell/templates/test.js.template +1 -1
- package/dist/commands/generate/cell/templates/testFragment.js.template +30 -0
- package/dist/commands/generate/component/componentHandler.js +14 -16
- package/dist/commands/generate/dataMigration/dataMigration.js +36 -18
- package/dist/commands/generate/dataMigration/templates/dataMigration.js.template +1 -1
- package/dist/commands/generate/dataMigration/templates/dataMigration.ts.template +1 -1
- package/dist/commands/generate/dbAuth/dbAuth.js +1 -0
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +63 -34
- package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +164 -0
- package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +147 -0
- package/dist/commands/generate/directive/directiveHandler.js +14 -16
- package/dist/commands/generate/function/function.js +1 -0
- package/dist/commands/generate/function/functionHandler.js +14 -19
- package/dist/commands/generate/helpers.js +34 -18
- package/dist/commands/generate/job/job.js +1 -0
- package/dist/commands/generate/job/jobHandler.js +20 -24
- package/dist/commands/generate/layout/layoutHandler.js +13 -16
- package/dist/commands/generate/model/model.js +1 -0
- package/dist/commands/generate/model/modelHandler.js +11 -5
- package/dist/commands/generate/ogImage/ogImage.js +1 -0
- package/dist/commands/generate/ogImage/ogImageHandler.js +18 -11
- package/dist/commands/generate/package/filesTask.js +9 -0
- package/dist/commands/generate/package/packageHandler.js +50 -61
- package/dist/commands/generate/package/templates/test.ts.template +2 -2
- package/dist/commands/generate/package/templates/vitest.config.ts.template +9 -0
- package/dist/commands/generate/page/pageHandler.js +27 -24
- package/dist/commands/generate/realtime/realtime.js +2 -2
- package/dist/commands/generate/realtime/realtimeHandler.js +51 -32
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +1 -1
- package/dist/commands/generate/scaffold/scaffold.js +1 -0
- package/dist/commands/generate/scaffold/scaffoldHandler.js +176 -49
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +1 -1
- package/dist/commands/generate/script/script.js +1 -0
- package/dist/commands/generate/script/scriptHandler.js +10 -6
- package/dist/commands/generate/script/templates/script.ts.template +9 -4
- package/dist/commands/generate/script/templates/tsconfig.json.template +16 -2
- package/dist/commands/generate/sdl/sdl.js +4 -3
- package/dist/commands/generate/sdl/sdlHandler.js +135 -46
- package/dist/commands/generate/sdl/stubFiles.js +132 -0
- package/dist/commands/generate/sdl/templates/sdl.js.template +2 -1
- package/dist/commands/generate/sdl/templates/sdl.ts.template +2 -1
- package/dist/commands/generate/secret/secret.js +20 -20
- package/dist/commands/generate/service/service.js +5 -5
- package/dist/commands/generate/service/serviceHandler.js +126 -61
- package/dist/commands/generate/service/templates/scenarios.ts.template +4 -2
- package/dist/commands/generate/service/templates/service.ts.template +22 -8
- package/dist/commands/generate/service/templates/test.ts.template +2 -2
- package/dist/commands/generate/yargsCommandHelpers.js +7 -2
- package/dist/commands/generate/yargsHandlerHelpers.js +20 -18
- package/dist/commands/generate.js +4 -4
- package/dist/commands/info.js +2 -2
- package/dist/commands/jobsHandler.js +7 -4
- package/dist/commands/lint.js +26 -69
- package/dist/commands/prerenderHandler.js +95 -58
- package/dist/commands/prismaHandler.js +51 -26
- package/dist/commands/record/init.js +2 -2
- package/dist/commands/record.js +4 -3
- package/dist/commands/serve.js +245 -31
- package/dist/commands/serveApiHandler.js +7 -6
- package/dist/commands/serveBothHandler.js +22 -13
- package/dist/commands/serveWebHandler.js +3 -2
- package/dist/commands/setup/auth/auth.js +15 -11
- package/dist/commands/setup/cache/cache.js +1 -1
- package/dist/commands/setup/cache/cacheHandler.js +15 -9
- package/dist/commands/setup/database/database.js +15 -0
- package/dist/commands/setup/database/postgres.js +19 -0
- package/dist/commands/setup/database/postgresHandler.js +196 -0
- package/dist/commands/setup/database/templates/db.ts.template +32 -0
- package/dist/commands/setup/deploy/deploy.js +4 -3
- package/dist/commands/setup/deploy/helpers/helpers.js +5 -1
- package/dist/commands/setup/deploy/helpers/index.js +132 -6
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +28 -6
- package/dist/commands/setup/deploy/providers/coherence.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +60 -31
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +69 -51
- package/dist/commands/setup/deploy/providers/netlify.js +6 -0
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +114 -13
- package/dist/commands/setup/deploy/providers/renderHandler.js +44 -41
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +7 -5
- package/dist/commands/setup/deploy/providers/universal-deploy.js +11 -0
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +186 -0
- package/dist/commands/setup/deploy/providers/vercel.js +6 -0
- package/dist/commands/setup/deploy/providers/vercelHandler.js +115 -14
- package/dist/commands/setup/deploy/templates/baremetal.js +3 -2
- package/dist/commands/setup/deploy/templates/flightcontrol.js +60 -49
- package/dist/commands/setup/deploy/templates/netlify.js +2 -1
- package/dist/commands/setup/deploy/templates/netlifyUD.js +31 -0
- package/dist/commands/setup/deploy/templates/render.js +32 -17
- package/dist/commands/setup/docker/docker.js +2 -2
- package/dist/commands/setup/docker/dockerHandler.js +74 -39
- package/dist/commands/setup/docker/templates/Dockerfile.npm +119 -0
- package/dist/commands/setup/docker/templates/Dockerfile.pnpm +112 -0
- package/dist/commands/setup/docker/templates/{Dockerfile → Dockerfile.yarn} +4 -7
- package/dist/commands/setup/docker/templates/docker-compose.dev.yml +3 -3
- package/dist/commands/setup/docker/templates/docker-compose.prod.yml +2 -5
- package/dist/commands/setup/docker/templates/dockerignore +1 -0
- package/dist/commands/setup/generator/generator.js +1 -1
- package/dist/commands/setup/generator/generatorHandler.js +5 -4
- package/dist/commands/setup/graphql/features/fragments/appGqlConfigTransform.js +6 -3
- package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +5 -7
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +4 -3
- package/dist/commands/setup/i18n/i18n.js +1 -1
- package/dist/commands/setup/i18n/i18nHandler.js +21 -17
- package/dist/commands/setup/jobs/jobs.js +1 -1
- package/dist/commands/setup/jobs/jobsHandler.js +17 -12
- package/dist/commands/setup/mailer/mailer.js +1 -1
- package/dist/commands/setup/mailer/mailerHandler.js +13 -11
- package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
- package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +2 -1
- package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
- package/dist/commands/setup/monitoring/sentry/sentryHandler.js +18 -12
- package/dist/commands/setup/neon/neon.js +35 -0
- package/dist/commands/setup/neon/neonHandler.js +264 -0
- package/dist/commands/setup/package/package.js +1 -1
- package/dist/commands/setup/package/packageHandler.js +18 -14
- package/dist/commands/setup/realtime/addRealtimeToGraphql.js +1 -1
- package/dist/commands/setup/realtime/realtime.js +1 -1
- package/dist/commands/setup/realtime/realtimeHandler.js +26 -37
- package/dist/commands/setup/realtime/templates/realtime.ts.template +1 -1
- package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +1 -1
- package/dist/commands/setup/server-file/serverFile.js +1 -1
- package/dist/commands/setup/server-file/serverFileHandler.js +18 -10
- package/dist/commands/setup/tenancy/authCodemod.js +66 -0
- package/dist/commands/setup/tenancy/dbCodemod.js +64 -0
- package/dist/commands/setup/tenancy/graphqlCodemod.js +88 -0
- package/dist/commands/setup/tenancy/preflight.js +49 -0
- package/dist/commands/setup/tenancy/schemaPrisma.js +81 -0
- package/dist/commands/setup/tenancy/signupCodemod.js +153 -0
- package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +63 -0
- package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +40 -0
- package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +39 -0
- package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +59 -0
- package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +89 -0
- package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +389 -0
- package/dist/commands/setup/tenancy/templates/organizations.ts.template +394 -0
- package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +35 -0
- package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +25 -0
- package/dist/commands/setup/tenancy/tenancy.js +30 -0
- package/dist/commands/setup/tenancy/tenancyHandler.js +425 -0
- package/dist/commands/setup/ui/helpers/helpers.js +5 -1
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +16 -8
- package/dist/commands/setup/ui/libraries/mantineHandler.js +26 -16
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +40 -29
- package/dist/commands/setup/uploads/schemaPrisma.js +41 -0
- package/dist/commands/setup/uploads/serverFile.js +151 -0
- package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +15 -0
- package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +23 -24
- package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +79 -0
- package/dist/commands/setup/uploads/templates/uploads.ts.template +89 -0
- package/dist/commands/setup/uploads/templates/withDataUri.ts.template +14 -0
- package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +16 -0
- package/dist/commands/setup/uploads/uploads.js +49 -7
- package/dist/commands/setup/uploads/uploadsHandler.js +266 -72
- package/dist/commands/setup.js +5 -4
- package/dist/commands/studio.js +1 -1
- package/dist/commands/studioHandler.js +2 -2
- package/dist/commands/test/datasourceWarning.js +42 -0
- package/dist/commands/test/testHandler.js +104 -0
- package/dist/commands/test/viteVersionCheck.js +75 -0
- package/dist/commands/test.js +16 -19
- package/dist/commands/type-check.js +2 -1
- package/dist/commands/type-checkHandler.js +25 -18
- package/dist/commands/upgrade/preUpgradeScripts.js +11 -11
- package/dist/commands/upgrade/upgrade.js +4 -2
- package/dist/commands/upgrade/upgradeHandler.js +97 -73
- package/dist/index.js +15 -11
- package/dist/lib/background.js +22 -1
- package/dist/lib/configureStorybook.js +2 -2
- package/dist/lib/exec.js +68 -63
- package/dist/lib/exit.js +20 -5
- package/dist/lib/extendFile.js +23 -13
- package/dist/lib/generatePrismaClient.js +48 -12
- package/dist/lib/index.js +137 -106
- package/dist/lib/loadEnvFiles.js +1 -1
- package/dist/lib/locking.js +8 -4
- package/dist/lib/merge/algorithms.js +4 -1
- package/dist/lib/merge/index.js +78 -41
- package/dist/lib/merge/semanticIdentity.js +18 -6
- package/dist/lib/merge/strategy.js +86 -36
- package/dist/lib/packages.js +23 -13
- package/dist/lib/plugin.js +13 -7
- package/dist/lib/pluralHelpers.js +6 -2
- package/dist/lib/project.js +3 -1
- package/dist/lib/rollback.js +7 -7
- package/dist/lib/schemaHelpers.js +16 -19
- package/dist/lib/test.js +20 -5
- package/dist/lib/updateCheck.js +47 -18
- package/dist/middleware/checkNodeVersion.js +9 -4
- package/dist/middleware/{detectProjectRxVersion.js → detectProjectCedarVersion.js} +2 -2
- package/dist/plugin.js +18 -12
- package/dist/telemetry/exporter.js +12 -5
- package/dist/telemetry/index.js +4 -3
- package/dist/telemetry/resource.js +9 -12
- package/dist/telemetry/send.js +14 -10
- package/dist/testLib/cells.js +5 -3
- package/package.json +44 -41
- package/LICENSE +0 -21
- package/dist/commands/consoleHandler.js +0 -68
- package/dist/commands/setup/tsconfig/tsconfig.js +0 -25
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +0 -59
- package/dist/commands/setup/uploads/dbCodemod.js +0 -28
- package/dist/commands/setup/uploads/templates/signedUrl.ts.template +0 -21
- package/dist/commands/setup/vite/templates/vite.config.ts.template +0 -19
- package/dist/commands/setup/vite/vite.js +0 -38
- package/dist/commands/setup/vite/viteHandler.js +0 -83
- package/dist/commands/testEsm.js +0 -36
- package/dist/commands/testHandler.js +0 -137
- package/dist/commands/testHandlerEsm.js +0 -85
- package/dist/commands/ts-to-js.js +0 -20
- package/dist/lib/cedarPluralize.js +0 -56
- package/dist/lib/colors.js +0 -18
- package/dist/testLib/getFilesWithPattern.js +0 -21
- /package/dist/{index.d.js → global.d.js} +0 -0
|
@@ -5,21 +5,21 @@ import { Document } from './Document'
|
|
|
5
5
|
import Routes from './Routes'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* When `#
|
|
8
|
+
* When `#cedar-app` isn't empty then it's very likely that you're using
|
|
9
9
|
* prerendering. So React attaches event listeners to the existing markup
|
|
10
10
|
* rather than replacing it.
|
|
11
11
|
* https://react.dev/reference/react-dom/client/hydrateRoot
|
|
12
12
|
*/
|
|
13
|
-
const
|
|
13
|
+
const cedarAppElement = document.getElementById('cedar-app')
|
|
14
14
|
|
|
15
|
-
if (!
|
|
15
|
+
if (!cedarAppElement) {
|
|
16
16
|
throw new Error(
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
'Could not find an element with ID "cedar-app". Please ensure it exists ' +
|
|
18
|
+
'in your `web/index.html` file.'
|
|
19
19
|
)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
if (
|
|
22
|
+
if (cedarAppElement.children?.length > 0) {
|
|
23
23
|
hydrateRoot(
|
|
24
24
|
document,
|
|
25
25
|
<Document css={window.__assetMap?.()?.css}>
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"skipLibCheck": false,
|
|
10
10
|
"rootDirs": [
|
|
11
11
|
"./src",
|
|
12
|
-
"../.
|
|
12
|
+
"../.cedar/types/mirror/web/src",
|
|
13
13
|
"../api/src",
|
|
14
|
-
"../.
|
|
14
|
+
"../.cedar/types/mirror/api/src"
|
|
15
15
|
],
|
|
16
16
|
"paths": {
|
|
17
17
|
"src/*": [
|
|
18
18
|
"./src/*",
|
|
19
|
-
"../.
|
|
19
|
+
"../.cedar/types/mirror/web/src/*",
|
|
20
20
|
"../api/src/*",
|
|
21
|
-
"../.
|
|
21
|
+
"../.cedar/types/mirror/api/src/*"
|
|
22
22
|
],
|
|
23
23
|
"$api/*": [
|
|
24
24
|
"../api/*"
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"include": [
|
|
47
47
|
"src",
|
|
48
48
|
"config",
|
|
49
|
-
"../.
|
|
50
|
-
"../.
|
|
49
|
+
"../.cedar/types/includes/all-*",
|
|
50
|
+
"../.cedar/types/includes/web-*",
|
|
51
51
|
"../types",
|
|
52
52
|
"./types"
|
|
53
53
|
]
|
|
@@ -2,45 +2,47 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import ansis from "ansis";
|
|
4
4
|
import { terminalLink } from "termi-link";
|
|
5
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
5
6
|
import { getPaths } from "../../lib/index.js";
|
|
6
7
|
import { isTypeScriptProject, serverFileExists } from "../../lib/project.js";
|
|
7
|
-
|
|
8
|
+
function link(topicId, isTerminal = false) {
|
|
8
9
|
const communityLink = `https://community.redwoodjs.com/t/${topicId}`;
|
|
9
10
|
if (isTerminal) {
|
|
10
11
|
return terminalLink(communityLink, communityLink);
|
|
11
12
|
} else {
|
|
12
13
|
return communityLink;
|
|
13
14
|
}
|
|
14
|
-
}
|
|
15
|
-
|
|
15
|
+
}
|
|
16
|
+
function getEpilogue(command, description, topicId, isTerminal = false) {
|
|
17
|
+
let epilogue = `This is an experimental feature to: ${description}.
|
|
18
|
+
|
|
19
|
+
If you need help with ${command}, please join our Discord community.
|
|
20
|
+
-> ${terminalLink("", "https://cedarjs.com/discord")}`;
|
|
21
|
+
if (topicId) {
|
|
22
|
+
epilogue += `
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
-> ${link(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
You might also be able to find some information at:
|
|
25
|
+
-> ${link(topicId, isTerminal)}`;
|
|
26
|
+
}
|
|
27
|
+
return epilogue;
|
|
28
|
+
}
|
|
29
|
+
function printTaskEpilogue(command, description, topicId) {
|
|
30
|
+
const orangeLine = ansis.hex("#ff845e")("-".repeat(64));
|
|
23
31
|
console.log(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
------------------------------------------------------------------`
|
|
30
|
-
)}`
|
|
32
|
+
[
|
|
33
|
+
orangeLine,
|
|
34
|
+
`\u{1F9EA} ${ansis.green("Experimental Feature")} \u{1F9EA}`,
|
|
35
|
+
orangeLine
|
|
36
|
+
].join("\n")
|
|
31
37
|
);
|
|
32
38
|
console.log(getEpilogue(command, description, topicId, false));
|
|
33
|
-
console.log(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)}
|
|
37
|
-
`
|
|
38
|
-
);
|
|
39
|
-
};
|
|
39
|
+
console.log(`${orangeLine}
|
|
40
|
+
`);
|
|
41
|
+
}
|
|
40
42
|
const isServerFileSetup = () => {
|
|
41
43
|
if (!serverFileExists()) {
|
|
42
44
|
throw new Error(
|
|
43
|
-
|
|
45
|
+
`CedarJS Realtime requires a serverful environment. Please run \`${formatCedarCommand(["setup", "server-file"])}\` first.`
|
|
44
46
|
);
|
|
45
47
|
}
|
|
46
48
|
return true;
|
|
@@ -55,7 +57,7 @@ const realtimeExists = () => {
|
|
|
55
57
|
const isRealtimeSetup = () => {
|
|
56
58
|
if (!realtimeExists()) {
|
|
57
59
|
throw new Error(
|
|
58
|
-
|
|
60
|
+
`Adding realtime events requires that CedarJS Realtime is setup. Please run \`${formatCedarCommand(["setup", "realtime"])}\` first.`
|
|
59
61
|
);
|
|
60
62
|
}
|
|
61
63
|
return true;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import
|
|
2
|
+
import { detectCedarVersion } from "../middleware/detectProjectCedarVersion.js";
|
|
3
|
+
import * as experimentalLiveQueries from "./experimental/live-queries/liveQueries.js";
|
|
3
4
|
import * as experimentalInngest from "./experimental/setupInngest.js";
|
|
4
5
|
import * as experimentalOpenTelemetry from "./experimental/setupOpentelemetry.js";
|
|
5
6
|
import * as experimentalReactCompiler from "./experimental/setupReactCompiler.js";
|
|
@@ -8,7 +9,7 @@ import * as experimentalStreamingSsr from "./experimental/setupStreamingSsr.js";
|
|
|
8
9
|
const command = "experimental <command>";
|
|
9
10
|
const aliases = ["exp"];
|
|
10
11
|
const description = "Run or setup experimental features";
|
|
11
|
-
const builder = (yargs) => yargs.command(experimentalInngest).command(experimentalOpenTelemetry).command(experimentalReactCompiler).command(experimentalRsc).command(experimentalStreamingSsr).demandCommand().middleware(
|
|
12
|
+
const builder = (yargs) => yargs.command(experimentalInngest).command(experimentalLiveQueries).command(experimentalOpenTelemetry).command(experimentalReactCompiler).command(experimentalRsc).command(experimentalStreamingSsr).demandCommand().middleware(detectCedarVersion).epilogue(
|
|
12
13
|
`Also see the ${terminalLink(
|
|
13
14
|
"CedarJS CLI Reference",
|
|
14
15
|
"https://cedarjs.com/docs/cli-commands#experimental"
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import pascalcase from "pascalcase";
|
|
2
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
2
3
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
3
|
-
import { isPlural, singularize } from "
|
|
4
|
-
import { nameVariants,
|
|
4
|
+
import { isPlural, singularize } from "@cedarjs/utils/cedarPluralize";
|
|
5
|
+
import { nameVariants, transformTSToJSMap } from "../../../lib/index.js";
|
|
5
6
|
import { isWordPluralizable } from "../../../lib/pluralHelpers.js";
|
|
6
7
|
import { addFunctionToRollback } from "../../../lib/rollback.js";
|
|
7
8
|
import { getSchema } from "../../../lib/schemaHelpers.js";
|
|
@@ -18,8 +19,19 @@ import {
|
|
|
18
19
|
uniqueOperationName
|
|
19
20
|
} from "./utils/utils.js";
|
|
20
21
|
const COMPONENT_SUFFIX = "Cell";
|
|
21
|
-
const
|
|
22
|
-
const files = async ({
|
|
22
|
+
const CEDAR_WEB_PATH_NAME = "components";
|
|
23
|
+
const files = async ({
|
|
24
|
+
name,
|
|
25
|
+
typescript = false,
|
|
26
|
+
list = false,
|
|
27
|
+
query,
|
|
28
|
+
stories,
|
|
29
|
+
tests,
|
|
30
|
+
beforeQuery = false,
|
|
31
|
+
afterQuery = false,
|
|
32
|
+
isEmpty = false,
|
|
33
|
+
fragment = ""
|
|
34
|
+
}) => {
|
|
23
35
|
let cellName = removeGeneratorName(name, "cell");
|
|
24
36
|
let idName = "id";
|
|
25
37
|
let idType;
|
|
@@ -27,22 +39,49 @@ const files = async ({ name, typescript, ...argv }) => {
|
|
|
27
39
|
let model = null;
|
|
28
40
|
let templateNameSuffix = "";
|
|
29
41
|
let typeName = cellName;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
}
|
|
39
70
|
}
|
|
40
71
|
if (shouldGenerateList) {
|
|
41
72
|
cellName = forcePluralizeWord(cellName);
|
|
42
73
|
templateNameSuffix = "List";
|
|
43
74
|
}
|
|
44
|
-
let operationName =
|
|
45
|
-
|
|
75
|
+
let operationName = query;
|
|
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) {
|
|
46
85
|
const userSpecifiedOperationNameIsUnique = await operationNameIsUnique(operationName);
|
|
47
86
|
if (!userSpecifiedOperationNameIsUnique) {
|
|
48
87
|
throw new Error(`Specified query name: "${operationName}" is not unique!`);
|
|
@@ -57,23 +96,32 @@ const files = async ({ name, typescript, ...argv }) => {
|
|
|
57
96
|
name: cellName,
|
|
58
97
|
suffix: COMPONENT_SUFFIX,
|
|
59
98
|
extension,
|
|
60
|
-
webPathSection:
|
|
99
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
61
100
|
generator: "cell",
|
|
62
|
-
templatePath: `cell${templateNameSuffix}.tsx.template`,
|
|
63
|
-
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
|
+
} : {
|
|
64
109
|
operationName,
|
|
65
110
|
idName,
|
|
66
|
-
idType
|
|
111
|
+
idType,
|
|
112
|
+
beforeQuery,
|
|
113
|
+
afterQuery,
|
|
114
|
+
isEmpty
|
|
67
115
|
}
|
|
68
116
|
});
|
|
69
117
|
const testFile = await templateForComponentFile({
|
|
70
118
|
name: cellName,
|
|
71
119
|
suffix: COMPONENT_SUFFIX,
|
|
72
120
|
extension: `.test${extension}`,
|
|
73
|
-
webPathSection:
|
|
121
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
74
122
|
generator: "cell",
|
|
75
|
-
templatePath: "test.js.template",
|
|
76
|
-
templateVars: {
|
|
123
|
+
templatePath: fragment ? "testFragment.js.template" : "test.js.template",
|
|
124
|
+
templateVars: fragment ? { camelName: fragmentPropName } : {
|
|
77
125
|
idName: shouldGenerateList ? void 0 : idName,
|
|
78
126
|
mockIdValues: shouldGenerateList ? void 0 : mockIdValues
|
|
79
127
|
}
|
|
@@ -82,46 +130,47 @@ const files = async ({ name, typescript, ...argv }) => {
|
|
|
82
130
|
name: cellName,
|
|
83
131
|
suffix: COMPONENT_SUFFIX,
|
|
84
132
|
extension: `.stories${extension}`,
|
|
85
|
-
webPathSection:
|
|
133
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
86
134
|
generator: "cell",
|
|
87
|
-
templatePath: "stories.tsx.template"
|
|
135
|
+
templatePath: fragment ? "storiesFragment.tsx.template" : "stories.tsx.template"
|
|
88
136
|
});
|
|
89
137
|
const mockFile = await templateForComponentFile({
|
|
90
138
|
name: cellName,
|
|
91
139
|
suffix: COMPONENT_SUFFIX,
|
|
92
140
|
extension: typescript ? ".mock.ts" : ".mock.js",
|
|
93
|
-
webPathSection:
|
|
141
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
94
142
|
generator: "cell",
|
|
95
143
|
templatePath: `mock${templateNameSuffix}.ts.template`,
|
|
96
|
-
templateVars: {
|
|
144
|
+
templateVars: fragment ? {
|
|
145
|
+
idName,
|
|
146
|
+
mockIdValues,
|
|
147
|
+
typeName: fragmentOnType,
|
|
148
|
+
camelName: fragmentPropName
|
|
149
|
+
} : {
|
|
97
150
|
idName,
|
|
98
151
|
mockIdValues,
|
|
99
152
|
typeName
|
|
100
153
|
}
|
|
101
154
|
});
|
|
102
155
|
const files2 = [cellFile];
|
|
103
|
-
if (
|
|
156
|
+
if (stories) {
|
|
104
157
|
files2.push(storiesFile);
|
|
105
158
|
}
|
|
106
|
-
if (
|
|
159
|
+
if (tests) {
|
|
107
160
|
files2.push(testFile);
|
|
108
161
|
}
|
|
109
|
-
if (
|
|
162
|
+
if (stories || tests) {
|
|
110
163
|
files2.push(mockFile);
|
|
111
164
|
}
|
|
112
|
-
return files2
|
|
113
|
-
const acc = await accP;
|
|
114
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
115
|
-
return {
|
|
116
|
-
[outputPath]: template,
|
|
117
|
-
...acc
|
|
118
|
-
};
|
|
119
|
-
}, Promise.resolve({}));
|
|
165
|
+
return transformTSToJSMap(files2, typescript);
|
|
120
166
|
};
|
|
121
167
|
const handler = createHandler({
|
|
122
168
|
componentName: "cell",
|
|
123
169
|
filesFn: files,
|
|
124
|
-
includeAdditionalTasks: ({
|
|
170
|
+
includeAdditionalTasks: ({
|
|
171
|
+
name: cellName,
|
|
172
|
+
fragment
|
|
173
|
+
}) => {
|
|
125
174
|
return [
|
|
126
175
|
{
|
|
127
176
|
title: `Generating types ...`,
|
|
@@ -129,7 +178,7 @@ const handler = createHandler({
|
|
|
129
178
|
const queryFieldName = nameVariants(
|
|
130
179
|
removeGeneratorName(cellName, "cell")
|
|
131
180
|
).camelName;
|
|
132
|
-
const projectHasSdl = await checkProjectForQueryField(queryFieldName);
|
|
181
|
+
const projectHasSdl = Boolean(fragment) || await checkProjectForQueryField(queryFieldName);
|
|
133
182
|
if (projectHasSdl) {
|
|
134
183
|
const { errors } = await generateTypes();
|
|
135
184
|
for (const { message, error } of errors) {
|
|
@@ -141,7 +190,7 @@ const handler = createHandler({
|
|
|
141
190
|
addFunctionToRollback(generateTypes, true);
|
|
142
191
|
} else {
|
|
143
192
|
task.skip(
|
|
144
|
-
`Skipping type generation: no SDL defined for "${queryFieldName}". To generate types, run '
|
|
193
|
+
`Skipping type generation: no SDL defined for "${queryFieldName}". To generate types, run '${formatCedarCommand(["generate", "sdl", queryFieldName])}'.`
|
|
145
194
|
);
|
|
146
195
|
}
|
|
147
196
|
}
|
|
@@ -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>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ${fragmentName} } from 'types/graphql'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CellSuccessProps,<% if (afterQuery || isEmpty) { %>
|
|
5
|
+
DataObject,<% } %>
|
|
6
|
+
} from '@cedarjs/web'
|
|
7
|
+
|
|
8
|
+
// A parent Cell spreads this fragment by name in its own QUERY, and passes
|
|
9
|
+
// the matching field down as the `${camelName}` prop - no import needed,
|
|
10
|
+
// just render <${pascalName}Cell />:
|
|
11
|
+
//
|
|
12
|
+
// query FindSomething($id: Int!) {
|
|
13
|
+
// something(id: $id) {
|
|
14
|
+
// id
|
|
15
|
+
// ...${fragmentName}
|
|
16
|
+
// }
|
|
17
|
+
// }
|
|
18
|
+
//
|
|
19
|
+
// <${pascalName}Cell ${camelName}={something} />
|
|
20
|
+
export const FRAGMENT = gql`
|
|
21
|
+
fragment ${fragmentName} on ${fragmentOnType} {
|
|
22
|
+
id
|
|
23
|
+
}
|
|
24
|
+
`
|
|
25
|
+
<% if (isEmpty) { %>
|
|
26
|
+
export const isEmpty = (
|
|
27
|
+
data: DataObject,
|
|
28
|
+
{ isDataEmpty }: { isDataEmpty: (data: DataObject) => boolean },
|
|
29
|
+
) => {
|
|
30
|
+
return isDataEmpty(data)
|
|
31
|
+
}
|
|
32
|
+
<% } %><% if (afterQuery) { %>
|
|
33
|
+
export const afterQuery = (data: DataObject): DataObject => {
|
|
34
|
+
return data
|
|
35
|
+
}
|
|
36
|
+
<% } %>
|
|
37
|
+
export const Empty = () => <div>Empty</div>
|
|
38
|
+
|
|
39
|
+
export const Success = ({
|
|
40
|
+
${camelName},
|
|
41
|
+
}: CellSuccessProps<{ ${camelName}: ${fragmentName} }>) => {
|
|
42
|
+
return <div>{JSON.stringify(${camelName})}</div>
|
|
43
|
+
}
|
|
@@ -3,7 +3,9 @@ import type { ${operationName}, ${operationName}Variables } from 'types/graphql
|
|
|
3
3
|
import type {
|
|
4
4
|
CellSuccessProps,
|
|
5
5
|
CellFailureProps,
|
|
6
|
-
TypedDocumentNode
|
|
6
|
+
TypedDocumentNode,<% if (beforeQuery) { %>
|
|
7
|
+
CellBeforeQueryResult,<% } %><% if (afterQuery || isEmpty) { %>
|
|
8
|
+
DataObject,<% } %>
|
|
7
9
|
} from '@cedarjs/web'
|
|
8
10
|
|
|
9
11
|
export const QUERY: TypedDocumentNode<
|
|
@@ -16,7 +18,24 @@ export const QUERY: TypedDocumentNode<
|
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
`
|
|
19
|
-
|
|
21
|
+
<% if (beforeQuery) { %>
|
|
22
|
+
export const beforeQuery = (
|
|
23
|
+
props: ${operationName}Variables,
|
|
24
|
+
): CellBeforeQueryResult<${operationName}Variables> => {
|
|
25
|
+
return { variables: props, fetchPolicy: 'cache-and-network' }
|
|
26
|
+
}
|
|
27
|
+
<% } %><% if (isEmpty) { %>
|
|
28
|
+
export const isEmpty = (
|
|
29
|
+
data: DataObject,
|
|
30
|
+
{ isDataEmpty }: { isDataEmpty: (data: DataObject) => boolean },
|
|
31
|
+
) => {
|
|
32
|
+
return isDataEmpty(data)
|
|
33
|
+
}
|
|
34
|
+
<% } %><% if (afterQuery) { %>
|
|
35
|
+
export const afterQuery = (data: DataObject): DataObject => {
|
|
36
|
+
return data
|
|
37
|
+
}
|
|
38
|
+
<% } %>
|
|
20
39
|
export const Loading = () => <div>Loading...</div>
|
|
21
40
|
|
|
22
41
|
export const Empty = () => <div>Empty</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import { Empty, Success } from './${pascalName}Cell'
|
|
4
|
+
import { standard } from './${pascalName}Cell.mock'
|
|
5
|
+
|
|
6
|
+
const meta: Meta = {
|
|
7
|
+
title: 'Cells/${pascalName}Cell',
|
|
8
|
+
tags: ['autodocs']
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default meta
|
|
12
|
+
|
|
13
|
+
export const empty: StoryObj<typeof Empty> = {
|
|
14
|
+
render: () => {
|
|
15
|
+
return Empty ? <Empty /> : <></>
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const success: StoryObj<typeof Success> = {
|
|
20
|
+
render: (args) => {
|
|
21
|
+
return Success ? <Success {...standard()} {...args} /> : <></>
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -7,7 +7,7 @@ import { standard } from './${pascalName}Cell.mock'
|
|
|
7
7
|
// and can fail without adjustments, e.g. Float and DateTime types.
|
|
8
8
|
// Please refer to the RedwoodJS Testing Docs:
|
|
9
9
|
// https://cedarjs.com/docs/testing#testing-cells
|
|
10
|
-
// https://cedarjs.com/docs/testing#
|
|
10
|
+
// https://cedarjs.com/docs/testing#expect-type-considerations
|
|
11
11
|
|
|
12
12
|
describe('${pascalName}Cell', () => {
|
|
13
13
|
it('renders Loading successfully', () => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { render } from '@cedarjs/testing/web'
|
|
2
|
+
|
|
3
|
+
import { Empty, Success } from './${pascalName}Cell'
|
|
4
|
+
import { standard } from './${pascalName}Cell.mock'
|
|
5
|
+
|
|
6
|
+
// Generated boilerplate tests do not account for all circumstances
|
|
7
|
+
// and can fail without adjustments, e.g. Float and DateTime types.
|
|
8
|
+
// Please refer to the RedwoodJS Testing Docs:
|
|
9
|
+
// https://cedarjs.com/docs/testing#testing-cells
|
|
10
|
+
// https://cedarjs.com/docs/testing#expect-type-considerations
|
|
11
|
+
|
|
12
|
+
describe('${pascalName}Cell', () => {
|
|
13
|
+
it('renders Empty successfully', async () => {
|
|
14
|
+
expect(() => {
|
|
15
|
+
render(<Empty />)
|
|
16
|
+
}).not.toThrow()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// When you're ready to test the actual output of your component render
|
|
20
|
+
// you could test that, for example, certain text is present:
|
|
21
|
+
//
|
|
22
|
+
// 1. import { screen } from '@cedarjs/testing/web'
|
|
23
|
+
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument()
|
|
24
|
+
|
|
25
|
+
it('renders Success successfully', async () => {
|
|
26
|
+
expect(() => {
|
|
27
|
+
render(<Success ${camelName}={standard().${camelName}} />)
|
|
28
|
+
}).not.toThrow()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { transformTSToJSMap } from "../../../lib/index.js";
|
|
2
2
|
import {
|
|
3
3
|
createHandler,
|
|
4
4
|
templateForComponentFile
|
|
5
5
|
} from "../yargsHandlerHelpers.js";
|
|
6
|
-
const
|
|
7
|
-
const files = async ({
|
|
6
|
+
const CEDAR_WEB_PATH_NAME = "components";
|
|
7
|
+
const files = async ({
|
|
8
|
+
name,
|
|
9
|
+
typescript = false,
|
|
10
|
+
stories,
|
|
11
|
+
tests
|
|
12
|
+
}) => {
|
|
8
13
|
const extension = typescript ? ".tsx" : ".jsx";
|
|
9
14
|
const componentFile = await templateForComponentFile({
|
|
10
15
|
name,
|
|
11
|
-
webPathSection:
|
|
16
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
12
17
|
extension,
|
|
13
18
|
generator: "component",
|
|
14
19
|
templatePath: "component.tsx.template"
|
|
@@ -16,34 +21,27 @@ const files = async ({ name, typescript = false, ...argv }) => {
|
|
|
16
21
|
const testFile = await templateForComponentFile({
|
|
17
22
|
name,
|
|
18
23
|
extension: `.test${extension}`,
|
|
19
|
-
webPathSection:
|
|
24
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
20
25
|
generator: "component",
|
|
21
26
|
templatePath: "test.tsx.template"
|
|
22
27
|
});
|
|
23
28
|
const storiesFile = await templateForComponentFile({
|
|
24
29
|
name,
|
|
25
30
|
extension: `.stories${extension}`,
|
|
26
|
-
webPathSection:
|
|
31
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
27
32
|
generator: "component",
|
|
28
33
|
// Using two different template files here because we have a TS-specific
|
|
29
34
|
// information in a comment in the .tsx template
|
|
30
35
|
templatePath: typescript ? "stories.tsx.template" : "stories.jsx.template"
|
|
31
36
|
});
|
|
32
37
|
const files2 = [componentFile];
|
|
33
|
-
if (
|
|
38
|
+
if (stories) {
|
|
34
39
|
files2.push(storiesFile);
|
|
35
40
|
}
|
|
36
|
-
if (
|
|
41
|
+
if (tests) {
|
|
37
42
|
files2.push(testFile);
|
|
38
43
|
}
|
|
39
|
-
return files2
|
|
40
|
-
const acc = await accP;
|
|
41
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
42
|
-
return {
|
|
43
|
-
[outputPath]: template,
|
|
44
|
-
...acc
|
|
45
|
-
};
|
|
46
|
-
}, Promise.resolve({}));
|
|
44
|
+
return transformTSToJSMap(files2, typescript);
|
|
47
45
|
};
|
|
48
46
|
const handler = createHandler({
|
|
49
47
|
componentName: "component",
|