@@ -13,84 +13,93 @@ type PromptResultType = {
1313 iosLanguage ?: IosLanguageType ;
1414} ;
1515
16- export async function promptAdditionalOptions ( tree : Tree , options : NormalizedSchema ) {
17- if ( process . env . NX_INTERACTIVE === 'true' && [ 'app' , 'plugin' ] . includes ( options . template ) ) {
18-
19- await prompt ( [
16+ export async function promptAdditionalOptions (
17+ tree : Tree ,
18+ options : NormalizedSchema
19+ ) {
20+ if (
21+ process . env . NX_INTERACTIVE === 'true' &&
22+ [ 'app' , 'plugin' ] . includes ( options . template )
23+ ) {
24+ await prompt ( [
25+ {
26+ name : 'platforms' ,
27+ type : 'multiselect' ,
28+ choices : [
29+ {
30+ name : 'android' ,
31+ value : 'Android platform' ,
32+ } ,
33+ {
34+ name : 'ios' ,
35+ value : 'iOS platform' ,
36+ } ,
37+ {
38+ name : 'linux' ,
39+ value : 'Linux platform' ,
40+ } ,
41+ {
42+ name : 'windows' ,
43+ value : 'Windows platform' ,
44+ } ,
2045 {
21- name : 'platforms' ,
22- type : 'multiselect' ,
23- choices : [
24- {
25- name : "android" ,
26- value : "Android platform" ,
27- } ,
28- {
29- name : "ios" ,
30- value : "iOS platform" ,
31- } ,
32- {
33- name : "linux" ,
34- value : "Linux platform" ,
35- } ,
36- {
37- name : "windows" ,
38- value : "Windows platform" ,
39- } ,
40- {
41- name : "macos" ,
42- value : "MacOS platform" ,
43- } ,
44- {
45- name : "web" ,
46- value : "Web platform" ,
47- }
48- ] ,
49- validate : ( platforms ) => {
50- return platforms ?. length ? true : 'You must select at least one platform'
46+ name : 'macos' ,
47+ value : 'MacOS platform' ,
48+ } ,
49+ {
50+ name : 'web' ,
51+ value : 'Web platform' ,
52+ } ,
53+ ] ,
54+ validate : ( platforms ) => {
55+ return platforms ?. length
56+ ? true
57+ : 'You must select at least one platform' ;
58+ } ,
59+ message : 'Which platforms would you like to use?' ,
60+ } ,
61+ ] ) . then ( async ( result : Partial < PromptResultType > ) => {
62+ const languages : Partial < PromptResultType > = await prompt ( [
63+ {
64+ skip : ( ) => result . platforms ?. indexOf ( 'android' ) === - 1 ,
65+ name : 'androidLanguage' ,
66+ type : 'select' ,
67+ initial : 1 ,
68+ choices : [
69+ {
70+ name : 'java' ,
71+ value : 'Java' ,
5172 } ,
52- message : 'Which platforms would you like to use?'
53- } ] ) . then ( async ( result : Partial < PromptResultType > ) => {
54-
55- const languages : Partial < PromptResultType > = await prompt ( [
56- {
57- skip : ( ) => result . platforms ?. indexOf ( 'android' ) === - 1 ,
58- name : 'androidLanguage' ,
59- type : 'select' ,
60- initial : 1 ,
61- choices : [
62- {
63- name : "java" ,
64- value : "Java"
65- } ,
66- {
67- name : "kotlin" ,
68- value : "Kotlin"
69- }
70- ] ,
71- message : "Which Android language would you like to use?" ,
72- } ,
73- {
74- skip : ( ) => result . platforms ?. indexOf ( 'ios' ) === - 1 ,
75- name : 'iosLanguage' ,
76- type : 'select' ,
77- initial : 1 ,
78- choices : [
79- {
80- name : "objc" ,
81- value : "Objective-C"
82- } ,
83- {
84- name : "swift" ,
85- value : "Swift"
86- }
87- ] ,
88- message : "Which iOS language would you like to use?" ,
89- }
90- ] ) ;
91- options . platforms = result ?. platforms ;
92- options . androidLanguage = languages ?. androidLanguage ;
93- options . iosLanguage = languages ?. iosLanguage ;
94- } ) ;
95- }
73+ {
74+ name : 'kotlin' ,
75+ value : 'Kotlin' ,
76+ } ,
77+ ] ,
78+ message : 'Which Android language would you like to use?' ,
79+ } ,
80+ {
81+ skip : ( ) =>
82+ result . platforms ?. indexOf ( 'ios' ) === - 1 ||
83+ options . template !== 'plugin' ,
84+ name : 'iosLanguage' ,
85+ type : 'select' ,
86+ initial : 1 ,
87+ choices : [
88+ {
89+ name : 'objc' ,
90+ value : 'Objective-C' ,
91+ } ,
92+ {
93+ name : 'swift' ,
94+ value : 'Swift' ,
95+ } ,
96+ ] ,
97+ message : 'Which iOS language would you like to use?' ,
98+ } ,
99+ ] ) ;
100+ options . platforms = result ?. platforms ;
101+ options . androidLanguage = languages ?. androidLanguage ;
102+ options . iosLanguage = languages ?. iosLanguage ;
103+ } ) ;
104+ }
96105}
0 commit comments