@cedarjs/cli 5.0.0-canary.2501 → 5.0.0-canary.2503
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/commands/build/buildPackagesTask.js +6 -6
- package/dist/commands/experimental/setupOpentelemetryHandler.js +9 -4
- package/dist/commands/experimental/setupRscHandler.js +14 -11
- package/dist/commands/generate/job/jobHandler.js +11 -5
- package/dist/commands/generate/sdl/sdlHandler.js +18 -10
- package/dist/commands/generate/service/serviceHandler.js +34 -18
- package/dist/commands/setup/realtime/realtimeHandler.js +6 -4
- package/dist/commands/setup/uploads/uploadsHandler.js +5 -3
- package/package.json +12 -12
|
@@ -10,7 +10,7 @@ async function buildPackagesTask(task, nonApiWebWorkspaces) {
|
|
|
10
10
|
const workspacePaths = nonApiWebWorkspaces.some((w) => w === "packages/*") ? await Array.fromAsync(fs.promises.glob(globPattern)) : nonApiWebWorkspaces.map((w) => {
|
|
11
11
|
const workspacePath = path.join(
|
|
12
12
|
cedarPaths.packages,
|
|
13
|
-
w.split("/").at(-1)
|
|
13
|
+
w.split("/").at(-1) ?? ""
|
|
14
14
|
);
|
|
15
15
|
if (!fs.existsSync(workspacePath)) {
|
|
16
16
|
return "";
|
|
@@ -30,15 +30,15 @@ async function buildPackagesTask(task, nonApiWebWorkspaces) {
|
|
|
30
30
|
try {
|
|
31
31
|
await runScript("build", [], { cwd: workspacePath });
|
|
32
32
|
} catch (e) {
|
|
33
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
34
|
+
const stderr = e instanceof Error && "stderr" in e && typeof e.stderr === "string" ? e.stderr : void 0;
|
|
33
35
|
errorTelemetry(
|
|
34
36
|
process.argv,
|
|
35
|
-
`Error building package "${name}": ${
|
|
37
|
+
`Error building package "${name}": ${message}`
|
|
36
38
|
);
|
|
37
|
-
throw new Error(
|
|
38
|
-
`Building "${name}" failed
|
|
39
|
+
throw new Error(`Building "${name}" failed
|
|
39
40
|
|
|
40
|
-
${
|
|
41
|
-
);
|
|
41
|
+
${stderr || message}`);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -18,7 +18,10 @@ import {
|
|
|
18
18
|
EXPERIMENTAL_TOPIC_ID
|
|
19
19
|
} from "./setupOpentelemetry.js";
|
|
20
20
|
import { printTaskEpilogue } from "./util.js";
|
|
21
|
-
const handler = async ({
|
|
21
|
+
const handler = async ({
|
|
22
|
+
force,
|
|
23
|
+
verbose
|
|
24
|
+
}) => {
|
|
22
25
|
const ts = isTypeScriptProject();
|
|
23
26
|
const configTomlPath = getConfigPath();
|
|
24
27
|
const configFileName = path.basename(configTomlPath);
|
|
@@ -208,9 +211,11 @@ const handler = async ({ force, verbose }) => {
|
|
|
208
211
|
try {
|
|
209
212
|
await tasks.run();
|
|
210
213
|
} catch (e) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
process.
|
|
214
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
215
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
216
|
+
errorTelemetry(process.argv, message);
|
|
217
|
+
console.error(c.error(message));
|
|
218
|
+
process.exit(exitCode);
|
|
214
219
|
}
|
|
215
220
|
};
|
|
216
221
|
export {
|
|
@@ -11,7 +11,10 @@ import { getPaths, transformTSToJS, writeFile } from "../../lib/index.js";
|
|
|
11
11
|
import { isTypeScriptProject } from "../../lib/project.js";
|
|
12
12
|
import { command, description, EXPERIMENTAL_TOPIC_ID } from "./setupRsc.js";
|
|
13
13
|
import { printTaskEpilogue } from "./util.js";
|
|
14
|
-
const handler = async ({
|
|
14
|
+
const handler = async ({
|
|
15
|
+
force,
|
|
16
|
+
verbose
|
|
17
|
+
}) => {
|
|
15
18
|
const rwPaths = getPaths();
|
|
16
19
|
const configTomlPath = getConfigPath();
|
|
17
20
|
const configContent = fs.readFileSync(configTomlPath, "utf-8");
|
|
@@ -84,11 +87,9 @@ const handler = async ({ force, verbose }) => {
|
|
|
84
87
|
),
|
|
85
88
|
"utf-8"
|
|
86
89
|
);
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
);
|
|
91
|
-
writeFile(rwPaths.web.entryClient, entryClientContent, {
|
|
90
|
+
const entryClient = rwPaths.web.entryClient ?? "";
|
|
91
|
+
const entryClientContent = isTypeScriptProject() ? entryClientTemplate : await transformTSToJS(entryClient, entryClientTemplate);
|
|
92
|
+
writeFile(entryClient, entryClientContent, {
|
|
92
93
|
overwriteExisting: true
|
|
93
94
|
});
|
|
94
95
|
}
|
|
@@ -220,7 +221,7 @@ const handler = async ({ force, verbose }) => {
|
|
|
220
221
|
{
|
|
221
222
|
title: "Adding CSS files...",
|
|
222
223
|
task: async () => {
|
|
223
|
-
const
|
|
224
|
+
const cssFiles = [
|
|
224
225
|
{
|
|
225
226
|
template: "Counter.css.template",
|
|
226
227
|
path: ["components", "Counter", "Counter.css"]
|
|
@@ -242,7 +243,7 @@ const handler = async ({ force, verbose }) => {
|
|
|
242
243
|
path: ["pages", "AboutPage", "AboutPage.css"]
|
|
243
244
|
}
|
|
244
245
|
];
|
|
245
|
-
|
|
246
|
+
cssFiles.forEach((file) => {
|
|
246
247
|
const template = fs.readFileSync(
|
|
247
248
|
path.resolve(
|
|
248
249
|
import.meta.dirname,
|
|
@@ -398,9 +399,11 @@ const handler = async ({ force, verbose }) => {
|
|
|
398
399
|
try {
|
|
399
400
|
await tasks.run();
|
|
400
401
|
} catch (e) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
process.
|
|
402
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
403
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
404
|
+
errorTelemetry(process.argv, message);
|
|
405
|
+
console.error(c.error(message));
|
|
406
|
+
process.exit(exitCode);
|
|
404
407
|
}
|
|
405
408
|
};
|
|
406
409
|
export {
|
|
@@ -66,7 +66,11 @@ const files = async ({
|
|
|
66
66
|
}
|
|
67
67
|
return transformTSToJSMap(outputFiles, typescript);
|
|
68
68
|
};
|
|
69
|
-
const handler = async ({
|
|
69
|
+
const handler = async ({
|
|
70
|
+
name,
|
|
71
|
+
force,
|
|
72
|
+
...rest
|
|
73
|
+
}) => {
|
|
70
74
|
recordTelemetryAttributes({
|
|
71
75
|
command: "generate job",
|
|
72
76
|
force,
|
|
@@ -78,7 +82,7 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
78
82
|
const jobsManagerFile = getPaths().api.distJobsConfig;
|
|
79
83
|
const jobManager = await import(pathToFileURL(jobsManagerFile).href);
|
|
80
84
|
queueName = jobManager.jobs?.queues[0] ?? "default";
|
|
81
|
-
} catch
|
|
85
|
+
} catch {
|
|
82
86
|
}
|
|
83
87
|
let jobFiles = {};
|
|
84
88
|
const tasks = new Listr(
|
|
@@ -111,9 +115,11 @@ const handler = async ({ name, force, ...rest }) => {
|
|
|
111
115
|
}
|
|
112
116
|
await tasks.run();
|
|
113
117
|
} catch (e) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
process.
|
|
118
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
119
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
120
|
+
errorTelemetry(process.argv, message);
|
|
121
|
+
console.error(c.error(message));
|
|
122
|
+
process.exit(exitCode);
|
|
117
123
|
}
|
|
118
124
|
};
|
|
119
125
|
export {
|
|
@@ -49,8 +49,11 @@ const modelFieldToSDL = ({
|
|
|
49
49
|
types = {},
|
|
50
50
|
docs = false
|
|
51
51
|
}) => {
|
|
52
|
-
if (Object.entries(types).length) {
|
|
53
|
-
|
|
52
|
+
if (Object.entries(types).length && field.kind === "object") {
|
|
53
|
+
const resolvedType = idType(types[field.type]);
|
|
54
|
+
if (typeof resolvedType === "string") {
|
|
55
|
+
field.type = resolvedType;
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
const prismaTypeToGraphqlType = {
|
|
56
59
|
Json: "JSON",
|
|
@@ -74,10 +77,10 @@ const inputSDL = (model, required, types = {}, docs = false) => {
|
|
|
74
77
|
const ignoredFields = DEFAULT_IGNORE_FIELDS_FOR_INPUT;
|
|
75
78
|
return model.fields.filter((field) => {
|
|
76
79
|
const idField = model.fields.find((field2) => field2.isId);
|
|
77
|
-
if (idField
|
|
80
|
+
if (idField?.default) {
|
|
78
81
|
ignoredFields.push(idField.name);
|
|
79
82
|
}
|
|
80
|
-
return ignoredFields.
|
|
83
|
+
return !ignoredFields.includes(field.name) && field.kind !== "object";
|
|
81
84
|
}).map((field) => modelFieldToSDL({ field, required, types, docs }));
|
|
82
85
|
};
|
|
83
86
|
const idInputSDL = (idType2, docs) => {
|
|
@@ -95,12 +98,12 @@ const updateInputSDL = (model, types = {}, docs = false) => {
|
|
|
95
98
|
return inputSDL(model, false, types, docs);
|
|
96
99
|
};
|
|
97
100
|
const idType = (model, crud) => {
|
|
98
|
-
if (!crud) {
|
|
101
|
+
if (!crud || !model) {
|
|
99
102
|
return void 0;
|
|
100
103
|
}
|
|
101
104
|
if (model.primaryKey?.fields.length) {
|
|
102
105
|
const { fields: fieldNames } = model.primaryKey;
|
|
103
|
-
return fieldNames.map((name) => model.fields.find((f) => f.name === name));
|
|
106
|
+
return fieldNames.map((name) => model.fields.find((f) => f.name === name)).filter((f) => f !== void 0);
|
|
104
107
|
}
|
|
105
108
|
const idField = model.fields.find((field) => field.isId);
|
|
106
109
|
if (!idField) {
|
|
@@ -127,7 +130,10 @@ const sdlFromSchemaModel = async (name, crud, docs = false) => {
|
|
|
127
130
|
const model2 = await getSchema(field.type);
|
|
128
131
|
return model2;
|
|
129
132
|
})
|
|
130
|
-
)).reduce(
|
|
133
|
+
)).reduce(
|
|
134
|
+
(acc, cur) => ({ ...acc, [cur.name]: cur }),
|
|
135
|
+
{}
|
|
136
|
+
);
|
|
131
137
|
const enums = (await Promise.all(
|
|
132
138
|
model.fields.filter((field) => field.kind === "enum").map(async (field) => {
|
|
133
139
|
const enumDef = await getEnum(field.type);
|
|
@@ -237,9 +243,11 @@ const handler = async ({
|
|
|
237
243
|
}
|
|
238
244
|
await tasks.run();
|
|
239
245
|
} catch (e) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
process.
|
|
246
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
247
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
248
|
+
errorTelemetry(process.argv, message);
|
|
249
|
+
console.error(c.error(message));
|
|
250
|
+
process.exit(exitCode);
|
|
243
251
|
}
|
|
244
252
|
};
|
|
245
253
|
export {
|
|
@@ -10,7 +10,7 @@ const parseSchema = async (model) => {
|
|
|
10
10
|
const schema = await getSchema(model);
|
|
11
11
|
const relations = {};
|
|
12
12
|
let foreignKeys = [];
|
|
13
|
-
|
|
13
|
+
const scalarFields = schema.fields.filter((field) => {
|
|
14
14
|
if (field.relationFromFields) {
|
|
15
15
|
if (field.isRequired && field.relationFromFields.length !== 0) {
|
|
16
16
|
relations[field.name] = {
|
|
@@ -27,11 +27,11 @@ const parseSchema = async (model) => {
|
|
|
27
27
|
};
|
|
28
28
|
function scenarioFieldValue(field) {
|
|
29
29
|
const randFloat = Math.random() * 1e7;
|
|
30
|
-
const randInt = parseInt(Math.random() * 1e7);
|
|
30
|
+
const randInt = parseInt(String(Math.random() * 1e7));
|
|
31
31
|
const randIntArray = [
|
|
32
|
-
parseInt(Math.random() * 300),
|
|
33
|
-
parseInt(Math.random() * 300),
|
|
34
|
-
parseInt(Math.random() * 300)
|
|
32
|
+
parseInt(String(Math.random() * 300)),
|
|
33
|
+
parseInt(String(Math.random() * 300)),
|
|
34
|
+
parseInt(String(Math.random() * 300))
|
|
35
35
|
];
|
|
36
36
|
switch (field.type) {
|
|
37
37
|
case "BigInt":
|
|
@@ -55,7 +55,7 @@ function scenarioFieldValue(field) {
|
|
|
55
55
|
case "Bytes":
|
|
56
56
|
return `new Uint8Array([${randIntArray}])`;
|
|
57
57
|
default: {
|
|
58
|
-
if (field.kind === "enum" && field.enumValues[0]) {
|
|
58
|
+
if (field.kind === "enum" && field.enumValues?.[0]) {
|
|
59
59
|
return field.enumValues[0].dbName || field.enumValues[0].name;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -126,15 +126,18 @@ const buildStringifiedScenario = async (model) => {
|
|
|
126
126
|
};
|
|
127
127
|
const fieldTypes = async (model) => {
|
|
128
128
|
const { scalarFields } = await parseSchema(model);
|
|
129
|
-
return scalarFields.reduce(
|
|
130
|
-
acc
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
return scalarFields.reduce(
|
|
130
|
+
(acc, value) => {
|
|
131
|
+
acc[value.name] = value.type;
|
|
132
|
+
return acc;
|
|
133
|
+
},
|
|
134
|
+
{}
|
|
135
|
+
);
|
|
133
136
|
};
|
|
134
137
|
const fieldsToInput = async (model) => {
|
|
135
138
|
const { scalarFields, foreignKeys } = await parseSchema(model);
|
|
136
139
|
const modelName = camelcase(singularize(model));
|
|
137
|
-
|
|
140
|
+
const inputObj = {};
|
|
138
141
|
scalarFields.forEach((field) => {
|
|
139
142
|
if (foreignKeys.includes(field.name)) {
|
|
140
143
|
inputObj[field.name] = `scenario.${modelName}.two.${field.name}`;
|
|
@@ -152,7 +155,9 @@ const fieldsToUpdate = async (model) => {
|
|
|
152
155
|
const { scalarFields, relations, foreignKeys } = await parseSchema(model);
|
|
153
156
|
const modelName = camelcase(singularize(model));
|
|
154
157
|
let field, newValue, fieldName;
|
|
155
|
-
field = scalarFields.find(
|
|
158
|
+
field = scalarFields.find(
|
|
159
|
+
(scalar) => !foreignKeys.includes(scalar.name)
|
|
160
|
+
);
|
|
156
161
|
if (!field) {
|
|
157
162
|
field = scalarFields[0];
|
|
158
163
|
}
|
|
@@ -168,25 +173,31 @@ const fieldsToUpdate = async (model) => {
|
|
|
168
173
|
newValue = value;
|
|
169
174
|
switch (field.type) {
|
|
170
175
|
case "BigInt":
|
|
171
|
-
|
|
176
|
+
if (typeof value === "bigint") {
|
|
177
|
+
newValue = `${value + 1n}`;
|
|
178
|
+
}
|
|
172
179
|
break;
|
|
173
180
|
case "Boolean": {
|
|
174
181
|
newValue = !value;
|
|
175
182
|
break;
|
|
176
183
|
}
|
|
177
184
|
case "DateTime": {
|
|
178
|
-
|
|
185
|
+
const date = /* @__PURE__ */ new Date();
|
|
179
186
|
date.setDate(date.getDate() + 1);
|
|
180
187
|
newValue = date;
|
|
181
188
|
break;
|
|
182
189
|
}
|
|
183
190
|
case "Decimal":
|
|
184
191
|
case "Float": {
|
|
185
|
-
|
|
192
|
+
if (typeof value === "number") {
|
|
193
|
+
newValue = value + 1.1;
|
|
194
|
+
}
|
|
186
195
|
break;
|
|
187
196
|
}
|
|
188
197
|
case "Int": {
|
|
189
|
-
|
|
198
|
+
if (typeof value === "number") {
|
|
199
|
+
newValue = value + 1;
|
|
200
|
+
}
|
|
190
201
|
break;
|
|
191
202
|
}
|
|
192
203
|
case "Json": {
|
|
@@ -194,11 +205,13 @@ const fieldsToUpdate = async (model) => {
|
|
|
194
205
|
break;
|
|
195
206
|
}
|
|
196
207
|
case "String": {
|
|
197
|
-
|
|
208
|
+
if (typeof value === "string") {
|
|
209
|
+
newValue = value + "2";
|
|
210
|
+
}
|
|
198
211
|
break;
|
|
199
212
|
}
|
|
200
213
|
default: {
|
|
201
|
-
if (field.kind === "enum" && field.enumValues[field.enumValues.length - 1]) {
|
|
214
|
+
if (field.kind === "enum" && field.enumValues?.[field.enumValues.length - 1]) {
|
|
202
215
|
const enumVal = field.enumValues[field.enumValues.length - 1];
|
|
203
216
|
newValue = enumVal.dbName || enumVal.name;
|
|
204
217
|
}
|
|
@@ -206,6 +219,9 @@ const fieldsToUpdate = async (model) => {
|
|
|
206
219
|
}
|
|
207
220
|
}
|
|
208
221
|
}
|
|
222
|
+
if (Array.isArray(fieldName)) {
|
|
223
|
+
return Object.fromEntries(fieldName.map((key) => [key, newValue]));
|
|
224
|
+
}
|
|
209
225
|
return { [fieldName]: newValue };
|
|
210
226
|
};
|
|
211
227
|
const getIdName = async (model) => {
|
|
@@ -30,7 +30,7 @@ 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
36
|
const cedarPaths = getPaths();
|
|
@@ -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 {
|
|
@@ -141,9 +141,11 @@ const handler = async ({ force }) => {
|
|
|
141
141
|
try {
|
|
142
142
|
await tasks.run();
|
|
143
143
|
} catch (e) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
process.
|
|
144
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
145
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
146
|
+
errorTelemetry(process.argv, message);
|
|
147
|
+
console.error(c.error(message));
|
|
148
|
+
process.exit(exitCode);
|
|
147
149
|
}
|
|
148
150
|
};
|
|
149
151
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.2503",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/parser": "7.29.3",
|
|
35
35
|
"@babel/preset-typescript": "7.28.5",
|
|
36
|
-
"@cedarjs/api-server": "5.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "5.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "5.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "5.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "5.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "5.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "5.0.0-canary.
|
|
45
|
-
"@cedarjs/vite": "5.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "5.0.0-canary.
|
|
36
|
+
"@cedarjs/api-server": "5.0.0-canary.2503",
|
|
37
|
+
"@cedarjs/cli-helpers": "5.0.0-canary.2503",
|
|
38
|
+
"@cedarjs/fastify-web": "5.0.0-canary.2503",
|
|
39
|
+
"@cedarjs/internal": "5.0.0-canary.2503",
|
|
40
|
+
"@cedarjs/prerender": "5.0.0-canary.2503",
|
|
41
|
+
"@cedarjs/project-config": "5.0.0-canary.2503",
|
|
42
|
+
"@cedarjs/structure": "5.0.0-canary.2503",
|
|
43
|
+
"@cedarjs/telemetry": "5.0.0-canary.2503",
|
|
44
|
+
"@cedarjs/utils": "5.0.0-canary.2503",
|
|
45
|
+
"@cedarjs/vite": "5.0.0-canary.2503",
|
|
46
|
+
"@cedarjs/web-server": "5.0.0-canary.2503",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.1",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|