Skip to content

Commit 0b157f7

Browse files
authored
Improve error handling in user authentication (#8)
Enhance the error handling mechanism during user authentication to provide clearer feedback and improve user experience.
1 parent 28d9b6c commit 0b157f7

File tree

9 files changed

+524
-52
lines changed

9 files changed

+524
-52
lines changed

.githooks/pre-commit

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# .githooks/pre-commit
3+
# Pre-commit hook for version validation
4+
5+
set -e
6+
7+
echo "🔍 Pre-commit: Validating version synchronization..."
8+
9+
# Check if validation script exists
10+
if [ ! -f "scripts/validate-github-version-sync.sh" ]; then
11+
echo "⚠️ Version validation script not found, skipping check"
12+
exit 0
13+
fi
14+
15+
# Run version validation (but don't fail the commit if GitHub CLI is unavailable)
16+
if ./scripts/validate-github-version-sync.sh 2>/dev/null; then
17+
echo "✅ Pre-commit: Version validation passed"
18+
else
19+
echo "⚠️ Pre-commit: Version validation failed or GitHub CLI unavailable"
20+
echo "💡 Consider running: ./scripts/sync-version-from-github.sh"
21+
echo "🔄 Continuing with commit (validation not enforced)"
22+
fi
23+
24+
echo "✅ Pre-commit checks complete"

CLAUDE.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,109 @@ echo 'export CODE_SIGN_IDENTITY="Apple Development: Your Name (TEAM_ID)"' >> ~/.
439439
2. **Avoid concurrency conflicts**: Use proper `@MainActor` isolation without redundant dispatch
440440
3. **Test permission changes**: Always test toggling permissions ON/OFF during development
441441

442+
## Version Management System
443+
444+
ClickIt uses an automated version management system that synchronizes version numbers between the UI, GitHub releases, and build processes.
445+
446+
### Version Architecture
447+
448+
**Single Source of Truth**: GitHub Release tags (e.g., `v1.4.15`)
449+
- **GitHub Release**: Latest published version
450+
- **Info.plist**: `CFBundleShortVersionString` (synced automatically)
451+
- **UI Display**: Reads from `Bundle.main.infoDictionary` at runtime
452+
- **Build Scripts**: Extract version from Info.plist (no hardcoding)
453+
454+
### Version Management Scripts
455+
456+
**Sync version with GitHub releases**:
457+
```bash
458+
./scripts/sync-version-from-github.sh
459+
```
460+
Automatically updates Info.plist to match the latest GitHub release version.
461+
462+
**Validate version synchronization**:
463+
```bash
464+
./scripts/validate-github-version-sync.sh
465+
```
466+
Checks if local version matches GitHub release. Used in build validation.
467+
468+
**Update to new version**:
469+
```bash
470+
./scripts/update-version.sh 1.5.0 # Creates GitHub release automatically
471+
./scripts/update-version.sh 1.5.0 false # Update without GitHub release
472+
```
473+
Complete version update workflow including Info.plist update, git commit, tag creation, and optional GitHub release trigger.
474+
475+
### Fastlane Integration
476+
477+
**Sync with GitHub**:
478+
```bash
479+
fastlane sync_version_with_github
480+
```
481+
482+
**Release new version**:
483+
```bash
484+
fastlane release_with_github version:1.5.0
485+
```
486+
487+
**Validate synchronization**:
488+
```bash
489+
fastlane validate_github_sync
490+
```
491+
492+
### Git Hooks (Optional)
493+
494+
**Install version validation hooks**:
495+
```bash
496+
./scripts/install-git-hooks.sh
497+
```
498+
Adds pre-commit hook that validates version synchronization before commits.
499+
500+
### Build Integration
501+
502+
Build scripts automatically:
503+
- Extract version from Info.plist
504+
- Validate sync with GitHub releases
505+
- Display version warnings if mismatched
506+
- Build with correct version in app bundle
507+
508+
### Troubleshooting Version Issues
509+
510+
**UI shows wrong version**:
511+
```bash
512+
# Sync Info.plist with GitHub release
513+
./scripts/sync-version-from-github.sh
514+
515+
# Rebuild app bundle
516+
./build_app_unified.sh release
517+
```
518+
519+
**Version mismatch detected**:
520+
```bash
521+
# Check current status
522+
./scripts/validate-github-version-sync.sh
523+
524+
# Fix automatically
525+
./scripts/sync-version-from-github.sh
526+
```
527+
528+
**Release new version**:
529+
```bash
530+
# Complete workflow (recommended)
531+
./scripts/update-version.sh 1.5.0
532+
533+
# Or use Fastlane
534+
fastlane release_with_github version:1.5.0
535+
```
536+
537+
### CI/CD Integration
538+
539+
The GitHub Actions release workflow (`.github/workflows/release.yml`) automatically:
540+
- Validates version synchronization
541+
- Auto-fixes version mismatches
542+
- Verifies built app version matches tag
543+
- Creates releases with proper version metadata
544+
442545
## Documentation References
443546

444547
- Full product requirements: `docs/clickit_autoclicker_prd.md`

ClickIt/Info.plist

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,51 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>CFBundleDisplayName</key>
6-
<string>ClickIt</string>
7-
<key>CFBundleExecutable</key>
8-
<string>ClickIt</string>
9-
<key>CFBundleIdentifier</key>
10-
<string>com.jsonify.ClickIt</string>
11-
<key>CFBundleInfoDictionaryVersion</key>
12-
<string>6.0</string>
13-
<key>CFBundleName</key>
14-
<string>ClickIt</string>
15-
<key>CFBundlePackageType</key>
16-
<string>APPL</string>
17-
<key>CFBundleShortVersionString</key>
18-
<string>1.2.0</string>
19-
<key>CFBundleVersion</key>
20-
<string>$(CURRENT_PROJECT_VERSION)</string>
21-
<key>LSMinimumSystemVersion</key>
22-
<string>14.0</string>
23-
<key>LSUIElement</key>
24-
<false/>
25-
<key>NSHighResolutionCapable</key>
26-
<true/>
27-
<key>NSSupportsAutomaticGraphicsSwitching</key>
28-
<true/>
29-
<!-- CRITICAL: Permission usage descriptions -->
30-
<key>NSAppleEventsUsageDescription</key>
31-
<string>ClickIt needs to send Apple Events to simulate mouse clicks in target applications.</string>
32-
<key>NSSystemAdministrationUsageDescription</key>
33-
<string>ClickIt requires accessibility access to simulate mouse clicks and detect window information.</string>
34-
<!-- Additional privacy entries for comprehensive permissions -->
35-
<key>NSAccessibilityUsageDescription</key>
36-
<string>ClickIt needs accessibility access to control mouse clicks and interact with other applications.</string>
37-
<key>NSScreenCaptureUsageDescription</key>
38-
<string>ClickIt needs screen recording access to detect windows and provide visual feedback overlays.</string>
39-
<!-- App icon reference -->
40-
<key>CFBundleIconFile</key>
41-
<string>AppIcon</string>
42-
<key>CFBundleIconName</key>
43-
<string>AppIcon</string>
44-
<!-- Sparkle auto-update configuration -->
45-
<key>SUFeedURL</key>
46-
<string>https://jsonify.github.io/ClickIt/appcast.xml</string>
47-
<key>SUPublicEDKey</key>
48-
<string>auto-generated-when-needed</string>
49-
<key>SUAutomaticallyUpdate</key>
50-
<false/>
51-
<key>SUEnableAutomaticChecks</key>
52-
<true/>
53-
<key>SUCheckAtStartup</key>
54-
<true/>
5+
<key>CFBundleDisplayName</key>
6+
<string>ClickIt</string>
7+
<key>CFBundleExecutable</key>
8+
<string>ClickIt</string>
9+
<key>CFBundleIconFile</key>
10+
<string>AppIcon</string>
11+
<key>CFBundleIconName</key>
12+
<string>AppIcon</string>
13+
<key>CFBundleIdentifier</key>
14+
<string>com.jsonify.ClickIt</string>
15+
<key>CFBundleInfoDictionaryVersion</key>
16+
<string>6.0</string>
17+
<key>CFBundleName</key>
18+
<string>ClickIt</string>
19+
<key>CFBundlePackageType</key>
20+
<string>APPL</string>
21+
<key>CFBundleShortVersionString</key>
22+
<string>1.4.15</string>
23+
<key>CFBundleVersion</key>
24+
<string>$(CURRENT_PROJECT_VERSION)</string>
25+
<key>LSMinimumSystemVersion</key>
26+
<string>14.0</string>
27+
<key>LSUIElement</key>
28+
<false/>
29+
<key>NSAccessibilityUsageDescription</key>
30+
<string>ClickIt needs accessibility access to control mouse clicks and interact with other applications.</string>
31+
<key>NSAppleEventsUsageDescription</key>
32+
<string>ClickIt needs to send Apple Events to simulate mouse clicks in target applications.</string>
33+
<key>NSHighResolutionCapable</key>
34+
<true/>
35+
<key>NSScreenCaptureUsageDescription</key>
36+
<string>ClickIt needs screen recording access to detect windows and provide visual feedback overlays.</string>
37+
<key>NSSupportsAutomaticGraphicsSwitching</key>
38+
<true/>
39+
<key>NSSystemAdministrationUsageDescription</key>
40+
<string>ClickIt requires accessibility access to simulate mouse clicks and detect window information.</string>
41+
<key>SUAutomaticallyUpdate</key>
42+
<false/>
43+
<key>SUCheckAtStartup</key>
44+
<true/>
45+
<key>SUEnableAutomaticChecks</key>
46+
<true/>
47+
<key>SUFeedURL</key>
48+
<string>https://jsonify.github.io/ClickIt/appcast.xml</string>
49+
<key>SUPublicEDKey</key>
50+
<string>auto-generated-when-needed</string>
5551
</dict>
56-
</plist>
52+
</plist>

build_app_unified.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,32 @@ BUILD_SYSTEM="${2:-auto}" # auto, spm, xcode
99
DIST_DIR="dist"
1010
APP_NAME="ClickIt"
1111
BUNDLE_ID="com.jsonify.clickit"
12-
VERSION="1.0.0"
12+
# Get version from Info.plist (synced with GitHub releases)
13+
get_version_from_plist() {
14+
/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ClickIt/Info.plist 2>/dev/null || echo "1.0.0"
15+
}
16+
17+
VERSION=$(get_version_from_plist)
1318
BUILD_NUMBER=$(date +%Y%m%d%H%M)
1419

1520
echo "🔨 Building $APP_NAME app bundle ($BUILD_MODE mode)..."
21+
echo "📦 Version: $VERSION (from Info.plist, synced with GitHub releases)"
22+
23+
# Validate version is synchronized with GitHub (optional validation)
24+
if command -v gh > /dev/null 2>&1; then
25+
GITHUB_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' 2>/dev/null || git describe --tags --abbrev=0 2>/dev/null || echo "")
26+
if [ -n "$GITHUB_TAG" ]; then
27+
GITHUB_VERSION=${GITHUB_TAG#v}
28+
if [ "$VERSION" != "$GITHUB_VERSION" ]; then
29+
echo "⚠️ Warning: Version mismatch detected!"
30+
echo " Building: v$VERSION"
31+
echo " GitHub: $GITHUB_TAG"
32+
echo " Run './scripts/sync-version-from-github.sh' to sync versions"
33+
else
34+
echo "✅ Version synchronized with GitHub release $GITHUB_TAG"
35+
fi
36+
fi
37+
fi
1638

1739
# Detect build system
1840
detect_build_system() {

0 commit comments

Comments
 (0)