omni-rest 0.2.5 → 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 +21 -6
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +21 -6
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -573,20 +573,36 @@ Please run this command from within your Prisma project, or specify the path wit
|
|
|
573
573
|
current = parent;
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
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
|
+
}
|
|
577
593
|
let prismaClientModule;
|
|
578
594
|
try {
|
|
579
|
-
prismaClientModule = __require(
|
|
595
|
+
prismaClientModule = __require(clientPath);
|
|
580
596
|
} catch (err) {
|
|
581
597
|
throw new Error(
|
|
582
|
-
`[omni-rest] Could not load "@prisma/client" from "${
|
|
598
|
+
`[omni-rest] Could not load "@prisma/client" from "${clientPath}".
|
|
583
599
|
Please run "npx prisma generate" to generate the Prisma client, then try again.`
|
|
584
600
|
);
|
|
585
601
|
}
|
|
586
602
|
const prismaNamespace = prismaClientModule?.Prisma ?? prismaClientModule?.default?.Prisma;
|
|
587
603
|
if (!prismaNamespace?.dmmf?.datamodel?.models) {
|
|
588
604
|
throw new Error(
|
|
589
|
-
`[omni-rest] Could not read DMMF from "@prisma/client" at "${
|
|
605
|
+
`[omni-rest] Could not read DMMF from "@prisma/client" at "${clientPath}".
|
|
590
606
|
Please run "npx prisma generate" to regenerate the Prisma client, then try again.`
|
|
591
607
|
);
|
|
592
608
|
}
|
|
@@ -1464,10 +1480,9 @@ async function run(argv) {
|
|
|
1464
1480
|
console.error(COLORS.red(` \u2717 ${err.message}`));
|
|
1465
1481
|
process.exit(1);
|
|
1466
1482
|
}
|
|
1467
|
-
const prismaClientPath = path__namespace.join(frontendDir, "node_modules", "@prisma", "client");
|
|
1468
1483
|
let allModels;
|
|
1469
1484
|
try {
|
|
1470
|
-
allModels = await loadDMMF(
|
|
1485
|
+
allModels = await loadDMMF(frontendDir, resolvedSchemaPath);
|
|
1471
1486
|
console.log(COLORS.cyan(` \u2192 Found ${allModels.length} model(s): ${allModels.map((m) => m.name).join(", ")}`));
|
|
1472
1487
|
} catch (err) {
|
|
1473
1488
|
console.error(COLORS.red(` \u2717 ${err.message}`));
|