@croacroa/react-native-template 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +18 -0
- package/.eslintrc.js +55 -0
- package/.github/workflows/ci.yml +184 -0
- package/.github/workflows/eas-build.yml +55 -0
- package/.github/workflows/eas-update.yml +50 -0
- package/.gitignore +62 -0
- package/.prettierrc +11 -0
- package/.storybook/main.ts +28 -0
- package/.storybook/preview.tsx +30 -0
- package/CHANGELOG.md +106 -0
- package/CONTRIBUTING.md +377 -0
- package/README.md +399 -0
- package/__tests__/components/Button.test.tsx +74 -0
- package/__tests__/hooks/useAuth.test.tsx +499 -0
- package/__tests__/services/api.test.ts +535 -0
- package/__tests__/utils/cn.test.ts +39 -0
- package/app/(auth)/_layout.tsx +36 -0
- package/app/(auth)/home.tsx +117 -0
- package/app/(auth)/profile.tsx +152 -0
- package/app/(auth)/settings.tsx +147 -0
- package/app/(public)/_layout.tsx +21 -0
- package/app/(public)/forgot-password.tsx +127 -0
- package/app/(public)/login.tsx +120 -0
- package/app/(public)/onboarding.tsx +5 -0
- package/app/(public)/register.tsx +139 -0
- package/app/_layout.tsx +97 -0
- package/app/index.tsx +21 -0
- package/app.config.ts +72 -0
- package/assets/images/.gitkeep +7 -0
- package/assets/images/adaptive-icon.png +0 -0
- package/assets/images/favicon.png +0 -0
- package/assets/images/icon.png +0 -0
- package/assets/images/notification-icon.png +0 -0
- package/assets/images/splash.png +0 -0
- package/babel.config.js +10 -0
- package/components/ErrorBoundary.tsx +169 -0
- package/components/forms/FormInput.tsx +78 -0
- package/components/forms/index.ts +1 -0
- package/components/onboarding/OnboardingScreen.tsx +370 -0
- package/components/onboarding/index.ts +2 -0
- package/components/ui/AnimatedButton.tsx +156 -0
- package/components/ui/AnimatedCard.tsx +108 -0
- package/components/ui/Avatar.tsx +316 -0
- package/components/ui/Badge.tsx +416 -0
- package/components/ui/BottomSheet.tsx +307 -0
- package/components/ui/Button.stories.tsx +115 -0
- package/components/ui/Button.tsx +104 -0
- package/components/ui/Card.stories.tsx +84 -0
- package/components/ui/Card.tsx +32 -0
- package/components/ui/Checkbox.tsx +261 -0
- package/components/ui/Input.stories.tsx +106 -0
- package/components/ui/Input.tsx +117 -0
- package/components/ui/Modal.tsx +98 -0
- package/components/ui/OptimizedImage.tsx +369 -0
- package/components/ui/Select.tsx +240 -0
- package/components/ui/Skeleton.tsx +180 -0
- package/components/ui/index.ts +18 -0
- package/constants/config.ts +54 -0
- package/docs/adr/001-state-management.md +79 -0
- package/docs/adr/002-styling-approach.md +130 -0
- package/docs/adr/003-data-fetching.md +155 -0
- package/docs/adr/004-auth-adapter-pattern.md +144 -0
- package/docs/adr/README.md +78 -0
- package/eas.json +47 -0
- package/global.css +10 -0
- package/hooks/index.ts +25 -0
- package/hooks/useApi.ts +236 -0
- package/hooks/useAuth.tsx +290 -0
- package/hooks/useBiometrics.ts +295 -0
- package/hooks/useDeepLinking.ts +256 -0
- package/hooks/useNotifications.ts +138 -0
- package/hooks/useOffline.ts +69 -0
- package/hooks/usePerformance.ts +434 -0
- package/hooks/useTheme.tsx +85 -0
- package/hooks/useUpdates.ts +358 -0
- package/i18n/index.ts +77 -0
- package/i18n/locales/en.json +101 -0
- package/i18n/locales/fr.json +101 -0
- package/jest.config.js +32 -0
- package/maestro/README.md +113 -0
- package/maestro/config.yaml +35 -0
- package/maestro/flows/login.yaml +62 -0
- package/maestro/flows/navigation.yaml +68 -0
- package/maestro/flows/offline.yaml +60 -0
- package/maestro/flows/register.yaml +94 -0
- package/metro.config.js +6 -0
- package/nativewind-env.d.ts +1 -0
- package/package.json +170 -0
- package/scripts/init.ps1 +162 -0
- package/scripts/init.sh +174 -0
- package/services/analytics.ts +428 -0
- package/services/api.ts +340 -0
- package/services/authAdapter.ts +333 -0
- package/services/index.ts +22 -0
- package/services/queryClient.ts +97 -0
- package/services/sentry.ts +131 -0
- package/services/storage.ts +82 -0
- package/stores/appStore.ts +54 -0
- package/stores/index.ts +2 -0
- package/stores/notificationStore.ts +40 -0
- package/tailwind.config.js +47 -0
- package/tsconfig.json +26 -0
- package/types/index.ts +42 -0
- package/types/user.ts +63 -0
- package/utils/accessibility.ts +446 -0
- package/utils/cn.ts +14 -0
- package/utils/index.ts +43 -0
- package/utils/toast.ts +113 -0
- package/utils/validation.ts +67 -0
package/scripts/init.ps1
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Template Initialization Script (Windows PowerShell)
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# This script customizes the template for a new project
|
|
5
|
+
#
|
|
6
|
+
# Usage: .\scripts\init.ps1
|
|
7
|
+
# =============================================================================
|
|
8
|
+
|
|
9
|
+
$ErrorActionPreference = "Stop"
|
|
10
|
+
|
|
11
|
+
function Write-Step {
|
|
12
|
+
param([string]$Message)
|
|
13
|
+
Write-Host "==> " -ForegroundColor Blue -NoNewline
|
|
14
|
+
Write-Host $Message
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function Write-Success {
|
|
18
|
+
param([string]$Message)
|
|
19
|
+
Write-Host "✓ " -ForegroundColor Green -NoNewline
|
|
20
|
+
Write-Host $Message
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function Write-Warning {
|
|
24
|
+
param([string]$Message)
|
|
25
|
+
Write-Host "⚠ " -ForegroundColor Yellow -NoNewline
|
|
26
|
+
Write-Host $Message
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function Write-Error {
|
|
30
|
+
param([string]$Message)
|
|
31
|
+
Write-Host "✗ " -ForegroundColor Red -NoNewline
|
|
32
|
+
Write-Host $Message
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# Header
|
|
36
|
+
Write-Host ""
|
|
37
|
+
Write-Host "╔════════════════════════════════════════════════════════════╗" -ForegroundColor Blue
|
|
38
|
+
Write-Host "║ React Native Template Initialization ║" -ForegroundColor Blue
|
|
39
|
+
Write-Host "╚════════════════════════════════════════════════════════════╝" -ForegroundColor Blue
|
|
40
|
+
Write-Host ""
|
|
41
|
+
|
|
42
|
+
# Get project info from user
|
|
43
|
+
$APP_NAME = Read-Host "Enter app name [e.g., MyAwesomeApp]"
|
|
44
|
+
if ([string]::IsNullOrEmpty($APP_NAME)) {
|
|
45
|
+
Write-Error "App name is required"
|
|
46
|
+
exit 1
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
$BUNDLE_ID = Read-Host "Enter bundle identifier [e.g., com.yourcompany.myapp]"
|
|
50
|
+
if ([string]::IsNullOrEmpty($BUNDLE_ID)) {
|
|
51
|
+
Write-Error "Bundle identifier is required"
|
|
52
|
+
exit 1
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
$APP_SCHEME = Read-Host "Enter app scheme [e.g., myapp] (leave empty for default)"
|
|
56
|
+
if ([string]::IsNullOrEmpty($APP_SCHEME)) {
|
|
57
|
+
$APP_SCHEME = $APP_NAME.ToLower() -replace '\s', ''
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
$COMPANY_NAME = Read-Host "Enter company/author name [e.g., Your Company]"
|
|
61
|
+
if ([string]::IsNullOrEmpty($COMPANY_NAME)) {
|
|
62
|
+
$COMPANY_NAME = "Your Company"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Write-Host ""
|
|
66
|
+
Write-Step "Configuring project with:"
|
|
67
|
+
Write-Host " App Name: $APP_NAME"
|
|
68
|
+
Write-Host " Bundle ID: $BUNDLE_ID"
|
|
69
|
+
Write-Host " Scheme: $APP_SCHEME"
|
|
70
|
+
Write-Host " Company: $COMPANY_NAME"
|
|
71
|
+
Write-Host ""
|
|
72
|
+
|
|
73
|
+
# Confirm
|
|
74
|
+
$CONFIRM = Read-Host "Proceed with these settings? [y/N]"
|
|
75
|
+
if ($CONFIRM -notmatch "^[Yy]$") {
|
|
76
|
+
Write-Warning "Cancelled"
|
|
77
|
+
exit 0
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Write-Host ""
|
|
81
|
+
Write-Step "Updating configuration files..."
|
|
82
|
+
|
|
83
|
+
# Create slug from app name
|
|
84
|
+
$APP_SLUG = $APP_NAME.ToLower() -replace '\s', '-'
|
|
85
|
+
|
|
86
|
+
# Update package.json
|
|
87
|
+
if (Test-Path "package.json") {
|
|
88
|
+
$content = Get-Content "package.json" -Raw
|
|
89
|
+
$content = $content -replace '"name": "react-native-template"', "`"name`": `"$APP_SLUG`""
|
|
90
|
+
Set-Content "package.json" $content -NoNewline
|
|
91
|
+
Write-Success "Updated package.json"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
# Update app.config.ts
|
|
95
|
+
if (Test-Path "app.config.ts") {
|
|
96
|
+
$content = Get-Content "app.config.ts" -Raw
|
|
97
|
+
$content = $content -replace 'YourApp', $APP_NAME
|
|
98
|
+
$content = $content -replace 'yourapp', $APP_SCHEME
|
|
99
|
+
$content = $content -replace 'com\.yourcompany\.yourapp', $BUNDLE_ID
|
|
100
|
+
Set-Content "app.config.ts" $content -NoNewline
|
|
101
|
+
Write-Success "Updated app.config.ts"
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
# Update constants/config.ts
|
|
105
|
+
if (Test-Path "constants/config.ts") {
|
|
106
|
+
$content = Get-Content "constants/config.ts" -Raw
|
|
107
|
+
$content = $content -replace 'YourApp', $APP_NAME
|
|
108
|
+
$content = $content -replace 'yourapp', $APP_SCHEME
|
|
109
|
+
Set-Content "constants/config.ts" $content -NoNewline
|
|
110
|
+
Write-Success "Updated constants/config.ts"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# Update eas.json
|
|
114
|
+
if (Test-Path "eas.json") {
|
|
115
|
+
$content = Get-Content "eas.json" -Raw
|
|
116
|
+
$content = $content -replace 'com\.yourcompany\.yourapp', $BUNDLE_ID
|
|
117
|
+
Set-Content "eas.json" $content -NoNewline
|
|
118
|
+
Write-Success "Updated eas.json"
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# Create .env from .env.example
|
|
122
|
+
if ((Test-Path ".env.example") -and !(Test-Path ".env")) {
|
|
123
|
+
Copy-Item ".env.example" ".env"
|
|
124
|
+
Write-Success "Created .env from .env.example"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
# Initialize git if not already
|
|
128
|
+
if (!(Test-Path ".git")) {
|
|
129
|
+
Write-Step "Initializing git repository..."
|
|
130
|
+
git init
|
|
131
|
+
Write-Success "Initialized git repository"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
# Install dependencies
|
|
135
|
+
Write-Step "Installing dependencies..."
|
|
136
|
+
npm install --legacy-peer-deps
|
|
137
|
+
Write-Success "Dependencies installed"
|
|
138
|
+
|
|
139
|
+
# Run type check
|
|
140
|
+
Write-Step "Running type check..."
|
|
141
|
+
try {
|
|
142
|
+
npm run typecheck
|
|
143
|
+
Write-Success "Type check passed"
|
|
144
|
+
} catch {
|
|
145
|
+
Write-Warning "Type check had issues - you may need to fix some types"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# Summary
|
|
149
|
+
Write-Host ""
|
|
150
|
+
Write-Host "╔════════════════════════════════════════════════════════════╗" -ForegroundColor Green
|
|
151
|
+
Write-Host "║ Setup Complete! 🎉 ║" -ForegroundColor Green
|
|
152
|
+
Write-Host "╚════════════════════════════════════════════════════════════╝" -ForegroundColor Green
|
|
153
|
+
Write-Host ""
|
|
154
|
+
Write-Host "Next steps:"
|
|
155
|
+
Write-Host ""
|
|
156
|
+
Write-Host " 1. Review and update your .env file"
|
|
157
|
+
Write-Host " 2. Run 'npx expo start' to start development"
|
|
158
|
+
Write-Host " 3. Configure Sentry DSN in .env for crash reporting"
|
|
159
|
+
Write-Host " 4. Set up EAS Build: 'eas build:configure'"
|
|
160
|
+
Write-Host ""
|
|
161
|
+
Write-Host "Happy coding! 🚀"
|
|
162
|
+
Write-Host ""
|
package/scripts/init.sh
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Template Initialization Script
|
|
5
|
+
# =============================================================================
|
|
6
|
+
# This script customizes the template for a new project
|
|
7
|
+
#
|
|
8
|
+
# Usage: ./scripts/init.sh
|
|
9
|
+
# =============================================================================
|
|
10
|
+
|
|
11
|
+
set -e
|
|
12
|
+
|
|
13
|
+
# Colors for output
|
|
14
|
+
RED='\033[0;31m'
|
|
15
|
+
GREEN='\033[0;32m'
|
|
16
|
+
YELLOW='\033[1;33m'
|
|
17
|
+
BLUE='\033[0;34m'
|
|
18
|
+
NC='\033[0m' # No Color
|
|
19
|
+
|
|
20
|
+
# Print with color
|
|
21
|
+
print_step() {
|
|
22
|
+
echo -e "${BLUE}==>${NC} $1"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
print_success() {
|
|
26
|
+
echo -e "${GREEN}✓${NC} $1"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
print_warning() {
|
|
30
|
+
echo -e "${YELLOW}⚠${NC} $1"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
print_error() {
|
|
34
|
+
echo -e "${RED}✗${NC} $1"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Header
|
|
38
|
+
echo ""
|
|
39
|
+
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
|
|
40
|
+
echo -e "${BLUE}║${NC} React Native Template Initialization ${BLUE}║${NC}"
|
|
41
|
+
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
|
|
42
|
+
echo ""
|
|
43
|
+
|
|
44
|
+
# Get project info from user
|
|
45
|
+
read -p "$(echo -e ${BLUE}Enter app name ${NC}[e.g., MyAwesomeApp]: )" APP_NAME
|
|
46
|
+
if [ -z "$APP_NAME" ]; then
|
|
47
|
+
print_error "App name is required"
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
read -p "$(echo -e ${BLUE}Enter bundle identifier ${NC}[e.g., com.yourcompany.myapp]: )" BUNDLE_ID
|
|
52
|
+
if [ -z "$BUNDLE_ID" ]; then
|
|
53
|
+
print_error "Bundle identifier is required"
|
|
54
|
+
exit 1
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
read -p "$(echo -e ${BLUE}Enter app scheme ${NC}[e.g., myapp]: )" APP_SCHEME
|
|
58
|
+
if [ -z "$APP_SCHEME" ]; then
|
|
59
|
+
# Default to lowercase app name
|
|
60
|
+
APP_SCHEME=$(echo "$APP_NAME" | tr '[:upper:]' '[:lower:]' | tr -d ' ')
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
read -p "$(echo -e ${BLUE}Enter company/author name ${NC}[e.g., Your Company]: )" COMPANY_NAME
|
|
64
|
+
if [ -z "$COMPANY_NAME" ]; then
|
|
65
|
+
COMPANY_NAME="Your Company"
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
echo ""
|
|
69
|
+
print_step "Configuring project with:"
|
|
70
|
+
echo " App Name: $APP_NAME"
|
|
71
|
+
echo " Bundle ID: $BUNDLE_ID"
|
|
72
|
+
echo " Scheme: $APP_SCHEME"
|
|
73
|
+
echo " Company: $COMPANY_NAME"
|
|
74
|
+
echo ""
|
|
75
|
+
|
|
76
|
+
# Confirm
|
|
77
|
+
read -p "$(echo -e ${YELLOW}Proceed with these settings? ${NC}[y/N]: )" CONFIRM
|
|
78
|
+
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
|
|
79
|
+
print_warning "Cancelled"
|
|
80
|
+
exit 0
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
echo ""
|
|
84
|
+
print_step "Updating configuration files..."
|
|
85
|
+
|
|
86
|
+
# Update package.json
|
|
87
|
+
if [ -f "package.json" ]; then
|
|
88
|
+
# Create lowercase slug from app name
|
|
89
|
+
APP_SLUG=$(echo "$APP_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
|
90
|
+
|
|
91
|
+
if command -v jq &> /dev/null; then
|
|
92
|
+
# Use jq if available
|
|
93
|
+
jq --arg name "$APP_SLUG" '.name = $name' package.json > tmp.json && mv tmp.json package.json
|
|
94
|
+
else
|
|
95
|
+
# Fallback to sed
|
|
96
|
+
sed -i.bak "s/\"name\": \"react-native-template\"/\"name\": \"$APP_SLUG\"/g" package.json
|
|
97
|
+
rm -f package.json.bak
|
|
98
|
+
fi
|
|
99
|
+
print_success "Updated package.json"
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
# Update app.config.ts
|
|
103
|
+
if [ -f "app.config.ts" ]; then
|
|
104
|
+
sed -i.bak "s/YourApp/$APP_NAME/g" app.config.ts
|
|
105
|
+
sed -i.bak "s/yourapp/$APP_SCHEME/g" app.config.ts
|
|
106
|
+
sed -i.bak "s/com\.yourcompany\.yourapp/$BUNDLE_ID/g" app.config.ts
|
|
107
|
+
rm -f app.config.ts.bak
|
|
108
|
+
print_success "Updated app.config.ts"
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Update constants/config.ts
|
|
112
|
+
if [ -f "constants/config.ts" ]; then
|
|
113
|
+
sed -i.bak "s/YourApp/$APP_NAME/g" constants/config.ts
|
|
114
|
+
sed -i.bak "s/yourapp/$APP_SCHEME/g" constants/config.ts
|
|
115
|
+
rm -f constants/config.ts.bak
|
|
116
|
+
print_success "Updated constants/config.ts"
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
# Update eas.json
|
|
120
|
+
if [ -f "eas.json" ]; then
|
|
121
|
+
sed -i.bak "s/com\.yourcompany\.yourapp/$BUNDLE_ID/g" eas.json
|
|
122
|
+
rm -f eas.json.bak
|
|
123
|
+
print_success "Updated eas.json"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
# Create .env from .env.example
|
|
127
|
+
if [ -f ".env.example" ] && [ ! -f ".env" ]; then
|
|
128
|
+
cp .env.example .env
|
|
129
|
+
print_success "Created .env from .env.example"
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
# Initialize git if not already
|
|
133
|
+
if [ ! -d ".git" ]; then
|
|
134
|
+
print_step "Initializing git repository..."
|
|
135
|
+
git init
|
|
136
|
+
print_success "Initialized git repository"
|
|
137
|
+
fi
|
|
138
|
+
|
|
139
|
+
# Install dependencies
|
|
140
|
+
print_step "Installing dependencies..."
|
|
141
|
+
if command -v bun &> /dev/null; then
|
|
142
|
+
bun install
|
|
143
|
+
elif command -v pnpm &> /dev/null; then
|
|
144
|
+
pnpm install
|
|
145
|
+
elif command -v yarn &> /dev/null; then
|
|
146
|
+
yarn install
|
|
147
|
+
else
|
|
148
|
+
npm install --legacy-peer-deps
|
|
149
|
+
fi
|
|
150
|
+
print_success "Dependencies installed"
|
|
151
|
+
|
|
152
|
+
# Run type check
|
|
153
|
+
print_step "Running type check..."
|
|
154
|
+
if npm run typecheck 2>/dev/null; then
|
|
155
|
+
print_success "Type check passed"
|
|
156
|
+
else
|
|
157
|
+
print_warning "Type check had issues - you may need to fix some types"
|
|
158
|
+
fi
|
|
159
|
+
|
|
160
|
+
# Summary
|
|
161
|
+
echo ""
|
|
162
|
+
echo -e "${GREEN}╔════════════════════════════════════════════════════════════╗${NC}"
|
|
163
|
+
echo -e "${GREEN}║${NC} Setup Complete! 🎉 ${GREEN}║${NC}"
|
|
164
|
+
echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}"
|
|
165
|
+
echo ""
|
|
166
|
+
echo "Next steps:"
|
|
167
|
+
echo ""
|
|
168
|
+
echo " 1. Review and update your .env file"
|
|
169
|
+
echo " 2. Run 'npx expo start' to start development"
|
|
170
|
+
echo " 3. Configure Sentry DSN in .env for crash reporting"
|
|
171
|
+
echo " 4. Set up EAS Build: 'eas build:configure'"
|
|
172
|
+
echo ""
|
|
173
|
+
echo "Happy coding! 🚀"
|
|
174
|
+
echo ""
|