Browse Source

feat: add utility fn to get root namespace from environment

pull/5173/head
Arman Ozak 6 years ago
parent
commit
8394ffcd42
  1. 25
      npm/ng-packs/packages/schematics/src/utils/source.ts

25
npm/ng-packs/packages/schematics/src/utils/source.ts

@ -25,6 +25,31 @@ export async function getApiDefinition(url: string) {
return body;
}
export function getRootNamespace(tree: Tree, project: Project, moduleName: string) {
const environmentExpr = readEnvironment(tree, project.definition);
if (!environmentExpr)
throw new SchematicsException(interpolate(Exception.NoEnvironment, project.name));
let assignment = getAssignedPropertyFromObjectliteral(environmentExpr, [
'apis',
moduleName,
'rootNamespace',
]);
if (!assignment)
assignment = getAssignedPropertyFromObjectliteral(environmentExpr, [
'apis',
'default',
'rootNamespace',
]);
if (!assignment)
throw new SchematicsException(interpolate(Exception.NoRootNamespace, project.name, moduleName));
return assignment.replace(/[`'"]/g, '');
}
export function getSourceUrl(tree: Tree, project: Project, moduleName: string) {
const environmentExpr = readEnvironment(tree, project.definition);

Loading…
Cancel
Save