create-fs-app 1.1.9 → 2.0.0

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.
Files changed (43) hide show
  1. package/README.md +524 -23
  2. package/dist/core/health-check.d.ts +21 -0
  3. package/dist/core/health-check.js +253 -0
  4. package/dist/core/health-check.js.map +1 -0
  5. package/dist/core/presets.d.ts +44 -0
  6. package/dist/core/presets.js +194 -0
  7. package/dist/core/presets.js.map +1 -0
  8. package/dist/core/scaffold.d.ts +32 -0
  9. package/dist/core/scaffold.js +106 -0
  10. package/dist/core/scaffold.js.map +1 -0
  11. package/dist/core/template-cache.d.ts +38 -0
  12. package/dist/core/template-cache.js +219 -0
  13. package/dist/core/template-cache.js.map +1 -0
  14. package/dist/core/template-clone.d.ts +27 -0
  15. package/dist/core/template-clone.js +335 -0
  16. package/dist/core/template-clone.js.map +1 -0
  17. package/dist/core/template-list.d.ts +34 -0
  18. package/dist/core/template-list.js +132 -0
  19. package/dist/core/template-list.js.map +1 -0
  20. package/dist/core/template-registry.d.ts +57 -0
  21. package/dist/core/template-registry.js +116 -0
  22. package/dist/core/template-registry.js.map +1 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +642 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/types/index.d.ts +106 -0
  27. package/dist/types/index.js +69 -0
  28. package/dist/types/index.js.map +1 -0
  29. package/dist/utils/errors.d.ts +15 -0
  30. package/dist/utils/errors.js +50 -0
  31. package/dist/utils/errors.js.map +1 -0
  32. package/dist/utils/logger.d.ts +37 -0
  33. package/dist/utils/logger.js +62 -0
  34. package/dist/utils/logger.js.map +1 -0
  35. package/dist/utils/validation.d.ts +25 -0
  36. package/dist/utils/validation.js +63 -0
  37. package/dist/utils/validation.js.map +1 -0
  38. package/package.json +81 -33
  39. package/assets/logo.png +0 -0
  40. package/assets/s1.png +0 -0
  41. package/assets/s2.png +0 -0
  42. package/create-fs-app.js +0 -139
  43. package/package-lock.json +0 -1408
package/dist/index.js ADDED
@@ -0,0 +1,642 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import prompts from 'prompts';
4
+ import chalk from 'chalk';
5
+ import gradient from 'gradient-string';
6
+ import figlet from 'figlet';
7
+ import ora from 'ora';
8
+ import boxen from 'boxen';
9
+ import updateNotifier from 'update-notifier';
10
+ import { readFileSync } from 'fs';
11
+ import { fileURLToPath } from 'url';
12
+ import { dirname, join } from 'path';
13
+ import { ProjectConfigSchema, MonorepoFramework, FrontendFramework, BackendFramework, Database, PackageManager } from './types/index.js';
14
+ import { scaffoldProject, validateProjectDirectory, checkTemplateAvailability, TemplateNotFoundError } from './core/scaffold.js';
15
+ import { displayAvailableTemplates, getTemplateByName } from './core/template-list.js';
16
+ import { assertValidProjectName } from './utils/validation.js';
17
+ import { Logger } from './utils/logger.js';
18
+ import { loadPreset, listPresets, deletePreset, getBuiltinPreset, BUILTIN_PRESETS } from './core/presets.js';
19
+ import { runHealthCheck, displayHealthCheckResults } from './core/health-check.js';
20
+ import { clearCache, getCacheStats } from './core/template-cache.js';
21
+ import { createCustomTemplate } from './core/template-registry.js';
22
+ import { validateTemplateUrl } from './utils/validation.js';
23
+ const __filename = fileURLToPath(import.meta.url);
24
+ const __dirname = dirname(__filename);
25
+ // Check for updates
26
+ const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
27
+ updateNotifier({ pkg }).notify();
28
+ const sleep = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
29
+ async function welcome() {
30
+ // Add spacing to separate from previous commands without clearing history
31
+ console.log('\n'.repeat(2));
32
+ // ASCII art title with filled/solid characters
33
+ const title = figlet.textSync('create-fs-app', {
34
+ font: 'ANSI Shadow',
35
+ horizontalLayout: 'fitted'
36
+ });
37
+ console.log(gradient.pastel.multiline(title));
38
+ console.log();
39
+ // Welcome box
40
+ const welcomeMsg = boxen(chalk.white.bold('Create production-ready full-stack applications\n') +
41
+ chalk.gray('Template-based • Fast • Customizable\n\n') +
42
+ chalk.cyan('✓ TypeScript only (no JavaScript projects)\n') +
43
+ chalk.cyan('✓ Multiple monorepo frameworks\n') +
44
+ chalk.cyan('✓ Customizable frontend & backend\n') +
45
+ chalk.cyan('✓ Database & ORM selection\n') +
46
+ chalk.cyan('✓ Docker & Testing setup'), {
47
+ padding: 1,
48
+ margin: 1,
49
+ borderStyle: 'round',
50
+ borderColor: 'cyan',
51
+ title: chalk.bold.cyan(`v${pkg.version}`),
52
+ titleAlignment: 'center'
53
+ });
54
+ console.log(welcomeMsg);
55
+ console.log();
56
+ }
57
+ /**
58
+ * Build configuration from CLI options
59
+ */
60
+ function buildConfigFromOptions(name, options) {
61
+ // Validate required fields
62
+ if (!name) {
63
+ Logger.error('Project name is required.');
64
+ console.log(chalk.cyan('Usage: create-fs-app <project-name> [options]\n'));
65
+ process.exit(1);
66
+ }
67
+ // Validate project name
68
+ assertValidProjectName(name);
69
+ if (!options.monorepo || !options.frontend || !options.backend || !options.database) {
70
+ Logger.error('When using CLI options, you must provide:');
71
+ console.log(chalk.yellow(' --monorepo <framework>'));
72
+ console.log(chalk.yellow(' --frontend <framework>'));
73
+ console.log(chalk.yellow(' --backend <framework>'));
74
+ console.log(chalk.yellow(' --database <db>\n'));
75
+ console.log(chalk.cyan('💡 Or run without options for interactive mode.\n'));
76
+ process.exit(1);
77
+ }
78
+ // Validate enum values
79
+ const validateEnum = (value, enumObj, name) => {
80
+ const validValues = Object.values(enumObj);
81
+ const found = validValues.find((v) => v.toLowerCase() === value.toLowerCase());
82
+ if (!found) {
83
+ console.log(chalk.red(`\n❌ Invalid ${name}: "${value}"\n`));
84
+ console.log(chalk.cyan(`Valid options: ${validValues.join(', ')}\n`));
85
+ process.exit(1);
86
+ }
87
+ return found;
88
+ };
89
+ const config = {
90
+ name,
91
+ monorepo: validateEnum(options.monorepo, MonorepoFramework, 'monorepo framework'),
92
+ packageManager: options.packageManager
93
+ ? validateEnum(options.packageManager, PackageManager, 'package manager')
94
+ : PackageManager.NPM,
95
+ apps: {
96
+ frontend: {
97
+ framework: validateEnum(options.frontend, FrontendFramework, 'frontend framework'),
98
+ // TypeScript is always enabled
99
+ styling: options.styling || 'tailwind',
100
+ linting: options.linting !== false // default true
101
+ },
102
+ backend: {
103
+ framework: validateEnum(options.backend, BackendFramework, 'backend framework'),
104
+ database: validateEnum(options.database, Database, 'database'),
105
+ orm: options.orm,
106
+ docker: options.docker !== false // default true based on options
107
+ }
108
+ }
109
+ };
110
+ // Validate the config with Zod
111
+ try {
112
+ return ProjectConfigSchema.parse(config);
113
+ }
114
+ catch (error) {
115
+ Logger.error('Invalid configuration:');
116
+ console.error(error);
117
+ process.exit(1);
118
+ }
119
+ }
120
+ async function promptForConfiguration(projectName) {
121
+ const questions = [];
122
+ if (!projectName) {
123
+ questions.push({
124
+ type: 'text',
125
+ name: 'name',
126
+ message: 'What is your project named?',
127
+ initial: 'my-fs-app'
128
+ });
129
+ }
130
+ questions.push({
131
+ type: 'select',
132
+ name: 'monorepo',
133
+ message: 'Select a monorepo framework:',
134
+ choices: Object.values(MonorepoFramework).map(v => ({ title: v, value: v }))
135
+ }, {
136
+ type: 'select',
137
+ name: 'packageManager',
138
+ message: 'Select a package manager:',
139
+ choices: Object.values(PackageManager).map(v => ({ title: v, value: v }))
140
+ }, {
141
+ type: 'select',
142
+ name: 'frontendFramework',
143
+ message: 'Select a frontend framework:',
144
+ choices: Object.values(FrontendFramework).map(v => ({ title: v, value: v }))
145
+ }, {
146
+ type: 'select',
147
+ name: 'styling',
148
+ message: 'Select a styling solution:',
149
+ choices: [
150
+ { title: 'css', value: 'css' },
151
+ { title: 'scss', value: 'scss' },
152
+ { title: 'tailwind', value: 'tailwind' },
153
+ { title: 'styled-components', value: 'styled-components' }
154
+ ]
155
+ }, {
156
+ type: 'confirm',
157
+ name: 'linting',
158
+ message: 'Enable ESLint and Prettier?',
159
+ initial: true
160
+ }, {
161
+ type: 'select',
162
+ name: 'backendFramework',
163
+ message: 'Select a backend framework:',
164
+ choices: Object.values(BackendFramework).map(v => ({ title: v, value: v }))
165
+ }, {
166
+ type: 'select',
167
+ name: 'database',
168
+ message: 'Select a database:',
169
+ choices: Object.values(Database).map(v => ({ title: v, value: v }))
170
+ }, {
171
+ type: 'select',
172
+ name: 'orm',
173
+ message: 'Select an ORM:',
174
+ choices: [
175
+ { title: 'prisma', value: 'prisma' },
176
+ { title: 'typeorm', value: 'typeorm' },
177
+ { title: 'mongoose', value: 'mongoose' },
178
+ { title: 'drizzle', value: 'drizzle' }
179
+ ]
180
+ }, {
181
+ type: 'confirm',
182
+ name: 'docker',
183
+ message: 'Include Docker configuration?',
184
+ initial: true
185
+ });
186
+ const answers = await prompts(questions, {
187
+ onCancel: () => {
188
+ console.log(chalk.yellow('\n\nOperation cancelled by user'));
189
+ process.exit(0);
190
+ }
191
+ });
192
+ // Build config from flat answers
193
+ const config = {
194
+ name: projectName || answers.name,
195
+ monorepo: answers.monorepo,
196
+ packageManager: answers.packageManager,
197
+ apps: {
198
+ frontend: {
199
+ framework: answers.frontendFramework,
200
+ styling: answers.styling,
201
+ linting: answers.linting
202
+ },
203
+ backend: {
204
+ framework: answers.backendFramework,
205
+ database: answers.database,
206
+ orm: answers.orm,
207
+ docker: answers.docker
208
+ }
209
+ }
210
+ };
211
+ // Validate configuration using Zod
212
+ return ProjectConfigSchema.parse(config);
213
+ }
214
+ async function main() {
215
+ const program = new Command();
216
+ program
217
+ .name('create-fs-app')
218
+ .description('Create a full-stack monorepo application')
219
+ .version('2.0.0');
220
+ // Main create command
221
+ program
222
+ .argument('[name]', 'The name of your application')
223
+ .option('-t, --template <name>', 'Use a predefined template')
224
+ .option('--template-url <url>', 'Use a custom template from GitHub URL')
225
+ .option('--preset <name>', 'Use a configuration preset')
226
+ .option('--monorepo <framework>', 'Monorepo framework (turborepo, nx, lerna)')
227
+ .option('--frontend <framework>', 'Frontend framework (react, next.js, vue, nuxt, angular)')
228
+ .option('--backend <framework>', 'Backend framework (express, nest.js, fastify, koa)')
229
+ .option('--database <db>', 'Database (postgresql, mongodb, mysql, sqlite)')
230
+ .option('--orm <orm>', 'ORM (prisma, typeorm, mongoose, drizzle)')
231
+ .option('--package-manager <pm>', 'Package manager (npm, yarn, pnpm)')
232
+ .option('--styling <style>', 'Styling solution (css, scss, tailwind, styled-components)')
233
+ .option('--linting', 'Enable linting (default: true)')
234
+ .option('--no-linting', 'Disable linting')
235
+ .option('--docker', 'Include Docker configuration')
236
+ .option('--no-docker', 'Skip Docker configuration')
237
+ .option('--no-git', 'Skip git initialization')
238
+ .option('--no-install', 'Skip package installation')
239
+ .option('--no-cache', 'Skip template caching')
240
+ .option('-y, --yes', 'Skip prompts and use defaults')
241
+ .action(async (name, options) => {
242
+ await welcome();
243
+ try {
244
+ let projectConfig;
245
+ let customTemplate = null;
246
+ // Check if using preset
247
+ if (options.preset) {
248
+ if (!name) {
249
+ Logger.error('Project name is required when using --preset.');
250
+ console.log(chalk.cyan('Usage: create-fs-app <project-name> --preset <preset-name>\n'));
251
+ process.exit(1);
252
+ }
253
+ // Try built-in preset first
254
+ let preset = getBuiltinPreset(options.preset);
255
+ // If not built-in, try user preset
256
+ if (!preset) {
257
+ preset = await loadPreset(options.preset);
258
+ }
259
+ if (!preset) {
260
+ Logger.error(`Preset "${options.preset}" not found`);
261
+ console.log(chalk.cyan('\n💡 Use ') + chalk.white.bold('create-fs-app preset list') + chalk.cyan(' to see available presets.\n'));
262
+ process.exit(1);
263
+ }
264
+ projectConfig = {
265
+ name,
266
+ ...preset.config
267
+ };
268
+ console.log();
269
+ const infoBox = boxen(chalk.cyan.bold('🎯 Using Preset\n\n') +
270
+ chalk.white(`Preset: `) + chalk.green(preset.name) + '\n' +
271
+ (preset.description ? chalk.white(`Description: `) + chalk.gray(preset.description) : ''), {
272
+ padding: 1,
273
+ margin: 1,
274
+ borderStyle: 'round',
275
+ borderColor: 'cyan'
276
+ });
277
+ console.log(infoBox);
278
+ }
279
+ // Check if using custom template URL
280
+ else if (options.templateUrl) {
281
+ if (!name) {
282
+ Logger.error('Project name is required when using --template-url.');
283
+ console.log(chalk.cyan('Usage: create-fs-app <project-name> --template-url <url>\n'));
284
+ process.exit(1);
285
+ }
286
+ // Validate URL
287
+ const validation = validateTemplateUrl(options.templateUrl);
288
+ if (!validation.valid) {
289
+ Logger.error(validation.error);
290
+ process.exit(1);
291
+ }
292
+ // Create minimal config for custom template
293
+ customTemplate = createCustomTemplate(options.templateUrl);
294
+ projectConfig = {
295
+ name,
296
+ monorepo: 'turborepo',
297
+ packageManager: 'npm',
298
+ apps: {
299
+ frontend: {
300
+ framework: 'react',
301
+ styling: 'tailwind',
302
+ linting: true
303
+ },
304
+ backend: {
305
+ framework: 'express',
306
+ database: 'postgresql',
307
+ docker: true
308
+ }
309
+ }
310
+ };
311
+ console.log();
312
+ const infoBox = boxen(chalk.cyan.bold('🔗 Using Custom Template\n\n') +
313
+ chalk.white(`URL: `) + chalk.green(options.templateUrl), {
314
+ padding: 1,
315
+ margin: 1,
316
+ borderStyle: 'round',
317
+ borderColor: 'cyan'
318
+ });
319
+ console.log(infoBox);
320
+ }
321
+ // Check if using direct template
322
+ else if (options.template) {
323
+ const template = getTemplateByName(options.template);
324
+ if (!template) {
325
+ const errorBox = boxen(chalk.red.bold('❌ Template Not Found\n\n') +
326
+ chalk.white(`Template "${options.template}" doesn't exist.\n\n`) +
327
+ chalk.cyan('💡 Use ') + chalk.white.bold('create-fs-app list') + chalk.cyan(' to see available templates.'), {
328
+ padding: 1,
329
+ margin: 1,
330
+ borderStyle: 'round',
331
+ borderColor: 'red'
332
+ });
333
+ console.log(errorBox);
334
+ process.exit(1);
335
+ }
336
+ // For direct template usage, we still need a project name
337
+ if (!name) {
338
+ console.log(chalk.red('\n❌ Project name is required when using --template.\n'));
339
+ console.log(chalk.cyan('Usage: create-fs-app <project-name> --template <template-name>\n'));
340
+ process.exit(1);
341
+ }
342
+ // Extract configuration from template key automatically
343
+ const parts = template.key.split('-');
344
+ projectConfig = {
345
+ name,
346
+ monorepo: parts[0],
347
+ packageManager: PackageManager.NPM,
348
+ apps: {
349
+ frontend: {
350
+ framework: (parts[1] === 'nextjs' ? 'next.js' : parts[1]),
351
+ // TypeScript is always enabled
352
+ styling: 'tailwind',
353
+ linting: true
354
+ },
355
+ backend: {
356
+ framework: (parts[2] === 'nestjs' ? 'nest.js' : parts[2]),
357
+ database: parts[3],
358
+ orm: parts[4],
359
+ docker: true
360
+ }
361
+ }
362
+ };
363
+ console.log();
364
+ const infoBox = boxen(chalk.cyan.bold('🚀 Using Template\n\n') +
365
+ chalk.white(`Template: `) + chalk.green(template.key) + '\n' +
366
+ chalk.white(`Description: `) + chalk.gray(template.metadata.description), {
367
+ padding: 1,
368
+ margin: 1,
369
+ borderStyle: 'round',
370
+ borderColor: 'cyan'
371
+ });
372
+ console.log(infoBox);
373
+ }
374
+ // Check if stack options provided via CLI
375
+ else if (options.monorepo || options.frontend || options.backend) {
376
+ projectConfig = buildConfigFromOptions(name, options);
377
+ // Show detected configuration
378
+ console.log(chalk.cyan('\n📋 Configuration from CLI options:\n'));
379
+ console.log(chalk.gray(' Project:'), chalk.white(projectConfig.name));
380
+ console.log(chalk.gray(' Monorepo:'), chalk.white(projectConfig.monorepo));
381
+ console.log(chalk.gray(' Frontend:'), chalk.white(projectConfig.apps.frontend.framework));
382
+ console.log(chalk.gray(' Backend:'), chalk.white(projectConfig.apps.backend.framework));
383
+ console.log(chalk.gray(' Database:'), chalk.white(projectConfig.apps.backend.database));
384
+ if (projectConfig.apps.backend.orm) {
385
+ console.log(chalk.gray(' ORM:'), chalk.white(projectConfig.apps.backend.orm));
386
+ }
387
+ console.log(chalk.gray(' Package Manager:'), chalk.white(projectConfig.packageManager));
388
+ console.log();
389
+ }
390
+ // Interactive mode
391
+ else {
392
+ projectConfig = await promptForConfiguration(name);
393
+ }
394
+ // Validate project directory
395
+ await validateProjectDirectory(projectConfig.name);
396
+ // Check if template exists
397
+ const availability = checkTemplateAvailability(projectConfig);
398
+ if (!availability.available) {
399
+ console.log(chalk.yellow('\n⚠️ No exact template match found for your configuration.'));
400
+ console.log(chalk.cyan('\n📋 Available similar templates:'));
401
+ availability.suggestions?.forEach((s, i) => {
402
+ console.log(chalk.cyan(` ${i + 1}. ${s}`));
403
+ });
404
+ console.log(chalk.yellow('\n💡 Tip: You can contribute this template combination to our repository!'));
405
+ console.log(chalk.blue(' Visit: https://github.com/create-fs-app-templates\n'));
406
+ process.exit(0);
407
+ }
408
+ const spinner = ora({
409
+ text: 'Creating your full-stack app...',
410
+ spinner: 'dots',
411
+ color: 'cyan',
412
+ hideCursor: true
413
+ }).start();
414
+ try {
415
+ await scaffoldProject(projectConfig, {
416
+ skipGit: options.git === false,
417
+ skipInstall: options.install === false
418
+ });
419
+ spinner.succeed(chalk.green.bold('Project created successfully!'));
420
+ }
421
+ catch (error) {
422
+ spinner.fail(chalk.red.bold('Project creation failed!'));
423
+ throw error;
424
+ }
425
+ finally {
426
+ // Ensure cursor is visible
427
+ process.stdout.write('\x1B[?25h');
428
+ }
429
+ console.log();
430
+ // Success box
431
+ const successMsg = boxen(chalk.white.bold(`🎉 ${projectConfig.name} is ready!\n\n`) +
432
+ chalk.cyan.bold('Next Steps:\n\n') +
433
+ chalk.white(`${chalk.green('1.')} ${chalk.cyan(`cd ${projectConfig.name}`)}\n`) +
434
+ chalk.white(`${chalk.green('2.')} ${chalk.cyan(options.install === false ? `${projectConfig.packageManager} install` : `${projectConfig.packageManager} run dev`)}\n`) +
435
+ chalk.white(`${chalk.green('3.')} ${chalk.cyan('Start building! 🚀')}\n\n`) +
436
+ chalk.gray('Documentation:\n') +
437
+ chalk.gray('• README.md - Project overview\n') +
438
+ chalk.gray('• .env.example - Environment setup'), {
439
+ padding: 1,
440
+ margin: 1,
441
+ borderStyle: 'round',
442
+ borderColor: 'green',
443
+ title: chalk.bold.green('✨ Success'),
444
+ titleAlignment: 'center'
445
+ });
446
+ console.log(successMsg);
447
+ console.log();
448
+ }
449
+ catch (error) {
450
+ if (error instanceof TemplateNotFoundError) {
451
+ console.log(error.message);
452
+ if (error.suggestions.length > 0) {
453
+ console.log(chalk.cyan('\n📋 Similar templates you might like:'));
454
+ error.suggestions.forEach((s, i) => {
455
+ console.log(chalk.cyan(` ${i + 1}. ${s}`));
456
+ });
457
+ }
458
+ }
459
+ else {
460
+ console.error(chalk.red('\n❌ Error creating project:'));
461
+ console.error(error);
462
+ }
463
+ process.exit(1);
464
+ }
465
+ });
466
+ // List templates command
467
+ program
468
+ .command('list')
469
+ .description('List all available templates')
470
+ .alias('ls')
471
+ .action(() => {
472
+ displayAvailableTemplates();
473
+ });
474
+ // Template info command
475
+ program
476
+ .command('info <template>')
477
+ .description('Show detailed information about a template')
478
+ .action((templateName) => {
479
+ const template = getTemplateByName(templateName);
480
+ if (!template) {
481
+ const errorBox = boxen(chalk.red.bold('❌ Template Not Found\n\n') +
482
+ chalk.white(`"${templateName}" doesn't exist.\n\n`) +
483
+ chalk.gray('Use ') + chalk.cyan('create-fs-app list') + chalk.gray(' to see available templates.'), {
484
+ padding: 1,
485
+ margin: 1,
486
+ borderStyle: 'round',
487
+ borderColor: 'red'
488
+ });
489
+ console.log(errorBox);
490
+ return;
491
+ }
492
+ console.log();
493
+ const infoBox = boxen(chalk.bold.white(`📦 ${template.key}\n\n`) +
494
+ chalk.gray('Description:\n') +
495
+ chalk.white(`${template.metadata.description}\n\n`) +
496
+ chalk.gray('Features:\n') +
497
+ template.metadata.features.map((f) => chalk.green(`✓ ${f}`)).join('\n') +
498
+ '\n\n' +
499
+ chalk.gray('Repository:\n') +
500
+ chalk.cyan.underline(template.metadata.url), {
501
+ padding: 1,
502
+ margin: 1,
503
+ borderStyle: 'round',
504
+ borderColor: 'cyan',
505
+ title: chalk.bold.cyan('Template Info'),
506
+ titleAlignment: 'center'
507
+ });
508
+ console.log(infoBox);
509
+ const usageBox = boxen(chalk.cyan(`npx create-fs-app my-app --template ${template.key}`), {
510
+ padding: 1,
511
+ margin: { top: 0, bottom: 1, left: 1, right: 1 },
512
+ borderStyle: 'round',
513
+ borderColor: 'blue',
514
+ title: chalk.bold.blue('💡 Usage'),
515
+ titleAlignment: 'left'
516
+ });
517
+ console.log(usageBox);
518
+ });
519
+ // Health check command
520
+ program
521
+ .command('health')
522
+ .description('Run health check on current project')
523
+ .action(async () => {
524
+ try {
525
+ const result = await runHealthCheck();
526
+ displayHealthCheckResults(result);
527
+ process.exit(result.passed ? 0 : 1);
528
+ }
529
+ catch (error) {
530
+ Logger.error('Failed to run health check');
531
+ console.error(error);
532
+ process.exit(1);
533
+ }
534
+ });
535
+ // Preset commands
536
+ const presetCmd = program
537
+ .command('preset')
538
+ .description('Manage configuration presets');
539
+ presetCmd
540
+ .command('save <name>')
541
+ .description('Save current configuration as a preset')
542
+ .option('-d, --description <desc>', 'Preset description')
543
+ .action(async (name, options) => {
544
+ // This would need to be called from within a project
545
+ Logger.error('This command must be run from within a create-fs-app project');
546
+ process.exit(1);
547
+ });
548
+ presetCmd
549
+ .command('list')
550
+ .description('List all saved presets')
551
+ .action(async () => {
552
+ try {
553
+ const presets = await listPresets();
554
+ const builtinKeys = Object.keys(BUILTIN_PRESETS);
555
+ console.log(chalk.cyan.bold('\n📚 Available Presets\n'));
556
+ // Built-in presets
557
+ console.log(chalk.bold.green('Built-in Presets:'));
558
+ builtinKeys.forEach(key => {
559
+ const preset = BUILTIN_PRESETS[key];
560
+ console.log(chalk.white(` ${key}`));
561
+ console.log(chalk.gray(` ${preset.description}`));
562
+ });
563
+ // User presets
564
+ if (presets.length > 0) {
565
+ console.log(chalk.bold.green('\nYour Presets:'));
566
+ presets.forEach(preset => {
567
+ console.log(chalk.white(` ${preset.name}`));
568
+ if (preset.description) {
569
+ console.log(chalk.gray(` ${preset.description}`));
570
+ }
571
+ });
572
+ }
573
+ console.log(chalk.cyan('\n💡 Use: create-fs-app my-app --preset <name>\n'));
574
+ }
575
+ catch (error) {
576
+ Logger.error('Failed to list presets');
577
+ console.error(error);
578
+ process.exit(1);
579
+ }
580
+ });
581
+ presetCmd
582
+ .command('delete <name>')
583
+ .description('Delete a saved preset')
584
+ .action(async (name) => {
585
+ try {
586
+ const deleted = await deletePreset(name);
587
+ if (!deleted) {
588
+ Logger.error(`Preset "${name}" not found`);
589
+ process.exit(1);
590
+ }
591
+ }
592
+ catch (error) {
593
+ Logger.error('Failed to delete preset');
594
+ console.error(error);
595
+ process.exit(1);
596
+ }
597
+ });
598
+ // Cache commands
599
+ const cacheCmd = program
600
+ .command('cache')
601
+ .description('Manage template cache');
602
+ cacheCmd
603
+ .command('clear')
604
+ .description('Clear template cache')
605
+ .action(async () => {
606
+ try {
607
+ await clearCache();
608
+ }
609
+ catch (error) {
610
+ Logger.error('Failed to clear cache');
611
+ console.error(error);
612
+ process.exit(1);
613
+ }
614
+ });
615
+ cacheCmd
616
+ .command('stats')
617
+ .description('Show cache statistics')
618
+ .action(async () => {
619
+ try {
620
+ const stats = await getCacheStats();
621
+ console.log(chalk.cyan.bold('\n📊 Cache Statistics\n'));
622
+ console.log(chalk.white(`Total templates: ${stats.totalTemplates}`));
623
+ console.log(chalk.white(`Cache size: ${stats.cacheSize}`));
624
+ if (stats.templates.length > 0) {
625
+ console.log(chalk.bold('\nCached Templates:'));
626
+ stats.templates.forEach(t => {
627
+ console.log(chalk.gray(` ${t.key}`));
628
+ console.log(chalk.gray(` Last used: ${new Date(t.lastUsed).toLocaleDateString()}`));
629
+ });
630
+ }
631
+ console.log();
632
+ }
633
+ catch (error) {
634
+ Logger.error('Failed to get cache stats');
635
+ console.error(error);
636
+ process.exit(1);
637
+ }
638
+ });
639
+ program.parse();
640
+ }
641
+ main().catch(console.error);
642
+ //# sourceMappingURL=index.js.map