extract-mysql-schema 0.0.8 → 0.0.9
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/example.js +10 -0
- package/package.json +1 -1
- package/run.js +44 -10
package/example.js
ADDED
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -1,16 +1,50 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
1
2
|
const { extractSchemas } = require('./index.js');
|
|
2
3
|
|
|
3
|
-
async function
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
async function main(options) {
|
|
5
|
+
const config = require(options.configFile);
|
|
6
|
+
const result = await extractSchemas(config.connection);
|
|
7
|
+
if(options.outputFile) {
|
|
8
|
+
fs.writeFileSync(options.outputFile, JSON.stringify(result,null,2) ,"utf8")
|
|
9
|
+
} else console.log(JSON.stringify(result,null,2));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let options = {
|
|
13
|
+
configFile:"",
|
|
14
|
+
outputFile:"",
|
|
15
|
+
}
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
if (process.argv.length === 2) {
|
|
18
|
+
console.error('Expected at least one argument!');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
} else {
|
|
21
|
+
let argv = process.argv;
|
|
12
22
|
|
|
13
|
-
|
|
23
|
+
for(let i=2;i<argv.length;i++) {
|
|
24
|
+
if(argv[i].substring(0,2)==="--") {
|
|
25
|
+
let name = argv[i].substring(2);
|
|
26
|
+
if(options[name]!==undefined) {
|
|
27
|
+
options[name] = argv[i+1];
|
|
28
|
+
i++;
|
|
29
|
+
} else {
|
|
30
|
+
console.error('Expected a known option');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
14
35
|
}
|
|
15
36
|
|
|
16
|
-
|
|
37
|
+
(async () => {
|
|
38
|
+
try {
|
|
39
|
+
console.log('\x1b[32m%s\x1b[0m',"Running with options:\n",JSON.stringify(options,null,2));
|
|
40
|
+
main(options).then(()=>{
|
|
41
|
+
if(options.debug) console.log("DONE");
|
|
42
|
+
process.exit(0);
|
|
43
|
+
},()=>{
|
|
44
|
+
if(options.debug) console.log("ERROR");
|
|
45
|
+
process.exit(1);
|
|
46
|
+
})
|
|
47
|
+
} catch (e) {
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
})();
|