@@ -28,6 +28,8 @@ export const checkNpxIsInstalled = async () => {
28
28
29
29
export const areNodeModulesInstalled = ( ) => ! ! doResolve ( 'resolve' , false ) ;
30
30
31
+ type NpmVersion = { name : string ; value : string } ;
32
+
31
33
export const listAndSelectNpmVersion = async ( c : RnvContext , npmPackage : string ) => {
32
34
const templateVersionsStr = await executeAsync ( c , `npm view ${ npmPackage } versions` ) ;
33
35
const versionArr = templateVersionsStr . replace ( / \r ? \n | \r | \s | ' | \[ | \] / g, '' ) . split ( ',' ) ;
@@ -46,9 +48,11 @@ export const listAndSelectNpmVersion = async (c: RnvContext, npmPackage: string)
46
48
} ) ;
47
49
48
50
versionArr . reverse ( ) ;
49
- const validVersions = versionArr . map ( ( v : string ) => ( { name : v , value : v } ) ) ;
51
+ const validVersions : NpmVersion [ ] = versionArr . map ( ( v : string ) => ( { name : v , value : v } ) ) ;
50
52
51
53
let recommendedVersion ;
54
+ const validVersionsStandard : NpmVersion [ ] = [ ] ;
55
+ const validVersionsHead : NpmVersion [ ] = [ ] ;
52
56
validVersions . forEach ( ( item ) => {
53
57
let matchStr = '' ;
54
58
const matchArr : Array < string > = [ ] ;
@@ -58,24 +62,29 @@ export const listAndSelectNpmVersion = async (c: RnvContext, npmPackage: string)
58
62
}
59
63
} ) ;
60
64
if ( matchArr . length ) {
61
- matchStr = ` (HEAD: ${ matchArr . join ( ', ' ) } )` ;
65
+ matchStr = ` (@ ${ matchArr . join ( ', ' ) } )` ;
62
66
item . name = `${ item . value } ${ matchStr } ` ;
63
67
if ( matchArr [ 0 ] === 'latest' ) {
64
68
recommendedVersion = item ;
65
69
}
70
+ validVersionsHead . push ( item ) ;
71
+ } else {
72
+ validVersionsStandard . push ( item ) ;
66
73
}
67
74
} ) ;
68
75
if ( ! recommendedVersion ) {
69
76
recommendedVersion = validVersions [ 0 ] ;
70
77
}
71
78
79
+ const validVersionsCombined = validVersionsHead . concat ( validVersionsStandard ) ;
80
+
72
81
const { inputTemplateVersion } = await inquirerPrompt ( {
73
82
name : 'inputTemplateVersion' ,
74
83
type : 'list' ,
75
84
message : `What ${ npmPackage } version to use?` ,
76
85
default : recommendedVersion . value ,
77
86
loop : false ,
78
- choices : validVersions ,
87
+ choices : validVersionsCombined ,
79
88
} ) ;
80
89
81
90
return inputTemplateVersion ;
0 commit comments