pyre-cli 5.1.0 → 6.0.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/dist/index.js +519 -223
- package/package.json +1 -1
- package/src/formatters/index.ts +1 -1
- package/src/formatters/output.ts +14 -13
- package/src/formatters/render.ts +296 -114
- package/src/formatters/types.ts +6 -1
- package/src/index.ts +40 -20
- package/src/live/input.ts +6 -5
- package/src/live/render.ts +63 -54
- package/src/live/types.ts +6 -1
- package/src/monitors/collectors.ts +119 -34
- package/src/monitors/smc.ts +60 -12
- package/src/p2p/server.test.ts +2 -2
- package/src/sparkline.ts +82 -13
- package/Formula/pyre.rb +0 -19
package/src/sparkline.ts
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
const BLOCKS = '
|
|
1
|
+
const BLOCKS = ' ▂▃▄▅▆▇█';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Render a series of numbers as a compact unicode sparkline.
|
|
5
5
|
*
|
|
6
6
|
* Values are normalised against `min`/`max` (auto-computed
|
|
7
|
-
* from the data if not supplied).
|
|
7
|
+
* from the data if not supplied). The output uses eight
|
|
8
8
|
* Unicode block characters to represent the range, making
|
|
9
9
|
* it suitable for inline terminal graphs.
|
|
10
|
-
*
|
|
11
|
-
* @param values - Numeric series to render.
|
|
12
|
-
* @param opts.min - Minimum value for normalisation.
|
|
13
|
-
* @param opts.max - Maximum value for normalisation.
|
|
14
|
-
* @returns A string of block characters whose length equals `values.length`.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* sparkline([10, 20, 15, 30, 25]); // "▁▂▃▅▄"
|
|
19
|
-
* ```
|
|
20
10
|
*/
|
|
21
11
|
export function sparkline(values: number[], opts: { min?: number; max?: number } = {}): string {
|
|
22
12
|
if (!values.length) return '';
|
|
@@ -37,4 +27,83 @@ export function sparkline(values: number[], opts: { min?: number; max?: number }
|
|
|
37
27
|
return BLOCKS[clamped];
|
|
38
28
|
})
|
|
39
29
|
.join('');
|
|
40
|
-
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Render a multi-row unicode sparkline area graph.
|
|
34
|
+
* Returns an array of strings representing each row from top to bottom.
|
|
35
|
+
*/
|
|
36
|
+
export function multiRowSparkline(
|
|
37
|
+
values: number[],
|
|
38
|
+
height: number,
|
|
39
|
+
opts: { min?: number; max?: number } = {}
|
|
40
|
+
): string[] {
|
|
41
|
+
if (!values.length || height <= 0) return Array(height).fill('');
|
|
42
|
+
let min = opts.min ?? Infinity;
|
|
43
|
+
let max = opts.max ?? -Infinity;
|
|
44
|
+
if (opts.min === undefined || opts.max === undefined) {
|
|
45
|
+
for (const v of values) {
|
|
46
|
+
if (v < min) min = v;
|
|
47
|
+
if (v > max) max = v;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const range = max - min || 1;
|
|
51
|
+
const levels = height * 8;
|
|
52
|
+
|
|
53
|
+
const rows: string[][] = Array.from({ length: height }, () => []);
|
|
54
|
+
|
|
55
|
+
for (const v of values) {
|
|
56
|
+
const rawSteps = Math.round(((v - min) / range) * levels);
|
|
57
|
+
const totalSteps = Math.min(levels, Math.max(0, rawSteps));
|
|
58
|
+
|
|
59
|
+
for (let r = 0; r < height; r++) {
|
|
60
|
+
const rowFromBottom = height - 1 - r;
|
|
61
|
+
const minForThisRow = rowFromBottom * 8;
|
|
62
|
+
const stepsInThisRow = Math.min(8, Math.max(0, totalSteps - minForThisRow));
|
|
63
|
+
|
|
64
|
+
if (stepsInThisRow === 0) {
|
|
65
|
+
rows[r].push(' ');
|
|
66
|
+
} else {
|
|
67
|
+
rows[r].push(BLOCKS[stepsInThisRow]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return rows.map(r => r.join(''));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Render values as a high-density braille sparkline string.
|
|
77
|
+
*/
|
|
78
|
+
export function brailleGraph(values: number[], opts: { min?: number; max?: number } = {}): string {
|
|
79
|
+
if (!values.length) return '';
|
|
80
|
+
let min = opts.min ?? Infinity;
|
|
81
|
+
let max = opts.max ?? -Infinity;
|
|
82
|
+
if (opts.min === undefined || opts.max === undefined) {
|
|
83
|
+
for (const v of values) {
|
|
84
|
+
if (v < min) min = v;
|
|
85
|
+
if (v > max) max = v;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const range = max - min || 1;
|
|
89
|
+
|
|
90
|
+
const dotsCol0 = [0x40, 0x04, 0x02, 0x01]; // bottom to top
|
|
91
|
+
const dotsCol1 = [0x80, 0x20, 0x10, 0x08]; // bottom to top
|
|
92
|
+
|
|
93
|
+
let result = '';
|
|
94
|
+
for (let i = 0; i < values.length; i += 2) {
|
|
95
|
+
const v0 = values[i];
|
|
96
|
+
const v1 = i + 1 < values.length ? values[i + 1] : v0;
|
|
97
|
+
|
|
98
|
+
const fill0 = Math.min(4, Math.max(0, Math.round(((v0 - min) / range) * 4)));
|
|
99
|
+
const fill1 = Math.min(4, Math.max(0, Math.round(((v1 - min) / range) * 4)));
|
|
100
|
+
|
|
101
|
+
let code = 0x2800;
|
|
102
|
+
for (let d = 0; d < fill0; d++) code |= dotsCol0[d];
|
|
103
|
+
for (let d = 0; d < fill1; d++) code |= dotsCol1[d];
|
|
104
|
+
|
|
105
|
+
result += String.fromCharCode(code);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return result;
|
|
109
|
+
}
|
package/Formula/pyre.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
class Pyre < Formula
|
|
2
|
-
desc "Mac system monitoring CLI: temps, CPU, memory, disk, battery, live dashboard"
|
|
3
|
-
homepage "https://github.com/somalip/pyre"
|
|
4
|
-
url "https://github.com/somalip/pyre/archive/refs/tags/v1.0.0.tar.gz"
|
|
5
|
-
sha256 "0000000000000000000000000000000000000000000000000000000000000000"
|
|
6
|
-
license "MIT"
|
|
7
|
-
|
|
8
|
-
depends_on "node"
|
|
9
|
-
|
|
10
|
-
def install
|
|
11
|
-
system "npm", "install", "--cache=#{buildpath}/.npm"
|
|
12
|
-
system "npm", "run", "build"
|
|
13
|
-
bin.install "dist/index.js" => "pyre"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
test do
|
|
17
|
-
assert_match "PYRE", shell_output("#{bin}/pyre --help")
|
|
18
|
-
end
|
|
19
|
-
end
|