Browse Source

Merge pull request #14614 from abpframework/fix/14519

fix entrypoint param, work without defaultProject
pull/14671/head
Mahmut Gundogdu 4 years ago
committed by GitHub
parent
commit
c8663ef3a9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      npm/ng-packs/packages/schematics/src/utils/api.ts
  2. 10
      npm/ng-packs/packages/schematics/src/utils/workspace.ts

6
npm/ng-packs/packages/schematics/src/utils/api.ts

@ -2,5 +2,9 @@ import { chain, schematic } from '@angular-devkit/schematics';
import { GenerateProxySchema } from '../models';
export function createApisGenerator(schema: GenerateProxySchema, generated: string[]) {
return chain(generated.map(m => schematic('api', { ...schema, module: m })));
return chain(
generated.map(m =>
schematic('api', { ...schema, module: m, entryPoint: schema.entryPoint || '__default' }),
),
);
}

10
npm/ng-packs/packages/schematics/src/utils/workspace.ts

@ -21,6 +21,14 @@ export function readEnvironment(tree: Tree, project: workspaces.ProjectDefinitio
const source = readFileInTree(tree, envPath);
return findEnvironmentExpression(source);
}
export function getFirstApplication(tree: Tree) {
const workspace = readWorkspaceSchema(tree);
const [name, project] =
Object.entries(workspace.projects).find(
([_, project]) => project.projectType === ProjectType.Application,
) || [];
return { name, project };
}
export function readWorkspaceSchema(tree: Tree) {
if (!tree.exists('/angular.json')) throw new SchematicsException(Exception.NoWorkspace);
@ -44,7 +52,7 @@ export async function resolveProject<T = any>(
// @typescript-eslint/no-explicit-any
notFoundValue: T = NOT_FOUND_VALUE as unknown as any,
): Promise<Project | T> {
name = name || readWorkspaceSchema(tree).defaultProject!;
name = name || readWorkspaceSchema(tree).defaultProject || getFirstApplication(tree).name!;
const workspace = await getWorkspace(tree);
let definition: Project['definition'] | undefined;

Loading…
Cancel
Save