Skip to content

Commit 518ff9f

Browse files
committed
refactor(@schematics/angular): improve feedback
1 parent 50434a9 commit 518ff9f

File tree

9 files changed

+21
-17
lines changed

9 files changed

+21
-17
lines changed

packages/angular/cli/lib/config/workspace-schema.json

+3
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@
162162
"@schematics/angular:library": {
163163
"$ref": "../../../../schematics/angular/library/schema.json"
164164
},
165+
"@schematics/angular:library-entrypoint": {
166+
"$ref": "../../../../schematics/angular/library-entrypoint/schema.json"
167+
},
165168
"@schematics/angular:pipe": {
166169
"$ref": "../../../../schematics/angular/pipe/schema.json"
167170
},

packages/schematics/angular/collection.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@
117117
"schema": "./library/schema.json",
118118
"description": "Generate a library project for Angular."
119119
},
120-
"library-secondary-entrypoint": {
121-
"aliases": ["secondary"],
122-
"factory": "./secondary-entrypoint",
123-
"schema": "./secondary-entrypoint/schema.json",
124-
"description": "Generate a secondary-entrypoint in a library project for Angular."
120+
"library-entrypoint": {
121+
"aliases": ["lib-entry"],
122+
"factory": "./library-entrypoint",
123+
"schema": "./library-entrypoint/schema.json",
124+
"description": "Generate an library-entrypoint in an Angular library project."
125125
},
126126
"web-worker": {
127127
"factory": "./web-worker",

packages/schematics/angular/secondary-entrypoint/index.ts renamed to packages/schematics/angular/library-entrypoint/index.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
url,
2020
} from '@angular-devkit/schematics';
2121
import { JSONFile } from '../utility/json-file';
22-
import { latestVersions } from '../utility/latest-versions';
2322
import { relativePathToWorkspaceRoot } from '../utility/paths';
2423
import { buildDefaultPath, getWorkspace } from '../utility/workspace';
2524
import { ProjectType } from '../utility/workspace-models';
@@ -34,7 +33,7 @@ function updateTsConfig(packageName: string, ...paths: string[]) {
3433
const file = new JSONFile(host, 'tsconfig.json');
3534
const jsonPath = ['compilerOptions', 'paths', packageName];
3635
const value = file.get(jsonPath);
37-
file.modify(jsonPath, Array.isArray(value) ? [...value, ...paths] : paths);
36+
file.modify(jsonPath, Array.isArray(value) ? [...paths, ...value] : paths);
3837
};
3938
}
4039

@@ -50,7 +49,7 @@ export default function (options: LibraryOptions): Rule {
5049

5150
if (project?.extensions.projectType !== ProjectType.Library) {
5251
throw new SchematicsException(
53-
`Secondary Entrypoint schematic requires a project type of "library".`,
52+
`Library entrypoint schematic requires a project type of "library".`,
5453
);
5554
}
5655

@@ -81,8 +80,6 @@ export default function (options: LibraryOptions): Rule {
8180
secondaryEntryPoint,
8281
relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(libDir),
8382
packageName: options.name,
84-
angularLatestVersion: latestVersions.Angular.replace(/~|\^/, ''),
85-
tsLibLatestVersion: latestVersions['tslib'].replace(/~|\^/, ''),
8683
}),
8784
move(libDir),
8885
]);

packages/schematics/angular/secondary-entrypoint/schema.json renamed to packages/schematics/angular/library-entrypoint/schema.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema",
33
"$id": "SchematicsLibrary",
4-
"title": "Secondary Entrypoint Schema",
4+
"title": "Library Entrypoint Schema",
55
"type": "object",
6-
"description": "Creates a secondary entrypoint in a library project in a project.",
6+
"description": "Generate an library entrypoint in an Angular library project.",
77
"additionalProperties": false,
88
"properties": {
99
"name": {
1010
"type": "string",
1111
"description": "The name of the library.",
12-
"pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
12+
"pattern": "^[a-zA-Z0-9-._~]+/?[a-zA-Z0-9-._~]+$",
1313
"$default": {
1414
"$source": "argv",
1515
"index": 0
1616
},
17-
"x-prompt": "What name would you like to use for the secondary entrypoint?"
17+
"x-prompt": "What name would you like to use for the entrypoint?"
1818
},
1919
"project": {
2020
"type": "string",
@@ -30,5 +30,8 @@
3030
"default": "public-api"
3131
}
3232
},
33-
"required": ["name", "project"]
34-
}
33+
"required": [
34+
"name",
35+
"project"
36+
]
37+
}

tests/legacy-cli/e2e/tests/build/library-with-demo-app.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { updateJsonFile } from '../../utils/project';
1212

1313
export default async function () {
1414
await ng('generate', 'library', 'mylib');
15-
await createLibraryEntryPoint('secondary');
15+
await ng('generate', 'lib-entry', 'secondary');
16+
// await createLibraryEntryPoint('secondary');
1617
await createLibraryEntryPoint('another');
1718

1819
// Scenario #1 where we use wildcard path mappings for secondary entry-points.

0 commit comments

Comments
 (0)