@cedarjs/cli 4.2.1-next.0 → 4.2.1-next.269
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 -13
- 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,7 +1,7 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import uniqWith from "lodash/uniqWith.js";
|
|
3
3
|
import { nodeIs, sieve } from "./algorithms.js";
|
|
4
|
-
const OPAQUE_UID_TAG = "
|
|
4
|
+
const OPAQUE_UID_TAG = "CEDAR_MERGE_OPAQUE_UID_Q2xldmVyIHlvdSEgSGF2ZSBhIGNvb2tpZS4=";
|
|
5
5
|
function requireSameType(base, ext) {
|
|
6
6
|
if (base.path.type !== ext.path.type) {
|
|
7
7
|
throw new Error(
|
|
@@ -17,9 +17,21 @@ function requireStrategyExists(base, _ext, strategy, strategyName) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
const strictEquality = (lhs, rhs) => lhs === rhs;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
function hasName(v) {
|
|
21
|
+
return typeof v === "object" && v !== null && "name" in v;
|
|
22
|
+
}
|
|
23
|
+
function hasKey(v) {
|
|
24
|
+
return typeof v === "object" && v !== null && "key" in v;
|
|
25
|
+
}
|
|
26
|
+
function hasKeyName(v) {
|
|
27
|
+
return hasKey(v) && hasName(v.key);
|
|
28
|
+
}
|
|
29
|
+
function hasValue(v) {
|
|
30
|
+
return typeof v === "object" && v !== null && "value" in v;
|
|
31
|
+
}
|
|
32
|
+
const byName = (lhs, rhs) => hasName(lhs) && hasName(rhs) && lhs.name === rhs.name;
|
|
33
|
+
const byKeyName = (lhs, rhs) => hasKeyName(lhs) && hasKeyName(rhs) && lhs.key.name === rhs.key.name;
|
|
34
|
+
const byValue = (lhs, rhs) => hasValue(lhs) && hasValue(rhs) && lhs.value === rhs.value;
|
|
23
35
|
function defaultEquality(baseContainer, extContainer) {
|
|
24
36
|
const sample = baseContainer.length && baseContainer[0] || extContainer.length && extContainer[0];
|
|
25
37
|
const defaults = {
|
|
@@ -30,14 +42,13 @@ function defaultEquality(baseContainer, extContainer) {
|
|
|
30
42
|
ObjectProperty: byKeyName,
|
|
31
43
|
StringLiteral: byValue
|
|
32
44
|
};
|
|
33
|
-
return sample && sample.type in defaults ? defaults[sample.type] : strictEquality;
|
|
45
|
+
return sample && typeof sample === "object" && "type" in sample && typeof sample.type === "string" && sample.type in defaults ? defaults[sample.type] : strictEquality;
|
|
34
46
|
}
|
|
35
|
-
function opaquely(
|
|
36
|
-
|
|
37
|
-
return strategy;
|
|
47
|
+
function opaquely(reducer) {
|
|
48
|
+
return Object.assign(reducer, { [OPAQUE_UID_TAG]: true });
|
|
38
49
|
}
|
|
39
|
-
function isOpaque(
|
|
40
|
-
return
|
|
50
|
+
function isOpaque(fn) {
|
|
51
|
+
return OPAQUE_UID_TAG in fn && fn[OPAQUE_UID_TAG] === true;
|
|
41
52
|
}
|
|
42
53
|
const keepBase = opaquely(() => {
|
|
43
54
|
});
|
|
@@ -47,20 +58,36 @@ const keepBoth = opaquely((base, ext) => {
|
|
|
47
58
|
const keepExtension = opaquely((base, ext) => {
|
|
48
59
|
base.path.replaceWith(ext.path);
|
|
49
60
|
});
|
|
50
|
-
const keepBothStatementParents = opaquely(
|
|
51
|
-
base
|
|
52
|
-
|
|
61
|
+
const keepBothStatementParents = opaquely(
|
|
62
|
+
(base, ext) => {
|
|
63
|
+
const extParent = ext.path.getStatementParent();
|
|
64
|
+
if (extParent) {
|
|
65
|
+
base.path.getStatementParent()?.insertAfter(extParent.node);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
);
|
|
53
69
|
const interleaveStrategy = {
|
|
54
|
-
ImportDeclaration(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
ImportDeclaration(base, ext) {
|
|
71
|
+
if (!t.isImportDeclaration(base) || !t.isImportDeclaration(ext)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const baseSpecs = base.specifiers;
|
|
75
|
+
const extSpecs = ext.specifiers;
|
|
76
|
+
const importSpecifierEquality = (lhs, rhs) => {
|
|
77
|
+
if (lhs.type !== rhs.type) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (lhs.type === "ImportSpecifier" && rhs.type === "ImportSpecifier") {
|
|
81
|
+
return lhs.imported.type === "Identifier" && rhs.imported.type === "Identifier" && lhs.imported.name === rhs.imported.name && lhs.local?.name === rhs.local?.name;
|
|
82
|
+
}
|
|
83
|
+
return lhs.local?.name === rhs.local?.name;
|
|
84
|
+
};
|
|
58
85
|
const uniqueSpecifiersOfType = (type) => uniqWith(
|
|
59
86
|
[...baseSpecs, ...extSpecs].filter(nodeIs(type)),
|
|
60
87
|
importSpecifierEquality
|
|
61
88
|
);
|
|
62
89
|
if (!baseSpecs.length !== !extSpecs.length) {
|
|
63
|
-
return keepBothStatementParents(
|
|
90
|
+
return keepBothStatementParents(base, ext);
|
|
64
91
|
}
|
|
65
92
|
const defaultPosition = (specs) => specs.some(nodeIs("ImportDefaultSpecifier")) ? -1 : 0;
|
|
66
93
|
const namespacePosition = (specs) => specs.some(nodeIs("ImportNamespaceSpecifier")) || specs.some(nodeIs("ImportSpecifier")) ? -1 : specs.length;
|
|
@@ -70,10 +97,10 @@ const interleaveStrategy = {
|
|
|
70
97
|
[uniqueSpecifiersOfType("ImportNamespaceSpecifier"), namespacePosition],
|
|
71
98
|
[uniqueSpecifiersOfType("ImportSpecifier"), importPosition]
|
|
72
99
|
);
|
|
73
|
-
|
|
100
|
+
base.specifiers = firstSpecifierList;
|
|
74
101
|
if (rest.length) {
|
|
75
|
-
|
|
76
|
-
rest.map((specs) => t.importDeclaration(specs,
|
|
102
|
+
base.path.insertAfter(
|
|
103
|
+
rest.map((specs) => t.importDeclaration(specs, base.source))
|
|
77
104
|
);
|
|
78
105
|
}
|
|
79
106
|
}
|
|
@@ -81,47 +108,70 @@ const interleaveStrategy = {
|
|
|
81
108
|
function interleave(base, ext) {
|
|
82
109
|
requireSameType(base, ext);
|
|
83
110
|
requireStrategyExists(base, ext, interleaveStrategy, "interleave");
|
|
84
|
-
|
|
111
|
+
interleaveStrategy[base.path.type]?.(base, ext);
|
|
85
112
|
}
|
|
86
113
|
const concatStrategy = {
|
|
87
114
|
ArrayExpression(base, ext) {
|
|
115
|
+
if (!t.isArrayExpression(base) || !t.isArrayExpression(ext)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
88
118
|
base.elements = [...base.elements, ...ext.elements];
|
|
89
119
|
},
|
|
90
120
|
ObjectExpression(base, ext) {
|
|
121
|
+
if (!t.isObjectExpression(base) || !t.isObjectExpression(ext)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
91
124
|
base.properties = [...base.properties, ...ext.properties];
|
|
92
125
|
},
|
|
93
126
|
StringLiteral(base, ext) {
|
|
127
|
+
if (!t.isStringLiteral(base) || !t.isStringLiteral(ext)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
94
130
|
base.value = base.value.concat(ext.value);
|
|
95
131
|
}
|
|
96
132
|
};
|
|
97
133
|
function concat(base, ext) {
|
|
98
134
|
requireSameType(base, ext);
|
|
99
135
|
requireStrategyExists(base, ext, concatStrategy, "concat");
|
|
100
|
-
|
|
136
|
+
concatStrategy[base.path.type]?.(base, ext);
|
|
101
137
|
}
|
|
102
138
|
const concatUniqueStrategy = {
|
|
103
139
|
ArrayExpression(base, ext, eq) {
|
|
104
|
-
|
|
105
|
-
|
|
140
|
+
if (!t.isArrayExpression(base) || !t.isArrayExpression(ext)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const equalFn = eq ?? defaultEquality(base.elements, ext.elements);
|
|
144
|
+
base.elements = uniqWith([...base.elements, ...ext.elements], equalFn);
|
|
106
145
|
},
|
|
107
146
|
ObjectExpression(base, ext, eq) {
|
|
108
|
-
|
|
109
|
-
|
|
147
|
+
if (!t.isObjectExpression(base) || !t.isObjectExpression(ext)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const equalFn = eq ?? defaultEquality(base.properties, ext.properties);
|
|
151
|
+
base.properties = uniqWith([...base.properties, ...ext.properties], equalFn);
|
|
110
152
|
}
|
|
111
153
|
};
|
|
112
154
|
function concatUnique(baseOrEq, ext) {
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
155
|
+
if (typeof baseOrEq === "function") {
|
|
156
|
+
const eq = baseOrEq;
|
|
157
|
+
return (base2, innerExt) => {
|
|
158
|
+
requireSameType(base2, innerExt);
|
|
159
|
+
requireStrategyExists(
|
|
160
|
+
base2,
|
|
161
|
+
innerExt,
|
|
162
|
+
concatUniqueStrategy,
|
|
163
|
+
"concatUnique"
|
|
164
|
+
);
|
|
165
|
+
concatUniqueStrategy[base2.path.type]?.(base2, innerExt, eq);
|
|
118
166
|
};
|
|
119
167
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return concatUniqueStrategy[baseOrEq.path.type](baseOrEq, ext);
|
|
168
|
+
const base = baseOrEq;
|
|
169
|
+
if (!ext) {
|
|
170
|
+
return;
|
|
124
171
|
}
|
|
172
|
+
requireSameType(base, ext);
|
|
173
|
+
requireStrategyExists(base, ext, concatUniqueStrategy, "concatUnique");
|
|
174
|
+
concatUniqueStrategy[base.path.type]?.(base, ext);
|
|
125
175
|
}
|
|
126
176
|
export {
|
|
127
177
|
concat,
|
package/dist/lib/packages.js
CHANGED
|
@@ -2,22 +2,26 @@ import fs from "node:fs";
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import execa from "execa";
|
|
5
|
+
import { dedupe } from "@cedarjs/cli-helpers/packageManager";
|
|
6
|
+
import { addRootPackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
7
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
5
8
|
import { getPaths } from "./index.js";
|
|
6
9
|
async function installModule(name, version = void 0) {
|
|
7
10
|
if (isModuleInstalled(name)) {
|
|
8
11
|
return false;
|
|
9
12
|
}
|
|
10
13
|
if (version === void 0) {
|
|
11
|
-
return
|
|
14
|
+
return installCedarModule(name);
|
|
12
15
|
} else {
|
|
13
|
-
await
|
|
16
|
+
await addRootPackages([`${name}@${version}`], {
|
|
17
|
+
dev: true,
|
|
14
18
|
stdio: "inherit",
|
|
15
19
|
cwd: getPaths().base
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
return true;
|
|
19
23
|
}
|
|
20
|
-
async function
|
|
24
|
+
async function installCedarModule(module) {
|
|
21
25
|
const packageJson = await import("@cedarjs/cli/package.json", { with: { type: "json" } });
|
|
22
26
|
let version = packageJson.default.version;
|
|
23
27
|
if (!isModuleInstalled(module)) {
|
|
@@ -35,21 +39,27 @@ async function installRedwoodModule(module) {
|
|
|
35
39
|
}
|
|
36
40
|
} catch (error) {
|
|
37
41
|
throw new Error(
|
|
38
|
-
`Couldn't fetch packument for ${module}: ${error.message}`
|
|
42
|
+
`Couldn't fetch packument for ${module}: ${error instanceof Error ? error.message : String(error)}`
|
|
39
43
|
);
|
|
40
44
|
}
|
|
41
|
-
const versionIsPublished = Object.keys(packument.versions).includes(
|
|
45
|
+
const versionIsPublished = Object.keys(packument.versions ?? {}).includes(
|
|
46
|
+
version
|
|
47
|
+
);
|
|
42
48
|
if (!versionIsPublished) {
|
|
43
49
|
version = "canary";
|
|
44
50
|
}
|
|
45
|
-
await
|
|
46
|
-
|
|
47
|
-
cwd: getPaths().base
|
|
48
|
-
});
|
|
49
|
-
await execa.command(`yarn dedupe`, {
|
|
51
|
+
await addRootPackages([`${module}@${version}`], {
|
|
52
|
+
dev: true,
|
|
50
53
|
stdio: "inherit",
|
|
51
54
|
cwd: getPaths().base
|
|
52
55
|
});
|
|
56
|
+
const dedupeCommand = dedupe();
|
|
57
|
+
if (dedupeCommand) {
|
|
58
|
+
await execa(getPackageManager(), [dedupeCommand], {
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
cwd: getPaths().base
|
|
61
|
+
});
|
|
62
|
+
}
|
|
53
63
|
return true;
|
|
54
64
|
}
|
|
55
65
|
return false;
|
|
@@ -66,12 +76,12 @@ function isModuleInstalled(module) {
|
|
|
66
76
|
return true;
|
|
67
77
|
}
|
|
68
78
|
const createdRequire = createRequire(import.meta.url);
|
|
69
|
-
return createdRequire.resolve.paths(`${module}/package.json`)
|
|
79
|
+
return createdRequire.resolve.paths(`${module}/package.json`)?.some((requireResolvePath) => {
|
|
70
80
|
return fs.existsSync(path.join(requireResolvePath, module));
|
|
71
|
-
});
|
|
81
|
+
}) ?? false;
|
|
72
82
|
}
|
|
73
83
|
export {
|
|
84
|
+
installCedarModule,
|
|
74
85
|
installModule,
|
|
75
|
-
installRedwoodModule,
|
|
76
86
|
isModuleInstalled
|
|
77
87
|
};
|
package/dist/lib/plugin.js
CHANGED
|
@@ -51,16 +51,23 @@ const PLUGIN_CACHE_BUILTIN = [
|
|
|
51
51
|
"tc",
|
|
52
52
|
"upgrade"
|
|
53
53
|
];
|
|
54
|
+
function isErrorWithCode(error, code) {
|
|
55
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
56
|
+
}
|
|
54
57
|
function loadCommandCache() {
|
|
55
|
-
let pluginCommandCache = PLUGIN_CACHE_DEFAULT;
|
|
58
|
+
let pluginCommandCache = { ...PLUGIN_CACHE_DEFAULT };
|
|
56
59
|
const commandCachePath = path.join(
|
|
57
60
|
getPaths().generated.base,
|
|
58
61
|
PLUGIN_CACHE_FILENAME
|
|
59
62
|
);
|
|
60
63
|
try {
|
|
61
|
-
const localCommandCache = JSON.parse(
|
|
64
|
+
const localCommandCache = JSON.parse(
|
|
65
|
+
fs.readFileSync(commandCachePath, "utf8")
|
|
66
|
+
);
|
|
62
67
|
let valid = true;
|
|
63
|
-
for (const [key, value] of Object.entries(
|
|
68
|
+
for (const [key, value] of Object.entries(
|
|
69
|
+
localCommandCache
|
|
70
|
+
)) {
|
|
64
71
|
if (key === "_builtin") {
|
|
65
72
|
continue;
|
|
66
73
|
}
|
|
@@ -73,7 +80,7 @@ function loadCommandCache() {
|
|
|
73
80
|
};
|
|
74
81
|
}
|
|
75
82
|
} catch (error) {
|
|
76
|
-
if (error
|
|
83
|
+
if (!isErrorWithCode(error, "ENOENT")) {
|
|
77
84
|
console.error(`Error loading plugin command cache at ${commandCachePath}`);
|
|
78
85
|
console.error(error);
|
|
79
86
|
}
|
|
@@ -162,7 +169,7 @@ async function installPluginPackage(packageName, packageVersion) {
|
|
|
162
169
|
console.log(
|
|
163
170
|
"The following error occurred while checking plugin compatibility for automatic installation:"
|
|
164
171
|
);
|
|
165
|
-
const errorMessage = error.message
|
|
172
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
166
173
|
console.log(errorMessage);
|
|
167
174
|
if (errorMessage.includes("does not have a tag") || errorMessage.includes("does not have a version")) {
|
|
168
175
|
process.exit(1);
|
|
@@ -33,7 +33,7 @@ To continue, the generator requires a unique plural form:`;
|
|
|
33
33
|
const destroyMessage = `Cannot determine the plural of "${model}" originally used to generate the files.
|
|
34
34
|
To continue, the destroy command requires the plural form:`;
|
|
35
35
|
const promptMessage = isDestroyer ? destroyMessage : generateMessage;
|
|
36
|
-
const initialPlural = model.
|
|
36
|
+
const initialPlural = model.endsWith("s") ? `${model}es` : `${model}s`;
|
|
37
37
|
const promptResult = await prompts({
|
|
38
38
|
type: "text",
|
|
39
39
|
name: "plural",
|
package/dist/lib/project.js
CHANGED
|
@@ -5,7 +5,9 @@ const isTypeScriptProject = () => {
|
|
|
5
5
|
const paths = getPaths();
|
|
6
6
|
return fs.existsSync(path.join(paths.web.base, "tsconfig.json")) || fs.existsSync(path.join(paths.api.base, "tsconfig.json"));
|
|
7
7
|
};
|
|
8
|
-
function workspaces({
|
|
8
|
+
function workspaces({
|
|
9
|
+
includePackages = false
|
|
10
|
+
} = {}) {
|
|
9
11
|
const cedarPaths = getPaths();
|
|
10
12
|
let workspaces2 = [];
|
|
11
13
|
if (fs.existsSync(path.join(cedarPaths.web.base, "package.json"))) {
|
package/dist/lib/rollback.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
|
|
3
|
+
const rollback = [];
|
|
4
4
|
function addFunctionToRollback(func, atEnd = false) {
|
|
5
5
|
const step = { type: "func", func };
|
|
6
6
|
if (atEnd) {
|
|
@@ -9,11 +9,11 @@ function addFunctionToRollback(func, atEnd = false) {
|
|
|
9
9
|
rollback.push(step);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function addFileToRollback(
|
|
12
|
+
function addFileToRollback(filePath, atEnd = false) {
|
|
13
13
|
const step = {
|
|
14
14
|
type: "file",
|
|
15
|
-
path:
|
|
16
|
-
content: fs.existsSync(
|
|
15
|
+
path: filePath,
|
|
16
|
+
content: fs.existsSync(filePath) ? fs.readFileSync(filePath) : null
|
|
17
17
|
};
|
|
18
18
|
if (atEnd) {
|
|
19
19
|
rollback.unshift(step);
|
|
@@ -21,7 +21,7 @@ function addFileToRollback(path2, atEnd = false) {
|
|
|
21
21
|
rollback.push(step);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const executeRollback = async (_, task) => {
|
|
25
25
|
if (task) {
|
|
26
26
|
task.title = "Reverting generator actions...";
|
|
27
27
|
}
|
|
@@ -51,9 +51,9 @@ async function executeRollback(_ = null, task = null) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
if (task) {
|
|
54
|
-
task.title = `Reverted because: ${task.task.message
|
|
54
|
+
task.title = `Reverted because: ${task.task.message?.error ?? "unknown error"}`;
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
57
|
function resetRollback() {
|
|
58
58
|
rollback.length = 0;
|
|
59
59
|
}
|
|
@@ -9,13 +9,13 @@ const getExistingModelName = async (name) => {
|
|
|
9
9
|
return void 0;
|
|
10
10
|
}
|
|
11
11
|
const modelName = name.replace(/[_-]/g, "").toLowerCase();
|
|
12
|
-
for (
|
|
12
|
+
for (const model of Object.values(schemaMemo)) {
|
|
13
13
|
if (model.name.toLowerCase() === modelName) {
|
|
14
14
|
return model.name;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
const schema = (await getSchemaDefinitions()).datamodel;
|
|
18
|
-
for (
|
|
18
|
+
for (const model of schema.models) {
|
|
19
19
|
if (model.name.toLowerCase() === modelName) {
|
|
20
20
|
return model.name;
|
|
21
21
|
}
|
|
@@ -36,25 +36,24 @@ const getSchema = async (name) => {
|
|
|
36
36
|
if (schemaMemo[modelName]) {
|
|
37
37
|
return schemaMemo[modelName];
|
|
38
38
|
}
|
|
39
|
-
const model = schema.models.find((
|
|
39
|
+
const model = schema.models.find((m) => m.name === modelName);
|
|
40
40
|
if (!model) {
|
|
41
41
|
return void 0;
|
|
42
42
|
}
|
|
43
|
-
model.fields.
|
|
43
|
+
const enrichedFields = model.fields.map((field) => {
|
|
44
44
|
const fieldEnum = schema.enums.find((e) => field.type === e.name);
|
|
45
|
-
|
|
46
|
-
field.enumValues = fieldEnum.values;
|
|
47
|
-
}
|
|
45
|
+
return fieldEnum ? { ...field, enumValues: fieldEnum.values } : { ...field };
|
|
48
46
|
});
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const enrichedModel = { ...model, fields: enrichedFields };
|
|
48
|
+
schemaMemo[modelName] = enrichedModel;
|
|
49
|
+
return enrichedModel;
|
|
51
50
|
};
|
|
52
51
|
const getEnum = async (name) => {
|
|
53
52
|
const schema = await getSchemaDefinitions();
|
|
54
53
|
if (!name) {
|
|
55
|
-
return schema.metadata.datamodel.enums;
|
|
54
|
+
return [...schema.metadata.datamodel.enums];
|
|
56
55
|
}
|
|
57
|
-
const model = schema.datamodel.enums.find((
|
|
56
|
+
const model = schema.datamodel.enums.find((e) => e.name === name);
|
|
58
57
|
if (!model) {
|
|
59
58
|
throw new Error(
|
|
60
59
|
`No enum schema definition found for \`${name}\` in schema.prisma file`
|
|
@@ -67,7 +66,8 @@ const getDataModel = async () => {
|
|
|
67
66
|
return result.schemas;
|
|
68
67
|
};
|
|
69
68
|
const getSchemaDefinitions = async () => {
|
|
70
|
-
|
|
69
|
+
const document = await getDMMF({ datamodel: await getDataModel() });
|
|
70
|
+
return document;
|
|
71
71
|
};
|
|
72
72
|
const getSchemaConfig = async () => {
|
|
73
73
|
return getConfig({
|
package/dist/lib/test.js
CHANGED
|
@@ -76,6 +76,10 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
|
+
vi.mock("@cedarjs/project-config/packageManager", () => ({
|
|
80
|
+
getPackageManager: vi.fn(() => "yarn"),
|
|
81
|
+
resetPackageManagerCache: vi.fn()
|
|
82
|
+
}));
|
|
79
83
|
vi.mock("@cedarjs/cli-helpers", async (importOriginal) => {
|
|
80
84
|
const originalCliHelpers = await importOriginal();
|
|
81
85
|
return {
|
package/dist/lib/updateCheck.js
CHANGED
|
@@ -4,6 +4,8 @@ import ansis from "ansis";
|
|
|
4
4
|
import boxen from "boxen";
|
|
5
5
|
import latestVersion from "latest-version";
|
|
6
6
|
import semver from "semver";
|
|
7
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
8
|
+
import { getNodeRunnerArgs } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
9
|
import { getConfig } from "@cedarjs/project-config";
|
|
8
10
|
import { spawnBackgroundProcess } from "./background.js";
|
|
9
11
|
import { isLockSet, setLock, unsetLock } from "./locking.js";
|
|
@@ -88,7 +90,7 @@ function getUpdateMessage() {
|
|
|
88
90
|
const data = readUpdateDataFile();
|
|
89
91
|
const localTag = extractTagFromVersion(data.localVersion) || "latest";
|
|
90
92
|
let updateCount = 0;
|
|
91
|
-
let message =
|
|
93
|
+
let message = ` New updates to Cedar are available via \`${formatCedarCommand(["upgrade#REPLACEME#"])}\` `;
|
|
92
94
|
data.remoteVersions.forEach((version, tag) => {
|
|
93
95
|
if (semver.gt(version, data.localVersion)) {
|
|
94
96
|
updateCount += 1;
|
|
@@ -182,10 +184,10 @@ function updateCheckMiddleware(argv) {
|
|
|
182
184
|
}
|
|
183
185
|
if (shouldCheck()) {
|
|
184
186
|
setLock(CHECK_LOCK_IDENTIFIER);
|
|
185
|
-
|
|
186
|
-
"node",
|
|
187
|
+
const [bgCmd, bgCmdArgs] = getNodeRunnerArgs(
|
|
187
188
|
path.join(import.meta.dirname, "updateCheckExecute.js")
|
|
188
|
-
|
|
189
|
+
);
|
|
190
|
+
spawnBackgroundProcess("updateCheck", bgCmd, bgCmdArgs);
|
|
189
191
|
} else if (shouldShow()) {
|
|
190
192
|
setLock(SHOW_LOCK_IDENTIFIER);
|
|
191
193
|
process.on("exit", () => {
|
|
@@ -5,6 +5,11 @@ function checkNodeVersion() {
|
|
|
5
5
|
const pVersion = process.version;
|
|
6
6
|
const pVersionC = semver.clean(pVersion);
|
|
7
7
|
const LOWER_BOUND = "v24.0.0";
|
|
8
|
+
if (!pVersionC) {
|
|
9
|
+
checks.ok = false;
|
|
10
|
+
checks.message = `Invalid Node.js version: ${pVersion}`;
|
|
11
|
+
return checks;
|
|
12
|
+
}
|
|
8
13
|
if (semver.gte(pVersionC, LOWER_BOUND)) {
|
|
9
14
|
return checks;
|
|
10
15
|
}
|
package/dist/plugin.js
CHANGED
|
@@ -59,8 +59,6 @@ async function loadPlugins(yargs) {
|
|
|
59
59
|
yargs.command({
|
|
60
60
|
command: `${namespace} <command>`,
|
|
61
61
|
describe: `Commands from ${namespace}`,
|
|
62
|
-
builder: () => {
|
|
63
|
-
},
|
|
64
62
|
handler: () => {
|
|
65
63
|
}
|
|
66
64
|
});
|
|
@@ -97,6 +95,7 @@ async function loadPlugins(yargs) {
|
|
|
97
95
|
describe: `Commands from ${namespaceInUse}`,
|
|
98
96
|
builder: (yargs2) => {
|
|
99
97
|
yargs2.command(commands).demandCommand();
|
|
98
|
+
return yargs2;
|
|
100
99
|
},
|
|
101
100
|
handler: () => {
|
|
102
101
|
}
|
|
@@ -108,7 +107,7 @@ async function loadPlugins(yargs) {
|
|
|
108
107
|
}
|
|
109
108
|
const packagesToLoad = /* @__PURE__ */ new Set();
|
|
110
109
|
for (const [packageName, cacheEntry] of Object.entries(pluginCommandCache)) {
|
|
111
|
-
if (packageName === "_builtin") {
|
|
110
|
+
if (packageName === "_builtin" || Array.isArray(cacheEntry)) {
|
|
112
111
|
continue;
|
|
113
112
|
}
|
|
114
113
|
const commandFirstWords = [];
|
|
@@ -134,6 +133,9 @@ async function loadPlugins(yargs) {
|
|
|
134
133
|
const commandsToRegister = [];
|
|
135
134
|
if (foundMatchingPackage) {
|
|
136
135
|
const packageToLoad = packagesToLoad.values().next().value;
|
|
136
|
+
if (!packageToLoad) {
|
|
137
|
+
throw new Error(`Invalid first value in ${packagesToLoad}`);
|
|
138
|
+
}
|
|
137
139
|
const commands = await loadCommandsFromCacheOrPackage(
|
|
138
140
|
packageToLoad,
|
|
139
141
|
pluginCommandCache,
|
|
@@ -160,6 +162,7 @@ async function loadPlugins(yargs) {
|
|
|
160
162
|
describe: `Commands from ${namespaceInUse}`,
|
|
161
163
|
builder: (yargs2) => {
|
|
162
164
|
yargs2.command(commandsToRegister).demandCommand();
|
|
165
|
+
return yargs2;
|
|
163
166
|
},
|
|
164
167
|
handler: () => {
|
|
165
168
|
}
|
|
@@ -173,8 +176,6 @@ async function loadPlugins(yargs) {
|
|
|
173
176
|
yargs.command({
|
|
174
177
|
command: `${namespace} <command>`,
|
|
175
178
|
describe: `Commands from ${namespace}`,
|
|
176
|
-
builder: () => {
|
|
177
|
-
},
|
|
178
179
|
handler: () => {
|
|
179
180
|
}
|
|
180
181
|
});
|
|
@@ -185,24 +186,29 @@ async function loadPlugins(yargs) {
|
|
|
185
186
|
}
|
|
186
187
|
async function loadCommandsFromCacheOrPackage(packageName, cache, autoInstall, readFromCache) {
|
|
187
188
|
let cacheEntry = void 0;
|
|
188
|
-
if (readFromCache) {
|
|
189
|
-
|
|
189
|
+
if (readFromCache && cache) {
|
|
190
|
+
const entry = cache[packageName];
|
|
191
|
+
if (entry && !Array.isArray(entry)) {
|
|
192
|
+
cacheEntry = entry;
|
|
193
|
+
}
|
|
190
194
|
}
|
|
191
195
|
if (cacheEntry !== void 0) {
|
|
192
196
|
const commands = Object.entries(cacheEntry).map(([command, info]) => {
|
|
193
197
|
return {
|
|
194
198
|
command,
|
|
195
199
|
describe: info.description,
|
|
196
|
-
aliases: info.aliases
|
|
200
|
+
aliases: info.aliases,
|
|
201
|
+
handler: () => {
|
|
202
|
+
}
|
|
197
203
|
};
|
|
198
204
|
});
|
|
199
205
|
return commands;
|
|
200
206
|
}
|
|
201
207
|
const plugin = await loadPluginPackage(packageName, void 0, autoInstall);
|
|
202
208
|
if (plugin) {
|
|
203
|
-
const
|
|
209
|
+
const rawCommands = plugin.commands ?? [];
|
|
204
210
|
const cacheUpdate = {};
|
|
205
|
-
for (const command of
|
|
211
|
+
for (const command of rawCommands) {
|
|
206
212
|
const info = {
|
|
207
213
|
aliases: command.aliases,
|
|
208
214
|
description: command.description
|
|
@@ -211,10 +217,10 @@ async function loadCommandsFromCacheOrPackage(packageName, cache, autoInstall, r
|
|
|
211
217
|
cacheUpdate[command.command] = info;
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
|
-
if (Object.keys(cacheUpdate).length > 0) {
|
|
220
|
+
if (cache && Object.keys(cacheUpdate).length > 0) {
|
|
215
221
|
cache[packageName] = cacheUpdate;
|
|
216
222
|
}
|
|
217
|
-
return commands;
|
|
223
|
+
return plugin.commands ?? [];
|
|
218
224
|
}
|
|
219
225
|
return [];
|
|
220
226
|
}
|
|
@@ -32,19 +32,26 @@ class CustomFileExporter {
|
|
|
32
32
|
* @param spans the list of sampled Spans to be exported.
|
|
33
33
|
*/
|
|
34
34
|
export(spans, resultCallback) {
|
|
35
|
-
for (
|
|
36
|
-
const span = spans[i];
|
|
37
|
-
delete span["_spanProcessor"];
|
|
35
|
+
for (const span of spans) {
|
|
38
36
|
fs.appendFileSync(
|
|
39
37
|
this.#storageFilePath,
|
|
40
|
-
JSON.stringify(
|
|
38
|
+
JSON.stringify(
|
|
39
|
+
span,
|
|
40
|
+
(key, value) => {
|
|
41
|
+
if (key === "_spanProcessor") {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
},
|
|
46
|
+
2
|
|
47
|
+
)
|
|
41
48
|
);
|
|
42
49
|
fs.appendFileSync(this.#storageFilePath, ",");
|
|
43
50
|
}
|
|
44
51
|
resultCallback({ code: 0 });
|
|
45
52
|
}
|
|
46
53
|
/** Stops the exporter. */
|
|
47
|
-
shutdown() {
|
|
54
|
+
async shutdown() {
|
|
48
55
|
if (!this.#isShutdown) {
|
|
49
56
|
fs.truncateSync(
|
|
50
57
|
this.#storageFilePath,
|
package/dist/telemetry/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SamplingDecision
|
|
8
8
|
} from "@opentelemetry/sdk-trace-node";
|
|
9
9
|
import { hideBin } from "yargs/helpers";
|
|
10
|
+
import { getNodeRunnerArgs } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
10
11
|
import { spawnBackgroundProcess } from "../lib/background.js";
|
|
11
12
|
import { CustomFileExporter } from "./exporter.js";
|
|
12
13
|
let traceProvider;
|
|
@@ -69,10 +70,10 @@ function shutdownTelemetry() {
|
|
|
69
70
|
opentelemetry.trace.getActiveSpan()?.end();
|
|
70
71
|
}
|
|
71
72
|
traceExporter?.shutdown();
|
|
72
|
-
|
|
73
|
-
"node",
|
|
73
|
+
const [cmd, args] = getNodeRunnerArgs(
|
|
74
74
|
path.join(import.meta.dirname, "send.js")
|
|
75
|
-
|
|
75
|
+
);
|
|
76
|
+
spawnBackgroundProcess("telemetry", cmd, args);
|
|
76
77
|
} catch (error) {
|
|
77
78
|
console.error("Telemetry error");
|
|
78
79
|
console.error(error);
|