File size: 1,529 Bytes
d97b8f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**

 * 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;
};