@mailkite/cli 0.1.0 → 0.2.0

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.
Files changed (3) hide show
  1. package/README.md +7 -5
  2. package/cli.mjs +49 -1
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -18,11 +18,13 @@ npm i -g @mailkite/cli # or install the `mailkite` binary globally
18
18
 
19
19
  ```bash
20
20
  mailkite signup --email you@example.com --password •••••• # or: login
21
- mailkite domains add mail.yourapp.com # prints the DNS records
21
+ mailkite domains check myapp.ai # available? + price
22
+ mailkite domains register myapp.ai --first-name … --email … --country US # buy + auto-DNS
23
+ mailkite domains add mail.myapp.ai # or add a domain you already own
22
24
  # …add those records at your DNS provider…
23
25
  mailkite domains verify <domainId> # MX/SPF/DKIM/DMARC
24
- mailkite webhook set <domainId> https://yourapp.com/hooks/mailkite
25
- mailkite send --from hello@mail.yourapp.com --to you@example.com \
26
+ mailkite webhook set <domainId> https://myapp.ai/hooks/mailkite
27
+ mailkite send --from hello@mail.myapp.ai --to you@example.com \
26
28
  --subject "It works" --html "<p>Hi from MailKite</p>"
27
29
  mailkite messages tail # watch inbound arrive
28
30
  ```
@@ -31,8 +33,8 @@ Or do the whole flow in one command:
31
33
 
32
34
  ```bash
33
35
  mailkite init --email you@example.com --password •••• \
34
- --domain mail.yourapp.com --provider cloudflare \
35
- --webhook https://yourapp.com/hooks/mailkite --to you@example.com --verify
36
+ --domain mail.myapp.ai --provider cloudflare \
37
+ --webhook https://myapp.ai/hooks/mailkite --to you@example.com --verify
36
38
  ```
37
39
 
38
40
  ## Built for scripts and agents
package/cli.mjs CHANGED
@@ -249,6 +249,51 @@ commands.domains = async ({ _, flags }) => {
249
249
  const id = await need(_[1] || flags.id, "id", "Domain id: ");
250
250
  return out(await mk.deleteDomain(id), flags, () => console.log(green("✓ ") + "Domain removed."));
251
251
  }
252
+ if (sub === "check") {
253
+ const domain = await need(_[1] || flags.domain, "domain", "Domain to check: ");
254
+ const res = await mk.checkDomainAvailability(domain);
255
+ return out(res, flags, (r) => {
256
+ if (r.configured === false) return console.log(dim("Domain registration isn't enabled for this account."));
257
+ if (r.available) {
258
+ const p = r.price ? " " + dim(`${r.price.amount} ${r.price.currency} / ${r.price.period}${r.price.periodUnit}`) : "";
259
+ console.log(green("✓ ") + `${bold(r.domain)} is available${p}${r.premium ? red(" (premium)") : ""}`);
260
+ console.log(dim(`Register it: mailkite domains register ${r.domain}`));
261
+ } else {
262
+ console.log(red("✗ ") + `${bold(r.domain)} is not available${r.reason ? dim(` (${r.reason})`) : ""}`);
263
+ }
264
+ });
265
+ }
266
+ if (sub === "register" || sub === "buy") {
267
+ const domain = await need(_[1] || flags.domain, "domain", "Domain to register: ");
268
+ // Show the price first (no charge) so the user confirms with eyes open.
269
+ const avail = await mk.checkDomainAvailability(domain).catch(() => null);
270
+ if (avail?.configured === false) die("Domain registration isn't enabled for this account.");
271
+ if (avail && !avail.available) die(`${domain} is not available${avail.reason ? ` (${avail.reason})` : ""}.`);
272
+ if (avail?.price) console.error(`Price: ${bold(`${avail.price.amount} ${avail.price.currency}`)} / ${avail.price.period}${avail.price.periodUnit}${avail.premium ? red(" (premium)") : ""}`);
273
+ const contact = {
274
+ firstName: await need(flags["first-name"], "first name", "First name: "),
275
+ lastName: await need(flags["last-name"], "last name", "Last name: "),
276
+ email: await need(flags.email, "email", "Email: "),
277
+ phone: await need(flags.phone, "phone", "Phone (+countrycode.number, e.g. +1.4155551234): "),
278
+ address: await need(flags.address, "address", "Address: "),
279
+ city: await need(flags.city, "city", "City: "),
280
+ zip: await need(flags.zip, "postal code", "Postal code: "),
281
+ country: await need(flags.country, "country", "Country (2-letter, e.g. US): "),
282
+ };
283
+ if (flags.state) contact.state = flags.state;
284
+ const org = flags.organization || flags.org;
285
+ if (org) { contact.organization = org; contact.type = flags.type || "company"; }
286
+ const years = flags.years ? Number(flags.years) : undefined;
287
+ // Final confirmation — this charges the registrar.
288
+ const ans = flags.yes || flags.force ? "y" : (await prompt(`Register ${bold(domain)} now? This charges your registrar. [y/N] `)).toLowerCase();
289
+ if (ans !== "y" && ans !== "yes") return console.error(dim("Cancelled."));
290
+ const res = await mk.registerDomain({ domain, contact, years });
291
+ return out(res, flags, (r) => {
292
+ console.log(green("✓ ") + `Registered ${bold(r.domain?.domain || domain)}${r.registration?.status ? dim(` (${r.registration.status})`) : ""}`);
293
+ if (r.dnsProvisioned) console.log(green("✓ ") + "Mail DNS provisioned automatically.");
294
+ else printDns(r.dns);
295
+ });
296
+ }
252
297
  die(`Unknown subcommand: domains ${sub}`);
253
298
  };
254
299
 
@@ -469,7 +514,10 @@ ${bold("SEND")}
469
514
 
470
515
  ${bold("DOMAINS & DNS")}
471
516
  domains list List your domains
472
- domains add <domain> Add a domain; prints the DNS records to set
517
+ domains add <domain> Add a domain you own; prints the DNS records to set
518
+ domains check <domain> Check if a domain is available to register (+ price)
519
+ domains register <domain> Buy a domain; provisions DNS + adds it (--first-name --last-name
520
+ --email --phone --address --city --zip --country [--state --org --years --yes])
473
521
  domains get <id> Show a domain (with DNS + webhook)
474
522
  domains verify <id> Re-check DNS (MX/SPF/DKIM/DMARC)
475
523
  domains rm <id> Remove a domain
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailkite/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "MailKite command-line client — sign in, add domains, set DNS + webhooks, send mail, and tail inbound messages from your terminal. Built on the MailKite Node SDK.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,11 +30,11 @@
30
30
  "homepage": "https://mailkite.dev/docs/cli",
31
31
  "repository": {
32
32
  "type": "git",
33
- "url": "https://github.com/fijiwebdesign/mailkite.git",
33
+ "url": "git+https://github.com/fijiwebdesign/mailkite.git",
34
34
  "directory": "sdks/cli"
35
35
  },
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "mailkite": "^0.1.0"
38
+ "mailkite": "^0.2.0"
39
39
  }
40
40
  }