-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathmakeNativeHeaders.ts
More file actions
48 lines (41 loc) · 1.22 KB
/
makeNativeHeaders.ts
File metadata and controls
48 lines (41 loc) · 1.22 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
import fs from 'fs'
import path from 'path'
function makeNativeHeaders() {
// Grab the API key:
let apiKey = 'Error: Set up env.json & re-run scripts/makeNativeHeaders.js'
try {
apiKey = require('../env.json').EDGE_API_KEY
} catch (e) {
console.log(apiKey)
}
// Grab the push notification server:
let pushServer = 'https://push2.edge.app'
try {
pushServer = require('../src/theme/appConfig.js').notificationServers[0]
} catch (e) {}
const iosPath = path.join(__dirname, '../ios/EdgeApiKey.swift')
const iosSource = `/* auto-generated by scripts/makeNativeHeaders.js */
public class EdgeApiKey {
public static let apiKey = "${apiKey}"
public static let pushServer = "${pushServer}"
}
`
fs.writeFileSync(iosPath, iosSource)
const androidPath = path.join(
__dirname,
'../android/app/src/main/java/co/edgesecure/app/EdgeApiKey.java'
)
const androidSource = `/* auto-generated by scripts/makeNativeHeaders.js */
package co.edgesecure.app;
public class EdgeApiKey {
public static final String apiKey = "${apiKey}";
public static final String pushServer = "${pushServer}";
}
`
fs.writeFileSync(androidPath, androidSource)
}
try {
makeNativeHeaders()
} catch (e) {
console.log(e)
}