Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
cd69d41
downloadMatchingBinaries: prefer artifacts named ".xcframework" when …
elliottwilliams Mar 19, 2021
f7e8fcf
Bump version to 0.38.0
elliottwilliams Mar 19, 2021
d1c78a8
Case insensitive comparisons, check xcframework first
elliottwilliams Mar 24, 2021
6b5c662
Don't say ".framework" when printing binary download events
elliottwilliams Mar 24, 2021
3ced67c
Prioritize assets by name instead of picking _only_ xcframeworks or f…
elliottwilliams Mar 24, 2021
86229d8
Fix Xcode 10.1 compilation in binaryAssetPrioritizingReducer
elliottwilliams Mar 24, 2021
082faaf
Parse and prioritize multiple assets from binary framework URLs
elliottwilliams Apr 30, 2021
b07198b
Refactor filter into a separate function, update tests
elliottwilliams Apr 30, 2021
0ac9138
Update Artifacts.md documenting alt URLS
elliottwilliams May 5, 2021
4e38790
Update README.md with github release xcframework information
elliottwilliams May 5, 2021
bde37b9
Cache binary dependencies using a hash of the download URL
elliottwilliams May 5, 2021
545f3f2
Fix tests
elliottwilliams May 5, 2021
130e0f1
binaryAssetPrioritization: allow assets which don't pass the name filter
elliottwilliams May 5, 2021
43cfb1a
downloadURLToCachedBinaryDependency: use Swift 4 APIs, retab
elliottwilliams May 5, 2021
3cc9238
"one zip file" -> "zip files"
elliottwilliams May 6, 2021
25df81e
README.md: update anchor
elliottwilliams May 6, 2021
a2c65ae
BinaryProject parsing: pull more state into the reduce() block
elliottwilliams May 7, 2021
bd35aef
Fix non-https logic
elliottwilliams May 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BinaryProject parsing: pull more state into the reduce() block
  • Loading branch information
elliottwilliams committed May 7, 2021
commit a2c65ae92fb127a1e2c4d4954161c0496bbf4c79
41 changes: 24 additions & 17 deletions Source/CarthageKit/BinaryProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,40 @@ public struct BinaryProject: Equatable {
return .failure(BinaryJSONError.invalidVersion(error))
}

var urlStrings: [String] = []
guard var components = URLComponents(string: value) else {
return .failure(BinaryJSONError.invalidURL(value))
}
components.queryItems = components.queryItems?.reduce(into: nil) { queryItems, item in

struct ExtractedURLs {
var remainingQueryItems: [URLQueryItem]? = nil
var urlStrings: [String] = []
}
let extractedURLs = components.queryItems?.reduce(into: ExtractedURLs()) { state, item in
if item.name == "alt", let value = item.value {
urlStrings.append(value)
} else if queryItems == nil {
queryItems = [item]
state.urlStrings.append(value)
} else if state.remainingQueryItems == nil {
state.remainingQueryItems = [item]
} else {
queryItems!.append(item)
state.remainingQueryItems!.append(item)
}
}
guard let string = components.string else {
components.queryItems = extractedURLs?.remainingQueryItems

guard let firstURL = components.url else {
return .failure(BinaryJSONError.invalidURL(value))
}
urlStrings.insert(string, at: 0)

var binaryURLs: [URL] = []
for string in urlStrings {
guard let binaryURL = URL(string: string) else {
return .failure(BinaryJSONError.invalidURL(string))
}
guard binaryURL.scheme == "file" || binaryURL.scheme == "https" else {
return .failure(BinaryJSONError.nonHTTPSURL(binaryURL))
var binaryURLs: [URL] = [firstURL]

if let extractedURLs = extractedURLs {
for string in extractedURLs.urlStrings {
guard let binaryURL = URL(string: string) else {
return .failure(BinaryJSONError.invalidURL(string))
}
guard binaryURL.scheme == "file" || binaryURL.scheme == "https" else {
return .failure(BinaryJSONError.nonHTTPSURL(binaryURL))
}
binaryURLs.append(binaryURL)
}
binaryURLs.append(binaryURL)
}

versions[pinnedVersion] = binaryURLs
Expand Down