|
@@ -6,36 +6,11 @@ try {
|
6
|
6
|
var PACKAGE_JSON = process.cwd() + '/package.json';
|
7
|
7
|
var package = JSON.parse(fs.readFileSync(PACKAGE_JSON));
|
8
|
8
|
var APP_NAME = package.name;
|
9
|
|
- var APPLICATION_MAIN = glob.sync(process.cwd() + '/android/app/src/main/**/MainApplication.java')[0];
|
10
|
9
|
var PACKAGE_GRADLE = process.cwd() + '/node_modules/react-native-fetch-blob/android/build.gradle'
|
11
|
|
- var hasNecessaryFile = MANIFEST_PATH && APPLICATION_MAIN;
|
12
|
10
|
var VERSION = checkVersion();
|
13
|
11
|
|
14
|
12
|
console.log('RNFetchBlob detected app version => ' + VERSION);
|
15
|
13
|
|
16
|
|
- if(VERSION >= 0.29) {
|
17
|
|
- console.log('RNFetchBlob patching MainApplication.java .. ');
|
18
|
|
- if(!hasNecessaryFile) {
|
19
|
|
- console.log(
|
20
|
|
- '\033[95mreact-native-fetch-blob\033[97m link \033[91mFAILED \033[97m\nCould not automatically link Android package, '+
|
21
|
|
- 'please follow the instructions to manually link the library : ' +
|
22
|
|
- '\033[4mhttps://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package\n\n')
|
23
|
|
- return
|
24
|
|
- }
|
25
|
|
- var main = fs.readFileSync(APPLICATION_MAIN);
|
26
|
|
- if(String(main).match('new RNFetchBlobPackage()') === null) {
|
27
|
|
-
|
28
|
|
- main = String(main).replace('new MainReactPackage()', 'new RNFetchBlobPackage(),\n new MainReactPackage()');
|
29
|
|
- main = String(main).replace('import com.facebook.react.ReactApplication;', 'import com.facebook.react.ReactApplication;\nimport com.RNFetchBlob.RNFetchBlobPackage;')
|
30
|
|
-
|
31
|
|
- fs.writeFileSync(APPLICATION_MAIN, main);
|
32
|
|
- console.log('RNFetchBlob patching MainApplication.java .. ok')
|
33
|
|
- }
|
34
|
|
- else {
|
35
|
|
- console.log('Project already linked, process skipped.');
|
36
|
|
- }
|
37
|
|
- }
|
38
|
|
-
|
39
|
14
|
if(VERSION < 0.28) {
|
40
|
15
|
console.log('You project version is '+ VERSION + ' which may not compatible to react-native-fetch-blob 7.0+, please consider upgrade your application template to react-native 0.27+.')
|
41
|
16
|
// add OkHttp3 dependency fo pre 0.28 project
|