From 63bb86a30662999e6aba5d52f143998ba2b26bab Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Tue, 25 Aug 2020 17:52:54 +0300 Subject: [PATCH] feat: resolve solution from rootNamespace in environment --- .../packages/schematics/src/commands/api/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/commands/api/index.ts b/npm/ng-packs/packages/schematics/src/commands/api/index.ts index 688430f35f..956e91e0b1 100644 --- a/npm/ng-packs/packages/schematics/src/commands/api/index.ts +++ b/npm/ng-packs/packages/schematics/src/commands/api/index.ts @@ -20,6 +20,7 @@ import { createImportRefToEnumMapper, EnumGeneratorParams, getEnumNamesFromImports, + getRootNamespace, interpolate, ModelGeneratorParams, resolveProject, @@ -29,18 +30,21 @@ import * as cases from '../../utils/text'; import { Schema as GenerateProxySchema } from './schema'; export default function(params: GenerateProxySchema) { - const solution = params.solution; const moduleName = strings.camelize(params.module || 'app'); return chain([ async (tree: Tree, _context: SchematicContext) => { + const source = await resolveProject(tree, params.source!); const target = await resolveProject(tree, params.target!); + const solution = getRootNamespace(tree, source, moduleName); const targetPath = buildDefaultPath(target.definition); - const readApiDefinition = createApiDefinitionReader( - `${targetPath}/shared/api-definition.json`, - ); + const definitionPath = `${targetPath}/shared/api-definition.json`; + const readApiDefinition = createApiDefinitionReader(definitionPath); const data = readApiDefinition(tree); const types = data.types; + const modules = data.modules; + if (!types || !modules) throw new SchematicsException(Exception.InvalidApiDefinition); + const definition = data.modules[moduleName]; if (!definition) throw new SchematicsException(interpolate(Exception.InvalidModule, moduleName));