aaex-cli 3.1.2 → 3.1.4
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/create-aaex-app.js +38 -72
- package/package.json +1 -1
- package/template/index.html +1 -1
- package/template/package-lock.json +3454 -0
- package/template/package.json +42 -0
- package/template/src/App.tsx +3 -20
- package/template/src/server-routes.ts +5 -0
- package/template/vite.config.ts +1 -1
package/create-aaex-app.js
CHANGED
|
@@ -32,64 +32,7 @@ async function copyTemplate(database = "MongoDB") {
|
|
|
32
32
|
errorOnExist: false,
|
|
33
33
|
});
|
|
34
34
|
} catch (err) {
|
|
35
|
-
console.error(chalk.red("
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Create package.json
|
|
41
|
-
async function createPackageJson() {
|
|
42
|
-
const pkg = {
|
|
43
|
-
name: appName,
|
|
44
|
-
version: "0.0.0",
|
|
45
|
-
private: true,
|
|
46
|
-
type: "module",
|
|
47
|
-
scripts: {
|
|
48
|
-
dev: "node .aaex/server/server.js",
|
|
49
|
-
build: "npm build client && npm client-entry && npm build:server",
|
|
50
|
-
"build:client": "vite build",
|
|
51
|
-
"build:server": "vite build --config vite.server.config.ts",
|
|
52
|
-
"client-entry": "node .aaex/Build.js",
|
|
53
|
-
preview: "cross-env NODE_ENV=production node .aaex/server/server.js",
|
|
54
|
-
},
|
|
55
|
-
dependencies: {
|
|
56
|
-
react: "^19.1.1",
|
|
57
|
-
"react-dom": "^19.1.1",
|
|
58
|
-
"react-router": "^7.10.0",
|
|
59
|
-
"react-router-dom": "^7.10.0",
|
|
60
|
-
express: "^5.1.0",
|
|
61
|
-
compression: "^1.8.1",
|
|
62
|
-
sirv: "^3.0.2",
|
|
63
|
-
"aaex-file-router": "^2.4.2",
|
|
64
|
-
jsonwebtoken: "^9.0.3",
|
|
65
|
-
mongodb: "^7.0.0",
|
|
66
|
-
pg: "^8.16.3",
|
|
67
|
-
|
|
68
|
-
bcrypt: "^6.0.0",
|
|
69
|
-
dotenv: "^17.2.3",
|
|
70
|
-
aaexjs: "^3.1.3",
|
|
71
|
-
},
|
|
72
|
-
devDependencies: {
|
|
73
|
-
typescript: "~5.9.2",
|
|
74
|
-
"@types/react": "^19.1.13",
|
|
75
|
-
"@types/react-dom": "^19.1.9",
|
|
76
|
-
"@types/express": "^5.0.3",
|
|
77
|
-
"@vitejs/plugin-react": "^5.0.2",
|
|
78
|
-
"@types/pg": "^8.16.0",
|
|
79
|
-
|
|
80
|
-
vite: "^7.1.5",
|
|
81
|
-
"cross-env": "^10.0.0",
|
|
82
|
-
"@types/bcrypt": "^6.0.0",
|
|
83
|
-
"@types/jsonwebtoken": "^9.0.10",
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
await fs.writeJson(path.join(targetDir, "package.json"), pkg, {
|
|
89
|
-
spaces: 2,
|
|
90
|
-
});
|
|
91
|
-
} catch (err) {
|
|
92
|
-
console.error(chalk.red("Error creating package.json:"), err);
|
|
35
|
+
console.error(chalk.red("Error copying template:"), err);
|
|
93
36
|
process.exit(1);
|
|
94
37
|
}
|
|
95
38
|
}
|
|
@@ -101,30 +44,19 @@ async function main() {
|
|
|
101
44
|
process.exit(1);
|
|
102
45
|
}
|
|
103
46
|
|
|
104
|
-
//
|
|
47
|
+
//DB config
|
|
105
48
|
const answers = await inquirer.prompt([
|
|
106
49
|
{
|
|
107
50
|
type: "select",
|
|
108
51
|
name: "database",
|
|
109
52
|
message: "Which database do you want to use?",
|
|
110
|
-
choices: [
|
|
111
|
-
"MongoDB",
|
|
112
|
-
"MySQL --not implemented",
|
|
113
|
-
"PostgreSQL --not fully implemented",
|
|
114
|
-
],
|
|
53
|
+
choices: ["MongoDB", "PostgreSQL"],
|
|
115
54
|
default: 0,
|
|
116
55
|
},
|
|
117
56
|
]);
|
|
118
57
|
|
|
119
|
-
if (answers.database !== "MongoDB") {
|
|
120
|
-
console.log(
|
|
121
|
-
chalk.yellow(`Currently only MongoDB is supported. Aborting...`)
|
|
122
|
-
);
|
|
123
|
-
process.exit(0);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
58
|
await copyTemplate(answers.database);
|
|
127
|
-
|
|
59
|
+
createEnv(answers.database);
|
|
128
60
|
|
|
129
61
|
console.log(chalk.green.bold("\nAAEx app created successfully!"));
|
|
130
62
|
console.log(
|
|
@@ -132,4 +64,38 @@ async function main() {
|
|
|
132
64
|
);
|
|
133
65
|
}
|
|
134
66
|
|
|
67
|
+
function createEnv(db) {
|
|
68
|
+
console.log(chalk.blue("\nSetting up .env ..."));
|
|
69
|
+
let db_fields;
|
|
70
|
+
|
|
71
|
+
switch (db) {
|
|
72
|
+
case "MongoDB":
|
|
73
|
+
db_fields = `
|
|
74
|
+
DB_TYPE="mongodb"
|
|
75
|
+
DB_URL="mongodb://localhost:27018/"
|
|
76
|
+
DB_NAME="mydatabase"
|
|
77
|
+
`;
|
|
78
|
+
break;
|
|
79
|
+
case "PostgreSQL":
|
|
80
|
+
db_fields = `
|
|
81
|
+
DB_TYPE="postgres"
|
|
82
|
+
DB_URL="postgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName"
|
|
83
|
+
`;
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
default:
|
|
87
|
+
db_fields = `#no database configured`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const jwt_fields = `
|
|
91
|
+
JWT_SECRET="your-jwt-secret"
|
|
92
|
+
JWT_EXP="24h"`;
|
|
93
|
+
|
|
94
|
+
fs.writeFileSync(
|
|
95
|
+
path.resolve(targetDir, ".env"),
|
|
96
|
+
db_fields + jwt_fields,
|
|
97
|
+
"utf-8"
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
135
101
|
main();
|
package/package.json
CHANGED
package/template/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" /> -->
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<link rel="stylesheet" href="
|
|
7
|
+
<link rel="stylesheet" href="/src/index.css" />
|
|
8
8
|
<title>AaExJS</title>
|
|
9
9
|
<!--app-head-->
|
|
10
10
|
</head>
|