@myapihq/cli 1.0.8 → 1.0.9

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.
@@ -3,3 +3,4 @@ export declare function register(domain: string, flags: Record<string, string |
3
3
  export declare function importDomain(domain: string, flags: Record<string, string | boolean>): Promise<void>;
4
4
  export declare function list(flags: Record<string, string | boolean>): Promise<void>;
5
5
  export declare function settings(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>;
@@ -5,6 +5,7 @@ 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");
@@ -54,3 +55,34 @@ async function settings(domain, flags) {
54
55
  const res = await sdk_1.domain.getDomainSettings(config.api_key, domain);
55
56
  (0, output_js_1.printJson)(res);
56
57
  }
58
+ async function run(subcommand, args, flags) {
59
+ if (!subcommand || (flags.help && !subcommand)) {
60
+ (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');
61
+ return;
62
+ }
63
+ if (flags.help) {
64
+ if (subcommand === 'list')
65
+ (0, output_js_1.info)('Usage: myapi domain list\n\nLists all registered domains in your account.');
66
+ 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.');
68
+ else if (subcommand === 'register')
69
+ (0, output_js_1.info)('Usage: myapi domain register <domain> [--years <num>]\n\nRegisters a new domain name.');
70
+ 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.');
72
+ 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.');
74
+ return;
75
+ }
76
+ if (subcommand === 'list')
77
+ await list(flags);
78
+ else if (subcommand === 'check')
79
+ await check(args[0], flags);
80
+ else if (subcommand === 'register')
81
+ await register(args[0], flags);
82
+ else if (subcommand === 'import')
83
+ await importDomain(args[0], flags);
84
+ else if (subcommand === 'settings')
85
+ await settings(args[0], flags);
86
+ else
87
+ (0, output_js_1.error)(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
88
+ }
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myapihq/cli",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "MyAPI command-line interface",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -47,3 +47,26 @@ export async function settings(domain: string, flags: Record<string, string | bo
47
47
  const res = await sdkDomain.getDomainSettings(config.api_key, domain);
48
48
  printJson(res);
49
49
  }
50
+
51
+ export async function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>) {
52
+ if (!subcommand || (flags.help && !subcommand)) {
53
+ 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');
54
+ return;
55
+ }
56
+
57
+ 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.');
63
+ return;
64
+ }
65
+
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);
71
+ else error(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
72
+ }
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
  }