mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-24 22:33:52 +03:00
Adapt code and scripts for Sparkle v2
This commit is contained in:
parent
fff6727a95
commit
69211cc0fd
@ -114,8 +114,8 @@
|
||||
"repositoryURL": "https://github.com/sparkle-project/Sparkle",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "7918c1c8fc68baa37917eeaa67286b077ad5e393",
|
||||
"version": "1.27.1"
|
||||
"revision": "286edd1fa22505a9e54d170e9fd07d775ea233f2",
|
||||
"version": "2.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1417,7 +1417,7 @@
|
||||
repositoryURL = "https://github.com/sparkle-project/Sparkle";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 1.27.1;
|
||||
version = 2.1.0;
|
||||
};
|
||||
};
|
||||
4BD5655124E8014100D52809 /* XCRemoteSwiftPackageReference "swifter" */ = {
|
||||
|
@ -14,6 +14,18 @@ import Sparkle
|
||||
|
||||
let debugMenuItemIdentifier = NSUserInterfaceItemIdentifier("debug-menu-item")
|
||||
|
||||
class UpdaterDelegate: NSObject, SPUUpdaterDelegate {
|
||||
var useSnapshotChannel = false
|
||||
|
||||
func feedURLString(for _: SPUUpdater) -> String? {
|
||||
if self.useSnapshotChannel {
|
||||
return "https://raw.githubusercontent.com/qvacua/vimr/develop/appcast_snapshot.xml"
|
||||
} else {
|
||||
return "https://raw.githubusercontent.com/qvacua/vimr/master/appcast.xml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate {
|
||||
struct OpenConfig {
|
||||
@ -55,7 +67,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
|
||||
self.openNewMainWindowOnLaunch = initialAppState.openNewMainWindowOnLaunch
|
||||
self.openNewMainWindowOnReactivation = initialAppState.openNewMainWindowOnReactivation
|
||||
self.useSnapshot = initialAppState.useSnapshotUpdate
|
||||
self.updaterDelegate.useSnapshotChannel = initialAppState.useSnapshotUpdate
|
||||
|
||||
super.init()
|
||||
|
||||
@ -85,9 +97,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
self.openNewMainWindowOnLaunch = appState.openNewMainWindowOnLaunch
|
||||
self.openNewMainWindowOnReactivation = appState.openNewMainWindowOnReactivation
|
||||
|
||||
if self.useSnapshot != appState.useSnapshotUpdate {
|
||||
self.useSnapshot = appState.useSnapshotUpdate
|
||||
self.setSparkleUrl(self.useSnapshot)
|
||||
if self.updaterDelegate.useSnapshotChannel != appState.useSnapshotUpdate {
|
||||
self.updaterDelegate.useSnapshotChannel = appState.useSnapshotUpdate
|
||||
}
|
||||
|
||||
if appState.quit { NSApp.terminate(self) }
|
||||
@ -105,25 +116,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
|
||||
private var openNewMainWindowOnLaunch: Bool
|
||||
private var openNewMainWindowOnReactivation: Bool
|
||||
private var useSnapshot: Bool
|
||||
|
||||
private let disposeBag = DisposeBag()
|
||||
|
||||
private var launching = true
|
||||
|
||||
private let log = OSLog(subsystem: Defs.loggerSubsystem, category: Defs.LoggerCategory.general)
|
||||
private let updaterDelegate = UpdaterDelegate()
|
||||
|
||||
private func setSparkleUrl(_ snapshot: Bool) {
|
||||
if snapshot {
|
||||
updater.feedURL = URL(
|
||||
string: "https://raw.githubusercontent.com/qvacua/vimr/develop/appcast_snapshot.xml"
|
||||
)
|
||||
} else {
|
||||
updater.feedURL = URL(
|
||||
string: "https://raw.githubusercontent.com/qvacua/vimr/master/appcast.xml"
|
||||
)
|
||||
}
|
||||
}
|
||||
private let log = OSLog(subsystem: Defs.loggerSubsystem, category: Defs.LoggerCategory.general)
|
||||
}
|
||||
|
||||
// MARK: - NSApplicationDelegate
|
||||
@ -144,6 +144,8 @@ extension AppDelegate {
|
||||
func applicationDidFinishLaunching(_: Notification) {
|
||||
self.launching = false
|
||||
|
||||
updaterController.startUpdater()
|
||||
|
||||
#if DEBUG
|
||||
NSApp.mainMenu?.items.first { $0.identifier == debugMenuItemIdentifier }?.isHidden = false
|
||||
#endif
|
||||
@ -215,9 +217,9 @@ extension AppDelegate {
|
||||
)
|
||||
switch self.context.state.openFilesFromApplicationsAction {
|
||||
case .inCurrentWindow:
|
||||
self.emit(.openInKeyWindow(config: config))
|
||||
self.emit(.openInKeyWindow(config: config))
|
||||
default:
|
||||
self.emit(.newMainWindow(config: config))
|
||||
self.emit(.newMainWindow(config: config))
|
||||
}
|
||||
|
||||
sender.reply(toOpenOrPrint: .success)
|
||||
@ -378,10 +380,11 @@ extension AppDelegate {
|
||||
return nil
|
||||
}
|
||||
|
||||
private func queryParam<T>(_ prefix: String,
|
||||
from rawParams: [String],
|
||||
transforming transform: (String) -> T) -> [T]
|
||||
{
|
||||
private func queryParam<T>(
|
||||
_ prefix: String,
|
||||
from rawParams: [String],
|
||||
transforming transform: (String) -> T
|
||||
) -> [T] {
|
||||
rawParams
|
||||
.filter { $0.hasPrefix(prefix) }
|
||||
.compactMap { $0.without(prefix: prefix).removingPercentEncoding }
|
||||
@ -393,7 +396,7 @@ extension AppDelegate {
|
||||
|
||||
extension AppDelegate {
|
||||
@IBAction func checkForUpdates(_ sender: Any?) {
|
||||
updater.checkForUpdates(sender)
|
||||
updaterController.checkForUpdates(sender)
|
||||
}
|
||||
|
||||
@IBAction func newDocument(_: Any?) {
|
||||
@ -444,7 +447,11 @@ private enum VimRUrlAction: String {
|
||||
case nvim
|
||||
}
|
||||
|
||||
private let updater = SUUpdater()
|
||||
private let updaterController = SPUStandardUpdaterController(
|
||||
startingUpdater: false,
|
||||
updaterDelegate: nil,
|
||||
userDriverDelegate: nil
|
||||
)
|
||||
|
||||
// Keep in sync with QueryParamKey in the `vimr` Python script.
|
||||
private let filePrefix = "file="
|
||||
|
@ -4,6 +4,13 @@ set -Eeuo pipefail
|
||||
readonly vimr_app_path=${vimr_app_path:?"Path to VimR.app"}
|
||||
readonly identity="Developer ID Application: Tae Won Ha (H96Q2NKTQH)"
|
||||
|
||||
remove_sparkle_xpc () {
|
||||
# VimR is not sandboxed, so, remove the XPCs
|
||||
# https://sparkle-project.org/documentation/sandboxing/#removing-xpc-services
|
||||
rm -rf "${vimr_app_path}/Contents/Frameworks/Sparkle.framework/Versions/B/XPCServices/org.sparkle-project.InstallerLauncher.xpc"
|
||||
rm -rf "${vimr_app_path}/Contents/Frameworks/Sparkle.framework/Versions/B/XPCServices/org.sparkle-project.Downloader.xpc"
|
||||
}
|
||||
|
||||
main () {
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null
|
||||
echo "### Signing VimR"
|
||||
@ -11,10 +18,16 @@ main () {
|
||||
entitlements_path=$(realpath ./Carthage/Build/Mac/NvimServer/NvimServer.entitlements)
|
||||
readonly entitlements_path
|
||||
|
||||
codesign --verbose --force -s "${identity}" --deep --timestamp --options=runtime \
|
||||
"${vimr_app_path}/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/Autoupdate.app"
|
||||
remove_sparkle_xpc
|
||||
|
||||
codesign --verbose --force -s "${identity}" --timestamp --options=runtime \
|
||||
"${vimr_app_path}/Contents/Frameworks/Sparkle.framework/Versions/A"
|
||||
"${vimr_app_path}/Contents/Frameworks/Sparkle.framework/Versions/B/Autoupdate"
|
||||
|
||||
codesign --verbose --force -s "${identity}" --deep --timestamp --options=runtime \
|
||||
"${vimr_app_path}/Contents/Frameworks/Sparkle.framework/Versions/B/Updater.app"
|
||||
|
||||
codesign --verbose --force -s "${identity}" --options=runtime \
|
||||
"${vimr_app_path}/Contents/Frameworks/Sparkle.framework"
|
||||
|
||||
codesign --verbose --force -s "${identity}" --timestamp --options=runtime \
|
||||
--entitlements="${entitlements_path}" \
|
||||
|
Loading…
Reference in New Issue
Block a user