From 26c4cb0fe9ddfeb53475f8f9318a60723c25865a Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Fri, 5 Mar 2021 11:26:26 +0100 Subject: [PATCH 1/7] fix: decode android.signing as an optional value --- Sources/VariantsCore/Schemas/Android/AndroidConfiguration.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/VariantsCore/Schemas/Android/AndroidConfiguration.swift b/Sources/VariantsCore/Schemas/Android/AndroidConfiguration.swift index 8378a5df..1dc6e521 100644 --- a/Sources/VariantsCore/Schemas/Android/AndroidConfiguration.swift +++ b/Sources/VariantsCore/Schemas/Android/AndroidConfiguration.swift @@ -47,7 +47,7 @@ public struct AndroidConfiguration: Codable { self.appName = try container.decode(String.self, forKey: .appName) self.appIdentifier = try container.decode(String.self, forKey: .appIdentifier) self.variants = definiteVariants - self.signing = try container.decode(AndroidSigning.self, forKey: .signing) + self.signing = try? container.decode(AndroidSigning.self, forKey: .signing) self.custom = try? container.decode([CustomProperty].self, forKey: .custom) } From f9ddfb340b7a340e877853dfcfb217a817b1f861 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Fri, 5 Mar 2021 11:28:51 +0100 Subject: [PATCH 2/7] fix: write 'fastlane/' in the base folder regardless of the path in 'android.path' --- .../Custom Types/Project/AndroidProject.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sources/VariantsCore/Custom Types/Project/AndroidProject.swift b/Sources/VariantsCore/Custom Types/Project/AndroidProject.swift index 5117e3d1..ec4ed7be 100644 --- a/Sources/VariantsCore/Custom Types/Project/AndroidProject.swift +++ b/Sources/VariantsCore/Custom Types/Project/AndroidProject.swift @@ -103,7 +103,7 @@ class AndroidProject: Project { do { let projectSourceFolder = configuration.path let path = try TemplateDirectory().path - try Bash("cp", arguments: "-R", "\(path.absolute())/android/_fastlane/", projectSourceFolder) + try Bash("cp", arguments: "-R", "\(path.absolute())/android/_fastlane/", ".") .run() let baseSetupCompletedMessage = @@ -129,7 +129,7 @@ class AndroidProject: Project { """ - if Path("\(projectSourceFolder)/fastlane/").isDirectory { + if StaticPath.Fastlane.baseFolder.isDirectory { guard let defaultVariant = configuration.variants .first(where: { $0.name.lowercased() == "default" }) else { throw ValidationError("Variant 'default' not found.") @@ -145,9 +145,9 @@ class AndroidProject: Project { Your setup is complete, congratulations! 🎉 However, you still need to provide some parameters in order for fastlane to run correctly. - ⚠️ Check the files in '\(projectSourceFolder)/fastlane/parameters/', change the parameters + ⚠️ Check the files in 'fastlane/parameters/', change the parameters accordingly, provide environment variables when applicable. - ⚠️ Note that the values in the file '\(projectSourceFolder)/fastlane/parameters/variants_params.rb' + ⚠️ Note that the values in the file 'fastlane/parameters/variants_params.rb' where generated automatically for configuration properties with 'fastlane' destination. """ @@ -167,6 +167,9 @@ class AndroidProject: Project { } catch let error as ValidationError { Logger.shared.logFatal(item: error.description) + } catch let error as RuntimeError { + Logger.shared.logFatal(item: error.description) + } catch { Logger.shared.logFatal(item: error.localizedDescription) } From 5e80e26833297f64154441744c1e15c7237a6e91 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Fri, 5 Mar 2021 11:29:36 +0100 Subject: [PATCH 3/7] ref: throw RuntimeErrors with more descriptive error message when writing to fastlane parameter files --- Sources/VariantsCore/Factory/FastlaneParametersFactory.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/VariantsCore/Factory/FastlaneParametersFactory.swift b/Sources/VariantsCore/Factory/FastlaneParametersFactory.swift index 030fd49e..f242eb8f 100644 --- a/Sources/VariantsCore/Factory/FastlaneParametersFactory.swift +++ b/Sources/VariantsCore/Factory/FastlaneParametersFactory.swift @@ -83,13 +83,13 @@ class FastlaneParametersFactory: ParametersFactory { // Or does exist and 'isWritable' guard !parametersFile.exists || parametersFile.isWritable else { - throw TemplateDoesNotExist(templateNames: [parentFolder.string]) + throw RuntimeError("'\(parametersFile.abbreviate())' can't be modified, you don't have write permission.") } // Write to file try parametersFile.write(data) } else { - throw TemplateDoesNotExist(templateNames: [parentFolder.string]) + throw RuntimeError("'\(parentFolder.abbreviate())' doesn't exist or isn't a directory.") } } From 3aab69f81f93ba5fda62f4a1ef8d8acd653a2231 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Fri, 5 Mar 2021 11:30:47 +0100 Subject: [PATCH 4/7] =?UTF-8?q?chore:=20remove=20redundant=20=E2=9D=8C=20w?= =?UTF-8?q?hen=20instantiating=20RuntimeError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/VariantsCore/Custom Types/TemplateDirectory.swift | 2 +- Sources/VariantsCore/Custom Types/UtilsDirectory.swift | 2 +- Sources/VariantsCore/Loggers/Logger.swift | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/VariantsCore/Custom Types/TemplateDirectory.swift b/Sources/VariantsCore/Custom Types/TemplateDirectory.swift index 17d99c20..8aa7c4e7 100644 --- a/Sources/VariantsCore/Custom Types/TemplateDirectory.swift +++ b/Sources/VariantsCore/Custom Types/TemplateDirectory.swift @@ -25,7 +25,7 @@ struct TemplateDirectory { guard let path = firstDirectory else { let dirs = directories.joined(separator: " or ") - throw RuntimeError("❌ Templates folder not found in \(dirs)") + throw RuntimeError("Templates folder not found in \(dirs)") } self.path = path diff --git a/Sources/VariantsCore/Custom Types/UtilsDirectory.swift b/Sources/VariantsCore/Custom Types/UtilsDirectory.swift index a823f27e..2f551009 100644 --- a/Sources/VariantsCore/Custom Types/UtilsDirectory.swift +++ b/Sources/VariantsCore/Custom Types/UtilsDirectory.swift @@ -25,7 +25,7 @@ struct UtilsDirectory { guard let path = firstDirectory else { let dirs = directories.joined(separator: " or ") - throw RuntimeError("❌ Utils folder not found in \(dirs)") + throw RuntimeError("Utils folder not found in \(dirs)") } self.path = path diff --git a/Sources/VariantsCore/Loggers/Logger.swift b/Sources/VariantsCore/Loggers/Logger.swift index 6dafd2c7..bef1af5c 100644 --- a/Sources/VariantsCore/Loggers/Logger.swift +++ b/Sources/VariantsCore/Loggers/Logger.swift @@ -19,7 +19,11 @@ public class Logger: VerboseLogger, Codable { public var showTimestamp: Bool { return shouldShowTimestamp } func logFatal(_ prefix: Any = "❌ ", item: Any, color: ShellColor = .red) { - logError(prefix, item: item, color: color) + if prefix == "❌ " && (item as? String)?.contains("❌") { + logError(item: item, color: color) + } else { + logError(prefix, item: item, color: color) + } exit(1) } From 06983e0ca22563387246e7171e12ca39e4f532c4 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Fri, 5 Mar 2021 11:58:45 +0100 Subject: [PATCH 5/7] ref: change type of logFatal arguments to String --- Sources/VariantsCore/Loggers/Logger.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/VariantsCore/Loggers/Logger.swift b/Sources/VariantsCore/Loggers/Logger.swift index bef1af5c..40cc90b7 100644 --- a/Sources/VariantsCore/Loggers/Logger.swift +++ b/Sources/VariantsCore/Loggers/Logger.swift @@ -18,8 +18,8 @@ public class Logger: VerboseLogger, Codable { public var verbose: Bool { return isVerbose } public var showTimestamp: Bool { return shouldShowTimestamp } - func logFatal(_ prefix: Any = "❌ ", item: Any, color: ShellColor = .red) { - if prefix == "❌ " && (item as? String)?.contains("❌") { + func logFatal(_ prefix: String = "❌ ", item: String, color: ShellColor = .red) { + if prefix == "❌ " && item.contains("❌") { logError(item: item, color: color) } else { logError(prefix, item: item, color: color) From 6cab42bd7502cb23fe369c1353643e2bef62fbb7 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Fri, 5 Mar 2021 12:19:55 +0100 Subject: [PATCH 6/7] ref: undo changes to logFatal --- Sources/VariantsCore/Loggers/Logger.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Sources/VariantsCore/Loggers/Logger.swift b/Sources/VariantsCore/Loggers/Logger.swift index 40cc90b7..6dafd2c7 100644 --- a/Sources/VariantsCore/Loggers/Logger.swift +++ b/Sources/VariantsCore/Loggers/Logger.swift @@ -18,12 +18,8 @@ public class Logger: VerboseLogger, Codable { public var verbose: Bool { return isVerbose } public var showTimestamp: Bool { return shouldShowTimestamp } - func logFatal(_ prefix: String = "❌ ", item: String, color: ShellColor = .red) { - if prefix == "❌ " && item.contains("❌") { - logError(item: item, color: color) - } else { - logError(prefix, item: item, color: color) - } + func logFatal(_ prefix: Any = "❌ ", item: Any, color: ShellColor = .red) { + logError(prefix, item: item, color: color) exit(1) } From 7679f6dd640892820208948c8f317dafd4ddab21 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Fri, 5 Mar 2021 12:20:15 +0100 Subject: [PATCH 7/7] ci: update codecov.yml to allow for threshold and not run on patches --- codecov.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codecov.yml b/codecov.yml index 37ca0dfc..72f04bdb 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,9 +1,12 @@ coverage: status: project: + threshold: 5% core: paths: - Sources/VariantsCore tests: paths: - Tests/VariantsCoreTests + + patch: no