Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: add secondary entrypoint schematic #28723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(@schematics/angular): improve feedback
  • Loading branch information
Jefiozie committed Feb 2, 2025
commit fa0daa33fc774a67c8c828f6bd0d42fe487a1c79
3 changes: 3 additions & 0 deletions 3 packages/angular/cli/lib/config/workspace-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
"@schematics/angular:library": {
"$ref": "../../../../schematics/angular/library/schema.json"
},
"@schematics/angular:library-entrypoint": {
"$ref": "../../../../schematics/angular/library-entrypoint/schema.json"
},
"@schematics/angular:pipe": {
"$ref": "../../../../schematics/angular/pipe/schema.json"
},
Expand Down
10 changes: 5 additions & 5 deletions 10 packages/schematics/angular/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@
"schema": "./library/schema.json",
"description": "Generate a library project for Angular."
},
"library-secondary-entrypoint": {
"aliases": ["secondary"],
"factory": "./secondary-entrypoint",
"schema": "./secondary-entrypoint/schema.json",
"description": "Generate a secondary-entrypoint in a library project for Angular."
"library-entrypoint": {
"aliases": ["lib-entry"],
"factory": "./library-entrypoint",
"schema": "./library-entrypoint/schema.json",
"description": "Generate an library-entrypoint in an Angular library project."
},
"web-worker": {
"factory": "./web-worker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
url,
} from '@angular-devkit/schematics';
import { JSONFile } from '../utility/json-file';
import { latestVersions } from '../utility/latest-versions';
import { relativePathToWorkspaceRoot } from '../utility/paths';
import { buildDefaultPath, getWorkspace } from '../utility/workspace';
import { ProjectType } from '../utility/workspace-models';
Expand All @@ -34,7 +33,7 @@ function updateTsConfig(packageName: string, ...paths: string[]) {
const file = new JSONFile(host, 'tsconfig.json');
const jsonPath = ['compilerOptions', 'paths', packageName];
const value = file.get(jsonPath);
file.modify(jsonPath, Array.isArray(value) ? [...value, ...paths] : paths);
file.modify(jsonPath, Array.isArray(value) ? [...paths, ...value] : paths);
};
}

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

if (project?.extensions.projectType !== ProjectType.Library) {
throw new SchematicsException(
`Secondary Entrypoint schematic requires a project type of "library".`,
`Library entrypoint schematic requires a project type of "library".`,
);
}

Expand Down Expand Up @@ -81,8 +80,6 @@ export default function (options: LibraryOptions): Rule {
secondaryEntryPoint,
relativePathToWorkspaceRoot: relativePathToWorkspaceRoot(libDir),
packageName: options.name,
angularLatestVersion: latestVersions.Angular.replace(/~|\^/, ''),
tsLibLatestVersion: latestVersions['tslib'].replace(/~|\^/, ''),
}),
move(libDir),
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "SchematicsLibrary",
"title": "Secondary Entrypoint Schema",
"title": "Library Entrypoint Schema",
"type": "object",
"description": "Creates a secondary entrypoint in a library project in a project.",
"description": "Generate an library entrypoint in an Angular library project.",
Jefiozie marked this conversation as resolved.
Show resolved Hide resolved
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the library.",
Jefiozie marked this conversation as resolved.
Show resolved Hide resolved
"pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
"pattern": "^[a-zA-Z0-9-._~]+/?[a-zA-Z0-9-._~]+$",
"$default": {
"$source": "argv",
"index": 0
},
"x-prompt": "What name would you like to use for the secondary entrypoint?"
"x-prompt": "What name would you like to use for the entrypoint?"
},
"project": {
"type": "string",
Expand All @@ -30,5 +30,8 @@
"default": "public-api"
}
},
"required": ["name", "project"]
}
"required": [
"name",
"project"
]
}
3 changes: 2 additions & 1 deletion 3 tests/legacy-cli/e2e/tests/build/library-with-demo-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { updateJsonFile } from '../../utils/project';

export default async function () {
await ng('generate', 'library', 'mylib');
await createLibraryEntryPoint('secondary');
await ng('generate', 'lib-entry', 'secondary');
// await createLibraryEntryPoint('secondary');
await createLibraryEntryPoint('another');
Jefiozie marked this conversation as resolved.
Show resolved Hide resolved

// Scenario #1 where we use wildcard path mappings for secondary entry-points.
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.