@myapihq/cli 1.0.58 → 1.0.60

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.
@@ -139,7 +139,7 @@ export async function whoami(flags = {}) {
139
139
  info(`Org: ${config.default_org ?? '(none)'}`);
140
140
  info(`Funnel: ${config.default_funnel ?? '(none)'}`);
141
141
  info(`Type: ${config.is_anonymous ? 'anonymous' : 'registered'}`);
142
- info(`Balance: ${balance ? `${balance.balance_display} | Credits: ${balance.credits_display}` : '(unavailable)'}`);
142
+ info(`Balance: ${balance ? `${balance.balance_display} | Credits: ${balance.credits_display} (not usable for domains)` : '(unavailable)'}`);
143
143
  }
144
144
  // myapi auth switch [index] — switch between saved accounts.
145
145
  export async function switchCmd(flags = {}, indexArg) {
@@ -21,7 +21,7 @@ export async function balance(flags) {
21
21
  const pm = result.has_payment_method ? 'yes' : 'no';
22
22
  const accountType = config.is_anonymous ? 'anonymous' : `registered (${config.email ?? ''})`;
23
23
  info(`Account: ${accountType}`);
24
- info(`Balance: ${result.balance_display} | Credits: ${result.credits_display} | Payment method: ${pm}`);
24
+ info(`Balance: ${result.balance_display} | Credits: ${result.credits_display} (not usable for domains) | Payment method: ${pm}`);
25
25
  }
26
26
  export async function history(flags) {
27
27
  if (flags.help) {
@@ -48,7 +48,7 @@ export async function history(flags) {
48
48
  }
49
49
  export async function topup(amountStr, flags) {
50
50
  if (flags.help) {
51
- info('Usage: myapi billing topup <amount>\n\nAmount is in whole dollars (e.g. "10" charges $10).\nUse --yes to skip confirmation.\nExample: myapi billing topup 10\n\nFlags:\n --yes Skip confirmation prompt');
51
+ info('Usage: myapi billing topup <amount>\n\nAmount is in whole dollars (e.g. "10" charges $10).\nConfirmation is required for amounts of $50 or more. Use --yes to skip it.\nExample: myapi billing topup 10\n\nFlags:\n --yes Skip confirmation prompt for large amounts');
52
52
  return;
53
53
  }
54
54
  const amount = Math.round(parseFloat(amountStr));
@@ -30,7 +30,10 @@ export async function register(domainArg, flags) {
30
30
  error("Missing required arguments.\nUsage: myapi domain register <domain> --org <id> [--years <num>]\n(Set defaults: myapi auth config set-org <id> / myapi auth config set-domain <domain>)");
31
31
  const years = parseInt(flags.years) || 1;
32
32
  const res = await sdkDomain.registerDomain(config.api_key, orgId, domain, years);
33
- success(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
33
+ success(`Registered ${domain}!`);
34
+ info(`Assign it to your org now:\n myapi domain assign ${domain} --org ${orgId}`);
35
+ info(`DNS propagation can take a few minutes — track it with: myapi domain status ${domain}`);
36
+ info(`Your funnel will be live on https://${domain} once propagation completes.`);
34
37
  }
35
38
  export async function importDomain(domainArg, flags) {
36
39
  const config = requireConfig();
@@ -63,11 +66,10 @@ export async function assign(domainArg, flags) {
63
66
  const config = requireConfig();
64
67
  const orgId = flags.org || config.default_org;
65
68
  const domain = domainArg || config.default_domain;
66
- const targetOrgId = flags.target;
67
- if (!orgId || !domain || !targetOrgId)
68
- error("Missing required arguments.\nUsage: myapi domain assign <domain> --org <id> --target <target_org_id>\n(Set defaults: myapi auth config set-org <id> / myapi auth config set-domain <domain>)");
69
- await sdkDomain.assignDomain(config.api_key, orgId, domain, targetOrgId);
70
- success(`Assigned ${domain} to org ${targetOrgId}`);
69
+ if (!orgId || !domain)
70
+ error("Missing required arguments.\nUsage: myapi domain assign <domain> --org <id>\n(Set defaults: myapi auth config set-org <id> / myapi auth config set-domain <domain>)");
71
+ await sdkDomain.assignDomain(config.api_key, orgId, domain);
72
+ success(`Assigned ${domain} to org ${orgId}`);
71
73
  }
72
74
  export async function unassign(domainArg, flags) {
73
75
  const config = requireConfig();
@@ -121,7 +123,7 @@ export async function updateSettings(domainArg, flags) {
121
123
  }
122
124
  export async function run(subcommand, args, flags) {
123
125
  if (!subcommand || (flags.help && !subcommand)) {
124
- info('Usage: myapi domain <subcommand>\n\nSubcommands:\n list List domains\n check Check domain availability\n register Register a domain\n import Import an existing domain\n assign Assign domain to org\n unassign Unassign domain from its current org\n status Get domain status\n settings Get domain settings\n update-settings Update domain settings\n\nTip: Set defaults with "myapi auth config set-org <id>" to skip --org on every command.');
126
+ info('Usage: myapi domain <subcommand>\n\nSubcommands:\n list List domains\n check Check domain availability\n register Register a domain\n import Import an existing domain\n assign Assign domain to an org\n unassign Unassign domain from its current org\n status Get domain status\n settings Get domain settings\n update-settings Update domain settings\n\nTip: Set defaults with "myapi auth config set-org <id>" to skip --org on every command.');
125
127
  return;
126
128
  }
127
129
  if (flags.help) {
@@ -134,7 +136,7 @@ export async function run(subcommand, args, flags) {
134
136
  else if (subcommand === 'import')
135
137
  info('Usage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
136
138
  else if (subcommand === 'assign')
137
- info('Usage: myapi domain assign <domain> --org <id> --target <target_org_id>\n\nAssigns a domain to a different organization.');
139
+ info('Usage: myapi domain assign <domain> --org <id>\n\nAssigns a domain to the specified organization.');
138
140
  else if (subcommand === 'unassign')
139
141
  info('Usage: myapi domain unassign <domain> --org <id>\n\nUnassigns a domain from its current organization.');
140
142
  else if (subcommand === 'status')
@@ -1,5 +1,5 @@
1
1
  import { funnel as sdkFunnel, hq } from '@myapihq/sdk';
2
- import { requireConfig } from '../config.js';
2
+ import { requireConfig, saveConfig } from '../config.js';
3
3
  import { success, error, printTable, info, printJson } from '../output.js';
4
4
  import { formatDate } from '../utils.js';
5
5
  export async function list(flags) {
@@ -47,14 +47,21 @@ export async function del(id, flags) {
47
47
  export async function push(id, slug, flags) {
48
48
  const config = requireConfig();
49
49
  const orgId = flags.org || config.default_org;
50
- const funnelId = id || config.default_funnel;
50
+ if (!orgId)
51
+ error("Missing org. Set a default with: myapi auth config set-org <id>");
51
52
  if (slug && flags.slug && slug !== flags.slug) {
52
53
  info(`› Note: positional slug "${slug}" takes precedence over --slug "${flags.slug}".`);
53
54
  }
54
55
  const rawSlug = slug || flags.slug || '/';
55
56
  const finalSlug = rawSlug.startsWith('/') ? rawSlug : `/${rawSlug}`;
56
- if (!orgId || !funnelId) {
57
- error("Missing required arguments.\nUsage: myapi funnel push [funnel_id] [slug] < index.html\n(Defaults to your configured funnel and slug '/' when omitted)");
57
+ let funnelId = id || config.default_funnel;
58
+ if (!funnelId) {
59
+ const existing = await sdkFunnel.listFunnels(config.api_key, orgId);
60
+ if (existing.length === 0)
61
+ error("No funnel found for this org. Try: myapi auth config set-org <id>");
62
+ funnelId = existing[0].id;
63
+ config.default_funnel = funnelId;
64
+ saveConfig(config);
58
65
  }
59
66
  const html = await new Promise((resolve, reject) => {
60
67
  let data = '';
package/dist/index.js CHANGED
@@ -199,8 +199,7 @@ function printHelp() {
199
199
  const config = loadConfig();
200
200
  const quickStart = config?.api_key
201
201
  ? `Quick start:
202
- myapi funnel create
203
- echo '<h1>Hello!</h1>' | myapi funnel push <funnel_id> /`
202
+ echo '<h1>Hello!</h1>' | myapi funnel push /`
204
203
  : `Quick start:
205
204
  myapi auth setup --help`;
206
205
  info(`myapi - MyAPI command-line interface
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myapihq/cli",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "description": "MyAPI command-line interface",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -146,7 +146,7 @@ export async function whoami(flags: Record<string, string | boolean> = {}) {
146
146
  info(`Org: ${config!.default_org ?? '(none)'}`);
147
147
  info(`Funnel: ${config!.default_funnel ?? '(none)'}`);
148
148
  info(`Type: ${config!.is_anonymous ? 'anonymous' : 'registered'}`);
149
- info(`Balance: ${balance ? `${balance.balance_display} | Credits: ${balance.credits_display}` : '(unavailable)'}`);
149
+ info(`Balance: ${balance ? `${balance.balance_display} | Credits: ${balance.credits_display} (not usable for domains)` : '(unavailable)'}`);
150
150
  }
151
151
 
152
152
  // myapi auth switch [index] — switch between saved accounts.
@@ -24,7 +24,7 @@ export async function balance(flags: Record<string, string | boolean>) {
24
24
  const pm = result.has_payment_method ? 'yes' : 'no';
25
25
  const accountType = config.is_anonymous ? 'anonymous' : `registered (${config.email ?? ''})`;
26
26
  info(`Account: ${accountType}`);
27
- info(`Balance: ${result.balance_display} | Credits: ${result.credits_display} | Payment method: ${pm}`);
27
+ info(`Balance: ${result.balance_display} | Credits: ${result.credits_display} (not usable for domains) | Payment method: ${pm}`);
28
28
  }
29
29
 
30
30
  export async function history(flags: Record<string, string | boolean>) {
@@ -57,7 +57,7 @@ export async function history(flags: Record<string, string | boolean>) {
57
57
 
58
58
  export async function topup(amountStr: string, flags: Record<string, string | boolean>) {
59
59
  if (flags.help) {
60
- info('Usage: myapi billing topup <amount>\n\nAmount is in whole dollars (e.g. "10" charges $10).\nUse --yes to skip confirmation.\nExample: myapi billing topup 10\n\nFlags:\n --yes Skip confirmation prompt');
60
+ info('Usage: myapi billing topup <amount>\n\nAmount is in whole dollars (e.g. "10" charges $10).\nConfirmation is required for amounts of $50 or more. Use --yes to skip it.\nExample: myapi billing topup 10\n\nFlags:\n --yes Skip confirmation prompt for large amounts');
61
61
  return;
62
62
  }
63
63
  const amount = Math.round(parseFloat(amountStr));
@@ -29,7 +29,10 @@ export async function register(domainArg: string, flags: Record<string, string |
29
29
  if (!orgId || !domain) error("Missing required arguments.\nUsage: myapi domain register <domain> --org <id> [--years <num>]\n(Set defaults: myapi auth config set-org <id> / myapi auth config set-domain <domain>)");
30
30
  const years = parseInt(flags.years as string) || 1;
31
31
  const res = await sdkDomain.registerDomain(config.api_key, orgId, domain, years);
32
- success(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
32
+ success(`Registered ${domain}!`);
33
+ info(`Assign it to your org now:\n myapi domain assign ${domain} --org ${orgId}`);
34
+ info(`DNS propagation can take a few minutes — track it with: myapi domain status ${domain}`);
35
+ info(`Your funnel will be live on https://${domain} once propagation completes.`);
33
36
  }
34
37
 
35
38
  export async function importDomain(domainArg: string, flags: Record<string, string | boolean>) {
@@ -58,10 +61,9 @@ export async function assign(domainArg: string, flags: Record<string, string | b
58
61
  const config = requireConfig();
59
62
  const orgId = (flags.org as string) || config.default_org;
60
63
  const domain = domainArg || (config.default_domain as string);
61
- const targetOrgId = flags.target as string;
62
- if (!orgId || !domain || !targetOrgId) error("Missing required arguments.\nUsage: myapi domain assign <domain> --org <id> --target <target_org_id>\n(Set defaults: myapi auth config set-org <id> / myapi auth config set-domain <domain>)");
63
- await sdkDomain.assignDomain(config.api_key, orgId, domain, targetOrgId);
64
- success(`Assigned ${domain} to org ${targetOrgId}`);
64
+ if (!orgId || !domain) error("Missing required arguments.\nUsage: myapi domain assign <domain> --org <id>\n(Set defaults: myapi auth config set-org <id> / myapi auth config set-domain <domain>)");
65
+ await sdkDomain.assignDomain(config.api_key, orgId, domain);
66
+ success(`Assigned ${domain} to org ${orgId}`);
65
67
  }
66
68
 
67
69
  export async function unassign(domainArg: string, flags: Record<string, string | boolean>) {
@@ -113,7 +115,7 @@ export async function updateSettings(domainArg: string, flags: Record<string, st
113
115
 
114
116
  export async function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>) {
115
117
  if (!subcommand || (flags.help && !subcommand)) {
116
- info('Usage: myapi domain <subcommand>\n\nSubcommands:\n list List domains\n check Check domain availability\n register Register a domain\n import Import an existing domain\n assign Assign domain to org\n unassign Unassign domain from its current org\n status Get domain status\n settings Get domain settings\n update-settings Update domain settings\n\nTip: Set defaults with "myapi auth config set-org <id>" to skip --org on every command.');
118
+ info('Usage: myapi domain <subcommand>\n\nSubcommands:\n list List domains\n check Check domain availability\n register Register a domain\n import Import an existing domain\n assign Assign domain to an org\n unassign Unassign domain from its current org\n status Get domain status\n settings Get domain settings\n update-settings Update domain settings\n\nTip: Set defaults with "myapi auth config set-org <id>" to skip --org on every command.');
117
119
  return;
118
120
  }
119
121
 
@@ -122,7 +124,7 @@ export async function run(subcommand: string | undefined, args: string[], flags:
122
124
  else if (subcommand === 'check') info('Usage: myapi domain check <domain> --org <id> [--json]\n\nChecks if a domain name is available for registration.\n\nFlags:\n --json Output raw JSON');
123
125
  else if (subcommand === 'register') info('Usage: myapi domain register <domain> --org <id> [--years <num>]\n\nRegisters a new domain name.');
124
126
  else if (subcommand === 'import') info('Usage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
125
- else if (subcommand === 'assign') info('Usage: myapi domain assign <domain> --org <id> --target <target_org_id>\n\nAssigns a domain to a different organization.');
127
+ else if (subcommand === 'assign') info('Usage: myapi domain assign <domain> --org <id>\n\nAssigns a domain to the specified organization.');
126
128
  else if (subcommand === 'unassign') info('Usage: myapi domain unassign <domain> --org <id>\n\nUnassigns a domain from its current organization.');
127
129
  else if (subcommand === 'status') info('Usage: myapi domain status <domain> --org <id> [--json]\n\nGets the registration status of a domain.\n\nFlags:\n --json Output raw JSON');
128
130
  else if (subcommand === 'settings') info('Usage: myapi domain settings <domain> --org <id>\n\nGets the DNS settings and configuration for a domain.');
@@ -1,5 +1,5 @@
1
1
  import { funnel as sdkFunnel, hq } from '@myapihq/sdk';
2
- import { requireConfig } from '../config.js';
2
+ import { requireConfig, saveConfig } from '../config.js';
3
3
  import { success, error, printTable, info, printJson } from '../output.js';
4
4
  import { formatDate } from '../utils.js';
5
5
  import * as fs from 'fs';
@@ -47,15 +47,21 @@ export async function del(id: string, flags: Record<string, string | boolean>) {
47
47
  export async function push(id: string, slug: string, flags: Record<string, string | boolean>) {
48
48
  const config = requireConfig();
49
49
  const orgId = (flags.org as string) || config.default_org;
50
- const funnelId = id || config.default_funnel;
50
+ if (!orgId) error("Missing org. Set a default with: myapi auth config set-org <id>");
51
+
51
52
  if (slug && flags.slug && slug !== flags.slug) {
52
53
  info(`› Note: positional slug "${slug}" takes precedence over --slug "${flags.slug}".`);
53
54
  }
54
55
  const rawSlug = slug || (flags.slug as string) || '/';
55
56
  const finalSlug = rawSlug.startsWith('/') ? rawSlug : `/${rawSlug}`;
56
57
 
57
- if (!orgId || !funnelId) {
58
- error("Missing required arguments.\nUsage: myapi funnel push [funnel_id] [slug] < index.html\n(Defaults to your configured funnel and slug '/' when omitted)");
58
+ let funnelId = id || config.default_funnel;
59
+ if (!funnelId) {
60
+ const existing = await sdkFunnel.listFunnels(config.api_key, orgId);
61
+ if (existing.length === 0) error("No funnel found for this org. Try: myapi auth config set-org <id>");
62
+ funnelId = existing[0].id;
63
+ config.default_funnel = funnelId;
64
+ saveConfig(config);
59
65
  }
60
66
 
61
67
  const html = await new Promise<string>((resolve, reject) => {
package/src/index.ts CHANGED
@@ -170,8 +170,7 @@ function printHelp() {
170
170
  const config = loadConfig();
171
171
  const quickStart = config?.api_key
172
172
  ? `Quick start:
173
- myapi funnel create
174
- echo '<h1>Hello!</h1>' | myapi funnel push <funnel_id> /`
173
+ echo '<h1>Hello!</h1>' | myapi funnel push /`
175
174
  : `Quick start:
176
175
  myapi auth setup --help`;
177
176
  info(`myapi - MyAPI command-line interface