-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9614c7
commit ee0fdb5
Showing
5 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
// | ||
// UpdateController.swift | ||
// UpdaterStuff.swift | ||
// Splitter | ||
// | ||
// Created by Michael Berk on 11/9/22. | ||
// Copyright © 2022 Michael Berk. All rights reserved. | ||
// Created by Michael Berk on 2/14/23. | ||
// Copyright © 2023 Michael Berk. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Defaults | ||
import BasicUpdater | ||
|
||
class UpdateController:NSObject { | ||
static let shared = UpdateController() | ||
|
||
let updater = Updater(projectURL: URL(string: "https://github.com/michaeljberk/Splitter"), shouldUpdateTo: { release in | ||
let regexStr = #"\d*$"# | ||
let tag = release.tagName | ||
let range = tag.range(of: regexStr, options: .regularExpression)! | ||
let newBuildStr = String(tag[range]) | ||
let newBuildNum = Int(newBuildStr)! | ||
let currentBuildStr = Bundle.main.infoDictionary?["CFBundleVersion"] as! String | ||
let currentBuildNum = Int(currentBuildStr)! | ||
return newBuildNum > currentBuildNum | ||
}) | ||
|
||
@objc func checkForUpdates() { | ||
updater.checkForUpdates() | ||
} | ||
|
||
func addUpdateCommand() { | ||
let settingsItem = NSApp.mainMenu!.item(withIdentifier: menuIdentifiers.appMenu.settingsMenuItem)! | ||
let appMenu = NSApp.mainMenu!.items[0].submenu! | ||
let settingsIndex = appMenu.index(of: settingsItem) | ||
let updateItem = NSMenuItem(title: "Check for Updates...", action: #selector(checkForUpdates), keyEquivalent: "") | ||
updateItem.target = self | ||
appMenu.insertItem(updateItem, at: settingsIndex + 1) | ||
} | ||
} |