mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
Add SwiftLint and SwiftFormat Husky pre-commit hooks for iOS and mac (#165)
Co-authored-by: Peter Steinberger <steipete@gmail.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
68ce36828a
commit
1d9112b9d3
8 changed files with 105 additions and 21 deletions
|
|
@ -36,9 +36,9 @@ struct VibeTunnelApp: App {
|
||||||
|
|
||||||
private var colorScheme: ColorScheme? {
|
private var colorScheme: ColorScheme? {
|
||||||
switch colorSchemePreferenceRaw {
|
switch colorSchemePreferenceRaw {
|
||||||
case "light": return .light
|
case "light": .light
|
||||||
case "dark": return .dark
|
case "dark": .dark
|
||||||
default: return nil
|
default: nil // System default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,9 @@ struct GeneralSettingsView: View {
|
||||||
|
|
||||||
var displayName: String {
|
var displayName: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .system: return "System"
|
case .system: "System"
|
||||||
case .light: return "Light"
|
case .light: "Light"
|
||||||
case .dark: return "Dark"
|
case .dark: "Dark"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -124,14 +124,14 @@ struct GeneralSettingsView: View {
|
||||||
Text("Appearance")
|
Text("Appearance")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.foregroundColor(Theme.Colors.terminalForeground)
|
.foregroundColor(Theme.Colors.terminalForeground)
|
||||||
|
|
||||||
VStack(spacing: Theme.Spacing.medium) {
|
VStack(spacing: Theme.Spacing.medium) {
|
||||||
// Color Scheme
|
// Color Scheme
|
||||||
VStack(alignment: .leading, spacing: Theme.Spacing.small) {
|
VStack(alignment: .leading, spacing: Theme.Spacing.small) {
|
||||||
Text("Color Scheme")
|
Text("Color Scheme")
|
||||||
.font(Theme.Typography.terminalSystem(size: 14))
|
.font(Theme.Typography.terminalSystem(size: 14))
|
||||||
.foregroundColor(Theme.Colors.terminalForeground.opacity(0.7))
|
.foregroundColor(Theme.Colors.terminalForeground.opacity(0.7))
|
||||||
|
|
||||||
Picker("Color Scheme", selection: $colorSchemePreferenceRaw) {
|
Picker("Color Scheme", selection: $colorSchemePreferenceRaw) {
|
||||||
ForEach(ColorSchemePreference.allCases, id: \.self) { preference in
|
ForEach(ColorSchemePreference.allCases, id: \.self) { preference in
|
||||||
Text(preference.displayName).tag(preference.rawValue)
|
Text(preference.displayName).tag(preference.rawValue)
|
||||||
|
|
@ -144,7 +144,7 @@ struct GeneralSettingsView: View {
|
||||||
.cornerRadius(Theme.CornerRadius.card)
|
.cornerRadius(Theme.CornerRadius.card)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terminal Defaults Section
|
// Terminal Defaults Section
|
||||||
VStack(alignment: .leading, spacing: Theme.Spacing.medium) {
|
VStack(alignment: .leading, spacing: Theme.Spacing.medium) {
|
||||||
Text("Terminal Defaults")
|
Text("Terminal Defaults")
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ struct TerminalToolbar: View {
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fourth row - F-keys (F7-F12)
|
// Fourth row - F-keys (F7-F12)
|
||||||
HStack(spacing: Theme.Spacing.extraSmall) {
|
HStack(spacing: Theme.Spacing.extraSmall) {
|
||||||
ForEach(["F7", "F8", "F9", "F10", "F11", "F12"], id: \.self) { fkey in
|
ForEach(["F7", "F8", "F9", "F10", "F11", "F12"], id: \.self) { fkey in
|
||||||
|
|
@ -184,29 +184,29 @@ struct TerminalToolbar: View {
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fifth row - Special characters
|
// Fifth row - Special characters
|
||||||
HStack(spacing: Theme.Spacing.extraSmall) {
|
HStack(spacing: Theme.Spacing.extraSmall) {
|
||||||
ToolbarButton(label: "\\") {
|
ToolbarButton(label: "\\") {
|
||||||
HapticFeedback.impact(.light)
|
HapticFeedback.impact(.light)
|
||||||
onSpecialKey(.backslash)
|
onSpecialKey(.backslash)
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolbarButton(label: "|") {
|
ToolbarButton(label: "|") {
|
||||||
HapticFeedback.impact(.light)
|
HapticFeedback.impact(.light)
|
||||||
onSpecialKey(.pipe)
|
onSpecialKey(.pipe)
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolbarButton(label: "`") {
|
ToolbarButton(label: "`") {
|
||||||
HapticFeedback.impact(.light)
|
HapticFeedback.impact(.light)
|
||||||
onSpecialKey(.backtick)
|
onSpecialKey(.backtick)
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolbarButton(label: "~") {
|
ToolbarButton(label: "~") {
|
||||||
HapticFeedback.impact(.light)
|
HapticFeedback.impact(.light)
|
||||||
onSpecialKey(.tilde)
|
onSpecialKey(.tilde)
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolbarButton(label: "END") {
|
ToolbarButton(label: "END") {
|
||||||
HapticFeedback.impact(.light)
|
HapticFeedback.impact(.light)
|
||||||
// Send Ctrl+E for end
|
// Send Ctrl+E for end
|
||||||
|
|
|
||||||
|
|
@ -888,7 +888,7 @@ class TerminalViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendSpecialKey(_ key: TerminalInput.SpecialKey) {
|
func sendSpecialKey(_ key: TerminalInput.SpecialKey) {
|
||||||
sendInput(key.rawValue)
|
sendInput(key.rawValue)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,9 @@ struct WelcomeView: View {
|
||||||
HStack(spacing: 8) {
|
HStack(spacing: 8) {
|
||||||
ForEach(0..<5) { index in
|
ForEach(0..<5) { index in
|
||||||
Circle()
|
Circle()
|
||||||
.fill(index == currentPage ? Theme.Colors.primaryAccent : Theme.Colors.secondaryText.opacity(0.3))
|
.fill(index == currentPage ?
|
||||||
|
Theme.Colors.primaryAccent :
|
||||||
|
Theme.Colors.secondaryText.opacity(0.3))
|
||||||
.frame(width: 8, height: 8)
|
.frame(width: 8, height: 8)
|
||||||
.animation(.easeInOut, value: currentPage)
|
.animation(.easeInOut, value: currentPage)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
78
ios/scripts/lint.sh
Executable file
78
ios/scripts/lint.sh
Executable file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# =============================================================================
|
||||||
|
#
|
||||||
|
# This script runs SwiftFormat and SwiftLint on the VibeTunnel iOS codebase
|
||||||
|
# to ensure consistent code style and catch potential issues.
|
||||||
|
#
|
||||||
|
# USAGE:
|
||||||
|
# ./scripts/lint.sh
|
||||||
|
#
|
||||||
|
# DEPENDENCIES:
|
||||||
|
# - swiftformat (brew install swiftformat)
|
||||||
|
# - swiftlint (brew install swiftlint)
|
||||||
|
#
|
||||||
|
# FEATURES:
|
||||||
|
# - Automatically formats Swift code with SwiftFormat
|
||||||
|
# - Fixes auto-correctable SwiftLint issues
|
||||||
|
# - Reports remaining SwiftLint warnings and errors
|
||||||
|
#
|
||||||
|
# EXIT CODES:
|
||||||
|
# 0 - Success (all checks passed)
|
||||||
|
# 1 - Missing dependencies or linting errors
|
||||||
|
#
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Source common functions
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
[[ -f "$SCRIPT_DIR/common.sh" ]] && source "$SCRIPT_DIR/common.sh" || true
|
||||||
|
|
||||||
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
|
|
||||||
|
# Change to project root
|
||||||
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
|
# Check if project has Swift files
|
||||||
|
if ! find . -name "*.swift" -not -path "./.build/*" -not -path "./build/*" | head -1 | grep -q .; then
|
||||||
|
print_warning "No Swift files found in project"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_info "Running SwiftFormat..."
|
||||||
|
if command -v swiftformat &> /dev/null; then
|
||||||
|
if swiftformat . --config ../apple/.swiftformat --verbose; then
|
||||||
|
print_success "SwiftFormat completed successfully"
|
||||||
|
else
|
||||||
|
print_error "SwiftFormat encountered errors"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print_error "SwiftFormat not installed"
|
||||||
|
echo " Install with: brew install swiftformat"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_info "Running SwiftLint..."
|
||||||
|
if command -v swiftlint &> /dev/null; then
|
||||||
|
# First run auto-corrections
|
||||||
|
print_info "Applying auto-corrections..."
|
||||||
|
swiftlint --fix --config ../apple/.swiftlint.yml
|
||||||
|
|
||||||
|
# Then run full lint check
|
||||||
|
print_info "Checking for remaining issues..."
|
||||||
|
if swiftlint --config ../apple/.swiftlint.yml; then
|
||||||
|
print_success "SwiftLint completed successfully"
|
||||||
|
else
|
||||||
|
print_warning "SwiftLint found issues that require manual attention"
|
||||||
|
# Don't exit with error as these may be warnings
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print_error "SwiftLint not installed"
|
||||||
|
echo " Install with: brew install swiftlint"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_success "Linting complete!"
|
||||||
|
|
@ -45,7 +45,7 @@ fi
|
||||||
# Run SwiftFormat
|
# Run SwiftFormat
|
||||||
print_info "Running SwiftFormat..."
|
print_info "Running SwiftFormat..."
|
||||||
if command -v swiftformat &> /dev/null; then
|
if command -v swiftformat &> /dev/null; then
|
||||||
if swiftformat . --verbose; then
|
if swiftformat . --config ../apple/.swiftformat --verbose; then
|
||||||
print_success "SwiftFormat completed successfully"
|
print_success "SwiftFormat completed successfully"
|
||||||
else
|
else
|
||||||
print_error "SwiftFormat encountered errors"
|
print_error "SwiftFormat encountered errors"
|
||||||
|
|
@ -62,11 +62,11 @@ print_info "Running SwiftLint..."
|
||||||
if command -v swiftlint &> /dev/null; then
|
if command -v swiftlint &> /dev/null; then
|
||||||
# First run auto-corrections
|
# First run auto-corrections
|
||||||
print_info "Applying auto-corrections..."
|
print_info "Applying auto-corrections..."
|
||||||
swiftlint --fix
|
swiftlint --fix --config ../apple/.swiftlint.yml
|
||||||
|
|
||||||
# Then run full lint check
|
# Then run full lint check
|
||||||
print_info "Checking for remaining issues..."
|
print_info "Checking for remaining issues..."
|
||||||
if swiftlint; then
|
if swiftlint --config ../apple/.swiftlint.yml; then
|
||||||
print_success "SwiftLint completed successfully"
|
print_success "SwiftLint completed successfully"
|
||||||
else
|
else
|
||||||
print_warning "SwiftLint found issues that require manual attention"
|
print_warning "SwiftLint found issues that require manual attention"
|
||||||
|
|
@ -78,4 +78,4 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_success "Linting complete!"
|
print_success "Linting complete!"
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,10 @@
|
||||||
"bash -c 'tsc --noEmit --project tsconfig.server.json'",
|
"bash -c 'tsc --noEmit --project tsconfig.server.json'",
|
||||||
"bash -c 'tsc --noEmit --project tsconfig.client.json'",
|
"bash -c 'tsc --noEmit --project tsconfig.client.json'",
|
||||||
"bash -c 'tsc --noEmit --project tsconfig.sw.json'"
|
"bash -c 'tsc --noEmit --project tsconfig.sw.json'"
|
||||||
|
],
|
||||||
|
"../{ios,mac}/**/*.swift": [
|
||||||
|
"bash -c 'cd ../ios && ./scripts/lint.sh'",
|
||||||
|
"bash -c 'cd ../mac && ./scripts/lint.sh'"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue