@@ -41,33 +41,70 @@ const NATIVE_COMMON_EXAMPLE_FILES = path.resolve(
4141) ;
4242
4343const NATIVE_FILES = {
44- module_legacy : path . resolve ( __dirname , '../templates/native-library-legacy' ) ,
45- module_new : path . resolve ( __dirname , '../templates/native-library-new' ) ,
46- module_mixed : path . resolve ( __dirname , '../templates/native-library-mixed' ) ,
47- view_legacy : path . resolve ( __dirname , '../templates/native-view-legacy' ) ,
48- view_mixed : path . resolve ( __dirname , '../templates/native-view-mixed' ) ,
49- view_new : path . resolve ( __dirname , '../templates/native-view-new' ) ,
44+ 'module-legacy' : path . resolve (
45+ __dirname ,
46+ '../templates/native-library-legacy'
47+ ) ,
48+ 'module-new' : path . resolve ( __dirname , '../templates/native-library-new' ) ,
49+ 'module-mixed' : path . resolve ( __dirname , '../templates/native-library-mixed' ) ,
50+ 'view-legacy' : path . resolve ( __dirname , '../templates/native-view-legacy' ) ,
51+ 'view-module-legacy' : path . resolve (
52+ __dirname ,
53+ '../templates/native-view-library-legacy'
54+ ) ,
55+ 'view-module-mixed' : path . resolve (
56+ __dirname ,
57+ '../templates/native-view-library-mixed'
58+ ) ,
59+ 'view-module-new' : path . resolve (
60+ __dirname ,
61+ '../templates/native-view-library-new'
62+ ) ,
5063} as const ;
5164
5265const OBJC_FILES = {
53- module_common : path . resolve ( __dirname , '../templates/objc-library' ) ,
54- view_legacy : path . resolve ( __dirname , '../templates/objc-view-legacy' ) ,
55- view_mixed : path . resolve ( __dirname , '../templates/objc-view-mixed' ) ,
56- view_new : path . resolve ( __dirname , '../templates/objc-view-new' ) ,
66+ 'module-legacy' : path . resolve ( __dirname , '../templates/objc-library' ) ,
67+ 'module-mixed' : path . resolve ( __dirname , '../templates/objc-library' ) ,
68+ 'module-new' : path . resolve ( __dirname , '../templates/objc-library' ) ,
69+ 'view-module-legacy' : path . resolve (
70+ __dirname ,
71+ '../templates/objc-view-library-legacy'
72+ ) ,
73+ 'view-module-mixed' : path . resolve (
74+ __dirname ,
75+ '../templates/objc-view-library-mixed'
76+ ) ,
77+ 'view-module-new' : path . resolve (
78+ __dirname ,
79+ '../templates/objc-view-library-new'
80+ ) ,
5781} as const ;
5882
5983const KOTLIN_FILES = {
60- module_legacy : path . resolve ( __dirname , '../templates/kotlin-library-legacy' ) ,
61- module_new : path . resolve ( __dirname , '../templates/kotlin-library-new' ) ,
62- module_mixed : path . resolve ( __dirname , '../templates/kotlin-library-mixed' ) ,
63- view_legacy : path . resolve ( __dirname , '../templates/kotlin-view-legacy' ) ,
64- view_mixed : path . resolve ( __dirname , '../templates/kotlin-view-mixed' ) ,
65- view_new : path . resolve ( __dirname , '../templates/kotlin-view-new' ) ,
84+ 'module-legacy' : path . resolve (
85+ __dirname ,
86+ '../templates/kotlin-library-legacy'
87+ ) ,
88+ 'module-new' : path . resolve ( __dirname , '../templates/kotlin-library-new' ) ,
89+ 'module-mixed' : path . resolve ( __dirname , '../templates/kotlin-library-mixed' ) ,
90+ 'view-legacy' : path . resolve ( __dirname , '../templates/kotlin-view-legacy' ) ,
91+ 'view-module-legacy' : path . resolve (
92+ __dirname ,
93+ '../templates/kotlin-view-library-legacy'
94+ ) ,
95+ 'view-module-mixed' : path . resolve (
96+ __dirname ,
97+ '../templates/kotlin-view-library-mixed'
98+ ) ,
99+ 'view-module-new' : path . resolve (
100+ __dirname ,
101+ '../templates/kotlin-view-library-new'
102+ ) ,
66103} as const ;
67104
68105const SWIFT_FILES = {
69- module_legacy : path . resolve ( __dirname , '../templates/swift-library-legacy' ) ,
70- view_legacy : path . resolve ( __dirname , '../templates/swift-view-legacy' ) ,
106+ 'module-legacy' : path . resolve ( __dirname , '../templates/swift-library-legacy' ) ,
107+ 'view-legacy' : path . resolve ( __dirname , '../templates/swift-view-legacy' ) ,
71108} as const ;
72109
73110type ArgName =
@@ -86,13 +123,14 @@ type ArgName =
86123type ProjectLanguages = 'kotlin-objc' | 'kotlin-swift' | 'cpp' | 'js' ;
87124
88125type ProjectType =
126+ | 'library'
89127 | 'module-legacy'
90- | 'module-new'
91128 | 'module-mixed'
92- | 'view-mixed'
93- | 'view-new'
129+ | 'module-new'
94130 | 'view-legacy'
95- | 'library' ;
131+ | 'view-module-legacy'
132+ | 'view-module-mixed'
133+ | 'view-module-new' ;
96134
97135type Answers = {
98136 name : string ;
@@ -117,14 +155,7 @@ const LANGUAGE_CHOICES: {
117155 {
118156 title : 'Kotlin & Objective-C' ,
119157 value : 'kotlin-objc' ,
120- types : [
121- 'module-legacy' ,
122- 'module-new' ,
123- 'module-mixed' ,
124- 'view-mixed' ,
125- 'view-new' ,
126- 'view-legacy' ,
127- ] ,
158+ types : [ 'view-module-legacy' , 'view-module-mixed' , 'view-module-new' ] ,
128159 } ,
129160 {
130161 title : 'Kotlin & Swift' ,
@@ -169,6 +200,21 @@ const TYPE_CHOICES: {
169200 value : ProjectType ;
170201 description : string ;
171202} [ ] = [
203+ {
204+ title : 'Fabric view and Turbo module with backward compat' ,
205+ value : 'view-module-mixed' ,
206+ description : BACKCOMPAT_DESCRIPTION ,
207+ } ,
208+ {
209+ title : 'Fabric view and Turbo module' ,
210+ value : 'view-module-new' ,
211+ description : NEWARCH_DESCRIPTION ,
212+ } ,
213+ {
214+ title : 'Native module and Native view' ,
215+ value : 'view-module-legacy' ,
216+ description : 'bridge for native APIs and views to JS' ,
217+ } ,
172218 {
173219 title : 'JavaScript library' ,
174220 value : 'library' ,
@@ -194,16 +240,6 @@ const TYPE_CHOICES: {
194240 value : 'module-new' ,
195241 description : NEWARCH_DESCRIPTION ,
196242 } ,
197- {
198- title : 'Fabric view with backward compat' ,
199- value : 'view-mixed' ,
200- description : BACKCOMPAT_DESCRIPTION ,
201- } ,
202- {
203- title : 'Fabric view' ,
204- value : 'view-new' ,
205- description : NEWARCH_DESCRIPTION ,
206- } ,
207243] ;
208244
209245const args : Record < ArgName , yargs . Options > = {
@@ -599,13 +635,11 @@ async function create(_argv: yargs.Arguments<any>) {
599635 bobVersion = FALLBACK_BOB_VERSION ;
600636 }
601637
602- const moduleType = type . startsWith ( 'view-' ) ? 'view' : 'module' ;
603- const arch =
604- type === 'module-new' || type === 'view-new'
605- ? 'new'
606- : type === 'module-mixed' || type === 'view-mixed'
607- ? 'mixed'
608- : 'legacy' ;
638+ const arch = type . endsWith ( 'new' )
639+ ? 'new'
640+ : type . endsWith ( 'mixed' )
641+ ? 'mixed'
642+ : 'legacy' ;
609643
610644 const project = slug . replace ( / ^ ( r e a c t - n a t i v e - | @ [ ^ / ] + \/ ) / , '' ) ;
611645
@@ -646,8 +680,8 @@ async function create(_argv: yargs.Arguments<any>) {
646680 arch,
647681 cpp : languages === 'cpp' ,
648682 swift : languages === 'kotlin-swift' ,
649- view : moduleType === 'view' ,
650- module : moduleType === 'module' ,
683+ view : type . includes ( 'view' ) ,
684+ module : type . includes ( 'module' ) ,
651685 } ,
652686 author : {
653687 name : authorName ,
@@ -735,7 +769,7 @@ async function create(_argv: yargs.Arguments<any>) {
735769 }
736770 }
737771
738- if ( languages === 'js ' ) {
772+ if ( type === 'library ' ) {
739773 await copyDir ( JS_FILES , folder ) ;
740774 await copyDir ( EXPO_FILES , folder ) ;
741775 } else {
@@ -745,25 +779,18 @@ async function create(_argv: yargs.Arguments<any>) {
745779 await copyDir ( NATIVE_COMMON_EXAMPLE_FILES , folder ) ;
746780 }
747781
748- if ( moduleType === 'module' ) {
749- await copyDir ( NATIVE_FILES [ `${ moduleType } _${ arch } ` ] , folder ) ;
750- } else {
751- await copyDir ( NATIVE_FILES [ `${ moduleType } _${ arch } ` ] , folder ) ;
752- }
782+ await copyDir ( NATIVE_FILES [ type ] , folder ) ;
753783
754- if ( options . project . swift ) {
755- await copyDir ( SWIFT_FILES [ `${ moduleType } _legacy` ] , folder ) ;
784+ if (
785+ type === 'view-legacy' ||
786+ ( type === 'module-legacy' && options . project . swift )
787+ ) {
788+ await copyDir ( SWIFT_FILES [ type ] , folder ) ;
756789 } else {
757- if ( moduleType === 'module' ) {
758- await copyDir ( OBJC_FILES [ `${ moduleType } _common` ] , folder ) ;
759- } else {
760- await copyDir ( OBJC_FILES [ `view_${ arch } ` ] , folder ) ;
761- }
790+ await copyDir ( OBJC_FILES [ type ] , folder ) ;
762791 }
763792
764- const templateType = `${ moduleType } _${ arch } ` as const ;
765-
766- await copyDir ( KOTLIN_FILES [ templateType ] , folder ) ;
793+ await copyDir ( KOTLIN_FILES [ type ] , folder ) ;
767794
768795 if ( options . project . cpp ) {
769796 await copyDir ( CPP_FILES , folder ) ;
0 commit comments