create-fs-app 2.0.0 → 2.0.2

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/dist/index.js CHANGED
@@ -10,16 +10,18 @@ import updateNotifier from 'update-notifier';
10
10
  import { readFileSync } from 'fs';
11
11
  import { fileURLToPath } from 'url';
12
12
  import { dirname, join } from 'path';
13
- import { ProjectConfigSchema, MonorepoFramework, FrontendFramework, BackendFramework, Database, PackageManager } from './types/index.js';
13
+ import { ProjectConfigSchema, MonorepoFramework, FrontendFramework, BackendFramework, Database, PackageManager, ApiStyle, AuthStrategy, } from './types/index.js';
14
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';
15
+ import { displayAvailableTemplates, getContributedByName, getContributedByUUID, getOfficialByName, } from './core/template-list.js';
16
+ import { assertValidProjectName, isValidUUID } from './utils/validation.js';
17
17
  import { Logger } from './utils/logger.js';
18
- import { loadPreset, listPresets, deletePreset, getBuiltinPreset, BUILTIN_PRESETS } from './core/presets.js';
18
+ import { savePreset, loadPreset, listPresets, deletePreset, getBuiltinPreset, isBuiltinPresetName, userPresetExists, BUILTIN_PRESETS, } from './core/presets.js';
19
19
  import { runHealthCheck, displayHealthCheckResults } from './core/health-check.js';
20
20
  import { clearCache, getCacheStats } from './core/template-cache.js';
21
21
  import { createCustomTemplate } from './core/template-registry.js';
22
- import { validateTemplateUrl } from './utils/validation.js';
22
+ import { getRemoteRegistry, clearRegistryCache } from './core/registry-fetch.js';
23
+ import { setActiveRegistry } from './core/template-registry.js';
24
+ import { parseTemplateUrl } from './utils/validation.js';
23
25
  const __filename = fileURLToPath(import.meta.url);
24
26
  const __dirname = dirname(__filename);
25
27
  // Check for updates
@@ -57,6 +59,19 @@ async function welcome() {
57
59
  /**
58
60
  * Build configuration from CLI options
59
61
  */
62
+ /**
63
+ * Case-insensitive enum validator — shared by buildConfigFromOptions and --yes/--template paths.
64
+ */
65
+ function validateEnum(value, enumObj, fieldName) {
66
+ const validValues = Object.values(enumObj);
67
+ const found = validValues.find((v) => v.toLowerCase() === value.toLowerCase());
68
+ if (!found) {
69
+ console.log(chalk.red(`\n❌ Invalid ${fieldName}: "${value}"\n`));
70
+ console.log(chalk.cyan(`Valid options: ${validValues.join(', ')}\n`));
71
+ process.exit(1);
72
+ }
73
+ return found;
74
+ }
60
75
  function buildConfigFromOptions(name, options) {
61
76
  // Validate required fields
62
77
  if (!name) {
@@ -75,35 +90,34 @@ function buildConfigFromOptions(name, options) {
75
90
  console.log(chalk.cyan('💡 Or run without options for interactive mode.\n'));
76
91
  process.exit(1);
77
92
  }
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
- };
93
+ const frontendFramework = validateEnum(options.frontend, FrontendFramework, 'frontend framework');
89
94
  const config = {
90
95
  name,
91
96
  monorepo: validateEnum(options.monorepo, MonorepoFramework, 'monorepo framework'),
92
97
  packageManager: options.packageManager
93
98
  ? validateEnum(options.packageManager, PackageManager, 'package manager')
94
99
  : PackageManager.NPM,
100
+ ci: options.ci === true,
95
101
  apps: {
96
102
  frontend: {
97
- framework: validateEnum(options.frontend, FrontendFramework, 'frontend framework'),
98
- // TypeScript is always enabled
103
+ framework: frontendFramework,
99
104
  styling: options.styling || 'tailwind',
100
- linting: options.linting !== false // default true
105
+ eslint: options.eslint !== false, // default true
106
+ prettier: options.prettier !== false, // default true
107
+ // Turbopack only valid for Next.js
108
+ turbopack: frontendFramework === 'next.js' && options.turbopack === true,
101
109
  },
102
110
  backend: {
103
111
  framework: validateEnum(options.backend, BackendFramework, 'backend framework'),
104
112
  database: validateEnum(options.database, Database, 'database'),
105
113
  orm: options.orm,
106
- docker: options.docker !== false // default true based on options
114
+ apiStyle: options.apiStyle
115
+ ? validateEnum(options.apiStyle, ApiStyle, 'API style')
116
+ : ApiStyle.REST,
117
+ auth: options.auth
118
+ ? validateEnum(options.auth, AuthStrategy, 'auth strategy')
119
+ : AuthStrategy.None,
120
+ docker: options.docker !== false, // default true
107
121
  }
108
122
  }
109
123
  };
@@ -112,137 +126,259 @@ function buildConfigFromOptions(name, options) {
112
126
  return ProjectConfigSchema.parse(config);
113
127
  }
114
128
  catch (error) {
115
- Logger.error('Invalid configuration:');
116
- console.error(error);
129
+ Logger.error('Invalid configuration: ' + (error instanceof Error ? error.message : String(error)));
117
130
  process.exit(1);
118
131
  }
119
132
  }
120
133
  async function promptForConfiguration(projectName) {
121
- const questions = [];
122
- if (!projectName) {
123
- questions.push({
134
+ const onCancel = () => {
135
+ console.log(chalk.yellow('\n\nOperation cancelled by user'));
136
+ process.exit(0);
137
+ };
138
+ // ── Step 1: Project name ────────────────────────────────────────────────
139
+ let name = projectName;
140
+ if (!name) {
141
+ const { projectName: n } = await prompts({
124
142
  type: 'text',
125
- name: 'name',
126
- message: 'What is your project named?',
127
- initial: 'my-fs-app'
128
- });
143
+ name: 'projectName',
144
+ message: 'Project name:',
145
+ initial: 'my-fs-app',
146
+ validate: (v) => v.trim().length > 0 || 'Name required'
147
+ }, { onCancel });
148
+ name = n;
129
149
  }
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
- }, {
150
+ // ── Step 2: Monorepo + package manager ─────────────────────────────────
151
+ const { monorepo, packageManager } = await prompts([
152
+ {
153
+ type: 'select',
154
+ name: 'monorepo',
155
+ message: 'Monorepo tool:',
156
+ choices: [
157
+ { title: 'Turborepo — fast build caching, simple config', value: 'turborepo' },
158
+ { title: 'Nx — powerful task graph, generators', value: 'nx' },
159
+ ],
160
+ initial: 0
161
+ },
162
+ {
163
+ type: 'select',
164
+ name: 'packageManager',
165
+ message: 'Package manager:',
166
+ choices: [
167
+ { title: 'npm', value: 'npm' },
168
+ { title: 'pnpm — faster installs, disk efficient', value: 'pnpm' },
169
+ { title: 'yarn', value: 'yarn' },
170
+ ],
171
+ initial: 0
172
+ },
173
+ ], { onCancel });
174
+ // ── Step 3: Frontend ────────────────────────────────────────────────────
175
+ const { frontendFramework, styling } = await prompts([
176
+ {
177
+ type: 'select',
178
+ name: 'frontendFramework',
179
+ message: 'Frontend framework:',
180
+ choices: [
181
+ { title: 'Next.js — App Router, SSR, RSC', value: 'next.js' },
182
+ { title: 'React — Vite, SPA/CSR', value: 'react' },
183
+ { title: 'Vue — Vite, Options/Composition API', value: 'vue' },
184
+ { title: 'Nuxt — SSR for Vue', value: 'nuxt' },
185
+ { title: 'Angular — full framework', value: 'angular' },
186
+ ],
187
+ initial: 0
188
+ },
189
+ {
190
+ type: 'select',
191
+ name: 'styling',
192
+ message: 'Styling solution:',
193
+ choices: [
194
+ { title: 'Tailwind CSS — utility-first', value: 'tailwind' },
195
+ { title: 'CSS — plain stylesheets', value: 'css' },
196
+ { title: 'SCSS/Sass — CSS with superpowers', value: 'scss' },
197
+ { title: 'Styled Components — CSS-in-JS', value: 'styled-components' },
198
+ ],
199
+ initial: 0
200
+ },
201
+ ], { onCancel });
202
+ // Turbopack — only relevant for Next.js
203
+ let turbopack = false;
204
+ if (frontendFramework === 'next.js') {
205
+ const { tp } = await prompts({
206
+ type: 'confirm',
207
+ name: 'tp',
208
+ message: 'Enable Turbopack? (faster dev server for Next.js)',
209
+ initial: true
210
+ }, { onCancel });
211
+ turbopack = tp;
212
+ }
213
+ // ── Step 4: Code quality ────────────────────────────────────────────────
214
+ const { eslint, prettier } = await prompts([
215
+ {
216
+ type: 'confirm',
217
+ name: 'eslint',
218
+ message: 'Add ESLint?',
219
+ initial: true
220
+ },
221
+ {
222
+ type: 'confirm',
223
+ name: 'prettier',
224
+ message: 'Add Prettier?',
225
+ initial: true
226
+ },
227
+ ], { onCancel });
228
+ // ── Step 5: Backend ─────────────────────────────────────────────────────
229
+ const { backendFramework, database, orm } = await prompts([
230
+ {
231
+ type: 'select',
232
+ name: 'backendFramework',
233
+ message: 'Backend framework:',
234
+ choices: [
235
+ { title: 'NestJS — TypeScript-first, modular, decorators', value: 'nest.js' },
236
+ { title: 'Express — minimal, flexible, battle-tested', value: 'express' },
237
+ { title: 'Fastify — high performance, schema validation', value: 'fastify-ts' },
238
+ { title: 'Koa — lightweight, async middleware', value: 'koa' },
239
+ ],
240
+ initial: 0
241
+ },
242
+ {
243
+ type: 'select',
244
+ name: 'database',
245
+ message: 'Database:',
246
+ choices: [
247
+ { title: 'PostgreSQL — relational, ACID, powerful', value: 'postgresql' },
248
+ { title: 'MongoDB — document, flexible schema', value: 'mongodb' },
249
+ { title: 'MySQL — relational, widely supported', value: 'mysql' },
250
+ { title: 'SQLite — file-based, zero setup', value: 'sqlite' },
251
+ ],
252
+ initial: 0
253
+ },
254
+ {
255
+ type: 'select',
256
+ name: 'orm',
257
+ message: 'ORM / ODM:',
258
+ choices: [
259
+ { title: 'Prisma — type-safe, migrations, Studio', value: 'prisma' },
260
+ { title: 'TypeORM — decorators, ActiveRecord/DataMapper', value: 'typeorm' },
261
+ { title: 'Mongoose — MongoDB ODM, schemas', value: 'mongoose' },
262
+ { title: 'Drizzle — lightweight, SQL-like', value: 'drizzle' },
263
+ ],
264
+ initial: 0
265
+ },
266
+ ], { onCancel });
267
+ // ── Step 6: API style ───────────────────────────────────────────────────
268
+ const { apiStyle } = await prompts({
146
269
  type: 'select',
147
- name: 'styling',
148
- message: 'Select a styling solution:',
270
+ name: 'apiStyle',
271
+ message: 'API style:',
149
272
  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
- }, {
273
+ { title: 'REST — standard HTTP endpoints (recommended)', value: 'rest' },
274
+ { title: 'GraphQL — flexible queries with Apollo/Mercurius', value: 'graphql' },
275
+ { title: 'Both — REST + GraphQL side by side', value: 'both' },
276
+ ],
277
+ initial: 0
278
+ }, { onCancel });
279
+ // ── Step 7: Auth ────────────────────────────────────────────────────────
280
+ const { auth } = await prompts({
161
281
  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:',
282
+ name: 'auth',
283
+ message: 'Authentication scaffolding:',
174
284
  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
285
+ { title: 'None — skip auth, add manually later', value: 'none' },
286
+ { title: 'JWT — login/register endpoints + guards/middleware', value: 'jwt' },
287
+ ],
288
+ initial: 0
289
+ }, { onCancel });
290
+ // ── Step 8: Docker + CI ────────────────────────────────────────────────
291
+ const { docker, ci } = await prompts([
292
+ {
293
+ type: 'confirm',
294
+ name: 'docker',
295
+ message: 'Include Docker / Docker Compose?',
296
+ initial: true
297
+ },
298
+ {
299
+ type: 'confirm',
300
+ name: 'ci',
301
+ message: 'Add GitHub Actions CI? (lint → build on push/PR)',
302
+ initial: false
303
+ },
304
+ ], { onCancel });
305
+ // ── Build + validate config ─────────────────────────────────────────────
193
306
  const config = {
194
- name: projectName || answers.name,
195
- monorepo: answers.monorepo,
196
- packageManager: answers.packageManager,
307
+ name: name,
308
+ monorepo,
309
+ packageManager,
310
+ ci,
197
311
  apps: {
198
312
  frontend: {
199
- framework: answers.frontendFramework,
200
- styling: answers.styling,
201
- linting: answers.linting
313
+ framework: frontendFramework,
314
+ styling,
315
+ eslint,
316
+ prettier,
317
+ turbopack,
202
318
  },
203
319
  backend: {
204
- framework: answers.backendFramework,
205
- database: answers.database,
206
- orm: answers.orm,
207
- docker: answers.docker
320
+ framework: backendFramework,
321
+ database,
322
+ orm,
323
+ apiStyle,
324
+ auth,
325
+ docker,
208
326
  }
209
327
  }
210
328
  };
211
- // Validate configuration using Zod
212
329
  return ProjectConfigSchema.parse(config);
213
330
  }
214
331
  async function main() {
332
+ // ── Hydrate registry from GitHub (non-blocking, 5 s timeout) ────────────
333
+ // Silently falls back to the hardcoded registry on any failure so the CLI
334
+ // always works offline. New templates published to the templates repo are
335
+ // picked up automatically without a CLI release.
336
+ // Store promise so list/info commands can await it (max 3 s)
337
+ const registryReady = getRemoteRegistry()
338
+ .then((remote) => { if (remote)
339
+ setActiveRegistry(remote); })
340
+ .catch(() => { });
215
341
  const program = new Command();
216
342
  program
217
343
  .name('create-fs-app')
218
344
  .description('Create a full-stack monorepo application')
219
- .version('2.0.0');
345
+ .version(pkg.version);
220
346
  // Main create command
221
347
  program
222
348
  .argument('[name]', 'The name of your application')
223
349
  .option('-t, --template <name>', 'Use a predefined template')
224
350
  .option('--template-url <url>', 'Use a custom template from GitHub URL')
225
351
  .option('--preset <name>', 'Use a configuration preset')
226
- .option('--monorepo <framework>', 'Monorepo framework (turborepo, nx, lerna)')
352
+ .option('--monorepo <framework>', 'Monorepo framework (turborepo, nx)')
227
353
  .option('--frontend <framework>', 'Frontend framework (react, next.js, vue, nuxt, angular)')
228
- .option('--backend <framework>', 'Backend framework (express, nest.js, fastify, koa)')
354
+ .option('--backend <framework>', 'Backend framework (express, nest.js, fastify-ts, koa)')
229
355
  .option('--database <db>', 'Database (postgresql, mongodb, mysql, sqlite)')
230
356
  .option('--orm <orm>', 'ORM (prisma, typeorm, mongoose, drizzle)')
231
357
  .option('--package-manager <pm>', 'Package manager (npm, yarn, pnpm)')
232
358
  .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')
359
+ .option('--eslint', 'Enable ESLint (default: true)')
360
+ .option('--no-eslint', 'Disable ESLint')
361
+ .option('--prettier', 'Enable Prettier (default: true)')
362
+ .option('--no-prettier', 'Disable Prettier')
363
+ .option('--turbopack', 'Enable Turbopack dev server (Next.js only)')
364
+ .option('--api-style <style>', 'API style: rest | graphql | both (default: rest)')
365
+ .option('--auth <strategy>', 'Auth scaffolding: none | jwt (default: none)')
366
+ .option('--docker', 'Include Docker / Docker Compose (default: true)')
236
367
  .option('--no-docker', 'Skip Docker configuration')
368
+ .option('--ci', 'Add GitHub Actions CI workflow')
369
+ .option('--no-ci', 'Skip GitHub Actions CI')
237
370
  .option('--no-git', 'Skip git initialization')
238
371
  .option('--no-install', 'Skip package installation')
239
372
  .option('--no-cache', 'Skip template caching')
373
+ .option('--local-templates <path>', 'Use local templates repo instead of GitHub (for development)')
240
374
  .option('-y, --yes', 'Skip prompts and use defaults')
241
375
  .action(async (name, options) => {
242
376
  await welcome();
243
377
  try {
244
378
  let projectConfig;
245
379
  let customTemplate = null;
380
+ // When true the availability check against the registry is skipped (custom URL supplies its own template)
381
+ let skipAvailabilityCheck = false;
246
382
  // Check if using preset
247
383
  if (options.preset) {
248
384
  if (!name) {
@@ -283,34 +419,47 @@ async function main() {
283
419
  console.log(chalk.cyan('Usage: create-fs-app <project-name> --template-url <url>\n'));
284
420
  process.exit(1);
285
421
  }
286
- // Validate URL
287
- const validation = validateTemplateUrl(options.templateUrl);
288
- if (!validation.valid) {
289
- Logger.error(validation.error);
422
+ // Parse URL — extracts repoUrl, branch, and optional subfolder
423
+ const parsed = parseTemplateUrl(options.templateUrl);
424
+ if (!parsed.valid) {
425
+ Logger.error(parsed.error);
290
426
  process.exit(1);
291
427
  }
292
- // Create minimal config for custom template
293
- customTemplate = createCustomTemplate(options.templateUrl);
428
+ const { repoUrl, branch, subfolder } = parsed.parsed;
429
+ // Build the TemplateMetadata directly from the parsed URL
430
+ customTemplate = createCustomTemplate(repoUrl, branch, subfolder);
431
+ // Minimal projectConfig — only name and pm matter here; the registry is not used
294
432
  projectConfig = {
295
433
  name,
296
434
  monorepo: 'turborepo',
297
- packageManager: 'npm',
435
+ packageManager: options.packageManager
436
+ ? validateEnum(options.packageManager, PackageManager, 'package manager')
437
+ : PackageManager.NPM,
438
+ ci: options.ci === true,
298
439
  apps: {
299
440
  frontend: {
300
441
  framework: 'react',
301
442
  styling: 'tailwind',
302
- linting: true
443
+ eslint: true,
444
+ prettier: true,
445
+ turbopack: false,
303
446
  },
304
447
  backend: {
305
448
  framework: 'express',
306
449
  database: 'postgresql',
307
- docker: true
450
+ apiStyle: 'rest',
451
+ auth: 'none',
452
+ docker: options.docker !== false,
308
453
  }
309
454
  }
310
455
  };
456
+ // Custom template bypasses the registry — skip availability check
457
+ skipAvailabilityCheck = true;
311
458
  console.log();
312
459
  const infoBox = boxen(chalk.cyan.bold('🔗 Using Custom Template\n\n') +
313
- chalk.white(`URL: `) + chalk.green(options.templateUrl), {
460
+ chalk.white('Repo: ') + chalk.green(repoUrl) + '\n' +
461
+ chalk.white('Branch: ') + chalk.green(branch) +
462
+ (subfolder ? '\n' + chalk.white('Folder: ') + chalk.green(subfolder) : ''), {
314
463
  padding: 1,
315
464
  margin: 1,
316
465
  borderStyle: 'round',
@@ -318,58 +467,112 @@ async function main() {
318
467
  });
319
468
  console.log(infoBox);
320
469
  }
321
- // Check if using direct template
470
+ // --template: contributed templates only (UUID-only mode)
322
471
  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);
472
+ // --template only accepts UUID v4
473
+ if (!isValidUUID(options.template)) {
474
+ console.log(boxen(chalk.red.bold('❌ Invalid --template value\n\n') +
475
+ chalk.white('--template only accepts a UUID v4 (the unique ID of a contributed template).\n\n') +
476
+ chalk.gray('Find the UUID with:\n') +
477
+ chalk.cyan(' create-fs-app list --contributed\n\n') +
478
+ chalk.gray('Then use it:\n') +
479
+ chalk.cyan(` create-fs-app my-app --template <uuid>`), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'red' }));
480
+ process.exit(1);
481
+ }
482
+ // Find in contributed registry only
483
+ const match = getContributedByUUID(options.template);
484
+ if (!match) {
485
+ console.log(boxen(chalk.red.bold('❌ Contributed Template Not Found\n\n') +
486
+ chalk.white(`No contributed template has UUID "${options.template}".\n\n`) +
487
+ chalk.cyan('💡 Browse contributed templates and copy a UUID:\n') +
488
+ chalk.cyan(' create-fs-app list --contributed'), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'red' }));
334
489
  process.exit(1);
335
490
  }
336
- // For direct template usage, we still need a project name
337
491
  if (!name) {
338
492
  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'));
493
+ console.log(chalk.cyan('Usage: create-fs-app <project-name> --template <uuid>\n'));
340
494
  process.exit(1);
341
495
  }
342
- // Extract configuration from template key automatically
343
- const parts = template.key.split('-');
496
+ // Extract stack config from the base 5 segments of the key
497
+ const FRAMEWORK_MAP = {
498
+ nextjs: 'next.js',
499
+ nestjs: 'nest.js',
500
+ fastifyts: 'fastify-ts',
501
+ react: 'react',
502
+ express: 'express',
503
+ koa: 'koa',
504
+ };
505
+ const parts = match.key.split('-');
506
+ const tplFrontend = (FRAMEWORK_MAP[parts[1]] ?? parts[1]);
507
+ const tplBackend = (FRAMEWORK_MAP[parts[2]] ?? parts[2]);
344
508
  projectConfig = {
345
509
  name,
346
510
  monorepo: parts[0],
347
- packageManager: PackageManager.NPM,
511
+ packageManager: options.packageManager
512
+ ? validateEnum(options.packageManager, PackageManager, 'package manager')
513
+ : PackageManager.NPM,
514
+ ci: options.ci === true,
348
515
  apps: {
349
516
  frontend: {
350
- framework: (parts[1] === 'nextjs' ? 'next.js' : parts[1]),
351
- // TypeScript is always enabled
517
+ framework: tplFrontend,
352
518
  styling: 'tailwind',
353
- linting: true
519
+ eslint: true,
520
+ prettier: true,
521
+ turbopack: false,
354
522
  },
355
523
  backend: {
356
- framework: (parts[2] === 'nestjs' ? 'nest.js' : parts[2]),
524
+ framework: tplBackend,
357
525
  database: parts[3],
358
526
  orm: parts[4],
359
- docker: true
527
+ apiStyle: 'rest',
528
+ auth: 'none',
529
+ docker: true,
360
530
  }
361
531
  }
362
532
  };
533
+ customTemplate = match.metadata;
534
+ skipAvailabilityCheck = true;
535
+ const contrib = match.metadata.contributor;
536
+ console.log();
537
+ console.log(boxen(chalk.yellow.bold('◆ Using Contributed Template\n\n') +
538
+ chalk.white('Template: ') + chalk.yellow(match.key) + '\n' +
539
+ chalk.white('UUID: ') + chalk.dim(match.metadata.id ?? options.template) + '\n' +
540
+ (contrib
541
+ ? chalk.white('By: ') + chalk.cyan(`@${contrib.github}`) + chalk.dim(` ${contrib.url}`) + '\n' +
542
+ chalk.white('Repo: ') + chalk.dim(contrib.repoUrl) + '\n'
543
+ : '') +
544
+ chalk.white('Description: ') + chalk.gray(match.metadata.description), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'yellow' }));
545
+ }
546
+ // --yes: fill missing flags with saas-starter defaults, skip all prompts
547
+ else if (options.yes) {
548
+ if (!name) {
549
+ Logger.error('Project name is required when using --yes.');
550
+ console.log(chalk.cyan('Usage: create-fs-app <project-name> [options] --yes\n'));
551
+ process.exit(1);
552
+ }
553
+ // Merge any explicit flags with defaults — explicit always wins
554
+ const withDefaults = {
555
+ ...options,
556
+ monorepo: options.monorepo ?? 'turborepo',
557
+ frontend: options.frontend ?? 'next.js',
558
+ backend: options.backend ?? 'nest.js',
559
+ database: options.database ?? 'postgresql',
560
+ orm: options.orm ?? 'prisma',
561
+ };
562
+ projectConfig = buildConfigFromOptions(name, withDefaults);
563
+ // Show resolved configuration
564
+ console.log(chalk.cyan('\n⚡ Using defaults (--yes)\n'));
565
+ console.log(chalk.gray(' Project:'), chalk.white(projectConfig.name));
566
+ console.log(chalk.gray(' Monorepo:'), chalk.white(projectConfig.monorepo));
567
+ console.log(chalk.gray(' Pkg manager:'), chalk.white(projectConfig.packageManager));
568
+ console.log(chalk.gray(' Frontend:'), chalk.white(projectConfig.apps.frontend.framework));
569
+ console.log(chalk.gray(' Styling:'), chalk.white(projectConfig.apps.frontend.styling));
570
+ console.log(chalk.gray(' Backend:'), chalk.white(projectConfig.apps.backend.framework));
571
+ console.log(chalk.gray(' Database:'), chalk.white(projectConfig.apps.backend.database));
572
+ console.log(chalk.gray(' ORM:'), chalk.white(projectConfig.apps.backend.orm ?? 'none'));
573
+ console.log(chalk.gray(' Docker:'), chalk.white(projectConfig.apps.backend.docker ? 'yes' : 'no'));
574
+ console.log(chalk.gray(' CI:'), chalk.white(projectConfig.ci ? 'yes' : 'no'));
363
575
  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
576
  }
374
577
  // Check if stack options provided via CLI
375
578
  else if (options.monorepo || options.frontend || options.backend) {
@@ -378,13 +581,23 @@ async function main() {
378
581
  console.log(chalk.cyan('\n📋 Configuration from CLI options:\n'));
379
582
  console.log(chalk.gray(' Project:'), chalk.white(projectConfig.name));
380
583
  console.log(chalk.gray(' Monorepo:'), chalk.white(projectConfig.monorepo));
584
+ console.log(chalk.gray(' Pkg manager:'), chalk.white(projectConfig.packageManager));
381
585
  console.log(chalk.gray(' Frontend:'), chalk.white(projectConfig.apps.frontend.framework));
586
+ console.log(chalk.gray(' Styling:'), chalk.white(projectConfig.apps.frontend.styling));
587
+ console.log(chalk.gray(' ESLint:'), chalk.white(projectConfig.apps.frontend.eslint ? 'yes' : 'no'));
588
+ console.log(chalk.gray(' Prettier:'), chalk.white(projectConfig.apps.frontend.prettier ? 'yes' : 'no'));
589
+ if (projectConfig.apps.frontend.turbopack) {
590
+ console.log(chalk.gray(' Turbopack:'), chalk.white('yes'));
591
+ }
382
592
  console.log(chalk.gray(' Backend:'), chalk.white(projectConfig.apps.backend.framework));
383
593
  console.log(chalk.gray(' Database:'), chalk.white(projectConfig.apps.backend.database));
384
594
  if (projectConfig.apps.backend.orm) {
385
595
  console.log(chalk.gray(' ORM:'), chalk.white(projectConfig.apps.backend.orm));
386
596
  }
387
- console.log(chalk.gray(' Package Manager:'), chalk.white(projectConfig.packageManager));
597
+ console.log(chalk.gray(' API style:'), chalk.white(projectConfig.apps.backend.apiStyle));
598
+ console.log(chalk.gray(' Auth:'), chalk.white(projectConfig.apps.backend.auth));
599
+ console.log(chalk.gray(' Docker:'), chalk.white(projectConfig.apps.backend.docker ? 'yes' : 'no'));
600
+ console.log(chalk.gray(' CI:'), chalk.white(projectConfig.ci ? 'yes' : 'no'));
388
601
  console.log();
389
602
  }
390
603
  // Interactive mode
@@ -393,17 +606,19 @@ async function main() {
393
606
  }
394
607
  // Validate project directory
395
608
  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);
609
+ // Check if a registry template exists (skipped for --template-url which supplies its own)
610
+ if (!skipAvailabilityCheck) {
611
+ const availability = checkTemplateAvailability(projectConfig);
612
+ if (!availability.available) {
613
+ console.log(chalk.yellow('\n⚠️ No exact template match found for your configuration.'));
614
+ console.log(chalk.cyan('\n📋 Available similar templates:'));
615
+ availability.suggestions?.forEach((s, i) => {
616
+ console.log(chalk.cyan(` ${i + 1}. ${s}`));
617
+ });
618
+ console.log(chalk.yellow('\n💡 Tip: You can contribute this template combination to our repository!'));
619
+ console.log(chalk.blue(' Visit: https://github.com/create-fs-app-templates\n'));
620
+ process.exit(0);
621
+ }
407
622
  }
408
623
  const spinner = ora({
409
624
  text: 'Creating your full-stack app...',
@@ -414,7 +629,10 @@ async function main() {
414
629
  try {
415
630
  await scaffoldProject(projectConfig, {
416
631
  skipGit: options.git === false,
417
- skipInstall: options.install === false
632
+ skipInstall: options.install === false,
633
+ skipCache: options.cache === false,
634
+ localTemplatesDir: options.localTemplates,
635
+ customTemplate: customTemplate ?? undefined,
418
636
  });
419
637
  spinner.succeed(chalk.green.bold('Project created successfully!'));
420
638
  }
@@ -457,64 +675,90 @@ async function main() {
457
675
  }
458
676
  }
459
677
  else {
460
- console.error(chalk.red('\n❌ Error creating project:'));
461
- console.error(error);
678
+ console.error(chalk.red('\n❌ Error: ') + chalk.red(error instanceof Error ? error.message : String(error)));
462
679
  }
463
680
  process.exit(1);
464
681
  }
465
682
  });
466
683
  // List templates command
467
684
  program
468
- .command('list')
469
- .description('List all available templates')
685
+ .command('list [search]')
686
+ .description('List templates. Default: official only. Use --contributed or --all to see community templates.')
470
687
  .alias('ls')
471
- .action(() => {
472
- displayAvailableTemplates();
688
+ .option('--contributed', 'Show only contributed (community) templates')
689
+ .option('--all', 'Show official and contributed templates')
690
+ .action(async (search, cmdOpts) => {
691
+ // Await registry hydration (max 3 s) before displaying
692
+ await Promise.race([registryReady, new Promise(r => setTimeout(r, 3000))]);
693
+ displayAvailableTemplates({
694
+ search: search?.trim() || undefined,
695
+ contributed: cmdOpts.contributed,
696
+ all: cmdOpts.all,
697
+ });
473
698
  });
474
699
  // Template info command
475
700
  program
476
701
  .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);
702
+ .description('Show detailed information about a specific template')
703
+ .action(async (templateName) => {
704
+ await Promise.race([registryReady, new Promise(r => setTimeout(r, 3000))]);
705
+ // Search official first, then contributed
706
+ const officialRes = getOfficialByName(templateName);
707
+ const contributedRes = getContributedByName(templateName);
708
+ // Collect all ambiguous across both registries
709
+ const allAmbiguous = [
710
+ ...(officialRes.ambiguous ?? []),
711
+ ...(contributedRes.ambiguous ?? []),
712
+ ];
713
+ if (!officialRes.match && !contributedRes.match) {
714
+ if (allAmbiguous.length > 0) {
715
+ const lines = allAmbiguous.map(t => ` ${chalk.cyan(t.key)} ${t.metadata.contributor ? chalk.dim('community') : chalk.green('✦ official')}`).join('\n');
716
+ console.log(boxen(chalk.yellow.bold('⚠️ Ambiguous — multiple templates match\n\n') + lines + '\n\n' +
717
+ chalk.gray('Use the full key: ') + chalk.cyan('create-fs-app info <full-key>'), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'yellow' }));
718
+ }
719
+ else {
720
+ console.log(boxen(chalk.red.bold('❌ Template Not Found\n\n') +
721
+ chalk.white(`"${templateName}" doesn't match any template.\n\n`) +
722
+ chalk.gray('Run ') + chalk.cyan('create-fs-app list --all') + chalk.gray(' to browse everything.'), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'red' }));
723
+ }
490
724
  return;
491
725
  }
726
+ const isOfficial = !!officialRes.match;
727
+ const { key, metadata } = (officialRes.match ?? contributedRes.match);
728
+ const borderColor = isOfficial ? 'cyan' : 'yellow';
729
+ const badge = isOfficial
730
+ ? chalk.green('✦ official')
731
+ : (() => {
732
+ const c = metadata.contributor;
733
+ return chalk.yellow('◆ contributed') +
734
+ (c ? chalk.dim(` by @${c.github} ${c.url}`) : '');
735
+ })();
736
+ let body = chalk.bold.white(`📦 ${key}\n`) + badge + '\n\n';
737
+ if (!isOfficial && metadata.contributor) {
738
+ body += chalk.gray('Contributor repo: ') + chalk.dim(metadata.contributor.repoUrl) + '\n\n';
739
+ }
740
+ body +=
741
+ chalk.gray('Description:\n') + chalk.white(`${metadata.description}\n\n`) +
742
+ chalk.gray('Features:\n') +
743
+ metadata.features.map((f) => chalk.green(`✓ ${f}`)).join('\n') + '\n\n' +
744
+ chalk.gray('Supports: ') +
745
+ Object.entries(metadata.supports ?? {}).filter(([, v]) => v).map(([k]) => chalk.yellow(k)).join(', ') +
746
+ '\n\n' +
747
+ chalk.gray('Repository: ') + chalk.cyan.underline(metadata.url ?? '');
492
748
  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}`), {
749
+ console.log(boxen(body, {
750
+ padding: 1, margin: 1, borderStyle: 'round', borderColor,
751
+ title: chalk.bold('Template Info'), titleAlignment: 'center',
752
+ }));
753
+ const usageCmd = isOfficial
754
+ ? `npx create-fs-app my-app # wizard auto-selects for this stack`
755
+ : `npx create-fs-app my-app --template ${key}`;
756
+ console.log(boxen(chalk.cyan(usageCmd), {
510
757
  padding: 1,
511
758
  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);
759
+ borderStyle: 'round', borderColor: 'blue',
760
+ title: chalk.bold.blue('💡 Usage'), titleAlignment: 'left',
761
+ }));
518
762
  });
519
763
  // Health check command
520
764
  program
@@ -528,7 +772,8 @@ async function main() {
528
772
  }
529
773
  catch (error) {
530
774
  Logger.error('Failed to run health check');
531
- console.error(error);
775
+ if (error instanceof Error)
776
+ console.error(chalk.red(error.message));
532
777
  process.exit(1);
533
778
  }
534
779
  });
@@ -538,12 +783,65 @@ async function main() {
538
783
  .description('Manage configuration presets');
539
784
  presetCmd
540
785
  .command('save <name>')
541
- .description('Save current configuration as a preset')
786
+ .description('Save a stack configuration as a reusable preset.\n' +
787
+ ' Pass the same stack flags as the main command (--frontend, --backend,\n' +
788
+ ' --database, --orm, --package-manager, etc.).\n' +
789
+ ' Unspecified flags default to the saas-starter stack.')
542
790
  .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);
791
+ .option('-f, --force', 'Overwrite an existing preset without prompting')
792
+ .action(async (presetName, cmdOptions) => {
793
+ try {
794
+ // ── Guard: block built-in names ─────────────────────────────────────
795
+ if (isBuiltinPresetName(presetName)) {
796
+ Logger.error(`"${presetName}" is a built-in preset and cannot be overwritten.`);
797
+ console.log(chalk.cyan('Built-in presets: ' + Object.keys(BUILTIN_PRESETS).join(', ') + '\n'));
798
+ process.exit(1);
799
+ }
800
+ // ── Guard: warn on duplicate user preset ────────────────────────────
801
+ const exists = await userPresetExists(presetName);
802
+ if (exists && !cmdOptions.force) {
803
+ Logger.error(`Preset "${presetName}" already exists.`);
804
+ console.log(chalk.cyan(` Use --force to overwrite: create-fs-app preset save ${presetName} --force\n`));
805
+ process.exit(1);
806
+ }
807
+ // Stack flags are defined on the root program and consumed there —
808
+ // read them back via program.opts().
809
+ const rootOpts = program.opts();
810
+ // Merge with saas-starter defaults for anything not specified
811
+ const withDefaults = {
812
+ monorepo: rootOpts.monorepo ?? 'turborepo',
813
+ frontend: rootOpts.frontend ?? 'next.js',
814
+ backend: rootOpts.backend ?? 'nest.js',
815
+ database: rootOpts.database ?? 'postgresql',
816
+ orm: rootOpts.orm ?? 'prisma',
817
+ packageManager: rootOpts.packageManager,
818
+ styling: rootOpts.styling,
819
+ apiStyle: rootOpts.apiStyle,
820
+ auth: rootOpts.auth,
821
+ docker: rootOpts.docker,
822
+ ci: rootOpts.ci,
823
+ };
824
+ // Build and validate the config (dummy project name — stripped by savePreset)
825
+ const config = buildConfigFromOptions('preset-placeholder', withDefaults);
826
+ await savePreset(presetName, config, cmdOptions.description);
827
+ const verb = exists ? chalk.yellow('updated') : chalk.green('saved');
828
+ console.log(`\n✓ Preset "${presetName}" ${verb}\n`);
829
+ console.log(chalk.gray(' Monorepo:'), chalk.white(config.monorepo));
830
+ console.log(chalk.gray(' Pkg manager:'), chalk.white(config.packageManager));
831
+ console.log(chalk.gray(' Frontend:'), chalk.white(config.apps.frontend.framework));
832
+ console.log(chalk.gray(' Backend:'), chalk.white(config.apps.backend.framework));
833
+ console.log(chalk.gray(' Database:'), chalk.white(config.apps.backend.database));
834
+ console.log(chalk.gray(' ORM:'), chalk.white(config.apps.backend.orm ?? 'none'));
835
+ console.log(chalk.gray(' Docker:'), chalk.white(config.apps.backend.docker ? 'yes' : 'no'));
836
+ console.log();
837
+ console.log(chalk.cyan(`💡 Use it: create-fs-app my-app --preset ${presetName}\n`));
838
+ }
839
+ catch (error) {
840
+ Logger.error('Failed to save preset');
841
+ if (error instanceof Error)
842
+ console.error(chalk.red(error.message));
843
+ process.exit(1);
844
+ }
547
845
  });
548
846
  presetCmd
549
847
  .command('list')
@@ -554,27 +852,37 @@ async function main() {
554
852
  const builtinKeys = Object.keys(BUILTIN_PRESETS);
555
853
  console.log(chalk.cyan.bold('\n📚 Available Presets\n'));
556
854
  // Built-in presets
557
- console.log(chalk.bold.green('Built-in Presets:'));
855
+ console.log(chalk.bold.green('Built-in Presets:') + chalk.dim(' (read-only — cannot be saved over or deleted)'));
558
856
  builtinKeys.forEach(key => {
559
857
  const preset = BUILTIN_PRESETS[key];
858
+ const cfg = preset.config;
560
859
  console.log(chalk.white(` ${key}`));
561
860
  console.log(chalk.gray(` ${preset.description}`));
861
+ console.log(chalk.dim(` Stack: ${cfg.apps.frontend.framework} + ${cfg.apps.backend.framework} + ${cfg.apps.backend.database}`));
562
862
  });
563
- // User presets
564
- if (presets.length > 0) {
863
+ // User presets — exclude any builtin names that may have leaked into the file
864
+ const userPresets = presets.filter(p => !isBuiltinPresetName(p.name));
865
+ if (userPresets.length > 0) {
565
866
  console.log(chalk.bold.green('\nYour Presets:'));
566
- presets.forEach(preset => {
867
+ userPresets.forEach(preset => {
567
868
  console.log(chalk.white(` ${preset.name}`));
568
869
  if (preset.description) {
569
870
  console.log(chalk.gray(` ${preset.description}`));
570
871
  }
872
+ console.log(chalk.dim(` Created: ${new Date(preset.createdAt).toLocaleString()}`));
873
+ if (preset.lastUsed) {
874
+ console.log(chalk.dim(` Last used: ${new Date(preset.lastUsed).toLocaleString()}`));
875
+ }
876
+ const cfg = preset.config;
877
+ console.log(chalk.dim(` Stack: ${cfg.apps.frontend.framework} + ${cfg.apps.backend.framework} + ${cfg.apps.backend.database}`));
571
878
  });
572
879
  }
573
880
  console.log(chalk.cyan('\n💡 Use: create-fs-app my-app --preset <name>\n'));
574
881
  }
575
882
  catch (error) {
576
883
  Logger.error('Failed to list presets');
577
- console.error(error);
884
+ if (error instanceof Error)
885
+ console.error(chalk.red(error.message));
578
886
  process.exit(1);
579
887
  }
580
888
  });
@@ -585,13 +893,23 @@ async function main() {
585
893
  try {
586
894
  const deleted = await deletePreset(name);
587
895
  if (!deleted) {
588
- Logger.error(`Preset "${name}" not found`);
896
+ // Not in user file — check if it's a builtin to give a better message
897
+ if (isBuiltinPresetName(name)) {
898
+ Logger.error(`"${name}" is a built-in preset and cannot be deleted.`);
899
+ console.log(chalk.cyan('Built-in presets: ' + Object.keys(BUILTIN_PRESETS).join(', ') + '\n'));
900
+ }
901
+ else {
902
+ Logger.error(`Preset "${name}" not found.`);
903
+ console.log(chalk.cyan('\nRun create-fs-app preset list to see available presets.\n'));
904
+ }
589
905
  process.exit(1);
590
906
  }
907
+ // deletePreset already logs success
591
908
  }
592
909
  catch (error) {
593
910
  Logger.error('Failed to delete preset');
594
- console.error(error);
911
+ if (error instanceof Error)
912
+ console.error(chalk.red(error.message));
595
913
  process.exit(1);
596
914
  }
597
915
  });
@@ -601,14 +919,17 @@ async function main() {
601
919
  .description('Manage template cache');
602
920
  cacheCmd
603
921
  .command('clear')
604
- .description('Clear template cache')
922
+ .description('Clear template cache and registry cache')
605
923
  .action(async () => {
606
924
  try {
607
925
  await clearCache();
926
+ await clearRegistryCache();
927
+ console.log(chalk.green('✓ Template cache and registry cache cleared'));
608
928
  }
609
929
  catch (error) {
610
930
  Logger.error('Failed to clear cache');
611
- console.error(error);
931
+ if (error instanceof Error)
932
+ console.error(chalk.red(error.message));
612
933
  process.exit(1);
613
934
  }
614
935
  });
@@ -632,7 +953,8 @@ async function main() {
632
953
  }
633
954
  catch (error) {
634
955
  Logger.error('Failed to get cache stats');
635
- console.error(error);
956
+ if (error instanceof Error)
957
+ console.error(chalk.red(error.message));
636
958
  process.exit(1);
637
959
  }
638
960
  });