I have an automatic script that generates some packages, one of those packages uses the other generated packages as dependencies. So for example if i have packages A, B and C, C's package.json would look like this:
{
"name": "C",
"version": "0.0.1",
"dependencies": {
"A": "0.0.1",
"B": "0.0.1"
}
}
I want to make it so that whenever i build the packages (i always build all the packages and change their version) C's package.json gets updated automatically but without any installation or check if the package exists in the registry (they are not published right away, and i can't change that, so they might not exist yet). In this case, if I update the packages to version 0.0.2 then C's package.json needs to become:
{
"name": "C",
"version": "0.0.2",
"dependencies": {
"A": "0.0.2",
"B": "0.0.2"
}
}
I already know how to change a package own version, I don't know how to update its dependencies.
Another thing worth mentioning is that I might need to use other versions sometimes so it's not always an upgrade (let's say for example the latest version is currently 0.2.0 but i need to build 0.1.5, so i can't just use something that will update dependencies to the latest version)
I have tried looking on the internet, I found something (for example this question: NPM - Add to package.json but don't install ) but they still check if the package exists and then give me error.
In the end i realized i did not need a tool that "updated" dependencies but a tool that edited the package.json so I ended using this library https://github.com/zeke/npe
In my bash script i created an array with the dependencies i need to be changed and then I iterate through it
for i in ${projects[@]}
do
npe dependencies.$i ${version}
done