vako 1.3.4 → 1.3.5
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/commands/setup-executor.js +153 -12
- package/bin/vako.js +1 -1
- package/package.json +1 -1
|
@@ -134,9 +134,7 @@ class SetupExecutor {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
async generateTemplateFiles() {
|
|
137
|
-
const
|
|
138
|
-
const generator = new TemplateGenerator(this.config);
|
|
139
|
-
const files = generator.generateFiles();
|
|
137
|
+
const files = this.generateFiles();
|
|
140
138
|
|
|
141
139
|
for (const [filePath, content] of Object.entries(files)) {
|
|
142
140
|
const fullPath = path.join(this.projectPath, filePath);
|
|
@@ -150,24 +148,167 @@ class SetupExecutor {
|
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
150
|
|
|
151
|
+
generateFiles() {
|
|
152
|
+
const { projectName, description, author, license, template, features, database, auth, styling } = this.config;
|
|
153
|
+
const files = {};
|
|
154
|
+
|
|
155
|
+
// package.json
|
|
156
|
+
files['package.json'] = JSON.stringify({
|
|
157
|
+
name: projectName,
|
|
158
|
+
version: '1.0.0',
|
|
159
|
+
description: description || 'A modern web application built with Vako',
|
|
160
|
+
main: 'app.js',
|
|
161
|
+
scripts: {
|
|
162
|
+
dev: 'vako dev',
|
|
163
|
+
start: 'vako start',
|
|
164
|
+
build: 'vako build'
|
|
165
|
+
},
|
|
166
|
+
keywords: ['vako', 'framework', 'web'],
|
|
167
|
+
author: author || '',
|
|
168
|
+
license: license || 'MIT',
|
|
169
|
+
dependencies: {
|
|
170
|
+
vako: '^1.3.4'
|
|
171
|
+
}
|
|
172
|
+
}, null, 2);
|
|
173
|
+
|
|
174
|
+
// app.js
|
|
175
|
+
files['app.js'] = `const { App } = require('vako');
|
|
176
|
+
|
|
177
|
+
const app = new App({
|
|
178
|
+
port: 3000,
|
|
179
|
+
isDev: true,
|
|
180
|
+
viewsDir: 'views',
|
|
181
|
+
staticDir: 'public',
|
|
182
|
+
routesDir: 'routes'
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
app.loadRoutes();
|
|
186
|
+
app.listen();
|
|
187
|
+
`;
|
|
188
|
+
|
|
189
|
+
// README.md
|
|
190
|
+
files['README.md'] = `# ${projectName}
|
|
191
|
+
|
|
192
|
+
${description || 'A modern web application built with Vako'}
|
|
193
|
+
|
|
194
|
+
## Getting Started
|
|
195
|
+
|
|
196
|
+
\`\`\`bash
|
|
197
|
+
npm install
|
|
198
|
+
npm run dev
|
|
199
|
+
\`\`\`
|
|
200
|
+
|
|
201
|
+
## Documentation
|
|
202
|
+
|
|
203
|
+
Visit [https://vako.js.org](https://vako.js.org) for more information.
|
|
204
|
+
`;
|
|
205
|
+
|
|
206
|
+
// .gitignore
|
|
207
|
+
files['.gitignore'] = `node_modules/
|
|
208
|
+
.env
|
|
209
|
+
*.log
|
|
210
|
+
.DS_Store
|
|
211
|
+
dist/
|
|
212
|
+
coverage/
|
|
213
|
+
`;
|
|
214
|
+
|
|
215
|
+
// routes/index.js
|
|
216
|
+
files['routes/index.js'] = `const { Router } = require('express');
|
|
217
|
+
const router = Router();
|
|
218
|
+
|
|
219
|
+
router.get('/', (req, res) => {
|
|
220
|
+
res.render('index', {
|
|
221
|
+
title: 'Welcome to ${projectName}'
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
module.exports = router;
|
|
226
|
+
`;
|
|
227
|
+
|
|
228
|
+
// views/index.ejs
|
|
229
|
+
files['views/index.ejs'] = `<!DOCTYPE html>
|
|
230
|
+
<html lang="en">
|
|
231
|
+
<head>
|
|
232
|
+
<meta charset="UTF-8">
|
|
233
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
234
|
+
<title><%= title %></title>
|
|
235
|
+
</head>
|
|
236
|
+
<body>
|
|
237
|
+
<h1><%= title %></h1>
|
|
238
|
+
<p>Welcome to your Vako application!</p>
|
|
239
|
+
</body>
|
|
240
|
+
</html>
|
|
241
|
+
`;
|
|
242
|
+
|
|
243
|
+
// public/css/style.css
|
|
244
|
+
files['public/css/style.css'] = `body {
|
|
245
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
246
|
+
margin: 0;
|
|
247
|
+
padding: 20px;
|
|
248
|
+
background-color: #f5f5f5;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
h1 {
|
|
252
|
+
color: #333;
|
|
253
|
+
}
|
|
254
|
+
`;
|
|
255
|
+
|
|
256
|
+
// public/js/main.js
|
|
257
|
+
files['public/js/main.js'] = `console.log('Vako loaded');
|
|
258
|
+
`;
|
|
259
|
+
|
|
260
|
+
return files;
|
|
261
|
+
}
|
|
262
|
+
|
|
153
263
|
async configureFeatures() {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
await configurer.configure();
|
|
264
|
+
// Configure features based on this.config.features
|
|
265
|
+
// This is a placeholder - features are already configured in generateFiles()
|
|
157
266
|
}
|
|
158
267
|
|
|
159
268
|
async setupAuthentication() {
|
|
160
269
|
if (this.config.auth.enabled) {
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
270
|
+
// Create auth routes and middleware
|
|
271
|
+
const authRoute = `const { Router } = require('express');
|
|
272
|
+
const router = Router();
|
|
273
|
+
|
|
274
|
+
router.get('/login', (req, res) => {
|
|
275
|
+
res.render('auth/login', { title: 'Login' });
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
router.post('/login', async (req, res) => {
|
|
279
|
+
// Implement login logic here
|
|
280
|
+
res.redirect('/');
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
router.get('/logout', (req, res) => {
|
|
284
|
+
// Implement logout logic here
|
|
285
|
+
res.redirect('/');
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
module.exports = router;
|
|
289
|
+
`;
|
|
290
|
+
|
|
291
|
+
const authPath = path.join(this.projectPath, 'routes/auth.js');
|
|
292
|
+
fs.writeFileSync(authPath, authRoute, 'utf8');
|
|
164
293
|
}
|
|
165
294
|
}
|
|
166
295
|
|
|
167
296
|
async setupDatabase() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
297
|
+
if (this.config.database !== 'none') {
|
|
298
|
+
// Create database configuration file
|
|
299
|
+
const dbConfig = `module.exports = {
|
|
300
|
+
type: '${this.config.database}',
|
|
301
|
+
// Add your database configuration here
|
|
302
|
+
};
|
|
303
|
+
`;
|
|
304
|
+
|
|
305
|
+
const dbPath = path.join(this.projectPath, 'config/database.js');
|
|
306
|
+
const dbDir = path.dirname(dbPath);
|
|
307
|
+
if (!fs.existsSync(dbDir)) {
|
|
308
|
+
fs.mkdirSync(dbDir, { recursive: true });
|
|
309
|
+
}
|
|
310
|
+
fs.writeFileSync(dbPath, dbConfig, 'utf8');
|
|
311
|
+
}
|
|
171
312
|
}
|
|
172
313
|
|
|
173
314
|
async initializeGit() {
|
package/bin/vako.js
CHANGED
package/package.json
CHANGED