Skip to content

Commit c8ecda2

Browse files
committed
cleanup
1 parent 6a93fac commit c8ecda2

File tree

6 files changed

+52
-22
lines changed

6 files changed

+52
-22
lines changed

Coder-Desktop/Coder-Desktop/Coder_DesktopApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
9292
image: "MenuBarIcon",
9393
onAppear: {
9494
// If the VPN is enabled, it's likely the token isn't expired
95+
guard self.vpn.state != .connected, self.state.hasSession else { return }
9596
Task { @MainActor in
96-
guard self.vpn.state != .connected, self.state.hasSession else { return }
9797
await self.state.handleTokenExpiry()
9898
}
9999
}, content: {

Coder-Desktop/Coder-Desktop/Preview Content/PreviewVPN.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,5 @@ final class PreviewVPN: Coder_Desktop.VPNService {
8181
state = .connecting
8282
}
8383

84-
func updateHelperState() {}
85-
8684
var startWhenReady: Bool = false
8785
}

Coder-Desktop/Coder-Desktop/Views/VPN/VPNState.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import ServiceManagement
21
import SwiftUI
32

43
struct VPNState<VPN: VPNService>: View {
@@ -57,22 +56,6 @@ struct VPNState<VPN: VPNService>: View {
5756
}
5857
}
5958

60-
struct HelperProgressView: View {
61-
var body: some View {
62-
HStack {
63-
Spacer()
64-
VStack {
65-
CircularProgressView(value: nil)
66-
Text("Installing Helper...")
67-
.multilineTextAlignment(.center)
68-
}
69-
.padding()
70-
.foregroundStyle(.secondary)
71-
Spacer()
72-
}
73-
}
74-
}
75-
7659
struct ApprovalRequiredView<VPN: VPNService>: View {
7760
@EnvironmentObject var vpn: VPN
7861
let message: String

Coder-Desktop/project.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,25 @@ targets:
216216
buildToolPlugins:
217217
- plugin: SwiftLintBuildToolPlugin
218218
package: SwiftLintPlugins
219+
postBuildScripts:
220+
# This is a dependency of the app, not the helper, as it copies the
221+
# helper plist from the app bundle to the system store.
222+
- name: "Upsert Helper for Local Development"
223+
# Only run this script (and prompt for admin) when the helper or any of
224+
# it's frameworks have changed.
225+
inputFiles:
226+
- "$(BUILT_PRODUCTS_DIR)/com.coder.Coder-Desktop.Helper"
227+
- "$(BUILT_PRODUCTS_DIR)/CoderSDK.framework/Versions/A/CoderSDK"
228+
- "$(BUILT_PRODUCTS_DIR)/VPNLib.framework/Versions/A/VPNLib"
229+
outputFiles:
230+
- "$(DERIVED_FILE_DIR)/upsert-helper.stamp"
231+
script: |
232+
/usr/bin/osascript <<'APPLESCRIPT'
233+
do shell script "/bin/bash -c " & quoted form of ((system attribute "SRCROOT") & "/../scripts/upsert-dev-helper.sh") with administrator privileges
234+
APPLESCRIPT
235+
/usr/bin/touch "${DERIVED_FILE_DIR}/upsert-helper.stamp"
236+
basedOnDependencyAnalysis: true
237+
runOnlyWhenInstalling: false
219238

220239
Coder-DesktopTests:
221240
type: bundle.unit-test
@@ -376,4 +395,4 @@ targets:
376395
PRODUCT_BUNDLE_IDENTIFIER: "com.coder.Coder-Desktop.Helper"
377396
PRODUCT_MODULE_NAME: "$(PRODUCT_NAME:c99extidentifier)"
378397
PRODUCT_NAME: "$(PRODUCT_BUNDLE_IDENTIFIER)"
379-
SKIP_INSTALL: YES
398+
SKIP_INSTALL: YES

scripts/update-cask.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ cask "coder-desktop" do
9393
9494
uninstall quit: [
9595
"com.coder.Coder-Desktop",
96-
"com.coder.Coder-Desktop.VPN",
9796
"com.coder.Coder-Desktop.Helper",
97+
"com.coder.Coder-Desktop.VPN",
9898
],
9999
login_item: "Coder Desktop"
100100

scripts/upsert-dev-helper.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This script operates like postinstall + preinstall, but for local development
2+
# builds, where the helper is necessary. Instead of looking for
3+
# /Applications/Coder Desktop.app, it looks for
4+
# /Applications/Coder/Coder Desktop.app, which is where the local build is
5+
# installed.
6+
7+
set -euox pipefail
8+
9+
LAUNCH_DAEMON_PLIST_SRC="/Applications/Coder/Coder Desktop.app/Contents/Library/LaunchDaemons"
10+
LAUNCH_DAEMON_PLIST_DEST="/Library/LaunchDaemons"
11+
LAUNCH_DAEMON_NAME="com.coder.Coder-Desktop.Helper"
12+
LAUNCH_DAEMON_PLIST_NAME="$LAUNCH_DAEMON_NAME.plist"
13+
LAUNCH_DAEMON_BINARY_PATH="/Applications/Coder/Coder Desktop.app/Contents/MacOS/com.coder.Coder-Desktop.Helper"
14+
15+
# Stop an existing launch daemon, if it exists
16+
sudo launchctl bootout "system/$LAUNCH_DAEMON_NAME" 2>/dev/null || true
17+
18+
# Install daemon
19+
# Copy plist into system dir, with the path corrected to the local build
20+
sed 's|/Applications/Coder Desktop\.app|/Applications/Coder/Coder Desktop.app|g' "$LAUNCH_DAEMON_PLIST_SRC"/"$LAUNCH_DAEMON_PLIST_NAME" | sudo tee "$LAUNCH_DAEMON_PLIST_DEST"/"$LAUNCH_DAEMON_PLIST_NAME" >/dev/null
21+
# Set necessary permissions
22+
sudo chmod -R 755 "$LAUNCH_DAEMON_BINARY_PATH"
23+
sudo chmod 644 "$LAUNCH_DAEMON_PLIST_DEST"/"$LAUNCH_DAEMON_PLIST_NAME"
24+
sudo chown root:wheel "$LAUNCH_DAEMON_PLIST_DEST"/"$LAUNCH_DAEMON_PLIST_NAME"
25+
26+
# Load daemon
27+
sudo launchctl enable "system/$LAUNCH_DAEMON_NAME" || true # Might already be enabled
28+
sudo launchctl bootstrap system "$LAUNCH_DAEMON_PLIST_DEST/$LAUNCH_DAEMON_PLIST_NAME"
29+
sudo launchctl kickstart -k "system/$LAUNCH_DAEMON_NAME"
30+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy