Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .periphery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# .periphery.yaml
# mas
#
# Periphery 3.3.0
# Periphery 3.4.0
#
---
disable_update_check: true
Expand Down
2 changes: 1 addition & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ brew "gh" # 2.83.2
brew "git" # 2.52.0
brew "ipsw" # 3.1.648
brew "markdownlint-cli2" # 0.20.0
brew "periphery" # 3.3.0
brew "periphery" if MacOS.version >= :sequoia && `/usr/bin/arch` == "arm64" # 3.4.0
brew "shellcheck" # 0.11.0
brew "swiftformat" # 0.58.7
brew "swiftlint" # 0.63.0
Expand Down
8 changes: 6 additions & 2 deletions Scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

print_notice '🚨 Linting' "${@}"

ensure_command_available actionlint git markdownlint-cli2 periphery shellcheck swiftformat swiftlint yamllint || exit
ensure_command_available actionlint git markdownlint-cli2 shellcheck swiftformat swiftlint yamllint || exit
[[ "$(/usr/bin/arch)" = arm64 && "${$(sw_vers -productVersion)%%.*}" -ge 15 ]]
integer -r can_use_periphery="$((! ?))"
# shellcheck disable=SC1083
((can_use_periphery)) && { ensure_command_available periphery || exit }

zmodload zsh/zutil
zparseopts -D -A received_flag A P
Expand All @@ -41,7 +45,7 @@ if ! [[ -v 'received_flag[-A]' ]]; then
((exit_status |= ${?}))
fi

if ! [[ -v 'received_flag[-P]' ]]; then
if ((can_use_periphery)) && ! [[ -v 'received_flag[-P]' ]]; then
printf -- $'--> 🌀 Periphery\n'
script -q /dev/null periphery scan --exclude-tests |
(grep -vxE '(?:\x1b\[0;1;32m|\^D\x08{2})\* (?:\x1b\[0;0m\x1b\[0;1m)?No unused code detected\.(?:\x1b\[0;0m)?\r' || true)
Expand Down
16 changes: 13 additions & 3 deletions Sources/mas/AppStore/AppStoreAction+download.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ private actor DownloadQueueObserver: CKDownloadQueueObserver {
MAS.printer.clearCurrentLine(of: .standardOutput)

do {
let appFolderPath: String?
if let error = snapshot.error {
guard error is Ignorable else {
throw error
Expand All @@ -250,7 +251,7 @@ private actor DownloadQueueObserver: CKDownloadQueueObserver {
"progress cannot be displayed",
terminator: "",
)
try await install(appNameAndVersion: snapshot.appNameAndVersion)
appFolderPath = try await install(appNameAndVersion: snapshot.appNameAndVersion)
MAS.printer.clearCurrentLine(of: .standardOutput)
} else {
guard !snapshot.isFailed else {
Expand All @@ -263,9 +264,14 @@ private actor DownloadQueueObserver: CKDownloadQueueObserver {
guard !snapshot.isCancelled else {
throw MASError.error("Download cancelled for \(snapshot.appNameAndVersion)")
}

appFolderPath = snapshot.appFolderPath
}

MAS.printer.notice(action.performed.capitalizingFirstCharacter, snapshot.appNameAndVersion)
MAS.printer.notice(
[action.performed.capitalizingFirstCharacter, snapshot.appNameAndVersion]
+ (appFolderPath.map { ["in", $0] } ?? []), // swiftformat:disable:this indent
)
resumeOnce { $0.resume() }
} catch {
resumeOnce { $0.resume(throwing: error) }
Expand All @@ -289,7 +295,7 @@ private actor DownloadQueueObserver: CKDownloadQueueObserver {
return hardLinkURL
}

private func install(appNameAndVersion: String) async throws {
private func install(appNameAndVersion: String) async throws -> String {
guard let pkgHardLinkPath = pkgHardLinkURL?.path(percentEncoded: false) else {
throw MASError.error("Failed to find pkg to \(action) \(appNameAndVersion)")
}
Expand Down Expand Up @@ -357,6 +363,8 @@ private actor DownloadQueueObserver: CKDownloadQueueObserver {
)

LSRegisterURL(appFolderURL as NSURL, true) // swiftlint:disable:this legacy_objc_type

return appFolderURL.path(percentEncoded: false)
}
}

Expand All @@ -366,6 +374,7 @@ private struct DownloadSnapshot: Sendable { // swiftlint:disable:this one_declar
let appNameAndVersion: String
let activePhaseType: PhaseType
let phasePercentComplete: Float
let appFolderPath: String?
let isCancelled: Bool
let isFailed: Bool
let error: (any Error)?
Expand All @@ -380,6 +389,7 @@ private struct DownloadSnapshot: Sendable { // swiftlint:disable:this one_declar
appNameAndVersion = "\(metadata.title ?? "unknown app") (\(version ?? "unknown version"))"
activePhaseType = PhaseType(action, rawValue: status.activePhase?.phaseType)
phasePercentComplete = status.phasePercentComplete
appFolderPath = download.installPath
isCancelled = status.isCancelled
isFailed = status.isFailed
error = status.error.map { $0 as NSError }.map { error in
Expand Down
3 changes: 1 addition & 2 deletions Sources/mas/Models/CatalogApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
struct CatalogApp: Sendable {
let adamID: ADAMID
let appStorePageURLString: String
// periphery:ignore
let bundleID: String
let bundleID: String // periphery:ignore
let fileSizeBytes: String
let formattedPrice: String?
let minimumOSVersion: String
Expand Down
5 changes: 2 additions & 3 deletions Sources/mas/Models/CatalogAppResults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// Copyright © 2018 mas-cli. All rights reserved.
//

struct CatalogAppResults: Decodable, Sendable {
// periphery:ignore
let resultCount: Int // swiftlint:disable:this unused_declaration
struct CatalogAppResults: Decodable, Sendable { // swiftlint:disable:next unused_declaration
let resultCount: Int // periphery:ignore
let results: [CatalogApp]
}
3 changes: 1 addition & 2 deletions Sources/mas/Models/InstalledApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ struct InstalledApp: Sendable {
let adamID: ADAMID
let bundleID: String
let name: String
// periphery:ignore
let path: String
let path: String // periphery:ignore
let version: String

var isTestFlight: Bool {
Expand Down
4 changes: 4 additions & 0 deletions Sources/mas/Utilities/Printer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct Printer: Sendable {
}

/// Prints to `stdout`.
@_disfavoredOverload
func info(_ items: Any..., separator: String = " ", terminator: String = "\n") {
info(items, separator: separator, terminator: terminator)
}
Expand All @@ -34,6 +35,7 @@ struct Printer: Sendable {

/// Prints to `stdout`, prefixed with "==> "; if connected to a terminal, the
/// prefix is blue.
@_disfavoredOverload
func notice(_ items: Any..., separator: String = " ", terminator: String = "\n") {
notice(items, separator: separator, terminator: terminator)
}
Expand All @@ -46,6 +48,7 @@ struct Printer: Sendable {

/// Prints to `stderr`, prefixed with "Warning: "; if connected to a terminal,
/// the prefix is yellow & underlined.
@_disfavoredOverload
func warning(_ items: Any..., error: (any Error)? = nil, separator: String = " ", terminator: String = "\n") {
warning(items, error: error, separator: separator, terminator: terminator)
}
Expand All @@ -58,6 +61,7 @@ struct Printer: Sendable {

/// Prints to `stderr`, prefixed with "Error: "; if connected to a terminal,
/// the prefix is red & underlined.
@_disfavoredOverload
func error(_ items: Any..., error: (any Error)? = nil, separator: String = " ", terminator: String = "\n") {
self.error(items, error: error, separator: separator, terminator: terminator)
}
Expand Down
12 changes: 5 additions & 7 deletions Sources/mas/Utilities/Version+SemVer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ protocol Version: CustomStringConvertible {
var prerelease: String? { get }
var build: String? { get }

// periphery:ignore
init?(from versionString: String)
init?(from versionString: String) // periphery:ignore
}

protocol CoreIntegerVersion: Version {
Expand All @@ -36,12 +35,11 @@ extension CoreIntegerVersion where Integer: FixedWidthInteger {
}
}

// periphery:ignore
protocol MajorMinorPatch { // swiftlint:disable unused_declaration
var major: String { get }
var minor: String { get }
var patch: String { get } // swiftlint:enable unused_declaration
}
var major: String { get } // periphery:ignore
var minor: String { get } // periphery:ignore
var patch: String { get } // periphery:ignore
} // swiftlint:enable unused_declaration

protocol MajorMinorPatchInteger: MajorMinorPatch {
associatedtype Integer: BinaryInteger
Expand Down
Loading