@@ -7,15 +7,15 @@ import { Input } from '../types';
7
7
import jetifier from '../utils/jetifier' ;
8
8
9
9
type TargetOptions = {
10
- androidPath : string ,
10
+ androidPath : string ;
11
11
androidBundleName : string ;
12
- reverseJetify : boolean
12
+ reverseJetify : boolean ;
13
13
} ;
14
14
15
15
const defaultOptions : TargetOptions = {
16
- androidPath : " android" ,
17
- androidBundleName : " android.aar" ,
18
- reverseJetify : false
16
+ androidPath : ' android' ,
17
+ androidBundleName : ' android.aar' ,
18
+ reverseJetify : false ,
19
19
} ;
20
20
21
21
type Options = Input & {
@@ -24,7 +24,10 @@ type Options = Input & {
24
24
25
25
async function createGradleFile ( file : string ) {
26
26
await fs . createFile ( file ) ;
27
- await fs . writeFile ( file , 'configurations.maybeCreate("default")\nartifacts.add("default", file(\'android.aar\'))' )
27
+ await fs . writeFile (
28
+ file ,
29
+ 'configurations.maybeCreate("default")\nartifacts.add("default", file(\'android.aar\'))'
30
+ ) ;
28
31
}
29
32
30
33
export default async function build ( {
@@ -35,7 +38,7 @@ export default async function build({
35
38
} : Options ) {
36
39
const targetOptions = {
37
40
...defaultOptions ,
38
- ...options
41
+ ...options ,
39
42
} ;
40
43
41
44
report . info (
@@ -44,18 +47,32 @@ export default async function build({
44
47
45
48
await del ( [ output ] ) ;
46
49
47
- await androidAssemble ( { root, androidPath : targetOptions . androidPath , report } ) ;
50
+ await androidAssemble ( {
51
+ root,
52
+ androidPath : targetOptions . androidPath ,
53
+ report,
54
+ } ) ;
48
55
49
56
report . info (
50
- `Creating new output directory at ${ chalk . blue ( path . relative ( root , output ) ) } `
57
+ `Creating new output directory at ${ chalk . blue (
58
+ path . relative ( root , output )
59
+ ) } `
51
60
) ;
52
61
await fs . mkdir ( output ) ;
53
62
54
- const sourceAar = path . join ( targetOptions . androidPath , 'build' , 'outputs' , 'aar' , targetOptions . androidBundleName ) ;
63
+ const sourceAar = path . join (
64
+ targetOptions . androidPath ,
65
+ 'build' ,
66
+ 'outputs' ,
67
+ 'aar' ,
68
+ targetOptions . androidBundleName
69
+ ) ;
55
70
const targetAar = path . join ( output , targetOptions . androidBundleName ) ;
56
71
57
72
report . info (
58
- `Copying AAR from ${ chalk . blue ( path . relative ( root , sourceAar ) ) } to ${ chalk . blue ( path . relative ( root , targetAar ) ) } `
73
+ `Copying AAR from ${ chalk . blue (
74
+ path . relative ( root , sourceAar )
75
+ ) } to ${ chalk . blue ( path . relative ( root , targetAar ) ) } `
59
76
) ;
60
77
await fs . copyFile ( sourceAar , targetAar ) ;
61
78
@@ -68,31 +85,38 @@ export default async function build({
68
85
if ( targetOptions . reverseJetify ) {
69
86
const supportOutputPath = path . join ( output , 'support' ) ;
70
87
report . info (
71
- `Creating new support output directory at ${ chalk . blue ( path . relative ( root , supportOutputPath ) ) } `
88
+ `Creating new support output directory at ${ chalk . blue (
89
+ path . relative ( root , supportOutputPath )
90
+ ) } `
72
91
) ;
73
92
await fs . mkdir ( supportOutputPath ) ;
74
93
75
- const supportAar = path . join ( supportOutputPath , targetOptions . androidBundleName ) ;
94
+ const supportAar = path . join (
95
+ supportOutputPath ,
96
+ targetOptions . androidBundleName
97
+ ) ;
76
98
report . info (
77
- `Using Jetifier to convert AAR from AndroidX to Support AAR at ${ chalk . blue ( path . relative ( root , supportAar ) ) } `
99
+ `Using Jetifier to convert AAR from AndroidX to Support AAR at ${ chalk . blue (
100
+ path . relative ( root , supportAar )
101
+ ) } `
78
102
) ;
79
103
80
104
await jetifier ( {
81
105
root,
82
106
report,
83
107
input : targetAar ,
84
108
output : supportAar ,
85
- reverse : true
109
+ reverse : true ,
86
110
} ) ;
87
111
88
112
const supportGradleFile = path . join ( supportOutputPath , 'build.gradle' ) ;
89
113
report . info (
90
- `Creating Support AAR Gradle file at ${ chalk . blue ( path . relative ( root , supportGradleFile ) ) } `
114
+ `Creating Support AAR Gradle file at ${ chalk . blue (
115
+ path . relative ( root , supportGradleFile )
116
+ ) } `
91
117
) ;
92
118
await createGradleFile ( supportGradleFile ) ;
93
119
}
94
120
95
- report . success (
96
- `Wrote files to ${ chalk . blue ( path . relative ( root , output ) ) } `
97
- ) ;
121
+ report . success ( `Wrote files to ${ chalk . blue ( path . relative ( root , output ) ) } ` ) ;
98
122
}
0 commit comments