angular / angular/angular-cli

Check pathnames for illegal characters (e.g. outputPath for build files)

Đang mở
#19,533 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
area: @angular-devkit/build-angular feature feature: insufficient votes
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 (mark with an `x`)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] extract-i18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

### Description

The Angular CLI should warn the user if a specified path is invalid for the current system.

I accidently set `".../dist"` (three dots) as `outputPath` in `angular.json`. Correct is `"../dist"` (two dots). Running `ng build` created a huge mess. In the app root a folder has been created with `...` as name (ending a folder name in Windows with a dot is illegal). Inside of this three dot folder all of my project files were listed (including `node_modules` folder). There was also a folder named `...`, which again contained my whole project files. This recursively went to whatever level (I clicked throuhg the folder approximately 30 levels down, there was still a `...` folder). Deleting the first `...` folder lastet more than 15 minutes, then telling me the files which should be deleted aren't there anymore. Also my project files in the root directory were deleted in this process (luckily most of it in Git). That was the strangest thing, it felt like the content inside of `...` mirrored my root project somehow (like in https://superuser.com/questions/528502/cant-remove-three-dots-folder-on-my-hdd). I also tried reverting my files using Git which did not work at all. I managed to delete the whole repository locally with `rm -rf 'folder'` using the GitBash. After cloning the project again, my IDE (Webstorm) listed the `...` folder once again, which luckily could be deleted this time. The project looks fine right now, and with the correct `outputPath` the app builds correctly.

It would be nice if the CLI checks pathnames for illegal characters. I did not try any other illegal characters inside of the path name.

## 🔬 Minimal Reproduction

Caution: Try in a sandbox environment with unimported files only to prevent loss of data!

1. Change the `"outputPath"` in `angular.json` to `".../dist"` (three dots)
2. Run `ng build`

## 🌍 Your Environment

Angular CLI: 11.0.1
Node: 14.15.0
OS: win32 x64

Angular: 11.0.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1100.1
@angular-devkit/build-angular 0.1100.1
@angular-devkit/core 11.0.1
@angular-devkit/schematics 11.0.1
@angular/cdk 11.0.1
@angular/cli 11.0.1
@angular/material 11.0.1
@schematics/angular 11.0.1
@schematics/update 0.1100.1
rxjs 6.6.3
typescript 4.0.5

**Anything else relevant?**

![ng build gone wrong](https://user-images.githubusercontent.com/41572666/100902827-8fc22880-34c5-11eb-8f4e-30f2bdfde031.png)

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 lệnh `ng build` với `outputPath` được đặt thành `.../dist` trong sandbox Windows, sử dụng cấu hình `angular.json` được mô tả trong issue. Theo dõi cách build xử lý đường dẫn đó và xác minh rằng một tên đường dẫn không hợp lệ sẽ tạo ra cảnh báo hoặc lỗi trước khi tạo các tệp hoặc thư mục.

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
build-system, cli
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả 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.