cdp-docs-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +213 -0
- package/bin/cdp-docs.js +48 -0
- package/bin/cdp-setup.js +91 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
- package/src/templates/docs/exporting.md +0 -0
- package/src/templates/docs/fund.md +122 -0
- package/src/templates/docs/importing.md +273 -0
- package/src/templates/docs/managing-accounts.md +366 -0
- package/src/templates/docs/policies.md +730 -0
- package/src/templates/docs/transfer.md +366 -0
- package/src/templates/docs/wallet-accounts.md +203 -0
- package/src/templates/docs/wallet-start.md +741 -0
- package/src/templates/prompt/INTEGRATION-SUMMARY.md +151 -0
- package/src/templates/prompt/SETUP-CDP-WALLET.md +142 -0
- package/src/templates/prompt/cdp-wallet.md +1155 -0
- package/src/templates/prompt/context.md +105 -0
- package/src/templates/prompt/directory.md +97 -0
package/README.md
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
# 🚀 CDP Docs CLI
|
2
|
+
|
3
|
+
A CLI tool to quickly set up Coinbase Developer Platform (CDP) documentation and integration in your Node.js projects.
|
4
|
+
|
5
|
+
## 📦 Installation
|
6
|
+
|
7
|
+
### Global Installation (Recommended)
|
8
|
+
```bash
|
9
|
+
npm install -g cdp-docs-cli
|
10
|
+
```
|
11
|
+
|
12
|
+
### Using npx (No Installation Required)
|
13
|
+
```bash
|
14
|
+
npx cdp-docs-cli setup
|
15
|
+
npx cdp-setup
|
16
|
+
```
|
17
|
+
|
18
|
+
## 🎯 What This Package Does
|
19
|
+
|
20
|
+
When you install and run this CLI tool, it will:
|
21
|
+
|
22
|
+
1. **📁 Create Documentation Structure**: Sets up a `/doc/cdp/` directory in your project
|
23
|
+
2. **📖 Copy Documentation**: Adds comprehensive CDP wallet API documentation
|
24
|
+
3. **🔧 Integration Guides**: Provides step-by-step setup and integration guides
|
25
|
+
4. **📦 Install Dependencies**: Optionally installs required CDP packages
|
26
|
+
5. **🔐 Environment Setup**: Creates environment file templates with CDP credentials
|
27
|
+
|
28
|
+
## 🚀 Quick Start
|
29
|
+
|
30
|
+
### Interactive Setup (Recommended)
|
31
|
+
```bash
|
32
|
+
npx cdp-setup
|
33
|
+
```
|
34
|
+
|
35
|
+
This will guide you through:
|
36
|
+
- Setting up documentation
|
37
|
+
- Installing CDP dependencies
|
38
|
+
- Creating environment templates
|
39
|
+
- Configuring your project
|
40
|
+
|
41
|
+
### Manual Setup
|
42
|
+
```bash
|
43
|
+
# Setup documentation only
|
44
|
+
npx cdp-docs setup
|
45
|
+
|
46
|
+
# List available documentation
|
47
|
+
npx cdp-docs list
|
48
|
+
|
49
|
+
# Setup with custom path
|
50
|
+
npx cdp-docs setup --path ./docs/coinbase
|
51
|
+
|
52
|
+
# Force overwrite existing files
|
53
|
+
npx cdp-docs setup --force
|
54
|
+
```
|
55
|
+
|
56
|
+
## 📁 Generated Directory Structure
|
57
|
+
|
58
|
+
After running the setup, your project will have:
|
59
|
+
|
60
|
+
```
|
61
|
+
your-project/
|
62
|
+
├── doc/
|
63
|
+
│ └── cdp/
|
64
|
+
│ ├── wallet/ # Wallet API documentation
|
65
|
+
│ │ ├── wallet-start.md
|
66
|
+
│ │ ├── fund.md
|
67
|
+
│ │ ├── transfer.md
|
68
|
+
│ │ ├── managing-accounts.md
|
69
|
+
│ │ ├── policies.md
|
70
|
+
│ │ ├── importing.md
|
71
|
+
│ │ ├── exporting.md
|
72
|
+
│ │ └── wallet-accounts.md
|
73
|
+
│ ├── integration/ # Integration guides
|
74
|
+
│ │ ├── SETUP-CDP-WALLET.md
|
75
|
+
│ │ ├── INTEGRATION-SUMMARY.md
|
76
|
+
│ │ ├── cdp-wallet.md
|
77
|
+
│ │ ├── context.md
|
78
|
+
│ │ └── directory.md
|
79
|
+
│ └── examples/ # Code examples (future)
|
80
|
+
├── .env.local.example # Environment template
|
81
|
+
└── package.json # Updated with CDP dependencies
|
82
|
+
```
|
83
|
+
|
84
|
+
## 🔧 Dependencies Installed
|
85
|
+
|
86
|
+
The CLI will optionally install these packages:
|
87
|
+
|
88
|
+
### Runtime Dependencies
|
89
|
+
- `@coinbase/cdp-sdk` - Official Coinbase Developer Platform SDK
|
90
|
+
- `dotenv` - Environment variable management
|
91
|
+
- `viem` - Ethereum interaction library
|
92
|
+
|
93
|
+
### Dev Dependencies
|
94
|
+
- `@types/node` - Node.js TypeScript definitions
|
95
|
+
|
96
|
+
## 🔐 Environment Setup
|
97
|
+
|
98
|
+
The tool creates a `.env.local.example` file with the required CDP configuration:
|
99
|
+
|
100
|
+
```bash
|
101
|
+
# CDP (Coinbase Developer Platform) Configuration
|
102
|
+
# Get these values from https://portal.cdp.coinbase.com/
|
103
|
+
|
104
|
+
# Your CDP API credentials
|
105
|
+
CDP_API_KEY_ID=your_actual_key_id_here
|
106
|
+
CDP_API_KEY_SECRET=your_actual_key_secret_here
|
107
|
+
CDP_WALLET_SECRET=your_actual_wallet_secret_here
|
108
|
+
|
109
|
+
# Network configuration (optional)
|
110
|
+
# CDP_NETWORK_ID=base-sepolia # Use base-sepolia for testing, base-mainnet for production
|
111
|
+
```
|
112
|
+
|
113
|
+
## 📚 Available Commands
|
114
|
+
|
115
|
+
### `cdp-docs`
|
116
|
+
Main documentation management command:
|
117
|
+
|
118
|
+
```bash
|
119
|
+
cdp-docs setup [options] # Setup CDP documentation
|
120
|
+
cdp-docs list # List available documentation
|
121
|
+
cdp-docs --help # Show help
|
122
|
+
```
|
123
|
+
|
124
|
+
#### Options:
|
125
|
+
- `-f, --force` - Overwrite existing files
|
126
|
+
- `-p, --path <path>` - Custom documentation path (default: ./doc/cdp)
|
127
|
+
|
128
|
+
### `cdp-setup`
|
129
|
+
Interactive setup wizard:
|
130
|
+
|
131
|
+
```bash
|
132
|
+
cdp-setup # Run interactive setup
|
133
|
+
```
|
134
|
+
|
135
|
+
## 🏗️ Integration Guide
|
136
|
+
|
137
|
+
After running the setup:
|
138
|
+
|
139
|
+
1. **Get CDP Credentials**:
|
140
|
+
- Visit [https://portal.cdp.coinbase.com/](https://portal.cdp.coinbase.com/)
|
141
|
+
- Create API keys and wallet secret
|
142
|
+
|
143
|
+
2. **Configure Environment**:
|
144
|
+
```bash
|
145
|
+
cp .env.local.example .env.local
|
146
|
+
# Edit .env.local with your actual credentials
|
147
|
+
```
|
148
|
+
|
149
|
+
3. **Review Documentation**:
|
150
|
+
- Read `./doc/cdp/integration/SETUP-CDP-WALLET.md`
|
151
|
+
- Follow `./doc/cdp/integration/INTEGRATION-SUMMARY.md`
|
152
|
+
|
153
|
+
4. **Start Building**:
|
154
|
+
- Use the wallet API documentation in `./doc/cdp/wallet/`
|
155
|
+
- Implement CDP features in your application
|
156
|
+
|
157
|
+
## 🌟 Features
|
158
|
+
|
159
|
+
### 📖 Comprehensive Documentation
|
160
|
+
- Complete wallet API v2 documentation
|
161
|
+
- Step-by-step integration guides
|
162
|
+
- Security best practices
|
163
|
+
- Troubleshooting guides
|
164
|
+
|
165
|
+
### 🛠️ Developer Experience
|
166
|
+
- Interactive CLI setup
|
167
|
+
- Automatic dependency management
|
168
|
+
- Environment template generation
|
169
|
+
- Force overwrite options
|
170
|
+
|
171
|
+
### 🔒 Security First
|
172
|
+
- Environment variable management
|
173
|
+
- Private key handling best practices
|
174
|
+
- Testnet-first development approach
|
175
|
+
|
176
|
+
### 🌐 Multi-Network Support
|
177
|
+
Documentation covers:
|
178
|
+
- **Base** (Layer 2 Ethereum)
|
179
|
+
- **Ethereum** (Mainnet & Testnets)
|
180
|
+
- **Solana** (Mainnet & Devnet)
|
181
|
+
|
182
|
+
## 📋 Requirements
|
183
|
+
|
184
|
+
- **Node.js**: 16.0.0 or higher
|
185
|
+
- **npm**: 7.0.0 or higher
|
186
|
+
- **Operating System**: macOS, Linux, Windows
|
187
|
+
|
188
|
+
## 🤝 Contributing
|
189
|
+
|
190
|
+
This package is maintained by [must-be-ash](https://github.com/must-be-ash).
|
191
|
+
|
192
|
+
## 📄 License
|
193
|
+
|
194
|
+
MIT
|
195
|
+
|
196
|
+
## 🆘 Support
|
197
|
+
|
198
|
+
- **CDP Documentation**: [https://docs.cdp.coinbase.com/](https://docs.cdp.coinbase.com/)
|
199
|
+
- **Base Network**: [https://base.org/](https://base.org/)
|
200
|
+
- **Issues**: [GitHub Issues](https://github.com/must-be-ash/cdp-docs-cli/issues)
|
201
|
+
|
202
|
+
## 🔄 Version History
|
203
|
+
|
204
|
+
### 1.0.0
|
205
|
+
- Initial release
|
206
|
+
- CDP documentation setup
|
207
|
+
- Interactive CLI
|
208
|
+
- Dependency management
|
209
|
+
- Environment templates
|
210
|
+
|
211
|
+
---
|
212
|
+
|
213
|
+
**Built with ❤️ for the CDP developer community**
|
package/bin/cdp-docs.js
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
const { program } = require('commander');
|
4
|
+
const { CdpDocsCli } = require('../dist/index.js');
|
5
|
+
|
6
|
+
const cli = new CdpDocsCli();
|
7
|
+
|
8
|
+
program
|
9
|
+
.name('cdp-docs')
|
10
|
+
.description('CDP (Coinbase Developer Platform) documentation CLI')
|
11
|
+
.version('1.0.0');
|
12
|
+
|
13
|
+
program
|
14
|
+
.command('setup')
|
15
|
+
.description('Setup CDP documentation in your project')
|
16
|
+
.option('-f, --force', 'Overwrite existing files')
|
17
|
+
.option('-p, --path <path>', 'Custom path for documentation (default: ./doc/cdp)')
|
18
|
+
.action(async (options) => {
|
19
|
+
try {
|
20
|
+
await cli.setupDocs({
|
21
|
+
force: options.force,
|
22
|
+
docsPath: options.path
|
23
|
+
});
|
24
|
+
} catch (error) {
|
25
|
+
console.error('Error:', error.message);
|
26
|
+
process.exit(1);
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
30
|
+
program
|
31
|
+
.command('list')
|
32
|
+
.description('List available CDP documentation')
|
33
|
+
.action(async () => {
|
34
|
+
try {
|
35
|
+
await cli.listDocs();
|
36
|
+
} catch (error) {
|
37
|
+
console.error('Error:', error.message);
|
38
|
+
process.exit(1);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
// Default action when no command is specified
|
43
|
+
program
|
44
|
+
.action(async () => {
|
45
|
+
await cli.listDocs();
|
46
|
+
});
|
47
|
+
|
48
|
+
program.parse(process.argv);
|
package/bin/cdp-setup.js
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
const { program } = require('commander');
|
4
|
+
const inquirer = require('inquirer');
|
5
|
+
const chalk = require('chalk');
|
6
|
+
const { CdpDocsCli } = require('../dist/index.js');
|
7
|
+
|
8
|
+
const cli = new CdpDocsCli();
|
9
|
+
|
10
|
+
async function interactiveSetup() {
|
11
|
+
console.log(chalk.blue.bold('\n🚀 CDP Interactive Setup\n'));
|
12
|
+
|
13
|
+
const answers = await inquirer.prompt([
|
14
|
+
{
|
15
|
+
type: 'confirm',
|
16
|
+
name: 'setupDocs',
|
17
|
+
message: 'Setup CDP documentation in your project?',
|
18
|
+
default: true
|
19
|
+
},
|
20
|
+
{
|
21
|
+
type: 'confirm',
|
22
|
+
name: 'installDeps',
|
23
|
+
message: 'Install CDP dependencies (@coinbase/cdp-sdk, viem, dotenv)?',
|
24
|
+
default: true,
|
25
|
+
when: (answers) => answers.setupDocs
|
26
|
+
},
|
27
|
+
{
|
28
|
+
type: 'confirm',
|
29
|
+
name: 'createEnv',
|
30
|
+
message: 'Create environment file template (.env.local.example)?',
|
31
|
+
default: true,
|
32
|
+
when: (answers) => answers.setupDocs
|
33
|
+
},
|
34
|
+
{
|
35
|
+
type: 'input',
|
36
|
+
name: 'docsPath',
|
37
|
+
message: 'Documentation path (relative to project root):',
|
38
|
+
default: './doc/cdp',
|
39
|
+
when: (answers) => answers.setupDocs
|
40
|
+
},
|
41
|
+
{
|
42
|
+
type: 'confirm',
|
43
|
+
name: 'force',
|
44
|
+
message: 'Overwrite existing files if they exist?',
|
45
|
+
default: false,
|
46
|
+
when: (answers) => answers.setupDocs
|
47
|
+
}
|
48
|
+
]);
|
49
|
+
|
50
|
+
console.log('');
|
51
|
+
|
52
|
+
try {
|
53
|
+
if (answers.setupDocs) {
|
54
|
+
// Setup documentation
|
55
|
+
await cli.setupDocs({
|
56
|
+
docsPath: answers.docsPath,
|
57
|
+
force: answers.force
|
58
|
+
});
|
59
|
+
}
|
60
|
+
|
61
|
+
if (answers.installDeps) {
|
62
|
+
// Install dependencies
|
63
|
+
await cli.installDependencies();
|
64
|
+
}
|
65
|
+
|
66
|
+
if (answers.createEnv) {
|
67
|
+
// Create environment template
|
68
|
+
await cli.createEnvTemplate();
|
69
|
+
}
|
70
|
+
|
71
|
+
console.log(chalk.green.bold('\n🎉 CDP setup complete!'));
|
72
|
+
console.log(chalk.cyan('\n📝 Next steps:'));
|
73
|
+
console.log(chalk.white('1. Get your CDP credentials from https://portal.cdp.coinbase.com/'));
|
74
|
+
console.log(chalk.white('2. Copy .env.local.example to .env.local'));
|
75
|
+
console.log(chalk.white('3. Add your actual CDP credentials to .env.local'));
|
76
|
+
console.log(chalk.white('4. Review the documentation in ./doc/cdp/'));
|
77
|
+
console.log(chalk.white('5. Follow the integration guide to add CDP to your app'));
|
78
|
+
|
79
|
+
} catch (error) {
|
80
|
+
console.error(chalk.red('\n❌ Setup failed:'), error.message);
|
81
|
+
process.exit(1);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
program
|
86
|
+
.name('cdp-setup')
|
87
|
+
.description('Interactive CDP integration setup')
|
88
|
+
.version('1.0.0')
|
89
|
+
.action(interactiveSetup);
|
90
|
+
|
91
|
+
program.parse(process.argv);
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
export interface SetupOptions {
|
2
|
+
projectRoot?: string;
|
3
|
+
docsPath?: string;
|
4
|
+
force?: boolean;
|
5
|
+
}
|
6
|
+
export declare class CdpDocsCli {
|
7
|
+
private templatePath;
|
8
|
+
constructor();
|
9
|
+
/**
|
10
|
+
* Setup CDP documentation in the target project
|
11
|
+
*/
|
12
|
+
setupDocs(options?: SetupOptions): Promise<void>;
|
13
|
+
/**
|
14
|
+
* Create the directory structure for CDP docs
|
15
|
+
*/
|
16
|
+
private createDirectoryStructure;
|
17
|
+
/**
|
18
|
+
* Copy documentation files from templates
|
19
|
+
*/
|
20
|
+
private copyDocumentationFiles;
|
21
|
+
/**
|
22
|
+
* Copy integration files from templates
|
23
|
+
*/
|
24
|
+
private copyIntegrationFiles;
|
25
|
+
/**
|
26
|
+
* Install CDP dependencies
|
27
|
+
*/
|
28
|
+
installDependencies(projectRoot?: string): Promise<void>;
|
29
|
+
/**
|
30
|
+
* Create environment file template
|
31
|
+
*/
|
32
|
+
createEnvTemplate(projectRoot?: string): Promise<void>;
|
33
|
+
/**
|
34
|
+
* List available documentation
|
35
|
+
*/
|
36
|
+
listDocs(projectRoot?: string): Promise<void>;
|
37
|
+
}
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,YAAY,CAAS;;IAM7B;;OAEG;IACG,SAAS,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B1D;;OAEG;YACW,wBAAwB;IAkBtC;;OAEG;YACW,sBAAsB;IAYpC;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;IACG,mBAAmB,CAAC,WAAW,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAyC7E;;OAEG;IACG,iBAAiB,CAAC,WAAW,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB3E;;OAEG;IACG,QAAQ,CAAC,WAAW,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAoCnE"}
|
package/dist/index.js
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
37
|
+
};
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
exports.CdpDocsCli = void 0;
|
40
|
+
const fs = __importStar(require("fs-extra"));
|
41
|
+
const path = __importStar(require("path"));
|
42
|
+
const chalk_1 = __importDefault(require("chalk"));
|
43
|
+
class CdpDocsCli {
|
44
|
+
constructor() {
|
45
|
+
this.templatePath = path.join(__dirname, '..', 'src', 'templates');
|
46
|
+
}
|
47
|
+
/**
|
48
|
+
* Setup CDP documentation in the target project
|
49
|
+
*/
|
50
|
+
async setupDocs(options = {}) {
|
51
|
+
const projectRoot = options.projectRoot || process.cwd();
|
52
|
+
const docsPath = options.docsPath || path.join(projectRoot, 'doc', 'cdp');
|
53
|
+
console.log(chalk_1.default.blue('🚀 Setting up CDP documentation...'));
|
54
|
+
try {
|
55
|
+
// Create the docs directory structure
|
56
|
+
await this.createDirectoryStructure(docsPath, options.force);
|
57
|
+
// Copy documentation files
|
58
|
+
await this.copyDocumentationFiles(docsPath);
|
59
|
+
// Copy prompt/integration files
|
60
|
+
await this.copyIntegrationFiles(docsPath);
|
61
|
+
console.log(chalk_1.default.green('✅ CDP documentation setup complete!'));
|
62
|
+
console.log(chalk_1.default.yellow(`📁 Documentation created at: ${docsPath}`));
|
63
|
+
console.log(chalk_1.default.cyan('\n📚 Available commands:'));
|
64
|
+
console.log(chalk_1.default.white(' - npx cdp-setup # Run interactive CDP integration setup'));
|
65
|
+
console.log(chalk_1.default.white(' - npx cdp-docs # Show available documentation'));
|
66
|
+
}
|
67
|
+
catch (error) {
|
68
|
+
console.error(chalk_1.default.red('❌ Error setting up CDP documentation:'), error);
|
69
|
+
throw error;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
/**
|
73
|
+
* Create the directory structure for CDP docs
|
74
|
+
*/
|
75
|
+
async createDirectoryStructure(docsPath, force = false) {
|
76
|
+
const dirsToCreate = [
|
77
|
+
docsPath,
|
78
|
+
path.join(docsPath, 'wallet'),
|
79
|
+
path.join(docsPath, 'integration'),
|
80
|
+
path.join(docsPath, 'examples')
|
81
|
+
];
|
82
|
+
for (const dir of dirsToCreate) {
|
83
|
+
if (await fs.pathExists(dir) && !force) {
|
84
|
+
console.log(chalk_1.default.yellow(`⚠️ Directory already exists: ${dir}`));
|
85
|
+
}
|
86
|
+
else {
|
87
|
+
await fs.ensureDir(dir);
|
88
|
+
console.log(chalk_1.default.green(`📁 Created directory: ${dir}`));
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
/**
|
93
|
+
* Copy documentation files from templates
|
94
|
+
*/
|
95
|
+
async copyDocumentationFiles(docsPath) {
|
96
|
+
const docsSourcePath = path.join(this.templatePath, 'docs');
|
97
|
+
const docsTargetPath = path.join(docsPath, 'wallet');
|
98
|
+
if (await fs.pathExists(docsSourcePath)) {
|
99
|
+
await fs.copy(docsSourcePath, docsTargetPath, { overwrite: true });
|
100
|
+
console.log(chalk_1.default.green('📖 Copied wallet documentation files'));
|
101
|
+
}
|
102
|
+
else {
|
103
|
+
console.log(chalk_1.default.yellow('⚠️ Wallet docs template not found'));
|
104
|
+
}
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* Copy integration files from templates
|
108
|
+
*/
|
109
|
+
async copyIntegrationFiles(docsPath) {
|
110
|
+
const promptSourcePath = path.join(this.templatePath, 'prompt');
|
111
|
+
const promptTargetPath = path.join(docsPath, 'integration');
|
112
|
+
if (await fs.pathExists(promptSourcePath)) {
|
113
|
+
await fs.copy(promptSourcePath, promptTargetPath, { overwrite: true });
|
114
|
+
console.log(chalk_1.default.green('🔧 Copied integration documentation files'));
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
console.log(chalk_1.default.yellow('⚠️ Integration docs template not found'));
|
118
|
+
}
|
119
|
+
}
|
120
|
+
/**
|
121
|
+
* Install CDP dependencies
|
122
|
+
*/
|
123
|
+
async installDependencies(projectRoot = process.cwd()) {
|
124
|
+
console.log(chalk_1.default.blue('📦 Installing CDP dependencies...'));
|
125
|
+
const packageJsonPath = path.join(projectRoot, 'package.json');
|
126
|
+
if (!await fs.pathExists(packageJsonPath)) {
|
127
|
+
throw new Error('package.json not found. Please run this command in a Node.js project directory.');
|
128
|
+
}
|
129
|
+
const dependencies = [
|
130
|
+
'@coinbase/cdp-sdk',
|
131
|
+
'dotenv',
|
132
|
+
'viem'
|
133
|
+
];
|
134
|
+
const devDependencies = [
|
135
|
+
'@types/node'
|
136
|
+
];
|
137
|
+
try {
|
138
|
+
const { execSync } = require('child_process');
|
139
|
+
console.log(chalk_1.default.blue('Installing runtime dependencies...'));
|
140
|
+
execSync(`npm install ${dependencies.join(' ')}`, {
|
141
|
+
stdio: 'inherit',
|
142
|
+
cwd: projectRoot
|
143
|
+
});
|
144
|
+
console.log(chalk_1.default.blue('Installing dev dependencies...'));
|
145
|
+
execSync(`npm install -D ${devDependencies.join(' ')}`, {
|
146
|
+
stdio: 'inherit',
|
147
|
+
cwd: projectRoot
|
148
|
+
});
|
149
|
+
console.log(chalk_1.default.green('✅ Dependencies installed successfully!'));
|
150
|
+
}
|
151
|
+
catch (error) {
|
152
|
+
console.error(chalk_1.default.red('❌ Error installing dependencies:'), error);
|
153
|
+
throw error;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
/**
|
157
|
+
* Create environment file template
|
158
|
+
*/
|
159
|
+
async createEnvTemplate(projectRoot = process.cwd()) {
|
160
|
+
const envPath = path.join(projectRoot, '.env.local.example');
|
161
|
+
const envContent = `# CDP (Coinbase Developer Platform) Configuration
|
162
|
+
# Get these values from https://portal.cdp.coinbase.com/
|
163
|
+
|
164
|
+
# Your CDP API credentials
|
165
|
+
CDP_API_KEY_ID=your_actual_key_id_here
|
166
|
+
CDP_API_KEY_SECRET=your_actual_key_secret_here
|
167
|
+
CDP_WALLET_SECRET=your_actual_wallet_secret_here
|
168
|
+
|
169
|
+
# Network configuration (optional)
|
170
|
+
# CDP_NETWORK_ID=base-sepolia # Use base-sepolia for testing, base-mainnet for production
|
171
|
+
`;
|
172
|
+
await fs.writeFile(envPath, envContent);
|
173
|
+
console.log(chalk_1.default.green(`🔐 Created environment template: ${envPath}`));
|
174
|
+
console.log(chalk_1.default.yellow('📝 Copy this to .env.local and add your actual CDP credentials'));
|
175
|
+
}
|
176
|
+
/**
|
177
|
+
* List available documentation
|
178
|
+
*/
|
179
|
+
async listDocs(projectRoot = process.cwd()) {
|
180
|
+
const docsPath = path.join(projectRoot, 'doc', 'cdp');
|
181
|
+
if (!await fs.pathExists(docsPath)) {
|
182
|
+
console.log(chalk_1.default.yellow('📚 CDP documentation not found.'));
|
183
|
+
console.log(chalk_1.default.cyan('Run: npx cdp-docs setup'));
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
console.log(chalk_1.default.blue('📚 Available CDP Documentation:'));
|
187
|
+
console.log('');
|
188
|
+
const walletPath = path.join(docsPath, 'wallet');
|
189
|
+
const integrationPath = path.join(docsPath, 'integration');
|
190
|
+
if (await fs.pathExists(walletPath)) {
|
191
|
+
console.log(chalk_1.default.green('🔗 Wallet API Documentation:'));
|
192
|
+
const walletFiles = await fs.readdir(walletPath);
|
193
|
+
walletFiles.forEach((file) => {
|
194
|
+
if (file.endsWith('.md')) {
|
195
|
+
console.log(chalk_1.default.white(` - ${file}`));
|
196
|
+
}
|
197
|
+
});
|
198
|
+
console.log('');
|
199
|
+
}
|
200
|
+
if (await fs.pathExists(integrationPath)) {
|
201
|
+
console.log(chalk_1.default.green('⚙️ Integration Guides:'));
|
202
|
+
const integrationFiles = await fs.readdir(integrationPath);
|
203
|
+
integrationFiles.forEach((file) => {
|
204
|
+
if (file.endsWith('.md')) {
|
205
|
+
console.log(chalk_1.default.white(` - ${file}`));
|
206
|
+
}
|
207
|
+
});
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
exports.CdpDocsCli = CdpDocsCli;
|
212
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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AAC,EAAE,CAAC;oBACzB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;YACzC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;YACpD,MAAM,gBAAgB,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YAC3D,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,EAAE;gBACxC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAjMD,gCAiMC"}
|
package/package.json
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"name": "cdp-docs-cli",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "CLI tool to set up CDP (Coinbase Developer Platform) documentation and integration in your project",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"types": "dist/index.d.ts",
|
7
|
+
"bin": {
|
8
|
+
"cdp-docs": "./bin/cdp-docs.js",
|
9
|
+
"cdp-setup": "./bin/cdp-setup.js"
|
10
|
+
},
|
11
|
+
"scripts": {
|
12
|
+
"build": "tsc",
|
13
|
+
"prepublishOnly": "npm run build",
|
14
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
15
|
+
},
|
16
|
+
"keywords": [
|
17
|
+
"cdp",
|
18
|
+
"coinbase",
|
19
|
+
"developer-platform",
|
20
|
+
"wallet",
|
21
|
+
"blockchain",
|
22
|
+
"documentation",
|
23
|
+
"cli",
|
24
|
+
"base",
|
25
|
+
"ethereum",
|
26
|
+
"solana"
|
27
|
+
],
|
28
|
+
"author": "mustbeash",
|
29
|
+
"license": "MIT",
|
30
|
+
"repository": {
|
31
|
+
"type": "git",
|
32
|
+
"url": "https://github.com/must-be-ash/cdp-docs-cli.git"
|
33
|
+
},
|
34
|
+
"homepage": "https://github.com/must-be-ash/cdp-docs-cli#readme",
|
35
|
+
"bugs": {
|
36
|
+
"url": "https://github.com/must-be-ash/cdp-docs-cli/issues"
|
37
|
+
},
|
38
|
+
"files": [
|
39
|
+
"dist/",
|
40
|
+
"bin/",
|
41
|
+
"src/templates/",
|
42
|
+
"README.md"
|
43
|
+
],
|
44
|
+
"dependencies": {
|
45
|
+
"fs-extra": "^11.2.0",
|
46
|
+
"commander": "^11.1.0",
|
47
|
+
"chalk": "^4.1.2",
|
48
|
+
"inquirer": "^8.2.6"
|
49
|
+
},
|
50
|
+
"devDependencies": {
|
51
|
+
"@types/node": "^20.10.0",
|
52
|
+
"@types/fs-extra": "^11.0.4",
|
53
|
+
"@types/inquirer": "^8.2.10",
|
54
|
+
"typescript": "^5.3.0"
|
55
|
+
},
|
56
|
+
"engines": {
|
57
|
+
"node": ">=16.0.0"
|
58
|
+
}
|
59
|
+
}
|
File without changes
|