user3356007
user3356007

Reputation: 403

Release new code with versionNumber automatically Angular4

I am using angular4. I want to know if there is a way to automatically add a new release number everytime that i deploey my code.

Does someone has expirience with this?

Thanks a lot

Upvotes: 1

Views: 74

Answers (1)

Muhammed Albarmavi
Muhammed Albarmavi

Reputation: 24434

Your angular app name and version is stored in package.json and you can create a npm script command to run like this

npm run command-name

this my setup 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"
  },
...
}

to run and update patch number

npm run build-patch

this will run ng build and update the package version to 0.0.4 as it was 0.0.3

this an output of run the command in the terminal

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

> [email protected] 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

Upvotes: 1

Related Questions