From c530bd4e059d8e040102dbe9201cdc72dcef7ee7 Mon Sep 17 00:00:00 2001 From: nkhanh44 Date: Fri, 29 Dec 2023 17:36:11 +0700 Subject: [PATCH] [#552] Fix the issue --- .../iOSTemplateMaker/SetUpCICDService.swift | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpCICDService.swift b/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpCICDService.swift index 972e9250..774b9f09 100644 --- a/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpCICDService.swift +++ b/Scripts/Swift/iOSTemplateMaker/Sources/iOSTemplateMaker/SetUpCICDService.swift @@ -7,34 +7,44 @@ struct SetUpCICDService { case github, bitrise, codemagic, later init?(_ name: String) { - switch name.lowercased() { - case "g", "github": - self = .github - case "b", "bitrise": - self = .bitrise - case "c", "codemagic": - self = .codemagic - case "l", "later": - self = .later - default: + let name = name.lowercased() + let mappings: [String: Self] = [ + "g": .github, + "github": .github, + "b": .bitrise, + "bitrise": .bitrise, + "c": .codemagic, + "codemagic": .codemagic, + "l": .later, + "later": .later + ] + + if let matchedCase = mappings[name] { + self = matchedCase + } else { return nil } } } - + enum GithubRunnerType { case macOSLatest, selfHosted, later init?(_ name: String) { - switch name.lowercased() { - case "m", "macOS": - self = .macOSLatest - case "s", "self-hosted": - self = .selfHosted - case "l", "later": - self = .later - default: + let mappings: [String: Self] = [ + "m": .macOSLatest, + "macos": .macOSLatest, + "s": .selfHosted, + "self-hosted": .selfHosted, + "l": .later, + "later": .later + ] + + let name = name.lowercased() + if let matchedCase = mappings[name] { + self = matchedCase + } else { return nil } } @@ -63,10 +73,12 @@ struct SetUpCICDService { fileManager.createDirectory(path: ".github/workflows") switch runnerType { case .macOSLatest: + print("Configured to run on the latest macOS.") fileManager.moveFiles(in: ".github/project_workflows", to: ".github/workflows") fileManager.removeItems(in: ".github/project_workflows") fileManager.removeItems(in: ".github/self_hosted_project_workflows") case .selfHosted: + print("Configured to run on self-hosted.") fileManager.moveFiles(in: ".github/self_hosted_project_workflows", to: ".github/workflows") fileManager.removeItems(in: ".github/project_workflows") fileManager.removeItems(in: ".github/self_hosted_project_workflows")