greybull 0.2.1 → 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.
- package/dist/index.js +20 -3
- 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.
|
|
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,13 +527,30 @@ async function prompt(question, valid, def, nonTtyDefault = def) {
|
|
|
527
527
|
rl.close();
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
|
+
function isVimFamily(cmd) {
|
|
531
|
+
const base = path2.basename(cmd).replace(/\.exe$/i, "").toLowerCase();
|
|
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
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
function editorArgv(args, file, forceVim) {
|
|
544
|
+
if (forceVim) return [...args, "-c", "syntax enable", "-c", "set ft=bindzone", file];
|
|
545
|
+
return [...args, file];
|
|
546
|
+
}
|
|
530
547
|
function openInEditor(zone, content) {
|
|
531
548
|
const file = path2.join(os3.tmpdir(), `greybull-${zone}-${process.pid}.zone`);
|
|
532
549
|
fs2.writeFileSync(file, content);
|
|
533
550
|
const editor = process.env.VISUAL || process.env.EDITOR || (process.platform === "win32" ? "notepad" : "vi");
|
|
534
551
|
const [cmd, ...args] = editor.split(" ");
|
|
535
552
|
try {
|
|
536
|
-
const r = spawnSync(cmd,
|
|
553
|
+
const r = spawnSync(cmd, editorArgv(args, file, isVimFamily(cmd)), { stdio: "inherit" });
|
|
537
554
|
if (r.error) return null;
|
|
538
555
|
return fs2.readFileSync(file, "utf8");
|
|
539
556
|
} finally {
|
|
@@ -667,7 +684,7 @@ async function domainsCheckCmd(ctx2, query, opts) {
|
|
|
667
684
|
|
|
668
685
|
// src/index.ts
|
|
669
686
|
var program = new Command();
|
|
670
|
-
program.name("greybull").description("Manage Greybull DNS records and domains from the command line").version("0.2.
|
|
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)");
|
|
671
688
|
function ctx(requireAuth = true) {
|
|
672
689
|
const opts = program.opts();
|
|
673
690
|
const apiUrl = resolveApiUrl(opts.apiUrl);
|