-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathfix-all-gradle.js
350 lines (273 loc) · 12.7 KB
/
fix-all-gradle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
const fs = require("fs");
const path = require("path");
const projectPath = `${__dirname}/../..`;
const qqFile = "/node_modules/@pangu/react-native-qq/android/build.gradle";
const qqformPath = path.resolve(projectPath + qqFile);
try {
let fileContent = fs.readFileSync(qqformPath, "utf-8");
const originValue1 = /buildToolsVersion "23.0.1"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 23/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(qqformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-qq ", e);
}
const umengFile =
"/node_modules/@pangu/react-native-umeng/android/build.gradle";
const umengformPath = path.resolve(projectPath + umengFile);
try {
let fileContent = fs.readFileSync(umengformPath, "utf-8");
const originValue1 = /buildToolsVersion "23.0.2"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 23/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(umengformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-wechat ", e);
}
const wechatFile =
"/node_modules/@pangu/react-native-wechat/android/build.gradle";
const wechatformPath = path.resolve(projectPath + wechatFile);
try {
let fileContent = fs.readFileSync(wechatformPath, "utf-8");
const originValue1 = /buildToolsVersion "23.0.1"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 23/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(wechatformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-wechat ", e);
}
const jpushFile = "/node_modules/jpush-react-native/android/build.gradle";
const jpushformPath = path.resolve(projectPath + jpushFile);
try {
let fileContent = fs.readFileSync(jpushformPath, "utf-8");
const originValue1 = /buildToolsVersion '26.0.2'/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 23/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(jpushformPath, fileContent, "utf8");
} catch (e) {
console.log("error jpush-react-native ", e);
}
const jcoreFile = "/node_modules/jcore-react-native/android/build.gradle";
const jcoreformPath = path.resolve(projectPath + jcoreFile);
try {
let fileContent = fs.readFileSync(jcoreformPath, "utf-8");
const originValue1 = /buildToolsVersion '26.0.2'/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 23/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(jcoreformPath, fileContent, "utf8");
} catch (e) {
console.log("error jcore-react-native ", e);
}
const deviceInfoFile =
"/node_modules/react-native-device-info/android/build.gradle";
const deviceInfoformPath = path.resolve(projectPath + deviceInfoFile);
try {
let fileContent = fs.readFileSync(deviceInfoformPath, "utf-8");
const originValue1 = /buildToolsVersion "25.0.2"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 23/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(deviceInfoformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-device-info ", e);
}
const svgFile = "/node_modules/react-native-svg/android/build.gradle";
const svgformPath = path.resolve(projectPath + svgFile);
try {
let fileContent = fs.readFileSync(svgformPath, "utf-8");
const originValue1 = /buildToolsVersion "23.0.1"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 23/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(svgformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-svg ", e);
}
const imagePickerFile =
"/node_modules/react-native-image-picker/android/build.gradle";
const imagePickerformPath = path.resolve(projectPath + imagePickerFile);
try {
let fileContent = fs.readFileSync(imagePickerformPath, "utf-8");
const originValue1 = /def DEFAULT_BUILD_TOOLS_VERSION = "25.0.2"/g;
const replaceValue1 = 'def DEFAULT_BUILD_TOOLS_VERSION = "26.0.3"';
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /def DEFAULT_COMPILE_SDK_VERSION = 25/g;
const replaceValue2 = "def DEFAULT_COMPILE_SDK_VERSION = 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
const originValue4 = / testImplementation /g;
const replaceValue4 = " testCompile ";
fileContent = fileContent.replace(originValue4, replaceValue4);
fs.writeFileSync(imagePickerformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-image-picker ", e);
}
const toastFile =
"/node_modules/@remobile/react-native-toast/android/build.gradle";
const toastformPath = path.resolve(projectPath + toastFile);
try {
let fileContent = fs.readFileSync(toastformPath, "utf-8");
const originValue1 = /buildToolsVersion "23.0.1"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 23/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(toastformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-toast ", e);
}
const viewShotFile =
"/node_modules/react-native-view-shot/android/build.gradle";
const viewShotformPath = path.resolve(projectPath + viewShotFile);
try {
let fileContent = fs.readFileSync(viewShotformPath, "utf-8");
const originValue1 = /buildToolsVersion "26.0.1"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 26/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(viewShotformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-view-shot ", e);
}
const fsFile = "/node_modules/react-native-fs/android/build.gradle";
const fsformPath = path.resolve(projectPath + fsFile);
try {
let fileContent = fs.readFileSync(fsformPath, "utf-8");
const originValue1 = /buildToolsVersion "25.0.0"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 25/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(fsformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-fs ", e);
}
const webviewcrossplatformFile =
"/node_modules/react-native-webview-crossplatform/android/build.gradle";
const webviewcrossplatformformPath = path.resolve(
projectPath + webviewcrossplatformFile
);
try {
let fileContent = fs.readFileSync(webviewcrossplatformformPath, "utf-8");
const originValue1 = /def DEFAULT_BUILD_TOOLS_VERSION {13}= "27.0.3"/g;
const replaceValue1 =
'def DEFAULT_BUILD_TOOLS_VERSION = "26.0.3"';
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /def DEFAULT_COMPILE_SDK_VERSION {13}= 27/g;
const replaceValue2 = "def DEFAULT_COMPILE_SDK_VERSION = 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(webviewcrossplatformformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-webview-crossplatform ", e);
}
const videoFile = "/node_modules/react-native-video/android/build.gradle";
const videoformPath = path.resolve(projectPath + videoFile);
try {
let fileContent = fs.readFileSync(videoformPath, "utf-8");
const originValue1 = /buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3')/g;
const replaceValue1 =
"buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion safeExtGet('compileSdkVersion', 27)/g;
const replaceValue2 = "compileSdkVersion safeExtGet('compileSdkVersion', 26)";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(videoformPath, fileContent, "utf8");
} catch (e) {
console.log("error react-native-video ", e);
}
const screenFile = "/node_modules/rn-splash-screen/android/build.gradle";
const screenformPath = path.resolve(projectPath + screenFile);
try {
let fileContent = fs.readFileSync(screenformPath, "utf-8");
const originValue1 = /buildToolsVersion "25.0.1"/g;
const replaceValue1 = "buildToolsVersion '26.0.3'";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion 25/g;
const replaceValue2 = "compileSdkVersion 26";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(screenformPath, fileContent, "utf8");
} catch (e) {
console.log("error rn-splash-screen ", e);
}
const fetchFile = "/node_modules/rn-fetch-blob/android/build.gradle";
const fetchformPath = path.resolve(projectPath + fetchFile);
try {
let fileContent = fs.readFileSync(fetchformPath, "utf-8");
const originValue1 = /buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')/g;
const replaceValue1 =
"buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')";
fileContent = fileContent.replace(originValue1, replaceValue1);
const originValue2 = /compileSdkVersion safeExtGet('compileSdkVersion', 26)/g;
const replaceValue2 = "compileSdkVersion safeExtGet('compileSdkVersion', 26)";
fileContent = fileContent.replace(originValue2, replaceValue2);
const originValue3 = / implementation /g;
const replaceValue3 = " compile ";
fileContent = fileContent.replace(originValue3, replaceValue3);
fs.writeFileSync(fetchformPath, fileContent, "utf8");
} catch (e) {
console.log("error rn-fetch-blob ", e);
}