draw2sql 1.0.0-beta.1 → 1.0.0-beta.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/README.md +8 -0
- package/dist/draw2sql.js +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ No install needed. `npx` downloads and runs draw2sql on the fly:
|
|
|
20
20
|
npx draw2sql --input schema.drawio --dialect postgres
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
On first use, `npx` may prompt: _"Need to install the following packages: draw2sql. Ok to proceed?"_ — press `y` to continue. The package is cached in a temp location and the prompt won't appear again until the cache expires.
|
|
24
|
+
|
|
23
25
|
### Install as a project dev dependency
|
|
24
26
|
|
|
25
27
|
Add draw2sql to a project's dev dependencies so it's available via `npx` without downloading each time:
|
|
@@ -117,6 +119,12 @@ When present, recognized keys are captured and included in SQL output comments.
|
|
|
117
119
|
- `dialect` (also `sqldialect`, `flavor`, `sqlFlavor`) overrides the CLI dialect.
|
|
118
120
|
- `schema` qualifies generated table names (e.g. `"myschema"."users"`). If omitted, table names are unqualified and the database will use its session default (`public` for postgres, `dbo` for sqlserver, the connected user's schema for oracle, etc.). Ignored for `sqlite`, which has no schema concept.
|
|
119
121
|
|
|
122
|
+
## Multi-page diagrams
|
|
123
|
+
|
|
124
|
+
If your draw.io file has multiple pages (tabs), draw2sql merges all tables from all pages into a single SQL output file. There is no per-page separation. This is useful when pages represent subject areas of the same schema; if your pages represent entirely separate schemas, run draw2sql once per file.
|
|
125
|
+
|
|
126
|
+
> **Note:** draw2sql requires the diagram to be saved in uncompressed XML format. If a page's content appears compressed (draw.io can optionally base64-encode page content), that page's tables will be silently skipped.
|
|
127
|
+
|
|
120
128
|
## Output strategy
|
|
121
129
|
|
|
122
130
|
Generated SQL is idempotent-oriented and includes:
|
package/dist/draw2sql.js
CHANGED
|
@@ -222,7 +222,16 @@ class CliParser {
|
|
|
222
222
|
console.log(CliParser.HELP);
|
|
223
223
|
process.exit(0);
|
|
224
224
|
}
|
|
225
|
-
const
|
|
225
|
+
const flagsWithValues = new Set(["--input", "-i", "--output", "-o", "--dialect", "-d", "--schema", "--table-case", "--table-style", "--field-case", "--column-case", "--field-style", "--column-style"]);
|
|
226
|
+
const positional = [];
|
|
227
|
+
for (let i = 0; i < argv.length; i++) {
|
|
228
|
+
if (flagsWithValues.has(argv[i])) {
|
|
229
|
+
i++;
|
|
230
|
+
}
|
|
231
|
+
else if (!argv[i].startsWith("-")) {
|
|
232
|
+
positional.push(argv[i]);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
226
235
|
let inputFile = "";
|
|
227
236
|
let outputFile = "";
|
|
228
237
|
let dialect = "";
|
|
@@ -947,6 +956,10 @@ class Draw2SqlApp {
|
|
|
947
956
|
generator = new SqlGenerator();
|
|
948
957
|
run(argv) {
|
|
949
958
|
const args = CliParser.parse(argv);
|
|
959
|
+
if (!node_fs_1.default.existsSync(args.inputFile)) {
|
|
960
|
+
console.error(`Input file not found: ${args.inputFile}`);
|
|
961
|
+
process.exit(1);
|
|
962
|
+
}
|
|
950
963
|
const xml = node_fs_1.default.readFileSync(args.inputFile, "utf8");
|
|
951
964
|
const parsed = this.parser.parse(xml);
|
|
952
965
|
const generated = this.generator.generate(parsed, args.dialect, { tableCase: args.tableCase, fieldCase: args.fieldCase }, args.schema);
|