dbmodel 0.1.2 → 5.2.2-alpha.11
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/LICENSE +21 -21
- package/README.md +88 -116
- package/bin/dbmodel.js +118 -81
- package/package.json +45 -47
- package/lib/build.js +0 -24
- package/lib/clients/mssql/build.js +0 -191
- package/lib/clients/mssql/connect.js +0 -9
- package/lib/clients/mssql/deploy.js +0 -343
- package/lib/clients/mssql/getsql.js +0 -140
- package/lib/clients/mssql/load.js +0 -210
- package/lib/clients/mssql/query.js +0 -6
- package/lib/connect.js +0 -8
- package/lib/deploy.js +0 -22
- package/lib/dump.js +0 -38
- package/lib/efmodel.js +0 -132
- package/lib/hooks/autoIndexForeignKeys.js +0 -23
- package/lib/hooks/index.js +0 -3
- package/lib/hooks/runHooks.js +0 -10
- package/lib/index.js +0 -20
- package/lib/load.js +0 -22
- package/lib/query.js +0 -7
- package/lib/read.js +0 -61
- package/lib/runAndExit.js +0 -13
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 dbshell
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 dbshell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,116 +1,88 @@
|
|
|
1
|
-
# dbmodel
|
|
2
|
-
Deploy, load or build script from model of SQL database. Can be used as command-line tool or as javascript functions
|
|
3
|
-
|
|
4
|
-
Model is stored as a collection of files:
|
|
5
|
-
* tables - stored as YAML files
|
|
6
|
-
* columns
|
|
7
|
-
* indexes
|
|
8
|
-
* primary keys
|
|
9
|
-
* foreign keys
|
|
10
|
-
* views - stored as SQL file with extension **.view.sql**
|
|
11
|
-
* stored procedures - stored as SQL file with extension **.proc.sql**
|
|
12
|
-
* functions - stored as SQL file with extension **.func.sql**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* checks
|
|
30
|
-
* checks
|
|
31
|
-
* checks
|
|
32
|
-
* checks
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* creates not existing
|
|
38
|
-
* creates not existing
|
|
39
|
-
* creates
|
|
40
|
-
* creates
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
type: int # data type. is used directly in target SQL engine
|
|
90
|
-
autoIncrement: true # column is autoincrement
|
|
91
|
-
notNull: true # column is not nullable (default: is nullable)
|
|
92
|
-
- name: Title
|
|
93
|
-
type: nvarchar
|
|
94
|
-
length: 160 # maximum character length
|
|
95
|
-
notNull: true
|
|
96
|
-
- name: ArtistId
|
|
97
|
-
type: int
|
|
98
|
-
references: Artist # name of table. Is used for creating foreign key
|
|
99
|
-
- name: isDeleted
|
|
100
|
-
type: bit
|
|
101
|
-
notNull: true
|
|
102
|
-
default: 0 # default value
|
|
103
|
-
primaryKey:
|
|
104
|
-
- AlbumId # list of primary key column names
|
|
105
|
-
indexes:
|
|
106
|
-
- name: UQ_AlbumTitleArtistId # index name
|
|
107
|
-
unique: true # whether index is unique. default=false
|
|
108
|
-
columns: # list of index columns
|
|
109
|
-
- Title
|
|
110
|
-
- ArtistId
|
|
111
|
-
filter: isDeleted=0 # if defined, filtered index (with WHERE condition) is created
|
|
112
|
-
continueOnError: true # if true and there was error in creating this index, continue (suitable for lately added unique indexes)
|
|
113
|
-
data: # static data (only for list tables)
|
|
114
|
-
- AlbumId: -1 # values for all columns, which should be filled
|
|
115
|
-
Title: Predefined static album
|
|
116
|
-
```
|
|
1
|
+
# dbmodel
|
|
2
|
+
Deploy, load or build script from model of SQL database. Can be used as command-line tool or as javascript functions
|
|
3
|
+
|
|
4
|
+
Model is stored as a collection of files:
|
|
5
|
+
* tables - stored as YAML files
|
|
6
|
+
* columns
|
|
7
|
+
* indexes
|
|
8
|
+
* primary keys
|
|
9
|
+
* foreign keys
|
|
10
|
+
* views - stored as SQL file with extension **.view.sql**
|
|
11
|
+
* stored procedures - stored as SQL file with extension **.proc.sql**
|
|
12
|
+
* functions - stored as SQL file with extension **.func.sql**
|
|
13
|
+
|
|
14
|
+
## Installation - as global tool
|
|
15
|
+
|
|
16
|
+
npm install --global dbmodel
|
|
17
|
+
|
|
18
|
+
## Installation - as regular package
|
|
19
|
+
|
|
20
|
+
npm install --save dbmodel
|
|
21
|
+
|
|
22
|
+
## Available commands
|
|
23
|
+
* **load** - loads structure of database, saves it to local directory (called *project*). Also can download data of enlisted tables (use --load-data-condition options)
|
|
24
|
+
* **deploy** - deploys structure from local directory (*project*) to database. *Deploy does not perform any actions leading to data loss, these changes must be made manually.*
|
|
25
|
+
* creates not existing tables
|
|
26
|
+
* creates not existing columns of existing tables
|
|
27
|
+
* checks column NULL/NOT NULL flag, alters colums
|
|
28
|
+
* checks tables, which are in database, but not in project, list of these tables are reported
|
|
29
|
+
* checks columns, which are in database, but not in project, list of these columns are reported
|
|
30
|
+
* checks indexes and its definitions, indexes are created or recreated, if neccessary (*but not deleted*)
|
|
31
|
+
* checks and creates foreign keys
|
|
32
|
+
* checks, creates new or changes existing views, stored procedures and functions
|
|
33
|
+
* updates and creates static data (included in table yaml files)
|
|
34
|
+
* **build** - builds script from project folder. This operation is complete offline, no database connection is needed. Built script makes subset of deploy command. It can be executed on empty database, but also it can convert existing database to current structure (but only using operations below).
|
|
35
|
+
* creates not existing tables
|
|
36
|
+
* creates not existing columns of existing tables
|
|
37
|
+
* creates not existing indexes (checked only by name)
|
|
38
|
+
* creates not existing foreign keys
|
|
39
|
+
* creates new or changes existing views, stored procedures and functions
|
|
40
|
+
* updates and creates static data (included in table yaml files)
|
|
41
|
+
|
|
42
|
+
## Command line interface
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
# load from existing database
|
|
46
|
+
dbmodel load -s localhost -u USERNAME -p PASSWORD -d DATABASE -e mssql@dbgate-plugin-mssql OUTPUT_FOLDER
|
|
47
|
+
|
|
48
|
+
# deploy project to database
|
|
49
|
+
dbmodel deploy -s localhost -u USERNAME -p PASSWORD -d DATABASE -e mssql@dbgate-plugin-mssql PROJECT_FOLDER
|
|
50
|
+
|
|
51
|
+
# build SQL script from project
|
|
52
|
+
dbmodel build -e mssql@dbgate-plugin-mssql PROJECT_FOLDER OUTPUT_FILE.sql
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Table yaml file documentation
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
name: Album # table name
|
|
59
|
+
columns:
|
|
60
|
+
- name: AlbumId # column name
|
|
61
|
+
type: int # data type. is used directly in target SQL engine
|
|
62
|
+
autoIncrement: true # column is autoincrement
|
|
63
|
+
notNull: true # column is not nullable (default: is nullable)
|
|
64
|
+
- name: Title
|
|
65
|
+
type: nvarchar
|
|
66
|
+
length: 160 # maximum character length
|
|
67
|
+
notNull: true
|
|
68
|
+
- name: ArtistId
|
|
69
|
+
type: int
|
|
70
|
+
references: Artist # name of table. Is used for creating foreign key
|
|
71
|
+
- name: isDeleted
|
|
72
|
+
type: bit
|
|
73
|
+
notNull: true
|
|
74
|
+
default: 0 # default value
|
|
75
|
+
primaryKey:
|
|
76
|
+
- AlbumId # list of primary key column names
|
|
77
|
+
indexes:
|
|
78
|
+
- name: UQ_AlbumTitleArtistId # index name
|
|
79
|
+
unique: true # whether index is unique. default=false
|
|
80
|
+
columns: # list of index columns
|
|
81
|
+
- Title
|
|
82
|
+
- ArtistId
|
|
83
|
+
filter: isDeleted=0 # if defined, filtered index (with WHERE condition) is created
|
|
84
|
+
continueOnError: true # if true and there was error in creating this index, continue (suitable for lately added unique indexes)
|
|
85
|
+
data: # static data (only for list tables)
|
|
86
|
+
- AlbumId: -1 # values for all columns, which should be filled
|
|
87
|
+
Title: Predefined static album
|
|
88
|
+
```
|
package/bin/dbmodel.js
CHANGED
|
@@ -1,81 +1,118 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
server,
|
|
54
|
-
user,
|
|
55
|
-
password,
|
|
56
|
-
database,
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
program.
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
require('dotenv').config();
|
|
5
|
+
|
|
6
|
+
global.API_PACKAGE = path.dirname(path.dirname(require.resolve('dbgate-api')));
|
|
7
|
+
global.PLUGINS_DIR = process.env.DEVMODE
|
|
8
|
+
? path.join(path.dirname(path.dirname(global.API_PACKAGE)), 'plugins')
|
|
9
|
+
: path.dirname(global.API_PACKAGE);
|
|
10
|
+
global.IS_NPM_DIST = true;
|
|
11
|
+
|
|
12
|
+
const program = require('commander');
|
|
13
|
+
const dbgateApi = require('dbgate-api');
|
|
14
|
+
const { createLogger } = require('pinomin');
|
|
15
|
+
|
|
16
|
+
const logger = createLogger('dbmodel');
|
|
17
|
+
|
|
18
|
+
async function runAndExit(promise) {
|
|
19
|
+
try {
|
|
20
|
+
await promise;
|
|
21
|
+
logger.info('Success');
|
|
22
|
+
process.exit();
|
|
23
|
+
} catch (err) {
|
|
24
|
+
logger.error({ err }, 'Processing failed');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
program
|
|
30
|
+
.option('-s, --server <server>', 'server host')
|
|
31
|
+
.option('-u, --user <user>', 'user name')
|
|
32
|
+
.option('-p, --password <password>', 'password')
|
|
33
|
+
.option('-d, --database <database>', 'database name')
|
|
34
|
+
.option('--auto-index-foreign-keys', 'automatically adds indexes to all foreign keys')
|
|
35
|
+
.option(
|
|
36
|
+
'--load-data-condition <condition>',
|
|
37
|
+
'regex, which table data will be loaded and stored in model (in load command)'
|
|
38
|
+
)
|
|
39
|
+
.requiredOption('-e, --engine <engine>', 'engine name, eg. mysql@dbgate-plugin-mysql');
|
|
40
|
+
|
|
41
|
+
program
|
|
42
|
+
.command('deploy <modelFolder>')
|
|
43
|
+
.description('Deploys model to database')
|
|
44
|
+
.action(modelFolder => {
|
|
45
|
+
const { engine, server, user, password, database } = program.opts();
|
|
46
|
+
// const hooks = [];
|
|
47
|
+
// if (program.autoIndexForeignKeys) hooks.push(dbmodel.hooks.autoIndexForeignKeys);
|
|
48
|
+
|
|
49
|
+
runAndExit(
|
|
50
|
+
dbgateApi.deployDb({
|
|
51
|
+
connection: {
|
|
52
|
+
engine,
|
|
53
|
+
server,
|
|
54
|
+
user,
|
|
55
|
+
password,
|
|
56
|
+
database,
|
|
57
|
+
},
|
|
58
|
+
modelFolder,
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// runAndExit(
|
|
64
|
+
// dbmodel.deploy({
|
|
65
|
+
// connection: {
|
|
66
|
+
// engine,
|
|
67
|
+
// server,
|
|
68
|
+
// user,
|
|
69
|
+
// password,
|
|
70
|
+
// database,
|
|
71
|
+
// },
|
|
72
|
+
// hooks,
|
|
73
|
+
// projectDir,
|
|
74
|
+
// })
|
|
75
|
+
// );
|
|
76
|
+
|
|
77
|
+
program
|
|
78
|
+
.command('load <outputDir>')
|
|
79
|
+
.description('Loads model from database')
|
|
80
|
+
.action(outputDir => {
|
|
81
|
+
const { engine, server, user, password, database } = program.opts();
|
|
82
|
+
// const loadDataCondition = program.loadDataCondition
|
|
83
|
+
// ? table => table.name.match(new RegExp(program.loadDataCondition, 'i'))
|
|
84
|
+
// : null;
|
|
85
|
+
// const hooks = [];
|
|
86
|
+
|
|
87
|
+
runAndExit(
|
|
88
|
+
dbgateApi.loadDatabase({
|
|
89
|
+
connection: {
|
|
90
|
+
engine,
|
|
91
|
+
server,
|
|
92
|
+
user,
|
|
93
|
+
password,
|
|
94
|
+
database,
|
|
95
|
+
},
|
|
96
|
+
outputDir,
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
program
|
|
102
|
+
.command('build <modelFolder> <outputFile>')
|
|
103
|
+
.description('Builds single SQL script from project')
|
|
104
|
+
.action((modelFolder, outputFile) => {
|
|
105
|
+
const { engine } = program.opts();
|
|
106
|
+
// const hooks = [];
|
|
107
|
+
runAndExit(
|
|
108
|
+
dbgateApi.generateModelSql({
|
|
109
|
+
// client,
|
|
110
|
+
// hooks,
|
|
111
|
+
modelFolder,
|
|
112
|
+
outputFile,
|
|
113
|
+
engine,
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dbmodel",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dbmodel",
|
|
3
|
+
"version": "5.2.2-alpha.11",
|
|
4
|
+
"homepage": "https://dbgate.org/",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/dbgate/dbgate.git"
|
|
8
|
+
},
|
|
9
|
+
"description": "Deploy, load or build script from model of SQL database",
|
|
10
|
+
"author": "Jan Prochazka",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"bin": {
|
|
13
|
+
"dbgate-serve": "./bin/dbmodel.js"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"sql",
|
|
17
|
+
"dbgate",
|
|
18
|
+
"web"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dbmodel": "node ./bin/dbmodel.js",
|
|
22
|
+
"dbmodel:load": "cross-env DEVMODE=1 node ./bin/dbmodel.js load testdata/db -e postgres@dbgate-plugin-postgres -s localhost -u postgres -p Pwd2020Db -d zradlo",
|
|
23
|
+
"dbmodel:deploy": "cross-env DEVMODE=1 node ./bin/dbmodel.js deploy testdata/db -e postgres@dbgate-plugin-postgres -s localhost -u postgres -p Pwd2020Db -d deployed",
|
|
24
|
+
"dbmodel:build": "cross-env DEVMODE=1 node ./bin/dbmodel.js build testdata/db testdata/db.sql -e postgres@dbgate-plugin-postgres "
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"README.md",
|
|
29
|
+
"bin"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"commander": "^10.0.0",
|
|
33
|
+
"dbgate-api": "^5.2.2-alpha.11",
|
|
34
|
+
"dbgate-plugin-csv": "^5.2.2-alpha.11",
|
|
35
|
+
"dbgate-plugin-excel": "^5.2.2-alpha.11",
|
|
36
|
+
"dbgate-plugin-mongo": "^5.2.2-alpha.11",
|
|
37
|
+
"dbgate-plugin-mssql": "^5.2.2-alpha.11",
|
|
38
|
+
"dbgate-plugin-mysql": "^5.2.2-alpha.11",
|
|
39
|
+
"dbgate-plugin-postgres": "^5.2.2-alpha.11",
|
|
40
|
+
"dbgate-plugin-xml": "^5.2.2-alpha.11",
|
|
41
|
+
"dbgate-web": "^5.2.2-alpha.11",
|
|
42
|
+
"dotenv": "^16.0.0",
|
|
43
|
+
"pinomin": "^1.0.1"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/lib/build.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
const read = require('./read');
|
|
3
|
-
const runHooks = require('./hooks/runHooks');
|
|
4
|
-
|
|
5
|
-
async function build(options) {
|
|
6
|
-
const { client } = options;
|
|
7
|
-
await read(options);
|
|
8
|
-
|
|
9
|
-
const { outputFile } = options;
|
|
10
|
-
options.outputDescriptor = fs.openSync(outputFile, 'w');
|
|
11
|
-
|
|
12
|
-
runHooks(options, 'before-build');
|
|
13
|
-
|
|
14
|
-
const buildFunc = require(`./clients/${client}/build`);
|
|
15
|
-
await buildFunc(options);
|
|
16
|
-
|
|
17
|
-
runHooks(options, 'after-build');
|
|
18
|
-
|
|
19
|
-
fs.close(options.outputDescriptor);
|
|
20
|
-
|
|
21
|
-
return options;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = build;
|