Compare commits
7 Commits
c675a98309
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
887d4b3727 | ||
|
|
5cfd971f57 | ||
|
|
675f4ee89b | ||
|
|
4c9665a41b | ||
|
|
253f550212 | ||
|
|
dc99548d07 | ||
|
|
6b3b26e4bc |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -97,4 +97,4 @@ fastlane/test_output
|
|||||||
# https://github.com/johnno1962/injectionforxcode
|
# https://github.com/johnno1962/injectionforxcode
|
||||||
|
|
||||||
iOSInjectionProject/
|
iOSInjectionProject/
|
||||||
|
.DS_Store
|
||||||
|
|||||||
69
.swift-format
Normal file
69
.swift-format
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
"fileScopedDeclarationPrivacy" : {
|
||||||
|
"accessLevel" : "private"
|
||||||
|
},
|
||||||
|
"indentation" : {
|
||||||
|
"tabs" : 1
|
||||||
|
},
|
||||||
|
"indentConditionalCompilationBlocks" : true,
|
||||||
|
"indentSwitchCaseLabels" : false,
|
||||||
|
"lineBreakAroundMultilineExpressionChainComponents" : false,
|
||||||
|
"lineBreakBeforeControlFlowKeywords" : false,
|
||||||
|
"lineBreakBeforeEachArgument" : false,
|
||||||
|
"lineBreakBeforeEachGenericRequirement" : false,
|
||||||
|
"lineLength" : 80,
|
||||||
|
"maximumBlankLines" : 1,
|
||||||
|
"multiElementCollectionTrailingCommas" : true,
|
||||||
|
"noAssignmentInExpressions" : {
|
||||||
|
"allowedFunctions" : [
|
||||||
|
"XCTAssertNoThrow"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"prioritizeKeepingFunctionOutputTogether" : false,
|
||||||
|
"respectsExistingLineBreaks" : true,
|
||||||
|
"rules" : {
|
||||||
|
"AllPublicDeclarationsHaveDocumentation" : false,
|
||||||
|
"AlwaysUseLiteralForEmptyCollectionInit" : false,
|
||||||
|
"AlwaysUseLowerCamelCase" : true,
|
||||||
|
"AmbiguousTrailingClosureOverload" : true,
|
||||||
|
"BeginDocumentationCommentWithOneLineSummary" : false,
|
||||||
|
"DoNotUseSemicolons" : true,
|
||||||
|
"DontRepeatTypeInStaticProperties" : true,
|
||||||
|
"FileScopedDeclarationPrivacy" : true,
|
||||||
|
"FullyIndirectEnum" : true,
|
||||||
|
"GroupNumericLiterals" : true,
|
||||||
|
"IdentifiersMustBeASCII" : true,
|
||||||
|
"NeverForceUnwrap" : false,
|
||||||
|
"NeverUseForceTry" : false,
|
||||||
|
"NeverUseImplicitlyUnwrappedOptionals" : false,
|
||||||
|
"NoAccessLevelOnExtensionDeclaration" : true,
|
||||||
|
"NoAssignmentInExpressions" : true,
|
||||||
|
"NoBlockComments" : true,
|
||||||
|
"NoCasesWithOnlyFallthrough" : true,
|
||||||
|
"NoEmptyTrailingClosureParentheses" : true,
|
||||||
|
"NoLabelsInCasePatterns" : true,
|
||||||
|
"NoLeadingUnderscores" : false,
|
||||||
|
"NoParensAroundConditions" : true,
|
||||||
|
"NoPlaygroundLiterals" : true,
|
||||||
|
"NoVoidReturnOnFunctionSignature" : true,
|
||||||
|
"OmitExplicitReturns" : false,
|
||||||
|
"OneCasePerLine" : true,
|
||||||
|
"OneVariableDeclarationPerLine" : true,
|
||||||
|
"OnlyOneTrailingClosureArgument" : true,
|
||||||
|
"OrderedImports" : true,
|
||||||
|
"ReplaceForEachWithForLoop" : true,
|
||||||
|
"ReturnVoidInsteadOfEmptyTuple" : true,
|
||||||
|
"TypeNamesShouldBeCapitalized" : true,
|
||||||
|
"UseEarlyExits" : false,
|
||||||
|
"UseLetInEveryBoundCaseVariable" : true,
|
||||||
|
"UseShorthandTypeNames" : true,
|
||||||
|
"UseSingleLinePropertyGetter" : true,
|
||||||
|
"UseSynthesizedInitializer" : true,
|
||||||
|
"UseTripleSlashForDocumentationComments" : true,
|
||||||
|
"UseWhereClausesInForLoops" : false,
|
||||||
|
"ValidateDocumentationComments" : false
|
||||||
|
},
|
||||||
|
"spacesAroundRangeFormationOperators" : false,
|
||||||
|
"tabWidth" : 4,
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
9E6C730C2C3D796D0056ADDC /* DownloadButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C730B2C3D796D0056ADDC /* DownloadButton.swift */; };
|
9E6C730C2C3D796D0056ADDC /* DownloadButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C730B2C3D796D0056ADDC /* DownloadButton.swift */; };
|
||||||
9E6C730E2C3DB16F0056ADDC /* UninstallButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C730D2C3DB16F0056ADDC /* UninstallButton.swift */; };
|
9E6C730E2C3DB16F0056ADDC /* UninstallButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C730D2C3DB16F0056ADDC /* UninstallButton.swift */; };
|
||||||
9E6C73112C3DB5940056ADDC /* CaskDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C73102C3DB5940056ADDC /* CaskDetailView.swift */; };
|
9E6C73112C3DB5940056ADDC /* CaskDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C73102C3DB5940056ADDC /* CaskDetailView.swift */; };
|
||||||
|
9E6C73182C3E853E0056ADDC /* UpdateButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E6C73172C3E853E0056ADDC /* UpdateButton.swift */; };
|
||||||
|
9E7ADB5A2C3EE41F00F2B8CA /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = 9E7ADB592C3EE41F00F2B8CA /* LaunchAtLogin */; };
|
||||||
9E8CE5362C3C545600A39146 /* BrewerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8CE5352C3C545600A39146 /* BrewerApp.swift */; };
|
9E8CE5362C3C545600A39146 /* BrewerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8CE5352C3C545600A39146 /* BrewerApp.swift */; };
|
||||||
9E8CE5382C3C545600A39146 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8CE5372C3C545600A39146 /* ContentView.swift */; };
|
9E8CE5382C3C545600A39146 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8CE5372C3C545600A39146 /* ContentView.swift */; };
|
||||||
9E8CE53A2C3C545700A39146 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9E8CE5392C3C545700A39146 /* Assets.xcassets */; };
|
9E8CE53A2C3C545700A39146 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9E8CE5392C3C545700A39146 /* Assets.xcassets */; };
|
||||||
@@ -45,6 +47,7 @@
|
|||||||
9E6C730B2C3D796D0056ADDC /* DownloadButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadButton.swift; sourceTree = "<group>"; };
|
9E6C730B2C3D796D0056ADDC /* DownloadButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadButton.swift; sourceTree = "<group>"; };
|
||||||
9E6C730D2C3DB16F0056ADDC /* UninstallButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UninstallButton.swift; sourceTree = "<group>"; };
|
9E6C730D2C3DB16F0056ADDC /* UninstallButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UninstallButton.swift; sourceTree = "<group>"; };
|
||||||
9E6C73102C3DB5940056ADDC /* CaskDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaskDetailView.swift; sourceTree = "<group>"; };
|
9E6C73102C3DB5940056ADDC /* CaskDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaskDetailView.swift; sourceTree = "<group>"; };
|
||||||
|
9E6C73172C3E853E0056ADDC /* UpdateButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateButton.swift; sourceTree = "<group>"; };
|
||||||
9E8CE5322C3C545600A39146 /* Brewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Brewer.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
9E8CE5322C3C545600A39146 /* Brewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Brewer.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
9E8CE5352C3C545600A39146 /* BrewerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrewerApp.swift; sourceTree = "<group>"; };
|
9E8CE5352C3C545600A39146 /* BrewerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrewerApp.swift; sourceTree = "<group>"; };
|
||||||
9E8CE5372C3C545600A39146 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
9E8CE5372C3C545600A39146 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||||
@@ -64,6 +67,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
9E7ADB5A2C3EE41F00F2B8CA /* LaunchAtLogin in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -88,6 +92,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
9E6C730B2C3D796D0056ADDC /* DownloadButton.swift */,
|
9E6C730B2C3D796D0056ADDC /* DownloadButton.swift */,
|
||||||
|
9E6C73172C3E853E0056ADDC /* UpdateButton.swift */,
|
||||||
9E6C730D2C3DB16F0056ADDC /* UninstallButton.swift */,
|
9E6C730D2C3DB16F0056ADDC /* UninstallButton.swift */,
|
||||||
);
|
);
|
||||||
path = Components;
|
path = Components;
|
||||||
@@ -187,6 +192,9 @@
|
|||||||
dependencies = (
|
dependencies = (
|
||||||
);
|
);
|
||||||
name = Brewer;
|
name = Brewer;
|
||||||
|
packageProductDependencies = (
|
||||||
|
9E7ADB592C3EE41F00F2B8CA /* LaunchAtLogin */,
|
||||||
|
);
|
||||||
productName = Brewer;
|
productName = Brewer;
|
||||||
productReference = 9E8CE5322C3C545600A39146 /* Brewer.app */;
|
productReference = 9E8CE5322C3C545600A39146 /* Brewer.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
@@ -259,6 +267,9 @@
|
|||||||
Base,
|
Base,
|
||||||
);
|
);
|
||||||
mainGroup = 9E8CE5292C3C545600A39146;
|
mainGroup = 9E8CE5292C3C545600A39146;
|
||||||
|
packageReferences = (
|
||||||
|
9E98BE4E2C3EE353006ED274 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */,
|
||||||
|
);
|
||||||
productRefGroup = 9E8CE5332C3C545600A39146 /* Products */;
|
productRefGroup = 9E8CE5332C3C545600A39146 /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
@@ -304,6 +315,7 @@
|
|||||||
9E6C73072C3D5E570056ADDC /* SearchView.swift in Sources */,
|
9E6C73072C3D5E570056ADDC /* SearchView.swift in Sources */,
|
||||||
9E6C730C2C3D796D0056ADDC /* DownloadButton.swift in Sources */,
|
9E6C730C2C3D796D0056ADDC /* DownloadButton.swift in Sources */,
|
||||||
9E8CE5382C3C545600A39146 /* ContentView.swift in Sources */,
|
9E8CE5382C3C545600A39146 /* ContentView.swift in Sources */,
|
||||||
|
9E6C73182C3E853E0056ADDC /* UpdateButton.swift in Sources */,
|
||||||
9E6C730E2C3DB16F0056ADDC /* UninstallButton.swift in Sources */,
|
9E6C730E2C3DB16F0056ADDC /* UninstallButton.swift in Sources */,
|
||||||
9E8CE5622C3C5A6A00A39146 /* Homebrew.swift in Sources */,
|
9E8CE5622C3C5A6A00A39146 /* Homebrew.swift in Sources */,
|
||||||
9E6C73092C3D5E950056ADDC /* InstalledView.swift in Sources */,
|
9E6C73092C3D5E950056ADDC /* InstalledView.swift in Sources */,
|
||||||
@@ -469,21 +481,24 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_ENTITLEMENTS = Brewer/Brewer.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Brewer/Brewer.entitlements;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = "0.1.3-beta";
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Brewer/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Brewer/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = 96S93Z7LTG;
|
DEVELOPMENT_TEAM = 96S93Z7LTG;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = Brewer;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
|
||||||
INFOPLIST_KEY_LSUIElement = YES;
|
INFOPLIST_KEY_LSUIElement = YES;
|
||||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = "0.1.3-beta";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = dev.cems.Brewer;
|
PRODUCT_BUNDLE_IDENTIFIER = dev.cems.Brewer;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -497,21 +512,24 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_ENTITLEMENTS = Brewer/Brewer.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Brewer/Brewer.entitlements;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = "0.1.3-beta";
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Brewer/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Brewer/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = 96S93Z7LTG;
|
DEVELOPMENT_TEAM = 96S93Z7LTG;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_KEY_CFBundleDisplayName = Brewer;
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
|
||||||
INFOPLIST_KEY_LSUIElement = YES;
|
INFOPLIST_KEY_LSUIElement = YES;
|
||||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = "0.1.3-beta";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = dev.cems.Brewer;
|
PRODUCT_BUNDLE_IDENTIFIER = dev.cems.Brewer;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -631,6 +649,25 @@
|
|||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
|
9E98BE4E2C3EE353006ED274 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin-Modern";
|
||||||
|
requirement = {
|
||||||
|
branch = main;
|
||||||
|
kind = branch;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
9E7ADB592C3EE41F00F2B8CA /* LaunchAtLogin */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = 9E98BE4E2C3EE353006ED274 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */;
|
||||||
|
productName = LaunchAtLogin;
|
||||||
|
};
|
||||||
|
/* End XCSwiftPackageProductDependency section */
|
||||||
};
|
};
|
||||||
rootObject = 9E8CE52A2C3C545600A39146 /* Project object */;
|
rootObject = 9E8CE52A2C3C545600A39146 /* Project object */;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"originHash" : "aae61040c30e63b9cf0f5455365680cfeabef0aac829c0941d4d6f6180010fc9",
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "launchatlogin-modern",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/sindresorhus/LaunchAtLogin-Modern",
|
||||||
|
"state" : {
|
||||||
|
"branch" : "main",
|
||||||
|
"revision" : "a04ec1c363be3627734f6dad757d82f5d4fa8fcc"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 3
|
||||||
|
}
|
||||||
@@ -5,38 +5,60 @@
|
|||||||
// Created by Cédric MAS on 08/07/2024.
|
// Created by Cédric MAS on 08/07/2024.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import LaunchAtLogin
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
@main
|
@main
|
||||||
struct BrewerApp: App {
|
struct BrewerApp: App {
|
||||||
@AppStorage("isUpToDate") var isUpToDate: Bool = true
|
@AppStorage("isUpToDate") var isUpToDate: Bool = true
|
||||||
init() {
|
init() {
|
||||||
do {
|
do {
|
||||||
let res = try shell("/opt/homebrew/bin/brew outdated --greedy-latest -g | wc -l")
|
let res = try shell(
|
||||||
if let number = Int(res.trimmingCharacters(in: .whitespacesAndNewlines)), number > 0 {
|
"/opt/homebrew/bin/brew outdated --greedy-latest -g | wc -l")
|
||||||
isUpToDate = false
|
if let number = Int(
|
||||||
}
|
res.trimmingCharacters(in: .whitespacesAndNewlines)), number > 0
|
||||||
} catch {
|
{
|
||||||
print(error.localizedDescription)
|
print(number)
|
||||||
}
|
isUpToDate = false
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
print(error.localizedDescription)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
MenuBarExtra {
|
||||||
EmptyView()
|
VStack(spacing: 0) {
|
||||||
}
|
ContentView()
|
||||||
MenuBarExtra {
|
Form {
|
||||||
ContentView().padding()
|
HStack {
|
||||||
} label: {
|
LaunchAtLogin.Toggle()
|
||||||
if isUpToDate {
|
Button {
|
||||||
Label("Brewer", systemImage: "sparkle.magnifyingglass")
|
NSApplication.shared.terminate(self)
|
||||||
} else {
|
} label: {
|
||||||
Label("Brewer", systemImage: "sparkle.magnifyingglass")
|
Label("Quit", systemImage: "x")
|
||||||
.symbolRenderingMode(.palette)
|
.symbolRenderingMode(.palette)
|
||||||
.foregroundStyle(.orange)
|
.symbolVariant(.circle)
|
||||||
}
|
.symbolVariant(.fill)
|
||||||
}
|
.foregroundStyle(.white, .red)
|
||||||
.menuBarExtraStyle(.window)
|
}
|
||||||
}
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.padding()
|
||||||
|
} label: {
|
||||||
|
if isUpToDate {
|
||||||
|
Label("Brewer", systemImage: "sparkle.magnifyingglass")
|
||||||
|
} else {
|
||||||
|
Label("Brewer", systemImage: "sparkle.magnifyingglass")
|
||||||
|
.symbolRenderingMode(.palette)
|
||||||
|
.foregroundStyle(.orange)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.menuBarExtraStyle(.window)
|
||||||
|
WindowGroup {
|
||||||
|
EmptyView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,31 +8,32 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct CaskDetailView: View {
|
struct CaskDetailView: View {
|
||||||
var cask: Cask
|
var cask: Cask
|
||||||
@Bindable var brewListing: Homebrew
|
@Bindable var brewListing: Homebrew
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
VStack {
|
VStack {
|
||||||
Text("Identifier: \(cask.fullToken)")
|
Text("Identifier: \(cask.fullToken)")
|
||||||
Text("Version: \(cask.version)")
|
Text("Version: \(cask.version)")
|
||||||
}
|
}
|
||||||
.navigationTitle(cask.name.first ?? cask.fullToken)
|
.navigationTitle(cask.name.first ?? cask.fullToken)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .primaryAction) {
|
ToolbarItem(placement: .primaryAction) {
|
||||||
if cask.installed == nil {
|
if cask.installed == nil {
|
||||||
DownloadButton(name: cask.fullToken, isCask: true)
|
DownloadButton(name: cask.fullToken, isCask: true)
|
||||||
} else if cask.outdated {
|
} else if cask.outdated {
|
||||||
Button("Update") {
|
Button("Update") {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cask.installed != nil {
|
if cask.installed != nil {
|
||||||
ToolbarItem(placement: .primaryAction) {
|
ToolbarItem(placement: .primaryAction) {
|
||||||
UninstallButton(name: cask.fullToken, brewListing: brewListing)
|
UninstallButton(
|
||||||
}
|
name: cask.fullToken, brewListing: brewListing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,46 +8,46 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct DownloadButton: View {
|
struct DownloadButton: View {
|
||||||
let name: String
|
let name: String
|
||||||
var isCask: Bool = false
|
var isCask: Bool = false
|
||||||
@State private var brew = Homebrew()
|
@State private var brew = Homebrew()
|
||||||
@State private var downloaded = false
|
@State private var downloaded = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
if downloaded {
|
if downloaded {
|
||||||
Image(systemName: "checkmark")
|
Image(systemName: "checkmark")
|
||||||
.symbolRenderingMode(.palette)
|
.symbolRenderingMode(.palette)
|
||||||
.symbolVariant(.circle)
|
.symbolVariant(.circle)
|
||||||
.symbolVariant(.fill)
|
.symbolVariant(.fill)
|
||||||
.foregroundStyle(.white, .green)
|
.foregroundStyle(.white, .green)
|
||||||
} else if brew.isLoading {
|
} else if brew.isLoading {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
.controlSize(.small)
|
.controlSize(.small)
|
||||||
} else if brew.errorMessage != nil {
|
} else if brew.errorMessage != nil {
|
||||||
Image(systemName: "x")
|
Image(systemName: "x")
|
||||||
.symbolRenderingMode(.palette)
|
.symbolRenderingMode(.palette)
|
||||||
.symbolVariant(.circle)
|
.symbolVariant(.circle)
|
||||||
.symbolVariant(.fill)
|
.symbolVariant(.fill)
|
||||||
.foregroundStyle(.white, .red)
|
.foregroundStyle(.white, .red)
|
||||||
} else {
|
} else {
|
||||||
Button("Get") {
|
Button("Get") {
|
||||||
Task {
|
Task {
|
||||||
downloaded = await brew.install(name, isCask: isCask)
|
downloaded = await brew.install(name, isCask: isCask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.buttonBorderShape(.capsule)
|
.buttonBorderShape(.capsule)
|
||||||
.buttonStyle(.borderedProminent)
|
.buttonStyle(.borderedProminent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
Task {
|
Task {
|
||||||
downloaded = await brew.isDownloaded(name)
|
downloaded = await brew.isDownloaded(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
DownloadButton(name: "firefox")
|
DownloadButton(name: "firefox")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,38 +8,38 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct UninstallButton: View {
|
struct UninstallButton: View {
|
||||||
let name: String
|
let name: String
|
||||||
@State private var brew = Homebrew()
|
@State private var brew = Homebrew()
|
||||||
@State private var uninstalled = false
|
@State private var uninstalled = false
|
||||||
@Bindable var brewListing: Homebrew
|
@Bindable var brewListing: Homebrew
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
if uninstalled {
|
if uninstalled {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
} else if brew.isLoading {
|
} else if brew.isLoading {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
.controlSize(.small)
|
.controlSize(.small)
|
||||||
} else if brew.errorMessage != nil {
|
} else if brew.errorMessage != nil {
|
||||||
Image(systemName: "x")
|
Image(systemName: "x")
|
||||||
.symbolRenderingMode(.palette)
|
.symbolRenderingMode(.palette)
|
||||||
.symbolVariant(.circle)
|
.symbolVariant(.circle)
|
||||||
.symbolVariant(.fill)
|
.symbolVariant(.fill)
|
||||||
.foregroundStyle(.white, .red)
|
.foregroundStyle(.white, .red)
|
||||||
} else {
|
} else {
|
||||||
Button("Uninstall", role: .destructive) {
|
Button("Uninstall", role: .destructive) {
|
||||||
Task {
|
Task {
|
||||||
uninstalled = await brew.uninstall(name)
|
uninstalled = await brew.uninstall(name)
|
||||||
brewListing.getInstalled()
|
brewListing.getInstalled()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.buttonBorderShape(.capsule)
|
.buttonBorderShape(.capsule)
|
||||||
.buttonStyle(.borderedProminent)
|
.buttonStyle(.borderedProminent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
Task {
|
Task {
|
||||||
uninstalled = await brew.isDownloaded(name)
|
uninstalled = await brew.isDownloaded(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
61
Brewer/Components/UpdateButton.swift
Normal file
61
Brewer/Components/UpdateButton.swift
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
//
|
||||||
|
// UpdateButton.swift
|
||||||
|
// Brewer
|
||||||
|
//
|
||||||
|
// Created by Cédric MAS on 10/07/2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct UpdateButton: View {
|
||||||
|
let name: String
|
||||||
|
@State private var brew = Homebrew()
|
||||||
|
@State private var newInfo = Homebrew()
|
||||||
|
|
||||||
|
private var updated: String? {
|
||||||
|
if let cask = newInfo.data?.casks.first(where: { $0.fullToken == name }
|
||||||
|
), !cask.outdated {
|
||||||
|
return cask.version
|
||||||
|
}
|
||||||
|
if let formulae = newInfo.data?.formulae.first(where: {
|
||||||
|
$0.fullName == name
|
||||||
|
}), !formulae.outdated {
|
||||||
|
return formulae.versions.stable
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
if let newVersion = updated {
|
||||||
|
Text("Updated: \(newVersion)")
|
||||||
|
} else if brew.isLoading {
|
||||||
|
ProgressView()
|
||||||
|
.controlSize(.small)
|
||||||
|
} else if brew.errorMessage != nil {
|
||||||
|
Image(systemName: "x")
|
||||||
|
.symbolRenderingMode(.palette)
|
||||||
|
.symbolVariant(.circle)
|
||||||
|
.symbolVariant(.fill)
|
||||||
|
.foregroundStyle(.white, .red)
|
||||||
|
} else {
|
||||||
|
Button {
|
||||||
|
Task {
|
||||||
|
await brew.update(name)
|
||||||
|
newInfo.getInfo(on: name)
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label(
|
||||||
|
"Update",
|
||||||
|
systemImage:
|
||||||
|
"arrow.counterclockwise"
|
||||||
|
)
|
||||||
|
.symbolRenderingMode(.palette)
|
||||||
|
.symbolVariant(.circle)
|
||||||
|
.symbolVariant(.fill)
|
||||||
|
.foregroundStyle(
|
||||||
|
.white, .orange)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,29 +8,32 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
enum SegementedSelection: String, CaseIterable {
|
enum SegementedSelection: String, CaseIterable {
|
||||||
case search = "Search"
|
case search = "Search"
|
||||||
case installed = "Installed"
|
case installed = "Installed"
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@State private var segmentedSelection: SegementedSelection = .search
|
@State private var segmentedSelection: SegementedSelection = .search
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
Picker("", selection: $segmentedSelection) {
|
VStack {
|
||||||
ForEach(SegementedSelection.allCases, id: \.self) { sel in
|
Picker("", selection: $segmentedSelection) {
|
||||||
Text(sel.rawValue).tag(sel)
|
ForEach(SegementedSelection.allCases, id: \.self) { sel in
|
||||||
}
|
Text(sel.rawValue).tag(sel)
|
||||||
}.pickerStyle(.segmented)
|
}
|
||||||
switch segmentedSelection {
|
}.pickerStyle(.segmented)
|
||||||
case .search:
|
.padding(.leading, -8)
|
||||||
SearchView()
|
switch segmentedSelection {
|
||||||
case .installed:
|
case .search:
|
||||||
InstalledView()
|
SearchView()
|
||||||
}
|
case .installed:
|
||||||
}
|
InstalledView()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
ContentView()
|
ContentView()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,101 +8,99 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct InstalledView: View {
|
struct InstalledView: View {
|
||||||
@State private var brew = Homebrew()
|
@State private var brew = Homebrew()
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
if brew.isLoading {
|
if brew.isLoading {
|
||||||
ProgressView("Loading...")
|
ProgressView("Loading...")
|
||||||
} else if let data = brew.data {
|
} else if let data = brew.data {
|
||||||
List {
|
List {
|
||||||
if !data.casks.isEmpty {
|
if !data.casks.isEmpty {
|
||||||
Section {
|
Section {
|
||||||
ForEach(data.casks, id: \.fullToken) { cask in
|
ForEach(data.casks, id: \.fullToken) { cask in
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
CaskDetailView(cask: cask, brewListing: brew)
|
CaskDetailView(
|
||||||
} label: {
|
cask: cask, brewListing: brew)
|
||||||
HStack {
|
} label: {
|
||||||
Text(cask.name.first ?? cask.fullToken)
|
HStack {
|
||||||
Spacer()
|
Text(cask.name.first ?? cask.fullToken)
|
||||||
if cask.outdated {
|
Spacer()
|
||||||
Button {
|
if cask.outdated {
|
||||||
|
UpdateButton(name: cask.fullToken)
|
||||||
|
} else {
|
||||||
|
Text(cask.version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.contextMenu {
|
||||||
|
UninstallButton(
|
||||||
|
name: cask.fullToken,
|
||||||
|
brewListing: brew)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} header: {
|
||||||
|
HStack {
|
||||||
|
Text("Casks")
|
||||||
|
Spacer()
|
||||||
|
Text("\(data.casks.count) installed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} label: {
|
if !data.formulae.isEmpty {
|
||||||
Label("Update", systemImage: "arrow.counterclockwise.circle.fill")
|
Section {
|
||||||
.symbolRenderingMode(.palette)
|
ForEach(data.formulae, id: \.fullName) { formulae in
|
||||||
.foregroundStyle(.white, .orange)
|
HStack {
|
||||||
}
|
Text(formulae.fullName)
|
||||||
} else {
|
Spacer()
|
||||||
Text(cask.version)
|
if formulae.outdated {
|
||||||
}
|
UpdateButton(name: formulae.fullName)
|
||||||
}
|
} else {
|
||||||
.contextMenu {
|
Text(formulae.versions.stable)
|
||||||
UninstallButton(name: cask.fullToken, brewListing: brew)
|
}
|
||||||
}
|
}
|
||||||
}
|
.contextMenu {
|
||||||
}
|
UninstallButton(
|
||||||
} header: {
|
name: formulae.fullName,
|
||||||
HStack {
|
brewListing: brew)
|
||||||
Text("Casks")
|
}
|
||||||
Spacer()
|
}
|
||||||
Text("\(data.casks.count) installed")
|
} header: {
|
||||||
}
|
HStack {
|
||||||
}
|
Text("Formulae")
|
||||||
}
|
Spacer()
|
||||||
|
Text("\(data.formulae.count) installed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.listStyle(.inset(alternatesRowBackgrounds: true))
|
||||||
|
let areOutdated =
|
||||||
|
data.casks.filter(\.outdated).count
|
||||||
|
+ data.formulae.filter(\.outdated).count
|
||||||
|
let _ = UserDefaults.standard.set(
|
||||||
|
!(areOutdated > 0), forKey: "isUpToDate")
|
||||||
|
if areOutdated > 0 {
|
||||||
|
Button {
|
||||||
|
|
||||||
if !data.formulae.isEmpty {
|
} label: {
|
||||||
Section {
|
Label(
|
||||||
ForEach(data.formulae, id: \.fullName) { formulae in
|
"Update all",
|
||||||
HStack {
|
systemImage: "arrow.counterclockwise.circle.fill")
|
||||||
Text(formulae.fullName)
|
}
|
||||||
Spacer()
|
.buttonStyle(.borderedProminent)
|
||||||
if formulae.outdated {
|
.tint(.orange)
|
||||||
Button {
|
}
|
||||||
|
} else if let error = brew.errorMessage {
|
||||||
} label: {
|
Text(error)
|
||||||
Label("Update", systemImage: "arrow.counterclockwise.circle.fill")
|
.foregroundStyle(.red)
|
||||||
.symbolRenderingMode(.palette)
|
}
|
||||||
.foregroundStyle(.white, .orange)
|
}.task {
|
||||||
}
|
brew.getInstalled()
|
||||||
} else {
|
}
|
||||||
Text(formulae.versions.stable)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
.contextMenu {
|
|
||||||
UninstallButton(name: formulae.fullName, brewListing: brew)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} header: {
|
|
||||||
HStack {
|
|
||||||
Text("Formulae")
|
|
||||||
Spacer()
|
|
||||||
Text("\(data.formulae.count) installed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.listStyle(.inset(alternatesRowBackgrounds: true))
|
|
||||||
let areOutdated = data.casks.map(\.outdated).count + data.formulae.map(\.outdated).count
|
|
||||||
let _ = UserDefaults.standard.set(!(areOutdated > 0), forKey: "isUpToDate")
|
|
||||||
if areOutdated > 0 {
|
|
||||||
Button {
|
|
||||||
|
|
||||||
} label: {
|
|
||||||
Label("Update all", systemImage: "arrow.counterclockwise.circle.fill")
|
|
||||||
}
|
|
||||||
.buttonStyle(.borderedProminent)
|
|
||||||
.tint(.orange)
|
|
||||||
}
|
|
||||||
} else if let error = brew.errorMessage {
|
|
||||||
Text(error)
|
|
||||||
.foregroundStyle(.red)
|
|
||||||
}
|
|
||||||
}.task {
|
|
||||||
brew.getInstalled()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
InstalledView()
|
InstalledView()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,207 +8,241 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum ShellError: Error {
|
enum ShellError: Error {
|
||||||
case emptyOutput
|
case emptyOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
func shell(_ command: String) throws -> String {
|
func shell(_ command: String) throws -> String {
|
||||||
let task = Process()
|
let task = Process()
|
||||||
task.executableURL = URL(filePath: "/bin/bash")
|
task.executableURL = URL(filePath: "/bin/bash")
|
||||||
task.arguments = ["-c", command]
|
task.arguments = ["-c", command]
|
||||||
|
|
||||||
let pipe = Pipe()
|
let pipe = Pipe()
|
||||||
task.standardError = pipe
|
task.standardError = pipe
|
||||||
task.standardOutput = pipe
|
task.standardOutput = pipe
|
||||||
|
|
||||||
try task.run()
|
try task.run()
|
||||||
if let data = try pipe.fileHandleForReading.readToEnd(),
|
if let data = try pipe.fileHandleForReading.readToEnd(),
|
||||||
let output = String(data: data, encoding: .utf8)
|
let output = String(data: data, encoding: .utf8)
|
||||||
{
|
{
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
throw ShellError.emptyOutput
|
throw ShellError.emptyOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Cask: Codable {
|
struct Cask: Codable {
|
||||||
let token: String
|
let token: String
|
||||||
let fullToken: String
|
let fullToken: String
|
||||||
let tap: String
|
let tap: String
|
||||||
let name: [String]
|
let name: [String]
|
||||||
let desc: String
|
let desc: String
|
||||||
let homepage: String
|
let homepage: String
|
||||||
let url: String
|
let url: String
|
||||||
let version: String
|
let version: String
|
||||||
let installed: String?
|
let installed: String?
|
||||||
let outdated: Bool
|
var outdated: Bool
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case token, tap, name, desc, homepage, url, version, installed, outdated
|
case token, tap, name, desc, homepage, url, version, installed, outdated
|
||||||
case fullToken = "full_token"
|
case fullToken = "full_token"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Formulae: Codable {
|
struct Formulae: Codable {
|
||||||
|
|
||||||
struct Version: Codable {
|
struct Version: Codable {
|
||||||
let stable: String
|
let stable: String
|
||||||
let head: String?
|
let head: String?
|
||||||
let bottle: Bool
|
let bottle: Bool
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case stable
|
case stable
|
||||||
case head, bottle
|
case head, bottle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let name: String
|
let name: String
|
||||||
let fullName: String
|
let fullName: String
|
||||||
let tap: String
|
let tap: String
|
||||||
let oldNames: [String]
|
let oldNames: [String]
|
||||||
let aliases: [String]
|
let aliases: [String]
|
||||||
let versionedFormulae: [String]
|
let versionedFormulae: [String]
|
||||||
let desc: String
|
let desc: String
|
||||||
let license: String?
|
let license: String?
|
||||||
let homepage: String
|
let homepage: String
|
||||||
let versions: Version
|
let versions: Version
|
||||||
let outdated: Bool
|
let outdated: Bool
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case name
|
case name
|
||||||
case tap
|
case tap
|
||||||
case aliases
|
case aliases
|
||||||
case desc
|
case desc
|
||||||
case license
|
case license
|
||||||
case homepage
|
case homepage
|
||||||
case versions
|
case versions
|
||||||
case outdated
|
case outdated
|
||||||
case fullName = "full_name"
|
case fullName = "full_name"
|
||||||
case oldNames = "oldnames"
|
case oldNames = "oldnames"
|
||||||
case versionedFormulae = "versioned_formulae"
|
case versionedFormulae = "versioned_formulae"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InfoResponse: Codable {
|
struct InfoResponse: Codable {
|
||||||
let formulae: [Formulae]
|
let formulae: [Formulae]
|
||||||
let casks: [Cask]
|
let casks: [Cask]
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case casks
|
case casks
|
||||||
case formulae
|
case formulae
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Observable
|
@Observable
|
||||||
class Homebrew {
|
class Homebrew {
|
||||||
var data: InfoResponse?
|
var data: InfoResponse?
|
||||||
var isLoading = false
|
var isLoading = false
|
||||||
var errorMessage: String?
|
var errorMessage: String?
|
||||||
|
|
||||||
func getInfo(on query: String) {
|
func getInfo(on query: String) {
|
||||||
self.isLoading = true
|
self.isLoading = true
|
||||||
self.errorMessage = nil
|
self.errorMessage = nil
|
||||||
self.data = nil
|
self.data = nil
|
||||||
Task { [weak self] in
|
Task { [weak self] in
|
||||||
do {
|
do {
|
||||||
let res = try shell("/opt/homebrew/bin/brew info --json=v2 \(query)")
|
let res = try shell(
|
||||||
if let data = res.data(using: .utf8) {
|
"/opt/homebrew/bin/brew info --json=v2 \(query)")
|
||||||
let output = try JSONDecoder().decode(InfoResponse.self, from: data)
|
if let data = res.data(using: .utf8) {
|
||||||
self?.data = output
|
let output = try JSONDecoder().decode(
|
||||||
}
|
InfoResponse.self, from: data)
|
||||||
} catch {
|
self?.data = output
|
||||||
self?.errorMessage = error.localizedDescription
|
}
|
||||||
}
|
} catch {
|
||||||
self?.isLoading = false
|
self?.errorMessage = error.localizedDescription
|
||||||
}
|
}
|
||||||
}
|
self?.isLoading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getInstalled() {
|
func getInstalled() {
|
||||||
self.isLoading = true
|
self.isLoading = true
|
||||||
self.data = nil
|
self.data = nil
|
||||||
self.errorMessage = nil
|
self.errorMessage = nil
|
||||||
Task { [weak self] in
|
Task { [weak self] in
|
||||||
do {
|
do {
|
||||||
let res = try shell("/opt/homebrew/bin/brew info --json=v2 --installed")
|
let res = try shell(
|
||||||
if let data = res.data(using: .utf8) {
|
"/opt/homebrew/bin/brew info --json=v2 --installed")
|
||||||
let output = try JSONDecoder().decode(InfoResponse.self, from: data)
|
if let data = res.data(using: .utf8) {
|
||||||
self?.data = output
|
let output = try JSONDecoder().decode(
|
||||||
}
|
InfoResponse.self, from: data)
|
||||||
} catch {
|
self?.data = output
|
||||||
self?.errorMessage = error.localizedDescription
|
}
|
||||||
}
|
} catch {
|
||||||
self?.isLoading = false
|
self?.errorMessage = error.localizedDescription
|
||||||
}
|
}
|
||||||
|
self?.isLoading = false
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isDownloaded(_ name: String) async -> Bool {
|
func isDownloaded(_ name: String) async -> Bool {
|
||||||
self.isLoading = true
|
self.isLoading = true
|
||||||
self.errorMessage = nil
|
self.errorMessage = nil
|
||||||
self.data = nil
|
self.data = nil
|
||||||
let task = Task { [weak self] in
|
let task = Task { [weak self] in
|
||||||
do {
|
do {
|
||||||
let res = try shell("/opt/homebrew/bin/brew list -1 \(name) >/dev/null 2>&1; echo $?")
|
let res = try shell(
|
||||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
"/opt/homebrew/bin/brew list -1 \(name) >/dev/null 2>&1; echo $?"
|
||||||
self?.isLoading = false
|
)
|
||||||
return res == "0"
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
} catch {
|
self?.isLoading = false
|
||||||
self?.errorMessage = error.localizedDescription
|
return res == "0"
|
||||||
}
|
} catch {
|
||||||
|
self?.errorMessage = error.localizedDescription
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
switch await task.result {
|
switch await task.result {
|
||||||
case .success(let success):
|
case .success(let success):
|
||||||
return success
|
return success
|
||||||
case .failure(let fail):
|
case .failure(let fail):
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func install(_ fullToken: String, isCask: Bool = false) async -> Bool {
|
func install(_ fullToken: String, isCask: Bool = false) async -> Bool {
|
||||||
self.isLoading = true
|
self.isLoading = true
|
||||||
self.data = nil
|
self.data = nil
|
||||||
let task = Task { [weak self] in
|
let task = Task { [weak self] in
|
||||||
do {
|
do {
|
||||||
try shell("/opt/homebrew/bin/brew install \(isCask ? "--cask" : "") \(fullToken)")
|
try shell(
|
||||||
} catch {
|
"/opt/homebrew/bin/brew install \(isCask ? "--cask" : "") \(fullToken)"
|
||||||
self?.errorMessage = error.localizedDescription
|
)
|
||||||
}
|
} catch {
|
||||||
self?.isLoading = false
|
self?.errorMessage = error.localizedDescription
|
||||||
return await self?.isDownloaded(fullToken) ?? false
|
}
|
||||||
}
|
self?.isLoading = false
|
||||||
|
return await self?.isDownloaded(fullToken) ?? false
|
||||||
|
}
|
||||||
|
|
||||||
return switch await task.result {
|
return switch await task.result {
|
||||||
case .success(let success):
|
case .success(let success):
|
||||||
success
|
success
|
||||||
case .failure(let fail):
|
case .failure:
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func uninstall(_ fullToken: String) async -> Bool {
|
func uninstall(_ fullToken: String) async -> Bool {
|
||||||
self.isLoading = true
|
self.isLoading = true
|
||||||
self.data = nil
|
self.data = nil
|
||||||
let task = Task { [weak self] in
|
let task = Task { [weak self] in
|
||||||
do {
|
do {
|
||||||
let res =
|
try shell(
|
||||||
try shell("/opt/homebrew/bin/brew uninstall \(fullToken); echo $?")
|
"/opt/homebrew/bin/brew uninstall \(fullToken)"
|
||||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
)
|
||||||
} catch {
|
} catch {
|
||||||
self?.errorMessage = error.localizedDescription
|
self?.errorMessage = error.localizedDescription
|
||||||
}
|
}
|
||||||
self?.isLoading = false
|
self?.isLoading = false
|
||||||
return await !(self?.isDownloaded(fullToken) ?? true)
|
return await !(self?.isDownloaded(fullToken) ?? true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return switch await task.result {
|
return switch await task.result {
|
||||||
case .success(let success):
|
case .success(let success):
|
||||||
success
|
success
|
||||||
case .failure(let failure):
|
case .failure:
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
func update(_ name: String) async -> Bool {
|
||||||
|
self.isLoading = true
|
||||||
|
self.errorMessage = nil
|
||||||
|
self.data = nil
|
||||||
|
let task = Task { [weak self] in
|
||||||
|
do {
|
||||||
|
let res = try shell(
|
||||||
|
"/opt/homebrew/bin/brew upgrade \(name); echo $?"
|
||||||
|
)
|
||||||
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
self?.isLoading = false
|
||||||
|
return res == "0"
|
||||||
|
} catch {
|
||||||
|
self?.errorMessage = error.localizedDescription
|
||||||
|
}
|
||||||
|
self?.isLoading = false
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return switch await task.result {
|
||||||
|
case .success(let success):
|
||||||
|
success
|
||||||
|
case .failure:
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,58 +8,59 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct SearchView: View {
|
struct SearchView: View {
|
||||||
@State private var query = ""
|
@State private var query = ""
|
||||||
@State private var brew = Homebrew()
|
@State private var brew = Homebrew()
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
TextField("Search", text: $query)
|
TextField("Search", text: $query)
|
||||||
.padding()
|
.onSubmit {
|
||||||
.padding(.bottom, 0)
|
brew.getInfo(on: query)
|
||||||
.onSubmit {
|
}
|
||||||
brew.getInfo(on: query)
|
Spacer()
|
||||||
}
|
if brew.isLoading {
|
||||||
Spacer()
|
ProgressView("Loading...")
|
||||||
if brew.isLoading {
|
} else if let data = brew.data {
|
||||||
ProgressView("Loading...")
|
List {
|
||||||
} else if let data = brew.data {
|
if !data.casks.isEmpty {
|
||||||
List {
|
Section("Casks") {
|
||||||
if !data.casks.isEmpty {
|
ForEach(data.casks, id: \.fullToken) { cask in
|
||||||
Section("Casks") {
|
HStack {
|
||||||
ForEach(data.casks, id: \.fullToken) { cask in
|
Text(cask.fullToken)
|
||||||
HStack {
|
Spacer()
|
||||||
Text(cask.fullToken)
|
if cask.installed != nil {
|
||||||
Spacer()
|
Image(
|
||||||
if cask.installed != nil {
|
systemName: "checkmark.circle.fill"
|
||||||
Image(systemName: "checkmark.circle.fill")
|
)
|
||||||
.symbolRenderingMode(.palette)
|
.symbolRenderingMode(.palette)
|
||||||
.foregroundStyle(.white, .green)
|
.foregroundStyle(.white, .green)
|
||||||
} else {
|
} else {
|
||||||
DownloadButton(name: cask.fullToken, isCask: true)
|
DownloadButton(
|
||||||
}
|
name: cask.fullToken, isCask: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !data.formulae.isEmpty {
|
}
|
||||||
|
if !data.formulae.isEmpty {
|
||||||
|
|
||||||
Section("Formulaes") {
|
Section("Formulaes") {
|
||||||
ForEach(data.formulae, id: \.fullName) { formulae in
|
ForEach(data.formulae, id: \.fullName) { formulae in
|
||||||
HStack {
|
HStack {
|
||||||
Text(formulae.fullName)
|
Text(formulae.fullName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let errorMessage = brew.errorMessage {
|
} else if let errorMessage = brew.errorMessage {
|
||||||
Text(errorMessage)
|
Text(errorMessage)
|
||||||
.foregroundStyle(.red)
|
.foregroundStyle(.red)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
SearchView()
|
SearchView()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,31 +6,32 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
@testable import Brewer
|
@testable import Brewer
|
||||||
|
|
||||||
final class BrewerTests: XCTestCase {
|
final class BrewerTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tearDownWithError() throws {
|
override func tearDownWithError() throws {
|
||||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExample() throws {
|
func testExample() throws {
|
||||||
// This is an example of a functional test case.
|
// This is an example of a functional test case.
|
||||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||||
// Any test you write for XCTest can be annotated as throws and async.
|
// Any test you write for XCTest can be annotated as throws and async.
|
||||||
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
|
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
|
||||||
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
|
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPerformanceExample() throws {
|
func testPerformanceExample() throws {
|
||||||
// This is an example of a performance test case.
|
// This is an example of a performance test case.
|
||||||
self.measure {
|
self.measure {
|
||||||
// Put the code you want to measure the time of here.
|
// Put the code you want to measure the time of here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,33 +9,33 @@ import XCTest
|
|||||||
|
|
||||||
final class BrewerUITests: XCTestCase {
|
final class BrewerUITests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||||
|
|
||||||
// In UI tests it is usually best to stop immediately when a failure occurs.
|
// In UI tests it is usually best to stop immediately when a failure occurs.
|
||||||
continueAfterFailure = false
|
continueAfterFailure = false
|
||||||
|
|
||||||
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
|
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tearDownWithError() throws {
|
override func tearDownWithError() throws {
|
||||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExample() throws {
|
func testExample() throws {
|
||||||
// UI tests must launch the application that they test.
|
// UI tests must launch the application that they test.
|
||||||
let app = XCUIApplication()
|
let app = XCUIApplication()
|
||||||
app.launch()
|
app.launch()
|
||||||
|
|
||||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLaunchPerformance() throws {
|
func testLaunchPerformance() throws {
|
||||||
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
|
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
|
||||||
// This measures how long it takes to launch your application.
|
// This measures how long it takes to launch your application.
|
||||||
measure(metrics: [XCTApplicationLaunchMetric()]) {
|
measure(metrics: [XCTApplicationLaunchMetric()]) {
|
||||||
XCUIApplication().launch()
|
XCUIApplication().launch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,24 +9,24 @@ import XCTest
|
|||||||
|
|
||||||
final class BrewerUITestsLaunchTests: XCTestCase {
|
final class BrewerUITestsLaunchTests: XCTestCase {
|
||||||
|
|
||||||
override class var runsForEachTargetApplicationUIConfiguration: Bool {
|
override class var runsForEachTargetApplicationUIConfiguration: Bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
continueAfterFailure = false
|
continueAfterFailure = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLaunch() throws {
|
func testLaunch() throws {
|
||||||
let app = XCUIApplication()
|
let app = XCUIApplication()
|
||||||
app.launch()
|
app.launch()
|
||||||
|
|
||||||
// Insert steps here to perform after app launch but before taking a screenshot,
|
// Insert steps here to perform after app launch but before taking a screenshot,
|
||||||
// such as logging into a test account or navigating somewhere in the app
|
// such as logging into a test account or navigating somewhere in the app
|
||||||
|
|
||||||
let attachment = XCTAttachment(screenshot: app.screenshot())
|
let attachment = XCTAttachment(screenshot: app.screenshot())
|
||||||
attachment.name = "Launch Screen"
|
attachment.name = "Launch Screen"
|
||||||
attachment.lifetime = .keepAlways
|
attachment.lifetime = .keepAlways
|
||||||
add(attachment)
|
add(attachment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user