angular / angular/angular-cli

CLI generates items in unexpected workspace directories

Đang mở
#21,660 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area: @angular/cli freq1: low severity2: inconvenient type: bug/fix
Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
14 giờ 23 phút
Pull request đã merge (30 ngày)
162

Mô tả

# 🐞 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện các lệnh `ng generate component component1` từ một workspace nhiều dự án, so sánh việc tạo từ thư mục gốc của dự án với việc tạo từ `src/app` hoặc `src/lib`. Được xem là hoàn tất khi việc tạo từ thư mục gốc của dự án đặt các mục vào thư mục mã nguồn dự kiến của dự án và phân giải module mà không yêu cầu đường dẫn tường minh.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
cli, tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.