From d1b32104e088d1179e1b137c5c853f8a5ade4f14 Mon Sep 17 00:00:00 2001 From: Ryo Aoyama Date: Fri, 12 Jul 2019 12:31:12 +0900 Subject: [PATCH] Supports cocoaapods-binary --- .travis.yml | 2 +- AcknowledgementsPlist.podspec | 2 +- .../Models/License.swift | 2 +- .../Models/LicenseLink.swift | 2 +- .../Protocols/LicenseURLsMakable.swift | 7 ++- .../Protocols/LicensesMakable.swift | 5 ++- .../cProject/Carthage/Checkouts/libC/license | 2 +- .../Carthage/Checkouts/libD/license.txt | 2 +- .../Dummy/pProject/Pods/libA/LICENSE | 2 +- .../Dummy/pProject/Pods/libB/license.md | 2 +- .../pcProject/Carthage/Checkouts/libC/license | 2 +- .../Carthage/Checkouts/libD/license.txt | 2 +- .../Dummy/pcProject/Pods/libA/LICENSE | 2 +- .../Dummy/pcProject/Pods/libB/license.md | 2 +- .../Protocols/LicensesMakableTests.swift | 43 ++++++++++++------- 15 files changed, 48 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index 245f2e3..972e9db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,6 @@ before_install: - gem install xcpretty script: - swift build - - swift test 2>&1 | xcpretty + - swift test notifications: email: false diff --git a/AcknowledgementsPlist.podspec b/AcknowledgementsPlist.podspec index 2168d47..5180621 100644 --- a/AcknowledgementsPlist.podspec +++ b/AcknowledgementsPlist.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'AcknowledgementsPlist' - s.version = '0.0.6' + s.version = '0.0.7' s.summary = 'AcknowledgementsPlist manages the licenses of libraries that depend on your iOS app.' s.homepage = 'https://github.com/cats-oss/AcknowledgementsPlist' s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/Sources/AcknowledgementsPlistCore/Models/License.swift b/Sources/AcknowledgementsPlistCore/Models/License.swift index 4c32416..fad24ab 100644 --- a/Sources/AcknowledgementsPlistCore/Models/License.swift +++ b/Sources/AcknowledgementsPlistCore/Models/License.swift @@ -7,7 +7,7 @@ import Foundation -public struct License: LicenseType { +public struct License: LicenseType, Hashable { private enum Key { static let title = "Title" diff --git a/Sources/AcknowledgementsPlistCore/Models/LicenseLink.swift b/Sources/AcknowledgementsPlistCore/Models/LicenseLink.swift index e74a066..906804b 100644 --- a/Sources/AcknowledgementsPlistCore/Models/LicenseLink.swift +++ b/Sources/AcknowledgementsPlistCore/Models/LicenseLink.swift @@ -7,7 +7,7 @@ import Foundation -public struct LicenseLink: LicenseType { +public struct LicenseLink: LicenseType, Hashable { private enum Name { static let plist = "AcknowledgementLinks.plist" diff --git a/Sources/AcknowledgementsPlistCore/Protocols/LicenseURLsMakable.swift b/Sources/AcknowledgementsPlistCore/Protocols/LicenseURLsMakable.swift index 7d7b5fc..124cb94 100644 --- a/Sources/AcknowledgementsPlistCore/Protocols/LicenseURLsMakable.swift +++ b/Sources/AcknowledgementsPlistCore/Protocols/LicenseURLsMakable.swift @@ -41,8 +41,11 @@ extension LicenseURLsMakable { } else { podsDirURL = URL(string: options.podsPath) } - guard let url = podsDirURL else { return [] } - return try getLicenseURLs(dirURL: url) + + return try podsDirURL.map { url in + let podsBinaryDirURL = url.appendingPathComponent("/_Prebuild", isDirectory: true) + return try getLicenseURLs(dirURL: url) + getLicenseURLs(dirURL: podsBinaryDirURL) + } ?? [] } private func getCarthageLicenseURLs() throws -> [URL] { diff --git a/Sources/AcknowledgementsPlistCore/Protocols/LicensesMakable.swift b/Sources/AcknowledgementsPlistCore/Protocols/LicensesMakable.swift index 6bbc220..bcc852a 100644 --- a/Sources/AcknowledgementsPlistCore/Protocols/LicensesMakable.swift +++ b/Sources/AcknowledgementsPlistCore/Protocols/LicensesMakable.swift @@ -25,7 +25,7 @@ extension LicensesMakable { let carthageLicenses = try getLicenses(licenseURLs: carthageLicenseURLs) let manualPlistLicenses = try getManualPlistLicenses().map { License(object: $0) } let manualLicenses = try getLicenses(licenseURLs: manualLicenseURLs) - return (podsLicenses + carthageLicenses + manualPlistLicenses + manualLicenses) + return Set(podsLicenses + carthageLicenses + manualPlistLicenses + manualLicenses) .sorted(by: { $0.title < $1.title }) } @@ -33,7 +33,8 @@ extension LicensesMakable { let podsLicenseLinks = getLicenseLinks(licenseURLs: podsLicenseURLs) let carthageLicenseLinks = getLicenseLinks(licenseURLs: carthageLicenseURLs) let manualLicenseLinks = try getManualPlistLicenses().map { LicenseLink(object: $0) } - return (podsLicenseLinks + carthageLicenseLinks + manualLicenseLinks).sorted(by: { $0.title < $1.title }) + return Set(podsLicenseLinks + carthageLicenseLinks + manualLicenseLinks) + .sorted(by: { $0.title < $1.title }) } private func getLicenses(licenseURLs: [URL]) throws -> [License] { diff --git a/Tests/AcknowledgementsPlistTests/Dummy/cProject/Carthage/Checkouts/libC/license b/Tests/AcknowledgementsPlistTests/Dummy/cProject/Carthage/Checkouts/libC/license index 43aa4fd..b4251ec 100644 --- a/Tests/AcknowledgementsPlistTests/Dummy/cProject/Carthage/Checkouts/libC/license +++ b/Tests/AcknowledgementsPlistTests/Dummy/cProject/Carthage/Checkouts/libC/license @@ -1 +1 @@ -CCC +CCC \ No newline at end of file diff --git a/Tests/AcknowledgementsPlistTests/Dummy/cProject/Carthage/Checkouts/libD/license.txt b/Tests/AcknowledgementsPlistTests/Dummy/cProject/Carthage/Checkouts/libD/license.txt index 191faf8..92d2df3 100644 --- a/Tests/AcknowledgementsPlistTests/Dummy/cProject/Carthage/Checkouts/libD/license.txt +++ b/Tests/AcknowledgementsPlistTests/Dummy/cProject/Carthage/Checkouts/libD/license.txt @@ -1 +1 @@ -DDD +DDD \ No newline at end of file diff --git a/Tests/AcknowledgementsPlistTests/Dummy/pProject/Pods/libA/LICENSE b/Tests/AcknowledgementsPlistTests/Dummy/pProject/Pods/libA/LICENSE index 43d5a8e..43d88b6 100644 --- a/Tests/AcknowledgementsPlistTests/Dummy/pProject/Pods/libA/LICENSE +++ b/Tests/AcknowledgementsPlistTests/Dummy/pProject/Pods/libA/LICENSE @@ -1 +1 @@ -AAA +AAA \ No newline at end of file diff --git a/Tests/AcknowledgementsPlistTests/Dummy/pProject/Pods/libB/license.md b/Tests/AcknowledgementsPlistTests/Dummy/pProject/Pods/libB/license.md index ba62923..f6d5afa 100644 --- a/Tests/AcknowledgementsPlistTests/Dummy/pProject/Pods/libB/license.md +++ b/Tests/AcknowledgementsPlistTests/Dummy/pProject/Pods/libB/license.md @@ -1 +1 @@ -BBB +BBB \ No newline at end of file diff --git a/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Carthage/Checkouts/libC/license b/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Carthage/Checkouts/libC/license index 43aa4fd..b4251ec 100644 --- a/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Carthage/Checkouts/libC/license +++ b/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Carthage/Checkouts/libC/license @@ -1 +1 @@ -CCC +CCC \ No newline at end of file diff --git a/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Carthage/Checkouts/libD/license.txt b/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Carthage/Checkouts/libD/license.txt index 191faf8..92d2df3 100644 --- a/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Carthage/Checkouts/libD/license.txt +++ b/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Carthage/Checkouts/libD/license.txt @@ -1 +1 @@ -DDD +DDD \ No newline at end of file diff --git a/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Pods/libA/LICENSE b/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Pods/libA/LICENSE index 43d5a8e..43d88b6 100644 --- a/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Pods/libA/LICENSE +++ b/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Pods/libA/LICENSE @@ -1 +1 @@ -AAA +AAA \ No newline at end of file diff --git a/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Pods/libB/license.md b/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Pods/libB/license.md index ba62923..f6d5afa 100644 --- a/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Pods/libB/license.md +++ b/Tests/AcknowledgementsPlistTests/Dummy/pcProject/Pods/libB/license.md @@ -1 +1 @@ -BBB +BBB \ No newline at end of file diff --git a/Tests/AcknowledgementsPlistTests/Protocols/LicensesMakableTests.swift b/Tests/AcknowledgementsPlistTests/Protocols/LicensesMakableTests.swift index 007d301..131270d 100644 --- a/Tests/AcknowledgementsPlistTests/Protocols/LicensesMakableTests.swift +++ b/Tests/AcknowledgementsPlistTests/Protocols/LicensesMakableTests.swift @@ -10,16 +10,17 @@ import XCTest @testable import AcknowledgementsPlistCore class LicensesMakableTests: XCTestCase, LicensesMakable { - var options: Options = .init(projectRootPath: "", outputPlistPath: "", outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) var podsLicenseURLs: [URL] = [] var carthageLicenseURLs: [URL] = [] + var manualLicenseURLs: [URL] = [] func testNotAllLicenses() { options = .init(projectRootPath: "", @@ -27,7 +28,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = [] carthageLicenseURLs = [] @@ -41,7 +43,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) } guard let licenses = try? makeLicenses() as? [License] else { @@ -58,7 +61,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) } guard let licenses = try? makeLicenses() as? [License] else { @@ -75,7 +79,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) } carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) } @@ -93,7 +98,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: ConstMocks.manualAcknowledgementsPath, + manualPlistPath: ConstMocks.manualAcknowledgementsPath, + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) } carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) } @@ -111,7 +117,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "foo", + manualPlistPath: "foo", + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) } carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) } @@ -124,7 +131,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = [] carthageLicenseURLs = [] @@ -138,7 +146,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) } guard let licenseLinks = try? makeLicenseLinks() as? [LicenseLink] else { @@ -155,7 +164,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) } guard let licenses = try? makeLicenseLinks() as? [LicenseLink] else { @@ -172,7 +182,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "", + manualPlistPath: "", + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) } carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) } @@ -190,7 +201,8 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: ConstMocks.manualAcknowledgementsPath, + manualPlistPath: ConstMocks.manualAcknowledgementsPath, + manualLicenseFilesPath: "", excludeWordArray: []) podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) } carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) } @@ -208,10 +220,11 @@ class LicensesMakableTests: XCTestCase, LicensesMakable { outputBundlePath: "", podsPath: "", carthageCheckoutsPath: "", - manualAcknowledgementsPath: "bar", + manualPlistPath: "", + manualLicenseFilesPath: "bar", excludeWordArray: []) podsLicenseURLs = ConstMocks.pProjectPodsLicensePaths.map { URL(fileURLWithPath: $0) } carthageLicenseURLs = ConstMocks.pcProjectCarthageLicensePaths.map { URL(fileURLWithPath: $0) } - XCTAssertThrowsError(try makeLicenseLinks()) + XCTAssertNoThrow(try makeLicenseLinks()) } }