Skip to content

Commit

Permalink
[#495] Add helper for Env
Browse files Browse the repository at this point in the history
  • Loading branch information
blyscuit committed Aug 30, 2023
1 parent 39da56f commit c37bd72
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/wiki/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ Options are optional and will be prompted if not provided. Example is provided i
- `--minimum-version`: The minimum version of the iOS application. (14.0)
- `--interface`: The user interface. (UIKit or SwiftUI)

### Example

```
swift run --package-path Scripts/Swift/iOSTemplateMaker iOSTemplateMaker make --bundle-id-production co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface SwiftUI
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// EnvironmentValue.swift
//
//
// Created by Bliss on 30/8/23.
//

import Foundation

enum EnvironmentValue {

static func value(for key: String) -> String? {
ProcessInfo.processInfo.environment[key]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// EnvironmentKey.swift
//
//
// Created by Bliss on 30/8/23.
//

enum EnvironmentKey: String {

case matchRepo = "MATCH_REPO"
case stagingFirebaseAppId = "STAGING_FIREBASE_APP_ID"
case teamId = "TEAM_ID"
case apiKey = "API_KEY_ID"
case issuerId = "ISSUER_ID"
case isCI = "CI"
}

extension EnvironmentValue {

static func value(for key: EnvironmentKey) -> String? {
Self.value(for: key.rawValue)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SetUpIOSProject {
private var minimumVersion = ""
private var interface: SetUpInterface.Interface?
private var projectNameNoSpace: String { projectName.trimmingCharacters(in: .whitespacesAndNewlines) }
private var isCI = !((ProcessInfo.processInfo.environment["CI"]).string).isEmpty
private var isCI = !((EnvironmentValue.value(for: .isCI)).string).isEmpty

init(
bundleIdProduction: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ extension iOSTemplateMaker {
struct MakeTestFirebase: ParsableCommand {

mutating func run() {
let envMatchRepo = ProcessInfo.processInfo.environment["MATCH_REPO"].string
let envStagingFirebaseAppId = ProcessInfo.processInfo.environment["STAGING_FIREBASE_APP_ID"].string
let envTeamId = ProcessInfo.processInfo.environment["TEAM_ID"].string
let envMatchRepo = EnvironmentValue.value(for: .matchRepo).string
let envStagingFirebaseAppId = EnvironmentValue.value(for: .stagingFirebaseAppId).string
let envTeamId = EnvironmentValue.value(for: .teamId).string

SetUpTestFirebase(
matchRepo: envMatchRepo,
Expand All @@ -62,10 +62,10 @@ extension iOSTemplateMaker {
struct MakeTestTestFlight: ParsableCommand {

mutating func run() {
let envMatchRepo = ProcessInfo.processInfo.environment["MATCH_REPO"].string
let envApiKey = ProcessInfo.processInfo.environment["API_KEY_ID"].string
let envIssuerId = ProcessInfo.processInfo.environment["ISSUER_ID"].string
let envTeamId = ProcessInfo.processInfo.environment["TEAM_ID"].string
let envMatchRepo = EnvironmentValue.value(for: .matchRepo).string
let envApiKey = EnvironmentValue.value(for: .apiKey).string
let envIssuerId = EnvironmentValue.value(for: .issuerId).string
let envTeamId = EnvironmentValue.value(for: .teamId).string

SetUpTestTestFlight(
matchRepo: envMatchRepo,
Expand Down

0 comments on commit c37bd72

Please sign in to comment.