@cedarjs/cli 5.0.0-canary.2332 → 5.0.0-canary.2333
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.
|
@@ -104,12 +104,17 @@ const handler = async ({
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
if (workspace.includes("api")) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
if (generate) {
|
|
108
|
+
try {
|
|
109
|
+
await generatePrismaClient({ verbose: false });
|
|
110
|
+
} catch (e) {
|
|
111
|
+
const message = getErrorMessage(e);
|
|
112
|
+
errorTelemetry(
|
|
113
|
+
process.argv,
|
|
114
|
+
`Error generating prisma client: ${message}`
|
|
115
|
+
);
|
|
116
|
+
console.error(c.error(message));
|
|
117
|
+
}
|
|
113
118
|
}
|
|
114
119
|
if (!ud && !serverFile) {
|
|
115
120
|
try {
|
|
@@ -440,7 +440,7 @@ async function downloadYarnPatches(ctx, { dryRun, verbose }) {
|
|
|
440
440
|
}
|
|
441
441
|
async function refreshPrismaClient(task, { verbose }) {
|
|
442
442
|
try {
|
|
443
|
-
await generatePrismaClient({ verbose, force:
|
|
443
|
+
await generatePrismaClient({ verbose, force: true });
|
|
444
444
|
} catch (e) {
|
|
445
445
|
const message = e instanceof Error ? e.message : String(e);
|
|
446
446
|
task.skip("Refreshing the Prisma client caused an Error.");
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
resolveGeneratedPrismaClient
|
|
6
|
-
} from "@cedarjs/project-config";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { getConfig, getPrismaSchemas } from "@cedarjs/project-config";
|
|
7
6
|
import { runCommandTask, getPaths } from "./index.js";
|
|
8
7
|
const generatePrismaCommand = async () => {
|
|
9
8
|
const config = getConfig();
|
|
@@ -19,15 +18,47 @@ const generatePrismaCommand = async () => {
|
|
|
19
18
|
]
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
|
-
|
|
21
|
+
async function computePrismaSchemaHash() {
|
|
22
|
+
try {
|
|
23
|
+
const hash = createHash("sha256");
|
|
24
|
+
const configPath = getPaths().api.prismaConfig;
|
|
25
|
+
if (fs.existsSync(configPath)) {
|
|
26
|
+
hash.update(fs.readFileSync(configPath));
|
|
27
|
+
}
|
|
28
|
+
const { schemas } = await getPrismaSchemas();
|
|
29
|
+
for (const schema of schemas) {
|
|
30
|
+
hash.update(schema[1]);
|
|
31
|
+
}
|
|
32
|
+
return hash.digest("hex");
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function getHashFilePath() {
|
|
38
|
+
const generatedBase = getPaths().generated.base;
|
|
39
|
+
return path.join(generatedBase, "prisma-schema-hash");
|
|
40
|
+
}
|
|
41
|
+
function getStoredSchemaHash() {
|
|
42
|
+
const hashFile = getHashFilePath();
|
|
43
|
+
if (fs.existsSync(hashFile)) {
|
|
44
|
+
return fs.readFileSync(hashFile, "utf-8").trim();
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function storeSchemaHash(hash) {
|
|
49
|
+
const hashFile = getHashFilePath();
|
|
50
|
+
fs.mkdirSync(path.dirname(hashFile), { recursive: true });
|
|
51
|
+
fs.writeFileSync(hashFile, hash);
|
|
52
|
+
}
|
|
53
|
+
async function generatePrismaClient({
|
|
23
54
|
verbose = true,
|
|
24
|
-
force =
|
|
55
|
+
force = false,
|
|
25
56
|
silent = false
|
|
26
|
-
} = {})
|
|
57
|
+
} = {}) {
|
|
58
|
+
const hash = await computePrismaSchemaHash();
|
|
27
59
|
if (!force) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
if (!prismaClientFile.includes("@prisma/client did not initialize yet.") && prismaClientFile.includes("exports.Prisma.")) {
|
|
60
|
+
const storedHash = hash ? getStoredSchemaHash() : null;
|
|
61
|
+
if (hash !== null && hash === storedHash) {
|
|
31
62
|
return;
|
|
32
63
|
}
|
|
33
64
|
}
|
|
@@ -43,7 +74,10 @@ const generatePrismaClient = async ({
|
|
|
43
74
|
silent
|
|
44
75
|
}
|
|
45
76
|
);
|
|
46
|
-
|
|
77
|
+
if (hash !== null) {
|
|
78
|
+
storeSchemaHash(hash);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
47
81
|
export {
|
|
48
82
|
generatePrismaClient,
|
|
49
83
|
generatePrismaCommand
|
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.2333",
|
|
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.2333",
|
|
37
|
+
"@cedarjs/cli-helpers": "5.0.0-canary.2333",
|
|
38
|
+
"@cedarjs/fastify-web": "5.0.0-canary.2333",
|
|
39
|
+
"@cedarjs/internal": "5.0.0-canary.2333",
|
|
40
|
+
"@cedarjs/prerender": "5.0.0-canary.2333",
|
|
41
|
+
"@cedarjs/project-config": "5.0.0-canary.2333",
|
|
42
|
+
"@cedarjs/structure": "5.0.0-canary.2333",
|
|
43
|
+
"@cedarjs/telemetry": "5.0.0-canary.2333",
|
|
44
|
+
"@cedarjs/utils": "5.0.0-canary.2333",
|
|
45
|
+
"@cedarjs/vite": "5.0.0-canary.2333",
|
|
46
|
+
"@cedarjs/web-server": "5.0.0-canary.2333",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.0",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|