create-aziz-app 3.1.0 β 3.1.2
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 +9 -58
- package/package.json +1 -1
- package/template/README.md +402 -667
- package/template/app/layout.js +18 -20
- package/template/app/page.js +33 -56
- package/template/scripts/lib/js-transform.js +57 -3
- package/template/api/contact.js +0 -39
- package/template/api/createUser.js +0 -69
- package/template/api/hello.js +0 -17
- package/template/api/loginUser.js +0 -61
- package/template/api/users.js +0 -59
- package/template/app/about/page.js +0 -41
- package/template/app/blog/[slug]/page.js +0 -31
- package/template/app/contact/page.js +0 -68
- package/template/app/not-found.js +0 -15
- package/template/app/test/page.js +0 -52
- package/template/components/Footer.js +0 -7
- package/template/components/Navbar.js +0 -28
- package/template/lib/db.js +0 -67
- package/template/models/User.js +0 -102
package/bin/create-aziz-app.js
CHANGED
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
// -y, --yes Accept all defaults (no prompts)
|
|
13
13
|
// --port <n> Dev-server port (default 3000)
|
|
14
14
|
// --css <name> none | bootstrap | tailwind
|
|
15
|
-
// --no-examples Skip the example Test page
|
|
16
|
-
// --no-api Skip example API routes
|
|
17
15
|
// --no-docs Skip the docs/ folder
|
|
18
16
|
// -h, --help Show help
|
|
19
17
|
// ============================================================
|
|
@@ -34,8 +32,6 @@ function parseArgs(argv) {
|
|
|
34
32
|
yes: false,
|
|
35
33
|
port: null,
|
|
36
34
|
css: null,
|
|
37
|
-
examples: null,
|
|
38
|
-
api: null,
|
|
39
35
|
docs: null,
|
|
40
36
|
help: false,
|
|
41
37
|
};
|
|
@@ -49,8 +45,6 @@ function parseArgs(argv) {
|
|
|
49
45
|
case '--yes': opts.yes = true; break;
|
|
50
46
|
case '--port': opts.port = argv[++i]; break;
|
|
51
47
|
case '--css': opts.css = argv[++i]; break;
|
|
52
|
-
case '--no-examples': opts.examples = false; break;
|
|
53
|
-
case '--no-api': opts.api = false; break;
|
|
54
48
|
case '--no-docs': opts.docs = false; break;
|
|
55
49
|
default:
|
|
56
50
|
if (!arg.startsWith('-') && !opts.projectName) opts.projectName = arg;
|
|
@@ -70,8 +64,6 @@ Options:
|
|
|
70
64
|
-y, --yes Accept all defaults (skip prompts)
|
|
71
65
|
--port <n> Dev-server port (default 3000)
|
|
72
66
|
--css <name> none | bootstrap | tailwind
|
|
73
|
-
--no-examples Skip the example Test page
|
|
74
|
-
--no-api Skip example API routes
|
|
75
67
|
--no-docs Skip the docs/ folder
|
|
76
68
|
-h, --help Show this help
|
|
77
69
|
|
|
@@ -94,7 +86,6 @@ function copyDir(src, dest, features) {
|
|
|
94
86
|
for (const entry of fs.readdirSync(src)) {
|
|
95
87
|
const srcPath = path.join(src, entry);
|
|
96
88
|
const destPath = path.join(dest, entry);
|
|
97
|
-
const rel = dest; // not needed; handled below
|
|
98
89
|
|
|
99
90
|
if (shouldSkip(entry)) continue;
|
|
100
91
|
|
|
@@ -111,17 +102,6 @@ function copyDir(src, dest, features) {
|
|
|
111
102
|
}
|
|
112
103
|
}
|
|
113
104
|
|
|
114
|
-
function removeDirIfExists(dir) {
|
|
115
|
-
if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true, force: true });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function emptyDirContents(dir) {
|
|
119
|
-
if (!fs.existsSync(dir)) return;
|
|
120
|
-
for (const entry of fs.readdirSync(dir)) {
|
|
121
|
-
fs.rmSync(path.join(dir, entry), { recursive: true, force: true });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
105
|
function updatePackageJson(targetDir, projectName) {
|
|
126
106
|
const pkgPath = path.join(targetDir, 'package.json');
|
|
127
107
|
if (!fs.existsSync(pkgPath)) return;
|
|
@@ -198,7 +178,7 @@ async function main() {
|
|
|
198
178
|
}
|
|
199
179
|
|
|
200
180
|
console.log(`\nβ‘ Welcome to Aziz.js!\n`);
|
|
201
|
-
console.log(`π¨ A lightweight Next.js clone β file-based routing, React hooks,
|
|
181
|
+
console.log(`π¨ A lightweight Next.js clone β file-based routing, React hooks, live reload\n`);
|
|
202
182
|
|
|
203
183
|
let projectName = opts.projectName;
|
|
204
184
|
if (!projectName) {
|
|
@@ -236,26 +216,12 @@ async function main() {
|
|
|
236
216
|
}
|
|
237
217
|
|
|
238
218
|
// ββ Features
|
|
239
|
-
let examples = opts.examples;
|
|
240
|
-
let apiExamples = opts.api;
|
|
241
219
|
let docs = opts.docs;
|
|
242
220
|
|
|
243
|
-
if (!opts.yes) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
examples = !['n', 'no'].includes(a.trim().toLowerCase());
|
|
247
|
-
}
|
|
248
|
-
if (apiExamples === null) {
|
|
249
|
-
const a = await question(' Include example API routes? (Y/n): ');
|
|
250
|
-
apiExamples = !['n', 'no'].includes(a.trim().toLowerCase());
|
|
251
|
-
}
|
|
252
|
-
if (docs === null) {
|
|
253
|
-
const a = await question(' Include documentation? (Y/n): ');
|
|
254
|
-
docs = !['n', 'no'].includes(a.trim().toLowerCase());
|
|
255
|
-
}
|
|
221
|
+
if (!opts.yes && docs === null) {
|
|
222
|
+
const a = await question(' Include documentation? (Y/n): ');
|
|
223
|
+
docs = !['n', 'no'].includes(a.trim().toLowerCase());
|
|
256
224
|
}
|
|
257
|
-
if (examples === null) examples = true;
|
|
258
|
-
if (apiExamples === null) apiExamples = true;
|
|
259
225
|
if (docs === null) docs = true;
|
|
260
226
|
|
|
261
227
|
// ββ CSS framework
|
|
@@ -270,7 +236,7 @@ async function main() {
|
|
|
270
236
|
}
|
|
271
237
|
if (!['none', 'bootstrap', 'tailwind'].includes(css)) css = 'none';
|
|
272
238
|
|
|
273
|
-
const features = {
|
|
239
|
+
const features = { docs, css };
|
|
274
240
|
|
|
275
241
|
console.log(`\nβ‘ Creating "${projectName}"...\n`);
|
|
276
242
|
|
|
@@ -284,22 +250,13 @@ async function main() {
|
|
|
284
250
|
// 1. Copy the template (excluding node_modules)
|
|
285
251
|
copyDir(templateDir, targetDir, features);
|
|
286
252
|
|
|
287
|
-
// 2.
|
|
288
|
-
if (!features.examples) {
|
|
289
|
-
removeDirIfExists(path.join(targetDir, 'app', 'test'));
|
|
290
|
-
}
|
|
291
|
-
if (!features.api) {
|
|
292
|
-
emptyDirContents(path.join(targetDir, 'api'));
|
|
293
|
-
fs.mkdirSync(path.join(targetDir, 'api'), { recursive: true });
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// 3. Personalize
|
|
253
|
+
// 2. Personalize
|
|
297
254
|
updatePackageJson(targetDir, projectName);
|
|
298
255
|
updateDevServerPort(targetDir, port);
|
|
299
256
|
updateTitle(targetDir, projectName);
|
|
300
257
|
setupCSSFramework(targetDir, features.css);
|
|
301
258
|
|
|
302
|
-
//
|
|
259
|
+
// 3. .gitignore
|
|
303
260
|
fs.writeFileSync(path.join(targetDir, '.gitignore'), [
|
|
304
261
|
'node_modules/',
|
|
305
262
|
'.DS_Store',
|
|
@@ -320,11 +277,8 @@ async function main() {
|
|
|
320
277
|
console.log(` app/ β pages + layouts (file-based routing)`);
|
|
321
278
|
console.log(` layout.js β root layout`);
|
|
322
279
|
console.log(` page.js β route: /`);
|
|
323
|
-
console.log(`
|
|
324
|
-
console.log(`
|
|
325
|
-
console.log(` components/ β shared UI components`);
|
|
326
|
-
console.log(` lib/ models/ β helpers + data models`);
|
|
327
|
-
console.log(` _framework/ β runtime, hooks, router, api client`);
|
|
280
|
+
console.log(` styles/ β global CSS`);
|
|
281
|
+
console.log(` _framework/ β runtime, hooks, router`);
|
|
328
282
|
console.log(` scripts/ β dev server + live reload`);
|
|
329
283
|
if (features.docs) console.log(` docs/ β full documentation`);
|
|
330
284
|
console.log(`\n⨠Highlights:\n`);
|
|
@@ -332,12 +286,9 @@ async function main() {
|
|
|
332
286
|
console.log(` β’ Dynamic routes app/blog/[slug]/page.js β /blog/:slug`);
|
|
333
287
|
console.log(` β’ Nested layouts app/**/layout.js`);
|
|
334
288
|
console.log(` β’ React hooks useState, useEffect, useMemo, contextβ¦`);
|
|
335
|
-
console.log(` β’ API route handlers api/*.js and app/api/**/route.js`);
|
|
336
|
-
console.log(` β’ API client api.get('/api/users') β retries + timeouts`);
|
|
337
289
|
console.log(` β’ Live reload instant browser refresh on save`);
|
|
338
290
|
console.log(`\nπ‘ Tips:\n`);
|
|
339
291
|
console.log(` β’ Create app/MyPage/page.js β route /MyPage`);
|
|
340
|
-
console.log(` β’ Create api/todos.js β route /api/todos`);
|
|
341
292
|
if (features.docs) console.log(` β’ Read docs/README.md for the full guide`);
|
|
342
293
|
console.log(`\nπ Happy building!\n`);
|
|
343
294
|
|