MCPcopy
hub / github.com/desktop/desktop / getNextVersionNumber

Function getNextVersionNumber

script/draft-release/version.ts:24–101  ·  view source on GitHub ↗
(
  version: string,
  channel: Channel
)

Source from the content-addressed store, hash-verified

22}
23
24export function getNextVersionNumber(
25 version: string,
26 channel: Channel
27): string {
28 const semanticVersion = parse(version)
29
30 if (semanticVersion == null) {
31 throw new Error(`Unable to parse input '${version}' into version`)
32 }
33
34 switch (channel) {
35 case 'production':
36 if (isBetaTag(semanticVersion)) {
37 throw new Error(
38 `Unable to draft production release using beta version '${version}'`
39 )
40 }
41
42 if (isTestTag(semanticVersion)) {
43 throw new Error(
44 `Unable to draft production release using test version '${version}'`
45 )
46 }
47
48 const nextVersion = inc(version, 'patch')
49 if (nextVersion == null) {
50 throw new Error(
51 `Unable to increment next production version from release version '${version}'`
52 )
53 }
54
55 return nextVersion
56
57 case 'beta':
58 if (isTestTag(semanticVersion)) {
59 throw new Error(
60 `Unable to draft beta release using test version '${version}'`
61 )
62 }
63
64 const betaNumber = tryGetBetaNumber(semanticVersion)
65
66 if (betaNumber) {
67 return semanticVersion.version.replace(
68 `-beta${betaNumber}`,
69 `-beta${betaNumber + 1}`
70 )
71 } else {
72 const nextVersion = inc(semanticVersion, 'patch')
73 const firstBeta = `${nextVersion}-beta1`
74 return firstBeta
75 }
76 case 'test':
77 if (isBetaTag(semanticVersion)) {
78 throw new Error(
79 `Unable to draft test release using beta version '${version}'`
80 )
81 }

Callers 3

runFunction · 0.90
commandVersionFunction · 0.90
version-test.tsFile · 0.90

Calls 4

isBetaTagFunction · 0.85
isTestTagFunction · 0.85
tryGetBetaNumberFunction · 0.85
parseFunction · 0.50

Tested by

no test coverage detected