Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jefiozie
Copy link
Contributor

@Jefiozie Jefiozie commented Oct 28, 2024

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

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?

  • Yes
  • No

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

@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Oct 28, 2024
Copy link

@SanderElias SanderElias left a 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!

@alan-agius4 alan-agius4 added the needs: discussion On the agenda for team meeting to determine next steps label Oct 28, 2024
@alan-agius4 alan-agius4 self-assigned this Oct 28, 2024
@Jefiozie

This comment was marked as outdated.

@alan-agius4

This comment was marked as outdated.

@Jefiozie

This comment was marked as outdated.

@Jefiozie Jefiozie force-pushed the secondaryEntrypoint branch from acc6219 to 6d617b8 Compare November 4, 2024 13:32
@Jefiozie

This comment was marked as outdated.

@Jefiozie Jefiozie force-pushed the secondaryEntrypoint branch from 6d617b8 to 6392681 Compare November 10, 2024 18:42
@Jefiozie

This comment was marked as outdated.

@alan-agius4

This comment was marked as outdated.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a 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": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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",
Copy link
Collaborator

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"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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({
Copy link
Collaborator

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.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"title": "Secondary Entrypoint Schema",
"title": "Library Secondary Entrypoint Schema",

"properties": {
"name": {
"type": "string",
"description": "The name of the library.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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-._~]*$",
Copy link
Collaborator

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"
Suggested change
"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
Copy link
Collaborator

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.

@alan-agius4 alan-agius4 added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: minor This PR is targeted for the next minor release and removed needs: discussion On the agenda for team meeting to determine next steps labels Jan 9, 2025
@@ -117,6 +117,12 @@
"schema": "./library/schema.json",
"description": "Generate a library project for Angular."
},
"library-secondary-entrypoint": {
Copy link
Collaborator

@alan-agius4 alan-agius4 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"$source": "projectName"
}
},
"entryFile": {
Copy link
Collaborator

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?"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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?"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library secondary entry-point generation
3 participants