diff options
| author | netop://ウィビ <paul@webb.page> | 2026-10-17 16:29:19 -0700 |
|---|---|---|
| committer | netop://ウィビ <paul@webb.page> | 2026-10-17 16:29:19 -0700 |
| commit | 14279df2e5affd44f957f5b52ad5d6267e31fa57 (patch) | |
| tree | fad5858161a34a4adc163a54c334d37c0a7529a0 /README.md | |
| parent | 6fdfb6f5758b354861d837982ab9de76020739b2 (diff) | |
| download | chronver-14279df2e5affd44f957f5b52ad5d6267e31fa57.tar.gz chronver-14279df2e5affd44f957f5b52ad5d6267e31fa57.zip | |
stricter parsing - v3.0.0 - fixes CLI changeset flag, padded year, debug output - updates deno.json permissionsHEADprimary
Diffstat (limited to '')
| -rw-r--r-- | README.md | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -35,6 +35,37 @@ YYYY.MM.DD[.CHANGESET][-FEATURE|-break] +## Rules + +A version is a date, then an optional changeset, then at most one label: a feature or `-break`. Every valid version has exactly one spelling, so `toString()` gives back the string it was parsed from. + +- **Date**: `YYYY.MM.DD`, always 4 + 2 + 2 digits. The year runs from `0001` to `9999` and is zero-padded. It must be a real calendar date: `2024.02.29` is valid, but `2023.02.29` and `2024.04.31` aren't. +- **Changeset**: `.N`, where `N` is a whole number from 1 to 9007199254740991 (`Number.MAX_SAFE_INTEGER`) with no leading zeros. Leave it out for 0, since `.0` and `.01` are rejected. +- **Feature**: `-name`, where the name uses letters, digits and hyphens and contains at least one letter or digit (`2024.04.03--` is rejected). +- **Breaking**: `-break`. A version is a feature or breaking, never both. `2024.04.03-ui-break` is the feature `ui-break`, and `-breaking` is a feature too. +- Nothing follows the label, so `2024.04.03-feature.5` and `2024.04.03-break.1` are rejected. Put the changeset first: `2024.04.03.5-feature`. +- `new ChronVer()` with no argument is today's version, but an empty string is invalid. + +### Ordering + +Versions compare by year, month, day, then changeset. When all four match, `-break` sorts after the version without it. Features are ignored, so `2024.04.03-a`, `2024.04.03-b` and `2024.04.03` are equal. + +``` +2024.04.03 < 2024.04.03-break < 2024.04.03.1 < 2024.04.03.1-break < 2024.04.04 +``` + +### Incrementing + +`increment()` works from today's local date: + +- **Same day**: the changeset goes up by 1 (`2025.07.21.1` → `2025.07.21.2`). +- **Earlier day**: today's version with no changeset (`2025.07.20.3` → `2025.07.21`). +- **Later day**: it throws, because a version dated in the future can't be incremented. + +The result never keeps the feature or `-break`: `2025.07.21.1-break` becomes `2025.07.21.2` that day. + + + ## Installation ### Deno @@ -127,7 +158,7 @@ console.log(v2.isNewerThan(v1)); // true // increment version const incremented = version.increment(); -console.log(incremented.toString()); // "2024.07.19.1" (if same day) +console.log(incremented.toString()); // "2025.07.21.1" (if same day) ``` ### Static Methods |