diff --git a/sm_osx.xcodeproj/project.pbxproj b/sm_osx.xcodeproj/project.pbxproj index 2fd2833..110dcf0 100644 --- a/sm_osx.xcodeproj/project.pbxproj +++ b/sm_osx.xcodeproj/project.pbxproj @@ -415,7 +415,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 10; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; @@ -431,10 +431,11 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.5; + MARKETING_VERSION = 1.3.0.92; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; }; @@ -449,7 +450,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 10; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; @@ -465,10 +466,11 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.5; + MARKETING_VERSION = 1.3.0.92; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; }; diff --git a/sm_osx/FirstLaunchView.swift b/sm_osx/FirstLaunchView.swift index d52b98f..bcc7a8c 100644 --- a/sm_osx/FirstLaunchView.swift +++ b/sm_osx/FirstLaunchView.swift @@ -148,7 +148,7 @@ struct FirstLaunchView: View { Text("Checking Homebrew Installation...") .onAppear { if isArm() { - if !((Shell().shell("which brew"))).contains("/opt/homebrew/bin/brew") { + if !FileManager.default.fileExists(atPath: "/opt/homebrew/bin/brew") { let task = Process() task.launchPath = "/usr/bin/osascript" @@ -161,7 +161,7 @@ struct FirstLaunchView: View { } } } else { - if Shell().shell("which brew").contains("/usr/local/bin/brew") { + if !FileManager.default.fileExists(atPath: "/usr/local/bin/brew") { let task = Process() task.launchPath = "/usr/bin/osascript" @@ -176,13 +176,13 @@ struct FirstLaunchView: View { } }.onReceive(timer) { _ in if isArm() { - if Shell().shell("which brew").contains("/opt/homebrew/bin/brew") { + if FileManager.default.fileExists(atPath: "/opt/homebrew/bin/brew") { withAnimation { status = .checkingIntelHomebrewInstallation } } } else { - if Shell().shell("which brew").contains("/usr/local/bin/brew") { + if FileManager.default.fileExists(atPath: "/usr/local/bin/brew") { withAnimation { status = .installingDeps } @@ -192,7 +192,7 @@ struct FirstLaunchView: View { } else if status == .checkingIntelHomebrewInstallation { Text("Checking Intel Homebrew Installation...") .onAppear { - if Shell().shell("which /usr/local/bin/brew").contains("/usr/local/bin/brew\n") { + if !FileManager.default.fileExists(atPath: "/usr/local/bin/brew") { let task = Process() task.launchPath = "/usr/bin/osascript" @@ -205,7 +205,7 @@ struct FirstLaunchView: View { } } }.onReceive(timer) { _ in - if Shell().shell("which /usr/local/bin/brew").contains("/usr/local/bin/brew\n") { + if FileManager.default.fileExists(atPath: "/usr/local/bin/brew") { withAnimation(.linear(duration: 0.4)) { status = .installingDeps } diff --git a/sm_osx/GeneralView.swift b/sm_osx/GeneralView.swift index 9144cee..cc7b308 100644 --- a/sm_osx/GeneralView.swift +++ b/sm_osx/GeneralView.swift @@ -16,29 +16,30 @@ struct GeneralView: View { let outHandle = pipe.fileHandleForReading outHandle.readabilityHandler = { pipe in - if let line = String(data: pipe.availableData, encoding: String.Encoding.utf8) { - if line.contains("Finished installing deps") { - - withAnimation() { - isInstallingDeps = false + if pipe.availableData.count > 0 { + if let line = String(data: pipe.availableData, encoding: String.Encoding.utf8) { + if line.contains("Finished installing deps") { + + withAnimation() { + isInstallingDeps = false + } + + let content = UNMutableNotificationContent() + content.title = "Finished installing dependencies" + content.subtitle = "Dependencies are now installed." + content.sound = UNNotificationSound.default + + let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false) + + let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) + + UNUserNotificationCenter.current().add(request) } - - let content = UNMutableNotificationContent() - content.title = "Finished installing dependencies" - content.subtitle = "Dependencies are now installed." - content.sound = UNNotificationSound.default - - // show this notification instantly - let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false) - - // choose a random identifier - let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) - - // add our notification request - UNUserNotificationCenter.current().add(request) + } else { + print("Error decoding data. why do I program...: \(pipe.availableData)") } } else { - print("Error decoding data. why do I program...: \(pipe.availableData)") + outHandle.readabilityHandler = nil } } diff --git a/sm_osx/HomebrewInstaller.scpt b/sm_osx/HomebrewInstaller.scpt index 866dddd..bd7f758 100644 Binary files a/sm_osx/HomebrewInstaller.scpt and b/sm_osx/HomebrewInstaller.scpt differ diff --git a/sm_osx/LauncherGridView.swift b/sm_osx/LauncherGridView.swift index 998801f..cc22166 100644 --- a/sm_osx/LauncherGridView.swift +++ b/sm_osx/LauncherGridView.swift @@ -9,6 +9,9 @@ struct LauncherGridView: View { @FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults @Binding var reloadMenuBarLauncher: Bool @Binding var existingRepo: URL? + @State var removeEntireRepo = false + @State var removeRepo = false + @State var item: Int? = nil let layout = [GridItem(.adaptive(minimum: 260))] func launcherShell(_ command: String) { @@ -34,8 +37,13 @@ struct LauncherGridView: View { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } @@ -49,6 +57,7 @@ struct LauncherGridView: View { LazyVGrid(columns: layout) { ForEach(launcherRepos) { LauncherRepo in let i = launcherRepos.firstIndex(of: LauncherRepo) ?? 0 + VStack { Button { @@ -102,26 +111,8 @@ struct LauncherGridView: View { } Button(action: { - - if launcherRepos.isEmpty { return } - - for i in 0...launcherRepos.count - 1 { - launcherRepos[i].isEditing = false - } - - let launcherRepo = launcherRepos[i] - - moc.delete(launcherRepo) - - do { - try withAnimation { - try moc.save() - } - reloadMenuBarLauncher = true - } - catch { - print("Error: its broken: \(error)") - } + item = i + removeRepo = true }) { Text("Remove Repo") } @@ -146,6 +137,67 @@ struct LauncherGridView: View { LauncherEditView(i: i, existingRepo: $existingRepo, reloadMenuBarLauncher: $reloadMenuBarLauncher) } } - }.padding(15) + }.alert("Are You Sure You Want to Remove the Repo?", isPresented: $removeEntireRepo) { + Button("Yes", role: .destructive) { + + if launcherRepos.isEmpty { return } + + let launcherRepo = launcherRepos[item!] + + do { + let path = URL(filePath: (launcherRepo.path!)).deletingLastPathComponent().path() + + Shell().shell("rm -rf \(path)") + } catch { + print("Error, could not delete file due to: \(error)") + } + + moc.delete(launcherRepo) + + do { + try withAnimation { + try moc.save() + } + reloadMenuBarLauncher = true + } catch { + print("Error: its broken: \(error)") + } + + item = nil + } + + Button("No", role: .cancel) {} + } message: { + Text("Make sure there are no important files in that folder!") + } + .padding(15) + .alert("Remove Repo \(launcherRepos[item ?? 0].title ?? "")?", isPresented: $removeRepo) { + Button("Remove Repo", role: .destructive) { + removeEntireRepo = true + } + + Button("Remove Entry", role: .destructive) { + if item != nil { + if launcherRepos.isEmpty { return } + + let launcherRepo = launcherRepos[item!] + + moc.delete(launcherRepo) + + do { + try withAnimation { + try moc.save() + } + reloadMenuBarLauncher = true + } catch { + print("Error: its broken: \(error)") + } + + item = nil + } + } + + Button("Cancel", role: .cancel) {} + } } } diff --git a/sm_osx/LauncherListView.swift b/sm_osx/LauncherListView.swift index 613aad6..e804d0f 100644 --- a/sm_osx/LauncherListView.swift +++ b/sm_osx/LauncherListView.swift @@ -33,8 +33,13 @@ struct LauncherListView: View { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } diff --git a/sm_osx/LauncherView.swift b/sm_osx/LauncherView.swift index f21eeca..4c3f71c 100644 --- a/sm_osx/LauncherView.swift +++ b/sm_osx/LauncherView.swift @@ -49,8 +49,13 @@ struct LauncherView: View { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } diff --git a/sm_osx/MenuCommands.swift b/sm_osx/MenuCommands.swift index e603210..89d5d91 100644 --- a/sm_osx/MenuCommands.swift +++ b/sm_osx/MenuCommands.swift @@ -52,8 +52,13 @@ struct MenuCommands: Commands { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } @@ -186,8 +191,13 @@ struct menuExtras: Scene { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) }