UNPKG

onramp-docs-cli

Version:

CLI tool to set up Onramp documentation and integration in your project

98 lines (85 loc) 2.69 kB
#!/usr/bin/env node const { OnrampDocs } = require('../dist/index'); const chalk = require('chalk'); const inquirer = require('inquirer'); async function runInteractiveSetup() { console.log(chalk.blue('🔧 Onramp Interactive Setup')); console.log(''); const onrampDocs = new OnrampDocs(); try { // Ask what to set up const { actions } = await inquirer.prompt([ { type: 'checkbox', name: 'actions', message: 'What would you like to set up?', choices: [ { name: '📚 Documentation files', value: 'docs', checked: true }, { name: '📦 Install dependencies', value: 'deps', checked: true }, { name: '🔐 Environment template', value: 'env', checked: true } ], validate(answer) { if (answer.length < 1) { return 'You must choose at least one option.'; } return true; } } ]); // Ask for custom path if docs selected let docsPath; if (actions.includes('docs')) { const { useCustomPath } = await inquirer.prompt([ { type: 'confirm', name: 'useCustomPath', message: 'Use custom documentation path?', default: false } ]); if (useCustomPath) { const { customPath } = await inquirer.prompt([ { type: 'input', name: 'customPath', message: 'Enter documentation path:', default: 'doc/onramp' } ]); docsPath = customPath; } } console.log(''); console.log(chalk.blue('🚀 Starting setup...')); console.log(''); // Set up documentation if (actions.includes('docs')) { await onrampDocs.setupDocs({ docsPath: docsPath, force: true }); console.log(''); } // Install dependencies if (actions.includes('deps')) { await onrampDocs.installDependencies(); console.log(''); } // Create environment template if (actions.includes('env')) { await onrampDocs.createEnvTemplate(); console.log(''); } console.log(chalk.green('🎉 Setup complete!')); console.log(''); console.log(chalk.cyan('Next steps:')); console.log(chalk.white('1. Copy .env.local.example to .env.local')); console.log(chalk.white('2. Add your CDP API credentials to .env.local')); console.log(chalk.white('3. Check the documentation in doc/onramp/')); console.log(chalk.white('4. Start building with Onramp!')); } catch (error) { console.error(chalk.red('❌ Setup failed:'), error.message); process.exit(1); } } runInteractiveSetup();