@cedarjs/cli 4.2.0 → 4.2.1-next.258
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cfw.js +8 -6
- package/dist/commands/build/buildHandler.js +43 -42
- package/dist/commands/build/buildPackagesTask.js +6 -6
- package/dist/commands/build.js +7 -1
- package/dist/commands/deploy/baremetal/SshExecutor.js +13 -4
- package/dist/commands/deploy/baremetal/baremetalHandler.js +117 -65
- package/dist/commands/deploy/baremetal.js +24 -3
- package/dist/commands/deploy/flightcontrolHandler.js +16 -14
- package/dist/commands/deploy/helpers/deployHandler.js +10 -5
- package/dist/commands/deploy/packing/nft.js +1 -2
- package/dist/commands/deploy/render.js +1 -1
- package/dist/commands/deploy/renderHandler.js +22 -12
- package/dist/commands/deploy/serverlessHandler.js +67 -25
- 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 +16 -16
- package/dist/commands/destroy/helpers.js +8 -2
- package/dist/commands/destroy/layout/layout.js +1 -2
- package/dist/commands/destroy/page/pageHandler.js +1 -1
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +28 -9
- package/dist/commands/destroy/sdl/sdlHandler.js +1 -1
- package/dist/commands/dev/devHandler.js +25 -25
- package/dist/commands/dev.js +3 -0
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +110 -4
- package/dist/commands/experimental/setupInngest.js +1 -1
- package/dist/commands/experimental/setupInngestHandler.js +12 -11
- package/dist/commands/experimental/setupOpentelemetry.js +1 -1
- package/dist/commands/experimental/setupOpentelemetryHandler.js +11 -7
- package/dist/commands/experimental/setupReactCompiler.js +1 -1
- package/dist/commands/experimental/setupReactCompilerHandler.js +45 -30
- package/dist/commands/experimental/setupRscHandler.js +14 -11
- package/dist/commands/experimental/setupStreamingSsr.js +1 -1
- package/dist/commands/experimental/setupStreamingSsrHandler.js +46 -31
- 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/util.js +3 -2
- package/dist/commands/generate/cell/cellHandler.js +22 -21
- package/dist/commands/generate/component/componentHandler.js +14 -16
- package/dist/commands/generate/dataMigration/dataMigration.js +24 -13
- package/dist/commands/generate/dbAuth/dbAuth.js +1 -0
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +40 -30
- package/dist/commands/generate/directive/directiveHandler.js +12 -14
- package/dist/commands/generate/function/function.js +1 -0
- package/dist/commands/generate/function/functionHandler.js +12 -17
- package/dist/commands/generate/helpers.js +17 -17
- package/dist/commands/generate/job/job.js +1 -0
- package/dist/commands/generate/job/jobHandler.js +15 -17
- 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 +9 -3
- package/dist/commands/generate/ogImage/ogImage.js +1 -0
- package/dist/commands/generate/ogImage/ogImageHandler.js +16 -9
- package/dist/commands/generate/package/packageHandler.js +32 -49
- package/dist/commands/generate/page/pageHandler.js +25 -22
- package/dist/commands/generate/realtime/realtime.js +1 -1
- package/dist/commands/generate/realtime/realtimeHandler.js +46 -20
- package/dist/commands/generate/scaffold/scaffold.js +1 -0
- package/dist/commands/generate/scaffold/scaffoldHandler.js +35 -27
- package/dist/commands/generate/script/script.js +1 -0
- package/dist/commands/generate/script/templates/tsconfig.json.template +14 -0
- package/dist/commands/generate/sdl/sdl.js +4 -3
- package/dist/commands/generate/sdl/sdlHandler.js +38 -18
- package/dist/commands/generate/secret/secret.js +19 -19
- package/dist/commands/generate/service/service.js +5 -5
- package/dist/commands/generate/service/serviceHandler.js +59 -22
- package/dist/commands/generate/yargsCommandHelpers.js +6 -1
- package/dist/commands/generate/yargsHandlerHelpers.js +18 -10
- package/dist/commands/generate.js +3 -10
- package/dist/commands/jobsHandler.js +3 -2
- package/dist/commands/prismaHandler.js +10 -9
- package/dist/commands/serve.js +84 -137
- package/dist/commands/serveApiHandler.js +5 -5
- package/dist/commands/serveBothHandler.js +10 -7
- package/dist/commands/serveWebHandler.js +2 -2
- package/dist/commands/setup/auth/auth.js +12 -6
- package/dist/commands/setup/cache/cacheHandler.js +11 -6
- 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 +157 -5
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +26 -4
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +53 -25
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +33 -23
- package/dist/commands/setup/deploy/providers/netlify.js +6 -0
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +112 -11
- package/dist/commands/setup/deploy/providers/renderHandler.js +10 -5
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +5 -3
- package/dist/commands/setup/deploy/providers/universal-deploy.js +11 -0
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +188 -0
- package/dist/commands/setup/deploy/providers/vercel.js +6 -0
- package/dist/commands/setup/deploy/providers/vercelHandler.js +113 -12
- 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/docker/docker.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +72 -37
- 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} +1 -1
- package/dist/commands/setup/docker/templates/docker-compose.dev.yml +2 -2
- package/dist/commands/setup/generator/generatorHandler.js +4 -3
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +2 -2
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +2 -2
- package/dist/commands/setup/i18n/i18nHandler.js +18 -15
- package/dist/commands/setup/jobs/jobsHandler.js +10 -5
- package/dist/commands/setup/mailer/mailerHandler.js +11 -9
- package/dist/commands/setup/package/packageHandler.js +14 -10
- package/dist/commands/setup/realtime/realtimeHandler.js +22 -20
- package/dist/commands/setup/server-file/serverFileHandler.js +16 -8
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +5 -3
- package/dist/commands/setup/ui/helpers/helpers.js +5 -1
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +11 -5
- package/dist/commands/setup/ui/libraries/mantineHandler.js +21 -13
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +38 -26
- package/dist/commands/setup/uploads/uploadsHandler.js +7 -4
- package/dist/commands/setup.js +1 -2
- package/dist/commands/test/testHandler.js +2 -1
- package/dist/commands/test/testHandlerEsm.js +2 -2
- package/dist/commands/type-checkHandler.js +4 -6
- package/dist/commands/upgrade/upgradeHandler.js +2 -4
- package/dist/index.js +10 -4
- package/dist/lib/configureStorybook.js +2 -2
- package/dist/lib/exec.js +36 -24
- package/dist/lib/exit.js +19 -4
- package/dist/lib/extendFile.js +22 -12
- package/dist/lib/index.js +119 -85
- package/dist/lib/merge/algorithms.js +4 -1
- package/dist/lib/merge/index.js +76 -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 +12 -5
- package/dist/lib/pluralHelpers.js +1 -1
- package/dist/lib/project.js +3 -1
- package/dist/lib/rollback.js +7 -7
- package/dist/lib/schemaHelpers.js +12 -12
- package/dist/lib/test.js +4 -0
- package/dist/lib/updateCheck.js +6 -4
- package/dist/middleware/checkNodeVersion.js +5 -0
- 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 -5
- package/dist/telemetry/send.js +14 -10
- package/package.json +15 -12
- 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 -82
- /package/dist/{index.d.js → global.d.js} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
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
5
|
import { getPrettierOptions, setTomlSetting } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
7
|
import { getConfig, getPaths, resolveFile } from "@cedarjs/project-config";
|
|
8
8
|
import { runTransform } from "../../../../../lib/runTransform.js";
|
|
9
9
|
async function handler({ force }) {
|
|
@@ -28,7 +28,7 @@ async function handler({ force }) {
|
|
|
28
28
|
{
|
|
29
29
|
title: "Generating Trusted Documents store ...",
|
|
30
30
|
task: () => {
|
|
31
|
-
|
|
31
|
+
runBinSync("cedar", ["generate", "types"], { stdio: "ignore" });
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
{
|
|
@@ -1,22 +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";
|
|
5
4
|
import { terminalLink } from "termi-link";
|
|
6
5
|
import { colors as c } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
7
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
8
|
import extendStorybookConfiguration from "../../../lib/configureStorybook.js";
|
|
9
9
|
import { fileIncludes } from "../../../lib/extendFile.js";
|
|
10
10
|
import { getPaths, writeFile } from "../../../lib/index.js";
|
|
11
11
|
const APP_JS_PATH = getPaths().web.app;
|
|
12
12
|
const i18nImportExist = (appJS) => {
|
|
13
|
-
|
|
13
|
+
const content = appJS.toString();
|
|
14
14
|
const hasBaseImport = () => /import '.\/i18n'/.test(content);
|
|
15
15
|
return hasBaseImport();
|
|
16
16
|
};
|
|
17
17
|
const addI18nImport = (appJS) => {
|
|
18
|
-
|
|
19
|
-
const index = content.findIndex((value) =>
|
|
18
|
+
const content = appJS.toString().split("\n").reverse();
|
|
19
|
+
const index = content.findIndex((value) => value.includes("import"));
|
|
20
20
|
content.splice(index, 0, "import './i18n'");
|
|
21
21
|
return content.reverse().join(`
|
|
22
22
|
`);
|
|
@@ -39,14 +39,15 @@ const handler = async ({ force }) => {
|
|
|
39
39
|
{
|
|
40
40
|
title: "Install i18next, react-i18next and i18next-browser-languagedetector",
|
|
41
41
|
task: async () => {
|
|
42
|
-
await
|
|
43
|
-
"workspace",
|
|
42
|
+
await addWorkspacePackages(
|
|
44
43
|
"web",
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
[
|
|
45
|
+
"i18next",
|
|
46
|
+
"react-i18next",
|
|
47
|
+
"i18next-browser-languagedetector"
|
|
48
|
+
],
|
|
49
|
+
{ cwd: rwPaths.base }
|
|
50
|
+
);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
],
|
|
@@ -123,7 +124,7 @@ const handler = async ({ force }) => {
|
|
|
123
124
|
{
|
|
124
125
|
title: "Adding import to App.{jsx,tsx}...",
|
|
125
126
|
task: (_ctx, task) => {
|
|
126
|
-
|
|
127
|
+
const appJS = fs.readFileSync(APP_JS_PATH);
|
|
127
128
|
if (i18nImportExist(appJS)) {
|
|
128
129
|
task.skip("Import already exists in App.js");
|
|
129
130
|
} else {
|
|
@@ -160,9 +161,11 @@ const handler = async ({ force }) => {
|
|
|
160
161
|
try {
|
|
161
162
|
await tasks.run();
|
|
162
163
|
} catch (e) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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);
|
|
166
169
|
}
|
|
167
170
|
};
|
|
168
171
|
export {
|
|
@@ -4,6 +4,7 @@ import prismaInternals from "@prisma/internals";
|
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
5
|
import { terminalLink } from "termi-link";
|
|
6
6
|
import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
|
|
7
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
7
8
|
import { getSchemaPath, getPrismaSchemas } from "@cedarjs/project-config";
|
|
8
9
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
9
10
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
@@ -53,6 +54,7 @@ const tasks = async ({ force }) => {
|
|
|
53
54
|
if (modelExists) {
|
|
54
55
|
return "BackgroundJob model exists, skipping";
|
|
55
56
|
}
|
|
57
|
+
return false;
|
|
56
58
|
}
|
|
57
59
|
},
|
|
58
60
|
{
|
|
@@ -97,10 +99,13 @@ const tasks = async ({ force }) => {
|
|
|
97
99
|
${c.success("\nBackground jobs configured!\n")}
|
|
98
100
|
|
|
99
101
|
${!modelExists ? "Migrate your database to finish setting up jobs:\n" : ""}
|
|
100
|
-
${!modelExists ? c.highlight(
|
|
102
|
+
${!modelExists ? c.highlight(`
|
|
103
|
+
\xA0\xA0${formatCedarCommand(["prisma", "migrate", "dev"])}
|
|
104
|
+
`) : ""}
|
|
101
105
|
|
|
102
|
-
Generate jobs with: ${c.highlight("
|
|
103
|
-
Execute jobs with: ${c.highlight("
|
|
106
|
+
Generate jobs with: ${c.highlight(formatCedarCommand(["g", "job", "<name>"]))}
|
|
107
|
+
Execute jobs with: ${c.highlight(`${formatCedarCommand(["jobs", "work"])}
|
|
108
|
+
`)}
|
|
104
109
|
|
|
105
110
|
Check out the docs for more info:
|
|
106
111
|
${terminalLink("", "https://cedarjs.com/docs/background-jobs")}
|
|
@@ -109,7 +114,7 @@ const tasks = async ({ force }) => {
|
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
],
|
|
112
|
-
{ rendererOptions: { collapseSubtasks: false },
|
|
117
|
+
{ rendererOptions: { collapseSubtasks: false }, exitOnError: true }
|
|
113
118
|
);
|
|
114
119
|
};
|
|
115
120
|
const handler = async ({ force }) => {
|
|
@@ -117,7 +122,7 @@ const handler = async ({ force }) => {
|
|
|
117
122
|
try {
|
|
118
123
|
await t.run();
|
|
119
124
|
} catch (e) {
|
|
120
|
-
console.error(c.error(e.message));
|
|
125
|
+
console.error(c.error(e instanceof Error ? e.message : String(e)));
|
|
121
126
|
}
|
|
122
127
|
};
|
|
123
128
|
export {
|
|
@@ -1,18 +1,18 @@
|
|
|
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
4
|
import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
|
|
6
5
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
6
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
8
7
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
9
|
-
const handler = async ({
|
|
8
|
+
const handler = async ({
|
|
9
|
+
force,
|
|
10
|
+
skipExamples
|
|
11
|
+
}) => {
|
|
10
12
|
const projectIsTypescript = isTypeScriptProject();
|
|
11
13
|
const pkgJsonPath = path.join(getPaths().base, "package.json");
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
const cedarVersion = pkgJson.devDependencies["@cedarjs/core"] ?? "latest";
|
|
14
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
15
|
+
const cedarVersion = pkgJson.devDependencies?.["@cedarjs/core"] ?? "latest";
|
|
16
16
|
const extension = projectIsTypescript ? "ts" : "js";
|
|
17
17
|
const tasks = new Listr(
|
|
18
18
|
[
|
|
@@ -99,9 +99,11 @@ const handler = async ({ force, skipExamples }) => {
|
|
|
99
99
|
try {
|
|
100
100
|
await tasks.run();
|
|
101
101
|
} catch (e) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
103
|
+
errorTelemetry(process.argv, message);
|
|
104
|
+
console.error(c.error(message));
|
|
105
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
106
|
+
process.exit(exitCode);
|
|
105
107
|
}
|
|
106
108
|
};
|
|
107
109
|
export {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import enq from "enquirer";
|
|
2
|
-
import execa from "execa";
|
|
3
2
|
import semver from "semver";
|
|
4
3
|
import { getCompatibilityData } from "@cedarjs/cli-helpers";
|
|
4
|
+
import { dlx } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
5
5
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
|
-
async function handler({
|
|
6
|
+
async function handler({
|
|
7
|
+
npmPackage,
|
|
8
|
+
force,
|
|
9
|
+
_: _args
|
|
10
|
+
}) {
|
|
7
11
|
const isScoped = npmPackage.startsWith("@");
|
|
8
12
|
const packageName = (isScoped ? "@" : "") + npmPackage.split("@")[isScoped ? 1 : 0];
|
|
9
13
|
const packageVersion = npmPackage.split("@")[isScoped ? 2 : 1] ?? "latest";
|
|
@@ -24,9 +28,9 @@ async function handler({ npmPackage, force, _: _args }) {
|
|
|
24
28
|
let compatibilityData;
|
|
25
29
|
try {
|
|
26
30
|
compatibilityData = await getCompatibilityData(packageName, packageVersion);
|
|
27
|
-
} catch (
|
|
31
|
+
} catch (e) {
|
|
28
32
|
console.log("The following error occurred while checking compatibility:");
|
|
29
|
-
const errorMessage =
|
|
33
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
30
34
|
console.log(errorMessage);
|
|
31
35
|
if (errorMessage.includes("does not have a tag") || errorMessage.includes("does not have a version")) {
|
|
32
36
|
process.exit(1);
|
|
@@ -106,12 +110,12 @@ async function runPackage(packageName, version, options = []) {
|
|
|
106
110
|
const versionString = version === void 0 ? "" : `@${version}`;
|
|
107
111
|
console.log(`Running ${packageName}${versionString}...`);
|
|
108
112
|
try {
|
|
109
|
-
await
|
|
113
|
+
await dlx(`${packageName}${versionString}`, options, {
|
|
110
114
|
stdio: "inherit",
|
|
111
115
|
cwd: getPaths().base
|
|
112
116
|
});
|
|
113
|
-
} catch (
|
|
114
|
-
process.exitCode =
|
|
117
|
+
} catch (e) {
|
|
118
|
+
process.exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
async function promptWithChoices(message, choices) {
|
|
@@ -122,9 +126,9 @@ async function promptWithChoices(message, choices) {
|
|
|
122
126
|
choices
|
|
123
127
|
});
|
|
124
128
|
return await prompt.run();
|
|
125
|
-
} catch (
|
|
126
|
-
if (
|
|
127
|
-
throw
|
|
129
|
+
} catch (e) {
|
|
130
|
+
if (e) {
|
|
131
|
+
throw e;
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
return null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import execa from "execa";
|
|
4
3
|
import { Listr } from "listr2";
|
|
5
4
|
import prompts from "prompts";
|
|
6
5
|
import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
|
|
6
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
7
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
8
8
|
import { projectIsEsm } from "@cedarjs/project-config";
|
|
9
9
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
@@ -30,13 +30,13 @@ async function handleExamplesPreference(includeExamples) {
|
|
|
30
30
|
});
|
|
31
31
|
incl = response.includeExamples;
|
|
32
32
|
}
|
|
33
|
-
return incl;
|
|
33
|
+
return incl ?? false;
|
|
34
34
|
}
|
|
35
35
|
async function handler(args) {
|
|
36
|
-
const
|
|
36
|
+
const cedarPaths = getPaths();
|
|
37
37
|
const ts = isTypeScriptProject();
|
|
38
38
|
const realtimeLibFilePath = path.join(
|
|
39
|
-
|
|
39
|
+
cedarPaths.api.lib,
|
|
40
40
|
`realtime.${isTypeScriptProject() ? "ts" : "js"}`
|
|
41
41
|
);
|
|
42
42
|
const force = args.force || false;
|
|
@@ -94,7 +94,7 @@ async function handler(args) {
|
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
const exampleFile = path.join(
|
|
97
|
-
|
|
97
|
+
cedarPaths.api.subscriptions,
|
|
98
98
|
"countdown",
|
|
99
99
|
`countdown.${isTypeScriptProject() ? "ts" : "js"}`
|
|
100
100
|
);
|
|
@@ -124,7 +124,7 @@ async function handler(args) {
|
|
|
124
124
|
"utf-8"
|
|
125
125
|
);
|
|
126
126
|
const sdlFile = path.join(
|
|
127
|
-
|
|
127
|
+
cedarPaths.api.graphql,
|
|
128
128
|
`rooms.sdl.${isTypeScriptProject() ? "ts" : "js"}`
|
|
129
129
|
);
|
|
130
130
|
const sdlContent = ts ? exampleSdlTemplateContent : await transformTSToJS(sdlFile, exampleSdlTemplateContent);
|
|
@@ -139,7 +139,7 @@ async function handler(args) {
|
|
|
139
139
|
"utf-8"
|
|
140
140
|
);
|
|
141
141
|
const serviceFile = path.join(
|
|
142
|
-
|
|
142
|
+
cedarPaths.api.services,
|
|
143
143
|
"rooms",
|
|
144
144
|
`rooms.${isTypeScriptProject() ? "ts" : "js"}`
|
|
145
145
|
);
|
|
@@ -161,7 +161,7 @@ async function handler(args) {
|
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
const exampleFile = path.join(
|
|
164
|
-
|
|
164
|
+
cedarPaths.api.subscriptions,
|
|
165
165
|
"newMessage",
|
|
166
166
|
`newMessage.${isTypeScriptProject() ? "ts" : "js"}`
|
|
167
167
|
);
|
|
@@ -197,7 +197,7 @@ async function handler(args) {
|
|
|
197
197
|
"utf-8"
|
|
198
198
|
);
|
|
199
199
|
const sdlFile = path.join(
|
|
200
|
-
|
|
200
|
+
cedarPaths.api.graphql,
|
|
201
201
|
`auctions.sdl.${isTypeScriptProject() ? "ts" : "js"}`
|
|
202
202
|
);
|
|
203
203
|
const sdlContent = ts ? exampleSdlTemplateContent : await transformTSToJS(sdlFile, exampleSdlTemplateContent);
|
|
@@ -212,7 +212,7 @@ async function handler(args) {
|
|
|
212
212
|
"utf-8"
|
|
213
213
|
);
|
|
214
214
|
const serviceFile = path.join(
|
|
215
|
-
|
|
215
|
+
cedarPaths.api.services,
|
|
216
216
|
"auctions",
|
|
217
217
|
`auctions.${isTypeScriptProject() ? "ts" : "js"}`
|
|
218
218
|
);
|
|
@@ -242,7 +242,7 @@ async function handler(args) {
|
|
|
242
242
|
"utf-8"
|
|
243
243
|
);
|
|
244
244
|
const sdlFile = path.join(
|
|
245
|
-
|
|
245
|
+
cedarPaths.api.graphql,
|
|
246
246
|
`fastAndSlowFields.sdl.${isTypeScriptProject() ? "ts" : "js"}`
|
|
247
247
|
);
|
|
248
248
|
const sdlContent = ts ? exampleSdlTemplateContent : await transformTSToJS(sdlFile, exampleSdlTemplateContent);
|
|
@@ -257,7 +257,7 @@ async function handler(args) {
|
|
|
257
257
|
"utf-8"
|
|
258
258
|
);
|
|
259
259
|
const serviceFile = path.join(
|
|
260
|
-
|
|
260
|
+
cedarPaths.api.services,
|
|
261
261
|
"fastAndSlowFields",
|
|
262
262
|
`fastAndSlowFields.${isTypeScriptProject() ? "ts" : "js"}`
|
|
263
263
|
);
|
|
@@ -287,7 +287,7 @@ async function handler(args) {
|
|
|
287
287
|
"utf-8"
|
|
288
288
|
);
|
|
289
289
|
const sdlFile = path.join(
|
|
290
|
-
|
|
290
|
+
cedarPaths.api.graphql,
|
|
291
291
|
`alphabet.sdl.${isTypeScriptProject() ? "ts" : "js"}`
|
|
292
292
|
);
|
|
293
293
|
const sdlContent = ts ? exampleSdlTemplateContent : await transformTSToJS(sdlFile, exampleSdlTemplateContent);
|
|
@@ -302,7 +302,7 @@ async function handler(args) {
|
|
|
302
302
|
"utf-8"
|
|
303
303
|
);
|
|
304
304
|
const serviceFile = path.join(
|
|
305
|
-
|
|
305
|
+
cedarPaths.api.services,
|
|
306
306
|
"alphabet",
|
|
307
307
|
`alphabet.${isTypeScriptProject() ? "ts" : "js"}`
|
|
308
308
|
);
|
|
@@ -333,9 +333,9 @@ async function handler(args) {
|
|
|
333
333
|
getPaths().api.functions,
|
|
334
334
|
`graphql.${isTypeScriptProject() ? "ts" : "js"}`
|
|
335
335
|
);
|
|
336
|
-
|
|
337
|
-
"
|
|
338
|
-
["
|
|
336
|
+
runBinSync(
|
|
337
|
+
"cedar",
|
|
338
|
+
["lint", "--fix", graphqlHandlerPath, realtimeLibFilePath],
|
|
339
339
|
{
|
|
340
340
|
cwd: getPaths().base,
|
|
341
341
|
// Silently ignore errors
|
|
@@ -372,9 +372,11 @@ async function handler(args) {
|
|
|
372
372
|
);
|
|
373
373
|
}
|
|
374
374
|
} catch (e) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
process.
|
|
375
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
376
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
377
|
+
errorTelemetry(process.argv, message);
|
|
378
|
+
console.error(c.error(message));
|
|
379
|
+
process.exit(exitCode);
|
|
378
380
|
}
|
|
379
381
|
}
|
|
380
382
|
export {
|
|
@@ -5,13 +5,16 @@ import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
|
|
|
5
5
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
6
6
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
7
7
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
8
|
-
const
|
|
8
|
+
const packageJson = JSON.parse(
|
|
9
9
|
fs.readFileSync(
|
|
10
10
|
path.resolve(import.meta.dirname, "../../../../package.json"),
|
|
11
11
|
"utf-8"
|
|
12
12
|
)
|
|
13
13
|
);
|
|
14
|
-
|
|
14
|
+
const { version } = packageJson;
|
|
15
|
+
function setupServerFileTasks({
|
|
16
|
+
force = false
|
|
17
|
+
} = {}) {
|
|
15
18
|
return [
|
|
16
19
|
{
|
|
17
20
|
title: "Adding the server file...",
|
|
@@ -36,17 +39,22 @@ function setupServerFileTasks({ force = false } = {}) {
|
|
|
36
39
|
addApiPackages([`@cedarjs/api-server@${version}`])
|
|
37
40
|
];
|
|
38
41
|
}
|
|
39
|
-
async function handler({
|
|
40
|
-
|
|
42
|
+
async function handler({
|
|
43
|
+
force,
|
|
44
|
+
verbose
|
|
45
|
+
}) {
|
|
46
|
+
const listr = new Listr(setupServerFileTasks({ force }), {
|
|
41
47
|
rendererOptions: { collapseSubtasks: false, persistentOutput: true },
|
|
42
48
|
renderer: verbose ? "verbose" : "default"
|
|
43
49
|
});
|
|
44
50
|
try {
|
|
45
|
-
await
|
|
51
|
+
await listr.run();
|
|
46
52
|
} catch (e) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
54
|
+
errorTelemetry(process.argv, message);
|
|
55
|
+
console.error(c.error(message));
|
|
56
|
+
const exitCode = typeof e === "object" && e !== null && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
57
|
+
process.exit(exitCode);
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
export {
|
|
@@ -50,9 +50,11 @@ const handler = async ({ force }) => {
|
|
|
50
50
|
try {
|
|
51
51
|
await tasks.run();
|
|
52
52
|
} catch (e) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
54
|
+
errorTelemetry(process.argv, message);
|
|
55
|
+
console.error(c.error(message));
|
|
56
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
57
|
+
process.exit(exitCode);
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
60
|
export {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
function createHandler(componentName) {
|
|
2
2
|
return async function handler(argv) {
|
|
3
|
-
const {
|
|
3
|
+
const { existsSync } = await import("node:fs");
|
|
4
|
+
const tsPath = `../libraries/${componentName}Handler.ts`;
|
|
5
|
+
const jsPath = `../libraries/${componentName}Handler.js`;
|
|
6
|
+
const resolvedPath = existsSync(new URL(tsPath, import.meta.url)) ? tsPath : jsPath;
|
|
7
|
+
const { handler: importedHandler } = await import(resolvedPath);
|
|
4
8
|
return importedHandler(argv);
|
|
5
9
|
};
|
|
6
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import execa from "execa";
|
|
3
2
|
import { Listr } from "listr2";
|
|
4
3
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
4
|
+
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
5
5
|
import extendStorybookConfiguration from "../../../../lib/configureStorybook.js";
|
|
6
6
|
import { extendJSXFile, fileIncludes } from "../../../../lib/extendFile.js";
|
|
7
7
|
import { getPaths, writeFile } from "../../../../lib/index.js";
|
|
@@ -10,7 +10,10 @@ const CHAKRA_THEME_AND_COMMENTS = `// This object will be used to override Chakr
|
|
|
10
10
|
const theme = {}
|
|
11
11
|
export default theme
|
|
12
12
|
`;
|
|
13
|
-
async function handler({
|
|
13
|
+
async function handler({
|
|
14
|
+
force,
|
|
15
|
+
install
|
|
16
|
+
}) {
|
|
14
17
|
recordTelemetryAttributes({
|
|
15
18
|
command: "setup ui chakra-ui",
|
|
16
19
|
force,
|
|
@@ -34,7 +37,9 @@ async function handler({ force, install }) {
|
|
|
34
37
|
{
|
|
35
38
|
title: `Install ${packages.join(", ")}`,
|
|
36
39
|
task: async () => {
|
|
37
|
-
await
|
|
40
|
+
await addWorkspacePackages("web", packages, {
|
|
41
|
+
cwd: rwPaths.base
|
|
42
|
+
});
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
],
|
|
@@ -88,8 +93,9 @@ async function handler({ force, install }) {
|
|
|
88
93
|
try {
|
|
89
94
|
await tasks.run();
|
|
90
95
|
} catch (e) {
|
|
91
|
-
console.error(c.error(e.message));
|
|
92
|
-
|
|
96
|
+
console.error(c.error(e instanceof Error ? e.message : String(e)));
|
|
97
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
98
|
+
process.exit(exitCode);
|
|
93
99
|
}
|
|
94
100
|
}
|
|
95
101
|
export {
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
6
6
|
import extendStorybookConfiguration from "../../../../lib/configureStorybook.js";
|
|
7
7
|
import { extendJSXFile, fileIncludes } from "../../../../lib/extendFile.js";
|
|
8
8
|
import { getPaths, writeFile } from "../../../../lib/index.js";
|
|
@@ -30,7 +30,11 @@ const theme = {}
|
|
|
30
30
|
|
|
31
31
|
export default createTheme(theme)
|
|
32
32
|
`;
|
|
33
|
-
async function handler({
|
|
33
|
+
async function handler({
|
|
34
|
+
force,
|
|
35
|
+
install,
|
|
36
|
+
packages
|
|
37
|
+
}) {
|
|
34
38
|
recordTelemetryAttributes({
|
|
35
39
|
command: "setup ui mantine",
|
|
36
40
|
force,
|
|
@@ -51,14 +55,14 @@ async function handler({ force, install, packages }) {
|
|
|
51
55
|
{
|
|
52
56
|
title: `Install ${installPackages.join(", ")}`,
|
|
53
57
|
task: async () => {
|
|
54
|
-
await
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
await addWorkspacePackages("web", installPackages, {
|
|
59
|
+
cwd: cedarPaths.base,
|
|
60
|
+
dev: true
|
|
61
|
+
});
|
|
62
|
+
await addWorkspacePackages("web", ["@emotion/react"], {
|
|
63
|
+
cwd: cedarPaths.base,
|
|
64
|
+
dev: true
|
|
65
|
+
});
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
],
|
|
@@ -113,7 +117,10 @@ async function handler({ force, install, packages }) {
|
|
|
113
117
|
},
|
|
114
118
|
{
|
|
115
119
|
title: "Configure Storybook...",
|
|
116
|
-
skip: () =>
|
|
120
|
+
skip: () => {
|
|
121
|
+
const previewConfig = cedarPaths.web.storybookPreviewConfig;
|
|
122
|
+
return previewConfig != null ? fileIncludes(previewConfig, "withMantine") : false;
|
|
123
|
+
},
|
|
117
124
|
task: async () => await extendStorybookConfiguration(
|
|
118
125
|
path.join(
|
|
119
126
|
import.meta.dirname,
|
|
@@ -129,8 +136,9 @@ async function handler({ force, install, packages }) {
|
|
|
129
136
|
try {
|
|
130
137
|
await tasks.run();
|
|
131
138
|
} catch (e) {
|
|
132
|
-
console.error(c.error(e.message));
|
|
133
|
-
|
|
139
|
+
console.error(c.error(e instanceof Error ? e.message : String(e)));
|
|
140
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
141
|
+
process.exit(exitCode);
|
|
134
142
|
}
|
|
135
143
|
}
|
|
136
144
|
export {
|