mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗 Read release manifest
This commit is contained in:
@ -51,7 +51,7 @@
|
|||||||
C4068CAB27B0890D00544CD5 /* MenuBarIcons.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4068CA927B0890D00544CD5 /* MenuBarIcons.swift */; };
|
C4068CAB27B0890D00544CD5 /* MenuBarIcons.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4068CA927B0890D00544CD5 /* MenuBarIcons.swift */; };
|
||||||
C406A5F3298AD2CE00B5B85A /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = C406A5F2298AD2CE00B5B85A /* main.swift */; };
|
C406A5F3298AD2CE00B5B85A /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = C406A5F2298AD2CE00B5B85A /* main.swift */; };
|
||||||
C406A5F7298AD2CF00B5B85A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C406A5F6298AD2CF00B5B85A /* Assets.xcassets */; };
|
C406A5F7298AD2CF00B5B85A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C406A5F6298AD2CF00B5B85A /* Assets.xcassets */; };
|
||||||
C406A602298AD50D00B5B85A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C406A601298AD50D00B5B85A /* AppDelegate.swift */; };
|
C406A602298AD50D00B5B85A /* Updater.swift in Sources */ = {isa = PBXBuildFile; fileRef = C406A601298AD50D00B5B85A /* Updater.swift */; };
|
||||||
C4080FF627BD8C6400BF2C6B /* BetterAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4080FF527BD8C6400BF2C6B /* BetterAlert.swift */; };
|
C4080FF627BD8C6400BF2C6B /* BetterAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4080FF527BD8C6400BF2C6B /* BetterAlert.swift */; };
|
||||||
C4080FF727BD8C6400BF2C6B /* BetterAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4080FF527BD8C6400BF2C6B /* BetterAlert.swift */; };
|
C4080FF727BD8C6400BF2C6B /* BetterAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4080FF527BD8C6400BF2C6B /* BetterAlert.swift */; };
|
||||||
C4080FFA27BD956700BF2C6B /* BetterAlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4080FF927BD956700BF2C6B /* BetterAlertVC.swift */; };
|
C4080FFA27BD956700BF2C6B /* BetterAlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4080FF927BD956700BF2C6B /* BetterAlertVC.swift */; };
|
||||||
@ -190,6 +190,8 @@
|
|||||||
C469E700294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; };
|
C469E700294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; };
|
||||||
C469E701294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; };
|
C469E701294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; };
|
||||||
C469E706294CFDF700A82AB2 /* DomainsListTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E702294CFDF700A82AB2 /* DomainsListTest.swift */; };
|
C469E706294CFDF700A82AB2 /* DomainsListTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E702294CFDF700A82AB2 /* DomainsListTest.swift */; };
|
||||||
|
C46B2648298B324100084651 /* ReleaseManifest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46B2647298B324100084651 /* ReleaseManifest.swift */; };
|
||||||
|
C46B2649298B324100084651 /* ReleaseManifest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46B2647298B324100084651 /* ReleaseManifest.swift */; };
|
||||||
C46E206D28299B3800D909D6 /* AppUpdateChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */; };
|
C46E206D28299B3800D909D6 /* AppUpdateChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */; };
|
||||||
C46E206E28299B3800D909D6 /* AppUpdateChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */; };
|
C46E206E28299B3800D909D6 /* AppUpdateChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */; };
|
||||||
C46E20702829D27F00D909D6 /* AppUpdaterCheckTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206F2829D27F00D909D6 /* AppUpdaterCheckTest.swift */; };
|
C46E20702829D27F00D909D6 /* AppUpdaterCheckTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206F2829D27F00D909D6 /* AppUpdaterCheckTest.swift */; };
|
||||||
@ -765,7 +767,7 @@
|
|||||||
C406A5F2298AD2CE00B5B85A /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
|
C406A5F2298AD2CE00B5B85A /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
|
||||||
C406A5F6298AD2CF00B5B85A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
C406A5F6298AD2CF00B5B85A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
C406A5FB298AD2CF00B5B85A /* phpmon-updater.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "phpmon-updater.entitlements"; sourceTree = "<group>"; };
|
C406A5FB298AD2CF00B5B85A /* phpmon-updater.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "phpmon-updater.entitlements"; sourceTree = "<group>"; };
|
||||||
C406A601298AD50D00B5B85A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
C406A601298AD50D00B5B85A /* Updater.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Updater.swift; sourceTree = "<group>"; };
|
||||||
C4080FF527BD8C6400BF2C6B /* BetterAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetterAlert.swift; sourceTree = "<group>"; };
|
C4080FF527BD8C6400BF2C6B /* BetterAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetterAlert.swift; sourceTree = "<group>"; };
|
||||||
C4080FF927BD956700BF2C6B /* BetterAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetterAlertVC.swift; sourceTree = "<group>"; };
|
C4080FF927BD956700BF2C6B /* BetterAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BetterAlertVC.swift; sourceTree = "<group>"; };
|
||||||
C40C5C9B2846A40600E28255 /* Preset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preset.swift; sourceTree = "<group>"; };
|
C40C5C9B2846A40600E28255 /* Preset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preset.swift; sourceTree = "<group>"; };
|
||||||
@ -847,6 +849,7 @@
|
|||||||
C464ADB1275A87CA003FCD53 /* DomainListCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListCellProtocol.swift; sourceTree = "<group>"; };
|
C464ADB1275A87CA003FCD53 /* DomainListCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListCellProtocol.swift; sourceTree = "<group>"; };
|
||||||
C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeValetProxy.swift; sourceTree = "<group>"; };
|
C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeValetProxy.swift; sourceTree = "<group>"; };
|
||||||
C469E702294CFDF700A82AB2 /* DomainsListTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DomainsListTest.swift; sourceTree = "<group>"; };
|
C469E702294CFDF700A82AB2 /* DomainsListTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DomainsListTest.swift; sourceTree = "<group>"; };
|
||||||
|
C46B2647298B324100084651 /* ReleaseManifest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseManifest.swift; sourceTree = "<group>"; };
|
||||||
C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUpdateChecker.swift; sourceTree = "<group>"; };
|
C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUpdateChecker.swift; sourceTree = "<group>"; };
|
||||||
C46E206F2829D27F00D909D6 /* AppUpdaterCheckTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppUpdaterCheckTest.swift; sourceTree = "<group>"; };
|
C46E206F2829D27F00D909D6 /* AppUpdaterCheckTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppUpdaterCheckTest.swift; sourceTree = "<group>"; };
|
||||||
C46EBC4328DB95F0007ACC74 /* ShellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellProtocol.swift; sourceTree = "<group>"; };
|
C46EBC4328DB95F0007ACC74 /* ShellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellProtocol.swift; sourceTree = "<group>"; };
|
||||||
@ -1100,7 +1103,8 @@
|
|||||||
C406A5F1298AD2CE00B5B85A /* phpmon-updater */ = {
|
C406A5F1298AD2CE00B5B85A /* phpmon-updater */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
C406A601298AD50D00B5B85A /* AppDelegate.swift */,
|
C406A601298AD50D00B5B85A /* Updater.swift */,
|
||||||
|
C46B2647298B324100084651 /* ReleaseManifest.swift */,
|
||||||
C406A5F2298AD2CE00B5B85A /* main.swift */,
|
C406A5F2298AD2CE00B5B85A /* main.swift */,
|
||||||
C406A5F6298AD2CF00B5B85A /* Assets.xcassets */,
|
C406A5F6298AD2CF00B5B85A /* Assets.xcassets */,
|
||||||
C406A5FB298AD2CF00B5B85A /* phpmon-updater.entitlements */,
|
C406A5FB298AD2CF00B5B85A /* phpmon-updater.entitlements */,
|
||||||
@ -2056,7 +2060,8 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
C406A602298AD50D00B5B85A /* AppDelegate.swift in Sources */,
|
C406A602298AD50D00B5B85A /* Updater.swift in Sources */,
|
||||||
|
C46B2649298B324100084651 /* ReleaseManifest.swift in Sources */,
|
||||||
C41F3D08298AED0D0042ACBF /* System.swift in Sources */,
|
C41F3D08298AED0D0042ACBF /* System.swift in Sources */,
|
||||||
C406A5F3298AD2CE00B5B85A /* main.swift in Sources */,
|
C406A5F3298AD2CE00B5B85A /* main.swift in Sources */,
|
||||||
);
|
);
|
||||||
@ -2201,6 +2206,7 @@
|
|||||||
C4D9ADC8277611A0007277F4 /* InternalSwitcher.swift in Sources */,
|
C4D9ADC8277611A0007277F4 /* InternalSwitcher.swift in Sources */,
|
||||||
C4FACE83288F1F9700FC478F /* OnboardingWindowController.swift in Sources */,
|
C4FACE83288F1F9700FC478F /* OnboardingWindowController.swift in Sources */,
|
||||||
C4080FFA27BD956700BF2C6B /* BetterAlertVC.swift in Sources */,
|
C4080FFA27BD956700BF2C6B /* BetterAlertVC.swift in Sources */,
|
||||||
|
C46B2648298B324100084651 /* ReleaseManifest.swift in Sources */,
|
||||||
C4BF56AB2949381100379603 /* FakeValetInteractor.swift in Sources */,
|
C4BF56AB2949381100379603 /* FakeValetInteractor.swift in Sources */,
|
||||||
C4B5635E276AB09000F12CCB /* VersionExtractor.swift in Sources */,
|
C4B5635E276AB09000F12CCB /* VersionExtractor.swift in Sources */,
|
||||||
C451AFF62969E40F0078E617 /* HelpButton.swift in Sources */,
|
C451AFF62969E40F0078E617 /* HelpButton.swift in Sources */,
|
||||||
|
14
phpmon-updater/ReleaseManifest.swift
Normal file
14
phpmon-updater/ReleaseManifest.swift
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// UpdateManifest.swift
|
||||||
|
// PHP Monitor
|
||||||
|
//
|
||||||
|
// Created by Nico Verbruggen on 02/02/2023.
|
||||||
|
// Copyright © 2023 Nico Verbruggen. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct ReleaseManifest: Codable {
|
||||||
|
let url: String
|
||||||
|
let sha256: String
|
||||||
|
}
|
@ -8,9 +8,10 @@
|
|||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class Updater: NSObject, NSApplicationDelegate {
|
||||||
|
|
||||||
var updaterDirectory: String = ""
|
var updaterDirectory: String = ""
|
||||||
|
var manifest: ReleaseManifest! = nil
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
|
|
||||||
@ -19,16 +20,25 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
self.updaterDirectory = "~/.config/phpmon/updater"
|
self.updaterDirectory = "~/.config/phpmon/updater"
|
||||||
.replacingOccurrences(of: "~", with: NSHomeDirectory())
|
.replacingOccurrences(of: "~", with: NSHomeDirectory())
|
||||||
|
|
||||||
|
let manifestPath = "\(updaterDirectory)/update.json"
|
||||||
|
|
||||||
|
// Read out the correct information from the manifest JSON
|
||||||
|
do {
|
||||||
|
let manifestText = try String(contentsOfFile: manifestPath)
|
||||||
|
manifest = try JSONDecoder().decode(ReleaseManifest.self, from: manifestText.data(using: .utf8)!)
|
||||||
|
} catch {
|
||||||
|
print("Parsing the manifest failed (or the manifest file doesn't exist)")
|
||||||
|
showAlert(
|
||||||
|
title: "Key information about the update is missing",
|
||||||
|
description: "The self-updater only works in combination with PHP Monitor. Please try searching for updates again in PHP Monitor. The app has not been updated."
|
||||||
|
)
|
||||||
|
exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
print("Updater directory set to: \(self.updaterDirectory)")
|
print("Updater directory set to: \(self.updaterDirectory)")
|
||||||
|
|
||||||
// Download the latest file
|
// Download the latest file
|
||||||
let zipPath = self.download(
|
let zipPath = self.download(manifest)
|
||||||
// zipUrl: "https://github.com/nicoverbruggen/phpmon/releases/download/v5.7.2/phpmon.zip",
|
|
||||||
// sha256: "654dd1df64ae32b1e3b9ebed7f6d89d04ed374b0b4d6732704e6df190169214f"
|
|
||||||
|
|
||||||
zipUrl: "https://github.com/nicoverbruggen/phpmon/releases/download/v5.7.2/phpmon-dev.zip",
|
|
||||||
sha256: "1cb147bd1b1fbd52971d90dff577465b644aee7c878f15ede57f46e8f217067a"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Terminating all instances of PHP Monitor first
|
// Terminating all instances of PHP Monitor first
|
||||||
terminatePhpMon()
|
terminatePhpMon()
|
||||||
@ -48,12 +58,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private func download(zipUrl: String, sha256: String) -> String {
|
private func download(_ manifest: ReleaseManifest) -> String {
|
||||||
// Remove all zips
|
// Remove all zips
|
||||||
system_quiet("rm -rf \(updaterDirectory)/*.zip")
|
system_quiet("rm -rf \(updaterDirectory)/*.zip")
|
||||||
|
|
||||||
// Download the file (and follow redirects + no output on failure)
|
// Download the file (and follow redirects + no output on failure)
|
||||||
system_quiet("cd \(updaterDirectory) && curl \(zipUrl) -fLO")
|
system_quiet("cd \(updaterDirectory) && curl \(manifest.url) -fLO")
|
||||||
|
|
||||||
// Identify the downloaded file
|
// Identify the downloaded file
|
||||||
let filename = system("cd \(updaterDirectory) && ls | grep .zip")
|
let filename = system("cd \(updaterDirectory) && ls | grep .zip")
|
||||||
@ -61,20 +71,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
|
|
||||||
if filename.isEmpty {
|
if filename.isEmpty {
|
||||||
print("The update has not been downloaded. Sadly, that means that PHP Monitor cannot not updated!")
|
print("The update has not been downloaded. Sadly, that means that PHP Monitor cannot not updated!")
|
||||||
|
|
||||||
showAlert(title: "The update was not downloaded.",
|
showAlert(title: "The update was not downloaded.",
|
||||||
description: "PHP Monitor will not be updated, but we will restart the app for you. You may not be connected to the internet or the server may be encountering issues. Please try again later!")
|
description: "PHP Monitor has not been updated. You may not be connected to the internet or the server may be encountering issues, or the file could not be written to disk. Please try again later!")
|
||||||
|
|
||||||
if FileManager.default.fileExists(atPath: "/Applications/PHP Monitor.app") {
|
|
||||||
restartPhpMon(dev: false)
|
|
||||||
}
|
|
||||||
else if FileManager.default.fileExists(atPath: "/Applications/PHP Monitor DEV.app") {
|
|
||||||
restartPhpMon(dev: true)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate the checksum for the downloaded file
|
// Calculate the checksum for the downloaded file
|
||||||
let checksum = system("openssl dgst -sha256 \(updaterDirectory)/\(filename) | awk '{print $NF}'")
|
let checksum = system("openssl dgst -sha256 \(updaterDirectory)/\(filename) | awk '{print $NF}'")
|
||||||
@ -82,12 +82,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
|
|
||||||
print("""
|
print("""
|
||||||
Comparing checksums...
|
Comparing checksums...
|
||||||
Expected SHA256: \(sha256)
|
Expected SHA256: \(manifest.sha256)
|
||||||
Actual SHA256: \(checksum)
|
Actual SHA256: \(checksum)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
// Make sure the checksum matches before we do anything with the file
|
// Make sure the checksum matches before we do anything with the file
|
||||||
if checksum != sha256 {
|
if checksum != manifest.sha256 {
|
||||||
print("The checksums failed to match. Cancelling!")
|
print("The checksums failed to match. Cancelling!")
|
||||||
showAlert(
|
showAlert(
|
||||||
title: "The downloaded update failed checksum validation",
|
title: "The downloaded update failed checksum validation",
|
||||||
@ -100,11 +100,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func install(zipPath: String) {
|
private func install(zipPath: String) {
|
||||||
system_quiet("rm -rf \(updaterDirectory)/output")
|
system_quiet("rm -rf \(updaterDirectory)/extracted")
|
||||||
system_quiet("mkdir -p \(updaterDirectory)/output")
|
system_quiet("mkdir -p \(updaterDirectory)/extracted")
|
||||||
|
|
||||||
var isDirectory: ObjCBool = true
|
var isDirectory: ObjCBool = true
|
||||||
if !FileManager.default.fileExists(atPath: "\(updaterDirectory)/output", isDirectory: &isDirectory) {
|
if !FileManager.default.fileExists(atPath: "\(updaterDirectory)/extracted", isDirectory: &isDirectory) {
|
||||||
showAlert(
|
showAlert(
|
||||||
title: "The updater directory is missing",
|
title: "The updater directory is missing",
|
||||||
description: "The automatic updater will quit. Make sure that ` ~/.config/phpmon/updater` is writeable."
|
description: "The automatic updater will quit. Make sure that ` ~/.config/phpmon/updater` is writeable."
|
||||||
@ -112,7 +112,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
system_quiet("unzip \(zipPath) -d \(updaterDirectory)/output")
|
system_quiet("unzip \(zipPath) -d \(updaterDirectory)/extracted")
|
||||||
|
|
||||||
let expectedAppName = zipPath.contains("dev")
|
let expectedAppName = zipPath.contains("dev")
|
||||||
? "PHP Monitor DEV.app"
|
? "PHP Monitor DEV.app"
|
||||||
@ -121,7 +121,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
print("Removing \(expectedAppName) before replacing...")
|
print("Removing \(expectedAppName) before replacing...")
|
||||||
|
|
||||||
system_quiet("rm -rf \"/Applications/\(expectedAppName)\"")
|
system_quiet("rm -rf \"/Applications/\(expectedAppName)\"")
|
||||||
system_quiet("mv \"\(updaterDirectory)/output/\(expectedAppName)\" \"/Applications/\(expectedAppName)\"")
|
system_quiet("mv \"\(updaterDirectory)/extracted/\(expectedAppName)\" \"/Applications/\(expectedAppName)\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
private func terminatePhpMon() {
|
private func terminatePhpMon() {
|
||||||
@ -140,6 +140,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func smartRestartPhpMon() {
|
||||||
|
if FileManager.default.fileExists(atPath: "/Applications/PHP Monitor.app") {
|
||||||
|
restartPhpMon(dev: false)
|
||||||
|
}
|
||||||
|
else if FileManager.default.fileExists(atPath: "/Applications/PHP Monitor DEV.app") {
|
||||||
|
restartPhpMon(dev: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func restartPhpMon(dev: Bool) {
|
private func restartPhpMon(dev: Bool) {
|
||||||
let path = dev ? "/Applications/PHP Monitor DEV.app" : "/Applications/PHP Monitor.app"
|
let path = dev ? "/Applications/PHP Monitor DEV.app" : "/Applications/PHP Monitor.app"
|
||||||
let url = NSURL(fileURLWithPath: path, isDirectory: true) as URL
|
let url = NSURL(fileURLWithPath: path, isDirectory: true) as URL
|
@ -8,10 +8,7 @@
|
|||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
// 1
|
|
||||||
let app = NSApplication.shared
|
let app = NSApplication.shared
|
||||||
let delegate = AppDelegate()
|
let delegate = Updater()
|
||||||
app.delegate = delegate
|
app.delegate = delegate
|
||||||
|
|
||||||
// 2
|
|
||||||
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
|
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
|
||||||
|
Reference in New Issue
Block a user