angular / angular/angular-cli

CLI generates items in unexpected workspace directories

未關閉
#21,660 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area: @angular/cli freq1: low severity2: inconvenient type: bug/fix
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

# 🐞 Bug report

### Command

- [x] generate

### Description

In a multi-project workspace, `ng generate` creates items (components, etc.) based on the current directory, rather than `[ProjectRoot]/src/app` or `[ProjectRoot/src/lib`.

In a single-project workspace, the CLI knows to place items inside of `src...`. However, in a multi-project workspace with a `projects/...` directory structure, the developer must navigate to `src/app` or `src/lib` prior to generating the item, or specify its location, such as:
```
cd ./projects/app1/src/app
ng generate component component1
```

or

```
cd ./projects/app1
ng generate component src/app/component1 -module src/app/app
```

The expectation would be to navigate to the root of the project, then generate items in the same manner as a single-project workspace, such as:

```
cd ./projects/app1
ng generate component component1
```

Ideally, developers would not have to worry about where they are within the project directory structure or having to specify the location of the module (particularly in default module configurations).

## 🌍 Your Environment



Angular CLI: 12.2.2
Node: 14.16.0
Package Manager: npm 7.21.0
OS: win32 x64

Angular: 12.2.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, material, platform-browser, platform-browser-dynamic
... router

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1202.2
@angular-devkit/build-angular 12.2.2
@angular-devkit/core 12.2.2
@angular-devkit/schematics 12.2.2
@schematics/angular 12.2.2
ng-packagr 12.2.0
rxjs 6.6.7
typescript 4.3.5

貢獻指南

開啟貢獻指南

研究方向

首先,在多專案 workspace 中重現 `ng generate component component1` 指令,比較從專案根目錄產生與從 `src/app` 或 `src/lib` 產生的結果。完成的標準是:從專案根目錄產生時,項目會放置在預期的專案原始碼目錄下,並且不需要明確指定路徑即可解析模組。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, typescript
領域
cli, tooling
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。