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,184 +0,0 @@
|
|
|
1
|
-
# Dev Server Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The dev server provides a smooth development experience with live reload using WebSocket, automatic import generation, and file watching.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
### 🔄 Live Reload (WebSocket-based)
|
|
10
|
-
- **Automatic browser refresh** when you save files
|
|
11
|
-
- **Visual indicator** in bottom-right corner shows connection status
|
|
12
|
-
- **WebSocket connection** - reliable, fast, no caching issues
|
|
13
|
-
- **CSS hot reload** - instant updates without regenerating imports
|
|
14
|
-
- **Always loaded** - script is part of your HTML, not injected
|
|
15
|
-
|
|
16
|
-
### 👀 File Watching
|
|
17
|
-
The dev server watches these directories:
|
|
18
|
-
- `api/` - API route files
|
|
19
|
-
- `components/` - React-like components
|
|
20
|
-
- `pages/` - Page components
|
|
21
|
-
- `modules/` - Core system modules
|
|
22
|
-
- `styles/` - CSS files
|
|
23
|
-
|
|
24
|
-
### 🚀 Auto Import Generation
|
|
25
|
-
- Automatically generates script tags in `app.html`
|
|
26
|
-
- Runs on startup and whenever JS/JSX files change
|
|
27
|
-
- No need to manually add imports
|
|
28
|
-
|
|
29
|
-
### 🎯 Smart Port Selection
|
|
30
|
-
- Defaults to port 3000
|
|
31
|
-
- Automatically finds next available port if 3000 is busy
|
|
32
|
-
- Shows the actual URL in console
|
|
33
|
-
|
|
34
|
-
## Usage
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npm run dev
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Then open the URL shown in console (usually `http://localhost:3000/`)
|
|
41
|
-
|
|
42
|
-
## Visual Indicators
|
|
43
|
-
|
|
44
|
-
The live reload indicator in the bottom-right corner shows:
|
|
45
|
-
- 🔌 **Connecting...** - Initial connection (gray/green)
|
|
46
|
-
- ✅ **Live Reload** - Connected and watching (green, fades to 30%)
|
|
47
|
-
- 🔄 **Reloading...** - Changes detected, refreshing page (blue)
|
|
48
|
-
- ⚠️ **Disconnected** - Connection lost, attempting to reconnect (orange)
|
|
49
|
-
- ❌ **Offline** - Max reconnection attempts reached (red)
|
|
50
|
-
|
|
51
|
-
**Click the indicator** to manually reload the page.
|
|
52
|
-
|
|
53
|
-
Hover over the indicator to make it fully visible.
|
|
54
|
-
|
|
55
|
-
## How It Works
|
|
56
|
-
|
|
57
|
-
1. **Server starts** and generates initial imports
|
|
58
|
-
2. **Browser loads** `live-reload-client.js` (always in HTML)
|
|
59
|
-
3. **WebSocket connects** to dev server
|
|
60
|
-
4. **File watcher** detects changes in watched directories
|
|
61
|
-
5. **Debouncing** prevents multiple rapid reloads (300ms for CSS, 500ms for JS)
|
|
62
|
-
6. **Import regeneration** (for JS/JSX changes only)
|
|
63
|
-
7. **WebSocket message** sent to all connected browsers
|
|
64
|
-
8. **Page reload** happens immediately
|
|
65
|
-
|
|
66
|
-
## Why WebSocket?
|
|
67
|
-
|
|
68
|
-
Previous versions used Server-Sent Events (SSE) with runtime injection, which had caching issues. The new approach:
|
|
69
|
-
|
|
70
|
-
- ✅ **Always loaded** - Script is in HTML, not injected at runtime
|
|
71
|
-
- ✅ **No caching issues** - Browser always has the script
|
|
72
|
-
- ✅ **Bidirectional** - WebSocket allows two-way communication
|
|
73
|
-
- ✅ **Reliable** - Built-in reconnection logic
|
|
74
|
-
- ✅ **Fast** - Instant notifications, no polling
|
|
75
|
-
|
|
76
|
-
## Cache Control
|
|
77
|
-
|
|
78
|
-
The dev server sends these headers to prevent caching:
|
|
79
|
-
```
|
|
80
|
-
Cache-Control: no-cache, no-store, must-revalidate
|
|
81
|
-
Pragma: no-cache
|
|
82
|
-
Expires: 0
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Plus, `app.html` has meta tags:
|
|
86
|
-
```html
|
|
87
|
-
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
|
88
|
-
<meta http-equiv="Pragma" content="no-cache">
|
|
89
|
-
<meta http-equiv="Expires" content="0">
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Troubleshooting
|
|
93
|
-
|
|
94
|
-
### Indicator stuck on "Connecting..."?
|
|
95
|
-
|
|
96
|
-
1. **Check dev server is running** - Terminal should show "✅ Dev server running"
|
|
97
|
-
2. **Check browser console** (F12) - Look for WebSocket errors
|
|
98
|
-
3. **Check port** - Browser URL should match server URL
|
|
99
|
-
4. **Firewall** - Allow Node.js through firewall
|
|
100
|
-
5. **Try different browser** - Rule out browser-specific issues
|
|
101
|
-
|
|
102
|
-
### Changes not showing?
|
|
103
|
-
|
|
104
|
-
1. **Check indicator is green** - "✅ Live Reload"
|
|
105
|
-
2. **Check terminal** - Should show "📝 Detected change: ..."
|
|
106
|
-
3. **Check file was saved** - No unsaved indicator in editor
|
|
107
|
-
4. **Check file location** - Must be in watched directories
|
|
108
|
-
5. **Check for errors** - Browser console (F12) for JavaScript errors
|
|
109
|
-
|
|
110
|
-
### WebSocket connection failed?
|
|
111
|
-
|
|
112
|
-
1. **Port mismatch** - Check browser URL matches server port
|
|
113
|
-
2. **Proxy/VPN** - May block WebSocket connections
|
|
114
|
-
3. **Browser extension** - Ad blockers can interfere
|
|
115
|
-
4. **Try incognito mode** - Rule out extensions
|
|
116
|
-
|
|
117
|
-
### Port already in use?
|
|
118
|
-
|
|
119
|
-
The server automatically tries the next port. Check terminal for actual port:
|
|
120
|
-
```
|
|
121
|
-
🌐 Server running at http://localhost:3001/
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Performance
|
|
125
|
-
|
|
126
|
-
- **Debouncing** prevents reload spam when saving multiple files
|
|
127
|
-
- **CSS-only changes** skip import regeneration for faster updates
|
|
128
|
-
- **WebSocket** is lightweight and efficient
|
|
129
|
-
- **Multiple browsers** can connect simultaneously
|
|
130
|
-
- **Automatic reconnection** if connection drops
|
|
131
|
-
|
|
132
|
-
## Development Tips
|
|
133
|
-
|
|
134
|
-
1. Keep the terminal visible to see file change notifications
|
|
135
|
-
2. The visual indicator helps confirm live reload is working
|
|
136
|
-
3. CSS changes are faster than JS changes (no import regeneration)
|
|
137
|
-
4. Multiple browser tabs will all reload simultaneously
|
|
138
|
-
5. Click the indicator to manually reload if needed
|
|
139
|
-
|
|
140
|
-
## Production
|
|
141
|
-
|
|
142
|
-
The live reload script only runs in development (localhost). In production:
|
|
143
|
-
- Script detects non-localhost hostname
|
|
144
|
-
- Exits immediately without connecting
|
|
145
|
-
- No performance impact
|
|
146
|
-
- No visual indicator
|
|
147
|
-
|
|
148
|
-
## Technical Details
|
|
149
|
-
|
|
150
|
-
### WebSocket Protocol
|
|
151
|
-
|
|
152
|
-
The dev server implements a simple WebSocket server without external dependencies:
|
|
153
|
-
- Uses Node.js `http` module's `upgrade` event
|
|
154
|
-
- Performs WebSocket handshake manually
|
|
155
|
-
- Sends text frames to connected clients
|
|
156
|
-
- Handles connection cleanup automatically
|
|
157
|
-
|
|
158
|
-
### Message Format
|
|
159
|
-
|
|
160
|
-
Server sends a single message type:
|
|
161
|
-
- `"reload"` - Triggers browser reload
|
|
162
|
-
|
|
163
|
-
### Reconnection Logic
|
|
164
|
-
|
|
165
|
-
Client attempts to reconnect:
|
|
166
|
-
- Max 10 attempts
|
|
167
|
-
- 2-second delay between attempts
|
|
168
|
-
- Exponential backoff could be added if needed
|
|
169
|
-
|
|
170
|
-
## Comparison with Other Tools
|
|
171
|
-
|
|
172
|
-
| Feature | Aziz App | Live Server | Vite |
|
|
173
|
-
|---------|----------|-------------|------|
|
|
174
|
-
| Setup | Zero config | Zero config | Config file |
|
|
175
|
-
| Speed | Fast | Fast | Very fast |
|
|
176
|
-
| WebSocket | ✅ | ✅ | ✅ |
|
|
177
|
-
| Auto-import | ✅ | ❌ | ✅ |
|
|
178
|
-
| Visual indicator | ✅ | ❌ | ❌ |
|
|
179
|
-
| Dependencies | None | None | Many |
|
|
180
|
-
|
|
181
|
-
## Summary
|
|
182
|
-
|
|
183
|
-
The dev server provides a reliable, fast live reload experience using WebSocket. The script is always loaded (not injected), eliminating caching issues. File watching, debouncing, and automatic reconnection make development smooth and efficient.
|
|
184
|
-
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
# Getting Started
|
|
2
|
-
|
|
3
|
-
## 🎉 Your App is Now Super Clean!
|
|
4
|
-
|
|
5
|
-
The app now uses an **auto-import system** - you only need to edit one file to add new pages, components, or API routes!
|
|
6
|
-
|
|
7
|
-
## 📁 Project Structure
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
template/
|
|
11
|
-
├── app.html # Main HTML (super clean - only 5 script tags!)
|
|
12
|
-
├── app.config.js # ⭐ Configure what files to load here
|
|
13
|
-
├── modules/ # Core system modules
|
|
14
|
-
│ ├── router.js # Routing & rendering
|
|
15
|
-
│ ├── state.js # State management
|
|
16
|
-
│ ├── api.js # API system
|
|
17
|
-
│ └── auto-import.js # Auto-import magic
|
|
18
|
-
├── api/ # API route handlers
|
|
19
|
-
│ ├── hello.js
|
|
20
|
-
│ └── users.js
|
|
21
|
-
├── components/ # Reusable components
|
|
22
|
-
│ ├── Navbar.jsx
|
|
23
|
-
│ ├── Footer.jsx
|
|
24
|
-
│ └── Counter.jsx
|
|
25
|
-
└── pages/ # Page components
|
|
26
|
-
├── Home.jsx
|
|
27
|
-
├── About.jsx
|
|
28
|
-
├── Contact.jsx
|
|
29
|
-
├── test.jsx
|
|
30
|
-
└── ApiDemo.jsx
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## 🚀 Adding New Files
|
|
34
|
-
|
|
35
|
-
### Add a New Page
|
|
36
|
-
|
|
37
|
-
1. **Create the page file:**
|
|
38
|
-
```javascript
|
|
39
|
-
// pages/MyNewPage.jsx
|
|
40
|
-
/** @jsx h */
|
|
41
|
-
|
|
42
|
-
registerPage("mynewpage", MyNewPage);
|
|
43
|
-
|
|
44
|
-
function MyNewPage() {
|
|
45
|
-
const [count, setCount] = useState(0);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div>
|
|
49
|
-
<h1>My New Page</h1>
|
|
50
|
-
<p>Count: {count}</p>
|
|
51
|
-
<button onClick={() => setCount(count + 1)}>
|
|
52
|
-
Increment
|
|
53
|
-
</button>
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
2. **Add to config:**
|
|
60
|
-
```javascript
|
|
61
|
-
// app.config.js
|
|
62
|
-
window.APP_CONFIG = {
|
|
63
|
-
pages: [
|
|
64
|
-
'pages/Home.jsx',
|
|
65
|
-
'pages/About.jsx',
|
|
66
|
-
'pages/MyNewPage.jsx' // ← Add this line
|
|
67
|
-
]
|
|
68
|
-
};
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
3. **That's it!** Refresh the page and navigate to `#/mynewpage`
|
|
72
|
-
|
|
73
|
-
### Add a New Component
|
|
74
|
-
|
|
75
|
-
1. **Create the component:**
|
|
76
|
-
```javascript
|
|
77
|
-
// components/Button.jsx
|
|
78
|
-
/** @jsx h */
|
|
79
|
-
|
|
80
|
-
function Button({ label, onClick }) {
|
|
81
|
-
return (
|
|
82
|
-
<button class="btn btn-primary" onClick={onClick}>
|
|
83
|
-
{label}
|
|
84
|
-
</button>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
2. **Add to config:**
|
|
90
|
-
```javascript
|
|
91
|
-
// app.config.js
|
|
92
|
-
window.APP_CONFIG = {
|
|
93
|
-
components: [
|
|
94
|
-
'components/Navbar.jsx',
|
|
95
|
-
'components/Button.jsx' // ← Add this line
|
|
96
|
-
]
|
|
97
|
-
};
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
3. **Use it in pages:**
|
|
101
|
-
```javascript
|
|
102
|
-
<Button label="Click me" onClick={() => alert('Clicked!')} />
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Add a New API Route
|
|
106
|
-
|
|
107
|
-
1. **Create the API route:**
|
|
108
|
-
```javascript
|
|
109
|
-
// api/todos.js
|
|
110
|
-
/** @jsx h */
|
|
111
|
-
|
|
112
|
-
const todos = [];
|
|
113
|
-
|
|
114
|
-
registerApiRoute('todos', async (req, res) => {
|
|
115
|
-
if (req.method === 'GET') {
|
|
116
|
-
return res.status(200).json(todos);
|
|
117
|
-
}
|
|
118
|
-
if (req.method === 'POST') {
|
|
119
|
-
const newTodo = { id: Date.now(), ...req.body };
|
|
120
|
-
todos.push(newTodo);
|
|
121
|
-
return res.status(201).json(newTodo);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
2. **Add to config:**
|
|
127
|
-
```javascript
|
|
128
|
-
// app.config.js
|
|
129
|
-
window.APP_CONFIG = {
|
|
130
|
-
apiRoutes: [
|
|
131
|
-
'api/hello.js',
|
|
132
|
-
'api/todos.js' // ← Add this line
|
|
133
|
-
]
|
|
134
|
-
};
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
3. **Use it:**
|
|
138
|
-
```javascript
|
|
139
|
-
const response = await fetchApi('/api/todos');
|
|
140
|
-
const data = await response.json();
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## 🎨 Key Features
|
|
144
|
-
|
|
145
|
-
### State Management (React-like)
|
|
146
|
-
```javascript
|
|
147
|
-
const [count, setCount] = useState(0);
|
|
148
|
-
const [name, setName] = useState('');
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Routing
|
|
152
|
-
```javascript
|
|
153
|
-
// Register a page
|
|
154
|
-
registerPage("about", AboutPage);
|
|
155
|
-
|
|
156
|
-
// Navigate
|
|
157
|
-
navigate("about");
|
|
158
|
-
|
|
159
|
-
// Get current path
|
|
160
|
-
const path = getCurrentPath();
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### API Routes
|
|
164
|
-
```javascript
|
|
165
|
-
// Register
|
|
166
|
-
registerApiRoute('users', async (req, res) => {
|
|
167
|
-
return res.status(200).json({ users: [] });
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// Call
|
|
171
|
-
const response = await fetchApi('/api/users');
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## 📝 Important Notes
|
|
175
|
-
|
|
176
|
-
1. **Always use `/** @jsx h */`** at the top of JSX files
|
|
177
|
-
2. **Load order matters** - config → modules → auto-import
|
|
178
|
-
3. **Check console** - auto-import logs what it's loading
|
|
179
|
-
4. **One config file** - `app.config.js` is the only place to add files
|
|
180
|
-
|
|
181
|
-
## 🔧 Troubleshooting
|
|
182
|
-
|
|
183
|
-
**Page not loading?**
|
|
184
|
-
- Check if it's added to `app.config.js`
|
|
185
|
-
- Check browser console for errors
|
|
186
|
-
- Make sure file path is correct
|
|
187
|
-
|
|
188
|
-
**State not working?**
|
|
189
|
-
- Make sure you're using `useState()` not `window.useState()`
|
|
190
|
-
- Check that `modules/state.js` is loaded
|
|
191
|
-
|
|
192
|
-
**API route not found?**
|
|
193
|
-
- Check if it's added to `app.config.js`
|
|
194
|
-
- Make sure you used `registerApiRoute()`
|
|
195
|
-
- Check the route path matches your `fetchApi()` call
|
|
196
|
-
|
|
197
|
-
## 🎯 Next Steps
|
|
198
|
-
|
|
199
|
-
1. Open `app.html` in your browser
|
|
200
|
-
2. Check the console to see auto-import in action
|
|
201
|
-
3. Navigate to different pages
|
|
202
|
-
4. Try the API Demo page at `#/api-demo`
|
|
203
|
-
5. Create your own pages and components!
|
|
204
|
-
|
|
205
|
-
Enjoy your clean, auto-importing app! 🚀
|