diff --git a/npm/ng-packs/packages/schematics/src/utils/api.ts b/npm/ng-packs/packages/schematics/src/utils/api.ts index 39483c2aa9..78f96f477b 100644 --- a/npm/ng-packs/packages/schematics/src/utils/api.ts +++ b/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' }), + ), + ); } diff --git a/npm/ng-packs/packages/schematics/src/utils/workspace.ts b/npm/ng-packs/packages/schematics/src/utils/workspace.ts index 2daaf8b2b6..ed53e482e8 100644 --- a/npm/ng-packs/packages/schematics/src/utils/workspace.ts +++ b/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( // @typescript-eslint/no-explicit-any notFoundValue: T = NOT_FOUND_VALUE as unknown as any, ): Promise { - name = name || readWorkspaceSchema(tree).defaultProject!; + name = name || readWorkspaceSchema(tree).defaultProject || getFirstApplication(tree).name!; const workspace = await getWorkspace(tree); let definition: Project['definition'] | undefined;