'How to manage CI/CD of multi level npm packages?

We have 4 layer npm projects which are dependent on each other like this.

Package 4
    - Package 2
    - Package 3
Package 3
    - Package 1
    - Package 2

enter image description here

I'm currently trying to setup CI/CD process for publishing these packages. For example, if package 1 changes, package 3 will be updated and outputs a new minor version. Package 4 which is dependent on Package 3 will also get a minor version update. This process looks like tedious to write when the number of packages increase.

Is there a best way to achieve this when a package changes, it will auto update its dependents?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source