convert dbmodel to json

This commit is contained in:
Jan Prochazka
2024-06-21 16:15:56 +02:00
parent a8999855bf
commit 297b321bc8
5 changed files with 58 additions and 1 deletions

View File

@@ -38,7 +38,8 @@ program
'--load-data-condition <condition>',
'regex, which table data will be loaded and stored in model (in load command)'
)
.requiredOption('-e, --engine <engine>', 'engine name, eg. mysql@dbgate-plugin-mysql');
.option('-e, --engine <engine>', 'engine name, eg. mysql@dbgate-plugin-mysql')
.option('--commonjs', 'Creates CommonJS module');
program
.command('deploy <modelFolder>')
@@ -117,4 +118,30 @@ program
);
});
program
.command('json-to-model <jsonFile> <modelFolder>')
.description('Converts JSON file to model')
.action((jsonFile, modelFolder) => {
runAndExit(
dbgateApi.jsonToDbModel({
modelFile: jsonFile,
outputDir: modelFolder,
})
);
});
program
.command('model-to-json <modelFolder> <jsonFile>')
.description('Converts model to JSON file')
.action((modelFolder, jsonFile) => {
const { commonjs } = program.opts();
runAndExit(
dbgateApi.dbModelToJson({
modelFolder,
outputFile: jsonFile,
commonjs,
})
);
});
program.parse(process.argv);