@@ -17,7 +17,7 @@ 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
19
20
- // Android
20
+ // Common native library template files
21
21
const NATIVE_FILES = ( moduleType : ModuleType ) => {
22
22
switch ( moduleType ) {
23
23
case 'module' :
@@ -37,6 +37,16 @@ const OBJC_FILES = (moduleType: ModuleType) => {
37
37
}
38
38
} ;
39
39
40
+ // Kotlin
41
+ const KOTLIN_FILES = ( moduleType : ModuleType ) => {
42
+ switch ( moduleType ) {
43
+ case 'module' :
44
+ return path . resolve ( __dirname , '../templates/kotlin-library' ) ;
45
+ case 'view' :
46
+ return path . resolve ( __dirname , '../templates/kotlin-view-library' ) ;
47
+ }
48
+ } ;
49
+
40
50
// Swift
41
51
const SWIFT_FILES = ( moduleType : ModuleType ) => {
42
52
switch ( moduleType ) {
@@ -59,12 +69,12 @@ type ArgName =
59
69
type ModuleType = 'module' | 'view' ;
60
70
61
71
type LibraryType =
62
- | 'native-view'
63
- | 'native-view-swift'
64
- | 'native'
65
- | 'native-swift'
66
- | 'js'
72
+ | 'native-kotlin'
73
+ | 'native-kotlin-swift'
74
+ | 'native-view-kotlin'
75
+ | 'native-view-kotlin-swift'
67
76
| 'cpp'
77
+ | 'js'
68
78
| 'expo' ;
69
79
70
80
type Answers = {
@@ -104,7 +114,15 @@ const args: Record<ArgName, yargs.Options> = {
104
114
} ,
105
115
'type' : {
106
116
description : 'Type package do you want to develop' ,
107
- choices : [ 'native' , 'native-swift' , 'js' , 'cpp' , 'expo' ] ,
117
+ choices : [
118
+ 'native-kotlin' ,
119
+ 'native-kotlin-swift' ,
120
+ 'native-view-kotlin' ,
121
+ 'native-view-kotlin-swift' ,
122
+ 'cpp' ,
123
+ 'js' ,
124
+ 'expo' ,
125
+ ] ,
108
126
} ,
109
127
} ;
110
128
@@ -218,17 +236,23 @@ async function create(argv: yargs.Arguments<any>) {
218
236
name : 'type' ,
219
237
message : 'What type of package do you want to develop?' ,
220
238
choices : [
221
- { title : 'Native module in Kotlin and Objective-C' , value : 'native' } ,
222
- { title : 'Native module in Kotlin and Swift' , value : 'native-swift' } ,
223
- { title : 'Native module with C++ code' , value : 'cpp' } ,
239
+ {
240
+ title : 'Native module in Kotlin and Objective-C' ,
241
+ value : 'native-kotlin' ,
242
+ } ,
243
+ {
244
+ title : 'Native module in Kotlin and Swift' ,
245
+ value : 'native-kotlin-swift' ,
246
+ } ,
224
247
{
225
248
title : 'Native view in Kotlin and Objective-C' ,
226
- value : 'native-view' ,
249
+ value : 'native-view-kotlin ' ,
227
250
} ,
228
251
{
229
252
title : 'Native view in Kotlin and Swift' ,
230
- value : 'native-view-swift' ,
253
+ value : 'native-view-kotlin- swift' ,
231
254
} ,
255
+ { title : 'Native module with C++ code' , value : 'cpp' } ,
232
256
{
233
257
title : 'JavaScript library with native example' ,
234
258
value : 'js' ,
@@ -265,7 +289,9 @@ async function create(argv: yargs.Arguments<any>) {
265
289
266
290
const project = slug . replace ( / ^ ( r e a c t - n a t i v e - | @ [ ^ / ] + \/ ) / , '' ) ;
267
291
const moduleType : ModuleType =
268
- type === 'native-view' || type === 'native-view-swift' ? 'view' : 'module' ;
292
+ type === 'native-view-kotlin' || type === 'native-view-kotlin-swift'
293
+ ? 'view'
294
+ : 'module' ;
269
295
270
296
// Get latest version of Bob from NPM
271
297
let version : string ;
@@ -308,13 +334,13 @@ async function create(argv: yargs.Arguments<any>) {
308
334
package : slug . replace ( / [ ^ a - z 0 - 9 ] / g, '' ) . toLowerCase ( ) ,
309
335
podspec : slug . replace ( / [ ^ a - z 0 - 9 ] + / g, '-' ) . replace ( / ^ - / , '' ) ,
310
336
native :
311
- type === 'native' ||
312
337
type === 'cpp' ||
313
- 'native-swift' ||
314
- 'native-view' ||
315
- 'native-view-swift' ,
338
+ type === 'native-kotlin' ||
339
+ type === 'native-kotlin-swift' ||
340
+ type === 'native-view-kotlin' ||
341
+ type === 'native-view-kotlin-swift' ,
316
342
cpp : type === 'cpp' ,
317
- swift : type === 'native-swift' || 'native-view-swift' ,
343
+ swift : type === 'native-kotlin- swift' || 'native-view-kotlin -swift' ,
318
344
module : type !== 'js' ,
319
345
moduleType,
320
346
} ,
@@ -374,11 +400,15 @@ async function create(argv: yargs.Arguments<any>) {
374
400
375
401
await copyDir ( NATIVE_FILES ( moduleType ) , folder ) ;
376
402
377
- if ( type === ' cpp' ) {
403
+ if ( options . project . cpp ) {
378
404
await copyDir ( CPP_FILES , folder ) ;
379
- } else if ( type === 'native-swift' ) {
405
+ }
406
+
407
+ if ( options . project . swift ) {
408
+ await copyDir ( KOTLIN_FILES ( moduleType ) , folder ) ;
380
409
await copyDir ( SWIFT_FILES ( moduleType ) , folder ) ;
381
410
} else {
411
+ await copyDir ( KOTLIN_FILES ( moduleType ) , folder ) ;
382
412
await copyDir ( OBJC_FILES ( moduleType ) , folder ) ;
383
413
}
384
414
}
0 commit comments