forked from Ineigo/bbgenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbbgenerator-model.ts
29 lines (25 loc) · 989 Bytes
/
bbgenerator-model.ts
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
28
29
import program from 'commander';
import ModelGenerator from './core/ModelGenerator';
import { Options } from './core/types';
import { init, success } from './core/utils';
const TYPE: string = 'Model';
async function run(entityName: string, options: Options): Promise<void> {
init(TYPE);
const gen = new ModelGenerator(options);
await gen.run(entityName);
console.log();
success(gen.rootEntity);
}
program
.usage('[options] <componentName>')
.option('-n, --name [name]', 'Имя модели', '')
.option('-p, --path [path]', 'Путь до папки c компонентом', process.cwd())
.action((file, cmd = {}) => {
const componentName: string = typeof file === 'string' ? file : '';
const templateName: string = typeof cmd.name === 'string' ? cmd.name || componentName : componentName;
run(componentName, {
name: templateName,
path: program.path,
});
})
.parse(process.argv);