create-ern-boilerplate 0.0.17 → 0.0.18

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.
Files changed (62) hide show
  1. package/package.json +1 -1
  2. package/templates/improved/README.md +274 -0
  3. package/templates/improved/app/(admin)/profile.tsx +589 -0
  4. package/templates/improved/app/(admin)/user-management.tsx +604 -0
  5. package/templates/improved/app/(auth)/_layout.tsx +25 -0
  6. package/templates/improved/app/(auth)/login.tsx +782 -0
  7. package/templates/improved/app/(auth)/register.tsx +547 -0
  8. package/templates/improved/app/(protected)/_layout.tsx +91 -0
  9. package/templates/improved/app/(protected)/home.tsx +665 -0
  10. package/templates/improved/app/(protected)/settings.tsx +332 -0
  11. package/templates/improved/app/_layout.tsx +24 -0
  12. package/templates/improved/app.json +58 -0
  13. package/templates/improved/babel.config.js +29 -0
  14. package/templates/improved/global.css +3 -0
  15. package/templates/improved/metro.config.js +6 -0
  16. package/templates/improved/nativewind-env.d.ts +3 -0
  17. package/templates/improved/package.json +54 -0
  18. package/templates/improved/server/db.json +78 -0
  19. package/templates/improved/src/assets/images/adaptive-icon.png +0 -0
  20. package/templates/improved/src/assets/images/favicon.png +0 -0
  21. package/templates/improved/src/assets/images/icon.png +0 -0
  22. package/templates/improved/src/assets/images/splash-icon.png +0 -0
  23. package/templates/improved/src/components/auth/ProtectedRoute.tsx +105 -0
  24. package/templates/improved/src/components/common/Button.tsx +70 -0
  25. package/templates/improved/src/components/common/Card.tsx +32 -0
  26. package/templates/improved/src/components/common/Input.tsx +75 -0
  27. package/templates/improved/src/components/common/Loading.tsx +41 -0
  28. package/templates/improved/src/components/config/ToastConfig.tsx +109 -0
  29. package/templates/improved/src/components/header/AppHeader.tsx +160 -0
  30. package/templates/improved/src/components/shared/ConfirmDialog.tsx +151 -0
  31. package/templates/improved/src/components/shared/FormInput.tsx +67 -0
  32. package/templates/improved/src/components/shared/LucideIcon.tsx +18 -0
  33. package/templates/improved/src/components/shared/RoleSelector.tsx +63 -0
  34. package/templates/improved/src/components/users/EmptyState.tsx +70 -0
  35. package/templates/improved/src/components/users/ErrorState.tsx +64 -0
  36. package/templates/improved/src/components/users/FilterModal.tsx +264 -0
  37. package/templates/improved/src/components/users/UserCard.tsx +230 -0
  38. package/templates/improved/src/components/users/UserFormModal.tsx +230 -0
  39. package/templates/improved/src/contexts/AuthContext.tsx +93 -0
  40. package/templates/improved/src/contexts/ThemeContext.tsx +56 -0
  41. package/templates/improved/src/hooks/useAuth.ts +12 -0
  42. package/templates/improved/src/hooks/useTheme.ts +12 -0
  43. package/templates/improved/src/hooks/useUsers.ts +261 -0
  44. package/templates/improved/src/services/api.ts +97 -0
  45. package/templates/improved/src/services/authService.ts +42 -0
  46. package/templates/improved/src/services/mockApi/auth.mock.ts +89 -0
  47. package/templates/improved/src/services/mockApi/categories.mock.ts +75 -0
  48. package/templates/improved/src/services/mockApi/index.ts +79 -0
  49. package/templates/improved/src/services/mockApi/products.mock.ts +125 -0
  50. package/templates/improved/src/services/mockApi/users.mock.ts +83 -0
  51. package/templates/improved/src/services/productService.ts +143 -0
  52. package/templates/improved/src/services/userServices.ts +49 -0
  53. package/templates/improved/src/theme/colors.ts +32 -0
  54. package/templates/improved/src/types/api.types.ts +28 -0
  55. package/templates/improved/src/types/auth.types.ts +38 -0
  56. package/templates/improved/src/types/product.types.ts +49 -0
  57. package/templates/improved/src/types/user.types.ts +40 -0
  58. package/templates/improved/src/utils/constants.ts +47 -0
  59. package/templates/improved/src/utils/storage.ts +73 -0
  60. package/templates/improved/src/utils/validation.ts +54 -0
  61. package/templates/improved/tailwind.config.js +33 -0
  62. package/templates/improved/tsconfig.json +57 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ern-boilerplate",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Expo React Native boilerplate generator",
5
5
  "bin": {
6
6
  "create-ern-boilerplate": "./create.js",
@@ -0,0 +1,274 @@
1
+ # Expo React Native Boilerplate
2
+
3
+ A comprehensive boilerplate for building React Native applications with Expo, featuring authentication, theming, and a clean architecture.
4
+
5
+ ## Features
6
+
7
+ - ✅ **Expo Router** - File-based routing
8
+ - ✅ **TypeScript** - Type-safe development
9
+ - ✅ **NativeWind (Tailwind CSS)** - Utility-first styling
10
+ - ✅ **Authentication Context** - Global auth state management
11
+ - ✅ **Theme Support** - Light/Dark mode with system preference
12
+ - ✅ **Mock API Server** - JSON Server for development
13
+ - ✅ **Secure Storage** - Expo SecureStore for sensitive data
14
+ - ✅ **Path Aliases** - Clean imports with `@` prefix
15
+ - ✅ **Form Validation** - Built-in validation utilities
16
+ - ✅ **Reusable Components** - Button, Input, Card, Loading, etc.
17
+
18
+ ## Project Structure
19
+
20
+ ```
21
+ .
22
+ ├── app
23
+ │ ├── (admin) # Halaman & route khusus admin
24
+ │ ├── (auth) # Halaman auth (login, register, dsb)
25
+ │ ├── (protected) # Halaman yang membutuhkan autentikasi
26
+ │ └── _layout.tsx # Root layout untuk Expo Router
27
+
28
+ ├── server
29
+ │ ├── db.json # Mock data untuk JSON Server
30
+
31
+ ├── src
32
+ │ ├── assets # Gambar, font, dan aset statis
33
+ │ ├── components # Komponen UI reusable
34
+ │ ├── contexts # Context API (Auth, Theme, dsb)
35
+ │ ├── hooks # Custom React hooks
36
+ │ ├── services # API service (Axios, interceptors, dll)
37
+ │ ├── theme # Konfigurasi tema (warna, dark mode)
38
+ │ ├── types # TypeScript type definitions
39
+ │ └── utils # Helper functions & constants
40
+
41
+ ├── app.json # Konfigurasi Expo project
42
+ ├── babel.config.js # Konfigurasi Babel
43
+ ├── expo-env.d.ts # Type definitions untuk Expo environment
44
+ ├── global.css # Global style untuk Tailwind / NativeWind
45
+ ├── index.ts # Entry point utama aplikasi
46
+ ├── LICENSE # Lisensi project
47
+ ├── metro.config.js # Konfigurasi Metro bundler
48
+ ├── nativewind-env.d.ts # Type support untuk NativeWind
49
+ ├── package.json # Dependency & script project
50
+ ├── package-lock.json # Lock file npm
51
+ ├── README.md # Dokumentasi project
52
+ ├── structure.txt # Struktur folder (auto-generated)
53
+ ├── tailwind.config.js # Konfigurasi TailwindCSS
54
+ └── tsconfig.json # Konfigurasi TypeScript
55
+
56
+ ```
57
+
58
+ ## Getting Started
59
+
60
+ ### Prerequisites
61
+
62
+ - Node.js 18+
63
+ - npm or yarn
64
+ - Expo CLI
65
+
66
+ ### Installation
67
+
68
+ 1. Clone the repository:
69
+ ```bash
70
+ git clone <your-repo-url>
71
+ cd <your-repo-folder>
72
+ ```
73
+
74
+ 2. Install dependencies:
75
+ ```bash
76
+ npm install
77
+ ```
78
+
79
+ 3. Start the development server:
80
+ ```bash
81
+ npm run start
82
+ ```
83
+
84
+ This will start both the Expo development server and the mock API server.
85
+
86
+ ### Available Scripts
87
+
88
+ - `npm start` - Start Expo development server
89
+ - `npm run android` - Run on Android
90
+ - `npm run ios` - Run on iOS
91
+ - `npm run web` - Run on web
92
+ - `npm run lint` - Run ESLint
93
+ - `npm run type-check` - Run TypeScript type checking
94
+
95
+ ## Configuration
96
+
97
+ ### API Configuration
98
+
99
+ Edit `src/utils/constants.ts` to configure your API endpoints:
100
+
101
+ ```typescript
102
+ export const API_CONFIG = {
103
+ BASE_URL: __DEV__ ? 'http://localhost:3001' : 'https://api.yourapp.com',
104
+ TIMEOUT: 10000,
105
+ };
106
+ ```
107
+
108
+ ### Theme Configuration
109
+
110
+ Customize colors in `src/theme/colors.ts`:
111
+
112
+ ```typescript
113
+ export const colors = {
114
+ light: {
115
+ primary: '#3b82f6',
116
+ // ... other colors
117
+ },
118
+ dark: {
119
+ primary: '#3b82f6',
120
+ // ... other colors
121
+ },
122
+ };
123
+ ```
124
+
125
+ ## Authentication
126
+
127
+ The boilerplate includes a complete authentication flow:
128
+
129
+ ### Default Credentials
130
+
131
+ - **Admin**: developer@localhost.com / @developer
132
+ - **User**: user@localhost.com / @developer
133
+
134
+ ### Using Authentication
135
+
136
+ ```typescript
137
+ import { useAuth } from '@hooks/useAuth';
138
+
139
+ function MyComponent() {
140
+ const { user, login, logout, isAuthenticated } = useAuth();
141
+
142
+ // Use authentication methods
143
+ }
144
+ ```
145
+
146
+ ## Theming
147
+
148
+ Switch between light and dark themes:
149
+
150
+ ```typescript
151
+ import { useTheme } from '@hooks/useTheme';
152
+
153
+ function MyComponent() {
154
+ const { theme, colors, setThemeMode } = useTheme();
155
+
156
+ // theme: 'light' | 'dark'
157
+ // colors: current theme colors
158
+ // setThemeMode: 'light' | 'dark' | 'auto'
159
+ }
160
+ ```
161
+
162
+ ## API Services
163
+
164
+ ### Making API Calls
165
+
166
+ ```typescript
167
+ import { newsService } from '@services/newsService';
168
+
169
+ // Get all news
170
+ const news = await newsService.getNews({ limit: 10 });
171
+
172
+ // Get single news item
173
+ const newsItem = await newsService.getNewsById('1');
174
+
175
+ // Create news
176
+ const newNews = await newsService.createNews({
177
+ title: 'New Article',
178
+ content: 'Content here',
179
+ // ...
180
+ });
181
+ ```
182
+
183
+ ## Custom Hooks
184
+
185
+ ### useAuth
186
+
187
+ Access authentication state and methods.
188
+
189
+ ### useTheme
190
+
191
+ Access theme configuration and toggle themes.
192
+
193
+ ## Components
194
+
195
+ ### Button
196
+
197
+ ```typescript
198
+ <Button
199
+ title="Click Me"
200
+ variant="primary"
201
+ size="md"
202
+ onPress={() => {}}
203
+ loading={false}
204
+ fullWidth
205
+ />
206
+ ```
207
+
208
+ ### Input
209
+
210
+ ```typescript
211
+ <Input
212
+ label="Email"
213
+ placeholder="Enter email"
214
+ value={email}
215
+ onChangeText={setEmail}
216
+ error={emailError}
217
+ secureTextEntry
218
+ />
219
+ ```
220
+
221
+ ### Card
222
+
223
+ ```typescript
224
+ <Card className="mb-4">
225
+ <Text>Card content</Text>
226
+ </Card>
227
+ ```
228
+
229
+ ### Loading
230
+
231
+ ```typescript
232
+ <Loading text="Loading..." fullScreen />
233
+ ```
234
+
235
+ ## Path Aliases
236
+
237
+ Use clean imports with configured path aliases:
238
+
239
+ ```typescript
240
+ import { Button } from '@components/common/Button';
241
+ import { useAuth } from '@hooks/useAuth';
242
+ import { newsService } from '@services/newsService';
243
+ ```
244
+
245
+ ## Deployment
246
+
247
+ ### Building for Production
248
+
249
+ ```bash
250
+ # For Android
251
+ eas build --platform android
252
+
253
+ # For iOS
254
+ eas build --platform ios
255
+
256
+ # For both
257
+ eas build --platform all
258
+ ```
259
+
260
+ ## Contributing
261
+
262
+ 1. Fork the repository
263
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
264
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
265
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
266
+ 5. Open a Pull Request
267
+
268
+ ## License
269
+
270
+ MIT License - feel free to use this boilerplate for your projects!
271
+
272
+ ## Support
273
+
274
+ For issues and questions, please open an issue on GitHub.