@hardkas/cli 0.2.1-alpha → 0.2.2-alpha.1
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/{accounts-keystore-runners-CVRE6NVM.js → accounts-keystore-runners-MCJIAGZ4.js} +1 -1
- package/dist/{artifact-lineage-runner-EPT6ABS2.js → artifact-lineage-runner-RJWQ3R3X.js} +1 -1
- package/dist/{chunk-M54KNJEH.js → chunk-AQWQW5ZG.js} +33 -10
- package/dist/{dag-runners-BQAKJ6DM.js → dag-runners-YQDHD7U6.js} +1 -1
- package/dist/index.js +550 -175
- package/dist/{replay-verify-runner-WBK2FCWC.js → replay-verify-runner-UMYALHNT.js} +1 -1
- package/dist/{rpc-doctor-runner-RKGKFGMM.js → rpc-doctor-runner-ERWXOXSE.js} +1 -1
- package/dist/{snapshot-restore-runner-P26HDE74.js → snapshot-restore-runner-QNAADGBX.js} +1 -1
- package/dist/{snapshot-verify-runner-UYTXXQ7A.js → snapshot-verify-runner-BWRW3NUW.js} +1 -1
- package/dist/{tx-verify-runner-GPPVBQIF.js → tx-verify-runner-Z5M2JDRI.js} +1 -1
- package/dist/{ui-DXULTF7Q.js → ui-OVK5PX6H.js} +1 -1
- package/package.json +16 -16
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// src/ui.ts
|
|
2
2
|
import pc from "picocolors";
|
|
3
|
-
import { formatSompi } from "@hardkas/core";
|
|
3
|
+
import { formatSompi, maskSecrets } from "@hardkas/core";
|
|
4
4
|
var UI = {
|
|
5
5
|
header(text) {
|
|
6
|
+
const masked = maskSecrets(text);
|
|
6
7
|
console.log(pc.bold(pc.magenta(`
|
|
7
|
-
\u2550\u2550\u2550 ${
|
|
8
|
+
\u2550\u2550\u2550 ${masked} \u2550\u2550\u2550`)));
|
|
8
9
|
},
|
|
9
10
|
divider() {
|
|
10
11
|
console.log(pc.dim(" " + "\u2500".repeat(50)));
|
|
@@ -26,27 +27,48 @@ var UI = {
|
|
|
26
27
|
console.log("");
|
|
27
28
|
},
|
|
28
29
|
warning(text) {
|
|
30
|
+
const masked = maskSecrets(text);
|
|
29
31
|
console.log(pc.yellow(`
|
|
30
32
|
\u26A0\uFE0F WARNING:`));
|
|
31
|
-
console.log(pc.yellow(` ${
|
|
33
|
+
console.log(pc.yellow(` ${masked}`));
|
|
32
34
|
},
|
|
33
35
|
error(msg, suggestion) {
|
|
36
|
+
const maskedMsg = maskSecrets(msg);
|
|
37
|
+
const maskedSuggestion = suggestion ? maskSecrets(suggestion) : void 0;
|
|
34
38
|
console.error(pc.red(`
|
|
35
39
|
\u2717 Error:`));
|
|
36
|
-
console.error(pc.red(` ${
|
|
37
|
-
if (
|
|
40
|
+
console.error(pc.red(` ${maskedMsg}`));
|
|
41
|
+
if (maskedSuggestion) {
|
|
38
42
|
console.error(pc.cyan(`
|
|
39
43
|
\u{1F4A1} Suggestion:`));
|
|
40
|
-
console.error(pc.cyan(` ${
|
|
44
|
+
console.error(pc.cyan(` ${maskedSuggestion}`));
|
|
41
45
|
}
|
|
42
46
|
},
|
|
43
47
|
field(label, value) {
|
|
44
|
-
const val = value === void 0 || value === null ? pc.dim("none") : String(value);
|
|
48
|
+
const val = value === void 0 || value === null ? pc.dim("none") : maskSecrets(String(value));
|
|
45
49
|
console.log(` ${pc.dim(label.padEnd(16))} ${pc.white(val)}`);
|
|
46
50
|
},
|
|
47
51
|
kas(label, sompi) {
|
|
48
52
|
this.field(label, pc.cyan(formatSompi(BigInt(sompi))));
|
|
49
53
|
},
|
|
54
|
+
maturity(label) {
|
|
55
|
+
const colors = {
|
|
56
|
+
stable: pc.green,
|
|
57
|
+
preview: pc.blue,
|
|
58
|
+
experimental: pc.yellow,
|
|
59
|
+
research: pc.magenta,
|
|
60
|
+
internal: pc.dim
|
|
61
|
+
};
|
|
62
|
+
const color = colors[label.toLowerCase()] || pc.white;
|
|
63
|
+
return color(label.toLowerCase());
|
|
64
|
+
},
|
|
65
|
+
async confirm(message) {
|
|
66
|
+
const readline = await import("readline/promises");
|
|
67
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
68
|
+
const answer = await rl.question(pc.yellow(` \u26A0\uFE0F ${message} (y/N): `));
|
|
69
|
+
rl.close();
|
|
70
|
+
return answer.toLowerCase() === "y";
|
|
71
|
+
},
|
|
50
72
|
footer(hint) {
|
|
51
73
|
if (hint) {
|
|
52
74
|
console.log(pc.dim(`
|
|
@@ -56,10 +78,11 @@ var UI = {
|
|
|
56
78
|
}
|
|
57
79
|
};
|
|
58
80
|
function handleError(e, context) {
|
|
59
|
-
const
|
|
81
|
+
const rawMsg = e instanceof Error ? e.message : String(e);
|
|
82
|
+
const msg = maskSecrets ? maskSecrets(rawMsg) : rawMsg;
|
|
60
83
|
const errorObj = e;
|
|
61
|
-
let reason = errorObj.reason;
|
|
62
|
-
let suggestion = errorObj.suggestion;
|
|
84
|
+
let reason = maskSecrets ? maskSecrets(errorObj.reason) : errorObj.reason;
|
|
85
|
+
let suggestion = maskSecrets ? maskSecrets(errorObj.suggestion) : errorObj.suggestion;
|
|
63
86
|
if (msg === "Real transaction signing is not available") {
|
|
64
87
|
console.error(`
|
|
65
88
|
${msg}`);
|