Skip to content

defaultCollection is relative to where cmd is run not angular.json #15014

Closed
@mina-skunk

Description

@mina-skunk

🐞 Bug report

Command (mark with an x)

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

Is this a regression?

I'm not sure

Description

With defaultCollection set to a relative path if ng g is ran in a sub folder it is not found.

🔬 Minimal Reproduction

  • clone https://github.com/william-lohan/collecion-path/tree/angular
  • use branch angular
  • npm i
  • ng g --help
  • see out put
  • cd .\projects\
  • ng g --help
  • see error
    -- or --
  • ng new my-app
  • make schematics in ./tools/schematics
  • set defaultCollection to ./tools/schematics/collection.json
  • ng g --help
  • see out put
  • cd .\projects\
  • ng g --help
  • see error

🔥 Exception or Error


Collection "./tools/schematics/collection.json" cannot be resolved.
Error: Collection "./tools/schematics/collection.json" cannot be resolved.
    at NodeModulesEngineHost._resolveCollectionPath (C:\Users\User\source\collecion-path\node_modules\@angular-devkit\schematics\tools\node-module-engine-host.js:91:15)
    at NodeModulesEngineHost.createCollectionDescription (C:\Users\User\source\collecion-path\node_modules\@angular-devkit\schematics\tools\file-system-engine-host-base.js:115:27)
    at SchematicEngine._createCollectionDescription (C:\Users\User\source\collecion-path\node_modules\@angular-devkit\schematics\src\engine\engine.js:147:40)
    at SchematicEngine.createCollection (C:\Users\User\source\collecion-path\node_modules\@angular-devkit\schematics\src\engine\engine.js:140:43)
    at GenerateCommand.getCollection (C:\Users\User\source\collecion-path\node_modules\@angular\cli\models\schematic-command.js:130:35)
    at GenerateCommand.initialize (C:\Users\User\source\collecion-path\node_modules\@angular\cli\commands\generate-impl.js:20:33)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

🌍 Your Environment

minimal repo project


Angular CLI: 8.0.0
Node: 10.16.0
OS: win32 x64
Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.800.0
@angular-devkit/core         8.0.0
@angular-devkit/schematics   8.0.0
@angular/cli                 8.0.0
@schematics/angular          8.0.0
@schematics/update           0.800.0
rxjs                         6.4.0
typescript                   3.4.5

closed source project I found the issues on


Angular CLI: 8.0.3
Node: 10.16.0
OS: win32 x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.800.3
@angular-devkit/build-angular      0.800.3
@angular-devkit/build-ng-packagr   0.800.3
@angular-devkit/build-optimizer    0.800.3
@angular-devkit/build-webpack      0.800.3
@angular-devkit/core               8.0.3
@angular-devkit/schematics         8.0.3
@angular/cdk                       8.0.1
@angular/cli                       8.0.3
@angular/flex-layout               8.0.0-beta.26
@angular/http                      7.2.12
@angular/material                  8.0.1
@ngtools/json-schema               1.1.0
@ngtools/webpack                   8.0.3
@schematics/angular                8.0.3
@schematics/update                 0.800.3
ng-packagr                         5.3.0
rxjs                               6.4.0
typescript                         3.4.5
webpack                            4.30.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions