-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.config.js
More file actions
56 lines (50 loc) · 1.48 KB
/
app.config.js
File metadata and controls
56 lines (50 loc) · 1.48 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
47
48
49
50
51
52
53
54
55
56
const fs = require('fs');
const path = require('path');
const appJson = require('./app.json');
const parseEnvFile = (content) => {
return content
.split('\n')
.map((line) => line.trim())
.filter((line) => line && !line.startsWith('#'))
.reduce((acc, line) => {
const separatorIndex = line.indexOf('=');
if (separatorIndex === -1) {
return acc;
}
const key = line.slice(0, separatorIndex).trim();
const value = line.slice(separatorIndex + 1).trim();
if (key.length > 0) {
acc[key] = value;
}
return acc;
}, {});
};
const readEnvFile = (filename) => {
const filePath = path.join(__dirname, filename);
if (!fs.existsSync(filePath)) {
return {};
}
return parseEnvFile(fs.readFileSync(filePath, 'utf8'));
};
module.exports = () => {
const env = {
...readEnvFile('.env'),
...readEnvFile('.env.local'),
...process.env
};
const baseExpo = appJson.expo ?? {};
return {
...appJson,
expo: {
...baseExpo,
extra: {
...baseExpo.extra,
powersyncUrl: env.POWERSYNC_URL ?? env.EXPO_PUBLIC_POWERSYNC_URL ?? '',
cactusApiKey: env.CACTUS_API_KEY ?? env.EXPO_PUBLIC_CACTUS_API_KEY ?? '',
supabaseUrl: env.SUPABASE_URL ?? env.EXPO_PUBLIC_SUPABASE_URL ?? '',
supabaseAnonKey: env.SUPABASE_ANON_KEY ?? env.EXPO_PUBLIC_SUPABASE_ANON_KEY ?? '',
supabaseBucket: env.SUPABASE_BUCKET ?? env.EXPO_PUBLIC_SUPABASE_BUCKET ?? 'files'
}
}
};
};