-
-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from gao-sun/v1.5.11
v1.5.11
- Loading branch information
Showing
36 changed files
with
1,468 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "arrow.up.circle.fill.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true, | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file not shown.
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
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
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// | ||
// AppDelegate.swift | ||
// SelfUpdate | ||
// | ||
// Created by Gao Sun on 2021/2/12. | ||
// Copyright © 2021 Gao Sun. All rights reserved. | ||
// | ||
|
||
import Cocoa | ||
import SwiftUI | ||
|
||
@main | ||
class AppDelegate: NSObject, NSApplicationDelegate { | ||
var window: NSWindow! | ||
let fileManager = FileManager.default | ||
|
||
static func quit() { | ||
NSApplication.shared.terminate(self) | ||
} | ||
|
||
func update() { | ||
defer { | ||
AppDelegate.quit() | ||
} | ||
|
||
let arguments = CommandLine.arguments | ||
let newAppUrl = URL(fileURLWithPath: arguments[1]).appendingPathComponent("eul.app") | ||
let appUrl = URL(fileURLWithPath: arguments[2]).appendingPathComponent("eul.app") | ||
let pidArg = pid_t(arguments[3]) | ||
|
||
guard | ||
let pid = pidArg, | ||
let currentApp = NSWorkspace.shared.runningApplications.first(where: { $0.processIdentifier == pid }) | ||
else { | ||
print("current app not found with pid", pidArg ?? "N/A") | ||
return | ||
} | ||
|
||
var isDirectory: ObjCBool = false | ||
|
||
guard fileManager.fileExists(atPath: newAppUrl.path, isDirectory: &isDirectory), isDirectory.boolValue else { | ||
print("new app not found at", newAppUrl) | ||
return | ||
} | ||
|
||
print("terminating current app") | ||
guard currentApp.terminate() || currentApp.forceTerminate() else { | ||
print("cannot terminate current app") | ||
return | ||
} | ||
|
||
do { | ||
print("removing old app", appUrl) | ||
try fileManager.removeItem(at: appUrl) | ||
print("copying new app from", newAppUrl, "to", appUrl) | ||
try fileManager.copyItem(at: newAppUrl, to: appUrl) | ||
} catch { | ||
print("error when setting up new app", error) | ||
return | ||
} | ||
|
||
print("opening app") | ||
guard NSWorkspace.shared.open(appUrl) else { | ||
print("failed to open app") | ||
return | ||
} | ||
|
||
print("update fininshed") | ||
} | ||
|
||
func applicationDidFinishLaunching(_: Notification) { | ||
update() | ||
|
||
guard CommandLine.arguments.contains("--debug") else { | ||
return | ||
} | ||
|
||
// Create the SwiftUI view that provides the window contents. | ||
let contentView = ContentView() | ||
|
||
// Create the window and set the content view. | ||
window = NSWindow( | ||
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), | ||
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], | ||
backing: .buffered, defer: false | ||
) | ||
window.isReleasedWhenClosed = false | ||
window.center() | ||
window.setFrameAutosaveName("Main Window") | ||
window.contentView = NSHostingView(rootView: contentView) | ||
window.makeKeyAndOrderFront(nil) | ||
} | ||
|
||
func applicationWillTerminate(_: Notification) { | ||
// Insert code here to tear down your application | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
SelfUpdate/Assets.xcassets/AccentColor.colorset/Contents.json
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
SelfUpdate/Assets.xcassets/AppIcon.appiconset/Contents.json
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "512x512" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "512x512" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.