From d05569749b7c681f222f892f49b6a41c6fcc8615 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 16 Oct 2020 08:59:26 -0700 Subject: [PATCH 1/2] Address #6747 review comments --- ZipBuilder/Sources/ZipBuilder/LaunchArgs.swift | 12 +++++++----- ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift | 6 ++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ZipBuilder/Sources/ZipBuilder/LaunchArgs.swift b/ZipBuilder/Sources/ZipBuilder/LaunchArgs.swift index dba7e5943a4..97257f277b6 100644 --- a/ZipBuilder/Sources/ZipBuilder/LaunchArgs.swift +++ b/ZipBuilder/Sources/ZipBuilder/LaunchArgs.swift @@ -169,17 +169,19 @@ struct LaunchArgs { defaults.register(defaults: [Key.buildDependencies.rawValue: true]) // Get the project repo directory, and fail if it doesn't exist and we're building Firebase. - let repoPath = defaults.string(forKey: Key.repoDir.rawValue) - if defaults.string(forKey: Key.zipPods.rawValue) != nil { + if let repoPath = defaults.string(forKey: Key.repoDir.rawValue) { + repoDir = URL(fileURLWithPath: repoPath) + } else if defaults.string(forKey: Key.zipPods.rawValue) != nil { LaunchArgs.exitWithUsageAndLog("Missing required key: `\(Key.repoDir)` for the folder " + "containing the repository from which we're building the zip.") + } else { + repoDir = nil } - repoDir = repoPath != nil ? URL(fileURLWithPath: repoPath!) : nil // Get the project template directory, and fail if it doesn't exist. var templatePath = defaults.string(forKey: Key.templateDir.rawValue) - if templatePath == nil, repoPath != nil { - templatePath = repoPath! + "/ZipBuilder/Template" + if templatePath == nil, let repoDir = repoDir { + templatePath = repoDir.path + "/ZipBuilder/Template" } else { LaunchArgs.exitWithUsageAndLog("Missing required key: `\(Key.templateDir)` for the folder " + "containing all required files to build frameworks.") diff --git a/ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift b/ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift index a35d77154eb..5d5ed9a6839 100644 --- a/ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift +++ b/ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift @@ -162,11 +162,9 @@ struct ZipBuilder { /// - Returns: Information related to the built artifacts. /// - Throws: One of many errors that could have happened during the build phase. func buildAndAssembleFirebaseRelease(inProjectDir projectDir: URL) throws -> ReleaseArtifacts { - var podsToInstall: [CocoaPodUtils.VersionedPod] = [] let manifest = FirebaseManifest.shared - for pod in (manifest.pods.filter { $0.zip }) { - podsToInstall.append(CocoaPodUtils.VersionedPod(name: pod.name, - version: manifest.versionString(pod))) + var podsToInstall = (manifest.pods.filter { $0.zip }).map { + CocoaPodUtils.VersionedPod(name: $0.name, version: manifest.versionString($0)) } guard !podsToInstall.isEmpty else { fatalError("Failed to find versions for Firebase release") From a740e95af724e1591c3f10462160571981ec9b86 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 16 Oct 2020 09:18:33 -0700 Subject: [PATCH 2/2] remove parentheses --- ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift b/ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift index 5d5ed9a6839..df5fc6d44c4 100644 --- a/ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift +++ b/ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift @@ -163,7 +163,7 @@ struct ZipBuilder { /// - Throws: One of many errors that could have happened during the build phase. func buildAndAssembleFirebaseRelease(inProjectDir projectDir: URL) throws -> ReleaseArtifacts { let manifest = FirebaseManifest.shared - var podsToInstall = (manifest.pods.filter { $0.zip }).map { + var podsToInstall = manifest.pods.filter { $0.zip }.map { CocoaPodUtils.VersionedPod(name: $0.name, version: manifest.versionString($0)) } guard !podsToInstall.isEmpty else {