Search code examples
angularversioningangular-library

Automating angular project versioning using standard-version npm package


I have an angular workspace with the structure below

- AngularProject
    - projects
        - lib1
           - lib
           - package.json
    - src
        - app
    - package.json

lib1 is a package that is to be published to npm.

I want to use the standard-version npm package to automate versioning in this project. Is there a way the standard-version CLI command can update the version in the package.json files in both the root directory and the lib1 directory.

I have tried using the standard-version CLI command but it only updates the package.json in the root directory.

Expectation:

The package.json files in both the root directory and lib1 directory should be updated using standard-version


Solution

  • The solution to this issue is to create a .versionrc file as shown below in the root directory and add a list of bump files (i.e files containing the project version).

    // .versionrc
    {
      "bumpFiles": [
        {
          "filename": "first package.json location",
          // The `json` updater assumes the version is available under a `version` key in the provided JSON document.
          "type": "json"
        },
         {
          "filename": "second package.json location",
          // The `json` updater assumes the version is available under a `version` key in the provided JSON document.
          "type": "json"
        }
      ]
    }
    
    

    For a better understanding, check out the project's GitHub page