Skip to content

Impossible to create Angular library nested in multiple directories #23988

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

Closed
1 task done
DariuszOstolski opened this issue Sep 30, 2022 · 2 comments
Closed
1 task done

Comments

@DariuszOstolski
Copy link
Contributor

Command

generate

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

11

Description

After migration to Angular 14 its no longer possible to create a library with nested directory structure. I'm working on a project where feature is usually split into multiple directories, for example:

projects/libs/feature-name/

  • app
  • shared
  • model
  • store

After migration when I try to create a library with a such scheme it is no longer possible, e.g.:

$ npx ng generate library projects/libs/feature/model                                                                                                                                                                                           ‹ruby-2.6.6›
Schematic input does not validate against the Schema: {"name":"projects/libs/feature/model"}
Errors:

  Data path "/name" must match pattern "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$".

I know that there is a workaround that when we make a path alias to projects/libs/feature-name it will work, e.g.:

$ npx ng generate library @feature-alias/model                                                                                                                                                                                           

In this project its very inconvenient since we have 100 different features and we would need to alias almost each one of it.

Minimal Reproduction

# create empty workspace
 ng new my-workspace --create-application false
# in that workspace create a library with nested directories
cd my-workspace/my-project
npx ng generate library projects/libs/feature/model

Exception or Error

Schematic input does not validate against the Schema: {"name":"projects/libs/feature/model"}
Errors:

  Data path "/name" must match pattern "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$".

Your Environment

$ ng version                                                                                                                                                                                                                                    ‹ruby-2.6.6›

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 14.2.4
Node: 16.17.0
Package Manager: npm 8.15.0 
OS: linux x64

Angular: 14.2.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.4
@angular-devkit/build-angular   14.2.4
@angular-devkit/core            14.2.4
@angular-devkit/schematics      14.2.4
@angular/cdk                    14.2.3
@angular/flex-layout            14.0.0-beta.40
@angular/material               14.2.3
@schematics/angular             14.2.4
ng-packagr                      14.2.1
rxjs                            7.5.7
typescript                      4.8.4

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

This is working as intended as the argument value represents the name of the library which must be a valid NPM package name.

Lets continue tracking this in #11927

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants