angular / angular/angular-cli

'ng update' does not work with yarn workspaces

オープン
#14,841 コメント 19 件 リアクション 33 件 担当者 0 名 GitHub で見る
area: @angular/cli feature feature: insufficient votes hotlist: devRel ng update DX
主要言語
TypeScript
スター
27k
フォーク
11.8k
平均マージ
14時間 23分
マージ済み PR(30日)
162

説明

# 🐞 Bug report

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

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

### Is this a regression?

No

### Description

I am utilizing yarn workspaces -feature in my project. Problem is that I have to keep Angular & AngularCLI dependencies on root packages.json, otherwise 'ng update' command can't figure out the version I currently have. I'd rather keep root package.json clean and move Angular & CLI dependencies to project/package.json to keep things isolated.
Looking at the [code](https://github.com/angular/angular-cli/blob/af93227f3295e918771e018d7d0fabbef774f1d1/packages/angular/cli/commands/update-impl.ts#L123), update command resolves dependencies from root package, even when command is executed on package folder. Would it be possible to change behavior in a way that update would first check package dependencies and the fall back to root if nothing is found?

## 🔬 Minimal Reproduction

- init yarn workspace project as follows: https://yarnpkg.com/lang/en/docs/workspaces/
- init angular app with cli and move dependencies from root package.json to workspace-a/package.json (example from previous step)
- wait until new angular version is available
- cd to 'workspace-a' and run 'ng update'. Command fails to find any dependencies to update.

## 🔥 Exception or Error

N/A

## 🌍 Your Environment



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

Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.800.3
@angular-devkit/build-angular 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/cli 8.0.3
@angular/pwa 0.800.3
@ngtools/webpack 8.0.3
@schematics/angular 8.0.3
@schematics/update 0.800.3
rxjs 6.4.0
typescript 3.4.5
webpack 4.30.0

Root package.json:

  "dependencies": {},

"devDependencies": {
"npm-run-all": "^4.1.5"
},

'workspace-a/package.json':

"dependencies": {

"@angular/animations": "~8.0.1",
"@angular/common": "~8.0.1",
"@angular/compiler": "~8.0.1",
"@angular/core": "~8.0.1",
"@angular/forms": "~8.0.1",
"@angular/platform-browser": "~8.0.1",
"@angular/platform-browser-dynamic": "~8.0.1",
"@angular/pwa": "^0.800.3",
"@angular/router": "~8.0.1",
"@angular/service-worker": "~8.0.1",
"@auth0/angular-jwt": "^2.1.0",
"@ngx-translate/core": "^11.0.1",
...
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "~8.0.3",
"@angular/compiler-cli": "~8.0.1",
"@angular/language-service": "~8.0.1",
...
}

**Anything else relevant?**

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、123行目付近の packages/angular/cli/commands/update-impl.ts にリンクされている update コマンドの実装から始め、Angular の依存関係を workspace-a/package.json にのみ配置した Yarn workspace を使って失敗を再現します。workspace ディレクトリから依存関係の解決がどのように行われるかを確認します。ng update が root package.json に依存関係を配置しなくても workspace の Angular 依存関係を見つけて更新できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, node.js, typescript
領域
cli, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。