omni-rest 0.2.1 → 0.2.2
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 +24 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +24 -1
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1559,13 +1559,36 @@ function tryLoadFromSchemaOutput() {
|
|
|
1559
1559
|
const mod = __require(indexPath);
|
|
1560
1560
|
const PrismaClient = mod.PrismaClient ?? mod.default?.PrismaClient;
|
|
1561
1561
|
if (!PrismaClient) continue;
|
|
1562
|
-
|
|
1562
|
+
const providerMatch = schema.match(/provider\s*=\s*["']([^"']+)["']/);
|
|
1563
|
+
const provider = providerMatch?.[1] ?? "postgresql";
|
|
1564
|
+
const dummyUrl = getDummyUrl(provider);
|
|
1565
|
+
try {
|
|
1566
|
+
return new PrismaClient({ datasourceUrl: dummyUrl });
|
|
1567
|
+
} catch {
|
|
1568
|
+
return new PrismaClient();
|
|
1569
|
+
}
|
|
1563
1570
|
} catch {
|
|
1564
1571
|
continue;
|
|
1565
1572
|
}
|
|
1566
1573
|
}
|
|
1567
1574
|
return null;
|
|
1568
1575
|
}
|
|
1576
|
+
function getDummyUrl(provider) {
|
|
1577
|
+
switch (provider) {
|
|
1578
|
+
case "mysql":
|
|
1579
|
+
return "mysql://root:root@localhost:3306/dummy";
|
|
1580
|
+
case "sqlite":
|
|
1581
|
+
return "file:./dummy.db";
|
|
1582
|
+
case "sqlserver":
|
|
1583
|
+
return "sqlserver://localhost:1433;database=dummy;user=sa;password=dummy";
|
|
1584
|
+
case "mongodb":
|
|
1585
|
+
return "mongodb://localhost:27017/dummy";
|
|
1586
|
+
case "cockroachdb":
|
|
1587
|
+
return "postgresql://root@localhost:26257/dummy";
|
|
1588
|
+
default:
|
|
1589
|
+
return "postgresql://postgres:postgres@localhost:5432/dummy";
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1569
1592
|
var USAGE = `
|
|
1570
1593
|
Usage:
|
|
1571
1594
|
npx omni-rest generate Generate both Zod schemas and OpenAPI spec
|