-
Notifications
You must be signed in to change notification settings - Fork 12k
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
feat: add secondary entrypoint schematic #28723
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Ship It!
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
acc6219
to
6d617b8
Compare
This comment was marked as outdated.
This comment was marked as outdated.
6d617b8
to
6392681
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this. We discussed this during yesterday's meeting and agreed to proceed with adding a schematic to generate additional library entry points.
As a side note, it would be great if the library schematic could also leverage this schematic to generate its own entry point.
I’ve completed an initial review and left a few minor comments. Let me know if you have any questions!
@@ -117,6 +117,12 @@ | |||
"schema": "./library/schema.json", | |||
"description": "Generate a library project for Angular." | |||
}, | |||
"library-secondary-entrypoint": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"library-secondary-entrypoint": { | |
"library-entrypoint": { |
@@ -117,6 +117,12 @@ | |||
"schema": "./library/schema.json", | |||
"description": "Generate a library project for Angular." | |||
}, | |||
"library-secondary-entrypoint": { | |||
"aliases": ["secondary"], | |||
"factory": "./secondary-entrypoint", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: name the directory the same as the schematic.
@@ -117,6 +117,12 @@ | |||
"schema": "./library/schema.json", | |||
"description": "Generate a library project for Angular." | |||
}, | |||
"library-secondary-entrypoint": { | |||
"aliases": ["secondary"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"aliases": ["secondary"], | |
"aliases": ["lib-entry"], |
"aliases": ["secondary"], | ||
"factory": "./secondary-entrypoint", | ||
"schema": "./secondary-entrypoint/schema.json", | ||
"description": "Generate a secondary-entrypoint in a library project for Angular." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Generate a secondary-entrypoint in a library project for Angular." | |
"description": "Generate an entrypoint in an Angular library project." |
const distRoot = `dist/${folderName}/${options.name}`; | ||
|
||
const templateSource = apply(url('./files'), [ | ||
applyTemplates({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the below are unused.
"$id": "SchematicsLibrary", | ||
"title": "Secondary Entrypoint Schema", | ||
"type": "object", | ||
"description": "Creates a secondary entrypoint in a library project in a project.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Creates a secondary entrypoint in a library project in a project.", | |
"description": "Generate an entrypoint in an Angular library project.", |
{ | ||
"$schema": "http://json-schema.org/draft-07/schema", | ||
"$id": "SchematicsLibrary", | ||
"title": "Secondary Entrypoint Schema", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"title": "Secondary Entrypoint Schema", | |
"title": "Library Secondary Entrypoint Schema", |
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "The name of the library.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "The name of the library.", | |
"description": "The name of the entrypoint to create.", |
"name": { | ||
"type": "string", | ||
"description": "The name of the library.", | ||
"pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should likely be just the name of the entry-point and not a combination of the library and entrypoint.
ng g library-entrypoint --project="@foo/bar" --name="buz"
"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-._~]+$", |
@@ -0,0 +1,164 @@ | |||
/** | |||
* @license |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please update https://github.com/angular/angular-cli/blob/main/tests/legacy-cli/e2e/tests/build/library-with-demo-app.ts to use the new schematic? so that we actually have an e2e that tests the generated code.
@@ -117,6 +117,12 @@ | |||
"schema": "./library/schema.json", | |||
"description": "Generate a library project for Angular." | |||
}, | |||
"library-secondary-entrypoint": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a reference to https://github.com/angular/angular-cli/blob/a8335cf950510eec70c77e541ca996431931b00f/packages/angular/cli/lib/config/workspace-schema.json#L162C1-L164C11 and
CLI_SCHEMA_DATA = [ |
"$source": "projectName" | ||
} | ||
}, | ||
"entryFile": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably can opt this option as I doubt it's actually used.
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name would you like to use for the secondary entrypoint?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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?" |
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
There is no easy way to generate a secondary entrypoint
Issue Number: #19070
What is the new behavior?
This PR adds the ability to generate a secondary entrypoint in a library project. It cannot be used without a library project.
Does this PR introduce a breaking change?
Other information
I've copied some helper utils from other schematics. I'm happy to make a other PR to add these to the utility parts with proper tests on it. Not updated the docs as this is I think in a other repo?
Pinging @SanderElias he mentioned there was nothing in the cli and encourage me to make this change 👍
Closes #19070