Skip to content

Commit c99eea3

Browse files
committed
fix: Built-in integrated DB migration tool: tramp-cli
1 parent 8ead9af commit c99eea3

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/commands/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import Command from './interface';
22
import { MakeEntity, MakeDbView, MakeGraphql } from './make_entity';
3+
import TrampConfig from './tramp';
34

45
export default Command;
56

67
export {
78
MakeEntity,
89
MakeDbView,
9-
MakeGraphql
10+
MakeGraphql,
11+
TrampConfig
1012
};

src/commands/tramp.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Command from './interface';
2+
import DI from '../di';
3+
4+
export default class TrampConfig extends Command {
5+
static getName() {
6+
return 'tramp:dump-config';
7+
}
8+
9+
static getDescription() {
10+
return 'Print tramp cli required config json';
11+
}
12+
13+
static getSpec() {
14+
return {};
15+
}
16+
17+
async run() {
18+
const config = DI.get('config');
19+
const dbConfig = config.get('db');
20+
// eslint-disable-next-line no-console
21+
console.log(JSON.stringify({
22+
connection: {
23+
host: dbConfig.replication.write.host,
24+
user: dbConfig.replication.write.username,
25+
password: dbConfig.replication.write.password,
26+
database: dbConfig.database,
27+
port: dbConfig.port
28+
},
29+
editor: config.get('dev.editor') || 'webstorm',
30+
paths: dbConfig.migrationPaths
31+
}));
32+
}
33+
}
34+

0 commit comments

Comments
 (0)