-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode-google-services.js
More file actions
46 lines (34 loc) · 1.42 KB
/
decode-google-services.js
File metadata and controls
46 lines (34 loc) · 1.42 KB
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
const { log } = require('console');
const fs = require('fs');
const path = require('path');
// Get the base64 encoded string from environment variable
const googleServicesBase64 = process.env.GOOGLE_SERVICES_JSON;
if (!googleServicesBase64) {
console.error('GOOGLE_SERVICES_JSON environment variable is not set');
process.exit(1);
}
// Decode the base64 string
const googleServicesJson = Buffer.from(googleServicesBase64, 'base64').toString('utf8');
console.log('Decoded google-services.json content:', googleServicesJson.length);
// Ensure the android/app directory exists
const androidAppDir = path.join(__dirname);
if (!fs.existsSync(androidAppDir)) {
fs.mkdirSync(androidAppDir, { recursive: true });
}
// Write the decoded content to google-services.json
fs.writeFileSync(
path.join(androidAppDir, 'google-services.json'),
googleServicesJson
);
console.log('Successfully created google-services.json');
// decode-google-services.js
// const fs = require('fs');
// const path = require('path');
// const googleServices = process.env.ANDROID_GOOGLE_SERVICES_JSON;
// console.log('ANDROID_GOOGLE_SERVICES_JSON:', googleServices);
// if (!googleServices) {
// throw new Error('ANDROID_GOOGLE_SERVICES_JSON env variable is not set');
// }
// const filePath = path.join(__dirname, 'android', 'app', 'google-services.json');
// fs.writeFileSync(filePath, googleServices);
// console.log('google-services.json written to android/app/');