create-aeui-app 0.0.1
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/index.js +85 -0
- package/package.json +21 -0
- package/template/gitignore +4 -0
- package/template/index.html +11 -0
- package/template/jsconfig.json +8 -0
- package/template/package.json +20 -0
- package/template/src/pages/about.jsx +9 -0
- package/template/src/pages/index.jsx +12 -0
- package/template/src/pages/products/[id].jsx +9 -0
- package/template/vite.config.js +6 -0
package/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const projectName = args[0];
|
|
9
|
+
|
|
10
|
+
function printUsage() {
|
|
11
|
+
console.error('Please specify the project name:');
|
|
12
|
+
console.error(' npx create-aeui-app <project-name>');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isValidPackageName(name) {
|
|
16
|
+
if (typeof name !== 'string') return false;
|
|
17
|
+
if (!name || name.length > 214) return false;
|
|
18
|
+
if (name === 'node_modules' || name === 'favicon.ico') return false;
|
|
19
|
+
if (name.startsWith('.') || name.startsWith('_')) return false;
|
|
20
|
+
if (name.includes('/') || name.includes('\\')) return false;
|
|
21
|
+
return /^[a-z0-9][a-z0-9._-]*$/.test(name);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
25
|
+
printUsage();
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!projectName) {
|
|
30
|
+
printUsage();
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (args.length > 1) {
|
|
35
|
+
console.error('Only one project name can be provided.');
|
|
36
|
+
printUsage();
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const templateDir = path.join(__dirname, 'template');
|
|
41
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
42
|
+
|
|
43
|
+
if (!isValidPackageName(projectName)) {
|
|
44
|
+
console.error(`Invalid project name: ${projectName}`);
|
|
45
|
+
console.error('Use a lowercase npm package name without spaces or path separators.');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (fs.existsSync(targetDir)) {
|
|
50
|
+
console.error(`Directory ${projectName} already exists.`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
console.log(`Creating a new AEUI app in ${targetDir}...`);
|
|
55
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
56
|
+
|
|
57
|
+
function copyDir(src, dest) {
|
|
58
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
59
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
60
|
+
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
const srcPath = path.join(src, entry.name);
|
|
63
|
+
const destName = entry.name === 'gitignore' ? '.gitignore' : entry.name;
|
|
64
|
+
const destPath = path.join(dest, destName);
|
|
65
|
+
|
|
66
|
+
if (entry.isDirectory()) {
|
|
67
|
+
copyDir(srcPath, destPath);
|
|
68
|
+
} else {
|
|
69
|
+
fs.copyFileSync(srcPath, destPath);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
copyDir(templateDir, targetDir);
|
|
75
|
+
|
|
76
|
+
// Update package.json name
|
|
77
|
+
const pkgFile = path.join(targetDir, 'package.json');
|
|
78
|
+
const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
|
|
79
|
+
pkg.name = projectName;
|
|
80
|
+
fs.writeFileSync(pkgFile, JSON.stringify(pkg, null, 2));
|
|
81
|
+
|
|
82
|
+
console.log(`\nDone! Now run:\n`);
|
|
83
|
+
console.log(` cd ${projectName}`);
|
|
84
|
+
console.log(` npm install`);
|
|
85
|
+
console.log(` npm run dev`);
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-aeui-app",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Scaffolding tool for AEUI apps",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-aeui-app": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js",
|
|
12
|
+
"template"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"aeui",
|
|
16
|
+
"cli",
|
|
17
|
+
"scaffold"
|
|
18
|
+
],
|
|
19
|
+
"author": "",
|
|
20
|
+
"license": "ISC"
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aeui-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"aeui": "npm:a-easy-ui@^0.0.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"vite": "^8.0.0"
|
|
19
|
+
}
|
|
20
|
+
}
|