Semantic Versioning with Yarn Commands
Semantic Versioning / SemVer
Semantic versioning aka. Semver is rules and requirements that dictate how version numbers are assigned and incremented based on the common practices used in both closed and open-source software.
In software management, we have a problem of “dependency hell”, where version lock and/or version promiscuity prevents you from easily and safely moving your project forward.
If the dependency specifications are too tight you are in danger of version lock (the inability to upgrade a package without having to release new versions of every dependent package). If dependencies are specified too loosely, you will inevitably be bitten by version promiscuity (assuming compatibility with more future versions than is reasonable).
The bigger the project grows and the more packages you integrate, the more likely you are to find yourself, one day, in this pit of despair.
To overcome this problem, semantic version(semver) concept was introduced. Under this scheme, version numbers are the way to convey meaning about the code and what has been modified from one version to the next.
There are three major components number in semver.
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
- PATCH version when you make backwards-compatible bug fixes.
Yarn
Yarn is a fast, reliable, and secure dependency management for nodejs. It caches every package that has download and uses checksums to verify the integrity of every package before the code is executed.
Yarn command ’s
To update the version of your package.json file you can run this command.
yarn version
You can input the desired version you like. After the input, you will get an updated version.
To make a patch version upgrade
yarn version --patch
To make a major version upgrade
yarn version --major
To make a minor version upgrade
yarn version --minor