Skip to content

Commit e1d51c4

Browse files
committed
Merge branch 'package-designation-rewrite.improved-adoptables-name-matching'
# Conflicts: # Modules/Packages/PackagesModels/Logic/Package Loading/Get Outdated Packages.swift
2 parents 1b86ae5 + ff42b93 commit e1d51c4

File tree

61 files changed

+378
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+378
-234
lines changed

Cork/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ private extension View
660660
shouldRemoveAllAssociatedFiles: false
661661
)
662662
} label: {
663-
Text("action.uninstall-\(packageToUninstall.name)")
663+
Text("action.uninstall-\(packageToUninstall.name(withPrecision: .precise))")
664664
}
665665
.keyboardShortcut(.defaultAction)
666666
.asyncButtonStyle(.plainStyle)
@@ -676,7 +676,7 @@ private extension View
676676
shouldRemoveAllAssociatedFiles: true
677677
)
678678
} label: {
679-
Text("action.purge-\(packageToPurge.name)")
679+
Text("action.purge-\(packageToPurge.name(withPrecision: .precise))")
680680
}
681681
}
682682
}, message: { dialogType in

Cork/CorkApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ struct CorkApp: App
706706
let differentPackages: Set<OutdatedPackage> = await newOutdatedPackages.subtracting(outdatedPackagesTracker.allDisplayableOutdatedPackages)
707707
AppConstants.shared.logger.debug("Changed packages: \(differentPackages, privacy: .auto)")
708708

709-
sendNotification(title: String(localized: "notification.new-outdated-packages-found.title"), subtitle: differentPackages.map{$0.package.name}.formatted(.list(type: .and)))
709+
sendNotification(title: String(localized: "notification.new-outdated-packages-found.title"), subtitle: differentPackages.map{$0.package.name(withPrecision: .precise)}.formatted(.list(type: .and)))
710710

711711
await outdatedPackagesTracker.setOutdatedPackages(to: newOutdatedPackages)
712712

Cork/Logic/App Intents/Currently Installed Packages/Get Installed Casks Intent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public struct GetInstalledCasksIntent: AppIntent
4949

5050
let minimalPackages: [MinimalHomebrewPackage] = validInstalledCasks.map
5151
{ package in
52-
.init(name: package.name, type: .cask, installDate: package.installedOn, installedIntentionally: true)
52+
.init(name: package.name(withPrecision: .precise), type: .cask, installDate: package.installedOn, installedIntentionally: true)
5353
}
5454

5555
return .result(value: minimalPackages)

Cork/Logic/App Intents/Currently Installed Packages/Get Installed Formulae Intent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct GetInstalledFormulaeIntent: AppIntent
6363

6464
var minimalPackages: [MinimalHomebrewPackage] = validInstalledFormulae.map
6565
{ package in
66-
.init(name: package.name, type: .formula, installedIntentionally: package.installedIntentionally)
66+
.init(name: package.name(withPrecision: .precise), type: .formula, installedIntentionally: package.installedIntentionally)
6767
}
6868

6969
if getOnlyManuallyInstalledPackages

Cork/Logic/Discoverability/Load up Top Packages.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ extension TopPackagesTracker
101101
if normalizedDownloadNumber > downloadsCutoff
102102
{
103103
return .init(
104-
name: rawTopFormula.formula,
104+
rawName: rawTopFormula.formula,
105105
type: .formula,
106106
installedOn: nil,
107107
versions: .init(),
@@ -165,7 +165,7 @@ extension TopPackagesTracker
165165
if normalizedDownloadNumber > downloadsCutoff
166166
{
167167
return .init(
168-
name: rawTopCask.cask,
168+
rawName: rawTopCask.cask,
169169
type: .cask,
170170
installedOn: nil,
171171
versions: .init(),

Cork/Logic/Maintenance/Steps/Delete Cached Downloads.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
import Foundation
99
import CorkShared
1010
import CorkModels
11+
import Defaults
1112

1213
func deleteCachedDownloads() throws(CachedDownloadDeletionError)
1314
{
14-
let shouldStrictlyCheckForHomebrewErrors: Bool = UserDefaults.standard.bool(forKey: "strictlyCheckForHomebrewErrors")
15+
let shouldStrictlyCheckForHomebrewErrors: Bool = Defaults[.strictlyCheckForHomebrewErrors]
1516

1617
/// This folder has the symlinks, so we have do **delete ONLY THE SYMLINKS**
1718
do

Cork/Logic/Submit System Version.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import AppKit
99
import CorkShared
1010
import Foundation
11+
import Defaults
1112

1213
func submitSystemVersion() async throws
1314
{

Cork/Logic/Updating and Upgrading/Refresh Packages.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import SwiftUI
1010
import CorkShared
1111
import CorkTerminalFunctions
1212
import CorkModels
13+
import Defaults
1314

1415
@MainActor
1516
func refreshPackages(_ updateProgressTracker: UpdateProgressTracker, outdatedPackagesTracker: OutdatedPackagesTracker) async -> PackageUpdateAvailability
1617
{
17-
let showRealTimeTerminalOutputs: Bool = UserDefaults.standard.bool(forKey: "showRealTimeTerminalOutputOfOperations")
18+
let showRealTimeTerminalOutputs: Bool = Defaults[.showRealTimeTerminalOutputOfOperations]
1819

1920
for await output in shell(AppConstants.shared.brewExecutablePath, ["update"])
2021
{

Cork/Logic/Updating and Upgrading/Update Packages.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import Foundation
99
import SwiftUI
1010
import CorkShared
1111
import CorkTerminalFunctions
12+
import Defaults
1213

1314
@MainActor
1415
func updatePackages(updateProgressTracker: UpdateProgressTracker, detailStage: UpdatingProcessDetails) async
1516
{
16-
let showRealTimeTerminalOutputs: Bool = UserDefaults.standard.bool(forKey: "showRealTimeTerminalOutputOfOperations")
17-
let includeGreedyPackages: Bool = UserDefaults.standard.bool(forKey: "includeGreedyOutdatedPackages")
17+
let showRealTimeTerminalOutputs: Bool = Defaults[.showRealTimeTerminalOutputOfOperations]
18+
let includeGreedyPackages: Bool = Defaults[.includeGreedyOutdatedPackages]
1819

1920
for await output in shell(AppConstants.shared.brewExecutablePath, ["upgrade", includeGreedyPackages ? "--greedy" : ""])
2021
{

Cork/Models/Package Installation/Installation Progress Tracker.swift

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,24 @@ import Foundation
99
import CorkShared
1010
import CorkModels
1111
import CorkTerminalFunctions
12+
import Defaults
1213

1314
@Observable
1415
class InstallationProgressTracker
1516
{
16-
var packageBeingInstalled: PackageInProgressOfBeingInstalled = .init(package: .init(name: "", type: .formula, installedOn: nil, versions: [], url: nil, sizeInBytes: 0, downloadCount: nil), installationStage: .downloadingCask, packageInstallationProgress: 0)
17+
var packageBeingInstalled: PackageInProgressOfBeingInstalled = .init(
18+
package: .init(
19+
rawName: "",
20+
type: .formula,
21+
installedOn: nil,
22+
versions: [],
23+
url: nil,
24+
sizeInBytes: 0,
25+
downloadCount: nil
26+
),
27+
installationStage: .downloadingCask,
28+
packageInstallationProgress: 0
29+
)
1730

1831
var numberOfPackageDependencies: Int = 0
1932
var numberInLineOfPackageCurrentlyBeingFetched: Int = 0
@@ -23,7 +36,7 @@ class InstallationProgressTracker
2336

2437
private var showRealTimeTerminalOutputs: Bool
2538
{
26-
UserDefaults.standard.bool(forKey: "showRealTimeTerminalOutputOfOperations")
39+
Defaults[.showRealTimeTerminalOutputOfOperations]
2740
}
2841

2942
deinit
@@ -45,13 +58,13 @@ class InstallationProgressTracker
4558
{
4659
let package: BrewPackage = packageBeingInstalled.package
4760

48-
AppConstants.shared.logger.debug("Installing package \(package.name, privacy: .auto)")
61+
AppConstants.shared.logger.debug("Installing package \(package.name(withPrecision: .precise), privacy: .auto)")
4962

5063
var installationResult: TerminalOutput = .init(standardOutput: "", standardError: "")
5164

5265
if package.type == .formula
5366
{
54-
AppConstants.shared.logger.info("Package \(package.name, privacy: .public) is Formula")
67+
AppConstants.shared.logger.info("Package \(package.name(withPrecision: .precise), privacy: .public) is Formula")
5568

5669
let output: String = try await installFormula(using: brewPackagesTracker).joined(separator: "")
5770

@@ -88,9 +101,9 @@ class InstallationProgressTracker
88101
var hasAlreadyMatchedLineAboutInstallingPackageItself: Bool = false
89102
var installOutput: [String] = .init()
90103

91-
AppConstants.shared.logger.info("Package \(package.name, privacy: .public) is Formula")
104+
AppConstants.shared.logger.info("Package \(package.name(withPrecision: .precise), privacy: .public) is Formula")
92105

93-
let (stream, process): (AsyncStream<StreamedTerminalOutput>, Process) = shell(AppConstants.shared.brewExecutablePath, ["install", package.name])
106+
let (stream, process): (AsyncStream<StreamedTerminalOutput>, Process) = shell(AppConstants.shared.brewExecutablePath, ["install", package.name(withPrecision: .precise)])
94107
installationProcess = process
95108
for await output in stream
96109
{
@@ -110,7 +123,7 @@ class InstallationProgressTracker
110123
if outputLine.contains("Fetching dependencies")
111124
{
112125
// First, we have to get a list of all the dependencies
113-
var matchedDependencies: String = try outputLine.regexMatch("(?<=\(package.name): ).*?(.*)")
126+
var matchedDependencies: String = try outputLine.regexMatch("(?<=\(package.name(withPrecision: .precise)): ).*?(.*)")
114127
matchedDependencies = matchedDependencies.replacingOccurrences(of: " and", with: ",") // The last dependency is different, because it's preceded by "and" instead of "," so let's replace that "and" with "," so we can split it nicely
115128

116129
AppConstants.shared.logger.debug("Matched Dependencies: \(matchedDependencies, privacy: .auto)")
@@ -126,7 +139,7 @@ class InstallationProgressTracker
126139
packageBeingInstalled.packageInstallationProgress = 1
127140
}
128141

129-
else if outputLine.contains("Installing dependencies") || outputLine.contains("Installing \(package.name) dependency")
142+
else if outputLine.contains("Installing dependencies") || outputLine.contains("Installing \(package.name(withPrecision: .precise)) dependency")
130143
{
131144
AppConstants.shared.logger.info("Will install dependencies!")
132145
packageBeingInstalled.installationStage = .installingDependencies
@@ -151,7 +164,7 @@ class InstallationProgressTracker
151164
packageBeingInstalled.packageInstallationProgress = packageBeingInstalled.packageInstallationProgress + Double(Double(10) / (Double(3) * (Double(numberOfPackageDependencies) * Double(5))))
152165
}
153166

154-
else if outputLine.contains("Fetching \(package.name)") || outputLine.contains("Installing \(package.name)")
167+
else if outputLine.contains("Fetching \(package.name(withPrecision: .precise))") || outputLine.contains("Installing \(package.name(withPrecision: .precise))")
155168
{
156169
if hasAlreadyMatchedLineAboutInstallingPackageItself
157170
{ /// Only the second line about the package being installed is valid
@@ -205,9 +218,9 @@ class InstallationProgressTracker
205218
let package: BrewPackage = packageBeingInstalled.package
206219

207220
AppConstants.shared.logger.info("Package is Cask")
208-
AppConstants.shared.logger.debug("Installing package \(package.name, privacy: .public)")
221+
AppConstants.shared.logger.debug("Installing package \(package.name(withPrecision: .precise), privacy: .public)")
209222

210-
let (stream, process): (AsyncStream<StreamedTerminalOutput>, Process) = shell(AppConstants.shared.brewExecutablePath, ["install", package.name])
223+
let (stream, process): (AsyncStream<StreamedTerminalOutput>, Process) = shell(AppConstants.shared.brewExecutablePath, ["install", package.name(withPrecision: .precise)])
211224
installationProcess = process
212225
for await output in stream
213226
{
@@ -255,7 +268,7 @@ class InstallationProgressTracker
255268
}
256269
else if outputLine.contains("Purging files")
257270
{
258-
AppConstants.shared.logger.info("Purging old version of cask \(package.name)")
271+
AppConstants.shared.logger.info("Purging old version of cask \(package.name(withPrecision: .precise))")
259272

260273
packageBeingInstalled.installationStage = .installingCask
261274

0 commit comments

Comments
 (0)