@cedarjs/cli 1.0.0-canary.12739 → 1.0.0-canary.12740
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/generate/helpers.js +1 -1
- package/dist/commands/generate/service/serviceHandler.js +5 -2
- package/dist/commands/generate/service/templates/test.ts.template +1 -1
- package/dist/commands/record/init.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +3 -3
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +3 -3
- package/dist/commands/setup/deploy/providers/renderHandler.js +3 -3
- package/dist/commands/setup/jobs/jobsHandler.js +3 -3
- package/dist/lib/schemaHelpers.js +11 -8
- package/package.json +13 -13
|
@@ -52,7 +52,7 @@ const scenarioFieldValue = (field) => {
|
|
|
52
52
|
case "String":
|
|
53
53
|
return field.isUnique ? `String${randInt}` : "String";
|
|
54
54
|
case "Bytes":
|
|
55
|
-
return `
|
|
55
|
+
return `new Uint8Array([${randIntArray}])`;
|
|
56
56
|
default: {
|
|
57
57
|
if (field.kind === "enum" && field.enumValues[0]) {
|
|
58
58
|
return field.enumValues[0].dbName || field.enumValues[0].name;
|
|
@@ -118,7 +118,10 @@ const buildStringifiedScenario = async (model) => {
|
|
|
118
118
|
}
|
|
119
119
|
return value;
|
|
120
120
|
});
|
|
121
|
-
return jsonString.replace(
|
|
121
|
+
return jsonString.replace(
|
|
122
|
+
/"new Uint8Array\(([^)]+)\)"/g,
|
|
123
|
+
"new Uint8Array($1)"
|
|
124
|
+
);
|
|
122
125
|
};
|
|
123
126
|
const fieldTypes = async (model) => {
|
|
124
127
|
const { scalarFields } = await parseSchema(model);
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
// Not all values can be represented as JSON, like function invocations
|
|
32
|
-
return jsonString.replace(/"
|
|
32
|
+
return jsonString.replace(/"new Uint8Array\(([^)]+)\)"/g, 'new Uint8Array($1)')
|
|
33
33
|
} %>
|
|
34
34
|
<% if (prismaImport) { %>import { Prisma, ${prismaModel} } from '@prisma/client'<% } else { %>import type { ${prismaModel} } from '@prisma/client'<% } %>
|
|
35
35
|
|
|
@@ -12,7 +12,7 @@ import { errorTelemetry } from "@cedarjs/telemetry";
|
|
|
12
12
|
import { printSetupNotes } from "../../../../lib/index.js";
|
|
13
13
|
import { serverFileExists } from "../../../../lib/project.js";
|
|
14
14
|
import { addFilesTask } from "../helpers/index.js";
|
|
15
|
-
const {
|
|
15
|
+
const { getSchemaWithPath, getConfig } = prismaInternals;
|
|
16
16
|
const redwoodProjectPaths = getPaths();
|
|
17
17
|
const EXTENSION = isTypeScriptProject ? "ts" : "js";
|
|
18
18
|
async function handler({ force }) {
|
|
@@ -57,8 +57,8 @@ async function getAddCoherenceFilesTask(force) {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
async function getCoherenceConfigFileContent() {
|
|
60
|
-
const
|
|
61
|
-
const prismaConfig = await getConfig({ datamodel:
|
|
60
|
+
const result = await getSchemaWithPath(redwoodProjectPaths.api.dbSchema);
|
|
61
|
+
const prismaConfig = await getConfig({ datamodel: result.schemas });
|
|
62
62
|
let db = prismaConfig.datasources[0].activeProvider;
|
|
63
63
|
if (!SUPPORTED_DATABASES.includes(db)) {
|
|
64
64
|
throw new Error(
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
postgresDatabaseService,
|
|
19
19
|
mysqlDatabaseService
|
|
20
20
|
} from "../templates/flightcontrol.js";
|
|
21
|
-
const {
|
|
21
|
+
const { getSchemaWithPath, getConfig } = prismaInternals;
|
|
22
22
|
const getFlightcontrolJson = async (database) => {
|
|
23
23
|
if (database === "none") {
|
|
24
24
|
return {
|
|
@@ -29,10 +29,10 @@ const getFlightcontrolJson = async (database) => {
|
|
|
29
29
|
if (!fs.existsSync(path.join(getPaths().base, "api/db/schema.prisma"))) {
|
|
30
30
|
throw new Error("Could not find prisma schema at 'api/db/schema.prisma'");
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const result = await getSchemaWithPath(
|
|
33
33
|
path.join(getPaths().base, "api/db/schema.prisma")
|
|
34
34
|
);
|
|
35
|
-
const config = await getConfig({ datamodel:
|
|
35
|
+
const config = await getConfig({ datamodel: result.schemas });
|
|
36
36
|
const detectedDatabase = config.datasources[0].activeProvider;
|
|
37
37
|
if (detectedDatabase === database) {
|
|
38
38
|
let dbService;
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
RENDER_YAML,
|
|
18
18
|
SQLITE_YAML
|
|
19
19
|
} from "../templates/render.js";
|
|
20
|
-
const {
|
|
20
|
+
const { getSchemaWithPath, getConfig } = prismaInternals;
|
|
21
21
|
const getRenderYamlContent = async (database) => {
|
|
22
22
|
if (database === "none") {
|
|
23
23
|
return {
|
|
@@ -28,8 +28,8 @@ const getRenderYamlContent = async (database) => {
|
|
|
28
28
|
if (!fs.existsSync("api/db/schema.prisma")) {
|
|
29
29
|
throw new Error("Could not find prisma schema at 'api/db/schema.prisma'");
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
const config = await getConfig({ datamodel:
|
|
31
|
+
const { schemas } = await getSchemaWithPath("api/db/schema.prisma");
|
|
32
|
+
const config = await getConfig({ datamodel: schemas });
|
|
33
33
|
const detectedDatabase = config.datasources[0].activeProvider;
|
|
34
34
|
if (detectedDatabase === database) {
|
|
35
35
|
switch (database) {
|
|
@@ -6,6 +6,7 @@ import { addApiPackages } from "@cedarjs/cli-helpers";
|
|
|
6
6
|
import c from "../../../lib/colors.js";
|
|
7
7
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
8
8
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
9
|
+
const { getDMMF, getSchemaWithPath } = prismaInternals;
|
|
9
10
|
const MODEL_SCHEMA = `
|
|
10
11
|
model BackgroundJob {
|
|
11
12
|
id Int @id @default(autoincrement())
|
|
@@ -24,9 +25,8 @@ model BackgroundJob {
|
|
|
24
25
|
}
|
|
25
26
|
`;
|
|
26
27
|
const getModelNames = async () => {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
});
|
|
28
|
+
const { schemas } = await getSchemaWithPath(getPaths().api.dbSchema);
|
|
29
|
+
const schema = await getDMMF({ datamodel: schemas });
|
|
30
30
|
return schema.datamodel.models.map((model) => model.name);
|
|
31
31
|
};
|
|
32
32
|
const addDatabaseModel = () => {
|
|
@@ -2,7 +2,7 @@ import prismaInternals from "@prisma/internals";
|
|
|
2
2
|
import { ensureUniquePlural } from "./pluralHelpers.js";
|
|
3
3
|
import { singularize, isPlural } from "./rwPluralize.js";
|
|
4
4
|
import { getPaths } from "./index.js";
|
|
5
|
-
const { getConfig, getDMMF,
|
|
5
|
+
const { getConfig, getDMMF, getSchemaWithPath } = prismaInternals;
|
|
6
6
|
const schemaMemo = {};
|
|
7
7
|
const getExistingModelName = async (name) => {
|
|
8
8
|
if (!name) {
|
|
@@ -62,15 +62,18 @@ const getEnum = async (name) => {
|
|
|
62
62
|
}
|
|
63
63
|
return model;
|
|
64
64
|
};
|
|
65
|
-
const getDataModel = (path = getPaths().api.dbSchema) => {
|
|
66
|
-
|
|
65
|
+
const getDataModel = async (path = getPaths().api.dbSchema) => {
|
|
66
|
+
const result = await getSchemaWithPath(path);
|
|
67
|
+
return result.schemas;
|
|
67
68
|
};
|
|
68
|
-
const getSchemaDefinitions = () => {
|
|
69
|
-
return getDMMF({ datamodel: getDataModel() });
|
|
69
|
+
const getSchemaDefinitions = async () => {
|
|
70
|
+
return getDMMF({ datamodel: await getDataModel() });
|
|
71
|
+
};
|
|
72
|
+
const getSchemaConfig = async () => {
|
|
73
|
+
return getConfig({
|
|
74
|
+
datamodel: await getDataModel()
|
|
75
|
+
});
|
|
70
76
|
};
|
|
71
|
-
const getSchemaConfig = () => getConfig({
|
|
72
|
-
datamodel: getDataModel()
|
|
73
|
-
});
|
|
74
77
|
async function verifyModelName(options) {
|
|
75
78
|
const modelName = await getExistingModelName(options.name) || await getExistingModelName(singularize(options.name));
|
|
76
79
|
if (modelName === void 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.12740+f0a895812",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/preset-typescript": "7.27.1",
|
|
34
34
|
"@babel/runtime-corejs3": "7.27.6",
|
|
35
|
-
"@cedarjs/api-server": "1.0.0-canary.
|
|
36
|
-
"@cedarjs/cli-helpers": "1.0.0-canary.
|
|
37
|
-
"@cedarjs/fastify-web": "1.0.0-canary.
|
|
38
|
-
"@cedarjs/internal": "1.0.0-canary.
|
|
39
|
-
"@cedarjs/prerender": "1.0.0-canary.
|
|
40
|
-
"@cedarjs/project-config": "1.0.0-canary.
|
|
41
|
-
"@cedarjs/structure": "1.0.0-canary.
|
|
42
|
-
"@cedarjs/telemetry": "1.0.0-canary.
|
|
43
|
-
"@cedarjs/web-server": "1.0.0-canary.
|
|
35
|
+
"@cedarjs/api-server": "1.0.0-canary.12740",
|
|
36
|
+
"@cedarjs/cli-helpers": "1.0.0-canary.12740",
|
|
37
|
+
"@cedarjs/fastify-web": "1.0.0-canary.12740",
|
|
38
|
+
"@cedarjs/internal": "1.0.0-canary.12740",
|
|
39
|
+
"@cedarjs/prerender": "1.0.0-canary.12740",
|
|
40
|
+
"@cedarjs/project-config": "1.0.0-canary.12740",
|
|
41
|
+
"@cedarjs/structure": "1.0.0-canary.12740",
|
|
42
|
+
"@cedarjs/telemetry": "1.0.0-canary.12740",
|
|
43
|
+
"@cedarjs/web-server": "1.0.0-canary.12740",
|
|
44
44
|
"@listr2/prompt-adapter-enquirer": "2.0.16",
|
|
45
45
|
"@opentelemetry/api": "1.8.0",
|
|
46
46
|
"@opentelemetry/core": "1.22.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@opentelemetry/resources": "1.22.0",
|
|
49
49
|
"@opentelemetry/sdk-trace-node": "1.22.0",
|
|
50
50
|
"@opentelemetry/semantic-conventions": "1.22.0",
|
|
51
|
-
"@prisma/internals": "
|
|
51
|
+
"@prisma/internals": "6.19.0",
|
|
52
52
|
"ansis": "4.1.0",
|
|
53
53
|
"archiver": "7.0.1",
|
|
54
54
|
"boxen": "5.1.2",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"pluralize": "8.0.0",
|
|
76
76
|
"portfinder": "1.0.37",
|
|
77
77
|
"prettier": "3.6.2",
|
|
78
|
-
"prisma": "
|
|
78
|
+
"prisma": "6.19.0",
|
|
79
79
|
"prompts": "2.4.2",
|
|
80
80
|
"rimraf": "6.0.1",
|
|
81
81
|
"semver": "7.6.3",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "f0a895812c12da9685816504885c2e77968fc9c0"
|
|
106
106
|
}
|