Semantic Versioning Qu' lIj
^2.4.1 package.json Daq precise legh 'ach caret meaning maintainer rules follow vaj choH. Semantic Versioning (semver) promise wej numbers Daq encoded - publisher 'ej consumer cha' yaj vaj promise Qu'.
wej numbers
semver version MAJOR.MINOR.PATCH ghaH. position Hoch meaning ghaj:
- MAJOR - breaking changes increment. existing correct code Qu'be' laH Dochmey Hoch: removed function, renamed parameter, changed return type, new required config field.
- MINOR - new backward-compatible functionality increment. new optional parameters, new exported functions, new config options (sane defaults).
- PATCH - backward-compatible bug fixes increment. new functionality pagh, behavior change pagh ("broken thing DaH documented rap Qu'").
1.4.2 → 1.5.0 "chu', Qaw' pagh". 1.4.2 → 2.0.0 "upgrade qaSpa' changelog laD". distinction 'oH semver value: tooling 'ej humans upgrade decisions commit Hoch laD pagh.
"breaking" strict
instinct: major bump dramatic rewrites vaD. 'ach semver definition any incompatible API change (Dach):
// v1.2.0
function formatPrice(amountCents) {
return `$${(amountCents / 100).toFixed(2)}`;
}
// v1.3.0 — adding an optional param is fine, existing callers are unaffected
function formatPrice(amountCents, currency = 'USD') {
return `${currency} ${(amountCents / 100).toFixed(2)}`;
}
// v2.0.0 — changing the parameter's meaning breaks every existing caller
function formatPrice(amountDollars, currency = 'USD') {
return `${currency} ${amountDollars.toFixed(2)}`;
}
last change one-line diff, minor legh. 'ach caller cents pass silently wrong output (error pagh) - loud breaking change law' Qagh. major bump (code change Dach 'ach).
public exported function remove, synchronous Promise choH, input types narrow, error messages (callers pattern-match) choH - Hoch breaking changes ("big rewrite" legh pagh 'ach).
version ranges: ^ 'ej ~ nuq promise
npm install range operators package.json Daq ghItlh. semver guarantees legh vaj yaj:
{
"dependencies": {
"lodash": "^4.17.21",
"express": "~4.18.2",
"left-pad": "1.3.0"
}
}
^4.17.21(caret) - leftmost non-zero number choHbe' version Hoch accept.4.17.215.0.0Dung (exclusive) - minor patch updates, majors pagh. npm default 'ej dependencies law' vaD Dun: bug fixes new features automatic, breaking changes explicit action.~4.18.2(tilde) - patch-level updates neH:4.18.24.19.0Dung (exclusive). conservative - new features manual.1.3.0(exact) - updates pagh (package.jsonedit pagh). dependency semver Qaw' history paghpackage-lock.jsonindependent reproducible builds poQ vaj.
caret "leftmost non-zero" rule pre-1.0 packages Daq sharp edge: ^0.4.2 patch updates neH (0.4.x), minor pagh - 1.0.0 qaSpa' cha'DIch number breaking-change position. semver 0.x.y "anything might change anytime" - library stable 1.0.0 qatlh.
own package publish: promise correct
package maintain vaj discipline SoH (users pagh):
- bump decide release decide qaSpa'. last release vo' diff legh, categorize: breaking change → major. breaking pagh 'ach new features → minor. pagh → patch. version number wa'DIch pagh.
npm versionlo' (hand edit pagh).package.jsonupdate, git tag chenmoH, valid semver strings.
npm version patch # 1.4.2 -> 1.4.3
npm version minor # 1.4.2 -> 1.5.0
npm version major # 1.4.2 -> 2.0.0
- release Hoch changelog entry ghItlh (commit log neH pagh). "nuq Qaw', nuq chu', nuq fix" - wej sentences Dun. consumer confident upgrade pagh fear pin.
- remove qaSpa' deprecate. old API deprecated mark (docs, JSDoc, runtime warning) minor release wa' Dung major Daq remove - migration window.
pre-release 'ej build metadata
semver general availability qaSpa' suffixes:
2.0.0-alpha.1
2.0.0-beta.3
2.0.0-rc.1
2.0.0
version qaSpa' sort (2.0.0-rc.1 < 2.0.0). package managers normal range Daq install pagh - npm install mypackage@next pagh exact pre-release. in-progress major early testing ship (^1.x.x consumer accident pagh).
yaj
Semver contract (formality pagh): MAJOR "upgrade qaSpa' laD", MINOR "automatic safe, chu'", PATCH "bug fix neH". package.json range operators dependencies contract honor vaj protect. own packages consumers protect SoH rap vaj.