create-aziz-app 3.1.2 → 3.1.3
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 +658 -207
- package/bin/create-aziz-app.js +302 -302
- package/package.json +1 -1
- package/template/README.md +402 -402
- package/template/_framework/api.js +219 -219
- package/template/_framework/boot.js +33 -33
- package/template/_framework/hooks.js +367 -291
- package/template/_framework/next-response.js +128 -128
- package/template/_framework/route-match.js +145 -145
- package/template/_framework/router.js +465 -259
- package/template/_framework/runtime.js +264 -264
- package/template/app/layout.js +18 -18
- package/template/app/page.js +33 -33
- package/template/docs/01-getting-started.md +151 -151
- package/template/docs/02-project-structure.md +109 -109
- package/template/docs/03-pages-and-layouts.md +140 -140
- package/template/docs/04-routing.md +120 -120
- package/template/docs/05-hooks.md +169 -169
- package/template/docs/06-api-routes.md +210 -210
- package/template/docs/07-api-client.md +151 -151
- package/template/docs/08-styling.md +94 -94
- package/template/docs/09-imports-and-modules.md +97 -97
- package/template/docs/10-database-and-models.md +154 -154
- package/template/docs/11-authentication.md +171 -171
- package/template/docs/12-production-and-deployment.md +121 -121
- package/template/docs/13-internals.md +179 -179
- package/template/docs/README.md +67 -67
- package/template/index.html +20 -20
- package/template/package.json +16 -16
- package/template/scripts/dev-server.js +493 -381
- package/template/scripts/lib/api-router.js +525 -525
- package/template/scripts/lib/js-transform.js +213 -195
- package/template/scripts/lib/module-resolver.js +132 -132
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
// ============================================================
|
|
2
|
-
// Aziz.js — node_modules resolver for browser bare imports
|
|
3
|
-
// Maps /_modules/<pkg>… to a real file inside node_modules.
|
|
4
|
-
// Supports: package.json "exports", "browser", "module", "main".
|
|
5
|
-
// ============================================================
|
|
6
|
-
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
|
|
10
|
-
const EXTENSIONS = ['.js', '.mjs', '.cjs', '.json'];
|
|
11
|
-
|
|
12
|
-
function statIsFile(p) {
|
|
13
|
-
try { return fs.statSync(p).isFile(); } catch { return false; }
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function firstExisting(candidates) {
|
|
17
|
-
for (const c of candidates) {
|
|
18
|
-
if (statIsFile(c)) return c;
|
|
19
|
-
for (const ext of EXTENSIONS) {
|
|
20
|
-
if (statIsFile(c + ext)) return c + ext;
|
|
21
|
-
}
|
|
22
|
-
if (statIsFile(path.join(c, 'index.js'))) return path.join(c, 'index.js');
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Resolve a value from the "exports" field (string or nested conditions).
|
|
28
|
-
// Condition order prefers browser builds, then ESM, then CJS.
|
|
29
|
-
function resolveExportsValue(value) {
|
|
30
|
-
if (typeof value === 'string') return value;
|
|
31
|
-
if (Array.isArray(value)) {
|
|
32
|
-
for (const v of value) {
|
|
33
|
-
const r = resolveExportsValue(v);
|
|
34
|
-
if (r) return r;
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
if (value && typeof value === 'object') {
|
|
39
|
-
for (const cond of ['browser', 'import', 'module', 'default', 'require']) {
|
|
40
|
-
if (cond in value) {
|
|
41
|
-
const r = resolveExportsValue(value[cond]);
|
|
42
|
-
if (r) return r;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function resolveExportsField(exportsField, subPath) {
|
|
50
|
-
if (!exportsField) return null;
|
|
51
|
-
|
|
52
|
-
// "exports": "./index.js"
|
|
53
|
-
if (typeof exportsField === 'string') {
|
|
54
|
-
return subPath ? null : exportsField;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Conditional exports at the top level (no subpaths)
|
|
58
|
-
if (!subPath) {
|
|
59
|
-
if ('.' in exportsField || Object.keys(exportsField).some(k => k.startsWith('./'))) {
|
|
60
|
-
return '.' in exportsField ? resolveExportsValue(exportsField['.']) : null;
|
|
61
|
-
}
|
|
62
|
-
return resolveExportsValue(exportsField);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Subpath exports
|
|
66
|
-
const key = './' + subPath;
|
|
67
|
-
if (key in exportsField) return resolveExportsValue(exportsField[key]);
|
|
68
|
-
|
|
69
|
-
// Wildcard patterns: "./*": "./dist/*.js"
|
|
70
|
-
for (const patternKey of Object.keys(exportsField)) {
|
|
71
|
-
if (!patternKey.includes('*')) continue;
|
|
72
|
-
const [pre, post = ''] = patternKey.split('*');
|
|
73
|
-
if (key.startsWith(pre) && key.endsWith(post) && key.length >= pre.length + post.length) {
|
|
74
|
-
const star = key.slice(pre.length, key.length - post.length);
|
|
75
|
-
const target = resolveExportsValue(exportsField[patternKey]);
|
|
76
|
-
if (target) return target.replace('*', star);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Resolve a bare specifier ("pkg", "pkg/sub", "@scope/pkg/sub")
|
|
84
|
-
// to an absolute file path inside ROOT/node_modules.
|
|
85
|
-
function resolveNodeModule(specifier, ROOT) {
|
|
86
|
-
const parts = specifier.split('/');
|
|
87
|
-
const isScoped = parts[0].startsWith('@');
|
|
88
|
-
const pkgName = isScoped ? parts[0] + '/' + parts[1] : parts[0];
|
|
89
|
-
const subPath = isScoped ? parts.slice(2).join('/') : parts.slice(1).join('/');
|
|
90
|
-
|
|
91
|
-
const pkgDir = path.join(ROOT, 'node_modules', pkgName);
|
|
92
|
-
const pkgJsonPath = path.join(pkgDir, 'package.json');
|
|
93
|
-
if (!fs.existsSync(pkgJsonPath)) return null;
|
|
94
|
-
|
|
95
|
-
let pkg;
|
|
96
|
-
try {
|
|
97
|
-
pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
|
|
98
|
-
} catch {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// 1. package.json "exports" (modern packages)
|
|
103
|
-
if (pkg.exports) {
|
|
104
|
-
const target = resolveExportsField(pkg.exports, subPath);
|
|
105
|
-
if (target) {
|
|
106
|
-
const resolved = firstExisting([path.join(pkgDir, target)]);
|
|
107
|
-
if (resolved) return resolved;
|
|
108
|
-
}
|
|
109
|
-
// "exports" exists but didn't resolve — fall through only when
|
|
110
|
-
// no subpath was requested, so legacy entry fields can still win.
|
|
111
|
-
if (subPath) return null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (subPath) {
|
|
115
|
-
return firstExisting([
|
|
116
|
-
path.join(pkgDir, subPath),
|
|
117
|
-
path.join(pkgDir, 'dist', subPath),
|
|
118
|
-
path.join(pkgDir, 'src', subPath),
|
|
119
|
-
]);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 2. Legacy entry fields: browser (string) → module → main
|
|
123
|
-
const entries = [];
|
|
124
|
-
if (typeof pkg.browser === 'string') entries.push(pkg.browser);
|
|
125
|
-
if (pkg.module) entries.push(pkg.module);
|
|
126
|
-
if (pkg.main) entries.push(pkg.main);
|
|
127
|
-
entries.push('index.js');
|
|
128
|
-
|
|
129
|
-
return firstExisting(entries.map(e => path.join(pkgDir, e)));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
module.exports = { resolveNodeModule, resolveExportsField };
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Aziz.js — node_modules resolver for browser bare imports
|
|
3
|
+
// Maps /_modules/<pkg>… to a real file inside node_modules.
|
|
4
|
+
// Supports: package.json "exports", "browser", "module", "main".
|
|
5
|
+
// ============================================================
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const EXTENSIONS = ['.js', '.mjs', '.cjs', '.json'];
|
|
11
|
+
|
|
12
|
+
function statIsFile(p) {
|
|
13
|
+
try { return fs.statSync(p).isFile(); } catch { return false; }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function firstExisting(candidates) {
|
|
17
|
+
for (const c of candidates) {
|
|
18
|
+
if (statIsFile(c)) return c;
|
|
19
|
+
for (const ext of EXTENSIONS) {
|
|
20
|
+
if (statIsFile(c + ext)) return c + ext;
|
|
21
|
+
}
|
|
22
|
+
if (statIsFile(path.join(c, 'index.js'))) return path.join(c, 'index.js');
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Resolve a value from the "exports" field (string or nested conditions).
|
|
28
|
+
// Condition order prefers browser builds, then ESM, then CJS.
|
|
29
|
+
function resolveExportsValue(value) {
|
|
30
|
+
if (typeof value === 'string') return value;
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
for (const v of value) {
|
|
33
|
+
const r = resolveExportsValue(v);
|
|
34
|
+
if (r) return r;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (value && typeof value === 'object') {
|
|
39
|
+
for (const cond of ['browser', 'import', 'module', 'default', 'require']) {
|
|
40
|
+
if (cond in value) {
|
|
41
|
+
const r = resolveExportsValue(value[cond]);
|
|
42
|
+
if (r) return r;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function resolveExportsField(exportsField, subPath) {
|
|
50
|
+
if (!exportsField) return null;
|
|
51
|
+
|
|
52
|
+
// "exports": "./index.js"
|
|
53
|
+
if (typeof exportsField === 'string') {
|
|
54
|
+
return subPath ? null : exportsField;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Conditional exports at the top level (no subpaths)
|
|
58
|
+
if (!subPath) {
|
|
59
|
+
if ('.' in exportsField || Object.keys(exportsField).some(k => k.startsWith('./'))) {
|
|
60
|
+
return '.' in exportsField ? resolveExportsValue(exportsField['.']) : null;
|
|
61
|
+
}
|
|
62
|
+
return resolveExportsValue(exportsField);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Subpath exports
|
|
66
|
+
const key = './' + subPath;
|
|
67
|
+
if (key in exportsField) return resolveExportsValue(exportsField[key]);
|
|
68
|
+
|
|
69
|
+
// Wildcard patterns: "./*": "./dist/*.js"
|
|
70
|
+
for (const patternKey of Object.keys(exportsField)) {
|
|
71
|
+
if (!patternKey.includes('*')) continue;
|
|
72
|
+
const [pre, post = ''] = patternKey.split('*');
|
|
73
|
+
if (key.startsWith(pre) && key.endsWith(post) && key.length >= pre.length + post.length) {
|
|
74
|
+
const star = key.slice(pre.length, key.length - post.length);
|
|
75
|
+
const target = resolveExportsValue(exportsField[patternKey]);
|
|
76
|
+
if (target) return target.replace('*', star);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Resolve a bare specifier ("pkg", "pkg/sub", "@scope/pkg/sub")
|
|
84
|
+
// to an absolute file path inside ROOT/node_modules.
|
|
85
|
+
function resolveNodeModule(specifier, ROOT) {
|
|
86
|
+
const parts = specifier.split('/');
|
|
87
|
+
const isScoped = parts[0].startsWith('@');
|
|
88
|
+
const pkgName = isScoped ? parts[0] + '/' + parts[1] : parts[0];
|
|
89
|
+
const subPath = isScoped ? parts.slice(2).join('/') : parts.slice(1).join('/');
|
|
90
|
+
|
|
91
|
+
const pkgDir = path.join(ROOT, 'node_modules', pkgName);
|
|
92
|
+
const pkgJsonPath = path.join(pkgDir, 'package.json');
|
|
93
|
+
if (!fs.existsSync(pkgJsonPath)) return null;
|
|
94
|
+
|
|
95
|
+
let pkg;
|
|
96
|
+
try {
|
|
97
|
+
pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 1. package.json "exports" (modern packages)
|
|
103
|
+
if (pkg.exports) {
|
|
104
|
+
const target = resolveExportsField(pkg.exports, subPath);
|
|
105
|
+
if (target) {
|
|
106
|
+
const resolved = firstExisting([path.join(pkgDir, target)]);
|
|
107
|
+
if (resolved) return resolved;
|
|
108
|
+
}
|
|
109
|
+
// "exports" exists but didn't resolve — fall through only when
|
|
110
|
+
// no subpath was requested, so legacy entry fields can still win.
|
|
111
|
+
if (subPath) return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (subPath) {
|
|
115
|
+
return firstExisting([
|
|
116
|
+
path.join(pkgDir, subPath),
|
|
117
|
+
path.join(pkgDir, 'dist', subPath),
|
|
118
|
+
path.join(pkgDir, 'src', subPath),
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 2. Legacy entry fields: browser (string) → module → main
|
|
123
|
+
const entries = [];
|
|
124
|
+
if (typeof pkg.browser === 'string') entries.push(pkg.browser);
|
|
125
|
+
if (pkg.module) entries.push(pkg.module);
|
|
126
|
+
if (pkg.main) entries.push(pkg.main);
|
|
127
|
+
entries.push('index.js');
|
|
128
|
+
|
|
129
|
+
return firstExisting(entries.map(e => path.join(pkgDir, e)));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = { resolveNodeModule, resolveExportsField };
|