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(angular): support generating artifacts using options as provided #19527

Merged

Conversation

leosvelperez
Copy link
Member

@leosvelperez leosvelperez commented Oct 10, 2023

Current Behavior

Artifact generators (e.g. component) options are more complex than they should be and are not consistent across the different Nx first-party plugins. These are some of the current problems:

  • Different generators have different option names for the same thing.
  • The directory/path option is expected to be relative to the workspace root for some generators, and for others, it’s expected to be relative to the project source root.
  • Devs need to specify many options to generate an artifact in a specific location: name, project, directory/path, flat.

Apart from those, there are also some automatic decisions made by these generators, like converting the provided names to kebab-case. While this can enforce certain standards, it can be limiting and might not fit every use case.

Expected Behavior

  • Similar to the changes done to the project generators, we'll have two formats: as-provided and derived. In most cases, we'll prompt the user for the format they want to use.
  • We’ll deprecate the following options, which will only be considered for the derived format:
    • project
    • flat
  • We’ll standardize the path and directory options name to be directory. We'll keep backward compat for path.
  • We’ll standardize the directory option to be relative to the cwd.
  • We’ll standardize the support for providing a path as the artifact name. It will be a shorthand of passing name & directory options.

Related Issue(s)

Fixes #

@leosvelperez leosvelperez self-assigned this Oct 10, 2023
@vercel
Copy link

vercel bot commented Oct 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Oct 11, 2023 6:13pm

@FrozenPandaz FrozenPandaz marked this pull request as ready for review October 11, 2023 15:48
@FrozenPandaz FrozenPandaz requested review from a team as code owners October 11, 2023 15:48
@@ -633,6 +633,8 @@ export async function combineOptionsForGenerator(
schema,
false
);

warnDeprecations(combined, schema);
Copy link
Member Author

Choose a reason for hiding this comment

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

This was being executed after the smart defaults were applied. That was wrong because it would warn about a deprecated option with a smart default (e.g. project). The order of operations after this change matches the order of those in the Angular CLI.

@FrozenPandaz FrozenPandaz merged commit c0027de into nrwl:master Oct 12, 2023
2 checks passed
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2023
@leosvelperez leosvelperez deleted the angular/artifact-consistent-generation branch December 19, 2023 10:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants