moralis-cli 0.1.0 → 0.1.2
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 +12 -4
- package/package.json +1 -1
- package/src/cli.js +22 -0
package/README.md
CHANGED
|
@@ -6,12 +6,10 @@ Use the Moralis API via Moralis CLI directly inside your AI agent 🤖 while kee
|
|
|
6
6
|
|
|
7
7
|
Follow these steps to start using Moralis CLI with your AI agent.
|
|
8
8
|
|
|
9
|
-
## Getting Started
|
|
10
|
-
|
|
11
9
|
Install:
|
|
12
10
|
|
|
13
11
|
```bash
|
|
14
|
-
|
|
12
|
+
npm install -g moralis-cli
|
|
15
13
|
```
|
|
16
14
|
|
|
17
15
|
Login:
|
|
@@ -22,10 +20,20 @@ moralis-cli login
|
|
|
22
20
|
|
|
23
21
|
Enter your Moralis API key when prompted (stored securely).
|
|
24
22
|
|
|
23
|
+
Check login status:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
moralis-cli status
|
|
27
|
+
```
|
|
28
|
+
|
|
25
29
|
Connect to AI
|
|
26
30
|
|
|
27
31
|
Import the [@moralis-cli](.codex/skills/moralis-cli/SKILL.md) skill into your AI agent and start making Moralis API calls securely.
|
|
28
32
|
|
|
33
|
+
```
|
|
34
|
+
› Please install this skill: https://raw.githubusercontent.com/MoralisWeb3/moralis-cli/refs/heads/main/.codex/skills/moralis-cli/SKILL.md
|
|
35
|
+
```
|
|
36
|
+
|
|
29
37
|
## Examples
|
|
30
38
|
|
|
31
39
|
Codex:
|
|
@@ -51,4 +59,4 @@ Codex:
|
|
|
51
59
|
|
|
52
60
|
# License
|
|
53
61
|
|
|
54
|
-
MIT
|
|
62
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moralis-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Use Moralis API via Moralis CLI directly inside AI agents with secure API key handling and access to EVM and Solana blockchain data.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"moralis-cli": "bin/moralis-cli.js"
|
package/src/cli.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const fsp = require('node:fs/promises');
|
|
4
4
|
const os = require('node:os');
|
|
5
5
|
const path = require('node:path');
|
|
6
|
+
const { version: CLI_VERSION } = require('../package.json');
|
|
6
7
|
|
|
7
8
|
const CONFIG_DIR = process.env.MORALIS_CLI_CONFIG_DIR || path.join(os.homedir(), '.moralis-cli');
|
|
8
9
|
const CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');
|
|
@@ -42,6 +43,11 @@ async function main() {
|
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
if (command === 'status') {
|
|
47
|
+
await showLoginStatus();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
const apiTarget = getApiTarget(command);
|
|
46
52
|
if (apiTarget) {
|
|
47
53
|
await handleApiCommand(apiTarget, args.slice(1));
|
|
@@ -138,12 +144,14 @@ async function printGlobalHelp(args = []) {
|
|
|
138
144
|
console.log(' moralis-cli help <evm|solana>');
|
|
139
145
|
console.log(' moralis-cli login <api_key>');
|
|
140
146
|
console.log(' moralis-cli login');
|
|
147
|
+
console.log(' moralis-cli status');
|
|
141
148
|
console.log(' moralis-cli evm <operationId> [required-path-args...] [--optional value]');
|
|
142
149
|
console.log(' moralis-cli solana <operationId> [required-path-args...] [--optional value]');
|
|
143
150
|
console.log('');
|
|
144
151
|
console.log('Built-in commands:');
|
|
145
152
|
console.log(' help - Show this help message');
|
|
146
153
|
console.log(' login - Save Moralis API key (prompts if omitted)');
|
|
154
|
+
console.log(' status - Show whether a Moralis API key is saved');
|
|
147
155
|
console.log(' evm - Run EVM API operations');
|
|
148
156
|
console.log(' solana - Run Solana API operations');
|
|
149
157
|
console.log('');
|
|
@@ -214,6 +222,18 @@ async function login(args) {
|
|
|
214
222
|
console.log('API key saved.');
|
|
215
223
|
}
|
|
216
224
|
|
|
225
|
+
async function showLoginStatus() {
|
|
226
|
+
const config = await readConfig();
|
|
227
|
+
const hasApiKey = typeof config.apiKey === 'string' && config.apiKey.trim().length > 0;
|
|
228
|
+
|
|
229
|
+
if (hasApiKey) {
|
|
230
|
+
console.log('Logged in: yes');
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
console.log('Logged in: no');
|
|
235
|
+
}
|
|
236
|
+
|
|
217
237
|
function promptHidden(promptText) {
|
|
218
238
|
return new Promise((resolve, reject) => {
|
|
219
239
|
const stdin = process.stdin;
|
|
@@ -417,6 +437,8 @@ function buildHttpRequest(apiTarget, spec, operation, params, parsedArgs, config
|
|
|
417
437
|
}
|
|
418
438
|
|
|
419
439
|
applyApiKeyAuth(spec, operation, config, headers, url);
|
|
440
|
+
headers.set('x-moralis-product', 'moralis-cli');
|
|
441
|
+
headers.set('x-moralis-cli-version', CLI_VERSION);
|
|
420
442
|
|
|
421
443
|
let requestBody = undefined;
|
|
422
444
|
if (bodyParamSeen && body !== undefined) {
|