Our intern project use calendar versioning for our angular typescript project managed with npm.
For example the version 2024.02.19.0
is for the first version of 19 february 2024.
However if I run npm version 2024.02.19.0
, resulting version does not make any sense:
v2024.2.1-9.0
First of all "19" became "1-9" which does not make any sense. and "02" became "2", which ruins alphabetical order.
How do I update my version without npm messing with my version name.
Note: I could manually edit package.json, which is what we have done until now but we plan on scripting it in our GitlabCI. nmp version
also has the courtesy of updating package-lock.json, which is a must.
I solved my problem by not using npm version and instead relying on jq:
VERSION=2024.02.19.0
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv -f tmp.json package.json
jq --arg v "$VERSION" '.version = $v | .packages."".version = $v' package-lock.json > tmp.json && mv -f tmp.json package-lock.json
using a tmp.json
buffer file to edit json 'inplace'