53 lines
1.8 KiB
JavaScript
Executable File
53 lines
1.8 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const { execSync } = require('child_process');
|
|
const chalk = require('chalk');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const rootDir = process.cwd();
|
|
const backendDir = path.join(rootDir, 'packages/backend');
|
|
const frontendDir = path.join(rootDir, 'packages/frontend');
|
|
|
|
// Create shell scripts for each service
|
|
const backendScript = path.join(rootDir, 'scripts', 'start-backend.sh');
|
|
const frontendScript = path.join(rootDir, 'scripts', 'start-frontend.sh');
|
|
|
|
// Write shell scripts
|
|
fs.writeFileSync(backendScript, `#!/bin/bash
|
|
cd "${backendDir}"
|
|
echo "🚀 Starting Backend Server..."
|
|
yarn start
|
|
`, { mode: 0o755 });
|
|
|
|
fs.writeFileSync(frontendScript, `#!/bin/bash
|
|
cd "${frontendDir}"
|
|
echo "🚀 Starting Frontend Dev Server..."
|
|
yarn dev
|
|
`, { mode: 0o755 });
|
|
|
|
console.log(chalk.cyan.bold('📦 Starting development environment'));
|
|
|
|
try {
|
|
// Clean up ports first
|
|
console.log(chalk.blue('🧹 Cleaning up ports...'));
|
|
execSync('yarn kill:ports', { stdio: 'inherit' });
|
|
|
|
// Build packages
|
|
console.log(chalk.blue('🔨 Building packages...'));
|
|
execSync('yarn build --ignore frontend', { stdio: 'inherit' });
|
|
|
|
console.log(chalk.green('✅ Build complete'));
|
|
console.log(chalk.blue('🚀 Starting services in separate terminals...'));
|
|
|
|
// Open new terminals with the shell scripts
|
|
execSync(`open -a Terminal ${backendScript}`);
|
|
execSync(`open -a Terminal ${frontendScript}`);
|
|
|
|
console.log(chalk.green('✅ Services started in separate terminal windows'));
|
|
console.log(chalk.cyan('Backend running at:') + chalk.yellow(' http://localhost:8000'));
|
|
console.log(chalk.cyan('Frontend running at:') + chalk.yellow(' http://localhost:3000'));
|
|
} catch (error) {
|
|
console.error(chalk.red(`❌ Error: ${error.message}`));
|
|
process.exit(1);
|
|
} |