@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
package/dist/commands/lint.js
CHANGED
|
@@ -1,69 +1,15 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import execa from "execa";
|
|
4
2
|
import { terminalLink } from "termi-link";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const projectRoot = getPaths().base;
|
|
9
|
-
const legacyConfigFiles = [
|
|
10
|
-
".eslintrc.js",
|
|
11
|
-
".eslintrc.cjs",
|
|
12
|
-
".eslintrc.json",
|
|
13
|
-
".eslintrc.yaml",
|
|
14
|
-
".eslintrc.yml"
|
|
15
|
-
];
|
|
16
|
-
const foundLegacyFiles = [];
|
|
17
|
-
for (const configFile of legacyConfigFiles) {
|
|
18
|
-
if (fs.existsSync(path.join(projectRoot, configFile))) {
|
|
19
|
-
foundLegacyFiles.push(configFile);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
23
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
24
|
-
try {
|
|
25
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
26
|
-
if (packageJson.eslintConfig) {
|
|
27
|
-
foundLegacyFiles.push("package.json (eslintConfig field)");
|
|
28
|
-
}
|
|
29
|
-
if (packageJson.eslint) {
|
|
30
|
-
foundLegacyFiles.push("package.json (eslint field)");
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return foundLegacyFiles;
|
|
36
|
-
}
|
|
37
|
-
function showLegacyEslintDeprecationWarning(legacyFiles) {
|
|
38
|
-
console.warn("");
|
|
39
|
-
console.warn("\u26A0\uFE0F DEPRECATION WARNING: Legacy ESLint Configuration Detected");
|
|
40
|
-
console.warn("");
|
|
41
|
-
console.warn(" The following legacy ESLint configuration files were found:");
|
|
42
|
-
legacyFiles.forEach((file) => {
|
|
43
|
-
console.warn(` - ${file}`);
|
|
44
|
-
});
|
|
45
|
-
console.warn("");
|
|
46
|
-
console.warn(
|
|
47
|
-
" Cedar has migrated to ESLint flat config format. Legacy configurations"
|
|
48
|
-
);
|
|
49
|
-
console.warn(
|
|
50
|
-
" still work but are deprecated and will be removed in a future version."
|
|
51
|
-
);
|
|
52
|
-
console.warn("");
|
|
53
|
-
console.warn(" To migrate to the new format:");
|
|
54
|
-
console.warn(" 1. Remove the legacy config file(s) listed above");
|
|
55
|
-
console.warn(" 2. Create an eslint.config.mjs");
|
|
56
|
-
console.warn(" 3. Use the flat config format with @cedarjs/eslint-config");
|
|
57
|
-
console.warn("");
|
|
58
|
-
console.warn(" See more here: https://github.com/cedarjs/cedar/pull/629");
|
|
59
|
-
console.warn("");
|
|
60
|
-
}
|
|
3
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
61
6
|
const command = "lint [paths..]";
|
|
62
7
|
const description = "Lint your files";
|
|
63
8
|
const builder = (yargs) => {
|
|
64
9
|
yargs.positional("paths", {
|
|
65
10
|
description: "Specify file(s) or directory(ies) to lint relative to project root",
|
|
66
|
-
type: "
|
|
11
|
+
type: "string",
|
|
12
|
+
array: true
|
|
67
13
|
}).option("fix", {
|
|
68
14
|
default: false,
|
|
69
15
|
description: "Try to fix errors",
|
|
@@ -79,18 +25,22 @@ const builder = (yargs) => {
|
|
|
79
25
|
)}`
|
|
80
26
|
);
|
|
81
27
|
};
|
|
82
|
-
const handler = async ({
|
|
28
|
+
const handler = async ({
|
|
29
|
+
paths = [],
|
|
30
|
+
fix = false,
|
|
31
|
+
format = "stylish"
|
|
32
|
+
}) => {
|
|
83
33
|
recordTelemetryAttributes({ command: "lint", fix, format });
|
|
84
|
-
const config = getConfig();
|
|
85
|
-
const legacyConfigFiles = detectLegacyEslintConfig();
|
|
86
|
-
if (legacyConfigFiles.length > 0 && config.eslintLegacyConfigWarning) {
|
|
87
|
-
showLegacyEslintDeprecationWarning(legacyConfigFiles);
|
|
88
|
-
}
|
|
89
34
|
try {
|
|
90
35
|
const sbPath = getPaths().web.storybook;
|
|
91
|
-
const
|
|
36
|
+
const eslintArgs = [
|
|
37
|
+
fix && "--fix",
|
|
38
|
+
"--format",
|
|
39
|
+
format,
|
|
40
|
+
...paths
|
|
41
|
+
];
|
|
92
42
|
if (paths.length === 0) {
|
|
93
|
-
|
|
43
|
+
eslintArgs.push(
|
|
94
44
|
fs.existsSync(getPaths().web.src) && "web/src",
|
|
95
45
|
fs.existsSync(getPaths().web.config) && "web/config",
|
|
96
46
|
fs.existsSync(sbPath) && "web/.storybook",
|
|
@@ -98,13 +48,20 @@ const handler = async ({ paths, fix, format }) => {
|
|
|
98
48
|
fs.existsSync(getPaths().api.src) && "api/src"
|
|
99
49
|
);
|
|
100
50
|
}
|
|
101
|
-
const
|
|
51
|
+
const filteredEslintArgs = eslintArgs.filter(
|
|
52
|
+
(arg) => Boolean(arg)
|
|
53
|
+
);
|
|
54
|
+
const result = await runBin("eslint", filteredEslintArgs, {
|
|
102
55
|
cwd: getPaths().base,
|
|
103
56
|
stdio: "inherit"
|
|
104
57
|
});
|
|
105
58
|
process.exitCode = result.exitCode;
|
|
106
59
|
} catch (error) {
|
|
107
|
-
|
|
60
|
+
if (error && typeof error === "object" && "exitCode" in error) {
|
|
61
|
+
process.exitCode = typeof error.exitCode === "number" ? error.exitCode : 1;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
process.exitCode = 1;
|
|
108
65
|
}
|
|
109
66
|
};
|
|
110
67
|
export {
|
|
@@ -1,20 +1,42 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
7
|
+
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
6
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
|
-
import c from "../lib/colors.js";
|
|
8
9
|
import { runScriptFunction } from "../lib/exec.js";
|
|
9
10
|
import { configureBabel } from "../lib/execBabel.js";
|
|
10
11
|
class PathParamError extends Error {
|
|
11
12
|
}
|
|
13
|
+
const hasPath = (route) => {
|
|
14
|
+
return typeof route.path === "string" && route.path.length > 0;
|
|
15
|
+
};
|
|
16
|
+
const normalizeRoute = (route) => {
|
|
17
|
+
const normalizedPath = route.path;
|
|
18
|
+
const normalizedName = typeof route.name === "string" ? route.name : normalizedPath;
|
|
19
|
+
const normalizedRoutePath = typeof route.routePath === "string" ? route.routePath : normalizedPath;
|
|
20
|
+
const normalizedFilePath = typeof route.filePath === "string" ? route.filePath : "";
|
|
21
|
+
return {
|
|
22
|
+
...route,
|
|
23
|
+
name: normalizedName,
|
|
24
|
+
path: normalizedPath,
|
|
25
|
+
routePath: normalizedRoutePath,
|
|
26
|
+
filePath: normalizedFilePath
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const getErrorMessage = (error) => {
|
|
30
|
+
return error instanceof Error ? error.message : String(error);
|
|
31
|
+
};
|
|
32
|
+
const getErrorStack = (error) => {
|
|
33
|
+
return error instanceof Error ? error.stack ?? error.message : String(error);
|
|
34
|
+
};
|
|
12
35
|
const mapRouterPathToHtml = (routerPath) => {
|
|
13
36
|
if (routerPath === "/") {
|
|
14
37
|
return "web/dist/index.html";
|
|
15
|
-
} else {
|
|
16
|
-
return `web/dist${routerPath}.html`;
|
|
17
38
|
}
|
|
39
|
+
return `web/dist${routerPath}.html`;
|
|
18
40
|
};
|
|
19
41
|
function getRouteHooksFilePath(routeFilePath) {
|
|
20
42
|
const routeHooksFilePathTs = routeFilePath.replace(
|
|
@@ -49,28 +71,32 @@ async function expandRouteParameters(route) {
|
|
|
49
71
|
filePath: route.filePath
|
|
50
72
|
}
|
|
51
73
|
});
|
|
52
|
-
if (routeParameters) {
|
|
74
|
+
if (Array.isArray(routeParameters)) {
|
|
53
75
|
return routeParameters.map((pathParamValues) => {
|
|
54
76
|
let newPath = route.path;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
77
|
+
if (typeof pathParamValues === "object" && pathParamValues !== null && !Array.isArray(pathParamValues)) {
|
|
78
|
+
Object.entries(pathParamValues).forEach(
|
|
79
|
+
([paramName, paramValue]) => {
|
|
80
|
+
newPath = newPath.replace(
|
|
81
|
+
new RegExp(`{${paramName}:?[^}]*}`),
|
|
82
|
+
String(paramValue)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
59
85
|
);
|
|
60
|
-
}
|
|
86
|
+
}
|
|
61
87
|
return { ...route, path: newPath };
|
|
62
88
|
});
|
|
63
89
|
}
|
|
64
|
-
} catch (
|
|
65
|
-
console.error(c.error(
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(c.error(getErrorStack(error)));
|
|
66
92
|
return [route];
|
|
67
93
|
}
|
|
68
94
|
return [route];
|
|
69
95
|
}
|
|
70
96
|
const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
71
|
-
const detector =
|
|
72
|
-
const
|
|
73
|
-
const
|
|
97
|
+
const detector = await import("@cedarjs/prerender/detection");
|
|
98
|
+
const detectedRoutes = detector.detectPrerenderRoutes();
|
|
99
|
+
const prerenderRoutes = detectedRoutes.filter(hasPath).map(normalizeRoute);
|
|
74
100
|
if (prerenderRoutes.length === 0) {
|
|
75
101
|
console.log("\nSkipping prerender...");
|
|
76
102
|
console.log(
|
|
@@ -80,9 +106,10 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
80
106
|
);
|
|
81
107
|
return [];
|
|
82
108
|
}
|
|
109
|
+
const indexHtmlPath = path.join(getPaths().web.dist, "index.html");
|
|
83
110
|
if (!fs.existsSync(indexHtmlPath)) {
|
|
84
111
|
console.error(
|
|
85
|
-
|
|
112
|
+
`You must run \`${formatCedarCommand(["build", "web"])}\` before trying to prerender.`
|
|
86
113
|
);
|
|
87
114
|
process.exit(1);
|
|
88
115
|
}
|
|
@@ -90,7 +117,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
90
117
|
const expandedRouteParameters = await Promise.all(
|
|
91
118
|
prerenderRoutes.map((route) => expandRouteParameters(route))
|
|
92
119
|
);
|
|
93
|
-
const prerenderer =
|
|
120
|
+
const prerenderer = await import("@cedarjs/prerender");
|
|
94
121
|
const listrTasks = expandedRouteParameters.flatMap((routesToPrerender) => {
|
|
95
122
|
const queryCache = {};
|
|
96
123
|
const shouldFold = routesToPrerender.length > 16;
|
|
@@ -125,24 +152,28 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
125
152
|
}
|
|
126
153
|
];
|
|
127
154
|
}
|
|
128
|
-
return routesToPrerender.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const outputHtmlPath = mapRouterPathToHtml(routeToPrerender.path);
|
|
133
|
-
return {
|
|
134
|
-
title: `Prerendering ${routeToPrerender.path} -> ${outputHtmlPath}`,
|
|
135
|
-
task: async () => {
|
|
136
|
-
await prerenderRoute(
|
|
137
|
-
prerenderer,
|
|
138
|
-
queryCache,
|
|
139
|
-
routeToPrerender,
|
|
140
|
-
dryrun,
|
|
141
|
-
outputHtmlPath
|
|
142
|
-
);
|
|
155
|
+
return routesToPrerender.flatMap(
|
|
156
|
+
(routeToPrerender) => {
|
|
157
|
+
if (routerPathFilter && routeToPrerender.path !== routerPathFilter) {
|
|
158
|
+
return [];
|
|
143
159
|
}
|
|
144
|
-
|
|
145
|
-
|
|
160
|
+
const outputHtmlPath = mapRouterPathToHtml(routeToPrerender.path);
|
|
161
|
+
return [
|
|
162
|
+
{
|
|
163
|
+
title: `Prerendering ${routeToPrerender.path} -> ${outputHtmlPath}`,
|
|
164
|
+
task: async () => {
|
|
165
|
+
await prerenderRoute(
|
|
166
|
+
prerenderer,
|
|
167
|
+
queryCache,
|
|
168
|
+
routeToPrerender,
|
|
169
|
+
dryrun,
|
|
170
|
+
outputHtmlPath
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
);
|
|
146
177
|
});
|
|
147
178
|
return listrTasks;
|
|
148
179
|
};
|
|
@@ -160,12 +191,6 @@ const diagnosticCheck = () => {
|
|
|
160
191
|
path.join(getPaths().web.base, "node_modules/react-dom")
|
|
161
192
|
)
|
|
162
193
|
},
|
|
163
|
-
{
|
|
164
|
-
message: "Duplicate core-js version found in web/node_modules",
|
|
165
|
-
failure: fs.existsSync(
|
|
166
|
-
path.join(getPaths().web.base, "node_modules/core-js")
|
|
167
|
-
)
|
|
168
|
-
},
|
|
169
194
|
{
|
|
170
195
|
message: "Duplicate @cedarjs/web version found in web/node_modules",
|
|
171
196
|
failure: fs.existsSync(
|
|
@@ -174,7 +199,7 @@ const diagnosticCheck = () => {
|
|
|
174
199
|
}
|
|
175
200
|
];
|
|
176
201
|
console.log("Running diagnostic checks");
|
|
177
|
-
if (checks.some((
|
|
202
|
+
if (checks.some((check) => check.failure)) {
|
|
178
203
|
console.error(c.error("node_modules are being duplicated in `./web` \n"));
|
|
179
204
|
console.log("\u26A0\uFE0F Issues found: ");
|
|
180
205
|
console.log("-".repeat(50));
|
|
@@ -196,8 +221,11 @@ const diagnosticCheck = () => {
|
|
|
196
221
|
console.log("\u2714 Diagnostics checks passed \n");
|
|
197
222
|
}
|
|
198
223
|
};
|
|
224
|
+
const hasUnexpandedPathParams = (routePath) => {
|
|
225
|
+
return /\{.*}/.test(routePath);
|
|
226
|
+
};
|
|
199
227
|
const prerenderRoute = async (prerenderer, queryCache, routeToPrerender, dryrun, outputHtmlPath) => {
|
|
200
|
-
if (
|
|
228
|
+
if (hasUnexpandedPathParams(routeToPrerender.path)) {
|
|
201
229
|
throw new PathParamError(
|
|
202
230
|
`Could not retrieve route parameters for ${routeToPrerender.path}`
|
|
203
231
|
);
|
|
@@ -207,25 +235,33 @@ const prerenderRoute = async (prerenderer, queryCache, routeToPrerender, dryrun,
|
|
|
207
235
|
queryCache,
|
|
208
236
|
renderPath: routeToPrerender.path
|
|
209
237
|
});
|
|
210
|
-
if (!dryrun) {
|
|
238
|
+
if (!dryrun && typeof prerenderedHtml === "string") {
|
|
211
239
|
prerenderer.writePrerenderedHtmlFile(outputHtmlPath, prerenderedHtml);
|
|
212
240
|
}
|
|
213
|
-
} catch (
|
|
241
|
+
} catch (error) {
|
|
214
242
|
console.log();
|
|
215
243
|
console.log(
|
|
216
|
-
c.warning(
|
|
244
|
+
c.warning(
|
|
245
|
+
"You can use `" + formatCedarCommand(["prerender", "--dry-run"]) + "` to debug"
|
|
246
|
+
)
|
|
217
247
|
);
|
|
218
248
|
console.log();
|
|
219
|
-
|
|
220
|
-
|
|
249
|
+
const sep = c.info("-".repeat(10));
|
|
250
|
+
console.log(`${sep} Error rendering path "${routeToPrerender.path}" ${sep}`);
|
|
251
|
+
errorTelemetry(
|
|
252
|
+
process.argv,
|
|
253
|
+
`Error prerendering: ${getErrorMessage(error)}`
|
|
221
254
|
);
|
|
222
|
-
|
|
223
|
-
console.error(c.error(e.stack));
|
|
255
|
+
console.error(c.error(getErrorStack(error)));
|
|
224
256
|
console.log();
|
|
225
257
|
throw new Error(`Failed to render "${routeToPrerender.filePath}"`);
|
|
226
258
|
}
|
|
227
259
|
};
|
|
228
|
-
const handler = async ({
|
|
260
|
+
const handler = async ({
|
|
261
|
+
path: routerPath,
|
|
262
|
+
dryRun = false,
|
|
263
|
+
verbose = false
|
|
264
|
+
}) => {
|
|
229
265
|
if (getConfig().experimental?.streamingSsr?.enabled) {
|
|
230
266
|
console.log(
|
|
231
267
|
c.warning(
|
|
@@ -239,7 +275,7 @@ const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
|
239
275
|
dryRun,
|
|
240
276
|
verbose
|
|
241
277
|
});
|
|
242
|
-
const listrTasks = await getTasks(dryRun, routerPath);
|
|
278
|
+
const listrTasks = await getTasks(dryRun, routerPath ?? null);
|
|
243
279
|
const tasks = new Listr(listrTasks, {
|
|
244
280
|
renderer: verbose ? "verbose" : "default",
|
|
245
281
|
rendererOptions: { collapseSubtasks: false },
|
|
@@ -250,11 +286,11 @@ const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
|
250
286
|
console.log(c.info("::: Dry run, not writing changes :::"));
|
|
251
287
|
}
|
|
252
288
|
await tasks.run();
|
|
253
|
-
} catch (
|
|
289
|
+
} catch (error) {
|
|
254
290
|
console.log();
|
|
255
|
-
|
|
291
|
+
diagnosticCheck();
|
|
256
292
|
console.log(c.warning("Tips:"));
|
|
257
|
-
if (
|
|
293
|
+
if (error instanceof PathParamError) {
|
|
258
294
|
console.log(
|
|
259
295
|
c.info(
|
|
260
296
|
"- You most likely need to add or update a *.routeHooks.{js,ts} file next to the Page you're trying to prerender"
|
|
@@ -263,7 +299,7 @@ const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
|
263
299
|
} else {
|
|
264
300
|
console.log(
|
|
265
301
|
c.info(
|
|
266
|
-
|
|
302
|
+
"- This could mean that a library you're using does not support SSR."
|
|
267
303
|
)
|
|
268
304
|
);
|
|
269
305
|
console.log(
|
|
@@ -283,5 +319,6 @@ const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
|
283
319
|
};
|
|
284
320
|
export {
|
|
285
321
|
getTasks,
|
|
286
|
-
handler
|
|
322
|
+
handler,
|
|
323
|
+
hasUnexpandedPathParams
|
|
287
324
|
};
|
|
@@ -1,66 +1,91 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import path from "path";
|
|
3
2
|
import boxen from "boxen";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
4
|
+
import {
|
|
5
|
+
formatCedarCommand,
|
|
6
|
+
formatRunBinCommand,
|
|
7
|
+
formatRunTransitiveBinCommand
|
|
8
|
+
} from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
|
+
import { runTransitiveBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
10
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
11
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
|
-
import c from "../lib/colors.js";
|
|
8
12
|
import { getPaths } from "../lib/index.js";
|
|
9
|
-
const
|
|
13
|
+
const getErrorMessage = (error) => {
|
|
14
|
+
return error instanceof Error ? error.message : String(error);
|
|
15
|
+
};
|
|
16
|
+
function getExitCode(value) {
|
|
17
|
+
if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
return value.exitCode;
|
|
21
|
+
}
|
|
22
|
+
const handler = async ({
|
|
23
|
+
_: _positionals,
|
|
24
|
+
$0: _binName,
|
|
25
|
+
commands = [],
|
|
26
|
+
...options
|
|
27
|
+
}) => {
|
|
10
28
|
recordTelemetryAttributes({
|
|
11
29
|
command: "prisma"
|
|
12
30
|
});
|
|
13
|
-
const
|
|
14
|
-
const
|
|
31
|
+
const cedarPaths = getPaths();
|
|
32
|
+
const args = [...Array.isArray(commands) ? commands : []].filter(
|
|
33
|
+
(value) => typeof value === "string"
|
|
34
|
+
);
|
|
35
|
+
const helpIndex = args.indexOf("help");
|
|
15
36
|
if (helpIndex !== -1) {
|
|
16
37
|
options.help = true;
|
|
17
|
-
|
|
38
|
+
args.splice(helpIndex, 1);
|
|
18
39
|
}
|
|
19
40
|
const hasHelpOption = options.help || options.h;
|
|
20
41
|
if (!hasHelpOption) {
|
|
21
|
-
if (!fs.existsSync(
|
|
42
|
+
if (!fs.existsSync(cedarPaths.api.prismaConfig)) {
|
|
22
43
|
console.error();
|
|
23
44
|
console.error(c.error("No Prisma config file found."));
|
|
24
|
-
console.error(`Cedar searched here '${
|
|
45
|
+
console.error(`Cedar searched here '${cedarPaths.api.prismaConfig}'`);
|
|
25
46
|
console.error();
|
|
26
47
|
process.exit(1);
|
|
27
48
|
}
|
|
28
|
-
options.config = `${
|
|
49
|
+
options.config = `${cedarPaths.api.prismaConfig}`;
|
|
29
50
|
}
|
|
30
|
-
const args = commands;
|
|
31
51
|
for (const [name, value] of Object.entries(options)) {
|
|
32
52
|
args.push(name.length > 1 ? `--${name}` : `-${name}`);
|
|
33
53
|
if (typeof value === "string") {
|
|
34
|
-
value.split(" ").length > 1 ? args.push(`"${value}"`) : args.push(value);
|
|
35
|
-
} else if (typeof value === "number") {
|
|
36
54
|
args.push(value);
|
|
55
|
+
} else if (typeof value === "number") {
|
|
56
|
+
args.push(String(value));
|
|
37
57
|
}
|
|
38
58
|
}
|
|
39
59
|
console.log();
|
|
40
60
|
console.log(c.note("Running Prisma CLI..."));
|
|
41
|
-
console.log(c.underline("
|
|
61
|
+
console.log(c.underline(`$ ${formatRunTransitiveBinCommand("prisma", args)}`));
|
|
42
62
|
console.log();
|
|
43
63
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
runTransitiveBinSync("prisma", args, {
|
|
65
|
+
cwd: cedarPaths.base,
|
|
66
|
+
stdio: [
|
|
67
|
+
process.stdin.isTTY && !process.env.CI ? "inherit" : "pipe",
|
|
68
|
+
"inherit",
|
|
69
|
+
"inherit"
|
|
70
|
+
]
|
|
49
71
|
});
|
|
50
|
-
if (hasHelpOption ||
|
|
72
|
+
if (hasHelpOption || args.length === 0) {
|
|
51
73
|
printWrapInfo();
|
|
52
74
|
}
|
|
53
|
-
} catch (
|
|
54
|
-
errorTelemetry(
|
|
55
|
-
|
|
75
|
+
} catch (error) {
|
|
76
|
+
errorTelemetry(
|
|
77
|
+
process.argv,
|
|
78
|
+
`Error generating prisma client: ${getErrorMessage(error)}`
|
|
79
|
+
);
|
|
80
|
+
process.exit(getExitCode(error) ?? 1);
|
|
56
81
|
}
|
|
57
82
|
};
|
|
58
83
|
const printWrapInfo = () => {
|
|
59
84
|
const message = [
|
|
60
85
|
c.bold("Cedar CLI wraps Prisma CLI"),
|
|
61
86
|
"",
|
|
62
|
-
|
|
63
|
-
|
|
87
|
+
`Use \`${formatCedarCommand(["prisma"])}\` to automatically pass \`--config\` and \`--preview-feature\` options.`,
|
|
88
|
+
`Use \`${formatRunBinCommand("prisma")}\` to skip Cedar's automatic CLI options.`,
|
|
64
89
|
"",
|
|
65
90
|
"Find more information in our docs:",
|
|
66
91
|
c.underline("https://cedarjs.com/docs/cli-commands#prisma")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
-
const handler = async () => {
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
|
+
const handler = async (_argv) => {
|
|
3
3
|
recordTelemetryAttributes({
|
|
4
4
|
command: "record"
|
|
5
5
|
});
|
package/dist/commands/record.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { terminalLink } from "termi-link";
|
|
1
2
|
const command = "record <command>";
|
|
2
3
|
const description = "Setup RedwoodRecord for your project. Caches a JSON version of your data model and adds api/src/models/index.js with some config.";
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
const builder = (yargs) => yargs.command(command, description, () => {
|
|
5
|
+
}, handler).demandCommand().epilogue(
|
|
5
6
|
`Also see the ${terminalLink(
|
|
6
7
|
"RedwoodRecord Docs",
|
|
7
8
|
"https://cedarjs.com/docs/redwoodrecord"
|
|
@@ -10,7 +11,7 @@ const builder = (yargs) => yargs.command({ command, description, handler }).dema
|
|
|
10
11
|
);
|
|
11
12
|
async function handler(argv) {
|
|
12
13
|
const recordInit = await import("./record/init.js");
|
|
13
|
-
recordInit(argv);
|
|
14
|
+
return recordInit.handler(argv);
|
|
14
15
|
}
|
|
15
16
|
export {
|
|
16
17
|
builder,
|