UNPKG

harmony-cli

Version:

AI-powered music generation CLI tool using Google's Lyria RealTime for coding background music

99 lines (82 loc) • 3.5 kB
#!/usr/bin/env node import chalk from 'chalk'; import { spawn } from 'child_process'; import inquirer from 'inquirer'; console.log(chalk.cyan('šŸ”§ Harmony CLI Setup\n')); async function checkPython() { console.log(chalk.blue('Checking Python installation...')); return new Promise((resolve) => { const pythonProcess = spawn('python', ['--version'], { stdio: 'pipe' }); let output = ''; pythonProcess.stdout.on('data', (data) => { output += data.toString(); }); pythonProcess.on('close', (code) => { if (code === 0) { console.log(chalk.green(`āœ… Python found: ${output.trim()}`)); resolve(true); } else { console.log(chalk.red('āŒ Python not found')); console.log(chalk.yellow('Please install Python from https://python.org')); resolve(false); } }); pythonProcess.on('error', () => { console.log(chalk.red('āŒ Python not found')); console.log(chalk.yellow('Please install Python from https://python.org')); resolve(false); }); }); } async function installPythonPackages() { console.log(chalk.blue('\nInstalling Python packages...')); return new Promise((resolve) => { const pipProcess = spawn('pip', ['install', 'google-generativeai'], { stdio: 'inherit' }); pipProcess.on('close', (code) => { if (code === 0) { console.log(chalk.green('\nāœ… Python packages installed successfully!')); resolve(true); } else { console.log(chalk.red('\nāŒ Failed to install Python packages')); console.log(chalk.yellow('Please run manually: pip install google-generativeai')); resolve(false); } }); pipProcess.on('error', () => { console.log(chalk.red('\nāŒ Failed to run pip')); console.log(chalk.yellow('Please run manually: pip install google-generativeai')); resolve(false); }); }); } async function main() { const pythonOk = await checkPython(); if (!pythonOk) { console.log(chalk.red('\nāŒ Setup incomplete - Python is required')); process.exit(1); } const { installPackages } = await inquirer.prompt([ { type: 'confirm', name: 'installPackages', message: 'Install required Python packages (google-generativeai)?', default: true } ]); if (installPackages) { const packagesOk = await installPythonPackages(); if (packagesOk) { console.log(chalk.green('\nšŸŽ‰ Setup complete!')); console.log(chalk.cyan('\nNext steps:')); console.log(chalk.white('1. Get your Gemini API key from: https://aistudio.google.com/apikey')); console.log(chalk.white('2. Run: npx harmony-cli')); console.log(chalk.white('3. Enjoy AI-generated music while coding! šŸŽµ')); } } else { console.log(chalk.yellow('\nāš ļø You will need to install python packages manually:')); console.log(chalk.white('pip install google-generativeai')); } } main().catch(console.error);