Skip to content

Commit 7a8b2f5

Browse files
committed
Support dependency update
1 parent f28d836 commit 7a8b2f5

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import CodeiumService
2+
import GitHubCopilotService
3+
import Logger
4+
5+
public struct DependencyUpdater {
6+
public init() {}
7+
8+
public func update() {
9+
Task {
10+
await withTaskGroup(of: Void.self) { taskGroup in
11+
let gitHubCopilot = GitHubCopilotInstallationManager()
12+
switch gitHubCopilot.checkInstallation() {
13+
case .notInstalled: break
14+
case .installed: break
15+
case .unsupported: break
16+
case .outdated:
17+
taskGroup.addTask {
18+
do {
19+
for try await step in gitHubCopilot.installLatestVersion() {
20+
let state = {
21+
switch step {
22+
case .downloading:
23+
return "Downloading"
24+
case .uninstalling:
25+
return "Uninstalling old version"
26+
case .decompressing:
27+
return "Decompressing"
28+
case .done:
29+
return "Done"
30+
}
31+
}()
32+
Logger.service
33+
.error("Update GitHub Copilot language server: \(state)")
34+
}
35+
} catch {
36+
Logger.service.error(
37+
"Update GitHub Copilot language server: \(error.localizedDescription)"
38+
)
39+
}
40+
}
41+
}
42+
let codeium = CodeiumInstallationManager()
43+
switch codeium.checkInstallation() {
44+
case .notInstalled: break
45+
case .installed: break
46+
case .unsupported: break
47+
case .outdated:
48+
taskGroup.addTask {
49+
do {
50+
for try await step in codeium.installLatestVersion() {
51+
let state = {
52+
switch step {
53+
case .downloading:
54+
return "Downloading"
55+
case .uninstalling:
56+
return "Uninstalling old version"
57+
case .decompressing:
58+
return "Decompressing"
59+
case .done:
60+
return "Done"
61+
}
62+
}()
63+
Logger.service.error("Update Codeium language server: \(state)")
64+
}
65+
} catch {
66+
Logger.service.error(
67+
"Update Codeium language server: \(error.localizedDescription)"
68+
)
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}
76+

ExtensionService/AppDelegate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
4242
Logger.service.info("XPC Service started.")
4343
NSApp.setActivationPolicy(.accessory)
4444
buildStatusBarMenu()
45+
DependencyUpdater().update()
4546
Task {
4647
do {
4748
try await ServiceUpdateMigrator().migrate()

0 commit comments

Comments
 (0)