mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
resilient vt
This commit is contained in:
parent
e82c633a9a
commit
5100d3f2fb
2 changed files with 55 additions and 36 deletions
37
mac/VibeTunnel/Resources/vt
Executable file
37
mac/VibeTunnel/Resources/vt
Executable file
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# VibeTunnel CLI wrapper
|
||||||
|
|
||||||
|
# Try standard locations first, but verify the binary exists
|
||||||
|
APP_PATH=""
|
||||||
|
for TRY_PATH in "/Applications/VibeTunnel.app" "$HOME/Applications/VibeTunnel.app"; do
|
||||||
|
if [ -d "$TRY_PATH" ] && [ -f "$TRY_PATH/Contents/Resources/vibetunnel" ]; then
|
||||||
|
APP_PATH="$TRY_PATH"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If not found in standard locations with valid binary, search for it
|
||||||
|
if [ -z "$APP_PATH" ]; then
|
||||||
|
# First try DerivedData (for development)
|
||||||
|
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "VibeTunnel.app" -type d 2>/dev/null | grep -v "\.dSYM" | head -1)
|
||||||
|
|
||||||
|
# If still not found, use mdfind as last resort
|
||||||
|
if [ -z "$APP_PATH" ] || [ ! -d "$APP_PATH" ]; then
|
||||||
|
APP_PATH=$(mdfind -name "VibeTunnel.app" 2>/dev/null | grep -v "\.dSYM" | head -1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$APP_PATH" ] || [ ! -d "$APP_PATH" ]; then
|
||||||
|
echo "Error: VibeTunnel.app not found anywhere on the system" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Execute vibetunnel from app bundle
|
||||||
|
VIBETUNNEL_BIN="$APP_PATH/Contents/Resources/vibetunnel"
|
||||||
|
if [ ! -f "$VIBETUNNEL_BIN" ]; then
|
||||||
|
echo "Error: vibetunnel binary not found in app bundle at $VIBETUNNEL_BIN" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run with fwd command
|
||||||
|
exec "$VIBETUNNEL_BIN" fwd "$@"
|
||||||
|
|
@ -47,8 +47,7 @@ final class CLIInstaller {
|
||||||
if let content = try? String(contentsOfFile: vtPath, encoding: .utf8) {
|
if let content = try? String(contentsOfFile: vtPath, encoding: .utf8) {
|
||||||
// Verify it's our wrapper script with all expected components
|
// Verify it's our wrapper script with all expected components
|
||||||
isCorrectlyInstalled = content.contains("VibeTunnel CLI wrapper") &&
|
isCorrectlyInstalled = content.contains("VibeTunnel CLI wrapper") &&
|
||||||
content.contains("APP_PATH=\"/Applications/VibeTunnel.app\"") &&
|
content.contains("$TRY_PATH/Contents/Resources/vibetunnel") &&
|
||||||
content.contains("$APP_PATH/Contents/Resources/vibetunnel") &&
|
|
||||||
content.contains("exec \"$VIBETUNNEL_BIN\" fwd \"$@\"")
|
content.contains("exec \"$VIBETUNNEL_BIN\" fwd \"$@\"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,11 +72,11 @@ final class CLIInstaller {
|
||||||
isInstalling = true
|
isInstalling = true
|
||||||
lastError = nil
|
lastError = nil
|
||||||
|
|
||||||
// Verify that vibetunnel exists in the app bundle
|
// Verify that vt script exists in the app bundle
|
||||||
guard Bundle.main.path(forResource: "vibetunnel", ofType: nil) != nil else {
|
guard let vtScriptPath = Bundle.main.path(forResource: "vt", ofType: nil) else {
|
||||||
logger.error("CLIInstaller: Could not find vibetunnel binary in app bundle")
|
logger.error("CLIInstaller: Could not find vt script in app bundle")
|
||||||
lastError = "The vibetunnel binary could not be found in the application bundle."
|
lastError = "The vt script could not be found in the application bundle."
|
||||||
showError("The vibetunnel binary could not be found in the application bundle.")
|
showError("The vt script could not be found in the application bundle.")
|
||||||
isInstalling = false
|
isInstalling = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +107,15 @@ final class CLIInstaller {
|
||||||
|
|
||||||
/// Performs the actual installation with sudo privileges
|
/// Performs the actual installation with sudo privileges
|
||||||
private func performInstallation() {
|
private func performInstallation() {
|
||||||
logger.info("CLIInstaller: Creating vt wrapper script")
|
logger.info("CLIInstaller: Installing vt script")
|
||||||
|
|
||||||
|
guard let vtScriptPath = Bundle.main.path(forResource: "vt", ofType: nil) else {
|
||||||
|
logger.error("CLIInstaller: Could not find vt script in app bundle")
|
||||||
|
lastError = "The vt script could not be found in the application bundle."
|
||||||
|
showError("The vt script could not be found in the application bundle.")
|
||||||
|
isInstalling = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let vtTargetPath = "/usr/local/bin/vt"
|
let vtTargetPath = "/usr/local/bin/vt"
|
||||||
let binDirectory = "/usr/local/bin"
|
let binDirectory = "/usr/local/bin"
|
||||||
|
|
@ -130,35 +137,10 @@ final class CLIInstaller {
|
||||||
echo "Removed existing file at \(vtTargetPath)"
|
echo "Removed existing file at \(vtTargetPath)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create vt wrapper script that finds and runs vibetunnel from app bundle
|
# Copy vt script from app bundle
|
||||||
cat > "\(vtTargetPath)" << 'EOF'
|
cp "\(vtScriptPath)" "\(vtTargetPath)"
|
||||||
#!/bin/bash
|
|
||||||
# VibeTunnel CLI wrapper
|
|
||||||
|
|
||||||
# Find VibeTunnel.app installation
|
|
||||||
APP_PATH="/Applications/VibeTunnel.app"
|
|
||||||
if [ ! -d "$APP_PATH" ]; then
|
|
||||||
# Try to find it in user Applications
|
|
||||||
APP_PATH="$HOME/Applications/VibeTunnel.app"
|
|
||||||
if [ ! -d "$APP_PATH" ]; then
|
|
||||||
echo "Error: VibeTunnel.app not found in /Applications or ~/Applications" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Execute vibetunnel from app bundle
|
|
||||||
VIBETUNNEL_BIN="$APP_PATH/Contents/Resources/vibetunnel"
|
|
||||||
if [ ! -f "$VIBETUNNEL_BIN" ]; then
|
|
||||||
echo "Error: vibetunnel binary not found in app bundle" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run with fwd command
|
|
||||||
exec "$VIBETUNNEL_BIN" fwd "$@"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x "\(vtTargetPath)"
|
chmod +x "\(vtTargetPath)"
|
||||||
echo "Created vt wrapper script at \(vtTargetPath)"
|
echo "Installed vt script at \(vtTargetPath)"
|
||||||
|
|
||||||
# Clean up old vibetunnel binary if it exists
|
# Clean up old vibetunnel binary if it exists
|
||||||
if [ -f "/usr/local/bin/vibetunnel" ]; then
|
if [ -f "/usr/local/bin/vibetunnel" ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue