@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,18 +1,23 @@
|
|
|
1
1
|
import camelcase from "camelcase";
|
|
2
|
-
import execa from "execa";
|
|
3
2
|
import { Listr } from "listr2";
|
|
4
3
|
import prompts from "prompts";
|
|
5
|
-
import {
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
7
|
import { getConfig } from "@cedarjs/project-config";
|
|
7
|
-
import
|
|
8
|
-
import { writeFilesTask, transformTSToJS } from "../../../lib/index.js";
|
|
8
|
+
import { writeFilesTask, transformTSToJSMap } from "../../../lib/index.js";
|
|
9
9
|
import {
|
|
10
10
|
prepareForRollback,
|
|
11
11
|
addFunctionToRollback
|
|
12
12
|
} from "../../../lib/rollback.js";
|
|
13
13
|
import { validateName } from "../helpers.js";
|
|
14
14
|
import { templateForComponentFile } from "../yargsHandlerHelpers.js";
|
|
15
|
-
const files = async ({
|
|
15
|
+
const files = async ({
|
|
16
|
+
name,
|
|
17
|
+
typescript = false,
|
|
18
|
+
type,
|
|
19
|
+
tests
|
|
20
|
+
}) => {
|
|
16
21
|
if (tests === void 0) {
|
|
17
22
|
tests = getConfig().generate.tests;
|
|
18
23
|
}
|
|
@@ -41,14 +46,7 @@ const files = async ({ name, typescript = false, type, tests }) => {
|
|
|
41
46
|
});
|
|
42
47
|
files2.push(testFile);
|
|
43
48
|
}
|
|
44
|
-
return files2
|
|
45
|
-
const acc = await accP;
|
|
46
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
47
|
-
return {
|
|
48
|
-
[outputPath]: template,
|
|
49
|
-
...acc
|
|
50
|
-
};
|
|
51
|
-
}, Promise.resolve({}));
|
|
49
|
+
return transformTSToJSMap(files2, typescript);
|
|
52
50
|
};
|
|
53
51
|
const handler = async (args) => {
|
|
54
52
|
recordTelemetryAttributes({
|
|
@@ -110,9 +108,9 @@ const handler = async (args) => {
|
|
|
110
108
|
title: "Generating TypeScript definitions and GraphQL schemas ...",
|
|
111
109
|
task: () => {
|
|
112
110
|
addFunctionToRollback(async () => {
|
|
113
|
-
await
|
|
111
|
+
await runBin("cedar-gen", [], { stdio: "pipe" });
|
|
114
112
|
}, true);
|
|
115
|
-
return
|
|
113
|
+
return runBin("cedar-gen", [], { stdio: "inherit" });
|
|
116
114
|
}
|
|
117
115
|
},
|
|
118
116
|
{
|
|
@@ -133,7 +131,7 @@ const handler = async (args) => {
|
|
|
133
131
|
console.log(notes);
|
|
134
132
|
}
|
|
135
133
|
} catch (e) {
|
|
136
|
-
console.log(c.error(e.message));
|
|
134
|
+
console.log(c.error(e instanceof Error ? e.message : String(e)));
|
|
137
135
|
process.exit(1);
|
|
138
136
|
}
|
|
139
137
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Listr } from "listr2";
|
|
2
2
|
import { terminalLink } from "termi-link";
|
|
3
|
-
import {
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
4
5
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
5
|
-
import
|
|
6
|
-
import { transformTSToJS, writeFilesTask } from "../../../lib/index.js";
|
|
6
|
+
import { transformTSToJSMap, writeFilesTask } from "../../../lib/index.js";
|
|
7
7
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
8
8
|
import { validateName } from "../helpers.js";
|
|
9
9
|
import { templateForComponentFile } from "../yargsHandlerHelpers.js";
|
|
10
10
|
const files = async ({
|
|
11
11
|
name,
|
|
12
|
-
typescript
|
|
13
|
-
tests
|
|
12
|
+
typescript = false,
|
|
13
|
+
tests = true,
|
|
14
14
|
...rest
|
|
15
15
|
}) => {
|
|
16
|
-
const extension =
|
|
16
|
+
const extension = typescript ? ".ts" : ".js";
|
|
17
17
|
const outputFiles = [];
|
|
18
18
|
const functionFiles = await templateForComponentFile({
|
|
19
19
|
name,
|
|
@@ -21,10 +21,10 @@ const files = async ({
|
|
|
21
21
|
apiPathSection: "functions",
|
|
22
22
|
generator: "function",
|
|
23
23
|
templatePath: "function.ts.template",
|
|
24
|
-
templateVars: { ...rest, typescript
|
|
24
|
+
templateVars: { ...rest, typescript }
|
|
25
25
|
});
|
|
26
26
|
outputFiles.push(functionFiles);
|
|
27
|
-
if (
|
|
27
|
+
if (tests) {
|
|
28
28
|
const testFile = await templateForComponentFile({
|
|
29
29
|
name,
|
|
30
30
|
extension: `.test${extension}`,
|
|
@@ -44,14 +44,7 @@ const files = async ({
|
|
|
44
44
|
outputFiles.push(testFile);
|
|
45
45
|
outputFiles.push(scenarioFile);
|
|
46
46
|
}
|
|
47
|
-
return outputFiles
|
|
48
|
-
const acc = await accP;
|
|
49
|
-
const template = generateTypescript ? content : await transformTSToJS(outputPath, content);
|
|
50
|
-
return {
|
|
51
|
-
[outputPath]: template,
|
|
52
|
-
...acc
|
|
53
|
-
};
|
|
54
|
-
}, Promise.resolve({}));
|
|
47
|
+
return transformTSToJSMap(outputFiles, typescript);
|
|
55
48
|
};
|
|
56
49
|
const handler = async ({ name, force, ...rest }) => {
|
|
57
50
|
recordTelemetryAttributes({
|
|
@@ -95,9 +88,11 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
95
88
|
);
|
|
96
89
|
console.info("");
|
|
97
90
|
} catch (e) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
process.
|
|
91
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
92
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
93
|
+
errorTelemetry(process.argv, message);
|
|
94
|
+
console.error(c.error(message));
|
|
95
|
+
process.exit(exitCode);
|
|
101
96
|
}
|
|
102
97
|
};
|
|
103
98
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { paramCase } from "change-case";
|
|
2
2
|
import pascalcase from "pascalcase";
|
|
3
|
-
import { pluralize, isPlural, isSingular } from "
|
|
3
|
+
import { pluralize, isPlural, isSingular } from "@cedarjs/utils/cedarPluralize";
|
|
4
4
|
const pathName = (path, name) => {
|
|
5
5
|
let routePath = path;
|
|
6
6
|
if (path && path.startsWith("{") && path.endsWith("}")) {
|
|
@@ -23,8 +23,22 @@ const validateName = (name) => {
|
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
+
const SENSITIVE_FIELDS = [
|
|
27
|
+
"hashedPassword",
|
|
28
|
+
"salt",
|
|
29
|
+
"resetToken",
|
|
30
|
+
"resetTokenExpiresAt",
|
|
31
|
+
"webAuthnChallenge"
|
|
32
|
+
];
|
|
33
|
+
const redactedModelFields = (fieldNames) => {
|
|
34
|
+
const sensitive = fieldNames.filter((name) => SENSITIVE_FIELDS.includes(name));
|
|
35
|
+
if (sensitive.length === 1 && sensitive[0] === "salt") {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
return sensitive;
|
|
39
|
+
};
|
|
26
40
|
const relationsForModel = (model) => {
|
|
27
|
-
return model
|
|
41
|
+
return model?.fields.filter((f) => f.relationName).map((field) => {
|
|
28
42
|
return field.name;
|
|
29
43
|
});
|
|
30
44
|
};
|
|
@@ -37,34 +51,36 @@ const forcePluralizeWord = (word) => {
|
|
|
37
51
|
}
|
|
38
52
|
return pluralize(word);
|
|
39
53
|
};
|
|
54
|
+
const routeParamToTsType = {
|
|
55
|
+
Int: "number",
|
|
56
|
+
Float: "number",
|
|
57
|
+
Boolean: "boolean",
|
|
58
|
+
String: "string"
|
|
59
|
+
};
|
|
40
60
|
const mapRouteParamTypeToTsType = (paramType) => {
|
|
41
|
-
const routeParamToTsType = {
|
|
42
|
-
Int: "number",
|
|
43
|
-
Float: "number",
|
|
44
|
-
Boolean: "boolean",
|
|
45
|
-
String: "string"
|
|
46
|
-
};
|
|
47
61
|
return routeParamToTsType[paramType] || "unknown";
|
|
48
62
|
};
|
|
63
|
+
const prismaScalarToTsType = {
|
|
64
|
+
String: "string",
|
|
65
|
+
Boolean: "boolean",
|
|
66
|
+
Int: "number",
|
|
67
|
+
BigInt: "number",
|
|
68
|
+
Float: "number",
|
|
69
|
+
Decimal: "number",
|
|
70
|
+
DateTime: "string",
|
|
71
|
+
Bytes: "Uint8Array"
|
|
72
|
+
};
|
|
49
73
|
const mapPrismaScalarToPagePropTsType = (scalarType) => {
|
|
50
|
-
const prismaScalarToTsType = {
|
|
51
|
-
String: "string",
|
|
52
|
-
Boolean: "boolean",
|
|
53
|
-
Int: "number",
|
|
54
|
-
BigInt: "number",
|
|
55
|
-
Float: "number",
|
|
56
|
-
Decimal: "number",
|
|
57
|
-
DateTime: "string",
|
|
58
|
-
Bytes: "Uint8Array"
|
|
59
|
-
};
|
|
60
74
|
return prismaScalarToTsType[scalarType] || "unknown";
|
|
61
75
|
};
|
|
62
76
|
export {
|
|
77
|
+
SENSITIVE_FIELDS,
|
|
63
78
|
forcePluralizeWord,
|
|
64
79
|
intForeignKeysForModel,
|
|
65
80
|
mapPrismaScalarToPagePropTsType,
|
|
66
81
|
mapRouteParamTypeToTsType,
|
|
67
82
|
pathName,
|
|
83
|
+
redactedModelFields,
|
|
68
84
|
relationsForModel,
|
|
69
85
|
removeGeneratorName,
|
|
70
86
|
validateName
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import * as changeCase from "change-case";
|
|
4
|
-
import execa from "execa";
|
|
5
4
|
import { Listr } from "listr2";
|
|
6
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
7
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
-
import c from "../../../lib/colors.js";
|
|
9
9
|
import {
|
|
10
10
|
getPaths,
|
|
11
|
-
|
|
11
|
+
transformTSToJSMap,
|
|
12
12
|
writeFilesTask
|
|
13
13
|
} from "../../../lib/index.js";
|
|
14
14
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
@@ -65,16 +65,13 @@ const files = async ({
|
|
|
65
65
|
outputFiles.push(testFile);
|
|
66
66
|
outputFiles.push(scenarioFile);
|
|
67
67
|
}
|
|
68
|
-
return outputFiles
|
|
69
|
-
const acc = await accP;
|
|
70
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
71
|
-
return {
|
|
72
|
-
[outputPath]: template,
|
|
73
|
-
...acc
|
|
74
|
-
};
|
|
75
|
-
}, Promise.resolve({}));
|
|
68
|
+
return transformTSToJSMap(outputFiles, typescript);
|
|
76
69
|
};
|
|
77
|
-
const handler = async ({
|
|
70
|
+
const handler = async ({
|
|
71
|
+
name,
|
|
72
|
+
force,
|
|
73
|
+
...rest
|
|
74
|
+
}) => {
|
|
78
75
|
recordTelemetryAttributes({
|
|
79
76
|
command: "generate job",
|
|
80
77
|
force,
|
|
@@ -86,7 +83,7 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
86
83
|
const jobsManagerFile = getPaths().api.distJobsConfig;
|
|
87
84
|
const jobManager = await import(pathToFileURL(jobsManagerFile).href);
|
|
88
85
|
queueName = jobManager.jobs?.queues[0] ?? "default";
|
|
89
|
-
} catch
|
|
86
|
+
} catch {
|
|
90
87
|
}
|
|
91
88
|
let jobFiles = {};
|
|
92
89
|
const tasks = new Listr(
|
|
@@ -101,14 +98,11 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
101
98
|
{
|
|
102
99
|
title: "Cleaning up...",
|
|
103
100
|
task: () => {
|
|
104
|
-
|
|
101
|
+
runBinSync(
|
|
105
102
|
"eslint",
|
|
106
|
-
"--fix",
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
`${getPaths().api.jobsConfig}`,
|
|
110
|
-
...Object.keys(jobFiles)
|
|
111
|
-
]);
|
|
103
|
+
["--fix", `${getPaths().api.jobsConfig}`, ...Object.keys(jobFiles)],
|
|
104
|
+
{ cwd: getPaths().base }
|
|
105
|
+
);
|
|
112
106
|
}
|
|
113
107
|
}
|
|
114
108
|
],
|
|
@@ -120,9 +114,11 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
120
114
|
}
|
|
121
115
|
await tasks.run();
|
|
122
116
|
} catch (e) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
process.
|
|
117
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
118
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
119
|
+
errorTelemetry(process.argv, message);
|
|
120
|
+
console.error(c.error(message));
|
|
121
|
+
process.exit(exitCode);
|
|
126
122
|
}
|
|
127
123
|
};
|
|
128
124
|
export {
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { transformTSToJSMap } from "../../../lib/index.js";
|
|
2
2
|
import { removeGeneratorName } from "../helpers.js";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
createHandler,
|
|
5
|
+
templateForComponentFile
|
|
6
6
|
} from "../yargsHandlerHelpers.js";
|
|
7
7
|
const COMPONENT_SUFFIX = "Layout";
|
|
8
|
-
const
|
|
9
|
-
const files = async ({
|
|
8
|
+
const CEDAR_WEB_PATH_NAME = "layouts";
|
|
9
|
+
const files = async ({
|
|
10
|
+
name,
|
|
11
|
+
typescript = false,
|
|
12
|
+
...options
|
|
13
|
+
}) => {
|
|
10
14
|
const layoutName = removeGeneratorName(name, "layout");
|
|
11
15
|
const extension = typescript ? ".tsx" : ".jsx";
|
|
12
16
|
const layoutFile = await templateForComponentFile({
|
|
13
17
|
name: layoutName,
|
|
14
18
|
suffix: COMPONENT_SUFFIX,
|
|
15
|
-
webPathSection:
|
|
19
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
16
20
|
extension,
|
|
17
21
|
generator: "layout",
|
|
18
22
|
templatePath: options.skipLink ? "layout.tsx.a11y.template" : "layout.tsx.template"
|
|
@@ -21,7 +25,7 @@ const files = async ({ name, typescript = false, ...options }) => {
|
|
|
21
25
|
name: layoutName,
|
|
22
26
|
suffix: COMPONENT_SUFFIX,
|
|
23
27
|
extension: `.test${extension}`,
|
|
24
|
-
webPathSection:
|
|
28
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
25
29
|
generator: "layout",
|
|
26
30
|
templatePath: "test.tsx.template"
|
|
27
31
|
});
|
|
@@ -29,7 +33,7 @@ const files = async ({ name, typescript = false, ...options }) => {
|
|
|
29
33
|
name: layoutName,
|
|
30
34
|
suffix: COMPONENT_SUFFIX,
|
|
31
35
|
extension: `.stories${extension}`,
|
|
32
|
-
webPathSection:
|
|
36
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
33
37
|
generator: "layout",
|
|
34
38
|
templatePath: "stories.tsx.template"
|
|
35
39
|
});
|
|
@@ -40,14 +44,7 @@ const files = async ({ name, typescript = false, ...options }) => {
|
|
|
40
44
|
if (options.tests) {
|
|
41
45
|
files2.push(testFile);
|
|
42
46
|
}
|
|
43
|
-
return files2
|
|
44
|
-
const acc = await accP;
|
|
45
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
46
|
-
return {
|
|
47
|
-
[outputPath]: template,
|
|
48
|
-
...acc
|
|
49
|
-
};
|
|
50
|
-
}, Promise.resolve({}));
|
|
47
|
+
return transformTSToJSMap(files2, typescript);
|
|
51
48
|
};
|
|
52
49
|
const handler = createHandler({
|
|
53
50
|
componentName: "layout",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { Listr } from "listr2";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
5
|
import {
|
|
6
6
|
getPaths,
|
|
7
7
|
writeFilesTask,
|
|
@@ -15,14 +15,20 @@ const TEMPLATE_PATH = path.resolve(
|
|
|
15
15
|
"templates",
|
|
16
16
|
"model.js.template"
|
|
17
17
|
);
|
|
18
|
-
const files = async ({
|
|
18
|
+
const files = async ({
|
|
19
|
+
name,
|
|
20
|
+
typescript = false
|
|
21
|
+
}) => {
|
|
19
22
|
const outputFilename = `${name}.${typescript ? "ts" : "js"}`;
|
|
20
23
|
const outputPath = path.join(getPaths().api.models, outputFilename);
|
|
21
24
|
return {
|
|
22
25
|
[outputPath]: await generateTemplate(TEMPLATE_PATH, { name })
|
|
23
26
|
};
|
|
24
27
|
};
|
|
25
|
-
const handler = async ({
|
|
28
|
+
const handler = async ({
|
|
29
|
+
force,
|
|
30
|
+
...args
|
|
31
|
+
}) => {
|
|
26
32
|
recordTelemetryAttributes({
|
|
27
33
|
command: "generate model",
|
|
28
34
|
force,
|
|
@@ -54,7 +60,7 @@ const handler = async ({ force, ...args }) => {
|
|
|
54
60
|
}
|
|
55
61
|
await tasks.run();
|
|
56
62
|
} catch (e) {
|
|
57
|
-
console.log(c.error(e.message));
|
|
63
|
+
console.log(c.error(e instanceof Error ? e.message : String(e)));
|
|
58
64
|
process.exit(1);
|
|
59
65
|
}
|
|
60
66
|
};
|
|
@@ -2,10 +2,10 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fg from "fast-glob";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
7
|
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
7
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
|
-
import c from "../../../lib/colors.js";
|
|
9
9
|
import {
|
|
10
10
|
generateTemplate,
|
|
11
11
|
getPaths,
|
|
@@ -14,7 +14,10 @@ import {
|
|
|
14
14
|
} from "../../../lib/index.js";
|
|
15
15
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
16
16
|
import { customOrDefaultTemplatePath } from "../yargsHandlerHelpers.js";
|
|
17
|
-
const files = async ({
|
|
17
|
+
const files = async ({
|
|
18
|
+
pagePath,
|
|
19
|
+
typescript = false
|
|
20
|
+
}) => {
|
|
18
21
|
const extension = typescript ? ".tsx" : ".jsx";
|
|
19
22
|
const componentOutputPath = path.join(
|
|
20
23
|
getPaths().web.pages,
|
|
@@ -74,6 +77,10 @@ const handler = async (options) => {
|
|
|
74
77
|
const extension = options.typescript ? "tsx" : "jsx";
|
|
75
78
|
try {
|
|
76
79
|
await validatePath(normalizedPagePath, extension);
|
|
80
|
+
const listrOptions = {
|
|
81
|
+
exitOnError: true,
|
|
82
|
+
...options.verbose ? { renderer: "verbose" } : { rendererOptions: { collapseSubtasks: false } }
|
|
83
|
+
};
|
|
77
84
|
const tasks = new Listr(
|
|
78
85
|
[
|
|
79
86
|
{
|
|
@@ -87,22 +94,22 @@ const handler = async (options) => {
|
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
],
|
|
90
|
-
|
|
91
|
-
rendererOptions: { collapseSubtasks: false },
|
|
92
|
-
exitOnError: true,
|
|
93
|
-
renderer: options.verbose && "verbose"
|
|
94
|
-
}
|
|
97
|
+
listrOptions
|
|
95
98
|
);
|
|
96
99
|
if (options.rollback && !options.force) {
|
|
97
100
|
prepareForRollback(tasks);
|
|
98
101
|
}
|
|
99
102
|
await tasks.run();
|
|
100
103
|
} catch (e) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
105
|
+
errorTelemetry(process.argv, message);
|
|
106
|
+
console.error(c.error(message));
|
|
107
|
+
process.exit(errorExitCode(e));
|
|
104
108
|
}
|
|
105
109
|
};
|
|
110
|
+
function errorExitCode(e) {
|
|
111
|
+
return typeof e === "object" && e !== null && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
112
|
+
}
|
|
106
113
|
export {
|
|
107
114
|
files,
|
|
108
115
|
handler,
|
|
@@ -58,6 +58,15 @@ const files = async ({
|
|
|
58
58
|
outputPath: path.join(folderName, "src", `${fileName}.test${extension}`)
|
|
59
59
|
});
|
|
60
60
|
outputFiles.push(testFile);
|
|
61
|
+
const vitestConfigFile = await templateForFile({
|
|
62
|
+
name,
|
|
63
|
+
side: "packages",
|
|
64
|
+
generator: "package",
|
|
65
|
+
templatePath: "vitest.config.ts.template",
|
|
66
|
+
templateVars: { folderName, ...rest },
|
|
67
|
+
outputPath: path.join(folderName, `vitest.config${extension}`)
|
|
68
|
+
});
|
|
69
|
+
outputFiles.push(vitestConfigFile);
|
|
61
70
|
}
|
|
62
71
|
return outputFiles.reduce(async (accP, [outputPath, content]) => {
|
|
63
72
|
const acc = await accP;
|