create-ern-boilerplate 0.0.22 → 0.0.24
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/create.js +40 -0
- package/package.json +1 -1
- package/templates/default/.clinerules +161 -0
- package/templates/default/ARCHITECTURE.md +754 -0
- package/templates/default/EXAMPLES.md +1132 -0
- package/templates/default/PROJECT_CONTEXT.md +399 -0
- package/templates/default/README.md +116 -9
- package/templates/default/app.prod.json +60 -0
- package/templates/default/app.staging.json +60 -0
- package/templates/default/eas.json +42 -0
- package/templates/default/package.json +29 -7
- package/templates/default/src/services/authService.ts +3 -0
- package/templates/default/src/utils/constants.ts +3 -2
package/create.js
CHANGED
|
@@ -138,6 +138,46 @@ async function main() {
|
|
|
138
138
|
await fs.writeJson(appJsonPath, appJson, { spaces: 2 });
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
// === Update app.staging.json ===
|
|
142
|
+
const appJsonPathStaging = path.join(targetDir, "app.staging.json");
|
|
143
|
+
if (fs.existsSync(appJsonPathStaging)) {
|
|
144
|
+
const appJsonStaging = await fs.readJson(appJsonPathStaging);
|
|
145
|
+
appJsonStaging.expo = appJsonStaging.expo || {};
|
|
146
|
+
appJsonStaging.expo.name = projectName;
|
|
147
|
+
appJsonStaging.expo.slug = projectName.toLowerCase().replace(/\s+/g, "-");
|
|
148
|
+
appJsonStaging.expo.ios = appJsonStaging.expo.ios || {};
|
|
149
|
+
appJsonStaging.expo.android = appJsonStaging.expo.android || {};
|
|
150
|
+
appJsonStaging.expo.ios.bundleIdentifier = `com.${projectName.toLowerCase()}.app`;
|
|
151
|
+
appJsonStaging.expo.android.package = `com.${projectName.toLowerCase()}.app`;
|
|
152
|
+
appJsonStaging.expo.scheme = projectName.toLowerCase();
|
|
153
|
+
if (appJsonStaging.expo.extra && appJsonStaging.expo.extra.eas) {
|
|
154
|
+
appJsonStaging.expo.extra.eas.projectId = "";
|
|
155
|
+
}
|
|
156
|
+
appJsonStaging.expo.extra.ENV = "staging";
|
|
157
|
+
appJsonStaging.expo.extra.BASE_URL = "";
|
|
158
|
+
await fs.writeJson(appJsonPathStaging, appJsonStaging, { spaces: 2 });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// === Update app.prod.json ===
|
|
162
|
+
const appJsonPathProd = path.join(targetDir, "app.prod.json");
|
|
163
|
+
if (fs.existsSync(appJsonPathProd)) {
|
|
164
|
+
const appJsonProd = await fs.readJson(appJsonPathProd);
|
|
165
|
+
appJsonProd.expo = appJsonProd.expo || {};
|
|
166
|
+
appJsonProd.expo.name = projectName;
|
|
167
|
+
appJsonProd.expo.slug = projectName.toLowerCase().replace(/\s+/g, "-");
|
|
168
|
+
appJsonProd.expo.ios = appJsonProd.expo.ios || {};
|
|
169
|
+
appJsonProd.expo.android = appJsonProd.expo.android || {};
|
|
170
|
+
appJsonProd.expo.ios.bundleIdentifier = `com.${projectName.toLowerCase()}.app`;
|
|
171
|
+
appJsonProd.expo.android.package = `com.${projectName.toLowerCase()}.app`;
|
|
172
|
+
appJsonProd.expo.scheme = projectName.toLowerCase();
|
|
173
|
+
if (appJsonProd.expo.extra && appJsonProd.expo.extra.eas) {
|
|
174
|
+
appJsonProd.expo.extra.eas.projectId = "";
|
|
175
|
+
}
|
|
176
|
+
appJsonProd.expo.extra.ENV = "production";
|
|
177
|
+
appJsonProd.expo.extra.BASE_URL = "";
|
|
178
|
+
await fs.writeJson(appJsonPathProd, appJsonProd, { spaces: 2 });
|
|
179
|
+
}
|
|
180
|
+
|
|
141
181
|
spinner.succeed(`✅ Template "${templateName}" berhasil dibuat!`);
|
|
142
182
|
} catch (err) {
|
|
143
183
|
spinner.fail("❌ Terjadi kesalahan saat membuat project.");
|
package/package.json
CHANGED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Claude Code AI Agent Rules for Expo Boilerplate
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
This is an Expo React Native boilerplate with TypeScript, NativeWind (Tailwind CSS), authentication, and theming support.
|
|
5
|
+
|
|
6
|
+
## Key Technologies
|
|
7
|
+
- **Framework**: Expo ~54.0.0 with Expo Router for file-based routing
|
|
8
|
+
- **Language**: TypeScript 5.9+
|
|
9
|
+
- **Styling**: NativeWind 4.0 (Tailwind CSS for React Native)
|
|
10
|
+
- **State Management**: React Context API (AuthContext, ThemeContext)
|
|
11
|
+
- **HTTP Client**: Axios with custom interceptors
|
|
12
|
+
- **Storage**: Expo SecureStore for sensitive data
|
|
13
|
+
- **UI Components**: Custom reusable components with LucideIcon integration
|
|
14
|
+
|
|
15
|
+
## Code Style & Standards
|
|
16
|
+
|
|
17
|
+
### TypeScript
|
|
18
|
+
- Use strict TypeScript settings
|
|
19
|
+
- Define types in `src/types/` directory
|
|
20
|
+
- Use interface for component props
|
|
21
|
+
- Use type for union types and API responses
|
|
22
|
+
- Avoid `any` type - use `unknown` if necessary
|
|
23
|
+
|
|
24
|
+
### Component Structure
|
|
25
|
+
- Use functional components with hooks
|
|
26
|
+
- Prefer arrow function syntax for components
|
|
27
|
+
- Use React.FC only when explicitly needed
|
|
28
|
+
- Place component files in appropriate directories:
|
|
29
|
+
- `src/components/common/` - Generic UI components (Button, Input, Card)
|
|
30
|
+
- `src/components/shared/` - Shared business components (ConfirmDialog, FormInput)
|
|
31
|
+
- `src/components/auth/` - Authentication-related components
|
|
32
|
+
- `src/components/users/` - User-specific components
|
|
33
|
+
|
|
34
|
+
### Styling Guidelines
|
|
35
|
+
- Use NativeWind utility classes for styling
|
|
36
|
+
- Access theme colors via `useTheme()` hook
|
|
37
|
+
- Use `className` prop for NativeWind styling
|
|
38
|
+
- Avoid inline styles unless dynamic
|
|
39
|
+
- Follow Tailwind naming conventions
|
|
40
|
+
|
|
41
|
+
### Path Aliases
|
|
42
|
+
Always use configured path aliases:
|
|
43
|
+
- `@/` - src root
|
|
44
|
+
- `@components/` - src/components
|
|
45
|
+
- `@services/` - src/services
|
|
46
|
+
- `@types/` - src/types
|
|
47
|
+
- `@utils/` - src/utils
|
|
48
|
+
- `@contexts/` - src/contexts
|
|
49
|
+
- `@hooks/` - src/hooks
|
|
50
|
+
- `@theme/` - src/theme
|
|
51
|
+
- `@assets/` - src/assets
|
|
52
|
+
|
|
53
|
+
### File Naming
|
|
54
|
+
- Components: PascalCase (e.g., `UserCard.tsx`, `Button.tsx`)
|
|
55
|
+
- Hooks: camelCase with 'use' prefix (e.g., `useAuth.ts`)
|
|
56
|
+
- Services: camelCase with 'Service' suffix (e.g., `authService.ts`)
|
|
57
|
+
- Types: camelCase with '.types' suffix (e.g., `user.types.ts`)
|
|
58
|
+
- Utils: camelCase (e.g., `validation.ts`, `constants.ts`)
|
|
59
|
+
|
|
60
|
+
## Architecture Patterns
|
|
61
|
+
|
|
62
|
+
### Authentication
|
|
63
|
+
- Use `AuthContext` for global auth state
|
|
64
|
+
- Access via `useAuth()` hook
|
|
65
|
+
- Protected routes use `ProtectedRoute` wrapper
|
|
66
|
+
- Token stored in SecureStore
|
|
67
|
+
- Auto-inject token in API requests via interceptor
|
|
68
|
+
|
|
69
|
+
### API Services
|
|
70
|
+
- All API calls go through `src/services/api.ts`
|
|
71
|
+
- Service files in `src/services/` (e.g., `authService.ts`, `userService.ts`)
|
|
72
|
+
- Use generic `api.get<T>()`, `api.post<T>()` methods
|
|
73
|
+
- Error handling via Axios interceptors
|
|
74
|
+
- Mock data available in `src/services/mockApi/`
|
|
75
|
+
|
|
76
|
+
### Routing
|
|
77
|
+
- File-based routing with Expo Router
|
|
78
|
+
- Route groups:
|
|
79
|
+
- `app/(auth)/` - Authentication screens (login, register)
|
|
80
|
+
- `app/(protected)/` - Authenticated user screens
|
|
81
|
+
- `app/(admin)/` - Admin-only screens
|
|
82
|
+
- Use `router.push()`, `router.replace()` for navigation
|
|
83
|
+
|
|
84
|
+
### Theme System
|
|
85
|
+
- Use `ThemeContext` for theme management
|
|
86
|
+
- Access via `useTheme()` hook
|
|
87
|
+
- Supports light/dark/auto modes
|
|
88
|
+
- Colors defined in `src/theme/colors.ts`
|
|
89
|
+
- Theme-aware components use `colors` from `useTheme()`
|
|
90
|
+
|
|
91
|
+
## Common Operations
|
|
92
|
+
|
|
93
|
+
### Adding a New Screen
|
|
94
|
+
1. Create file in appropriate route group under `app/`
|
|
95
|
+
2. Use `_layout.tsx` if custom layout needed
|
|
96
|
+
3. Wrap with `ProtectedRoute` if authentication required
|
|
97
|
+
4. Import and use theme colors via `useTheme()`
|
|
98
|
+
|
|
99
|
+
### Creating a New Component
|
|
100
|
+
1. Create file in `src/components/[category]/`
|
|
101
|
+
2. Define prop types interface
|
|
102
|
+
3. Use NativeWind for styling
|
|
103
|
+
4. Export as default or named export
|
|
104
|
+
5. Add to index file if needed
|
|
105
|
+
|
|
106
|
+
### Adding API Service
|
|
107
|
+
1. Define types in `src/types/`
|
|
108
|
+
2. Create service file in `src/services/`
|
|
109
|
+
3. Use `api` instance from `src/services/api.ts`
|
|
110
|
+
4. Add mock data in `src/services/mockApi/` if needed
|
|
111
|
+
5. Export service methods
|
|
112
|
+
|
|
113
|
+
### Creating Custom Hook
|
|
114
|
+
1. Create file in `src/hooks/`
|
|
115
|
+
2. Name with 'use' prefix
|
|
116
|
+
3. Follow React hooks rules
|
|
117
|
+
4. Export as named export
|
|
118
|
+
|
|
119
|
+
## Testing Credentials
|
|
120
|
+
- Admin: developer@localhost.com / @developer
|
|
121
|
+
- User: user@localhost.com / @developer
|
|
122
|
+
|
|
123
|
+
## Environment Configuration
|
|
124
|
+
- Development: Uses localhost:3001 for API
|
|
125
|
+
- Production: Configure in `src/utils/constants.ts`
|
|
126
|
+
- Multi-environment support: app.json, app.staging.json, app.prod.json
|
|
127
|
+
|
|
128
|
+
## Build Commands
|
|
129
|
+
- Development: `npm start`
|
|
130
|
+
- Type check: `npm run type-check`
|
|
131
|
+
- Lint: `npm run lint`
|
|
132
|
+
- Build (local): `npm run build`
|
|
133
|
+
- Staging build: `npm run build:staging`
|
|
134
|
+
- Production build: `npm run build:prod`
|
|
135
|
+
|
|
136
|
+
## Important Notes
|
|
137
|
+
- Always run type-check before committing
|
|
138
|
+
- Use Expo SecureStore for sensitive data only
|
|
139
|
+
- Handle loading states in components
|
|
140
|
+
- Show error messages via Toast
|
|
141
|
+
- Validate forms using `src/utils/validation.ts`
|
|
142
|
+
- Clean imports (remove unused)
|
|
143
|
+
- Follow React Native performance best practices
|
|
144
|
+
|
|
145
|
+
## Security Considerations
|
|
146
|
+
- Never log sensitive data
|
|
147
|
+
- Validate all user inputs
|
|
148
|
+
- Use SecureStore for tokens
|
|
149
|
+
- Implement proper error handling
|
|
150
|
+
- Don't expose API keys in code
|
|
151
|
+
- Use environment variables for configs
|
|
152
|
+
|
|
153
|
+
## When Adding Features
|
|
154
|
+
1. Check existing patterns first
|
|
155
|
+
2. Maintain consistent folder structure
|
|
156
|
+
3. Reuse existing components when possible
|
|
157
|
+
4. Add proper TypeScript types
|
|
158
|
+
5. Update relevant documentation
|
|
159
|
+
6. Test on both light and dark themes
|
|
160
|
+
7. Ensure responsive design
|
|
161
|
+
8. Handle loading and error states
|