@myapihq/cli 1.0.0 → 1.0.1
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/dist/commands/account.js +12 -0
- package/package.json +1 -1
- package/src/commands/account.ts +16 -1
package/dist/commands/account.js
CHANGED
|
@@ -42,6 +42,18 @@ const config_js_1 = require("../config.js");
|
|
|
42
42
|
const output_js_1 = require("../output.js");
|
|
43
43
|
const readline = __importStar(require("readline"));
|
|
44
44
|
async function create() {
|
|
45
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
46
|
+
const ask = (q) => new Promise(resolve => rl.question(q, resolve));
|
|
47
|
+
const choice = await ask('Do you want to (1) auto-create a new account or (2) paste an existing API key? [1/2]: ');
|
|
48
|
+
rl.close();
|
|
49
|
+
if (choice.trim() === '2') {
|
|
50
|
+
const rl2 = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
51
|
+
const key = await new Promise(resolve => rl2.question('Paste your API key: ', resolve));
|
|
52
|
+
rl2.close();
|
|
53
|
+
(0, config_js_1.saveConfig)({ api_key: key.trim(), account_id: '', pin: '' });
|
|
54
|
+
(0, output_js_1.success)(`API key saved to ~/.myapi/config.json`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
45
57
|
const agent = await sdk_1.hq.createAgentAccount();
|
|
46
58
|
const keyInfo = await sdk_1.hq.createApiKey(agent.token, 'default');
|
|
47
59
|
(0, config_js_1.saveConfig)({
|
package/package.json
CHANGED
package/src/commands/account.ts
CHANGED
|
@@ -4,9 +4,24 @@ import { success, error, printTable } from '../output.js';
|
|
|
4
4
|
import * as readline from 'readline';
|
|
5
5
|
|
|
6
6
|
export async function create() {
|
|
7
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
8
|
+
const ask = (q: string) => new Promise<string>(resolve => rl.question(q, resolve));
|
|
9
|
+
|
|
10
|
+
const choice = await ask('Do you want to (1) auto-create a new account or (2) paste an existing API key? [1/2]: ');
|
|
11
|
+
rl.close();
|
|
12
|
+
|
|
13
|
+
if (choice.trim() === '2') {
|
|
14
|
+
const rl2 = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
15
|
+
const key = await new Promise<string>(resolve => rl2.question('Paste your API key: ', resolve));
|
|
16
|
+
rl2.close();
|
|
17
|
+
saveConfig({ api_key: key.trim(), account_id: '', pin: '' });
|
|
18
|
+
success(`API key saved to ~/.myapi/config.json`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
const agent = await hq.createAgentAccount();
|
|
8
23
|
const keyInfo = await hq.createApiKey(agent.token, 'default');
|
|
9
|
-
|
|
24
|
+
|
|
10
25
|
saveConfig({
|
|
11
26
|
api_key: keyInfo.api_key,
|
|
12
27
|
account_id: agent.account_id,
|