-
Notifications
You must be signed in to change notification settings - Fork 2
/
EnvironmentUpdater.swift
59 lines (51 loc) · 1.63 KB
/
EnvironmentUpdater.swift
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
57
58
59
//
// EnvironmentUpdater.swift
// Basic
//
// Created by Ellen Shapiro on 4/9/19.
//
import Foundation
import Files
/// Updates the `Environment.plist` file.
struct EnvironmentUpdater {
/// Required keys which should be provided in either a `secrets.json` file or in the CI environment.
enum EnvironmentKey: String, CaseIterable, KeyToUpdate {
case appleMerchantId = "apple_merchant_id"
case firebaseProjectID = "firebase_project_id"
case freshchatAppID = "freshchat_app_id"
case freshchatAppKey = "freshchat_app_key"
case jumioToken = "jumio_token"
case jumioSecret = "jumio_secret"
case myInfoURL = "myinfo_url"
case myInfoClientID = "myinfo_client_id"
case myInfoCallbackURL = "myinfo_callback_url"
case serverURL = "server_url"
case stripePublishableKey = "stripe_publishable_key"
var jsonKey: String {
switch self {
case .firebaseProjectID:
return "FIR_PROJECT_ID"
default:
return self.rawValue
}
}
var plistKey: String {
return self.rawValue
}
init?(jsonKey: String) {
if jsonKey == EnvironmentKey.firebaseProjectID.jsonKey {
self = .firebaseProjectID
} else {
self.init(rawValue: jsonKey)
}
}
}
}
extension EnvironmentUpdater: SecretPlistUpdater {
static var keyType: KeyToUpdate.Type {
return EnvironmentKey.self
}
static var outputFileName: String {
return "Environment.plist"
}
}