create-aziz-app 2.0.15 → 3.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/README.md +3 -3
- package/bin/create-aziz-app.js +9 -9
- package/package.json +10 -11
- package/template/README.md +5 -5
- package/template/_framework/boot.js +3 -3
- package/template/_framework/hooks.js +1 -1
- package/template/{modules → _framework}/next-response.js +5 -13
- package/template/_framework/router.js +1 -1
- package/template/_framework/runtime.js +1 -1
- package/template/api/createUser.js +1 -1
- package/template/api/hello.js +1 -1
- package/template/api/loginUser.js +1 -1
- package/template/api/users.js +1 -1
- package/template/app/about/page.js +1 -1
- package/template/app/layout.js +1 -1
- package/template/components/Footer.js +1 -1
- package/template/components/Navbar.js +1 -1
- package/template/package.json +4 -7
- package/template/scripts/dev-server.js +1 -1
- package/template/.vscode/settings.json +0 -15
- package/template/api/getUser.js +0 -60
- package/template/api/getUserWithDB.js +0 -65
- package/template/app.config.js +0 -41
- package/template/app.html +0 -55
- package/template/components/Counter.jsx +0 -36
- package/template/components/Footer.jsx +0 -9
- package/template/components/Navbar.jsx +0 -17
- package/template/docs/API-GUIDE.md +0 -196
- package/template/docs/API-ROUTES.md +0 -538
- package/template/docs/AUTO-IMPORT.md +0 -99
- package/template/docs/AUTO-REGISTRATION.md +0 -248
- package/template/docs/CSS-FRAMEWORKS.md +0 -221
- package/template/docs/DEV-SERVER.md +0 -184
- package/template/docs/GETTING-STARTED.md +0 -205
- package/template/docs/HOW-IT-WORKS.md +0 -362
- package/template/docs/NEXTJS-APP-ROUTER.md +0 -536
- package/template/docs/NEXTJS-COMPARISON.md +0 -473
- package/template/docs/QUICK-START.md +0 -111
- package/template/docs/STYLING.md +0 -269
- package/template/docs/TROUBLESHOOTING.md +0 -282
- package/template/modules/README.md +0 -129
- package/template/modules/api.js +0 -44
- package/template/modules/auto-import.js +0 -130
- package/template/modules/router.js +0 -218
- package/template/modules/state.js +0 -248
- package/template/package-lock.json +0 -13
- package/template/pages/About.jsx +0 -48
- package/template/pages/ApiDemo.jsx +0 -209
- package/template/pages/Contact.jsx +0 -25
- package/template/pages/Example.jsx +0 -59
- package/template/pages/Home.jsx +0 -39
- package/template/pages/HooksDemo.jsx +0 -194
- package/template/pages/test.jsx +0 -72
- package/template/scripts/build.js +0 -81
- package/template/scripts/generate-imports.js +0 -88
- package/template/tailwind.config.js +0 -17
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
# How It Works
|
|
2
|
-
|
|
3
|
-
## System Architecture
|
|
4
|
-
|
|
5
|
-
Aziz App has three main systems working together:
|
|
6
|
-
|
|
7
|
-
1. **Auto-Import System** - Automatically generates script tags
|
|
8
|
-
2. **Live Reload System** - Automatically refreshes browser on changes
|
|
9
|
-
3. **Routing System** - File-based routing with auto-registration
|
|
10
|
-
|
|
11
|
-
## 1. Auto-Import System
|
|
12
|
-
|
|
13
|
-
### Files Involved:
|
|
14
|
-
- `scripts/generate-imports.js` - Scans folders and generates script tags
|
|
15
|
-
- `app.html` - Contains the generated script tags
|
|
16
|
-
- `app.config.js` - Configuration (auto-generated)
|
|
17
|
-
|
|
18
|
-
### How It Works:
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
1. Dev server starts
|
|
22
|
-
2. Runs generate-imports.js
|
|
23
|
-
3. Scans: api/, components/, pages/
|
|
24
|
-
4. Generates <script> tags for each file
|
|
25
|
-
5. Updates app.html (body section only)
|
|
26
|
-
6. Browser loads all scripts
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### What Gets Generated:
|
|
30
|
-
|
|
31
|
-
```html
|
|
32
|
-
<!-- Load core modules -->
|
|
33
|
-
<script type="text/babel" src="modules/router.js"></script>
|
|
34
|
-
<script type="text/babel" src="modules/state.js"></script>
|
|
35
|
-
<script type="text/babel" src="modules/api.js"></script>
|
|
36
|
-
|
|
37
|
-
<!-- Load API routes -->
|
|
38
|
-
<script type="text/babel" src="api/hello.js"></script>
|
|
39
|
-
|
|
40
|
-
<!-- Load shared components -->
|
|
41
|
-
<script type="text/babel" src="components/Navbar.jsx"></script>
|
|
42
|
-
|
|
43
|
-
<!-- Load pages -->
|
|
44
|
-
<script type="text/babel" src="pages/Home.jsx"></script>
|
|
45
|
-
|
|
46
|
-
<!-- Start the app -->
|
|
47
|
-
<script type="text/babel">
|
|
48
|
-
startApp();
|
|
49
|
-
</script>
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### When It Runs:
|
|
53
|
-
|
|
54
|
-
- **On server start** - Initial generation
|
|
55
|
-
- **On file change** - When .js/.jsx files are added/removed/renamed
|
|
56
|
-
- **Manual** - Run `npm run build`
|
|
57
|
-
|
|
58
|
-
### What It Doesn't Touch:
|
|
59
|
-
|
|
60
|
-
- `<head>` section - Styles, meta tags, live-reload script
|
|
61
|
-
- Files outside watched folders
|
|
62
|
-
- Non-.js/.jsx files
|
|
63
|
-
|
|
64
|
-
## 2. Live Reload System
|
|
65
|
-
|
|
66
|
-
### Files Involved:
|
|
67
|
-
- `scripts/live-reload-client.js` - Browser-side WebSocket client
|
|
68
|
-
- `scripts/dev-server.js` - Server-side WebSocket server + file watcher
|
|
69
|
-
- `app.html` - Loads the client script
|
|
70
|
-
|
|
71
|
-
### How It Works:
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
1. Browser loads app.html
|
|
75
|
-
2. app.html includes live-reload-client.js
|
|
76
|
-
3. Client creates WebSocket connection
|
|
77
|
-
4. Server watches: api/, components/, pages/, modules/, styles/
|
|
78
|
-
5. File changes detected
|
|
79
|
-
6. Server sends "reload" message via WebSocket
|
|
80
|
-
7. Client receives message
|
|
81
|
-
8. Browser reloads page
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Architecture:
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
┌─────────────┐ ┌─────────────┐
|
|
88
|
-
│ Browser │ │ Dev Server │
|
|
89
|
-
│ │ │ │
|
|
90
|
-
│ live- │ WebSocket │ File │
|
|
91
|
-
│ reload- │◄──────────────────►│ Watcher │
|
|
92
|
-
│ client.js │ "reload" message │ │
|
|
93
|
-
│ │ │ │
|
|
94
|
-
└─────────────┘ └─────────────┘
|
|
95
|
-
│ │
|
|
96
|
-
│ Reload page │ Detects changes
|
|
97
|
-
▼ ▼
|
|
98
|
-
app.html api/, pages/, etc.
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### Why WebSocket?
|
|
102
|
-
|
|
103
|
-
- **Reliable** - Bidirectional, persistent connection
|
|
104
|
-
- **Fast** - Instant notifications
|
|
105
|
-
- **Simple** - No external dependencies
|
|
106
|
-
- **No caching** - Script is always loaded, not injected
|
|
107
|
-
|
|
108
|
-
### Connection States:
|
|
109
|
-
|
|
110
|
-
1. **Connecting** (gray) - Initial connection
|
|
111
|
-
2. **Connected** (green) - Ready, watching for changes
|
|
112
|
-
3. **Reloading** (blue) - Change detected, reloading
|
|
113
|
-
4. **Disconnected** (orange) - Connection lost, reconnecting
|
|
114
|
-
5. **Offline** (red) - Max reconnection attempts reached
|
|
115
|
-
|
|
116
|
-
## 3. Routing System
|
|
117
|
-
|
|
118
|
-
### Files Involved:
|
|
119
|
-
- `modules/router.js` - Core routing engine
|
|
120
|
-
- `pages/*.jsx` - Page components
|
|
121
|
-
- `app.html` - Root element (#root)
|
|
122
|
-
|
|
123
|
-
### How It Works:
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
1. Browser loads all page files
|
|
127
|
-
2. Each page defines a function: HomePage(), AboutPage(), etc.
|
|
128
|
-
3. startApp() calls autoRegisterPages()
|
|
129
|
-
4. Scans window for functions ending with "Page"
|
|
130
|
-
5. Registers: HomePage → "home", AboutPage → "about"
|
|
131
|
-
6. URL hash changes: #/about
|
|
132
|
-
7. Router finds AboutPage() function
|
|
133
|
-
8. Renders it into #root
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Auto-Registration:
|
|
137
|
-
|
|
138
|
-
```javascript
|
|
139
|
-
// In pages/About.jsx
|
|
140
|
-
function AboutPage() {
|
|
141
|
-
return <div><h1>About</h1></div>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Router automatically does:
|
|
145
|
-
routes["about"] = AboutPage;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Manual Registration (Optional):
|
|
149
|
-
|
|
150
|
-
```javascript
|
|
151
|
-
// For custom route names
|
|
152
|
-
registerPage("user-profile", UserProfilePage);
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## How They Work Together
|
|
156
|
-
|
|
157
|
-
### Startup Sequence:
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
1. Run: npm run dev
|
|
161
|
-
2. Dev server starts
|
|
162
|
-
3. Runs generate-imports.js
|
|
163
|
-
4. Scans folders, updates app.html
|
|
164
|
-
5. Starts HTTP server on port 3000
|
|
165
|
-
6. Starts WebSocket server
|
|
166
|
-
7. Starts file watchers
|
|
167
|
-
8. Ready! ✅
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### Browser Load Sequence:
|
|
171
|
-
|
|
172
|
-
```
|
|
173
|
-
1. Browser requests http://localhost:3000/
|
|
174
|
-
2. Server sends app.html
|
|
175
|
-
3. Browser loads:
|
|
176
|
-
- styles/globals.css
|
|
177
|
-
- scripts/live-reload-client.js (connects to WebSocket)
|
|
178
|
-
- Babel standalone
|
|
179
|
-
- modules/router.js, state.js, api.js
|
|
180
|
-
- api/*.js
|
|
181
|
-
- components/*.jsx
|
|
182
|
-
- pages/*.jsx
|
|
183
|
-
4. Calls startApp()
|
|
184
|
-
5. Auto-registers pages
|
|
185
|
-
6. Renders current route
|
|
186
|
-
7. Done! ✅
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### File Change Sequence:
|
|
190
|
-
|
|
191
|
-
```
|
|
192
|
-
1. Developer edits pages/Home.jsx
|
|
193
|
-
2. File watcher detects change
|
|
194
|
-
3. Debounce timer starts (500ms)
|
|
195
|
-
4. Timer expires
|
|
196
|
-
5. Runs generate-imports.js
|
|
197
|
-
6. Updates app.html
|
|
198
|
-
7. Sends "reload" via WebSocket
|
|
199
|
-
8. Browser receives message
|
|
200
|
-
9. Browser reloads
|
|
201
|
-
10. New version loads
|
|
202
|
-
11. Done! ✅
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### CSS Change Sequence (Faster):
|
|
206
|
-
|
|
207
|
-
```
|
|
208
|
-
1. Developer edits styles/globals.css
|
|
209
|
-
2. File watcher detects change
|
|
210
|
-
3. Debounce timer starts (300ms)
|
|
211
|
-
4. Timer expires
|
|
212
|
-
5. Skips generate-imports (not needed for CSS)
|
|
213
|
-
6. Sends "reload" via WebSocket
|
|
214
|
-
7. Browser reloads
|
|
215
|
-
8. Done! ✅
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## File Organization
|
|
219
|
-
|
|
220
|
-
### What Goes Where:
|
|
221
|
-
|
|
222
|
-
```
|
|
223
|
-
template/
|
|
224
|
-
├── app.html # Main HTML (auto-generated scripts)
|
|
225
|
-
├── modules/ # Core system (don't modify)
|
|
226
|
-
│ ├── router.js # Routing + rendering
|
|
227
|
-
│ ├── state.js # State management
|
|
228
|
-
│ └── api.js # API system
|
|
229
|
-
├── scripts/ # Build tools (don't modify)
|
|
230
|
-
│ ├── dev-server.js # Dev server + WebSocket
|
|
231
|
-
│ ├── generate-imports.js # Auto-import generator
|
|
232
|
-
│ └── live-reload-client.js # Browser WebSocket client
|
|
233
|
-
├── api/ # Your API routes (auto-imported)
|
|
234
|
-
├── components/ # Your components (auto-imported)
|
|
235
|
-
├── pages/ # Your pages (auto-imported)
|
|
236
|
-
└── styles/ # Your styles (watched for changes)
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### What You Modify:
|
|
240
|
-
|
|
241
|
-
- ✅ `api/` - Add your API routes
|
|
242
|
-
- ✅ `components/` - Add your components
|
|
243
|
-
- ✅ `pages/` - Add your pages
|
|
244
|
-
- ✅ `styles/` - Add your styles
|
|
245
|
-
- ❌ `modules/` - Core system
|
|
246
|
-
- ❌ `scripts/` - Build tools
|
|
247
|
-
- ⚠️ `app.html` - Only modify `<head>` section
|
|
248
|
-
|
|
249
|
-
## Key Concepts
|
|
250
|
-
|
|
251
|
-
### 1. Auto-Import is Automatic
|
|
252
|
-
|
|
253
|
-
You don't need to:
|
|
254
|
-
- Add `<script>` tags manually
|
|
255
|
-
- Run build commands after creating files
|
|
256
|
-
- Restart the dev server
|
|
257
|
-
|
|
258
|
-
Just create a file and save it!
|
|
259
|
-
|
|
260
|
-
### 2. Live Reload is Always On
|
|
261
|
-
|
|
262
|
-
The `live-reload-client.js` script:
|
|
263
|
-
- Is always loaded (in `<head>`)
|
|
264
|
-
- Only runs on localhost
|
|
265
|
-
- Connects automatically
|
|
266
|
-
- Reconnects if disconnected
|
|
267
|
-
- Safe for production (does nothing)
|
|
268
|
-
|
|
269
|
-
### 3. Pages Auto-Register
|
|
270
|
-
|
|
271
|
-
You don't need to:
|
|
272
|
-
- Call `registerPage()` (optional)
|
|
273
|
-
- Import pages manually
|
|
274
|
-
- Configure routes
|
|
275
|
-
|
|
276
|
-
Just name your function `YourNamePage()` and it works!
|
|
277
|
-
|
|
278
|
-
### 4. Everything is Watched
|
|
279
|
-
|
|
280
|
-
The dev server watches:
|
|
281
|
-
- `api/` - API routes
|
|
282
|
-
- `components/` - Components
|
|
283
|
-
- `pages/` - Pages
|
|
284
|
-
- `modules/` - Core modules
|
|
285
|
-
- `styles/` - Stylesheets
|
|
286
|
-
|
|
287
|
-
Changes trigger:
|
|
288
|
-
- Import regeneration (for .js/.jsx)
|
|
289
|
-
- Browser reload (for everything)
|
|
290
|
-
|
|
291
|
-
## Performance Optimizations
|
|
292
|
-
|
|
293
|
-
### 1. Debouncing
|
|
294
|
-
|
|
295
|
-
Prevents multiple rapid reloads:
|
|
296
|
-
- CSS changes: 300ms delay
|
|
297
|
-
- JS/JSX changes: 500ms delay
|
|
298
|
-
|
|
299
|
-
### 2. Selective Regeneration
|
|
300
|
-
|
|
301
|
-
- CSS changes: Skip import generation
|
|
302
|
-
- JS/JSX changes: Regenerate imports
|
|
303
|
-
|
|
304
|
-
### 3. WebSocket Efficiency
|
|
305
|
-
|
|
306
|
-
- Single persistent connection
|
|
307
|
-
- Minimal message size ("reload")
|
|
308
|
-
- Automatic cleanup on disconnect
|
|
309
|
-
|
|
310
|
-
### 4. Smart Watching
|
|
311
|
-
|
|
312
|
-
- Only watches specific folders
|
|
313
|
-
- Ignores non-code files
|
|
314
|
-
- Recursive: false (performance)
|
|
315
|
-
|
|
316
|
-
## Troubleshooting
|
|
317
|
-
|
|
318
|
-
### Import Generation Issues
|
|
319
|
-
|
|
320
|
-
**Problem:** New file not showing up
|
|
321
|
-
|
|
322
|
-
**Check:**
|
|
323
|
-
1. File is in `api/`, `components/`, or `pages/`
|
|
324
|
-
2. File ends with `.js` or `.jsx`
|
|
325
|
-
3. Dev server is running
|
|
326
|
-
4. Check terminal for errors
|
|
327
|
-
|
|
328
|
-
**Solution:** Run `npm run build` manually
|
|
329
|
-
|
|
330
|
-
### Live Reload Issues
|
|
331
|
-
|
|
332
|
-
**Problem:** Changes not showing
|
|
333
|
-
|
|
334
|
-
**Check:**
|
|
335
|
-
1. Indicator is green (✅ Live Reload)
|
|
336
|
-
2. Dev server is running
|
|
337
|
-
3. File was saved
|
|
338
|
-
4. Browser console for errors
|
|
339
|
-
|
|
340
|
-
**Solution:** Click indicator to manually reload
|
|
341
|
-
|
|
342
|
-
### Routing Issues
|
|
343
|
-
|
|
344
|
-
**Problem:** Page shows 404
|
|
345
|
-
|
|
346
|
-
**Check:**
|
|
347
|
-
1. Function name ends with "Page"
|
|
348
|
-
2. File is loaded (check app.html)
|
|
349
|
-
3. Browser console shows auto-registration
|
|
350
|
-
4. URL hash is correct (#/about)
|
|
351
|
-
|
|
352
|
-
**Solution:** Add manual registration
|
|
353
|
-
|
|
354
|
-
## Summary
|
|
355
|
-
|
|
356
|
-
Aziz App combines three systems:
|
|
357
|
-
|
|
358
|
-
1. **Auto-Import** - Scans folders, generates script tags
|
|
359
|
-
2. **Live Reload** - WebSocket connection, file watching
|
|
360
|
-
3. **Auto-Registration** - Scans functions, registers routes
|
|
361
|
-
|
|
362
|
-
Together, they provide a seamless development experience with zero configuration!
|