1 Commits

Author SHA1 Message Date
cdricms
6f651f7cad Release of version v0.1.1-beta
Better reactivity and functionality

Formatting

Formatting

Added quit button, and fixed WindowGroup showing up
2024-07-09 22:26:01 +02:00
14 changed files with 641 additions and 513 deletions

69
.swift-format Normal file
View 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
}

View File

@@ -469,21 +469,24 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Brewer/Brewer.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = "0.1.1-beta";
DEVELOPMENT_ASSET_PATHS = "\"Brewer/Preview Content\"";
DEVELOPMENT_TEAM = 96S93Z7LTG;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = Brewer;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = "0.1.1-beta";
PRODUCT_BUNDLE_IDENTIFIER = dev.cems.Brewer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -497,21 +500,24 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Brewer/Brewer.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = "0.1.1-beta";
DEVELOPMENT_ASSET_PATHS = "\"Brewer/Preview Content\"";
DEVELOPMENT_TEAM = 96S93Z7LTG;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = Brewer;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = "0.1.1-beta";
PRODUCT_BUNDLE_IDENTIFIER = dev.cems.Brewer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;

View File

@@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:">
location = "self:/Volumes/Data/Projects/Brewer/Brewer.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -12,8 +12,11 @@ struct BrewerApp: App {
@AppStorage("isUpToDate") var isUpToDate: Bool = true
init() {
do {
let res = try shell("/opt/homebrew/bin/brew outdated --greedy-latest -g | wc -l")
if let number = Int(res.trimmingCharacters(in: .whitespacesAndNewlines)), number > 0 {
let res = try shell(
"/opt/homebrew/bin/brew outdated --greedy-latest -g | wc -l")
if let number = Int(
res.trimmingCharacters(in: .whitespacesAndNewlines)), number > 0
{
isUpToDate = false
}
} catch {
@@ -22,11 +25,24 @@ struct BrewerApp: App {
}
var body: some Scene {
WindowGroup {
EmptyView()
}
MenuBarExtra {
ContentView().padding()
VStack(spacing: 0) {
ContentView()
.padding()
.padding(.bottom, 0)
Button {
NSApplication.shared.terminate(self)
} label: {
Label("Quit", systemImage: "x")
.symbolRenderingMode(.palette)
.symbolVariant(.circle)
.symbolVariant(.fill)
.foregroundStyle(.white, .red)
}
.frame(maxWidth: .infinity, alignment: .trailing)
.padding()
.padding(.top, 0)
}
} label: {
if isUpToDate {
Label("Brewer", systemImage: "sparkle.magnifyingglass")
@@ -37,6 +53,9 @@ struct BrewerApp: App {
}
}
.menuBarExtraStyle(.window)
WindowGroup {
EmptyView()
}
}
}

View File

@@ -29,7 +29,8 @@ struct CaskDetailView: View {
}
if cask.installed != nil {
ToolbarItem(placement: .primaryAction) {
UninstallButton(name: cask.fullToken, brewListing: brewListing)
UninstallButton(
name: cask.fullToken, brewListing: brewListing)
}
}
}

View File

@@ -19,7 +19,8 @@ struct InstalledView: View {
Section {
ForEach(data.casks, id: \.fullToken) { cask in
NavigationLink {
CaskDetailView(cask: cask, brewListing: brew)
CaskDetailView(
cask: cask, brewListing: brew)
} label: {
HStack {
Text(cask.name.first ?? cask.fullToken)
@@ -28,16 +29,23 @@ struct InstalledView: View {
Button {
} label: {
Label("Update", systemImage: "arrow.counterclockwise.circle.fill")
Label(
"Update",
systemImage:
"arrow.counterclockwise.circle.fill"
)
.symbolRenderingMode(.palette)
.foregroundStyle(.white, .orange)
.foregroundStyle(
.white, .orange)
}
} else {
Text(cask.version)
}
}
.contextMenu {
UninstallButton(name: cask.fullToken, brewListing: brew)
UninstallButton(
name: cask.fullToken,
brewListing: brew)
}
}
}
@@ -60,7 +68,11 @@ struct InstalledView: View {
Button {
} label: {
Label("Update", systemImage: "arrow.counterclockwise.circle.fill")
Label(
"Update",
systemImage:
"arrow.counterclockwise.circle.fill"
)
.symbolRenderingMode(.palette)
.foregroundStyle(.white, .orange)
}
@@ -69,7 +81,9 @@ struct InstalledView: View {
}
}
.contextMenu {
UninstallButton(name: formulae.fullName, brewListing: brew)
UninstallButton(
name: formulae.fullName,
brewListing: brew)
}
}
} header: {
@@ -82,13 +96,18 @@ struct InstalledView: View {
}
}
.listStyle(.inset(alternatesRowBackgrounds: true))
let areOutdated = data.casks.map(\.outdated).count + data.formulae.map(\.outdated).count
let _ = UserDefaults.standard.set(!(areOutdated > 0), forKey: "isUpToDate")
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")
Label(
"Update all",
systemImage: "arrow.counterclockwise.circle.fill")
}
.buttonStyle(.borderedProminent)
.tint(.orange)

View File

@@ -111,9 +111,11 @@ class Homebrew {
self.data = nil
Task { [weak self] in
do {
let res = try shell("/opt/homebrew/bin/brew info --json=v2 \(query)")
let res = try shell(
"/opt/homebrew/bin/brew info --json=v2 \(query)")
if let data = res.data(using: .utf8) {
let output = try JSONDecoder().decode(InfoResponse.self, from: data)
let output = try JSONDecoder().decode(
InfoResponse.self, from: data)
self?.data = output
}
} catch {
@@ -129,9 +131,11 @@ class Homebrew {
self.errorMessage = nil
Task { [weak self] in
do {
let res = try shell("/opt/homebrew/bin/brew info --json=v2 --installed")
let res = try shell(
"/opt/homebrew/bin/brew info --json=v2 --installed")
if let data = res.data(using: .utf8) {
let output = try JSONDecoder().decode(InfoResponse.self, from: data)
let output = try JSONDecoder().decode(
InfoResponse.self, from: data)
self?.data = output
}
} catch {
@@ -148,7 +152,9 @@ class Homebrew {
self.data = nil
let task = Task { [weak self] in
do {
let res = try shell("/opt/homebrew/bin/brew list -1 \(name) >/dev/null 2>&1; echo $?")
let res = try shell(
"/opt/homebrew/bin/brew list -1 \(name) >/dev/null 2>&1; echo $?"
)
.trimmingCharacters(in: .whitespacesAndNewlines)
self?.isLoading = false
return res == "0"
@@ -172,7 +178,9 @@ class Homebrew {
self.data = nil
let task = Task { [weak self] in
do {
try shell("/opt/homebrew/bin/brew install \(isCask ? "--cask" : "") \(fullToken)")
try shell(
"/opt/homebrew/bin/brew install \(isCask ? "--cask" : "") \(fullToken)"
)
} catch {
self?.errorMessage = error.localizedDescription
}
@@ -194,7 +202,9 @@ class Homebrew {
let task = Task { [weak self] in
do {
let res =
try shell("/opt/homebrew/bin/brew uninstall \(fullToken); echo $?")
try shell(
"/opt/homebrew/bin/brew uninstall \(fullToken); echo $?"
)
.trimmingCharacters(in: .whitespacesAndNewlines)
} catch {
self?.errorMessage = error.localizedDescription

View File

@@ -30,11 +30,14 @@ struct SearchView: View {
Text(cask.fullToken)
Spacer()
if cask.installed != nil {
Image(systemName: "checkmark.circle.fill")
Image(
systemName: "checkmark.circle.fill"
)
.symbolRenderingMode(.palette)
.foregroundStyle(.white, .green)
} else {
DownloadButton(name: cask.fullToken, isCask: true)
DownloadButton(
name: cask.fullToken, isCask: true)
}
}
}

View File

@@ -6,6 +6,7 @@
//
import XCTest
@testable import Brewer
final class BrewerTests: XCTestCase {