@myapihq/cli 1.0.8 → 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 +6 -5
- package/dist/commands/domain.js +53 -18
- package/dist/index.js +5 -0
- package/package.json +1 -1
- package/src/commands/domain.ts +39 -14
- package/src/index.ts +5 -0
|
@@ -1,5 +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
|
+
export declare function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>): Promise<void>;
|
package/dist/commands/domain.js
CHANGED
|
@@ -5,14 +5,15 @@ exports.register = register;
|
|
|
5
5
|
exports.importDomain = importDomain;
|
|
6
6
|
exports.list = list;
|
|
7
7
|
exports.settings = settings;
|
|
8
|
+
exports.run = run;
|
|
8
9
|
const sdk_1 = require("@myapihq/sdk");
|
|
9
10
|
const config_js_1 = require("../config.js");
|
|
10
11
|
const output_js_1 = require("../output.js");
|
|
11
|
-
async function check(domain, flags) {
|
|
12
|
-
if (!domain)
|
|
13
|
-
(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");
|
|
14
15
|
const config = (0, config_js_1.requireConfig)();
|
|
15
|
-
const res = await sdk_1.domain.checkDomain(config.api_key, domain);
|
|
16
|
+
const res = await sdk_1.domain.checkDomain(config.api_key, orgId, domain);
|
|
16
17
|
if (res.available) {
|
|
17
18
|
(0, output_js_1.info)(`${domain} — Available ✓ Price: $${(res.price_cents / 100).toFixed(2)}/yr`);
|
|
18
19
|
}
|
|
@@ -20,37 +21,71 @@ async function check(domain, flags) {
|
|
|
20
21
|
(0, output_js_1.info)(`Not available ✗`);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
async function register(domain, flags) {
|
|
24
|
-
if (!domain)
|
|
25
|
-
(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");
|
|
26
27
|
const years = parseInt(flags.years) || 1;
|
|
27
28
|
const config = (0, config_js_1.requireConfig)();
|
|
28
|
-
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);
|
|
29
30
|
(0, output_js_1.success)(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
|
|
30
31
|
}
|
|
31
|
-
async function importDomain(domain, flags) {
|
|
32
|
-
if (!domain)
|
|
33
|
-
(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");
|
|
34
35
|
if (!flags['namecheap-user'] || !flags['namecheap-key']) {
|
|
35
36
|
(0, output_js_1.error)("Missing --namecheap-user or --namecheap-key flags");
|
|
36
37
|
}
|
|
37
38
|
const config = (0, config_js_1.requireConfig)();
|
|
38
|
-
await sdk_1.domain.importDomain(config.api_key, {
|
|
39
|
+
await sdk_1.domain.importDomain(config.api_key, orgId, {
|
|
39
40
|
domain,
|
|
40
41
|
namecheap_api_user: flags['namecheap-user'],
|
|
41
42
|
namecheap_api_key: flags['namecheap-key']
|
|
42
43
|
});
|
|
43
44
|
(0, output_js_1.success)(`Imported ${domain}`);
|
|
44
45
|
}
|
|
45
|
-
async function list(flags) {
|
|
46
|
+
async function list(orgId, flags) {
|
|
47
|
+
if (!orgId)
|
|
48
|
+
(0, output_js_1.error)("Missing org_id");
|
|
46
49
|
const config = (0, config_js_1.requireConfig)();
|
|
47
|
-
const
|
|
50
|
+
const filter = flags.filter;
|
|
51
|
+
const domains = await sdk_1.domain.listDomains(config.api_key, orgId, filter);
|
|
48
52
|
(0, output_js_1.printTable)(domains);
|
|
49
53
|
}
|
|
50
|
-
async function settings(domain, flags) {
|
|
51
|
-
if (!domain)
|
|
52
|
-
(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");
|
|
53
57
|
const config = (0, config_js_1.requireConfig)();
|
|
54
|
-
const res = await sdk_1.domain.getDomainSettings(config.api_key, domain);
|
|
58
|
+
const res = await sdk_1.domain.getDomainSettings(config.api_key, orgId, domain);
|
|
55
59
|
(0, output_js_1.printJson)(res);
|
|
56
60
|
}
|
|
61
|
+
async function run(subcommand, args, flags) {
|
|
62
|
+
if (!subcommand || (flags.help && !subcommand)) {
|
|
63
|
+
(0, output_js_1.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 settings Get domain settings');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (flags.help) {
|
|
67
|
+
if (subcommand === 'list')
|
|
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.');
|
|
69
|
+
else if (subcommand === 'check')
|
|
70
|
+
(0, output_js_1.info)('Usage: myapi domain check <org_id> <domain>\n\nChecks if a domain name is available for registration.');
|
|
71
|
+
else if (subcommand === 'register')
|
|
72
|
+
(0, output_js_1.info)('Usage: myapi domain register <org_id> <domain> [--years <num>]\n\nRegisters a new domain name.');
|
|
73
|
+
else if (subcommand === 'import')
|
|
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.');
|
|
75
|
+
else if (subcommand === 'settings')
|
|
76
|
+
(0, output_js_1.info)('Usage: myapi domain settings <org_id> <domain>\n\nGets the DNS settings and configuration for a domain.');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (subcommand === 'list')
|
|
80
|
+
await list(args[0], flags);
|
|
81
|
+
else if (subcommand === 'check')
|
|
82
|
+
await check(args[0], args[1], flags);
|
|
83
|
+
else if (subcommand === 'register')
|
|
84
|
+
await register(args[0], args[1], flags);
|
|
85
|
+
else if (subcommand === 'import')
|
|
86
|
+
await importDomain(args[0], args[1], flags);
|
|
87
|
+
else if (subcommand === 'settings')
|
|
88
|
+
await settings(args[0], args[1], flags);
|
|
89
|
+
else
|
|
90
|
+
(0, output_js_1.error)(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
|
|
91
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ const keysCmd = __importStar(require("./commands/keys.js"));
|
|
|
42
42
|
const billingCmd = __importStar(require("./commands/billing.js"));
|
|
43
43
|
const orgCmd = __importStar(require("./commands/org.js"));
|
|
44
44
|
const setupCmd = __importStar(require("./commands/setup.js"));
|
|
45
|
+
const domainCmd = __importStar(require("./commands/domain.js"));
|
|
45
46
|
async function main() {
|
|
46
47
|
const { args, flags } = (0, utils_js_1.parseArgs)(process.argv.slice(2));
|
|
47
48
|
if (args.length === 0) {
|
|
@@ -106,6 +107,9 @@ async function main() {
|
|
|
106
107
|
else
|
|
107
108
|
printHelp();
|
|
108
109
|
break;
|
|
110
|
+
case 'domain':
|
|
111
|
+
await domainCmd.run(subcommand, restArgs, flags);
|
|
112
|
+
break;
|
|
109
113
|
default:
|
|
110
114
|
printHelp();
|
|
111
115
|
process.exit(0);
|
|
@@ -131,6 +135,7 @@ Commands:
|
|
|
131
135
|
billing Check balance and manage billing
|
|
132
136
|
org Manage organizations
|
|
133
137
|
setup Setup CLI credentials and view integration instructions
|
|
138
|
+
domain Manage domain configurations
|
|
134
139
|
|
|
135
140
|
Run "myapi <command> --help" for subcommand help.`);
|
|
136
141
|
}
|
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,15 +35,40 @@ 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
|
}
|
|
52
|
+
|
|
53
|
+
export async function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>) {
|
|
54
|
+
if (!subcommand || (flags.help && !subcommand)) {
|
|
55
|
+
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 settings Get domain settings');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (flags.help) {
|
|
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.');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
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);
|
|
73
|
+
else error(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
|
|
74
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import * as keysCmd from './commands/keys.js';
|
|
|
7
7
|
import * as billingCmd from './commands/billing.js';
|
|
8
8
|
import * as orgCmd from './commands/org.js';
|
|
9
9
|
import * as setupCmd from './commands/setup.js';
|
|
10
|
+
import * as domainCmd from './commands/domain.js';
|
|
10
11
|
|
|
11
12
|
async function main() {
|
|
12
13
|
const { args, flags } = parseArgs(process.argv.slice(2));
|
|
@@ -54,6 +55,9 @@ async function main() {
|
|
|
54
55
|
else if (subcommand === 'setup') await billingCmd.setup(flags);
|
|
55
56
|
else printHelp();
|
|
56
57
|
break;
|
|
58
|
+
case 'domain':
|
|
59
|
+
await domainCmd.run(subcommand, restArgs, flags);
|
|
60
|
+
break;
|
|
57
61
|
default:
|
|
58
62
|
printHelp();
|
|
59
63
|
process.exit(0);
|
|
@@ -77,6 +81,7 @@ Commands:
|
|
|
77
81
|
billing Check balance and manage billing
|
|
78
82
|
org Manage organizations
|
|
79
83
|
setup Setup CLI credentials and view integration instructions
|
|
84
|
+
domain Manage domain configurations
|
|
80
85
|
|
|
81
86
|
Run "myapi <command> --help" for subcommand help.`);
|
|
82
87
|
}
|