gh-ssh 1.0.0 → 1.1.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.
- package/README.md +3 -3
- package/dist/cli.js +238 -225
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# gh-ssh
|
|
2
2
|
|
|
3
|
-
An interactive CLI that guides you through creating or reusing an SSH key and connecting it to GitHub in a 7-step workflow.
|
|
3
|
+
An interactive CLI that guides you through creating or reusing an SSH key and connecting it to GitHub in a 7-step workflow. Supports macOS and Linux with clipboard integration.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -52,13 +52,13 @@ Options:
|
|
|
52
52
|
3. Start ssh-agent if it is not already running.
|
|
53
53
|
4. Add the selected key to ssh-agent.
|
|
54
54
|
5. Optionally update ~/.ssh/config (with an optional GitHub host alias).
|
|
55
|
-
6. Copy the public key to clipboard (macOS) or print it to the terminal, then add it at https://github.com/settings/keys.
|
|
55
|
+
6. Copy the public key to clipboard (macOS/Linux) or print it to the terminal, then add it at https://github.com/settings/keys.
|
|
56
56
|
7. Prompt to verify with `ssh -T git@github.com` (or your alias).
|
|
57
57
|
|
|
58
58
|
## Platform notes
|
|
59
59
|
|
|
60
60
|
- macOS: full workflow, clipboard uses `pbcopy`.
|
|
61
|
-
- Linux
|
|
61
|
+
- Linux: full workflow, clipboard uses `wl-copy`, `xclip`, or `xsel` (if available).
|
|
62
62
|
- Requires `ssh-keygen`, `ssh-agent`, and `ssh-add` to be available in PATH.
|
|
63
63
|
|
|
64
64
|
## Development
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync as Ae, existsSync as M, readdirSync as Lt, mkdirSync as Rt, writeFileSync as Ut, chmodSync as $t } from "node:fs";
|
|
3
|
-
import { dirname as lt, join as I, isAbsolute as Tt, basename as
|
|
3
|
+
import { dirname as lt, join as I, isAbsolute as Tt, basename as De } from "node:path";
|
|
4
4
|
import { fileURLToPath as Ot } from "node:url";
|
|
5
5
|
import { spawnSync as Q } from "node:child_process";
|
|
6
6
|
import { homedir as V } from "node:os";
|
|
@@ -89,10 +89,23 @@ Options:
|
|
|
89
89
|
} catch {
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
|
-
}, Kt = (e) =>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
}, Kt = (e) => {
|
|
93
|
+
const t = process.platform, n = [];
|
|
94
|
+
t === "darwin" ? n.push({ command: "pbcopy", args: [] }) : t === "linux" && (n.push({ command: "wl-copy", args: [] }), n.push({ command: "xclip", args: ["-selection", "clipboard"] }), n.push({ command: "xsel", args: ["--clipboard", "--input"] }));
|
|
95
|
+
for (const { command: s, args: u } of n)
|
|
96
|
+
try {
|
|
97
|
+
const i = Q(s, u, {
|
|
98
|
+
input: e,
|
|
99
|
+
encoding: "utf8",
|
|
100
|
+
stdio: ["pipe", "ignore", "ignore"]
|
|
101
|
+
});
|
|
102
|
+
if (!i.error && i.status === 0)
|
|
103
|
+
return !0;
|
|
104
|
+
} catch {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
return !1;
|
|
108
|
+
}, ct = (e, t, n) => {
|
|
96
109
|
const s = Q(e, t, {
|
|
97
110
|
stdio: "pipe",
|
|
98
111
|
encoding: "utf8",
|
|
@@ -197,8 +210,8 @@ Options:
|
|
|
197
210
|
const n = Ft(e);
|
|
198
211
|
if (!n.ok)
|
|
199
212
|
return { ok: !1, reason: n.reason };
|
|
200
|
-
const { lines: s, content: u, configPath: i } = n, r = dt(s, t.host),
|
|
201
|
-
if (t.hostName && a.push(`${
|
|
213
|
+
const { lines: s, content: u, configPath: i } = n, r = dt(s, t.host), o = " ", D = nu(t.identityFile), a = [];
|
|
214
|
+
if (t.hostName && a.push(`${o}HostName ${t.hostName}`), a.push(`${o}IdentityFile ${D}`), a.push(`${o}IdentitiesOnly yes`), t.useKeychain && a.push(`${o}UseKeychain yes`), r) {
|
|
202
215
|
const h = s.slice(r.start, r.end), f = h[0], g = [
|
|
203
216
|
/^\s*IdentityFile\s+/i,
|
|
204
217
|
/^\s*IdentitiesOnly\s+/i,
|
|
@@ -225,7 +238,7 @@ Options:
|
|
|
225
238
|
return { ok: !1, reason: "write_failed" };
|
|
226
239
|
}
|
|
227
240
|
return { ok: !0, changed: !0 };
|
|
228
|
-
},
|
|
241
|
+
}, ou = !!process.stdout.isTTY && !process.env.NO_COLOR && process.env.TERM !== "dumb", H = (e, t) => ou ? `\x1B[${e}m${t}\x1B[0m` : t, L = {
|
|
229
242
|
bold: (e) => H("1", e),
|
|
230
243
|
dim: (e) => H("2", e),
|
|
231
244
|
red: (e) => H("31", e),
|
|
@@ -257,7 +270,7 @@ Options:
|
|
|
257
270
|
console.log(`${w.warn} ${re("WARN", L.yellow)} ${e}`);
|
|
258
271
|
}, P = (e) => {
|
|
259
272
|
console.error(`${w.error} ${re("ERROR", L.red)} ${e}`);
|
|
260
|
-
},
|
|
273
|
+
}, Du = () => {
|
|
261
274
|
console.log(L.bold(`${w.header} gh-ssh`)), console.log(L.dim(`${w.subtitle} GitHub SSH key setup`)), console.log(L.dim("----------------------------------------"));
|
|
262
275
|
}, $ = (e, t, n = w.step) => {
|
|
263
276
|
console.log(""), console.log(
|
|
@@ -414,18 +427,18 @@ function gu() {
|
|
|
414
427
|
qe = 1;
|
|
415
428
|
const t = qt?.WriteStream?.prototype?.hasColors?.() ?? !1, n = (u, i) => {
|
|
416
429
|
if (!t)
|
|
417
|
-
return (
|
|
418
|
-
const r = `\x1B[${u}m`,
|
|
419
|
-
return (
|
|
420
|
-
const a =
|
|
421
|
-
let l = a.indexOf(
|
|
430
|
+
return (D) => D;
|
|
431
|
+
const r = `\x1B[${u}m`, o = `\x1B[${i}m`;
|
|
432
|
+
return (D) => {
|
|
433
|
+
const a = D + "";
|
|
434
|
+
let l = a.indexOf(o);
|
|
422
435
|
if (l === -1)
|
|
423
|
-
return r + a +
|
|
436
|
+
return r + a + o;
|
|
424
437
|
let c = r, h = 0;
|
|
425
|
-
const g = (i === 22 ?
|
|
438
|
+
const g = (i === 22 ? o : "") + r;
|
|
426
439
|
for (; l !== -1; )
|
|
427
|
-
c += a.slice(h, l) + g, h = l +
|
|
428
|
-
return c += a.slice(h) +
|
|
440
|
+
c += a.slice(h, l) + g, h = l + o.length, l = a.indexOf(o, h);
|
|
441
|
+
return c += a.slice(h) + o, c;
|
|
429
442
|
};
|
|
430
443
|
}, s = {};
|
|
431
444
|
return s.reset = n(0, 0), s.bold = n(1, 22), s.dim = n(2, 22), s.italic = n(3, 23), s.underline = n(4, 24), s.overline = n(53, 55), s.inverse = n(7, 27), s.hidden = n(8, 28), s.strikethrough = n(9, 29), s.black = n(30, 39), s.red = n(31, 39), s.green = n(32, 39), s.yellow = n(33, 39), s.blue = n(34, 39), s.magenta = n(35, 39), s.cyan = n(36, 39), s.white = n(37, 39), s.gray = n(90, 39), s.bgBlack = n(40, 49), s.bgRed = n(41, 49), s.bgGreen = n(42, 49), s.bgYellow = n(43, 49), s.bgBlue = n(44, 49), s.bgMagenta = n(45, 49), s.bgCyan = n(46, 49), s.bgWhite = n(47, 49), s.bgGray = n(100, 49), s.redBright = n(91, 39), s.greenBright = n(92, 39), s.yellowBright = n(93, 39), s.blueBright = n(94, 39), s.magentaBright = n(95, 39), s.cyanBright = n(96, 39), s.whiteBright = n(97, 39), s.bgRedBright = n(101, 49), s.bgGreenBright = n(102, 49), s.bgYellowBright = n(103, 49), s.bgBlueBright = n(104, 49), s.bgMagentaBright = n(105, 49), s.bgCyanBright = n(106, 49), s.bgWhiteBright = n(107, 49), ce = s, ce;
|
|
@@ -745,7 +758,7 @@ function wt(...e) {
|
|
|
745
758
|
}
|
|
746
759
|
return t;
|
|
747
760
|
}
|
|
748
|
-
function
|
|
761
|
+
function oe(...e) {
|
|
749
762
|
const t = [
|
|
750
763
|
xu,
|
|
751
764
|
...e.filter((n) => n != null)
|
|
@@ -753,21 +766,21 @@ function De(...e) {
|
|
|
753
766
|
return wt(...t);
|
|
754
767
|
}
|
|
755
768
|
function Ue({ status: e = "idle", theme: t }) {
|
|
756
|
-
const [n, s] = A(!1), [u, i] = A(0), { prefix: r, spinner:
|
|
769
|
+
const [n, s] = A(!1), [u, i] = A(0), { prefix: r, spinner: o } = oe(t);
|
|
757
770
|
return se(() => {
|
|
758
771
|
if (e === "loading") {
|
|
759
772
|
let a, l = -1;
|
|
760
773
|
const c = setTimeout(() => {
|
|
761
774
|
s(!0), a = setInterval(() => {
|
|
762
|
-
l = l + 1, i(l %
|
|
763
|
-
},
|
|
775
|
+
l = l + 1, i(l % o.frames.length);
|
|
776
|
+
}, o.interval);
|
|
764
777
|
}, 300);
|
|
765
778
|
return () => {
|
|
766
779
|
clearTimeout(c), clearInterval(a);
|
|
767
780
|
};
|
|
768
781
|
} else
|
|
769
782
|
s(!1);
|
|
770
|
-
}, [e]), n ?
|
|
783
|
+
}, [e]), n ? o.frames[u] : typeof r == "string" ? r : r[e === "loading" ? "idle" : e] ?? r.idle;
|
|
771
784
|
}
|
|
772
785
|
function he(e, t) {
|
|
773
786
|
return Le((n) => {
|
|
@@ -882,8 +895,8 @@ function Uu() {
|
|
|
882
895
|
u = u.replace(n(), " ");
|
|
883
896
|
let i = 0;
|
|
884
897
|
for (let r = 0; r < u.length; r++) {
|
|
885
|
-
const
|
|
886
|
-
|
|
898
|
+
const o = u.codePointAt(r);
|
|
899
|
+
o <= 31 || o >= 127 && o <= 159 || o >= 768 && o <= 879 || (o > 65535 && r++, i += t(o) ? 2 : 1);
|
|
887
900
|
}
|
|
888
901
|
return i;
|
|
889
902
|
};
|
|
@@ -1078,29 +1091,29 @@ function kt() {
|
|
|
1078
1091
|
delete n[u].channels, delete n[u].labels, Object.defineProperty(n[u], "channels", { value: i }), Object.defineProperty(n[u], "labels", { value: r });
|
|
1079
1092
|
}
|
|
1080
1093
|
n.rgb.hsl = function(u) {
|
|
1081
|
-
const i = u[0] / 255, r = u[1] / 255,
|
|
1094
|
+
const i = u[0] / 255, r = u[1] / 255, o = u[2] / 255, D = Math.min(i, r, o), a = Math.max(i, r, o), l = a - D;
|
|
1082
1095
|
let c, h;
|
|
1083
|
-
a ===
|
|
1084
|
-
const f = (
|
|
1085
|
-
return a ===
|
|
1096
|
+
a === D ? c = 0 : i === a ? c = (r - o) / l : r === a ? c = 2 + (o - i) / l : o === a && (c = 4 + (i - r) / l), c = Math.min(c * 60, 360), c < 0 && (c += 360);
|
|
1097
|
+
const f = (D + a) / 2;
|
|
1098
|
+
return a === D ? h = 0 : f <= 0.5 ? h = l / (a + D) : h = l / (2 - a - D), [c, h * 100, f * 100];
|
|
1086
1099
|
}, n.rgb.hsv = function(u) {
|
|
1087
|
-
let i, r,
|
|
1100
|
+
let i, r, o, D, a;
|
|
1088
1101
|
const l = u[0] / 255, c = u[1] / 255, h = u[2] / 255, f = Math.max(l, c, h), g = f - Math.min(l, c, h), d = function(C) {
|
|
1089
1102
|
return (f - C) / 6 / g + 1 / 2;
|
|
1090
1103
|
};
|
|
1091
|
-
return g === 0 ? (
|
|
1092
|
-
|
|
1104
|
+
return g === 0 ? (D = 0, a = 0) : (a = g / f, i = d(l), r = d(c), o = d(h), l === f ? D = o - r : c === f ? D = 1 / 3 + i - o : h === f && (D = 2 / 3 + r - i), D < 0 ? D += 1 : D > 1 && (D -= 1)), [
|
|
1105
|
+
D * 360,
|
|
1093
1106
|
a * 100,
|
|
1094
1107
|
f * 100
|
|
1095
1108
|
];
|
|
1096
1109
|
}, n.rgb.hwb = function(u) {
|
|
1097
1110
|
const i = u[0], r = u[1];
|
|
1098
|
-
let
|
|
1099
|
-
const
|
|
1100
|
-
return
|
|
1111
|
+
let o = u[2];
|
|
1112
|
+
const D = n.rgb.hsl(u)[0], a = 1 / 255 * Math.min(i, Math.min(r, o));
|
|
1113
|
+
return o = 1 - 1 / 255 * Math.max(i, Math.max(r, o)), [D, a * 100, o * 100];
|
|
1101
1114
|
}, n.rgb.cmyk = function(u) {
|
|
1102
|
-
const i = u[0] / 255, r = u[1] / 255,
|
|
1103
|
-
return [a * 100, l * 100, c * 100,
|
|
1115
|
+
const i = u[0] / 255, r = u[1] / 255, o = u[2] / 255, D = Math.min(1 - i, 1 - r, 1 - o), a = (1 - i - D) / (1 - D) || 0, l = (1 - r - D) / (1 - D) || 0, c = (1 - o - D) / (1 - D) || 0;
|
|
1116
|
+
return [a * 100, l * 100, c * 100, D * 100];
|
|
1104
1117
|
};
|
|
1105
1118
|
function s(u, i) {
|
|
1106
1119
|
return (u[0] - i[0]) ** 2 + (u[1] - i[1]) ** 2 + (u[2] - i[2]) ** 2;
|
|
@@ -1109,73 +1122,73 @@ function kt() {
|
|
|
1109
1122
|
const i = t[u];
|
|
1110
1123
|
if (i)
|
|
1111
1124
|
return i;
|
|
1112
|
-
let r = 1 / 0,
|
|
1113
|
-
for (const
|
|
1114
|
-
const a = e[
|
|
1115
|
-
l < r && (r = l,
|
|
1125
|
+
let r = 1 / 0, o;
|
|
1126
|
+
for (const D of Object.keys(e)) {
|
|
1127
|
+
const a = e[D], l = s(u, a);
|
|
1128
|
+
l < r && (r = l, o = D);
|
|
1116
1129
|
}
|
|
1117
|
-
return
|
|
1130
|
+
return o;
|
|
1118
1131
|
}, n.keyword.rgb = function(u) {
|
|
1119
1132
|
return e[u];
|
|
1120
1133
|
}, n.rgb.xyz = function(u) {
|
|
1121
|
-
let i = u[0] / 255, r = u[1] / 255,
|
|
1122
|
-
i = i > 0.04045 ? ((i + 0.055) / 1.055) ** 2.4 : i / 12.92, r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92,
|
|
1123
|
-
const
|
|
1124
|
-
return [
|
|
1134
|
+
let i = u[0] / 255, r = u[1] / 255, o = u[2] / 255;
|
|
1135
|
+
i = i > 0.04045 ? ((i + 0.055) / 1.055) ** 2.4 : i / 12.92, r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92, o = o > 0.04045 ? ((o + 0.055) / 1.055) ** 2.4 : o / 12.92;
|
|
1136
|
+
const D = i * 0.4124 + r * 0.3576 + o * 0.1805, a = i * 0.2126 + r * 0.7152 + o * 0.0722, l = i * 0.0193 + r * 0.1192 + o * 0.9505;
|
|
1137
|
+
return [D * 100, a * 100, l * 100];
|
|
1125
1138
|
}, n.rgb.lab = function(u) {
|
|
1126
1139
|
const i = n.rgb.xyz(u);
|
|
1127
|
-
let r = i[0],
|
|
1128
|
-
r /= 95.047,
|
|
1129
|
-
const a = 116 *
|
|
1140
|
+
let r = i[0], o = i[1], D = i[2];
|
|
1141
|
+
r /= 95.047, o /= 100, D /= 108.883, r = r > 8856e-6 ? r ** (1 / 3) : 7.787 * r + 16 / 116, o = o > 8856e-6 ? o ** (1 / 3) : 7.787 * o + 16 / 116, D = D > 8856e-6 ? D ** (1 / 3) : 7.787 * D + 16 / 116;
|
|
1142
|
+
const a = 116 * o - 16, l = 500 * (r - o), c = 200 * (o - D);
|
|
1130
1143
|
return [a, l, c];
|
|
1131
1144
|
}, n.hsl.rgb = function(u) {
|
|
1132
|
-
const i = u[0] / 360, r = u[1] / 100,
|
|
1133
|
-
let
|
|
1145
|
+
const i = u[0] / 360, r = u[1] / 100, o = u[2] / 100;
|
|
1146
|
+
let D, a, l;
|
|
1134
1147
|
if (r === 0)
|
|
1135
|
-
return l =
|
|
1136
|
-
|
|
1137
|
-
const c = 2 *
|
|
1148
|
+
return l = o * 255, [l, l, l];
|
|
1149
|
+
o < 0.5 ? D = o * (1 + r) : D = o + r - o * r;
|
|
1150
|
+
const c = 2 * o - D, h = [0, 0, 0];
|
|
1138
1151
|
for (let f = 0; f < 3; f++)
|
|
1139
|
-
a = i + 1 / 3 * -(f - 1), a < 0 && a++, a > 1 && a--, 6 * a < 1 ? l = c + (
|
|
1152
|
+
a = i + 1 / 3 * -(f - 1), a < 0 && a++, a > 1 && a--, 6 * a < 1 ? l = c + (D - c) * 6 * a : 2 * a < 1 ? l = D : 3 * a < 2 ? l = c + (D - c) * (2 / 3 - a) * 6 : l = c, h[f] = l * 255;
|
|
1140
1153
|
return h;
|
|
1141
1154
|
}, n.hsl.hsv = function(u) {
|
|
1142
1155
|
const i = u[0];
|
|
1143
|
-
let r = u[1] / 100,
|
|
1144
|
-
const a = Math.max(
|
|
1145
|
-
|
|
1146
|
-
const l = (
|
|
1156
|
+
let r = u[1] / 100, o = u[2] / 100, D = r;
|
|
1157
|
+
const a = Math.max(o, 0.01);
|
|
1158
|
+
o *= 2, r *= o <= 1 ? o : 2 - o, D *= a <= 1 ? a : 2 - a;
|
|
1159
|
+
const l = (o + r) / 2, c = o === 0 ? 2 * D / (a + D) : 2 * r / (o + r);
|
|
1147
1160
|
return [i, c * 100, l * 100];
|
|
1148
1161
|
}, n.hsv.rgb = function(u) {
|
|
1149
1162
|
const i = u[0] / 60, r = u[1] / 100;
|
|
1150
|
-
let
|
|
1151
|
-
const
|
|
1152
|
-
switch (
|
|
1163
|
+
let o = u[2] / 100;
|
|
1164
|
+
const D = Math.floor(i) % 6, a = i - Math.floor(i), l = 255 * o * (1 - r), c = 255 * o * (1 - r * a), h = 255 * o * (1 - r * (1 - a));
|
|
1165
|
+
switch (o *= 255, D) {
|
|
1153
1166
|
case 0:
|
|
1154
|
-
return [
|
|
1167
|
+
return [o, h, l];
|
|
1155
1168
|
case 1:
|
|
1156
|
-
return [c,
|
|
1169
|
+
return [c, o, l];
|
|
1157
1170
|
case 2:
|
|
1158
|
-
return [l,
|
|
1171
|
+
return [l, o, h];
|
|
1159
1172
|
case 3:
|
|
1160
|
-
return [l, c,
|
|
1173
|
+
return [l, c, o];
|
|
1161
1174
|
case 4:
|
|
1162
|
-
return [h, l,
|
|
1175
|
+
return [h, l, o];
|
|
1163
1176
|
case 5:
|
|
1164
|
-
return [
|
|
1177
|
+
return [o, l, c];
|
|
1165
1178
|
}
|
|
1166
1179
|
}, n.hsv.hsl = function(u) {
|
|
1167
|
-
const i = u[0], r = u[1] / 100,
|
|
1180
|
+
const i = u[0], r = u[1] / 100, o = u[2] / 100, D = Math.max(o, 0.01);
|
|
1168
1181
|
let a, l;
|
|
1169
|
-
l = (2 - r) *
|
|
1170
|
-
const c = (2 - r) *
|
|
1171
|
-
return a = r *
|
|
1182
|
+
l = (2 - r) * o;
|
|
1183
|
+
const c = (2 - r) * D;
|
|
1184
|
+
return a = r * D, a /= c <= 1 ? c : 2 - c, a = a || 0, l /= 2, [i, a * 100, l * 100];
|
|
1172
1185
|
}, n.hwb.rgb = function(u) {
|
|
1173
1186
|
const i = u[0] / 360;
|
|
1174
|
-
let r = u[1] / 100,
|
|
1175
|
-
const
|
|
1187
|
+
let r = u[1] / 100, o = u[2] / 100;
|
|
1188
|
+
const D = r + o;
|
|
1176
1189
|
let a;
|
|
1177
|
-
|
|
1178
|
-
const l = Math.floor(6 * i), c = 1 -
|
|
1190
|
+
D > 1 && (r /= D, o /= D);
|
|
1191
|
+
const l = Math.floor(6 * i), c = 1 - o;
|
|
1179
1192
|
a = 6 * i - l, (l & 1) !== 0 && (a = 1 - a);
|
|
1180
1193
|
const h = r + a * (c - r);
|
|
1181
1194
|
let f, g, d;
|
|
@@ -1203,50 +1216,50 @@ function kt() {
|
|
|
1203
1216
|
}
|
|
1204
1217
|
return [f * 255, g * 255, d * 255];
|
|
1205
1218
|
}, n.cmyk.rgb = function(u) {
|
|
1206
|
-
const i = u[0] / 100, r = u[1] / 100,
|
|
1219
|
+
const i = u[0] / 100, r = u[1] / 100, o = u[2] / 100, D = u[3] / 100, a = 1 - Math.min(1, i * (1 - D) + D), l = 1 - Math.min(1, r * (1 - D) + D), c = 1 - Math.min(1, o * (1 - D) + D);
|
|
1207
1220
|
return [a * 255, l * 255, c * 255];
|
|
1208
1221
|
}, n.xyz.rgb = function(u) {
|
|
1209
|
-
const i = u[0] / 100, r = u[1] / 100,
|
|
1210
|
-
let
|
|
1211
|
-
return
|
|
1222
|
+
const i = u[0] / 100, r = u[1] / 100, o = u[2] / 100;
|
|
1223
|
+
let D, a, l;
|
|
1224
|
+
return D = i * 3.2406 + r * -1.5372 + o * -0.4986, a = i * -0.9689 + r * 1.8758 + o * 0.0415, l = i * 0.0557 + r * -0.204 + o * 1.057, D = D > 31308e-7 ? 1.055 * D ** (1 / 2.4) - 0.055 : D * 12.92, a = a > 31308e-7 ? 1.055 * a ** (1 / 2.4) - 0.055 : a * 12.92, l = l > 31308e-7 ? 1.055 * l ** (1 / 2.4) - 0.055 : l * 12.92, D = Math.min(Math.max(0, D), 1), a = Math.min(Math.max(0, a), 1), l = Math.min(Math.max(0, l), 1), [D * 255, a * 255, l * 255];
|
|
1212
1225
|
}, n.xyz.lab = function(u) {
|
|
1213
|
-
let i = u[0], r = u[1],
|
|
1214
|
-
i /= 95.047, r /= 100,
|
|
1215
|
-
const
|
|
1216
|
-
return [
|
|
1226
|
+
let i = u[0], r = u[1], o = u[2];
|
|
1227
|
+
i /= 95.047, r /= 100, o /= 108.883, i = i > 8856e-6 ? i ** (1 / 3) : 7.787 * i + 16 / 116, r = r > 8856e-6 ? r ** (1 / 3) : 7.787 * r + 16 / 116, o = o > 8856e-6 ? o ** (1 / 3) : 7.787 * o + 16 / 116;
|
|
1228
|
+
const D = 116 * r - 16, a = 500 * (i - r), l = 200 * (r - o);
|
|
1229
|
+
return [D, a, l];
|
|
1217
1230
|
}, n.lab.xyz = function(u) {
|
|
1218
|
-
const i = u[0], r = u[1],
|
|
1219
|
-
let
|
|
1220
|
-
a = (i + 16) / 116,
|
|
1221
|
-
const c = a ** 3, h =
|
|
1222
|
-
return a = c > 8856e-6 ? c : (a - 16 / 116) / 7.787,
|
|
1231
|
+
const i = u[0], r = u[1], o = u[2];
|
|
1232
|
+
let D, a, l;
|
|
1233
|
+
a = (i + 16) / 116, D = r / 500 + a, l = a - o / 200;
|
|
1234
|
+
const c = a ** 3, h = D ** 3, f = l ** 3;
|
|
1235
|
+
return a = c > 8856e-6 ? c : (a - 16 / 116) / 7.787, D = h > 8856e-6 ? h : (D - 16 / 116) / 7.787, l = f > 8856e-6 ? f : (l - 16 / 116) / 7.787, D *= 95.047, a *= 100, l *= 108.883, [D, a, l];
|
|
1223
1236
|
}, n.lab.lch = function(u) {
|
|
1224
|
-
const i = u[0], r = u[1],
|
|
1225
|
-
let
|
|
1226
|
-
|
|
1227
|
-
const l = Math.sqrt(r * r +
|
|
1228
|
-
return [i, l,
|
|
1237
|
+
const i = u[0], r = u[1], o = u[2];
|
|
1238
|
+
let D;
|
|
1239
|
+
D = Math.atan2(o, r) * 360 / 2 / Math.PI, D < 0 && (D += 360);
|
|
1240
|
+
const l = Math.sqrt(r * r + o * o);
|
|
1241
|
+
return [i, l, D];
|
|
1229
1242
|
}, n.lch.lab = function(u) {
|
|
1230
|
-
const i = u[0], r = u[1],
|
|
1243
|
+
const i = u[0], r = u[1], D = u[2] / 360 * 2 * Math.PI, a = r * Math.cos(D), l = r * Math.sin(D);
|
|
1231
1244
|
return [i, a, l];
|
|
1232
1245
|
}, n.rgb.ansi16 = function(u, i = null) {
|
|
1233
|
-
const [r,
|
|
1246
|
+
const [r, o, D] = u;
|
|
1234
1247
|
let a = i === null ? n.rgb.hsv(u)[2] : i;
|
|
1235
1248
|
if (a = Math.round(a / 50), a === 0)
|
|
1236
1249
|
return 30;
|
|
1237
|
-
let l = 30 + (Math.round(
|
|
1250
|
+
let l = 30 + (Math.round(D / 255) << 2 | Math.round(o / 255) << 1 | Math.round(r / 255));
|
|
1238
1251
|
return a === 2 && (l += 60), l;
|
|
1239
1252
|
}, n.hsv.ansi16 = function(u) {
|
|
1240
1253
|
return n.rgb.ansi16(n.hsv.rgb(u), u[2]);
|
|
1241
1254
|
}, n.rgb.ansi256 = function(u) {
|
|
1242
|
-
const i = u[0], r = u[1],
|
|
1243
|
-
return i === r && r ===
|
|
1255
|
+
const i = u[0], r = u[1], o = u[2];
|
|
1256
|
+
return i === r && r === o ? i < 8 ? 16 : i > 248 ? 231 : Math.round((i - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(i / 255 * 5) + 6 * Math.round(r / 255 * 5) + Math.round(o / 255 * 5);
|
|
1244
1257
|
}, n.ansi16.rgb = function(u) {
|
|
1245
1258
|
let i = u % 10;
|
|
1246
1259
|
if (i === 0 || i === 7)
|
|
1247
1260
|
return u > 50 && (i += 3.5), i = i / 10.5 * 255, [i, i, i];
|
|
1248
|
-
const r = (~~(u > 50) + 1) * 0.5,
|
|
1249
|
-
return [
|
|
1261
|
+
const r = (~~(u > 50) + 1) * 0.5, o = (i & 1) * r * 255, D = (i >> 1 & 1) * r * 255, a = (i >> 2 & 1) * r * 255;
|
|
1262
|
+
return [o, D, a];
|
|
1250
1263
|
}, n.ansi256.rgb = function(u) {
|
|
1251
1264
|
if (u >= 232) {
|
|
1252
1265
|
const a = (u - 232) * 10 + 8;
|
|
@@ -1254,8 +1267,8 @@ function kt() {
|
|
|
1254
1267
|
}
|
|
1255
1268
|
u -= 16;
|
|
1256
1269
|
let i;
|
|
1257
|
-
const r = Math.floor(u / 36) / 5 * 255,
|
|
1258
|
-
return [r,
|
|
1270
|
+
const r = Math.floor(u / 36) / 5 * 255, o = Math.floor((i = u % 36) / 6) / 5 * 255, D = i % 6 / 5 * 255;
|
|
1271
|
+
return [r, o, D];
|
|
1259
1272
|
}, n.rgb.hex = function(u) {
|
|
1260
1273
|
const r = (((Math.round(u[0]) & 255) << 16) + ((Math.round(u[1]) & 255) << 8) + (Math.round(u[2]) & 255)).toString(16).toUpperCase();
|
|
1261
1274
|
return "000000".substring(r.length) + r;
|
|
@@ -1265,65 +1278,65 @@ function kt() {
|
|
|
1265
1278
|
return [0, 0, 0];
|
|
1266
1279
|
let r = i[0];
|
|
1267
1280
|
i[0].length === 3 && (r = r.split("").map((c) => c + c).join(""));
|
|
1268
|
-
const
|
|
1269
|
-
return [
|
|
1281
|
+
const o = parseInt(r, 16), D = o >> 16 & 255, a = o >> 8 & 255, l = o & 255;
|
|
1282
|
+
return [D, a, l];
|
|
1270
1283
|
}, n.rgb.hcg = function(u) {
|
|
1271
|
-
const i = u[0] / 255, r = u[1] / 255,
|
|
1284
|
+
const i = u[0] / 255, r = u[1] / 255, o = u[2] / 255, D = Math.max(Math.max(i, r), o), a = Math.min(Math.min(i, r), o), l = D - a;
|
|
1272
1285
|
let c, h;
|
|
1273
|
-
return l < 1 ? c = a / (1 - l) : c = 0, l <= 0 ? h = 0 :
|
|
1286
|
+
return l < 1 ? c = a / (1 - l) : c = 0, l <= 0 ? h = 0 : D === i ? h = (r - o) / l % 6 : D === r ? h = 2 + (o - i) / l : h = 4 + (i - r) / l, h /= 6, h %= 1, [h * 360, l * 100, c * 100];
|
|
1274
1287
|
}, n.hsl.hcg = function(u) {
|
|
1275
|
-
const i = u[1] / 100, r = u[2] / 100,
|
|
1276
|
-
let
|
|
1277
|
-
return
|
|
1288
|
+
const i = u[1] / 100, r = u[2] / 100, o = r < 0.5 ? 2 * i * r : 2 * i * (1 - r);
|
|
1289
|
+
let D = 0;
|
|
1290
|
+
return o < 1 && (D = (r - 0.5 * o) / (1 - o)), [u[0], o * 100, D * 100];
|
|
1278
1291
|
}, n.hsv.hcg = function(u) {
|
|
1279
|
-
const i = u[1] / 100, r = u[2] / 100,
|
|
1280
|
-
let
|
|
1281
|
-
return
|
|
1292
|
+
const i = u[1] / 100, r = u[2] / 100, o = i * r;
|
|
1293
|
+
let D = 0;
|
|
1294
|
+
return o < 1 && (D = (r - o) / (1 - o)), [u[0], o * 100, D * 100];
|
|
1282
1295
|
}, n.hcg.rgb = function(u) {
|
|
1283
|
-
const i = u[0] / 360, r = u[1] / 100,
|
|
1296
|
+
const i = u[0] / 360, r = u[1] / 100, o = u[2] / 100;
|
|
1284
1297
|
if (r === 0)
|
|
1285
|
-
return [
|
|
1286
|
-
const
|
|
1298
|
+
return [o * 255, o * 255, o * 255];
|
|
1299
|
+
const D = [0, 0, 0], a = i % 1 * 6, l = a % 1, c = 1 - l;
|
|
1287
1300
|
let h = 0;
|
|
1288
1301
|
switch (Math.floor(a)) {
|
|
1289
1302
|
case 0:
|
|
1290
|
-
|
|
1303
|
+
D[0] = 1, D[1] = l, D[2] = 0;
|
|
1291
1304
|
break;
|
|
1292
1305
|
case 1:
|
|
1293
|
-
|
|
1306
|
+
D[0] = c, D[1] = 1, D[2] = 0;
|
|
1294
1307
|
break;
|
|
1295
1308
|
case 2:
|
|
1296
|
-
|
|
1309
|
+
D[0] = 0, D[1] = 1, D[2] = l;
|
|
1297
1310
|
break;
|
|
1298
1311
|
case 3:
|
|
1299
|
-
|
|
1312
|
+
D[0] = 0, D[1] = c, D[2] = 1;
|
|
1300
1313
|
break;
|
|
1301
1314
|
case 4:
|
|
1302
|
-
|
|
1315
|
+
D[0] = l, D[1] = 0, D[2] = 1;
|
|
1303
1316
|
break;
|
|
1304
1317
|
default:
|
|
1305
|
-
|
|
1318
|
+
D[0] = 1, D[1] = 0, D[2] = c;
|
|
1306
1319
|
}
|
|
1307
|
-
return h = (1 - r) *
|
|
1308
|
-
(r *
|
|
1309
|
-
(r *
|
|
1310
|
-
(r *
|
|
1320
|
+
return h = (1 - r) * o, [
|
|
1321
|
+
(r * D[0] + h) * 255,
|
|
1322
|
+
(r * D[1] + h) * 255,
|
|
1323
|
+
(r * D[2] + h) * 255
|
|
1311
1324
|
];
|
|
1312
1325
|
}, n.hcg.hsv = function(u) {
|
|
1313
|
-
const i = u[1] / 100, r = u[2] / 100,
|
|
1314
|
-
let
|
|
1315
|
-
return
|
|
1326
|
+
const i = u[1] / 100, r = u[2] / 100, o = i + r * (1 - i);
|
|
1327
|
+
let D = 0;
|
|
1328
|
+
return o > 0 && (D = i / o), [u[0], D * 100, o * 100];
|
|
1316
1329
|
}, n.hcg.hsl = function(u) {
|
|
1317
|
-
const i = u[1] / 100,
|
|
1318
|
-
let
|
|
1319
|
-
return
|
|
1330
|
+
const i = u[1] / 100, o = u[2] / 100 * (1 - i) + 0.5 * i;
|
|
1331
|
+
let D = 0;
|
|
1332
|
+
return o > 0 && o < 0.5 ? D = i / (2 * o) : o >= 0.5 && o < 1 && (D = i / (2 * (1 - o))), [u[0], D * 100, o * 100];
|
|
1320
1333
|
}, n.hcg.hwb = function(u) {
|
|
1321
|
-
const i = u[1] / 100, r = u[2] / 100,
|
|
1322
|
-
return [u[0], (
|
|
1334
|
+
const i = u[1] / 100, r = u[2] / 100, o = i + r * (1 - i);
|
|
1335
|
+
return [u[0], (o - i) * 100, (1 - o) * 100];
|
|
1323
1336
|
}, n.hwb.hcg = function(u) {
|
|
1324
|
-
const i = u[1] / 100,
|
|
1337
|
+
const i = u[1] / 100, o = 1 - u[2] / 100, D = o - i;
|
|
1325
1338
|
let a = 0;
|
|
1326
|
-
return
|
|
1339
|
+
return D < 1 && (a = (o - D) / (1 - D)), [u[0], D * 100, a * 100];
|
|
1327
1340
|
}, n.apple.rgb = function(u) {
|
|
1328
1341
|
return [u[0] / 65535 * 255, u[1] / 65535 * 255, u[2] / 65535 * 255];
|
|
1329
1342
|
}, n.rgb.apple = function(u) {
|
|
@@ -1339,8 +1352,8 @@ function kt() {
|
|
|
1339
1352
|
}, n.gray.lab = function(u) {
|
|
1340
1353
|
return [u[0], 0, 0];
|
|
1341
1354
|
}, n.gray.hex = function(u) {
|
|
1342
|
-
const i = Math.round(u[0] / 100 * 255) & 255,
|
|
1343
|
-
return "000000".substring(
|
|
1355
|
+
const i = Math.round(u[0] / 100 * 255) & 255, o = ((i << 16) + (i << 8) + i).toString(16).toUpperCase();
|
|
1356
|
+
return "000000".substring(o.length) + o;
|
|
1344
1357
|
}, n.rgb.gray = function(u) {
|
|
1345
1358
|
return [(u[0] + u[1] + u[2]) / 3 / 255 * 100];
|
|
1346
1359
|
}, Ce;
|
|
@@ -1352,8 +1365,8 @@ function Tu() {
|
|
|
1352
1365
|
const e = kt();
|
|
1353
1366
|
function t() {
|
|
1354
1367
|
const i = {}, r = Object.keys(e);
|
|
1355
|
-
for (let
|
|
1356
|
-
i[r[
|
|
1368
|
+
for (let o = r.length, D = 0; D < o; D++)
|
|
1369
|
+
i[r[D]] = {
|
|
1357
1370
|
// http://jsperf.com/1-vs-infinity
|
|
1358
1371
|
// micro-opt, but this is simple.
|
|
1359
1372
|
distance: -1,
|
|
@@ -1362,35 +1375,35 @@ function Tu() {
|
|
|
1362
1375
|
return i;
|
|
1363
1376
|
}
|
|
1364
1377
|
function n(i) {
|
|
1365
|
-
const r = t(),
|
|
1366
|
-
for (r[i].distance = 0;
|
|
1367
|
-
const
|
|
1378
|
+
const r = t(), o = [i];
|
|
1379
|
+
for (r[i].distance = 0; o.length; ) {
|
|
1380
|
+
const D = o.pop(), a = Object.keys(e[D]);
|
|
1368
1381
|
for (let l = a.length, c = 0; c < l; c++) {
|
|
1369
1382
|
const h = a[c], f = r[h];
|
|
1370
|
-
f.distance === -1 && (f.distance = r[
|
|
1383
|
+
f.distance === -1 && (f.distance = r[D].distance + 1, f.parent = D, o.unshift(h));
|
|
1371
1384
|
}
|
|
1372
1385
|
}
|
|
1373
1386
|
return r;
|
|
1374
1387
|
}
|
|
1375
1388
|
function s(i, r) {
|
|
1376
|
-
return function(
|
|
1377
|
-
return r(i(
|
|
1389
|
+
return function(o) {
|
|
1390
|
+
return r(i(o));
|
|
1378
1391
|
};
|
|
1379
1392
|
}
|
|
1380
1393
|
function u(i, r) {
|
|
1381
|
-
const
|
|
1382
|
-
let
|
|
1394
|
+
const o = [r[i].parent, i];
|
|
1395
|
+
let D = e[r[i].parent][i], a = r[i].parent;
|
|
1383
1396
|
for (; r[a].parent; )
|
|
1384
|
-
|
|
1385
|
-
return
|
|
1397
|
+
o.unshift(r[a].parent), D = s(e[r[a].parent][a], D), a = r[a].parent;
|
|
1398
|
+
return D.conversion = o, D;
|
|
1386
1399
|
}
|
|
1387
1400
|
return me = function(i) {
|
|
1388
|
-
const r = n(i),
|
|
1389
|
-
for (let a =
|
|
1390
|
-
const c =
|
|
1391
|
-
r[c].parent !== null && (
|
|
1401
|
+
const r = n(i), o = {}, D = Object.keys(r);
|
|
1402
|
+
for (let a = D.length, l = 0; l < a; l++) {
|
|
1403
|
+
const c = D[l];
|
|
1404
|
+
r[c].parent !== null && (o[c] = u(c, r));
|
|
1392
1405
|
}
|
|
1393
|
-
return
|
|
1406
|
+
return o;
|
|
1394
1407
|
}, me;
|
|
1395
1408
|
}
|
|
1396
1409
|
var Ee, Qe;
|
|
@@ -1399,31 +1412,31 @@ function Ou() {
|
|
|
1399
1412
|
Qe = 1;
|
|
1400
1413
|
const e = kt(), t = Tu(), n = {}, s = Object.keys(e);
|
|
1401
1414
|
function u(r) {
|
|
1402
|
-
const
|
|
1403
|
-
const a =
|
|
1404
|
-
return a == null ? a : (a.length > 1 && (
|
|
1415
|
+
const o = function(...D) {
|
|
1416
|
+
const a = D[0];
|
|
1417
|
+
return a == null ? a : (a.length > 1 && (D = a), r(D));
|
|
1405
1418
|
};
|
|
1406
|
-
return "conversion" in r && (
|
|
1419
|
+
return "conversion" in r && (o.conversion = r.conversion), o;
|
|
1407
1420
|
}
|
|
1408
1421
|
function i(r) {
|
|
1409
|
-
const
|
|
1410
|
-
const a =
|
|
1422
|
+
const o = function(...D) {
|
|
1423
|
+
const a = D[0];
|
|
1411
1424
|
if (a == null)
|
|
1412
1425
|
return a;
|
|
1413
|
-
a.length > 1 && (
|
|
1414
|
-
const l = r(
|
|
1426
|
+
a.length > 1 && (D = a);
|
|
1427
|
+
const l = r(D);
|
|
1415
1428
|
if (typeof l == "object")
|
|
1416
1429
|
for (let c = l.length, h = 0; h < c; h++)
|
|
1417
1430
|
l[h] = Math.round(l[h]);
|
|
1418
1431
|
return l;
|
|
1419
1432
|
};
|
|
1420
|
-
return "conversion" in r && (
|
|
1433
|
+
return "conversion" in r && (o.conversion = r.conversion), o;
|
|
1421
1434
|
}
|
|
1422
1435
|
return s.forEach((r) => {
|
|
1423
1436
|
n[r] = {}, Object.defineProperty(n[r], "channels", { value: e[r].channels }), Object.defineProperty(n[r], "labels", { value: e[r].labels });
|
|
1424
|
-
const
|
|
1425
|
-
Object.keys(
|
|
1426
|
-
const l =
|
|
1437
|
+
const o = t(r);
|
|
1438
|
+
Object.keys(o).forEach((a) => {
|
|
1439
|
+
const l = o[a];
|
|
1427
1440
|
n[r][a] = i(l), n[r][a].raw = u(l);
|
|
1428
1441
|
});
|
|
1429
1442
|
}), Ee = n, Ee;
|
|
@@ -1452,11 +1465,11 @@ function Mu() {
|
|
|
1452
1465
|
configurable: !0
|
|
1453
1466
|
});
|
|
1454
1467
|
};
|
|
1455
|
-
let
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1468
|
+
let o;
|
|
1469
|
+
const D = (l, c, h, f) => {
|
|
1470
|
+
o === void 0 && (o = Ou());
|
|
1458
1471
|
const g = f ? 10 : 0, d = {};
|
|
1459
|
-
for (const [C, p] of Object.entries(
|
|
1472
|
+
for (const [C, p] of Object.entries(o)) {
|
|
1460
1473
|
const F = C === "ansi16" ? "ansi" : C;
|
|
1461
1474
|
C === c ? d[F] = l(h, g) : typeof p == "object" && (d[F] = l(p[c], g));
|
|
1462
1475
|
}
|
|
@@ -1529,7 +1542,7 @@ function Mu() {
|
|
|
1529
1542
|
return Object.defineProperty(c, "codes", {
|
|
1530
1543
|
value: l,
|
|
1531
1544
|
enumerable: !1
|
|
1532
|
-
}), c.color.close = "\x1B[39m", c.bgColor.close = "\x1B[49m", r(c.color, "ansi", () =>
|
|
1545
|
+
}), c.color.close = "\x1B[39m", c.bgColor.close = "\x1B[49m", r(c.color, "ansi", () => D(t, "ansi16", u, !1)), r(c.color, "ansi256", () => D(n, "ansi256", u, !1)), r(c.color, "ansi16m", () => D(s, "rgb", i, !1)), r(c.bgColor, "ansi", () => D(t, "ansi16", u, !0)), r(c.bgColor, "ansi256", () => D(n, "ansi256", u, !0)), r(c.bgColor, "ansi16m", () => D(s, "rgb", i, !0)), c;
|
|
1533
1546
|
}
|
|
1534
1547
|
Object.defineProperty(e, "exports", {
|
|
1535
1548
|
enumerable: !0,
|
|
@@ -1544,7 +1557,7 @@ function Iu() {
|
|
|
1544
1557
|
const e = Uu(), t = xt(), n = Mu(), s = /* @__PURE__ */ new Set([
|
|
1545
1558
|
"\x1B",
|
|
1546
1559
|
""
|
|
1547
|
-
]), u = 39, i = (l) => `${s.values().next().value}[${l}m`, r = (l) => l.split(" ").map((c) => e(c)),
|
|
1560
|
+
]), u = 39, i = (l) => `${s.values().next().value}[${l}m`, r = (l) => l.split(" ").map((c) => e(c)), o = (l, c, h) => {
|
|
1548
1561
|
const f = [...c];
|
|
1549
1562
|
let g = !1, d = e(t(l[l.length - 1]));
|
|
1550
1563
|
for (const [C, p] of f.entries()) {
|
|
@@ -1558,7 +1571,7 @@ function Iu() {
|
|
|
1558
1571
|
g || (d += F, d === h && C < f.length - 1 && (l.push(""), d = 0));
|
|
1559
1572
|
}
|
|
1560
1573
|
!d && l[l.length - 1].length > 0 && l.length > 1 && (l[l.length - 2] += l.pop());
|
|
1561
|
-
},
|
|
1574
|
+
}, D = (l) => {
|
|
1562
1575
|
const c = l.split(" ");
|
|
1563
1576
|
let h = c.length;
|
|
1564
1577
|
for (; h > 0 && !(e(c[h - 1]) > 0); )
|
|
@@ -1575,23 +1588,23 @@ function Iu() {
|
|
|
1575
1588
|
let E = e(p[p.length - 1]);
|
|
1576
1589
|
if (F !== 0 && (E >= c && (h.wordWrap === !1 || h.trim === !1) && (p.push(""), E = 0), (E > 0 || h.trim === !1) && (p[p.length - 1] += " ", E++)), h.hard && C[F] > c) {
|
|
1577
1590
|
const B = c - E, N = 1 + Math.floor((C[F] - B - 1) / c);
|
|
1578
|
-
Math.floor((C[F] - 1) / c) < N && p.push(""),
|
|
1591
|
+
Math.floor((C[F] - 1) / c) < N && p.push(""), o(p, m, c);
|
|
1579
1592
|
continue;
|
|
1580
1593
|
}
|
|
1581
1594
|
if (E + C[F] > c && E > 0 && C[F] > 0) {
|
|
1582
1595
|
if (h.wordWrap === !1 && E < c) {
|
|
1583
|
-
|
|
1596
|
+
o(p, m, c);
|
|
1584
1597
|
continue;
|
|
1585
1598
|
}
|
|
1586
1599
|
p.push("");
|
|
1587
1600
|
}
|
|
1588
1601
|
if (E + C[F] > c && h.wordWrap === !1) {
|
|
1589
|
-
|
|
1602
|
+
o(p, m, c);
|
|
1590
1603
|
continue;
|
|
1591
1604
|
}
|
|
1592
1605
|
p[p.length - 1] += m;
|
|
1593
1606
|
}
|
|
1594
|
-
h.trim !== !1 && (p = p.map(
|
|
1607
|
+
h.trim !== !1 && (p = p.map(D)), f = p.join(`
|
|
1595
1608
|
`);
|
|
1596
1609
|
for (const [F, m] of [...f].entries()) {
|
|
1597
1610
|
if (g += m, s.has(m)) {
|
|
@@ -1625,16 +1638,16 @@ function ju({ active: e, renderedItems: t, pageSize: n, loop: s }) {
|
|
|
1625
1638
|
const u = $e({
|
|
1626
1639
|
lastPointer: e,
|
|
1627
1640
|
lastActive: void 0
|
|
1628
|
-
}), { lastPointer: i, lastActive: r } = u.current,
|
|
1641
|
+
}), { lastPointer: i, lastActive: r } = u.current, o = Math.floor(n / 2), D = t.reduce((c, h) => c + h.length, 0), a = t.slice(0, e).reduce((c, h) => c + h.length, 0);
|
|
1629
1642
|
let l = a;
|
|
1630
|
-
if (
|
|
1643
|
+
if (D > n)
|
|
1631
1644
|
if (s)
|
|
1632
1645
|
l = i, // First render, skip this logic.
|
|
1633
1646
|
r != null && // Only move the pointer down when the user moves down.
|
|
1634
1647
|
r < e && // Check user didn't move up across page boundary.
|
|
1635
1648
|
e - r < n && (l = Math.min(
|
|
1636
1649
|
// Furthest allowed position for the pointer is the middle of the list
|
|
1637
|
-
|
|
1650
|
+
o,
|
|
1638
1651
|
Math.abs(e - r) === 1 ? Math.min(
|
|
1639
1652
|
// Move the pointer at most the height of the last active item.
|
|
1640
1653
|
i + (t[r]?.length ?? 0),
|
|
@@ -1648,27 +1661,27 @@ function ju({ active: e, renderedItems: t, pageSize: n, loop: s }) {
|
|
|
1648
1661
|
));
|
|
1649
1662
|
else {
|
|
1650
1663
|
const c = t.slice(e).reduce((h, f) => h + f.length, 0);
|
|
1651
|
-
l = c < n -
|
|
1664
|
+
l = c < n - o ? (
|
|
1652
1665
|
// If the active item is near the end of the list, progressively move the cursor towards the end.
|
|
1653
1666
|
n - c
|
|
1654
1667
|
) : (
|
|
1655
1668
|
// Otherwise, progressively move the pointer to the middle of the list.
|
|
1656
|
-
Math.min(a,
|
|
1669
|
+
Math.min(a, o)
|
|
1657
1670
|
);
|
|
1658
1671
|
}
|
|
1659
1672
|
return u.current.lastPointer = l, u.current.lastActive = e, l;
|
|
1660
1673
|
}
|
|
1661
1674
|
function qu({ items: e, active: t, renderItem: n, pageSize: s, loop: u = !0 }) {
|
|
1662
|
-
const i = At(), r = (p) => (p % e.length + e.length) % e.length,
|
|
1663
|
-
`)),
|
|
1675
|
+
const i = At(), r = (p) => (p % e.length + e.length) % e.length, o = e.map((p, F) => p == null ? [] : xe(n({ item: p, index: F, isActive: F === t }), i).split(`
|
|
1676
|
+
`)), D = o.reduce((p, F) => p + F.length, 0), a = (p) => o[p] ?? [], l = ju({ active: t, renderedItems: o, pageSize: s, loop: u }), c = a(t).slice(0, s), h = l + c.length <= s ? l : s - c.length, f = Array.from({ length: s });
|
|
1664
1677
|
f.splice(h, c.length, ...c);
|
|
1665
1678
|
const g = /* @__PURE__ */ new Set([t]);
|
|
1666
1679
|
let d = h + c.length, C = r(t + 1);
|
|
1667
|
-
for (; d < s && !g.has(C) && (u &&
|
|
1680
|
+
for (; d < s && !g.has(C) && (u && D > s ? C !== t : C > t); ) {
|
|
1668
1681
|
const F = a(C).slice(0, s - d);
|
|
1669
1682
|
f.splice(d, F.length, ...F), g.add(C), d += F.length, C = r(C + 1);
|
|
1670
1683
|
}
|
|
1671
|
-
for (d = h - 1, C = r(t - 1); d >= 0 && !g.has(C) && (u &&
|
|
1684
|
+
for (d = h - 1, C = r(t - 1); d >= 0 && !g.has(C) && (u && D > s ? C !== t : C < t); ) {
|
|
1672
1685
|
const p = a(C), F = p.slice(Math.max(0, p.length - d - 1));
|
|
1673
1686
|
f.splice(d - F.length + 1, F.length, ...F), g.add(C), d -= F.length, C = r(C - 1);
|
|
1674
1687
|
}
|
|
@@ -1851,8 +1864,8 @@ class Yu extends St {
|
|
|
1851
1864
|
const i = t;
|
|
1852
1865
|
if (typeof i.__signal_exit_emitter__ == "object" && typeof i.__signal_exit_emitter__.count == "number" && (u += i.__signal_exit_emitter__.count), s.length === u) {
|
|
1853
1866
|
this.unload();
|
|
1854
|
-
const r = this.#t.emit("exit", null, n),
|
|
1855
|
-
r || t.kill(t.pid,
|
|
1867
|
+
const r = this.#t.emit("exit", null, n), o = n === "SIGHUP" ? this.#u : n;
|
|
1868
|
+
r || t.kill(t.pid, o);
|
|
1856
1869
|
}
|
|
1857
1870
|
};
|
|
1858
1871
|
this.#i = t.reallyExit, this.#s = t.emit;
|
|
@@ -1876,7 +1889,7 @@ class Yu extends St {
|
|
|
1876
1889
|
n && this.#e.on(t, n);
|
|
1877
1890
|
} catch {
|
|
1878
1891
|
}
|
|
1879
|
-
this.#e.emit = (t, ...n) => this.#
|
|
1892
|
+
this.#e.emit = (t, ...n) => this.#D(t, ...n), this.#e.reallyExit = (t) => this.#o(t);
|
|
1880
1893
|
}
|
|
1881
1894
|
}
|
|
1882
1895
|
unload() {
|
|
@@ -1890,10 +1903,10 @@ class Yu extends St {
|
|
|
1890
1903
|
}
|
|
1891
1904
|
}), this.#e.emit = this.#s, this.#e.reallyExit = this.#i, this.#t.count -= 1);
|
|
1892
1905
|
}
|
|
1893
|
-
#
|
|
1906
|
+
#o(t) {
|
|
1894
1907
|
return ne(this.#e) ? (this.#e.exitCode = t || 0, this.#t.emit("exit", this.#e.exitCode, null), this.#i.call(this.#e, this.#e.exitCode)) : 0;
|
|
1895
1908
|
}
|
|
1896
|
-
#
|
|
1909
|
+
#D(t, ...n) {
|
|
1897
1910
|
const s = this.#s;
|
|
1898
1911
|
if (t === "exit" && ne(this.#e)) {
|
|
1899
1912
|
typeof n[0] == "number" && (this.#e.exitCode = n[0]);
|
|
@@ -1936,10 +1949,10 @@ class tn {
|
|
|
1936
1949
|
const r = At();
|
|
1937
1950
|
t = xe(t, r), n = xe(n, r), u.length % r === 0 && (t += `
|
|
1938
1951
|
`);
|
|
1939
|
-
let
|
|
1952
|
+
let o = t + (n ? `
|
|
1940
1953
|
` + n : "");
|
|
1941
1954
|
const a = Math.floor(u.length / r) - this.cursorPos.rows + (n ? it(n) : 0);
|
|
1942
|
-
a > 0 && (
|
|
1955
|
+
a > 0 && (o += vt(a)), o += nt(this.cursorPos.cols), this.write(ut(this.extraLinesUnderPrompt) + st(this.height) + o), this.extraLinesUnderPrompt = a, this.height = it(o);
|
|
1943
1956
|
}
|
|
1944
1957
|
checkCursorPos() {
|
|
1945
1958
|
const t = this.rl.getCursorPos();
|
|
@@ -1978,28 +1991,28 @@ function nn() {
|
|
|
1978
1991
|
function Oe(e) {
|
|
1979
1992
|
const t = nn();
|
|
1980
1993
|
return (s, u = {}) => {
|
|
1981
|
-
const { input: i = process.stdin, signal: r } = u,
|
|
1982
|
-
|
|
1994
|
+
const { input: i = process.stdin, signal: r } = u, o = /* @__PURE__ */ new Set(), D = new Wu();
|
|
1995
|
+
D.pipe(u.output ?? process.stdout);
|
|
1983
1996
|
const a = Mt.createInterface({
|
|
1984
1997
|
terminal: !0,
|
|
1985
1998
|
input: i,
|
|
1986
|
-
output:
|
|
1999
|
+
output: D
|
|
1987
2000
|
}), l = new tn(a), { promise: c, resolve: h, reject: f } = un.withResolver(), g = () => f(new hu());
|
|
1988
2001
|
if (r) {
|
|
1989
2002
|
const p = () => f(new cu({ cause: r.reason }));
|
|
1990
2003
|
if (r.aborted)
|
|
1991
2004
|
return p(), Object.assign(c, { cancel: g });
|
|
1992
|
-
r.addEventListener("abort", p),
|
|
2005
|
+
r.addEventListener("abort", p), o.add(() => r.removeEventListener("abort", p));
|
|
1993
2006
|
}
|
|
1994
|
-
|
|
2007
|
+
o.add(Zu((p, F) => {
|
|
1995
2008
|
f(new je(`User force closed the prompt with ${p} ${F}`));
|
|
1996
2009
|
}));
|
|
1997
2010
|
const d = () => f(new je("User force closed the prompt with SIGINT"));
|
|
1998
|
-
a.on("SIGINT", d),
|
|
2011
|
+
a.on("SIGINT", d), o.add(() => a.removeListener("SIGINT", d));
|
|
1999
2012
|
const C = () => l.checkCursorPos();
|
|
2000
|
-
return a.input.on("keypress", C),
|
|
2013
|
+
return a.input.on("keypress", C), o.add(() => a.input.removeListener("keypress", C)), pu(a, (p) => {
|
|
2001
2014
|
const F = Se.bind(() => Y.clearAll());
|
|
2002
|
-
return a.on("close", F),
|
|
2015
|
+
return a.on("close", F), o.add(() => a.removeListener("close", F)), p(() => {
|
|
2003
2016
|
try {
|
|
2004
2017
|
const m = e(s, (N) => {
|
|
2005
2018
|
setImmediate(() => h(N));
|
|
@@ -2017,7 +2030,7 @@ function Oe(e) {
|
|
|
2017
2030
|
}), Object.assign(c.then((m) => (Y.clearAll(), m), (m) => {
|
|
2018
2031
|
throw Y.clearAll(), m;
|
|
2019
2032
|
}).finally(() => {
|
|
2020
|
-
|
|
2033
|
+
o.forEach((m) => m()), l.done({ clearContent: !!u.clearPromptOnDone }), D.end();
|
|
2021
2034
|
}).then(() => c), { cancel: g });
|
|
2022
2035
|
});
|
|
2023
2036
|
};
|
|
@@ -2032,34 +2045,34 @@ class Z {
|
|
|
2032
2045
|
return !!(t && typeof t == "object" && "type" in t && t.type === "separator");
|
|
2033
2046
|
}
|
|
2034
2047
|
}
|
|
2035
|
-
function
|
|
2048
|
+
function ot(e, t) {
|
|
2036
2049
|
let n = t !== !1;
|
|
2037
2050
|
return /^(y|yes)/i.test(e) ? n = !0 : /^(n|no)/i.test(e) && (n = !1), n;
|
|
2038
2051
|
}
|
|
2039
|
-
function
|
|
2052
|
+
function Dt(e) {
|
|
2040
2053
|
return e ? "Yes" : "No";
|
|
2041
2054
|
}
|
|
2042
2055
|
const rn = Oe((e, t) => {
|
|
2043
|
-
const { transformer: n =
|
|
2056
|
+
const { transformer: n = Dt } = e, [s, u] = A("idle"), [i, r] = A(""), o = oe(e.theme), D = Ue({ status: s, theme: o });
|
|
2044
2057
|
Te((h, f) => {
|
|
2045
2058
|
if (s === "idle")
|
|
2046
2059
|
if (ve(h)) {
|
|
2047
|
-
const g =
|
|
2060
|
+
const g = ot(i, e.default);
|
|
2048
2061
|
r(n(g)), u("done"), t(g);
|
|
2049
2062
|
} else if (Ct(h)) {
|
|
2050
|
-
const g =
|
|
2063
|
+
const g = Dt(!ot(i, e.default));
|
|
2051
2064
|
f.clearLine(0), f.write(g), r(g);
|
|
2052
2065
|
} else
|
|
2053
2066
|
r(f.line);
|
|
2054
2067
|
});
|
|
2055
2068
|
let a = i, l = "";
|
|
2056
|
-
s === "done" ? a =
|
|
2057
|
-
const c =
|
|
2058
|
-
return `${
|
|
2069
|
+
s === "done" ? a = o.style.answer(i) : l = ` ${o.style.defaultAnswer(e.default === !1 ? "y/N" : "Y/n")}`;
|
|
2070
|
+
const c = o.style.message(e.message, s);
|
|
2071
|
+
return `${D} ${c}${l} ${a}`;
|
|
2059
2072
|
}), sn = {
|
|
2060
2073
|
validationFailureMode: "keep"
|
|
2061
|
-
},
|
|
2062
|
-
const { prefill: n = "tab" } = e, s =
|
|
2074
|
+
}, on = Oe((e, t) => {
|
|
2075
|
+
const { prefill: n = "tab" } = e, s = oe(sn, e.theme), [u, i] = A("idle"), [r = "", o] = A(e.default), [D, a] = A(), [l, c] = A(""), h = Ue({ status: u, theme: s });
|
|
2063
2076
|
async function f(F) {
|
|
2064
2077
|
const { required: m, pattern: E, patternError: B = "Invalid input" } = e;
|
|
2065
2078
|
return m && !F ? "You must provide a value" : E && !E.test(F) ? B : typeof e.validate == "function" ? await e.validate(F) || "You must provide a valid value" : !0;
|
|
@@ -2071,7 +2084,7 @@ const rn = Oe((e, t) => {
|
|
|
2071
2084
|
i("loading");
|
|
2072
2085
|
const B = await f(E);
|
|
2073
2086
|
B === !0 ? (c(E), i("done"), t(E)) : (s.validationFailureMode === "clear" ? c("") : m.write(l), a(B), i("idle"));
|
|
2074
|
-
} else gt(F) && !l ?
|
|
2087
|
+
} else gt(F) && !l ? o(void 0) : Ct(F) && !l ? (o(void 0), m.clearLine(0), m.write(r), c(r)) : (c(m.line), a(void 0));
|
|
2075
2088
|
}), se((F) => {
|
|
2076
2089
|
n === "editable" && r && (F.write(r), c(r));
|
|
2077
2090
|
}, []);
|
|
@@ -2081,11 +2094,11 @@ const rn = Oe((e, t) => {
|
|
|
2081
2094
|
let C;
|
|
2082
2095
|
r && u !== "done" && !l && (C = s.style.defaultAnswer(r));
|
|
2083
2096
|
let p = "";
|
|
2084
|
-
return
|
|
2097
|
+
return D && (p = s.style.error(D)), [
|
|
2085
2098
|
[h, g, C, d].filter((F) => F !== void 0).join(" "),
|
|
2086
2099
|
p
|
|
2087
2100
|
];
|
|
2088
|
-
}),
|
|
2101
|
+
}), Dn = {
|
|
2089
2102
|
icon: { cursor: Re.pointer },
|
|
2090
2103
|
style: {
|
|
2091
2104
|
disabled: (e) => y.dim(`- ${e}`),
|
|
@@ -2120,7 +2133,7 @@ function ln(e) {
|
|
|
2120
2133
|
});
|
|
2121
2134
|
}
|
|
2122
2135
|
const an = Oe((e, t) => {
|
|
2123
|
-
const { loop: n = !0, pageSize: s = 7 } = e, u =
|
|
2136
|
+
const { loop: n = !0, pageSize: s = 7 } = e, u = oe(Dn, e.theme), { keybindings: i } = u, [r, o] = A("idle"), D = Ue({ status: r, theme: u }), a = $e(), l = !i.includes("vim"), c = he(() => ln(e.choices), [e.choices]), h = he(() => {
|
|
2124
2137
|
const b = c.findIndex(G), x = c.findLastIndex(G);
|
|
2125
2138
|
if (b === -1)
|
|
2126
2139
|
throw new mt("[select prompt] No selectable choices. All choices are disabled.");
|
|
@@ -2128,7 +2141,7 @@ const an = Oe((e, t) => {
|
|
|
2128
2141
|
}, [c]), f = he(() => "default" in e ? c.findIndex((b) => G(b) && b.value === e.default) : -1, [e.default, c]), [g, d] = A(f === -1 ? h.first : f), C = c[g];
|
|
2129
2142
|
Te((b, x) => {
|
|
2130
2143
|
if (clearTimeout(a.current), ve(b))
|
|
2131
|
-
|
|
2144
|
+
o("done"), t(C.value);
|
|
2132
2145
|
else if (ae(b, i) || Pe(b, i)) {
|
|
2133
2146
|
if (x.clearLine(0), n || ae(b, i) && g !== h.first || Pe(b, i) && g !== h.last) {
|
|
2134
2147
|
const _ = ae(b, i) ? -1 : 1;
|
|
@@ -2186,17 +2199,17 @@ const an = Oe((e, t) => {
|
|
|
2186
2199
|
loop: n
|
|
2187
2200
|
});
|
|
2188
2201
|
if (r === "done")
|
|
2189
|
-
return [
|
|
2202
|
+
return [D, p, u.style.answer(C.short)].filter(Boolean).join(" ");
|
|
2190
2203
|
const { description: B } = C;
|
|
2191
2204
|
return `${[
|
|
2192
|
-
[
|
|
2205
|
+
[D, p].filter(Boolean).join(" "),
|
|
2193
2206
|
E,
|
|
2194
2207
|
" ",
|
|
2195
2208
|
B ? u.style.description(B) : "",
|
|
2196
2209
|
F
|
|
2197
2210
|
].filter(Boolean).join(`
|
|
2198
2211
|
`).trimEnd()}${Qu}`;
|
|
2199
|
-
}), R = async (e, t) => rn({ message: e, default: t }), J = async (e, t) =>
|
|
2212
|
+
}), R = async (e, t) => rn({ message: e, default: t }), J = async (e, t) => on({ message: e, default: t }), cn = async (e, t) => an({
|
|
2200
2213
|
message: e,
|
|
2201
2214
|
choices: t.map((n) => ({ name: n, value: n }))
|
|
2202
2215
|
}), hn = async (e, t) => {
|
|
@@ -2233,10 +2246,10 @@ const an = Oe((e, t) => {
|
|
|
2233
2246
|
$(1, "Check for existing SSH keys", w.step1);
|
|
2234
2247
|
const u = Yt(t);
|
|
2235
2248
|
if (u.length > 0) {
|
|
2236
|
-
const f = u.map((d) =>
|
|
2249
|
+
const f = u.map((d) => De(d));
|
|
2237
2250
|
if (O("Found existing public keys:"), lu(f), await R("Reuse an existing key", !1)) {
|
|
2238
2251
|
const d = await cn("Select a key", f), p = I(t, d).replace(/\.pub$/, "");
|
|
2239
|
-
M(p) ? (n = p, await T(), $(2, "Use existing SSH key", w.step2), W(`Using ${
|
|
2252
|
+
M(p) ? (n = p, await T(), $(2, "Use existing SSH key", w.step2), W(`Using ${De(p)}`)) : v(`Private key not found at ${p}.`);
|
|
2240
2253
|
}
|
|
2241
2254
|
} else
|
|
2242
2255
|
O("No existing public keys found in ~/.ssh.");
|
|
@@ -2259,7 +2272,7 @@ const an = Oe((e, t) => {
|
|
|
2259
2272
|
!m && d === "ed25519" ? await R(
|
|
2260
2273
|
"ed25519 failed. Try rsa 4096 instead",
|
|
2261
2274
|
!0
|
|
2262
|
-
) ? Ie(F, g, "rsa") || (P("Failed to generate RSA key."), process.exit(1)) : process.exit(1) : m || (P("Failed to generate SSH key."), process.exit(1)), n = F, W(`Key ready: ${
|
|
2275
|
+
) ? Ie(F, g, "rsa") || (P("Failed to generate RSA key."), process.exit(1)) : process.exit(1) : m || (P("Failed to generate SSH key."), process.exit(1)), n = F, W(`Key ready: ${De(F)}`);
|
|
2263
2276
|
}
|
|
2264
2277
|
n || (P("No SSH key selected. Exiting."), process.exit(1));
|
|
2265
2278
|
const i = `${n}.pub`;
|
|
@@ -2321,7 +2334,7 @@ const an = Oe((e, t) => {
|
|
|
2321
2334
|
console.log(n ?? "unknown");
|
|
2322
2335
|
return;
|
|
2323
2336
|
}
|
|
2324
|
-
|
|
2337
|
+
Du(), O(`This tool will guide you through ${at} steps.`), process.platform !== "darwin" && v("This workflow is optimized for macOS."), await dn(e);
|
|
2325
2338
|
};
|
|
2326
2339
|
pn().catch((e) => {
|
|
2327
2340
|
const t = e instanceof Error ? e.message : String(e);
|