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
JavaScript
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);