|
|
|
@ -1,6 +1,5 @@ |
|
|
|
import { normalize, strings } from '@angular-devkit/core'; |
|
|
|
import { applyTemplates, branchAndMerge, chain, move, SchematicContext, Tree, url } from '@angular-devkit/schematics'; |
|
|
|
import app from '../../mocks/app.gitignore'; |
|
|
|
import { applyWithOverwrite, buildDefaultPath, createApiDefinitionReader, resolveProject } from '../../utils'; |
|
|
|
import * as cases from '../../utils/text'; |
|
|
|
import type { Schema as GenerateProxySchema } from './schema'; |
|
|
|
@ -15,15 +14,21 @@ export default function(params: GenerateProxySchema) { |
|
|
|
const targetPath = buildDefaultPath(target.definition); |
|
|
|
const readApiDefinition = createApiDefinitionReader(`${targetPath}/shared/api-definition.json`); |
|
|
|
const data = readApiDefinition(tree); |
|
|
|
data.modules.app = app; |
|
|
|
|
|
|
|
const controllers = Object.values(data.modules[moduleName]?.controllers || {}); |
|
|
|
|
|
|
|
const createServiceFiles = chain( |
|
|
|
controllers.map(controller => { |
|
|
|
const {controllerName: name, type, actions, interfaces} = controller; |
|
|
|
const namespaceRegex = new RegExp('^' + solution + '\.(Controllers\.)?'); |
|
|
|
const namespace = type.replace(namespaceRegex, '').split('.').slice(0, -1).join('.'); |
|
|
|
let namespace = type.split('.').slice(0, -1).join('.'); |
|
|
|
solution.split('.').reduceRight((acc, part) => { |
|
|
|
acc = part + '\.' + acc; |
|
|
|
const regex = new RegExp('^' + acc + '(Controllers\.)?'); |
|
|
|
namespace = namespace.replace(regex, ''); |
|
|
|
return acc; |
|
|
|
}, ''); |
|
|
|
|
|
|
|
console.log(namespace); |
|
|
|
|
|
|
|
return applyWithOverwrite(url('./files-service'), [ |
|
|
|
applyTemplates({ |
|
|
|
|