cdp-docs-cli
Version:
CLI tool to set up CDP (Coinbase Developer Platform) documentation and integration in your project
91 lines (79 loc) ⢠2.52 kB
JavaScript
const { program } = require('commander');
const inquirer = require('inquirer');
const chalk = require('chalk');
const { CdpDocsCli } = require('../dist/index.js');
const cli = new CdpDocsCli();
async function interactiveSetup() {
console.log(chalk.blue.bold('\nš CDP Interactive Setup\n'));
const answers = await inquirer.prompt([
{
type: 'confirm',
name: 'setupDocs',
message: 'Setup CDP documentation in your project?',
default: true
},
{
type: 'confirm',
name: 'installDeps',
message: 'Install CDP dependencies (@coinbase/cdp-sdk, viem, dotenv)?',
default: true,
when: (answers) => answers.setupDocs
},
{
type: 'confirm',
name: 'createEnv',
message: 'Create environment file template (.env.local.example)?',
default: true,
when: (answers) => answers.setupDocs
},
{
type: 'input',
name: 'docsPath',
message: 'Documentation path (relative to project root):',
default: './doc/cdp',
when: (answers) => answers.setupDocs
},
{
type: 'confirm',
name: 'force',
message: 'Overwrite existing files if they exist?',
default: false,
when: (answers) => answers.setupDocs
}
]);
console.log('');
try {
if (answers.setupDocs) {
// Setup documentation
await cli.setupDocs({
docsPath: answers.docsPath,
force: answers.force
});
}
if (answers.installDeps) {
// Install dependencies
await cli.installDependencies();
}
if (answers.createEnv) {
// Create environment template
await cli.createEnvTemplate();
}
console.log(chalk.green.bold('\nš CDP setup complete!'));
console.log(chalk.cyan('\nš Next steps:'));
console.log(chalk.white('1. Get your CDP credentials from https://portal.cdp.coinbase.com/'));
console.log(chalk.white('2. Copy .env.local.example to .env.local'));
console.log(chalk.white('3. Add your actual CDP credentials to .env.local'));
console.log(chalk.white('4. Review the documentation in ./doc/cdp/'));
console.log(chalk.white('5. Follow the integration guide to add CDP to your app'));
} catch (error) {
console.error(chalk.red('\nā Setup failed:'), error.message);
process.exit(1);
}
}
program
.name('cdp-setup')
.description('Interactive CDP integration setup')
.version('1.0.0')
.action(interactiveSetup);
program.parse(process.argv);