@myapihq/cli 1.0.9 → 1.0.10
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/domain.d.ts +5 -5
- package/dist/commands/domain.js +31 -28
- package/package.json +1 -1
- package/src/commands/domain.ts +26 -24
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function check(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
2
|
-
export declare function register(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
3
|
-
export declare function importDomain(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
4
|
-
export declare function list(flags: Record<string, string | boolean>): Promise<void>;
|
|
5
|
-
export declare function settings(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
1
|
+
export declare function check(orgId: string, domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
2
|
+
export declare function register(orgId: string, domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
3
|
+
export declare function importDomain(orgId: string, domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
4
|
+
export declare function list(orgId: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
5
|
+
export declare function settings(orgId: string, domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
6
6
|
export declare function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>): Promise<void>;
|
package/dist/commands/domain.js
CHANGED
|
@@ -9,11 +9,11 @@ exports.run = run;
|
|
|
9
9
|
const sdk_1 = require("@myapihq/sdk");
|
|
10
10
|
const config_js_1 = require("../config.js");
|
|
11
11
|
const output_js_1 = require("../output.js");
|
|
12
|
-
async function check(domain, flags) {
|
|
13
|
-
if (!domain)
|
|
14
|
-
(0, output_js_1.error)("Missing domain");
|
|
12
|
+
async function check(orgId, domain, flags) {
|
|
13
|
+
if (!orgId || !domain)
|
|
14
|
+
(0, output_js_1.error)("Missing org_id or domain");
|
|
15
15
|
const config = (0, config_js_1.requireConfig)();
|
|
16
|
-
const res = await sdk_1.domain.checkDomain(config.api_key, domain);
|
|
16
|
+
const res = await sdk_1.domain.checkDomain(config.api_key, orgId, domain);
|
|
17
17
|
if (res.available) {
|
|
18
18
|
(0, output_js_1.info)(`${domain} — Available ✓ Price: $${(res.price_cents / 100).toFixed(2)}/yr`);
|
|
19
19
|
}
|
|
@@ -21,38 +21,41 @@ async function check(domain, flags) {
|
|
|
21
21
|
(0, output_js_1.info)(`Not available ✗`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
async function register(domain, flags) {
|
|
25
|
-
if (!domain)
|
|
26
|
-
(0, output_js_1.error)("Missing domain");
|
|
24
|
+
async function register(orgId, domain, flags) {
|
|
25
|
+
if (!orgId || !domain)
|
|
26
|
+
(0, output_js_1.error)("Missing org_id or domain");
|
|
27
27
|
const years = parseInt(flags.years) || 1;
|
|
28
28
|
const config = (0, config_js_1.requireConfig)();
|
|
29
|
-
const res = await sdk_1.domain.registerDomain(config.api_key, domain, years);
|
|
29
|
+
const res = await sdk_1.domain.registerDomain(config.api_key, orgId, domain, years);
|
|
30
30
|
(0, output_js_1.success)(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
|
|
31
31
|
}
|
|
32
|
-
async function importDomain(domain, flags) {
|
|
33
|
-
if (!domain)
|
|
34
|
-
(0, output_js_1.error)("Missing domain");
|
|
32
|
+
async function importDomain(orgId, domain, flags) {
|
|
33
|
+
if (!orgId || !domain)
|
|
34
|
+
(0, output_js_1.error)("Missing org_id or domain");
|
|
35
35
|
if (!flags['namecheap-user'] || !flags['namecheap-key']) {
|
|
36
36
|
(0, output_js_1.error)("Missing --namecheap-user or --namecheap-key flags");
|
|
37
37
|
}
|
|
38
38
|
const config = (0, config_js_1.requireConfig)();
|
|
39
|
-
await sdk_1.domain.importDomain(config.api_key, {
|
|
39
|
+
await sdk_1.domain.importDomain(config.api_key, orgId, {
|
|
40
40
|
domain,
|
|
41
41
|
namecheap_api_user: flags['namecheap-user'],
|
|
42
42
|
namecheap_api_key: flags['namecheap-key']
|
|
43
43
|
});
|
|
44
44
|
(0, output_js_1.success)(`Imported ${domain}`);
|
|
45
45
|
}
|
|
46
|
-
async function list(flags) {
|
|
46
|
+
async function list(orgId, flags) {
|
|
47
|
+
if (!orgId)
|
|
48
|
+
(0, output_js_1.error)("Missing org_id");
|
|
47
49
|
const config = (0, config_js_1.requireConfig)();
|
|
48
|
-
const
|
|
50
|
+
const filter = flags.filter;
|
|
51
|
+
const domains = await sdk_1.domain.listDomains(config.api_key, orgId, filter);
|
|
49
52
|
(0, output_js_1.printTable)(domains);
|
|
50
53
|
}
|
|
51
|
-
async function settings(domain, flags) {
|
|
52
|
-
if (!domain)
|
|
53
|
-
(0, output_js_1.error)("Missing domain");
|
|
54
|
+
async function settings(orgId, domain, flags) {
|
|
55
|
+
if (!orgId || !domain)
|
|
56
|
+
(0, output_js_1.error)("Missing org_id or domain");
|
|
54
57
|
const config = (0, config_js_1.requireConfig)();
|
|
55
|
-
const res = await sdk_1.domain.getDomainSettings(config.api_key, domain);
|
|
58
|
+
const res = await sdk_1.domain.getDomainSettings(config.api_key, orgId, domain);
|
|
56
59
|
(0, output_js_1.printJson)(res);
|
|
57
60
|
}
|
|
58
61
|
async function run(subcommand, args, flags) {
|
|
@@ -62,27 +65,27 @@ async function run(subcommand, args, flags) {
|
|
|
62
65
|
}
|
|
63
66
|
if (flags.help) {
|
|
64
67
|
if (subcommand === 'list')
|
|
65
|
-
(0, output_js_1.info)('Usage: myapi domain list\n\nLists all registered domains in your account.');
|
|
68
|
+
(0, output_js_1.info)('Usage: myapi domain list <org_id> [--filter=all|unassigned|org]\n\nLists all registered domains in your account.\n --filter=all Lists all domains owned by the account.\n --filter=unassigned Lists domains not assigned to an org.\n --filter=org (Default) Lists domains assigned to the current org.');
|
|
66
69
|
else if (subcommand === 'check')
|
|
67
|
-
(0, output_js_1.info)('Usage: myapi domain check <domain>\n\nChecks if a domain name is available for registration.');
|
|
70
|
+
(0, output_js_1.info)('Usage: myapi domain check <org_id> <domain>\n\nChecks if a domain name is available for registration.');
|
|
68
71
|
else if (subcommand === 'register')
|
|
69
|
-
(0, output_js_1.info)('Usage: myapi domain register <domain> [--years <num>]\n\nRegisters a new domain name.');
|
|
72
|
+
(0, output_js_1.info)('Usage: myapi domain register <org_id> <domain> [--years <num>]\n\nRegisters a new domain name.');
|
|
70
73
|
else if (subcommand === 'import')
|
|
71
|
-
(0, output_js_1.info)('Usage: myapi domain import <domain> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
|
|
74
|
+
(0, output_js_1.info)('Usage: myapi domain import <org_id> <domain> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
|
|
72
75
|
else if (subcommand === 'settings')
|
|
73
|
-
(0, output_js_1.info)('Usage: myapi domain settings <domain>\n\nGets the DNS settings and configuration for a domain.');
|
|
76
|
+
(0, output_js_1.info)('Usage: myapi domain settings <org_id> <domain>\n\nGets the DNS settings and configuration for a domain.');
|
|
74
77
|
return;
|
|
75
78
|
}
|
|
76
79
|
if (subcommand === 'list')
|
|
77
|
-
await list(flags);
|
|
80
|
+
await list(args[0], flags);
|
|
78
81
|
else if (subcommand === 'check')
|
|
79
|
-
await check(args[0], flags);
|
|
82
|
+
await check(args[0], args[1], flags);
|
|
80
83
|
else if (subcommand === 'register')
|
|
81
|
-
await register(args[0], flags);
|
|
84
|
+
await register(args[0], args[1], flags);
|
|
82
85
|
else if (subcommand === 'import')
|
|
83
|
-
await importDomain(args[0], flags);
|
|
86
|
+
await importDomain(args[0], args[1], flags);
|
|
84
87
|
else if (subcommand === 'settings')
|
|
85
|
-
await settings(args[0], flags);
|
|
88
|
+
await settings(args[0], args[1], flags);
|
|
86
89
|
else
|
|
87
90
|
(0, output_js_1.error)(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
|
|
88
91
|
}
|
package/package.json
CHANGED
package/src/commands/domain.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { domain as sdkDomain } from '@myapihq/sdk';
|
|
|
2
2
|
import { requireConfig } from '../config.js';
|
|
3
3
|
import { success, error, info, printTable, printJson } from '../output.js';
|
|
4
4
|
|
|
5
|
-
export async function check(domain: string, flags: Record<string, string | boolean>) {
|
|
6
|
-
if (!domain) error("Missing domain");
|
|
5
|
+
export async function check(orgId: string, domain: string, flags: Record<string, string | boolean>) {
|
|
6
|
+
if (!orgId || !domain) error("Missing org_id or domain");
|
|
7
7
|
const config = requireConfig();
|
|
8
|
-
const res = await sdkDomain.checkDomain(config.api_key, domain);
|
|
8
|
+
const res = await sdkDomain.checkDomain(config.api_key, orgId, domain);
|
|
9
9
|
if (res.available) {
|
|
10
10
|
info(`${domain} — Available ✓ Price: $${(res.price_cents / 100).toFixed(2)}/yr`);
|
|
11
11
|
} else {
|
|
@@ -13,21 +13,21 @@ export async function check(domain: string, flags: Record<string, string | boole
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export async function register(domain: string, flags: Record<string, string | boolean>) {
|
|
17
|
-
if (!domain) error("Missing domain");
|
|
16
|
+
export async function register(orgId: string, domain: string, flags: Record<string, string | boolean>) {
|
|
17
|
+
if (!orgId || !domain) error("Missing org_id or domain");
|
|
18
18
|
const years = parseInt(flags.years as string) || 1;
|
|
19
19
|
const config = requireConfig();
|
|
20
|
-
const res = await sdkDomain.registerDomain(config.api_key, domain, years);
|
|
20
|
+
const res = await sdkDomain.registerDomain(config.api_key, orgId, domain, years);
|
|
21
21
|
success(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export async function importDomain(domain: string, flags: Record<string, string | boolean>) {
|
|
25
|
-
if (!domain) error("Missing domain");
|
|
24
|
+
export async function importDomain(orgId: string, domain: string, flags: Record<string, string | boolean>) {
|
|
25
|
+
if (!orgId || !domain) error("Missing org_id or domain");
|
|
26
26
|
if (!flags['namecheap-user'] || !flags['namecheap-key']) {
|
|
27
27
|
error("Missing --namecheap-user or --namecheap-key flags");
|
|
28
28
|
}
|
|
29
29
|
const config = requireConfig();
|
|
30
|
-
await sdkDomain.importDomain(config.api_key, {
|
|
30
|
+
await sdkDomain.importDomain(config.api_key, orgId, {
|
|
31
31
|
domain,
|
|
32
32
|
namecheap_api_user: flags['namecheap-user'] as string,
|
|
33
33
|
namecheap_api_key: flags['namecheap-key'] as string
|
|
@@ -35,16 +35,18 @@ export async function importDomain(domain: string, flags: Record<string, string
|
|
|
35
35
|
success(`Imported ${domain}`);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export async function list(flags: Record<string, string | boolean>) {
|
|
38
|
+
export async function list(orgId: string, flags: Record<string, string | boolean>) {
|
|
39
|
+
if (!orgId) error("Missing org_id");
|
|
39
40
|
const config = requireConfig();
|
|
40
|
-
const
|
|
41
|
+
const filter = flags.filter as 'all' | 'unassigned' | 'org' | undefined;
|
|
42
|
+
const domains = await sdkDomain.listDomains(config.api_key, orgId, filter);
|
|
41
43
|
printTable(domains as unknown as Record<string, unknown>[]);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
export async function settings(domain: string, flags: Record<string, string | boolean>) {
|
|
45
|
-
if (!domain) error("Missing domain");
|
|
46
|
+
export async function settings(orgId: string, domain: string, flags: Record<string, string | boolean>) {
|
|
47
|
+
if (!orgId || !domain) error("Missing org_id or domain");
|
|
46
48
|
const config = requireConfig();
|
|
47
|
-
const res = await sdkDomain.getDomainSettings(config.api_key, domain);
|
|
49
|
+
const res = await sdkDomain.getDomainSettings(config.api_key, orgId, domain);
|
|
48
50
|
printJson(res);
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -55,18 +57,18 @@ export async function run(subcommand: string | undefined, args: string[], flags:
|
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
if (flags.help) {
|
|
58
|
-
if (subcommand === 'list') info('Usage: myapi domain list\n\nLists all registered domains in your account.');
|
|
59
|
-
else if (subcommand === 'check') info('Usage: myapi domain check <domain>\n\nChecks if a domain name is available for registration.');
|
|
60
|
-
else if (subcommand === 'register') info('Usage: myapi domain register <domain> [--years <num>]\n\nRegisters a new domain name.');
|
|
61
|
-
else if (subcommand === 'import') info('Usage: myapi domain import <domain> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
|
|
62
|
-
else if (subcommand === 'settings') info('Usage: myapi domain settings <domain>\n\nGets the DNS settings and configuration for a domain.');
|
|
60
|
+
if (subcommand === 'list') info('Usage: myapi domain list <org_id> [--filter=all|unassigned|org]\n\nLists all registered domains in your account.\n --filter=all Lists all domains owned by the account.\n --filter=unassigned Lists domains not assigned to an org.\n --filter=org (Default) Lists domains assigned to the current org.');
|
|
61
|
+
else if (subcommand === 'check') info('Usage: myapi domain check <org_id> <domain>\n\nChecks if a domain name is available for registration.');
|
|
62
|
+
else if (subcommand === 'register') info('Usage: myapi domain register <org_id> <domain> [--years <num>]\n\nRegisters a new domain name.');
|
|
63
|
+
else if (subcommand === 'import') info('Usage: myapi domain import <org_id> <domain> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
|
|
64
|
+
else if (subcommand === 'settings') info('Usage: myapi domain settings <org_id> <domain>\n\nGets the DNS settings and configuration for a domain.');
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
if (subcommand === 'list') await list(flags);
|
|
67
|
-
else if (subcommand === 'check') await check(args[0], flags);
|
|
68
|
-
else if (subcommand === 'register') await register(args[0], flags);
|
|
69
|
-
else if (subcommand === 'import') await importDomain(args[0], flags);
|
|
70
|
-
else if (subcommand === 'settings') await settings(args[0], flags);
|
|
68
|
+
if (subcommand === 'list') await list(args[0], flags);
|
|
69
|
+
else if (subcommand === 'check') await check(args[0], args[1], flags);
|
|
70
|
+
else if (subcommand === 'register') await register(args[0], args[1], flags);
|
|
71
|
+
else if (subcommand === 'import') await importDomain(args[0], args[1], flags);
|
|
72
|
+
else if (subcommand === 'settings') await settings(args[0], args[1], flags);
|
|
71
73
|
else error(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
|
|
72
74
|
}
|