@@ -16,14 +16,18 @@ const JS_FILES = path.resolve(__dirname, '../templates/js-library');
16
16
const EXPO_FILES = path . resolve ( __dirname , '../templates/expo-library' ) ;
17
17
const CPP_FILES = path . resolve ( __dirname , '../templates/cpp-library' ) ;
18
18
const EXAMPLE_FILES = path . resolve ( __dirname , '../templates/example' ) ;
19
+ const NATIVE_COMMON_FILES = path . resolve (
20
+ __dirname ,
21
+ '../templates/native-common'
22
+ ) ;
19
23
20
- // Android
21
- const NATIVE_FILES = ( moduleType : ModuleType ) => {
24
+ // Java
25
+ const JAVA_FILES = ( moduleType : ModuleType ) => {
22
26
switch ( moduleType ) {
23
27
case 'module' :
24
- return path . resolve ( __dirname , '../templates/native -library' ) ;
28
+ return path . resolve ( __dirname , '../templates/java -library' ) ;
25
29
case 'view' :
26
- return path . resolve ( __dirname , '../templates/native -view-library' ) ;
30
+ return path . resolve ( __dirname , '../templates/java -view-library' ) ;
27
31
}
28
32
} ;
29
33
@@ -37,6 +41,16 @@ const OBJC_FILES = (moduleType: ModuleType) => {
37
41
}
38
42
} ;
39
43
44
+ // Kotlin
45
+ const KOTLIN_FILES = ( moduleType : ModuleType ) => {
46
+ switch ( moduleType ) {
47
+ case 'module' :
48
+ return path . resolve ( __dirname , '../templates/kotlin-library' ) ;
49
+ case 'view' :
50
+ return path . resolve ( __dirname , '../templates/kotlin-view-library' ) ;
51
+ }
52
+ } ;
53
+
40
54
// Swift
41
55
const SWIFT_FILES = ( moduleType : ModuleType ) => {
42
56
switch ( moduleType ) {
@@ -59,12 +73,16 @@ type ArgName =
59
73
type ModuleType = 'module' | 'view' ;
60
74
61
75
type LibraryType =
62
- | 'native-view'
63
- | 'native-view-swift'
64
76
| 'native'
65
77
| 'native-swift'
66
- | 'js'
78
+ | 'native-kotlin'
79
+ | 'native-kotlin-swift'
80
+ | 'native-view'
81
+ | 'native-view-swift'
82
+ | 'native-view-kotlin'
83
+ | 'native-view-kotlin-swift'
67
84
| 'cpp'
85
+ | 'js'
68
86
| 'expo' ;
69
87
70
88
type Answers = {
@@ -104,7 +122,19 @@ const args: Record<ArgName, yargs.Options> = {
104
122
} ,
105
123
'type' : {
106
124
description : 'Type package do you want to develop' ,
107
- choices : [ 'native' , 'native-swift' , 'js' , 'cpp' , 'expo' ] ,
125
+ choices : [
126
+ 'native' ,
127
+ 'native-swift' ,
128
+ 'native-kotlin' ,
129
+ 'native-kotlin-swift' ,
130
+ 'native-view' ,
131
+ 'native-view-swift' ,
132
+ 'native-view-kotlin' ,
133
+ 'native-view-kotlin-swift' ,
134
+ 'cpp' ,
135
+ 'js' ,
136
+ 'expo' ,
137
+ ] ,
108
138
} ,
109
139
} ;
110
140
@@ -218,17 +248,33 @@ async function create(argv: yargs.Arguments<any>) {
218
248
name : 'type' ,
219
249
message : 'What type of package do you want to develop?' ,
220
250
choices : [
221
- { title : 'Native module in Kotlin and Objective-C' , value : 'native' } ,
222
- { title : 'Native module in Kotlin and Swift' , value : 'native-swift' } ,
251
+ { title : 'Native module in Java and Objective-C' , value : 'native' } ,
252
+ { title : 'Native module in Java and Swift' , value : 'native-swift' } ,
253
+ {
254
+ title : 'Native module in Kotlin and Objective-C' ,
255
+ value : 'native-kotlin' ,
256
+ } ,
257
+ {
258
+ title : 'Native module in Kotlin and Swift' ,
259
+ value : 'native-kotlin-swift' ,
260
+ } ,
223
261
{ title : 'Native module with C++ code' , value : 'cpp' } ,
224
262
{
225
- title : 'Native view in Kotlin and Objective-C' ,
263
+ title : 'Native view in Java and Objective-C' ,
226
264
value : 'native-view' ,
227
265
} ,
228
266
{
229
- title : 'Native view in Kotlin and Swift' ,
267
+ title : 'Native view in Java and Swift' ,
230
268
value : 'native-view-swift' ,
231
269
} ,
270
+ {
271
+ title : 'Native view in Kotlin and Objective-C' ,
272
+ value : 'native-view-kotlin' ,
273
+ } ,
274
+ {
275
+ title : 'Native view in Kotlin and Swift' ,
276
+ value : 'native-view-kotlin-swift' ,
277
+ } ,
232
278
{
233
279
title : 'JavaScript library with native example' ,
234
280
value : 'js' ,
@@ -265,7 +311,12 @@ async function create(argv: yargs.Arguments<any>) {
265
311
266
312
const project = slug . replace ( / ^ ( r e a c t - n a t i v e - | @ [ ^ / ] + \/ ) / , '' ) ;
267
313
const moduleType : ModuleType =
268
- type === 'native-view' || type === 'native-view-swift' ? 'view' : 'module' ;
314
+ type === 'native-view' ||
315
+ type === 'native-view-swift' ||
316
+ type === 'native-view-kotlin' ||
317
+ type === 'native-view-kotlin-swift'
318
+ ? 'view'
319
+ : 'module' ;
269
320
270
321
// Get latest version of Bob from NPM
271
322
let version : string ;
@@ -308,13 +359,26 @@ async function create(argv: yargs.Arguments<any>) {
308
359
package : slug . replace ( / [ ^ a - z 0 - 9 ] / g, '' ) . toLowerCase ( ) ,
309
360
podspec : slug . replace ( / [ ^ a - z 0 - 9 ] + / g, '-' ) . replace ( / ^ - / , '' ) ,
310
361
native :
311
- type === 'native' ||
312
362
type === 'cpp' ||
313
- 'native-swift' ||
314
- 'native-view' ||
315
- 'native-view-swift' ,
363
+ type === 'native' ||
364
+ type === 'native-swift' ||
365
+ type === 'native-kotlin' ||
366
+ type === 'native-kotlin-swift' ||
367
+ type === 'native-view' ||
368
+ type === 'native-view-swift' ||
369
+ type === 'native-view-kotlin' ||
370
+ type === 'native-view-kotlin-swift' ,
316
371
cpp : type === 'cpp' ,
317
- swift : type === 'native-swift' || 'native-view-swift' ,
372
+ kotlin :
373
+ type === 'native-kotlin' ||
374
+ type === 'native-kotlin-swift' ||
375
+ type === 'native-view-kotlin' ||
376
+ type === 'native-view-kotlin-swift' ,
377
+ swift :
378
+ type === 'native-swift' ||
379
+ type === 'native-kotlin-swift' ||
380
+ type === 'native-view-swift' ||
381
+ type === 'native-view-kotlin-swift' ,
318
382
module : type !== 'js' ,
319
383
moduleType,
320
384
} ,
@@ -372,15 +436,22 @@ async function create(argv: yargs.Arguments<any>) {
372
436
path . join ( folder , 'example' )
373
437
) ;
374
438
375
- await copyDir ( NATIVE_FILES ( moduleType ) , folder ) ;
439
+ await copyDir ( NATIVE_COMMON_FILES , folder ) ;
376
440
377
- if ( type === ' cpp' ) {
441
+ if ( options . project . cpp ) {
378
442
await copyDir ( CPP_FILES , folder ) ;
379
- } else if ( type === 'native-swift' ) {
443
+ }
444
+
445
+ if ( options . project . swift ) {
380
446
await copyDir ( SWIFT_FILES ( moduleType ) , folder ) ;
381
447
} else {
382
448
await copyDir ( OBJC_FILES ( moduleType ) , folder ) ;
383
449
}
450
+ if ( options . project . kotlin ) {
451
+ await copyDir ( KOTLIN_FILES ( moduleType ) , folder ) ;
452
+ } else {
453
+ await copyDir ( JAVA_FILES ( moduleType ) , folder ) ;
454
+ }
384
455
}
385
456
386
457
try {
0 commit comments