Versions and Semver
Control which versions you accept with semver ranges, then check and update them.
In this lesson you will learn the version ranges CommandBox understands, install with one, and use outdated and update to keep dependencies current.
Semantic versions
A version has three numbers, major.minor.patch, such as 4.3.1. A patch is a bug fix, a minor adds features, and a major may break things. Ranges let you say how much change you accept.
Ranges in box.json
Ranges are written as the value of each dependency:
"dependencies" : {
"coldbox" : "^7.0.0"
}
| Range | Meaning |
|---|---|
1.2.3 | exactly that version |
^1.2.3 | any 1.x.x from 1.2.3 up, never 2.0 |
~1.2.3 | patch updates only, so 1.2.x |
>=2.0.0 <=2.5.0 | between two versions |
2.0.0 - 2.5.0 | the same range, as a hyphen range |
1.x \|\| >=2.5.0 | either condition may match |
The caret is the default range CommandBox writes when you install from ForgeBox.
Install with a range
box install coldbox@^7.0.0
Check what is behind
box outdated
This compares each dependency against what is available. Use --hideUpToDate to show only the ones with an update:
box outdated --hideUpToDate
Update
box update
box update coldbox
With no slug, update upgrades every dependency that has a newer version inside its range. Pass one or more slugs, comma separated, to update only those.
Add --force to skip the confirmation prompt, for example box update --force.
Recap
- Ranges in
box.jsonset how much change you accept,^being the default. box install name@^x.y.zinstalls and saves with a range.box outdatedshows what is behind andbox updatebrings it forward.