-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial extension functionality (#33)
- Loading branch information
Showing
115 changed files
with
3,004 additions
and
1,461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ on: | |
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
lint: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
Tophat/Assets.xcassets/GoogleCloudSDK.imageset/Contents.json
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Tophat/Extensions/InstallationTicketMachineError+LocalizedError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// InstallationTicketMachineError+LocalizedError.swift | ||
// Tophat | ||
// | ||
// Created by Lukas Romsicki on 2024-10-04. | ||
// Copyright © 2024 Shopify. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import TophatFoundation | ||
|
||
extension InstallationTicketMachineError: LocalizedError { | ||
var errorDescription: String? { | ||
switch self { | ||
case .noCompatibleDevices(let providedBuildTypes): | ||
"No \(description(for: providedBuildTypes)) Selected" | ||
case .noSelectedDevices: | ||
"No Device Selected" | ||
} | ||
} | ||
|
||
var failureReason: String? { | ||
switch self { | ||
case .noCompatibleDevices: | ||
"None of the specified builds are compatible with the selected devices." | ||
default: | ||
nil | ||
} | ||
} | ||
|
||
var recoverySuggestion: String? { | ||
switch self { | ||
case .noCompatibleDevices(let providedBuildTypes): | ||
let text = description(for: providedBuildTypes) | ||
return "Select \(text.startsWithVowel ? "an" : "a") \(text) using the Tophat menu and try again." | ||
case .noSelectedDevices: | ||
return "Select a device from the Tophat menu and try again." | ||
} | ||
} | ||
|
||
private func description(for providedBuildTypes: [Platform: Set<DeviceType>]) -> String { | ||
providedBuildTypes.map { "\($0.key) \(description(for: $0.value))" }.formatted(.list(type: .or)) | ||
} | ||
|
||
private func description(for platforms: Set<Platform>) -> String { | ||
platforms.map { String(describing: $0) }.formatted(.list(type: .or)) | ||
} | ||
|
||
private func description(for targets: Set<DeviceType>) -> String { | ||
targets.map { String(describing: $0) }.formatted(.list(type: .or)) | ||
} | ||
|
||
} | ||
|
||
extension Character { | ||
var isVowel: Bool { "aeiou".contains { String($0).compare(String(self).folding(options: .diacriticInsensitive, locale: nil), options: .caseInsensitive) == .orderedSame } } | ||
} | ||
|
||
extension StringProtocol { | ||
var startsWithVowel: Bool { first?.isVowel == true } | ||
} |
45 changes: 0 additions & 45 deletions
45
Tophat/Extensions/LaunchRequestBuilderError+LocalizedError.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.