import { Rule, SchematicContext, Tree, chain, schematic } from '@angular-devkit/schematics'; import { FrontendSchematics } from './frontend-schematics'; import { Model } from '@vmfvmf/ywtc-lib'; import { setModel } from '../../router.gen'; import { UcType } from '@vmfvmf/ywtc-lib/dist/model.enums'; export function gen(model: Model): Rule { return async (tree: Tree, _context: SchematicContext) => { setModel(model); let schematics: Rule[] = [ schematic(FrontendSchematics.CLASS, model), ]; if ([UcType.STD, UcType.STDUBD].includes(model.ucType!)) { schematics.push(schematic(FrontendSchematics.COMPONENT, model)); schematics.push(schematic(FrontendSchematics.APPFILTERABLE, model)); } schematics.push(schematic(FrontendSchematics.APPFORMABLE, model)); if (UcType.STD == model.ucType) { schematics.push(schematic(FrontendSchematics.UPDATEPAGE, model)); } else if ([UcType.STDUBD, UcType.CHILD_TABLE].includes(model.ucType!) ) { schematics.push(schematic(FrontendSchematics.UPDATEDIALOG, model)); } if (UcType.CHILD_FORM !== model.ucType) { schematics.push(schematic(FrontendSchematics.APPTABLEABLE, model)); } schematics.push(schematic(FrontendSchematics.SERVICE, model)); schematics.push(schematic(FrontendSchematics.ADD_E2E, model)); schematics.push(schematic(FrontendSchematics.E2E_UPDATE_APP_TEST_SUITE, model)); schematics.push(schematic(FrontendSchematics.E2E_UPDATE_GLOBAL_SPEC, model)); schematics.push(schematic(FrontendSchematics.E2E_UPDATE_DB_SCRIPTS, model)); return chain(schematics)(tree, _context); }; }