forked from Ineigo/bbgenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbbgenerator-component.ts
More file actions
33 lines (29 loc) · 1.15 KB
/
bbgenerator-component.ts
File metadata and controls
33 lines (29 loc) · 1.15 KB
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
30
31
32
33
import program from 'commander';
import ComponentGenerator from './core/ComponentGenerator';
import { Options } from './core/types';
import { init, success } from './core/utils';
const TYPE: string = 'Component';
async function run(entityName: string, options: Options): Promise<void> {
init(TYPE);
const gen: ComponentGenerator = new ComponentGenerator(options);
await gen.run(entityName);
console.log();
success(gen.rootEntity);
}
program
.usage('[options] <componentName>')
.option('-m, --model [name]', 'Добавить model')
.option('-c, --collection [name]', 'Добавить collection')
.option('-i, --item-view [name]', 'Создать CollectionView')
.option('-p, --path [path]', 'Путь до папки в которой создавать', process.cwd())
.action(file => {
const componentName: string = typeof file === 'string' ? file : '';
run(componentName, {
name: componentName,
model: program.model,
collection: program.collection,
path: program.path,
itemView: program.itemView,
});
})
.parse(process.argv);