-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add tvos focus audit script #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MoElnaggar14
wants to merge
3
commits into
Abdo-codes:main
Choose a base branch
from
MoElnaggar14:feat/tvos-focus-audit-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,77 @@ | ||
| #!/bin/bash | ||
| # Audit a SwiftUI tvOS app for common focus navigation risk areas. | ||
| # Usage: audit-tvos-focus.sh [path-to-repo] | ||
| # Outputs a structured report of findings grouped by category. | ||
|
|
||
| set -o pipefail | ||
|
|
||
| REPO="${1:-.}" | ||
|
|
||
| if ! command -v rg >/dev/null 2>&1; then | ||
| echo "error: ripgrep (rg) is required for this audit" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$REPO" ]; then | ||
| echo "error: repository path is not a directory: $REPO" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -r "$REPO" ]; then | ||
| echo "error: repository path is not readable: $REPO" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "=== tvOS Focus Audit: $REPO ===" | ||
| echo "" | ||
|
|
||
| echo "## 1. Focus APIs In Use" | ||
| rg -n 'FocusState|@FocusState|\.focused\(|\.focusSection\(|\.prefersDefaultFocus|\.defaultFocus|\.focusScope|\.focusEffect|\.focusable\(' \ | ||
| --type swift "$REPO" 2>/dev/null || echo " (none found)" | ||
| echo "" | ||
|
|
||
| echo "## 2. Button Styles And Default Focus Chrome Hotspots" | ||
| rg -n 'ButtonStyle|\.buttonStyle\(\.plain\)|\.buttonStyle\(|@Environment\(\\\.isFocused\)|isFocused' \ | ||
| --type swift "$REPO" 2>/dev/null | head -120 || echo " (none found)" | ||
| echo "" | ||
|
|
||
| echo "## 3. Invisible Or Clear Interactive Views" | ||
| rg -n 'Button\s*\{|Color\.clear|\.opacity\(0\)|\.hidden\(\)|\.frame\(width:\s*1|\.frame\(.*height:\s*1' \ | ||
| --type swift "$REPO" 2>/dev/null | head -120 || echo " (none found)" | ||
| echo "" | ||
|
|
||
| echo "## 4. Spacer Gaps That May Break Spatial Navigation" | ||
| rg -n 'Spacer\(\)' --type swift "$REPO" 2>/dev/null | head -80 || echo " (none found)" | ||
| echo "" | ||
|
|
||
| echo "## 5. ScrollViews That May Trap Directional Input" | ||
| rg -n 'ScrollView\s*[\(\{]|LazyHStack|LazyVStack|\.scrollTarget|\.scrollPosition' \ | ||
| --type swift "$REPO" 2>/dev/null | head -120 || echo " (none found)" | ||
| echo "" | ||
|
|
||
| echo "## 6. Directional Command Handlers" | ||
| rg -n '\.onMoveCommand|\.onExitCommand|\.onPlayPauseCommand|MoveCommandDirection|pressesBegan|UIPress' \ | ||
| --type swift "$REPO" 2>/dev/null || echo " (none found)" | ||
| echo "" | ||
|
|
||
| echo "## 7. Overlay And Modal Focus Capture" | ||
| rg -n 'ZStack|\.overlay\s*[\(\{]|fullScreenCover|sheet\(|popover\(|\.disabled\(|isPresented|isOverlay|showOverlay|dismiss' \ | ||
| --type swift "$REPO" 2>/dev/null | head -160 || echo " (none found)" | ||
| echo "" | ||
|
|
||
| echo "## 8. Focus Restore After State Changes" | ||
| rg -n '\.onChange\(of:|DispatchQueue\.main\.async|Task\s*\{|focused[A-Za-z0-9_]*\s*=' \ | ||
| --type swift "$REPO" 2>/dev/null | head -120 || echo " (none found)" | ||
| echo "" | ||
|
|
||
| echo "## 9. tvOS-Specific Files And Targets" | ||
| TVOS_FILES="$(find "$REPO" \( -name '*tvOS*' -o -name '*.xcodeproj' -o -name 'Package.swift' \) \ | ||
| -not -path '*/.*' 2>/dev/null)" | ||
| if [ -n "$TVOS_FILES" ]; then | ||
| echo "$TVOS_FILES" | ||
| else | ||
| echo " (none found)" | ||
| fi | ||
| echo "" | ||
|
|
||
| echo "=== End Audit ===" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
REPOis invalid or unreadable, this command hides ripgrep’s error output (2>/dev/null) and falls back to(none found), so the script exits successfully with a misleading “clean” audit. Runningaudit-tvos-focus.sh /tmp/does-not-existcurrently reports no findings instead of failing, which can mask operator mistakes and invalidate audit results; add an upfront path check (and/or treat rg exit code 2 as an error) before printing empty-category output.Useful? React with 👍 / 👎.