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

Library schematic does not support path property #16080

Open
CobusKruger opened this issue Nov 6, 2019 · 6 comments
Open

Library schematic does not support path property #16080

CobusKruger opened this issue Nov 6, 2019 · 6 comments
Labels
area: schematics/angular feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Milestone

Comments

@CobusKruger
Copy link

CobusKruger commented Nov 6, 2019

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
- [X] schematics

Is this a regression?

Not as far as I know

Description

I tried to create a schematic that generates an application and adds a library to it. However, the library schematic does not accept a path as parameter and it then attempts to create the library in the folder that contains the application. Specifically, it tries to read the angular.json file from the folder containing the application folder (e.g. the folder where the schematic is run).

Note that I expected the path property to work, as it's included with most of the other Angular schematics, for example component, module and service.

🔬 Minimal Reproduction

A minimal reproduction may be found in this repo.

It also addresses a problem I had when trying to work around this with applyToSubtree.

Here is the simplest description I could come up with.

Given this factory:

export function createProject(_options: any): Rule {
  return (_tree: Tree, _context: SchematicContext) => {
    return chain([
      externalSchematic('@schematics/angular', 'ng-new', optionsNew),
      externalSchematic('@schematics/angular', 'library', optionsLib)
    ]);
  };
}

If you execute the schematic in a folder named /parent/folder and the app generates in a new folder named app (/parent/folder/app), the library schematic searches for the angular.json in /parent/folder instead of /parent/folder/app.

🔥 Exception or Error

An error occured:
Error: Unable to locate a workspace file for workspace path.
    at Object.readWorkspace (C:\dev\scratchpad\scaffolding-tests\node_modules\@angular-devkit\core\src\workspace\core.js:74:19)
    at async Object.getWorkspace (C:\dev\scratchpad\scaffolding-tests\node_modules\@schematics\angular\utility\workspace.js:51:27)
    at async C:\dev\scratchpad\scaffolding-tests\node_modules\@schematics\angular\library\index.js:153:27

🌍 Your Environment


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

Angular CLI: 8.3.1
Node: 12.12.0
OS: win32 x64
Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.1 (cli-only)
@angular-devkit/core         8.3.17
@angular-devkit/schematics   8.3.17
@schematics/angular          8.3.1 (cli-only)
@schematics/update           0.803.1 (cli-only)
rxjs                         6.4.0
typescript                   3.5.3

Similar issues

#17598

@BrianMikinski
Copy link

I'm bumping into the same issue for any schematic dev work trying to use the Angular Schematics config getWorkspacePath method - they'r blowing up in test runs and dev work no matter what work arounds I try to implement

@ActJV
Copy link

ActJV commented May 3, 2020

+1

@kyliau kyliau added triage #1 feature Issue that requests a new feature labels May 28, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog May 28, 2020
@d-koppenhagen
Copy link

Same here.
I think the problem is that after running externalSchematic('@schematics/angular', 'ng-new', optionsNew), the workspace is just present as a virtual tree and not entered. So the next Rule can't determine that it's in a valid Angular workspace. Is there a way to tell the schematics, to either:

  • enter the target workspace within the virtual representation and use this as new base
  • save the changes made by externalSchematic('@schematics/angular', 'ng-new', optionsNew) from virtual tree to the file system and then run the next Rule afterwards?

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Feb 1, 2022
@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 1, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@ngbot ngbot bot modified the milestones: Backlog, needsTriage Feb 1, 2022
@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 21, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors and removed feature: votes required Feature request which is currently still in the voting phase labels Feb 21, 2022
@maguilarl
Copy link

I have the same problem, any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: schematics/angular feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

7 participants