【问题标题】:Release new code with versionNumber automatically Angular4自动发布带有版本号的新代码 Angular 4
【发布时间】:2018-09-26 13:30:14
【问题描述】:

我正在使用 angular4。我想知道是否有一种方法可以在我每次部署代码时自动添加新的版本号。

有人对此有经验吗?

非常感谢

【问题讨论】:

标签: angular deployment release


【解决方案1】:

您的 Angular 应用名称和版本存储在 package.json 中,您可以创建一个 npm 脚本命令来像这样运行

npm run command-name

这是我的设置package.json

{
  "name": "test-app",
  "version": "0.0.3",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build-patch": "ng build && npm version patch",
    "build-minor ": "ng build && npm version minor",
    "build-major": "ng build && npm version major",
    "build": "ng build"
  },
...
}

运行和更新补丁号

npm run build-patch

这将运行 ng build 并将软件包版本更新为 0.0.4,因为它是 0.0.3

这是在终端中运行命令的输出

C:\test-app>npm run build-patch

> test-app@0.0.3 build-patch C:\test-app
> ng build && npm version patch


Date: 2018-09-26T15:28:56.189Z
Hash: 3f1b223e30325514ebd1
Time: 6742ms
chunk {main} main.js, main.js.map (main) 9.42 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 2.95 MB [initial] [rendered]
v0.0.4

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-05
    • 2011-10-10
    • 2022-08-08
    • 1970-01-01
    相关资源
    最近更新 更多