omni-rest 0.2.4 → 0.2.6
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/cli.js +29 -9
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +29 -9
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -554,9 +554,14 @@ Please check that the path is correct and the file is readable.`
|
|
|
554
554
|
}
|
|
555
555
|
let current = path__namespace.resolve(startDir);
|
|
556
556
|
while (true) {
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
557
|
+
const candidates = [
|
|
558
|
+
path__namespace.join(current, "prisma", "schema.prisma"),
|
|
559
|
+
path__namespace.join(current, "schema.prisma")
|
|
560
|
+
];
|
|
561
|
+
for (const candidate of candidates) {
|
|
562
|
+
if (fs3__namespace.existsSync(candidate)) {
|
|
563
|
+
return candidate;
|
|
564
|
+
}
|
|
560
565
|
}
|
|
561
566
|
const parent = path__namespace.dirname(current);
|
|
562
567
|
if (parent === current) {
|
|
@@ -568,20 +573,36 @@ Please run this command from within your Prisma project, or specify the path wit
|
|
|
568
573
|
current = parent;
|
|
569
574
|
}
|
|
570
575
|
}
|
|
571
|
-
async function loadDMMF(
|
|
576
|
+
async function loadDMMF(frontendDir, schemaPath) {
|
|
577
|
+
let clientPath = null;
|
|
578
|
+
try {
|
|
579
|
+
const schemaContent = fs3__namespace.readFileSync(schemaPath, "utf-8");
|
|
580
|
+
const outputMatch = schemaContent.match(/output\s*=\s*["']([^"']+)["']/);
|
|
581
|
+
if (outputMatch) {
|
|
582
|
+
const schemaDir = path__namespace.dirname(schemaPath);
|
|
583
|
+
const customOutput = path__namespace.resolve(schemaDir, outputMatch[1]);
|
|
584
|
+
if (fs3__namespace.existsSync(customOutput)) {
|
|
585
|
+
clientPath = customOutput;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
} catch {
|
|
589
|
+
}
|
|
590
|
+
if (!clientPath) {
|
|
591
|
+
clientPath = path__namespace.join(frontendDir, "node_modules", "@prisma", "client");
|
|
592
|
+
}
|
|
572
593
|
let prismaClientModule;
|
|
573
594
|
try {
|
|
574
|
-
prismaClientModule = __require(
|
|
595
|
+
prismaClientModule = __require(clientPath);
|
|
575
596
|
} catch (err) {
|
|
576
597
|
throw new Error(
|
|
577
|
-
`[omni-rest] Could not load "@prisma/client" from "${
|
|
598
|
+
`[omni-rest] Could not load "@prisma/client" from "${clientPath}".
|
|
578
599
|
Please run "npx prisma generate" to generate the Prisma client, then try again.`
|
|
579
600
|
);
|
|
580
601
|
}
|
|
581
602
|
const prismaNamespace = prismaClientModule?.Prisma ?? prismaClientModule?.default?.Prisma;
|
|
582
603
|
if (!prismaNamespace?.dmmf?.datamodel?.models) {
|
|
583
604
|
throw new Error(
|
|
584
|
-
`[omni-rest] Could not read DMMF from "@prisma/client" at "${
|
|
605
|
+
`[omni-rest] Could not read DMMF from "@prisma/client" at "${clientPath}".
|
|
585
606
|
Please run "npx prisma generate" to regenerate the Prisma client, then try again.`
|
|
586
607
|
);
|
|
587
608
|
}
|
|
@@ -1459,10 +1480,9 @@ async function run(argv) {
|
|
|
1459
1480
|
console.error(COLORS.red(` \u2717 ${err.message}`));
|
|
1460
1481
|
process.exit(1);
|
|
1461
1482
|
}
|
|
1462
|
-
const prismaClientPath = path__namespace.join(frontendDir, "node_modules", "@prisma", "client");
|
|
1463
1483
|
let allModels;
|
|
1464
1484
|
try {
|
|
1465
|
-
allModels = await loadDMMF(
|
|
1485
|
+
allModels = await loadDMMF(frontendDir, resolvedSchemaPath);
|
|
1466
1486
|
console.log(COLORS.cyan(` \u2192 Found ${allModels.length} model(s): ${allModels.map((m) => m.name).join(", ")}`));
|
|
1467
1487
|
} catch (err) {
|
|
1468
1488
|
console.error(COLORS.red(` \u2717 ${err.message}`));
|