Compare commits
1 Commits
c675a98309
...
beta-relea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
daae01b05c |
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,8 +12,11 @@ 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")
|
||||||
|
if let number = Int(
|
||||||
|
res.trimmingCharacters(in: .whitespacesAndNewlines)), number > 0
|
||||||
|
{
|
||||||
isUpToDate = false
|
isUpToDate = false
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ struct CaskDetailView: View {
|
|||||||
}
|
}
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ struct InstalledView: View {
|
|||||||
Section {
|
Section {
|
||||||
ForEach(data.casks, id: \.fullToken) { cask in
|
ForEach(data.casks, id: \.fullToken) { cask in
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
CaskDetailView(cask: cask, brewListing: brew)
|
CaskDetailView(
|
||||||
|
cask: cask, brewListing: brew)
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
HStack {
|
||||||
Text(cask.name.first ?? cask.fullToken)
|
Text(cask.name.first ?? cask.fullToken)
|
||||||
@@ -28,16 +29,23 @@ struct InstalledView: View {
|
|||||||
Button {
|
Button {
|
||||||
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Update", systemImage: "arrow.counterclockwise.circle.fill")
|
Label(
|
||||||
|
"Update",
|
||||||
|
systemImage:
|
||||||
|
"arrow.counterclockwise.circle.fill"
|
||||||
|
)
|
||||||
.symbolRenderingMode(.palette)
|
.symbolRenderingMode(.palette)
|
||||||
.foregroundStyle(.white, .orange)
|
.foregroundStyle(
|
||||||
|
.white, .orange)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Text(cask.version)
|
Text(cask.version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
UninstallButton(name: cask.fullToken, brewListing: brew)
|
UninstallButton(
|
||||||
|
name: cask.fullToken,
|
||||||
|
brewListing: brew)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +68,11 @@ struct InstalledView: View {
|
|||||||
Button {
|
Button {
|
||||||
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Update", systemImage: "arrow.counterclockwise.circle.fill")
|
Label(
|
||||||
|
"Update",
|
||||||
|
systemImage:
|
||||||
|
"arrow.counterclockwise.circle.fill"
|
||||||
|
)
|
||||||
.symbolRenderingMode(.palette)
|
.symbolRenderingMode(.palette)
|
||||||
.foregroundStyle(.white, .orange)
|
.foregroundStyle(.white, .orange)
|
||||||
}
|
}
|
||||||
@@ -69,7 +81,9 @@ struct InstalledView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
UninstallButton(name: formulae.fullName, brewListing: brew)
|
UninstallButton(
|
||||||
|
name: formulae.fullName,
|
||||||
|
brewListing: brew)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} header: {
|
} header: {
|
||||||
@@ -82,13 +96,18 @@ struct InstalledView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.listStyle(.inset(alternatesRowBackgrounds: true))
|
.listStyle(.inset(alternatesRowBackgrounds: true))
|
||||||
let areOutdated = data.casks.map(\.outdated).count + data.formulae.map(\.outdated).count
|
let areOutdated =
|
||||||
let _ = UserDefaults.standard.set(!(areOutdated > 0), forKey: "isUpToDate")
|
data.casks.map(\.outdated).count
|
||||||
|
+ data.formulae.map(\.outdated).count
|
||||||
|
let _ = UserDefaults.standard.set(
|
||||||
|
!(areOutdated > 0), forKey: "isUpToDate")
|
||||||
if areOutdated > 0 {
|
if areOutdated > 0 {
|
||||||
Button {
|
Button {
|
||||||
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Update all", systemImage: "arrow.counterclockwise.circle.fill")
|
Label(
|
||||||
|
"Update all",
|
||||||
|
systemImage: "arrow.counterclockwise.circle.fill")
|
||||||
}
|
}
|
||||||
.buttonStyle(.borderedProminent)
|
.buttonStyle(.borderedProminent)
|
||||||
.tint(.orange)
|
.tint(.orange)
|
||||||
|
|||||||
@@ -111,9 +111,11 @@ class Homebrew {
|
|||||||
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(
|
||||||
|
"/opt/homebrew/bin/brew info --json=v2 \(query)")
|
||||||
if let data = res.data(using: .utf8) {
|
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
|
self?.data = output
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -129,9 +131,11 @@ class Homebrew {
|
|||||||
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(
|
||||||
|
"/opt/homebrew/bin/brew info --json=v2 --installed")
|
||||||
if let data = res.data(using: .utf8) {
|
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
|
self?.data = output
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -148,7 +152,9 @@ class Homebrew {
|
|||||||
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(
|
||||||
|
"/opt/homebrew/bin/brew list -1 \(name) >/dev/null 2>&1; echo $?"
|
||||||
|
)
|
||||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
self?.isLoading = false
|
self?.isLoading = false
|
||||||
return res == "0"
|
return res == "0"
|
||||||
@@ -172,7 +178,9 @@ class Homebrew {
|
|||||||
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(
|
||||||
|
"/opt/homebrew/bin/brew install \(isCask ? "--cask" : "") \(fullToken)"
|
||||||
|
)
|
||||||
} catch {
|
} catch {
|
||||||
self?.errorMessage = error.localizedDescription
|
self?.errorMessage = error.localizedDescription
|
||||||
}
|
}
|
||||||
@@ -194,7 +202,9 @@ class Homebrew {
|
|||||||
let task = Task { [weak self] in
|
let task = Task { [weak self] in
|
||||||
do {
|
do {
|
||||||
let res =
|
let res =
|
||||||
try shell("/opt/homebrew/bin/brew uninstall \(fullToken); echo $?")
|
try shell(
|
||||||
|
"/opt/homebrew/bin/brew uninstall \(fullToken); echo $?"
|
||||||
|
)
|
||||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
} catch {
|
} catch {
|
||||||
self?.errorMessage = error.localizedDescription
|
self?.errorMessage = error.localizedDescription
|
||||||
|
|||||||
@@ -30,11 +30,14 @@ struct SearchView: View {
|
|||||||
Text(cask.fullToken)
|
Text(cask.fullToken)
|
||||||
Spacer()
|
Spacer()
|
||||||
if cask.installed != nil {
|
if cask.installed != nil {
|
||||||
Image(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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
@testable import Brewer
|
@testable import Brewer
|
||||||
|
|
||||||
final class BrewerTests: XCTestCase {
|
final class BrewerTests: XCTestCase {
|
||||||
|
|||||||
Reference in New Issue
Block a user