-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
27 lines (23 loc) · 912 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const fsp = require('node:fs/promises');
const path = require('node:path');
const createSqlStructure = require('./lib/sqlStructure.js');
const createVba = require('./lib/vbaStructure.js');
const staticServer = require('./lib/static.js');
const SCHEMAS = path.join(process.cwd(), './schemas');
const DB = path.join(process.cwd(), './db');
const STATIC_PORT = 3000;
(async () => {
const schemas = await fsp.readdir(SCHEMAS);
for (const schemaFile of schemas) {
const schema = require(path.join(SCHEMAS, schemaFile));
const schemaName = schemaFile.split('.')[0];
const name = schemaName + '-' + schema.method;
const sql = createSqlStructure(schema, schemaName);
const vba = createVba(name, sql);
await fsp.writeFile(`${DB}/${name}.bas`, vba);
}
console.log('successful! \r\n All schemas are loadede in db directory')
})().catch((err) => {
console.error(err);
});