create-dalila 1.2.12 → 1.2.14
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 +17 -6
- package/index.js +88 -0
- package/package.json +4 -1
- package/template/.nvmrc +1 -0
- package/template/package.json +4 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Scaffold a new Dalila project with one command.
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm create dalila my-app
|
|
8
|
+
npm create dalila@latest my-app
|
|
9
9
|
cd my-app
|
|
10
10
|
npm install
|
|
11
11
|
npm run dev
|
|
@@ -13,10 +13,14 @@ npm run dev
|
|
|
13
13
|
|
|
14
14
|
Open http://localhost:4242 to see your app.
|
|
15
15
|
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Node.js `>=22.6.0`
|
|
19
|
+
|
|
16
20
|
## What's Included
|
|
17
21
|
|
|
18
|
-
-
|
|
19
|
-
-
|
|
22
|
+
- File-based router starter (`src/app`)
|
|
23
|
+
- Dev server + route generation watcher
|
|
20
24
|
- TypeScript support out of the box
|
|
21
25
|
- Minimal CSS styling
|
|
22
26
|
|
|
@@ -24,9 +28,14 @@ Open http://localhost:4242 to see your app.
|
|
|
24
28
|
|
|
25
29
|
```
|
|
26
30
|
my-app/
|
|
27
|
-
├──
|
|
31
|
+
├── dev.mjs # Runs route watcher + dev server
|
|
32
|
+
├── index.html # App shell
|
|
28
33
|
├── src/
|
|
29
|
-
│ ├──
|
|
34
|
+
│ ├── app/
|
|
35
|
+
│ │ ├── layout.html
|
|
36
|
+
│ │ ├── page.html
|
|
37
|
+
│ │ └── page.ts
|
|
38
|
+
│ ├── main.ts # Router bootstrap
|
|
30
39
|
│ └── style.css # Styles
|
|
31
40
|
├── package.json
|
|
32
41
|
└── tsconfig.json
|
|
@@ -35,8 +44,10 @@ my-app/
|
|
|
35
44
|
## Scripts
|
|
36
45
|
|
|
37
46
|
- `npm run dev` - Start dev server and route watcher
|
|
47
|
+
- `npm run routes` - Generate route files once
|
|
48
|
+
- `npm run routes:watch` - Watch route files and regenerate outputs
|
|
38
49
|
- `npm run build` - Compile TypeScript
|
|
39
50
|
|
|
40
51
|
## Learn More
|
|
41
52
|
|
|
42
|
-
- [Dalila Documentation](https://github.com/
|
|
53
|
+
- [Dalila Documentation](https://github.com/evertondsvieira/dalila)
|
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ const green = (text) => `\x1b[32m${text}\x1b[0m`;
|
|
|
15
15
|
const cyan = (text) => `\x1b[36m${text}\x1b[0m`;
|
|
16
16
|
const yellow = (text) => `\x1b[33m${text}\x1b[0m`;
|
|
17
17
|
const bold = (text) => `\x1b[1m${text}\x1b[0m`;
|
|
18
|
+
const MIN_NODE = { major: 22, minor: 6, patch: 0 };
|
|
18
19
|
|
|
19
20
|
function printHelp() {
|
|
20
21
|
console.log(`
|
|
@@ -34,6 +35,80 @@ ${bold('Options:')}
|
|
|
34
35
|
`);
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
function compareVersions(a, b) {
|
|
39
|
+
if (a.major !== b.major) return a.major - b.major;
|
|
40
|
+
if (a.minor !== b.minor) return a.minor - b.minor;
|
|
41
|
+
return a.patch - b.patch;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function parseNodeVersion(version) {
|
|
45
|
+
const [major = '0', minor = '0', patch = '0'] = version.split('.');
|
|
46
|
+
return {
|
|
47
|
+
major: Number.parseInt(major, 10) || 0,
|
|
48
|
+
minor: Number.parseInt(minor, 10) || 0,
|
|
49
|
+
patch: Number.parseInt(patch, 10) || 0,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function ensureSupportedNode() {
|
|
54
|
+
const current = parseNodeVersion(process.versions.node);
|
|
55
|
+
if (compareVersions(current, MIN_NODE) >= 0) return;
|
|
56
|
+
|
|
57
|
+
console.error(
|
|
58
|
+
`${yellow('Error:')} Node.js ${MIN_NODE.major}.${MIN_NODE.minor}.${MIN_NODE.patch}+ is required to create and run Dalila apps.\n`
|
|
59
|
+
);
|
|
60
|
+
console.error(`Current version: ${process.versions.node}`);
|
|
61
|
+
console.error('Please upgrade Node.js and try again.\n');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function suggestPackageName(input) {
|
|
66
|
+
return (input || 'my-app')
|
|
67
|
+
.trim()
|
|
68
|
+
.toLowerCase()
|
|
69
|
+
.replace(/\s+/g, '-')
|
|
70
|
+
.replace(/[^a-z0-9._~-]/g, '-')
|
|
71
|
+
.replace(/-+/g, '-')
|
|
72
|
+
.replace(/^[._-]+/, '')
|
|
73
|
+
.replace(/[._-]+$/, '') || 'my-app';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function validateProjectName(name) {
|
|
77
|
+
const trimmed = name.trim();
|
|
78
|
+
const errors = [];
|
|
79
|
+
|
|
80
|
+
if (trimmed.length === 0) {
|
|
81
|
+
errors.push('Project name cannot be empty.');
|
|
82
|
+
}
|
|
83
|
+
if (trimmed !== name) {
|
|
84
|
+
errors.push('Project name cannot start or end with spaces.');
|
|
85
|
+
}
|
|
86
|
+
if (trimmed.length > 214) {
|
|
87
|
+
errors.push('Project name must be 214 characters or fewer.');
|
|
88
|
+
}
|
|
89
|
+
if (trimmed.includes('/')) {
|
|
90
|
+
errors.push('Use an unscoped package name (e.g. "my-app").');
|
|
91
|
+
}
|
|
92
|
+
if (/[A-Z]/.test(trimmed)) {
|
|
93
|
+
errors.push('Project name must be lowercase.');
|
|
94
|
+
}
|
|
95
|
+
if (trimmed.startsWith('.') || trimmed.startsWith('_')) {
|
|
96
|
+
errors.push('Project name cannot start with "." or "_".');
|
|
97
|
+
}
|
|
98
|
+
if (!/^[a-z0-9][a-z0-9._~-]*$/.test(trimmed)) {
|
|
99
|
+
errors.push('Use only lowercase letters, numbers, ".", "_", "~", and "-".');
|
|
100
|
+
}
|
|
101
|
+
if (trimmed === 'node_modules' || trimmed === 'favicon.ico') {
|
|
102
|
+
errors.push(`"${trimmed}" is not a valid package name.`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
valid: errors.length === 0,
|
|
107
|
+
errors,
|
|
108
|
+
suggested: suggestPackageName(trimmed),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
37
112
|
function copyDir(src, dest) {
|
|
38
113
|
fs.mkdirSync(dest, { recursive: true });
|
|
39
114
|
|
|
@@ -57,6 +132,8 @@ function updatePackageJson(projectPath, projectName) {
|
|
|
57
132
|
}
|
|
58
133
|
|
|
59
134
|
function main() {
|
|
135
|
+
ensureSupportedNode();
|
|
136
|
+
|
|
60
137
|
// Handle flags
|
|
61
138
|
if (args.includes('-h') || args.includes('--help')) {
|
|
62
139
|
printHelp();
|
|
@@ -78,6 +155,17 @@ function main() {
|
|
|
78
155
|
process.exit(1);
|
|
79
156
|
}
|
|
80
157
|
|
|
158
|
+
const validation = validateProjectName(projectName);
|
|
159
|
+
if (!validation.valid) {
|
|
160
|
+
console.error(`${yellow('Error:')} Invalid project name "${projectName}".\n`);
|
|
161
|
+
for (const error of validation.errors) {
|
|
162
|
+
console.error(`- ${error}`);
|
|
163
|
+
}
|
|
164
|
+
console.error('\nTry something like:');
|
|
165
|
+
console.error(` npm create dalila ${cyan(validation.suggested)}\n`);
|
|
166
|
+
process.exit(1);
|
|
167
|
+
}
|
|
168
|
+
|
|
81
169
|
// Check if directory exists
|
|
82
170
|
const projectPath = path.resolve(process.cwd(), projectName);
|
|
83
171
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-dalila",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14",
|
|
4
4
|
"description": "Create Dalila apps with one command",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-dalila": "index.js"
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"author": "Everton Da Silva Vieira",
|
|
25
25
|
"license": "MIT",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22.6.0"
|
|
28
|
+
},
|
|
26
29
|
"repository": {
|
|
27
30
|
"type": "git",
|
|
28
31
|
"url": "https://github.com/evertondsvieira/dalila.git"
|
package/template/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22
|
package/template/package.json
CHANGED