-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbbgenerator-collection.ts
31 lines (27 loc) · 1.13 KB
/
bbgenerator-collection.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
30
31
import program from 'commander';
import CollectionGenerator from './core/CollectionGenerator';
import { Options } from './core/types';
import { init, success } from './core/utils';
const TYPE: string = 'Collection';
async function run(entityName: string, options: Options): Promise<void> {
init(TYPE);
const gen: CollectionGenerator = new CollectionGenerator(options);
await gen.run(entityName);
console.log();
success(gen.rootEntity);
}
program
.usage('[options] <componentName>')
.option('-n, --name [name]', 'Имя коллекции', '')
.option('-m, --model [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,
model: program.model,
path: program.path,
});
})
.parse(process.argv);