angular - 一次更新所有过时的 Angular 包
问题描述
我以前使用过ng update --all
,因为我想将每个包更新到最新版本,包括那些没有附加原理图的依赖项。
该--all
选项现已弃用,将不再起作用。唯一的选择是指定要更新的每个包,我觉得这很乏味。有没有办法将过时的包输出从ng update
一个单行空格分隔变量中提取出来,然后可以输入一个新的ng update ${packageList}
?
输出ng update
如下:
The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 67 dependencies.
We analyzed your package.json, there are some packages to update:
Name Version Command to update
--------------------------------------------------------------------------------------
@angular/cdk 10.2.5 -> 11.0.0 ng update @angular/cdk
@angular/cli 10.1.7 -> 11.0.0 ng update @angular/cli
@angular/core 10.2.0 -> 11.0.0 ng update @angular/core
@angular/material 10.2.5 -> 11.0.0 ng update @angular/material
@nrwl/angular 10.3.1 -> 10.3.3 ng update @nrwl/angular
@nrwl/cypress 10.3.1 -> 10.3.3 ng update @nrwl/cypress
@nrwl/jest 10.3.1 -> 10.3.3 ng update @nrwl/jest
@nrwl/storybook 10.3.1 -> 10.3.3 ng update @nrwl/storybook
@nrwl/workspace 10.3.1 -> 10.3.3 ng update @nrwl/workspace
There might be additional packages which don't provide 'ng update' capabilities that are outdated.
You can update the addition packages by running the update command of your package manager.
我想运行一个 bash 脚本,该脚本仅从该输出的第一列收集包名称,并将其反馈给变量。最终结果是:
> ng update ${packageList}
ng update @angular/cdk @angular/cli @angular/core @angular/material @nrwl/angular @nrwl/cypress @nrwl/jest @nrwl/storybook @nrwl/workspace --force=true
帮助?这可能吗?
解决方案
想我用这个单线做到了:
ng update | awk -v re='@[[:alnum:]]' '$0 ~ re {printf $1 " "}' | xargs ng update --force=true && npm update
通过将第一次运行的输出通过管道ng update
传输到 awk,我可以搜索类似于包名称的文本并输出以空格分隔的参数列表,然后我将其作为 xargs 管道传输到第二个ng update
命令。
通过先和npm update
之后运行它,我首先更新了迁移示意图的每个依赖项,然后是所有其余的。快乐的!
推荐阅读
- java - 我想在基于 Java 的游戏中使用 RPI SenseHat 上的操纵杆作为输入
- javascript - 如何将字符串转换为毫秒?
- python - 当 CSV 仍在加载数据时,Python 调用错误(SQL 语句的参数不足)
- c# - 在 .net 核心上创建主机以在带有 topshelf 的 Windows 上用作服务
- google-app-engine - 为什么 GCP App 引擎的出口成本突然飙升?
- python - 计算另一列中重复数字的序列 - 熊猫
- python - 在 Python 中创建 Aroon 指标
- javascript - 在 React 中使用 props 和跨组件的样式化组件
- c# - NSwag:如何抑制控制器 ASP.NET Core
- swift - Vimeo 视频上传 API Swift 失败