create-aziz-app 2.0.10 → 2.0.12
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/bin/create-aziz-app.js +36 -0
- package/package.json +1 -1
- package/template/README.md +9 -5
- package/template/api/hello.js +5 -6
- package/template/api/users.js +6 -8
- package/template/app.html +24 -25
- package/template/docs/API-ROUTES.md +538 -0
- package/template/docs/DEV-SERVER.md +108 -22
- package/template/docs/HOW-IT-WORKS.md +362 -0
- package/template/modules/api.js +20 -124
- package/template/package-lock.json +13 -0
- package/template/package.json +1 -1
- package/template/scripts/dev-server.js +263 -170
- package/template/scripts/generate-imports.js +0 -10
- package/template/scripts/live-reload-client.js +105 -0
package/bin/create-aziz-app.js
CHANGED
|
@@ -217,6 +217,18 @@ function setupCSSFramework(targetDir, framework) {
|
|
|
217
217
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">`
|
|
218
218
|
);
|
|
219
219
|
|
|
220
|
+
// Ensure live reload script is present
|
|
221
|
+
if (!html.includes('live-reload-client.js')) {
|
|
222
|
+
html = html.replace(
|
|
223
|
+
'<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>',
|
|
224
|
+
`<!-- Live Reload (only active in development) -->
|
|
225
|
+
<script src="scripts/live-reload-client.js"></script>
|
|
226
|
+
|
|
227
|
+
<!-- Babel compiles JSX in the browser -->
|
|
228
|
+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>`
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
220
232
|
// Add Bootstrap JS before closing body tag
|
|
221
233
|
const bootstrapJS = `
|
|
222
234
|
<!-- Bootstrap 5 JS -->
|
|
@@ -249,8 +261,32 @@ function setupCSSFramework(targetDir, framework) {
|
|
|
249
261
|
</script>`
|
|
250
262
|
);
|
|
251
263
|
|
|
264
|
+
// Ensure live reload script is present
|
|
265
|
+
if (!html.includes('live-reload-client.js')) {
|
|
266
|
+
html = html.replace(
|
|
267
|
+
'<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>',
|
|
268
|
+
`<!-- Live Reload (only active in development) -->
|
|
269
|
+
<script src="scripts/live-reload-client.js"></script>
|
|
270
|
+
|
|
271
|
+
<!-- Babel compiles JSX in the browser -->
|
|
272
|
+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>`
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
252
276
|
// Update components
|
|
253
277
|
updateComponentsForTailwind(targetDir);
|
|
278
|
+
} else {
|
|
279
|
+
// For 'none', ensure live reload script is present
|
|
280
|
+
if (!html.includes('live-reload-client.js')) {
|
|
281
|
+
html = html.replace(
|
|
282
|
+
'<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>',
|
|
283
|
+
`<!-- Live Reload (only active in development) -->
|
|
284
|
+
<script src="scripts/live-reload-client.js"></script>
|
|
285
|
+
|
|
286
|
+
<!-- Babel compiles JSX in the browser -->
|
|
287
|
+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
254
290
|
}
|
|
255
291
|
// If 'none', keep globals.css as is
|
|
256
292
|
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -125,10 +125,12 @@ navigate("about");
|
|
|
125
125
|
|
|
126
126
|
### API Routes
|
|
127
127
|
```javascript
|
|
128
|
-
// api/todos.js
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
128
|
+
// api/todos.js - Runs on SERVER (Node.js)!
|
|
129
|
+
module.exports = async function handler(req, res) {
|
|
130
|
+
if (req.method === 'GET') {
|
|
131
|
+
return res.status(200).json({ todos: [] });
|
|
132
|
+
}
|
|
133
|
+
};
|
|
132
134
|
|
|
133
135
|
// Use in components
|
|
134
136
|
const response = await fetchApi('/api/todos');
|
|
@@ -152,9 +154,11 @@ The CLI will automatically set up your chosen framework!
|
|
|
152
154
|
|
|
153
155
|
- **[Getting Started](docs/GETTING-STARTED.md)** - Complete setup guide
|
|
154
156
|
- **[Auto-Registration](docs/AUTO-REGISTRATION.md)** - How pages auto-register
|
|
155
|
-
- **[API
|
|
157
|
+
- **[API Routes](docs/API-ROUTES.md)** - Server-side API endpoints (like Next.js!)
|
|
158
|
+
- **[API Guide](docs/API-GUIDE.md)** - Legacy API guide
|
|
156
159
|
- **[Auto-Import](docs/AUTO-IMPORT.md)** - Auto-import system details
|
|
157
160
|
- **[Dev Server](docs/DEV-SERVER.md)** - Live reload and development
|
|
161
|
+
- **[How It Works](docs/HOW-IT-WORKS.md)** - System architecture
|
|
158
162
|
- **[Troubleshooting](docs/TROUBLESHOOTING.md)** - Fix common issues
|
|
159
163
|
- **[Quick Start](docs/QUICK-START.md)** - Quick examples
|
|
160
164
|
|
package/template/api/hello.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// API Route: /api/hello
|
|
2
|
+
// This runs on the SERVER (Node.js), not in the browser!
|
|
2
3
|
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
registerApiRoute('hello', async (req, res) => {
|
|
4
|
+
// Export the handler function (like Next.js)
|
|
5
|
+
module.exports = async function handler(req, res) {
|
|
7
6
|
const name = req.query.name || 'World';
|
|
8
7
|
|
|
9
8
|
return res.status(200).json({
|
|
@@ -11,4 +10,4 @@ registerApiRoute('hello', async (req, res) => {
|
|
|
11
10
|
timestamp: new Date().toISOString(),
|
|
12
11
|
method: req.method
|
|
13
12
|
});
|
|
14
|
-
}
|
|
13
|
+
};
|
package/template/api/users.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// API Route: /api/users
|
|
2
|
+
// This runs on the SERVER (Node.js), not in the browser!
|
|
2
3
|
|
|
3
|
-
//
|
|
4
|
-
// This simulates a backend API endpoint
|
|
5
|
-
|
|
6
|
-
// Mock database
|
|
4
|
+
// Mock database (in real app, use a real database)
|
|
7
5
|
const users = [
|
|
8
6
|
{ id: 1, name: 'Aziz Ahmed', email: 'aziz@example.com' },
|
|
9
7
|
{ id: 2, name: 'John Doe', email: 'john@example.com' },
|
|
10
8
|
{ id: 3, name: 'Jane Smith', email: 'jane@example.com' }
|
|
11
9
|
];
|
|
12
10
|
|
|
13
|
-
//
|
|
14
|
-
|
|
11
|
+
// Export the handler function (like Next.js)
|
|
12
|
+
module.exports = async function handler(req, res) {
|
|
15
13
|
// Handle different HTTP methods
|
|
16
14
|
switch (req.method) {
|
|
17
15
|
case 'GET':
|
|
@@ -59,4 +57,4 @@ registerApiRoute('users', async (req, res) => {
|
|
|
59
57
|
default:
|
|
60
58
|
return res.status(405).json({ error: 'Method not allowed' });
|
|
61
59
|
}
|
|
62
|
-
}
|
|
60
|
+
};
|
package/template/app.html
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
<!-- Global Styles -->
|
|
12
12
|
<link rel="stylesheet" href="styles/globals.css">
|
|
13
13
|
|
|
14
|
+
<!-- Live Reload (only active in development) -->
|
|
15
|
+
<script src="scripts/live-reload-client.js"></script>
|
|
16
|
+
|
|
14
17
|
<!-- Babel compiles JSX in the browser -->
|
|
15
18
|
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
|
16
19
|
</head>
|
|
@@ -25,31 +28,27 @@
|
|
|
25
28
|
<!-- Footer is always visible -->
|
|
26
29
|
<div id="footer"></div>
|
|
27
30
|
|
|
28
|
-
<!-- Load core modules -->
|
|
29
|
-
<script type="text/babel" src="modules/router.js"></script>
|
|
30
|
-
<script type="text/babel" src="modules/state.js"></script>
|
|
31
|
-
<script type="text/babel" src="modules/api.js"></script>
|
|
32
|
-
|
|
33
|
-
<!-- Load
|
|
34
|
-
<script type="text/babel" src="
|
|
35
|
-
<script type="text/babel" src="
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<script type="text/babel" src="
|
|
40
|
-
<script type="text/babel" src="
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<script type="text/babel" src="pages/
|
|
44
|
-
<script type="text/babel" src="pages/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<script type="text/babel"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<!-- Start the app -->
|
|
51
|
-
<script type="text/babel">
|
|
52
|
-
startApp();
|
|
31
|
+
<!-- Load core modules -->
|
|
32
|
+
<script type="text/babel" src="modules/router.js"></script>
|
|
33
|
+
<script type="text/babel" src="modules/state.js"></script>
|
|
34
|
+
<script type="text/babel" src="modules/api.js"></script>
|
|
35
|
+
|
|
36
|
+
<!-- Load shared components -->
|
|
37
|
+
<script type="text/babel" src="components/Counter.jsx"></script>
|
|
38
|
+
<script type="text/babel" src="components/Footer.jsx"></script>
|
|
39
|
+
<script type="text/babel" src="components/Navbar.jsx"></script>
|
|
40
|
+
|
|
41
|
+
<!-- Load pages -->
|
|
42
|
+
<script type="text/babel" src="pages/About.jsx"></script>
|
|
43
|
+
<script type="text/babel" src="pages/ApiDemo.jsx"></script>
|
|
44
|
+
<script type="text/babel" src="pages/Contact.jsx"></script>
|
|
45
|
+
<script type="text/babel" src="pages/Example.jsx"></script>
|
|
46
|
+
<script type="text/babel" src="pages/Home.jsx"></script>
|
|
47
|
+
<script type="text/babel" src="pages/test.jsx"></script>
|
|
48
|
+
|
|
49
|
+
<!-- Start the app -->
|
|
50
|
+
<script type="text/babel">
|
|
51
|
+
startApp();
|
|
53
52
|
</script>
|
|
54
53
|
|
|
55
54
|
</body>
|