Browse Source

feat: resolve solution from rootNamespace in environment

pull/5173/head
Arman Ozak 6 years ago
parent
commit
63bb86a306
  1. 12
      npm/ng-packs/packages/schematics/src/commands/api/index.ts

12
npm/ng-packs/packages/schematics/src/commands/api/index.ts

@ -20,6 +20,7 @@ import {
createImportRefToEnumMapper, createImportRefToEnumMapper,
EnumGeneratorParams, EnumGeneratorParams,
getEnumNamesFromImports, getEnumNamesFromImports,
getRootNamespace,
interpolate, interpolate,
ModelGeneratorParams, ModelGeneratorParams,
resolveProject, resolveProject,
@ -29,18 +30,21 @@ import * as cases from '../../utils/text';
import { Schema as GenerateProxySchema } from './schema'; import { Schema as GenerateProxySchema } from './schema';
export default function(params: GenerateProxySchema) { export default function(params: GenerateProxySchema) {
const solution = params.solution;
const moduleName = strings.camelize(params.module || 'app'); const moduleName = strings.camelize(params.module || 'app');
return chain([ return chain([
async (tree: Tree, _context: SchematicContext) => { async (tree: Tree, _context: SchematicContext) => {
const source = await resolveProject(tree, params.source!);
const target = await resolveProject(tree, params.target!); const target = await resolveProject(tree, params.target!);
const solution = getRootNamespace(tree, source, moduleName);
const targetPath = buildDefaultPath(target.definition); const targetPath = buildDefaultPath(target.definition);
const readApiDefinition = createApiDefinitionReader( const definitionPath = `${targetPath}/shared/api-definition.json`;
`${targetPath}/shared/api-definition.json`, const readApiDefinition = createApiDefinitionReader(definitionPath);
);
const data = readApiDefinition(tree); const data = readApiDefinition(tree);
const types = data.types; const types = data.types;
const modules = data.modules;
if (!types || !modules) throw new SchematicsException(Exception.InvalidApiDefinition);
const definition = data.modules[moduleName]; const definition = data.modules[moduleName];
if (!definition) if (!definition)
throw new SchematicsException(interpolate(Exception.InvalidModule, moduleName)); throw new SchematicsException(interpolate(Exception.InvalidModule, moduleName));

Loading…
Cancel
Save