import chalk from 'chalk'; import * as path from 'path'; import { ConfigManager } from '../utils/config'; import { NostrManager } from '../utils/nostr'; export async function infoCommand(): Promise { const config = await ConfigManager.getInstance(); const nostr = new NostrManager(); try { console.log(chalk.cyan('\nšŸ“‹ Local Project Configuration\n')); const hasLocalConfig = await config.hasLocalConfig(); const configPath = config.getConfigPath(); const currentDir = process.cwd(); const projectName = path.basename(currentDir); console.log(chalk.white('Project Details:')); console.log(chalk.white(' šŸ“ Project Name: ') + chalk.yellow(projectName)); console.log(chalk.white(' šŸ“ Project Path: ') + chalk.gray(currentDir)); console.log(chalk.white(' āš™ļø Config Path: ') + chalk.gray(configPath)); console.log( chalk.white(' šŸ“„ Config Exists: ') + (hasLocalConfig ? chalk.green('āœ… Yes') : chalk.red('āŒ No')) ); if (!hasLocalConfig) { console.log(chalk.yellow('\nāš ļø No local configuration found for this project.')); console.log(chalk.white('To set up authentication for this project, run:')); console.log(chalk.green(' nostr-deploy-cli auth')); console.log(chalk.white('To configure deployment settings, run:')); console.log(chalk.green(' nostr-deploy-cli config')); return; } const userConfig = config.getConfig(); console.log(chalk.white('\nAuthentication Status:')); if (userConfig.nostr?.publicKey) { console.log(chalk.white(' šŸ”‘ Public Key: ') + chalk.green('āœ… Configured')); try { const npub = await nostr.getNpubSubdomain(); console.log(chalk.white(' 🌐 Your npub: ') + chalk.blue(npub)); const baseDomain = userConfig.deployment?.baseDomain || 'nostrdeploy.com'; console.log( chalk.white(' šŸŒ Deployment URL: ') + chalk.cyan(`https://${npub}.${baseDomain}`) ); } catch (error) { console.log(chalk.white(' 🌐 npub: ') + chalk.red('āŒ Error generating npub')); } if (userConfig.nostr?.privateKey) { console.log(chalk.white(' šŸ” Private Key: ') + chalk.green('āœ… Configured (can deploy)')); } else { console.log( chalk.white(' šŸ” Private Key: ') + chalk.yellow('āš ļø Not configured (read-only)') ); } } else { console.log(chalk.white(' šŸ”‘ Authentication: ') + chalk.red('āŒ Not configured')); } console.log(chalk.white('\nNostr Configuration:')); if (userConfig.nostr?.relays && userConfig.nostr.relays.length > 0) { console.log( chalk.white(' šŸ“” Relays: ') + chalk.green(`āœ… ${userConfig.nostr.relays.length} configured`) ); userConfig.nostr.relays.forEach((relay, index) => { console.log(chalk.white(` ${index + 1}. `) + chalk.gray(relay)); }); } else { console.log(chalk.white(' šŸ“” Relays: ') + chalk.red('āŒ Not configured')); } console.log(chalk.white('\nDeployment Configuration:')); if (userConfig.blossom?.servers && userConfig.blossom.servers.length > 0) { console.log(chalk.white(' 🌸 Blossom Servers: ') + chalk.green('āœ… Configured')); userConfig.blossom.servers.forEach((server, index) => { console.log(chalk.white(` ${index + 1}. `) + chalk.gray(server)); }); } else { console.log(chalk.white(' 🌸 Blossom Servers: ') + chalk.red('āŒ Not configured')); } if (userConfig.deployment?.baseDomain) { console.log(chalk.white(' 🌐 Base Domain: ') + chalk.green('āœ… Configured')); console.log(chalk.white(' Domain: ') + chalk.gray(userConfig.deployment.baseDomain)); } else { console.log(chalk.white(' 🌐 Base Domain: ') + chalk.red('āŒ Not configured')); } console.log(chalk.white('\nConfiguration Status:')); if (config.isConfigured()) { console.log(chalk.green(' āœ… Ready to deploy! All required settings are configured.')); console.log(chalk.white('\nNext steps:')); console.log(chalk.white(' • Deploy your site: ') + chalk.green('nostr-deploy-cli deploy')); console.log( chalk.white(' • Check deployment status: ') + chalk.green('nostr-deploy-cli status') ); } else { console.log(chalk.yellow(' āš ļø Configuration incomplete. Missing required settings.')); console.log(chalk.white('\nRequired next steps:')); if (!userConfig.nostr?.publicKey) { console.log( chalk.white(' • Set up authentication: ') + chalk.green('nostr-deploy-cli auth') ); } if (!userConfig.blossom?.servers || userConfig.blossom.servers.length === 0) { console.log( chalk.white(' • Configure Blossom servers: ') + chalk.green('nostr-deploy-cli config') ); } } } catch (error) { console.error(chalk.red(`\nāŒ Failed to load configuration: ${error}`)); process.exit(1); } }