Last active
June 25, 2019 03:46
-
-
Save duytq94/47ef945131b61de538447d449813b3d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const fs = require('fs') | |
// Change your version you want. eg: 11.8.0 | |
var ggPlayServiceVersion = '11.8.0' | |
// Folder package library, find it in node_modules. | |
var folderLibrary = [ | |
'react-native-onesignal', | |
'react-native-admob', | |
'react-native-maps', | |
'react-native-google-sign-in' | |
] | |
let i | |
for (i = 0; i < folderLibrary.length; i++) { | |
try { | |
var rootDir = process.cwd() | |
var filePath = `${rootDir}/node_modules/${ | |
folderLibrary[i] | |
}/android/build.gradle` | |
var fileNeedFix = fs.readFileSync(filePath, 'utf8') | |
var dataFix = [{ | |
current: /com.google.android.gms:play-services-gcm:\+/g, | |
new: `com.google.android.gms:play-services-gcm:${ggPlayServiceVersion}` | |
}, | |
{ | |
current: /com.google.android.gms:play-services-analytics:\+/g, | |
new: `com.google.android.gms:play-services-analytics:${ggPlayServiceVersion}` | |
}, | |
{ | |
current: /com.google.android.gms:play-services-location:\+/g, | |
new: `com.google.android.gms:play-services-location:${ggPlayServiceVersion}` | |
}, | |
{ | |
current: /com.google.android.gms:play-services-ads:\+/g, | |
new: `com.google.android.gms:play-services-ads:${ggPlayServiceVersion}` | |
}, | |
{ | |
current: /com.google.android.gms:play-services-base:\+/g, | |
new: `com.google.android.gms:play-services-base:${ggPlayServiceVersion}` | |
}, | |
{ | |
current: /com.google.android.gms:play-services-maps:\+/g, | |
new: `com.google.android.gms:play-services-maps:${ggPlayServiceVersion}` | |
}, | |
{ | |
current: /com.google.android.gms:play-services-auth:\+/g, | |
new: `com.google.android.gms:play-services-auth:${ggPlayServiceVersion}` | |
} | |
] | |
for (var j = 0; j < dataFix.length; j++) { | |
fileNeedFix = fileNeedFix.replace(dataFix[j].current, dataFix[j].new) | |
} | |
fs.writeFileSync(filePath, fileNeedFix, 'utf8') | |
console.log(`Change version ${folderLibrary[i]} success`) | |
} catch (error) { | |
console.error(`Change version fail with error: ${error}`) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment