@@ -12,7 +12,7 @@ import { isPrerelease, releaseTypes } from './release-type'
12
12
*/
13
13
export async function getNewVersion ( operation : Operation ) : Promise < Operation > {
14
14
const { release } = operation . options
15
- const { oldVersion } = operation . state
15
+ const { currentVersion } = operation . state
16
16
17
17
switch ( release . type ) {
18
18
case 'prompt' :
@@ -26,16 +26,16 @@ export async function getNewVersion(operation: Operation): Promise<Operation> {
26
26
default :
27
27
return operation . update ( {
28
28
release : release . type ,
29
- newVersion : getNextVersion ( oldVersion , release ) ,
29
+ newVersion : getNextVersion ( currentVersion , release ) ,
30
30
} )
31
31
}
32
32
}
33
33
34
34
/**
35
35
* Returns the next version number of the specified type.
36
36
*/
37
- function getNextVersion ( oldVersion : string , bump : BumpRelease ) : string {
38
- const oldSemVer = new SemVer ( oldVersion )
37
+ function getNextVersion ( currentVersion : string , bump : BumpRelease ) : string {
38
+ const oldSemVer = new SemVer ( currentVersion )
39
39
40
40
const type = bump . type === 'next'
41
41
? oldSemVer . prerelease . length ? 'prerelease' : 'patch'
@@ -63,15 +63,15 @@ function getNextVersion(oldVersion: string, bump: BumpRelease): string {
63
63
/**
64
64
* Returns the next version number for all release types.
65
65
*/
66
- function getNextVersions ( oldVersion : string , preid : string ) : Record < ReleaseType , string > {
66
+ function getNextVersions ( currentVersion : string , preid : string ) : Record < ReleaseType , string > {
67
67
const next : Record < string , string > = { }
68
68
69
- const parse = semver . parse ( oldVersion )
69
+ const parse = semver . parse ( currentVersion )
70
70
if ( typeof parse ?. prerelease [ 0 ] === 'string' )
71
71
preid = parse ?. prerelease [ 0 ] || 'preid'
72
72
73
73
for ( const type of releaseTypes )
74
- next [ type ] = getNextVersion ( oldVersion , { type, preid } )
74
+ next [ type ] = getNextVersion ( currentVersion , { type, preid } )
75
75
76
76
return next
77
77
}
@@ -82,18 +82,18 @@ function getNextVersions(oldVersion: string, preid: string): Record<ReleaseType,
82
82
* @returns - A tuple containing the new version number and the release type (if any)
83
83
*/
84
84
async function promptForNewVersion ( operation : Operation ) : Promise < Operation > {
85
- const { oldVersion } = operation . state
85
+ const { currentVersion } = operation . state
86
86
const release = operation . options . release as PromptRelease
87
87
88
- const next = getNextVersions ( oldVersion , release . preid )
89
- const configCustomVersion = await operation . options . customVersion ?.( oldVersion , semver )
88
+ const next = getNextVersions ( currentVersion , release . preid )
89
+ const configCustomVersion = await operation . options . customVersion ?.( currentVersion , semver )
90
90
91
91
const PADDING = 13
92
92
const answers = await prompts ( [
93
93
{
94
94
type : 'autocomplete' ,
95
95
name : 'release' ,
96
- message : `Current version ${ c . green ( oldVersion ) } ` ,
96
+ message : `Current version ${ c . green ( currentVersion ) } ` ,
97
97
initial : configCustomVersion ? 'config' : 'next' ,
98
98
choices : [
99
99
{ value : 'major' , title : `${ 'major' . padStart ( PADDING , ' ' ) } ${ c . bold ( next . major ) } ` } ,
@@ -108,15 +108,15 @@ async function promptForNewVersion(operation: Operation): Promise<Operation> {
108
108
{ value : 'prepatch' , title : `${ 'pre-patch' . padStart ( PADDING , ' ' ) } ${ c . bold ( next . prepatch ) } ` } ,
109
109
{ value : 'preminor' , title : `${ 'pre-minor' . padStart ( PADDING , ' ' ) } ${ c . bold ( next . preminor ) } ` } ,
110
110
{ value : 'premajor' , title : `${ 'pre-major' . padStart ( PADDING , ' ' ) } ${ c . bold ( next . premajor ) } ` } ,
111
- { value : 'none' , title : `${ 'as-is' . padStart ( PADDING , ' ' ) } ${ c . bold ( oldVersion ) } ` } ,
111
+ { value : 'none' , title : `${ 'as-is' . padStart ( PADDING , ' ' ) } ${ c . bold ( currentVersion ) } ` } ,
112
112
{ value : 'custom' , title : 'custom ...' . padStart ( PADDING + 4 , ' ' ) } ,
113
113
] ,
114
114
} ,
115
115
{
116
116
type : prev => prev === 'custom' ? 'text' : null ,
117
117
name : 'custom' ,
118
118
message : 'Enter the new version number:' ,
119
- initial : oldVersion ,
119
+ initial : currentVersion ,
120
120
validate : ( custom : string ) => {
121
121
return isValidVersion ( custom ) ? true : 'That\'s not a valid version number'
122
122
} ,
@@ -127,7 +127,7 @@ async function promptForNewVersion(operation: Operation): Promise<Operation> {
127
127
}
128
128
129
129
const newVersion = answers . release === 'none'
130
- ? oldVersion
130
+ ? currentVersion
131
131
: answers . release === 'custom'
132
132
? cleanVersion ( answers . custom ! ) !
133
133
: answers . release === 'config'
0 commit comments