nexusql 0.6.0 → 0.6.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 +17 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3211,10 +3211,9 @@ var Database = class _Database {
|
|
|
3211
3211
|
};
|
|
3212
3212
|
|
|
3213
3213
|
// src/lib/dbml.ts
|
|
3214
|
-
import {
|
|
3214
|
+
import { exporter } from "@dbml/core";
|
|
3215
3215
|
function dbmlToSql(dbmlContent) {
|
|
3216
|
-
const
|
|
3217
|
-
const sql = ModelExporter.export(database, "postgres");
|
|
3216
|
+
const sql = exporter.export(dbmlContent, "postgres");
|
|
3218
3217
|
return { sql };
|
|
3219
3218
|
}
|
|
3220
3219
|
|
|
@@ -3686,7 +3685,11 @@ function getReadline() {
|
|
|
3686
3685
|
if (!rl) {
|
|
3687
3686
|
rl = readline.createInterface({
|
|
3688
3687
|
input: process.stdin,
|
|
3689
|
-
output: process.stdout
|
|
3688
|
+
output: process.stdout,
|
|
3689
|
+
terminal: process.stdin.isTTY ?? false
|
|
3690
|
+
});
|
|
3691
|
+
rl.on("close", () => {
|
|
3692
|
+
rl = null;
|
|
3690
3693
|
});
|
|
3691
3694
|
}
|
|
3692
3695
|
return rl;
|
|
@@ -3698,8 +3701,14 @@ function closePrompts() {
|
|
|
3698
3701
|
}
|
|
3699
3702
|
}
|
|
3700
3703
|
function question(query) {
|
|
3701
|
-
return new Promise((resolve3) => {
|
|
3702
|
-
getReadline()
|
|
3704
|
+
return new Promise((resolve3, reject) => {
|
|
3705
|
+
const readline2 = getReadline();
|
|
3706
|
+
const closeHandler = () => {
|
|
3707
|
+
reject(new Error("Readline closed unexpectedly"));
|
|
3708
|
+
};
|
|
3709
|
+
readline2.once("close", closeHandler);
|
|
3710
|
+
readline2.question(query, (answer) => {
|
|
3711
|
+
readline2.removeListener("close", closeHandler);
|
|
3703
3712
|
resolve3(answer);
|
|
3704
3713
|
});
|
|
3705
3714
|
});
|
|
@@ -3974,7 +3983,7 @@ import { readFileSync as readFileSync3, writeFileSync as writeFileSync4 } from "
|
|
|
3974
3983
|
import { resolve as resolve2 } from "path";
|
|
3975
3984
|
|
|
3976
3985
|
// src/lib/types-generator.ts
|
|
3977
|
-
import { Parser
|
|
3986
|
+
import { Parser } from "@dbml/core";
|
|
3978
3987
|
var TYPE_MAP = {
|
|
3979
3988
|
// Numbers
|
|
3980
3989
|
int: "number",
|
|
@@ -4022,7 +4031,7 @@ function toPascalCase(str) {
|
|
|
4022
4031
|
return str.replace(/(?:^|[-_])(\w)/g, (_, c) => c.toUpperCase()).replace(/[-_]/g, "");
|
|
4023
4032
|
}
|
|
4024
4033
|
function generateTypes(dbmlContent) {
|
|
4025
|
-
const database = new
|
|
4034
|
+
const database = new Parser().parse(dbmlContent, "dbml");
|
|
4026
4035
|
const tables = database.schemas.flatMap((s) => s.tables);
|
|
4027
4036
|
const enums = database.schemas.flatMap((s) => s.enums);
|
|
4028
4037
|
let output = `/**
|