mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗 Working proof-of-concept updater if zip exists
This commit is contained in:
@ -99,6 +99,7 @@
|
|||||||
C41CD0292628D8EE0065BBED /* GlobalKeybindPreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41CD0282628D8EE0065BBED /* GlobalKeybindPreference.swift */; };
|
C41CD0292628D8EE0065BBED /* GlobalKeybindPreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41CD0282628D8EE0065BBED /* GlobalKeybindPreference.swift */; };
|
||||||
C41E871A2763D42300161EE0 /* DomainListVC+ContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41E87192763D42300161EE0 /* DomainListVC+ContextMenu.swift */; };
|
C41E871A2763D42300161EE0 /* DomainListVC+ContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41E87192763D42300161EE0 /* DomainListVC+ContextMenu.swift */; };
|
||||||
C41E871B2763D42300161EE0 /* DomainListVC+ContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41E87192763D42300161EE0 /* DomainListVC+ContextMenu.swift */; };
|
C41E871B2763D42300161EE0 /* DomainListVC+ContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41E87192763D42300161EE0 /* DomainListVC+ContextMenu.swift */; };
|
||||||
|
C41F3D08298AED0D0042ACBF /* System.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D3660A29113F20006BD146 /* System.swift */; };
|
||||||
C4205A7E27F4D21800191A39 /* ValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4205A7D27F4D21800191A39 /* ValetProxy.swift */; };
|
C4205A7E27F4D21800191A39 /* ValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4205A7D27F4D21800191A39 /* ValetProxy.swift */; };
|
||||||
C4205A7F27F4D21800191A39 /* ValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4205A7D27F4D21800191A39 /* ValetProxy.swift */; };
|
C4205A7F27F4D21800191A39 /* ValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4205A7D27F4D21800191A39 /* ValetProxy.swift */; };
|
||||||
C422DDAA28A2C49900CEAC97 /* WarningListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C422DDA928A2C49900CEAC97 /* WarningListView.swift */; };
|
C422DDAA28A2C49900CEAC97 /* WarningListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C422DDA928A2C49900CEAC97 /* WarningListView.swift */; };
|
||||||
@ -2056,6 +2057,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
C406A602298AD50D00B5B85A /* AppDelegate.swift in Sources */,
|
C406A602298AD50D00B5B85A /* AppDelegate.swift in Sources */,
|
||||||
|
C41F3D08298AED0D0042ACBF /* System.swift in Sources */,
|
||||||
C406A5F3298AD2CE00B5B85A /* main.swift in Sources */,
|
C406A5F3298AD2CE00B5B85A /* main.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -14,7 +14,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
print("PHP MONITOR SELF-UPDATER by Nico Verbruggen")
|
print("PHP MONITOR SELF-UPDATER by Nico Verbruggen")
|
||||||
|
|
||||||
// Figure out where the updater would like to find the
|
// Figure out where the updater would like to find the
|
||||||
let path = "~/config/phpmon/updater/phpmon.zip"
|
let path = "~/.config/phpmon/updater/phpmon.zip"
|
||||||
.replacingOccurrences(of: "~", with: NSHomeDirectory())
|
.replacingOccurrences(of: "~", with: NSHomeDirectory())
|
||||||
|
|
||||||
// Terminating all instances of PHP Monitor first
|
// Terminating all instances of PHP Monitor first
|
||||||
@ -25,7 +25,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
|
|
||||||
// If the file does not exist, exit gracefully
|
// If the file does not exist, exit gracefully
|
||||||
if !FileManager.default.fileExists(atPath: path) {
|
if !FileManager.default.fileExists(atPath: path) {
|
||||||
print("The update has not been downloaded. Sadly, that means we will not update!")
|
print("The update has not been downloaded. Sadly, that means that PHP Monitor cannot not updated!")
|
||||||
|
|
||||||
showAlert(title: "The archive containing the zip appears to be missing.",
|
showAlert(title: "The archive containing the zip appears to be missing.",
|
||||||
description: "PHP Monitor will not be updated, but we will restart the app for you.")
|
description: "PHP Monitor will not be updated, but we will restart the app for you.")
|
||||||
@ -40,6 +40,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We made it!
|
||||||
|
install(zipPath: path)
|
||||||
|
|
||||||
|
// Restart PHP Monitor, this will also close the updater
|
||||||
|
restartPhpMon(dev: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationWillTerminate(_ aNotification: Notification) {
|
func applicationWillTerminate(_ aNotification: Notification) {
|
||||||
@ -50,6 +56,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func install(zipPath: String) {
|
||||||
|
_ = system("rm -rf ~/.config/phpmon/updater/output")
|
||||||
|
_ = system("mkdir -p ~/.config/phpmon/updater/output")
|
||||||
|
_ = system("unzip \(zipPath) -d ~/.config/phpmon/updater/output")
|
||||||
|
_ = system("rm -rf \"/Applications/PHP Monitor.app\"")
|
||||||
|
let command = "mv \"~/.config/phpmon/updater/output/PHP Monitor.app\" \"/Applications/PHP Monitor.app\""
|
||||||
|
.replacingOccurrences(of: "~", with: NSHomeDirectory())
|
||||||
|
_ = system(command)
|
||||||
|
}
|
||||||
|
|
||||||
private func terminatePhpMon() {
|
private func terminatePhpMon() {
|
||||||
let runningApplications = NSWorkspace.shared.runningApplications
|
let runningApplications = NSWorkspace.shared.runningApplications
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user