@myapihq/cli 1.0.39 → 1.0.40
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/index.js +10 -26
- package/package.json +1 -1
- package/src/index.ts +10 -22
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
2
|
+
// manually maintained — do not regenerate from scripts/generate-indexes.js
|
|
3
3
|
import { parseArgs } from './utils.js';
|
|
4
4
|
import { error, info, success } from './output.js';
|
|
5
5
|
import { loadConfig } from './config.js';
|
|
@@ -17,16 +17,15 @@ import * as funnelCmd from './commands/funnel.js';
|
|
|
17
17
|
import * as authCmd from './commands/auth.js';
|
|
18
18
|
import * as configCmd from './commands/config.js';
|
|
19
19
|
async function main() {
|
|
20
|
-
|
|
21
|
-
updateCmd.checkForUpdate(pkg.version).catch(() => { });
|
|
20
|
+
const updatePromise = updateCmd.checkForUpdate(pkg.version).catch(() => { });
|
|
22
21
|
const { args, flags } = parseArgs(process.argv.slice(2));
|
|
23
22
|
if (flags.version || flags.v) {
|
|
24
|
-
const latest = await updateCmd.latestVersion();
|
|
23
|
+
const [latest] = await Promise.all([updateCmd.latestVersion(), updatePromise]);
|
|
25
24
|
const updateNote = latest && updateCmd.isNewer(latest, pkg.version)
|
|
26
25
|
? ` (update available: ${latest})`
|
|
27
26
|
: '';
|
|
28
27
|
info(`myapi ${pkg.version}${updateNote}`);
|
|
29
|
-
|
|
28
|
+
return;
|
|
30
29
|
}
|
|
31
30
|
if (args.length === 0) {
|
|
32
31
|
const config = loadConfig();
|
|
@@ -35,7 +34,8 @@ async function main() {
|
|
|
35
34
|
info('');
|
|
36
35
|
}
|
|
37
36
|
printHelp();
|
|
38
|
-
|
|
37
|
+
await updatePromise;
|
|
38
|
+
return;
|
|
39
39
|
}
|
|
40
40
|
const [command, subcommand, ...restArgs] = args;
|
|
41
41
|
try {
|
|
@@ -77,20 +77,6 @@ async function main() {
|
|
|
77
77
|
case 'update':
|
|
78
78
|
await updateCmd.update();
|
|
79
79
|
break;
|
|
80
|
-
case 'keys':
|
|
81
|
-
if (!subcommand || (flags.help && !subcommand)) {
|
|
82
|
-
info('Usage: myapi keys <subcommand>\n\nSubcommands:\n list List your API keys\n create Create a new API key\n revoke Revoke an API key (e.g. myapi keys revoke <id>)');
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
if (subcommand === 'create')
|
|
86
|
-
await keysCmd.createNew(flags);
|
|
87
|
-
else if (subcommand === 'list')
|
|
88
|
-
await keysCmd.list(flags);
|
|
89
|
-
else if (subcommand === 'revoke')
|
|
90
|
-
await keysCmd.revoke(restArgs[0], flags);
|
|
91
|
-
else
|
|
92
|
-
printHelp();
|
|
93
|
-
break;
|
|
94
80
|
case 'org':
|
|
95
81
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
96
82
|
info('Usage: myapi org <subcommand>\n\nSubcommands:\n list List organizations\n create Create an organization\n get Get details of an organization\n delete Delete an organization\n import Extract org from domain');
|
|
@@ -132,8 +118,7 @@ async function main() {
|
|
|
132
118
|
await funnelCmd.run(subcommand, restArgs, flags);
|
|
133
119
|
break;
|
|
134
120
|
default:
|
|
135
|
-
|
|
136
|
-
process.exit(0);
|
|
121
|
+
error(`Unknown command: ${command}. Run "myapi" for available commands.`);
|
|
137
122
|
}
|
|
138
123
|
}
|
|
139
124
|
catch (err) {
|
|
@@ -141,7 +126,7 @@ async function main() {
|
|
|
141
126
|
if (err.status === 402)
|
|
142
127
|
error('Insufficient balance. Run: myapi billing topup <amount>');
|
|
143
128
|
else if (err.status === 401)
|
|
144
|
-
error('Invalid API key. Run: myapi setup');
|
|
129
|
+
error('Invalid API key. Run: myapi auth setup');
|
|
145
130
|
}
|
|
146
131
|
error(err.message || (typeof err === 'object' ? JSON.stringify(err) : String(err)));
|
|
147
132
|
}
|
|
@@ -153,17 +138,16 @@ function printHelp() {
|
|
|
153
138
|
myapi funnel create
|
|
154
139
|
echo '<h1>Hello!</h1>' | myapi funnel push <funnel_id> /`
|
|
155
140
|
: `Quick start:
|
|
156
|
-
myapi setup`;
|
|
141
|
+
myapi auth setup`;
|
|
157
142
|
info(`myapi - MyAPI command-line interface
|
|
158
143
|
|
|
159
144
|
Usage: myapi <command> [subcommand] [args]
|
|
160
145
|
myapi --version
|
|
161
146
|
|
|
162
147
|
Commands:
|
|
163
|
-
|
|
148
|
+
auth Manage account · setup · whoami · signup
|
|
164
149
|
billing Check balance and manage billing
|
|
165
150
|
org Manage organizations
|
|
166
|
-
setup Configure account · whoami · signup · config · install-skills
|
|
167
151
|
update Update CLI and skills to the latest version
|
|
168
152
|
domain Manage domain configurations
|
|
169
153
|
funnel Manage headless funnels and pages
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
2
|
+
// manually maintained — do not regenerate from scripts/generate-indexes.js
|
|
3
3
|
import { parseArgs } from './utils.js';
|
|
4
4
|
import { error, info, success } from './output.js';
|
|
5
5
|
import { loadConfig } from './config.js';
|
|
@@ -19,18 +19,17 @@ import * as authCmd from './commands/auth.js';
|
|
|
19
19
|
import * as configCmd from './commands/config.js';
|
|
20
20
|
|
|
21
21
|
async function main() {
|
|
22
|
-
|
|
23
|
-
updateCmd.checkForUpdate(pkg.version).catch(() => {});
|
|
22
|
+
const updatePromise = updateCmd.checkForUpdate(pkg.version).catch(() => {});
|
|
24
23
|
|
|
25
24
|
const { args, flags } = parseArgs(process.argv.slice(2));
|
|
26
25
|
|
|
27
26
|
if (flags.version || flags.v) {
|
|
28
|
-
const latest = await updateCmd.latestVersion();
|
|
27
|
+
const [latest] = await Promise.all([updateCmd.latestVersion(), updatePromise]);
|
|
29
28
|
const updateNote = latest && updateCmd.isNewer(latest, pkg.version)
|
|
30
29
|
? ` (update available: ${latest})`
|
|
31
30
|
: '';
|
|
32
31
|
info(`myapi ${pkg.version}${updateNote}`);
|
|
33
|
-
|
|
32
|
+
return;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
if (args.length === 0) {
|
|
@@ -40,7 +39,8 @@ async function main() {
|
|
|
40
39
|
info('');
|
|
41
40
|
}
|
|
42
41
|
printHelp();
|
|
43
|
-
|
|
42
|
+
await updatePromise;
|
|
43
|
+
return;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const [command, subcommand, ...restArgs] = args;
|
|
@@ -69,16 +69,6 @@ async function main() {
|
|
|
69
69
|
case 'update':
|
|
70
70
|
await updateCmd.update();
|
|
71
71
|
break;
|
|
72
|
-
case 'keys':
|
|
73
|
-
if (!subcommand || (flags.help && !subcommand)) {
|
|
74
|
-
info('Usage: myapi keys <subcommand>\n\nSubcommands:\n list List your API keys\n create Create a new API key\n revoke Revoke an API key (e.g. myapi keys revoke <id>)');
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
if (subcommand === 'create') await keysCmd.createNew(flags);
|
|
78
|
-
else if (subcommand === 'list') await keysCmd.list(flags);
|
|
79
|
-
else if (subcommand === 'revoke') await keysCmd.revoke(restArgs[0], flags);
|
|
80
|
-
else printHelp();
|
|
81
|
-
break;
|
|
82
72
|
case 'org':
|
|
83
73
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
84
74
|
info('Usage: myapi org <subcommand>\n\nSubcommands:\n list List organizations\n create Create an organization\n get Get details of an organization\n delete Delete an organization\n import Extract org from domain');
|
|
@@ -109,13 +99,12 @@ async function main() {
|
|
|
109
99
|
await funnelCmd.run(subcommand, restArgs, flags);
|
|
110
100
|
break;
|
|
111
101
|
default:
|
|
112
|
-
|
|
113
|
-
process.exit(0);
|
|
102
|
+
error(`Unknown command: ${command}. Run "myapi" for available commands.`);
|
|
114
103
|
}
|
|
115
104
|
} catch (err: any) {
|
|
116
105
|
if (err instanceof MyApiError) {
|
|
117
106
|
if (err.status === 402) error('Insufficient balance. Run: myapi billing topup <amount>');
|
|
118
|
-
else if (err.status === 401) error('Invalid API key. Run: myapi setup');
|
|
107
|
+
else if (err.status === 401) error('Invalid API key. Run: myapi auth setup');
|
|
119
108
|
}
|
|
120
109
|
error(err.message || (typeof err === 'object' ? JSON.stringify(err) : String(err)));
|
|
121
110
|
}
|
|
@@ -128,17 +117,16 @@ function printHelp() {
|
|
|
128
117
|
myapi funnel create
|
|
129
118
|
echo '<h1>Hello!</h1>' | myapi funnel push <funnel_id> /`
|
|
130
119
|
: `Quick start:
|
|
131
|
-
myapi setup`;
|
|
120
|
+
myapi auth setup`;
|
|
132
121
|
info(`myapi - MyAPI command-line interface
|
|
133
122
|
|
|
134
123
|
Usage: myapi <command> [subcommand] [args]
|
|
135
124
|
myapi --version
|
|
136
125
|
|
|
137
126
|
Commands:
|
|
138
|
-
|
|
127
|
+
auth Manage account · setup · whoami · signup
|
|
139
128
|
billing Check balance and manage billing
|
|
140
129
|
org Manage organizations
|
|
141
|
-
setup Configure account · whoami · signup · config · install-skills
|
|
142
130
|
update Update CLI and skills to the latest version
|
|
143
131
|
domain Manage domain configurations
|
|
144
132
|
funnel Manage headless funnels and pages
|