import { classify } from '@angular-devkit/core/src/utils/strings'; import { Rule, SchematicContext, Tree, chain, schematic } from '@angular-devkit/schematics'; import { JeovaSchematicsEnum } from '../../../shared/jeova-schematics.enum'; import { ComponentType } from '../../updates/update-modules.gen'; import { IModel } from '@vmfvmf/ywtc-lib'; import { getPrjSrd } from '../../../router.gen'; import { FrontEndGenerator } from '../../../shared/generator'; import { UcType } from '@vmfvmf/ywtc-lib/dist/model.enums'; export function gen(imodel: IModel): Rule { return (tree: Tree, _context: SchematicContext) => { if (![UcType.STD, UcType.STDUBD].includes(imodel.ucType)) { throw Error('To create a component the model must be of standard type'); } const componentName = classify(imodel.name!) + 'Component'; const componentType = ComponentType.LIST; const url = imodel.url; const rule = chain([ new FrontEndGenerator(__filename).gen({...imodel, ...getPrjSrd()}), schematic(JeovaSchematicsEnum.UPDATE_FRONTEND_MODULE, {componentName, componentType, url}) ]); return rule(tree, _context); }; }