Spaces:
Sleeping
Sleeping
| /** | |
| * Application version management | |
| * | |
| * Version format: MAJOR.MINOR.PATCH | |
| * | |
| * Rules for incrementing: | |
| * - PATCH: Small bug fixes and minor changes | |
| * - MINOR: New features that don't break backward compatibility | |
| * - MAJOR: Breaking changes or significant new features | |
| * | |
| * When MINOR reaches 10, increment MAJOR and reset MINOR to 0 | |
| * Example: 2.10.0 -> 3.0.0 | |
| */ | |
| export interface Version { | |
| major: number; | |
| minor: number; | |
| patch: number; | |
| } | |
| export const APP_VERSION: Version = { | |
| major: 2, | |
| minor: 3, | |
| patch: 51 | |
| }; | |
| /** | |
| * Returns the full version string | |
| */ | |
| export const getVersionString = (): string => { | |
| return `${APP_VERSION.major}.${APP_VERSION.minor}.${APP_VERSION.patch}`; | |
| }; | |
| /** | |
| * Increments version according to semver rules with custom handling | |
| * for MINOR reaching 10 (bumps MAJOR instead) | |
| */ | |
| export const incrementVersion = ( | |
| version: Version, | |
| type: 'major' | 'minor' | 'patch' | |
| ): Version => { | |
| const newVersion = { ...version }; | |
| switch (type) { | |
| case 'major': | |
| newVersion.major += 1; | |
| newVersion.minor = 0; | |
| newVersion.patch = 0; | |
| break; | |
| case 'minor': | |
| newVersion.minor += 1; | |
| newVersion.patch = 0; | |
| // Custom rule: When minor reaches 10, increment major instead | |
| if (newVersion.minor === 10) { | |
| newVersion.major += 1; | |
| newVersion.minor = 0; | |
| } | |
| break; | |
| case 'patch': | |
| newVersion.patch += 1; | |
| break; | |
| } | |
| return newVersion; | |
| }; |