angular / angular/angular-cli

Have NodePackageInstallTask use project directory if no directory specified

未关闭
#21,680 8 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: @angular-devkit/schematics feature feature: insufficient votes
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
14 小时 23 分钟
30 天内合并 PR
162

描述

# 🚀 Feature request

### Command (mark with an `x`)

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

### Description

A clear and concise description of the problem or missing capability...

`NodePackageInstallTask` is frequently used by add tasks such as `ng-add` in `@angular/material`. If a schematic like this is called from a custom `ng-new` schematic using `externalSchematic` the install fails because it is run from some non-project directory rather than from inside the newly created project directory.

### Describe the solution you'd like

If you have a solution in mind, please describe it.

Since schematics knows the location of `package.json` it should by default run `NodePackageInstallTask` from that same directory rather than using the working directory.

This would unfortunately qualify as a "breaking" change so a configuration option might be necessary to allow for the "old" (current) behavior once this change is made.

### Describe alternatives you've considered

Have you considered any alternative solutions or workarounds?
The only work-around I've been able to do is essentially replicating the behaviors of third-party schematic "add" tasks within my custom schematic and then running install after the fact which is less than ideal.

贡献指南

打开贡献指南

调研方向

在 Angular CLI schematics 代码中定位 NodePackageInstallTask 和 package.json 路径处理逻辑。复现 externalSchematic ng-new 场景,然后验证 new 和 add 任务默认从新创建的项目目录进行安装,并验证请求的兼容性选项保留现有行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
cli, tooling
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。