UNPKG

kawkab-frontend

Version:

Kawkab frontend is a frontend library for the Kawkab framework

32 lines (31 loc) • 1.38 kB
import { execSync } from 'child_process'; import fs from 'fs'; import path from 'path'; import chalk from 'chalk'; export function startCommand(program) { program .command('start') .description('Start the production server.') .action(() => { const projectRoot = process.cwd(); const serverEntryPoint = path.join(projectRoot, 'web', 'server', 'index.js'); // --- Smart Check --- // Verify that the server build entry point exists before trying to start it. if (!fs.existsSync(serverEntryPoint)) { console.error(chalk.red.bold('āŒ Cannot start server.')); console.error(chalk.yellow('The production server build is missing.')); console.error(chalk.cyan('Please run "kawkab-frontend build" first to create a production build.')); process.exit(1); } console.log(chalk.blue('šŸš€ Starting production server...')); try { const command = `npx dotenv-cli -e .env.production -- npx react-router-serve ${serverEntryPoint}`; execSync(command, { stdio: 'inherit' }); } catch (error) { // This will catch errors if the server starts but then crashes. console.error(chalk.red('\nāŒ The production server crashed or failed to start.')); process.exit(1); } }); }