angular - 一次更新所有过时的 Angular 包

标签 angular bash grep angular-cli

我以前用过 ng update --all ,因为我想将每个包更新到最新版本,包括那些没有附上原理图的依赖项。--all选项现已弃用,将不再起作用。唯一的选择是指定要更新的每个包,我觉得这很乏味。有没有办法从 ng update grep 过时的包输出到单行空格分隔的变量中,然后可以将其输入到新的 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之后,我首先更新了迁移原理图的每个依赖项,然后更新了所有其他依赖项。快乐的! 🙂

关于angular - 一次更新所有过时的 Angular 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64804114/

相关文章:

java - Spring Boot 2 Reactor Flux API 的 Angular 客户端

angular - 是否有 'smoother' 编码进度条的方法?

linux - 我有一些代码有一个在终端上运行良好但从脚本运行时失败的命令

windows - 在Linux环境下运行.bat

Android shell 脚本 grep

javascript - 修改 typescript 文件时,Angular2 在浏览器中没有变化

angular - ngx-chips:无法显示自动完成项目

linux - 由于 mkdir 拒绝,无法安装软件

regex - 如何获取包含特定短语的 XML 文件的数量?

linux - 统计二进制数据出现的次数