Skip to content

Commit 98c90c5

Browse files
committed
fixup! feat(@schematics/angular): use library builder and add entry-point schematic
1 parent 9636cf2 commit 98c90c5

3 files changed

Lines changed: 10 additions & 29 deletions

File tree

‎packages/schematics/angular/entry-point/index.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ export default createProjectSchematic<EntryPointOptions>((options, { project, tr
5656
throw new SchematicsException('Entry point name "package.json" is reserved.');
5757
}
5858

59-
if (options.name === 'src' || options.name.startsWith('src/')) {
60-
throw new SchematicsException(
61-
`Entry point name "${options.name}" cannot be "src" or start with "src/" ` +
62-
'as it conflicts with the primary entry point source directory.',
63-
);
64-
}
65-
6659
const libDir = project.root;
6760
const packageJsonPath = join(libDir, 'package.json');
6861
if (!tree.exists(packageJsonPath)) {

‎packages/schematics/angular/entry-point/index_spec.ts‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -430,24 +430,6 @@ describe('EntryPoint Schematic', () => {
430430
).toBeRejectedWithError('Entry point name "package.json" is reserved.');
431431
});
432432

433-
it('should throw if the entry-point name conflicts with the primary source directory', async () => {
434-
for (const invalidName of ['src', 'src/sub']) {
435-
await expectAsync(
436-
schematicRunner.runSchematic(
437-
'entry-point',
438-
{
439-
name: invalidName,
440-
project: 'foo',
441-
},
442-
workspaceTree,
443-
),
444-
).toBeRejectedWithError(
445-
`Entry point name "${invalidName}" cannot be "src" or start with "src/" ` +
446-
'as it conflicts with the primary entry point source directory.',
447-
);
448-
}
449-
});
450-
451433
it('should reject invalid entry-point names via schema validation', async () => {
452434
for (const invalidName of ['.', '../foo', 'foo..bar', '/secondary', 'secondary/', './sub']) {
453435
await expectAsync(

‎packages/schematics/angular/utility/workspace.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,16 @@ export async function writeWorkspace(
116116
* @param project The project which will have its default path generated.
117117
*/
118118
export function buildDefaultPath(project: workspaces.ProjectDefinition): string {
119-
const root =
120-
project.sourceRoot && project.sourceRoot !== project.root
121-
? `/${project.sourceRoot}/`
122-
: `/${project.root}/src/`;
119+
let root: string;
120+
if (project.extensions['projectType'] === ProjectType.Library) {
121+
root =
122+
project.sourceRoot && project.sourceRoot !== project.root
123+
? `/${project.sourceRoot}/`
124+
: `/${project.root}/src/`;
125+
} else {
126+
root = `/${project.sourceRoot || project.root}/`; // fallback for non-library projects
127+
}
128+
123129
const projectDirName =
124130
project.extensions['projectType'] === ProjectType.Application ? 'app' : 'lib';
125131

0 commit comments

Comments
 (0)