@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
|
@@ -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 c from "
|
|
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"],
|
|
@@ -36,7 +36,7 @@ const tasks = ({ name, force }) => {
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
title: "Destination:",
|
|
39
|
-
task: (
|
|
39
|
+
task: (_ctx, task) => {
|
|
40
40
|
task.title = ` Wrote templates to ${destination.replace(
|
|
41
41
|
getPaths().base,
|
|
42
42
|
""
|
|
@@ -44,7 +44,7 @@ const tasks = ({ name, force }) => {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
|
-
{ rendererOptions: { collapseSubtasks: false }
|
|
47
|
+
{ rendererOptions: { collapseSubtasks: false } }
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
50
|
const handler = async ({ name, force }) => {
|
|
@@ -52,7 +52,8 @@ const handler = async ({ name, force }) => {
|
|
|
52
52
|
try {
|
|
53
53
|
await t.run();
|
|
54
54
|
} catch (e) {
|
|
55
|
-
|
|
55
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
56
|
+
console.log(c.error(message));
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
59
|
export {
|
|
@@ -16,8 +16,11 @@ function isPropertyWithName(node, name) {
|
|
|
16
16
|
function transform(file, api) {
|
|
17
17
|
const j = api.jscodeshift;
|
|
18
18
|
const root = j(file.source);
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
let apolloProviderElements = root.findJSXElements("CedarApolloProvider");
|
|
20
|
+
if (apolloProviderElements.length === 0) {
|
|
21
|
+
apolloProviderElements = root.findJSXElements("RedwoodApolloProvider");
|
|
22
|
+
}
|
|
23
|
+
const graphQLClientConfigCollection = apolloProviderElements.find(
|
|
21
24
|
j.JSXAttribute,
|
|
22
25
|
{
|
|
23
26
|
name: { name: "graphQLClientConfig" }
|
|
@@ -104,7 +107,7 @@ function transform(file, api) {
|
|
|
104
107
|
cacheConfigValue.properties.push(property);
|
|
105
108
|
}
|
|
106
109
|
graphQLClientConfigCollection.remove();
|
|
107
|
-
|
|
110
|
+
apolloProviderElements.get(0).node.openingElement.attributes.push(
|
|
108
111
|
j.jsxAttribute(
|
|
109
112
|
j.jsxIdentifier("graphQLClientConfig"),
|
|
110
113
|
j.jsxExpressionContainer(j.identifier(graphQLClientConfigVariableName))
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import execa from "execa";
|
|
4
3
|
import { Listr } from "listr2";
|
|
5
4
|
import { format } from "prettier";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "@cedarjs/cli-helpers";
|
|
5
|
+
import { colors } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
|
|
7
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
8
|
+
import { setTomlSetting } from "@cedarjs/cli-helpers/project";
|
|
11
9
|
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
12
10
|
import { runTransform } from "../../../../../lib/runTransform.js";
|
|
13
11
|
const command = "fragments";
|
|
@@ -34,7 +32,7 @@ async function handler({ force }) {
|
|
|
34
32
|
{
|
|
35
33
|
title: "Generate possibleTypes.ts",
|
|
36
34
|
task: () => {
|
|
37
|
-
|
|
35
|
+
runBinSync("cedar", ["generate", "types"], { stdio: "ignore" });
|
|
38
36
|
}
|
|
39
37
|
},
|
|
40
38
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
const command = "trusted-documents";
|
|
3
3
|
const description = "Set up Trusted Documents for GraphQL";
|
|
4
4
|
function builder(yargs) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import execa from "execa";
|
|
4
3
|
import { Listr } from "listr2";
|
|
5
4
|
import { format } from "prettier";
|
|
6
|
-
import { getPrettierOptions
|
|
5
|
+
import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
|
|
6
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
|
+
import { setTomlSetting } from "@cedarjs/cli-helpers/project";
|
|
7
8
|
import { getConfig, getPaths, resolveFile } from "@cedarjs/project-config";
|
|
8
9
|
import { runTransform } from "../../../../../lib/runTransform.js";
|
|
9
10
|
async function handler({ force }) {
|
|
@@ -28,7 +29,7 @@ async function handler({ force }) {
|
|
|
28
29
|
{
|
|
29
30
|
title: "Generating Trusted Documents store ...",
|
|
30
31
|
task: () => {
|
|
31
|
-
|
|
32
|
+
runBinSync("cedar", ["generate", "types"], { stdio: "ignore" });
|
|
32
33
|
}
|
|
33
34
|
},
|
|
34
35
|
{
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import execa from "execa";
|
|
4
3
|
import { Listr } from "listr2";
|
|
4
|
+
import { terminalLink } from "termi-link";
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
5
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
6
|
-
import c from "../../../lib/colors.js";
|
|
7
8
|
import extendStorybookConfiguration from "../../../lib/configureStorybook.js";
|
|
8
9
|
import { fileIncludes } from "../../../lib/extendFile.js";
|
|
9
10
|
import { getPaths, writeFile } from "../../../lib/index.js";
|
|
10
11
|
const APP_JS_PATH = getPaths().web.app;
|
|
11
12
|
const i18nImportExist = (appJS) => {
|
|
12
|
-
|
|
13
|
+
const content = appJS.toString();
|
|
13
14
|
const hasBaseImport = () => /import '.\/i18n'/.test(content);
|
|
14
15
|
return hasBaseImport();
|
|
15
16
|
};
|
|
16
17
|
const addI18nImport = (appJS) => {
|
|
17
|
-
|
|
18
|
-
const index = content.findIndex((value) =>
|
|
18
|
+
const content = appJS.toString().split("\n").reverse();
|
|
19
|
+
const index = content.findIndex((value) => value.includes("import"));
|
|
19
20
|
content.splice(index, 0, "import './i18n'");
|
|
20
21
|
return content.reverse().join(`
|
|
21
22
|
`);
|
|
@@ -38,14 +39,15 @@ const handler = async ({ force }) => {
|
|
|
38
39
|
{
|
|
39
40
|
title: "Install i18next, react-i18next and i18next-browser-languagedetector",
|
|
40
41
|
task: async () => {
|
|
41
|
-
await
|
|
42
|
-
"workspace",
|
|
42
|
+
await addWorkspacePackages(
|
|
43
43
|
"web",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
[
|
|
45
|
+
"i18next",
|
|
46
|
+
"react-i18next",
|
|
47
|
+
"i18next-browser-languagedetector"
|
|
48
|
+
],
|
|
49
|
+
{ cwd: rwPaths.base }
|
|
50
|
+
);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
],
|
|
@@ -122,7 +124,7 @@ const handler = async ({ force }) => {
|
|
|
122
124
|
{
|
|
123
125
|
title: "Adding import to App.{jsx,tsx}...",
|
|
124
126
|
task: (_ctx, task) => {
|
|
125
|
-
|
|
127
|
+
const appJS = fs.readFileSync(APP_JS_PATH);
|
|
126
128
|
if (i18nImportExist(appJS)) {
|
|
127
129
|
task.skip("Import already exists in App.js");
|
|
128
130
|
} else {
|
|
@@ -149,7 +151,7 @@ const handler = async ({ force }) => {
|
|
|
149
151
|
|
|
150
152
|
${c.tip("Quick link to the docs:")}
|
|
151
153
|
|
|
152
|
-
${
|
|
154
|
+
${terminalLink("react-i18next quick start guide", "https://react.i18next.com/guides/quick-start/")}
|
|
153
155
|
`;
|
|
154
156
|
}
|
|
155
157
|
}
|
|
@@ -159,9 +161,11 @@ const handler = async ({ force }) => {
|
|
|
159
161
|
try {
|
|
160
162
|
await tasks.run();
|
|
161
163
|
} catch (e) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
165
|
+
errorTelemetry(process.argv, message);
|
|
166
|
+
console.error(c.error(message));
|
|
167
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
168
|
+
process.exit(exitCode);
|
|
165
169
|
}
|
|
166
170
|
};
|
|
167
171
|
export {
|
|
@@ -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 = "jobs";
|
|
4
4
|
const description = "Sets up the config file and parent directory for background jobs";
|
|
5
5
|
const builder = (yargs) => {
|
|
@@ -2,12 +2,14 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import prismaInternals from "@prisma/internals";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
5
|
+
import { terminalLink } from "termi-link";
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
|
+
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
8
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
|
+
import { getSchemaPath, getPrismaSchemas } from "@cedarjs/project-config";
|
|
8
10
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
9
11
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
10
|
-
const { getDMMF
|
|
12
|
+
const { getDMMF } = prismaInternals;
|
|
11
13
|
const MODEL_SCHEMA = `
|
|
12
14
|
model BackgroundJob {
|
|
13
15
|
id Int @id @default(autoincrement())
|
|
@@ -26,8 +28,7 @@ model BackgroundJob {
|
|
|
26
28
|
}
|
|
27
29
|
`;
|
|
28
30
|
const getModelNames = async () => {
|
|
29
|
-
const
|
|
30
|
-
const { schemas } = await getSchemaWithPath(schemaPath);
|
|
31
|
+
const { schemas } = await getPrismaSchemas();
|
|
31
32
|
const schema = await getDMMF({ datamodel: schemas });
|
|
32
33
|
return schema.datamodel.models.map((model) => model.name);
|
|
33
34
|
};
|
|
@@ -54,6 +55,7 @@ const tasks = async ({ force }) => {
|
|
|
54
55
|
if (modelExists) {
|
|
55
56
|
return "BackgroundJob model exists, skipping";
|
|
56
57
|
}
|
|
58
|
+
return false;
|
|
57
59
|
}
|
|
58
60
|
},
|
|
59
61
|
{
|
|
@@ -98,19 +100,22 @@ const tasks = async ({ force }) => {
|
|
|
98
100
|
${c.success("\nBackground jobs configured!\n")}
|
|
99
101
|
|
|
100
102
|
${!modelExists ? "Migrate your database to finish setting up jobs:\n" : ""}
|
|
101
|
-
${!modelExists ? c.highlight(
|
|
103
|
+
${!modelExists ? c.highlight(`
|
|
104
|
+
\xA0\xA0${formatCedarCommand(["prisma", "migrate", "dev"])}
|
|
105
|
+
`) : ""}
|
|
102
106
|
|
|
103
|
-
Generate jobs with: ${c.highlight("
|
|
104
|
-
Execute jobs with: ${c.highlight("
|
|
107
|
+
Generate jobs with: ${c.highlight(formatCedarCommand(["g", "job", "<name>"]))}
|
|
108
|
+
Execute jobs with: ${c.highlight(`${formatCedarCommand(["jobs", "work"])}
|
|
109
|
+
`)}
|
|
105
110
|
|
|
106
111
|
Check out the docs for more info:
|
|
107
|
-
${
|
|
112
|
+
${terminalLink("", "https://cedarjs.com/docs/background-jobs")}
|
|
108
113
|
|
|
109
114
|
`;
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
],
|
|
113
|
-
{ rendererOptions: { collapseSubtasks: false },
|
|
118
|
+
{ rendererOptions: { collapseSubtasks: false }, exitOnError: true }
|
|
114
119
|
);
|
|
115
120
|
};
|
|
116
121
|
const handler = async ({ force }) => {
|
|
@@ -118,7 +123,7 @@ const handler = async ({ force }) => {
|
|
|
118
123
|
try {
|
|
119
124
|
await t.run();
|
|
120
125
|
} catch (e) {
|
|
121
|
-
console.error(c.error(e.message));
|
|
126
|
+
console.error(c.error(e instanceof Error ? e.message : String(e)));
|
|
122
127
|
}
|
|
123
128
|
};
|
|
124
129
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
const command = "mailer";
|
|
3
3
|
const description = "Setup the Cedar mailer. This will install the required packages and add the required initial configuration to your Cedar app.";
|
|
4
4
|
const builder = (yargs) => {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { pathToFileURL } from "node:url";
|
|
4
3
|
import { Listr } from "listr2";
|
|
5
|
-
import {
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
6
6
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
|
-
import c from "../../../lib/colors.js";
|
|
8
7
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
9
8
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
10
|
-
const handler = async ({
|
|
9
|
+
const handler = async ({
|
|
10
|
+
force,
|
|
11
|
+
skipExamples
|
|
12
|
+
}) => {
|
|
11
13
|
const projectIsTypescript = isTypeScriptProject();
|
|
12
14
|
const pkgJsonPath = path.join(getPaths().base, "package.json");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
const cedarVersion = pkgJson.devDependencies["@cedarjs/core"] ?? "latest";
|
|
15
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
16
|
+
const cedarVersion = pkgJson.devDependencies?.["@cedarjs/core"] ?? "latest";
|
|
17
17
|
const extension = projectIsTypescript ? "ts" : "js";
|
|
18
18
|
const tasks = new Listr(
|
|
19
19
|
[
|
|
@@ -100,9 +100,11 @@ const handler = async ({ force, skipExamples }) => {
|
|
|
100
100
|
try {
|
|
101
101
|
await tasks.run();
|
|
102
102
|
} catch (e) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
104
|
+
errorTelemetry(process.argv, message);
|
|
105
|
+
console.error(c.error(message));
|
|
106
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
107
|
+
process.exit(exitCode);
|
|
106
108
|
}
|
|
107
109
|
};
|
|
108
110
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
const command = "og-image";
|
|
3
3
|
const aliases = ["ogImage", "ogimage"];
|
|
4
4
|
const description = "Set up OG Image generation middleware";
|
|
@@ -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 { format } from "prettier";
|
|
5
|
-
import {
|
|
5
|
+
import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
|
|
6
|
+
import { addWebPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
6
7
|
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
7
8
|
import { runTransform } from "../../../../lib/runTransform.js";
|
|
8
9
|
async function handler({ force }) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
+
import { colors } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { prettify, writeFilesTask } from "@cedarjs/cli-helpers/fileHelpers";
|
|
4
6
|
import {
|
|
5
7
|
addApiPackages,
|
|
8
|
+
addWebPackages
|
|
9
|
+
} from "@cedarjs/cli-helpers/installHelpers";
|
|
10
|
+
import { getPaths } from "@cedarjs/cli-helpers/paths";
|
|
11
|
+
import {
|
|
6
12
|
addEnvVarTask,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getPaths,
|
|
10
|
-
isTypeScriptProject,
|
|
11
|
-
prettify,
|
|
12
|
-
writeFilesTask
|
|
13
|
-
} from "@cedarjs/cli-helpers";
|
|
13
|
+
isTypeScriptProject
|
|
14
|
+
} from "@cedarjs/cli-helpers/project";
|
|
14
15
|
import { getConfigPath } from "@cedarjs/project-config";
|
|
15
16
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
16
17
|
const rwPaths = getPaths();
|
|
@@ -90,15 +91,20 @@ const handler = async ({ force }) => {
|
|
|
90
91
|
title: "Replacing Redwood's Error boundary",
|
|
91
92
|
task: async () => {
|
|
92
93
|
const contentLines = fs.readFileSync(rwPaths.web.app).toString().split("\n");
|
|
94
|
+
const webImportRe = /^import \{ FatalErrorBoundary, ((?:Cedar|Redwood)Provider) \} from '@cedarjs\/web'$/;
|
|
93
95
|
const webImportIndex = contentLines.findLastIndex(
|
|
94
|
-
(line) =>
|
|
95
|
-
line
|
|
96
|
-
)
|
|
96
|
+
(line) => webImportRe.test(line)
|
|
97
97
|
);
|
|
98
|
+
if (webImportIndex === -1) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Could not find "import { FatalErrorBoundary, CedarProvider } from '@cedarjs/web'" in web/src/App`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const providerName = contentLines[webImportIndex].match(webImportRe)?.[1];
|
|
98
104
|
contentLines.splice(
|
|
99
105
|
webImportIndex,
|
|
100
106
|
1,
|
|
101
|
-
|
|
107
|
+
`import { ${providerName} } from '@cedarjs/web'`
|
|
102
108
|
);
|
|
103
109
|
const boundaryOpenIndex = contentLines.findLastIndex(
|
|
104
110
|
(line) => line.includes("<FatalErrorBoundary page={FatalErrorPage}>")
|
|
@@ -121,7 +127,7 @@ const handler = async ({ force }) => {
|
|
|
121
127
|
},
|
|
122
128
|
{
|
|
123
129
|
title: "One more thing...",
|
|
124
|
-
task: (ctx) => {
|
|
130
|
+
task: (ctx, task) => {
|
|
125
131
|
notes.push(
|
|
126
132
|
colors.important(
|
|
127
133
|
task.output = `You will need to add \`SENTRY_DSN\` to \`includeEnvironmentVariables\` in ${configFileName}.`
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
|
+
const command = "neon";
|
|
3
|
+
const description = "Provision a Neon Postgres database and configure your project";
|
|
4
|
+
function builder(yargs) {
|
|
5
|
+
return yargs.option("force", {
|
|
6
|
+
alias: "f",
|
|
7
|
+
default: false,
|
|
8
|
+
description: "Overwrite existing DATABASE_URL in .env",
|
|
9
|
+
type: "boolean"
|
|
10
|
+
}).option("migrations", {
|
|
11
|
+
description: "Run Prisma migrations after setup. Omit to be prompted. Use --no-migrations to skip.",
|
|
12
|
+
type: "boolean"
|
|
13
|
+
}).option("verbose", {
|
|
14
|
+
alias: "v",
|
|
15
|
+
default: false,
|
|
16
|
+
description: "Show full output from migration commands (stderr visible in terminal)",
|
|
17
|
+
type: "boolean"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async function handler({ force, migrations, verbose }) {
|
|
21
|
+
recordTelemetryAttributes({
|
|
22
|
+
command: "setup neon",
|
|
23
|
+
force,
|
|
24
|
+
migrations,
|
|
25
|
+
verbose
|
|
26
|
+
});
|
|
27
|
+
const { handler: handler2 } = await import("./neonHandler.js");
|
|
28
|
+
return handler2({ force, migrations, verbose });
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
builder,
|
|
32
|
+
command,
|
|
33
|
+
description,
|
|
34
|
+
handler
|
|
35
|
+
};
|