greybull 0.2.2 → 0.2.3

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 (2) hide show
  1. package/dist/index.js +16 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -94,7 +94,7 @@ var ApiError = class extends Error {
94
94
  this.status = status;
95
95
  }
96
96
  };
97
- var VERSION = "0.2.2";
97
+ var VERSION = "0.2.3";
98
98
  function buildRequest(opts) {
99
99
  const url = new URL(opts.apiUrl.replace(/\/+$/, "") + opts.path);
100
100
  if (opts.query) {
@@ -527,11 +527,21 @@ async function prompt(question, valid, def, nonTtyDefault = def) {
527
527
  rl.close();
528
528
  }
529
529
  }
530
- function editorArgv(cmd, args, file) {
530
+ function isVimFamily(cmd) {
531
531
  const base = path2.basename(cmd).replace(/\.exe$/i, "").toLowerCase();
532
- if (["vim", "nvim", "gvim", "mvim"].includes(base)) {
533
- return [...args, "-c", "syntax enable", "-c", "set ft=bindzone", file];
532
+ if (["vim", "nvim", "gvim", "mvim", "vimdiff", "view"].includes(base)) return true;
533
+ if (base === "vi") {
534
+ try {
535
+ const r = spawnSync(cmd, ["--version"], { encoding: "utf8", timeout: 2e3 });
536
+ return /\bn?vim\b/i.test(`${r.stdout ?? ""}${r.stderr ?? ""}`);
537
+ } catch {
538
+ return false;
539
+ }
534
540
  }
541
+ return false;
542
+ }
543
+ function editorArgv(args, file, forceVim) {
544
+ if (forceVim) return [...args, "-c", "syntax enable", "-c", "set ft=bindzone", file];
535
545
  return [...args, file];
536
546
  }
537
547
  function openInEditor(zone, content) {
@@ -540,7 +550,7 @@ function openInEditor(zone, content) {
540
550
  const editor = process.env.VISUAL || process.env.EDITOR || (process.platform === "win32" ? "notepad" : "vi");
541
551
  const [cmd, ...args] = editor.split(" ");
542
552
  try {
543
- const r = spawnSync(cmd, editorArgv(cmd, args, file), { stdio: "inherit" });
553
+ const r = spawnSync(cmd, editorArgv(args, file, isVimFamily(cmd)), { stdio: "inherit" });
544
554
  if (r.error) return null;
545
555
  return fs2.readFileSync(file, "utf8");
546
556
  } finally {
@@ -674,7 +684,7 @@ async function domainsCheckCmd(ctx2, query, opts) {
674
684
 
675
685
  // src/index.ts
676
686
  var program = new Command();
677
- program.name("greybull").description("Manage Greybull DNS records and domains from the command line").version("0.2.2").option("--json", "output raw JSON", false).option("--api-url <url>", "portal base URL (or set GREYBULL_API_URL)");
687
+ program.name("greybull").description("Manage Greybull DNS records and domains from the command line").version("0.2.3").option("--json", "output raw JSON", false).option("--api-url <url>", "portal base URL (or set GREYBULL_API_URL)");
678
688
  function ctx(requireAuth = true) {
679
689
  const opts = program.opts();
680
690
  const apiUrl = resolveApiUrl(opts.apiUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybull",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Command-line tool for the Greybull portal — manage DNS records and domains",
5
5
  "type": "module",
6
6
  "bin": {