@dheerajsom/pinhub 0.1.2 → 0.2.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 → CLI.md} +53 -13
- package/LICENSE +21 -0
- package/SETUP.md +16 -5
- package/dist/boards/arduino-uno-r3.js +1 -1
- package/dist/boards/esp32-devkit-v1.js +5 -4
- package/dist/boards/generated.js +1044 -218
- package/dist/cli.js +17 -1
- package/dist/model.d.ts +3 -0
- package/dist/render/board.d.ts +4 -2
- package/dist/render/board.js +174 -96
- package/dist/render/chars.d.ts +4 -0
- package/dist/render/chars.js +8 -0
- package/dist/render/meta.d.ts +5 -5
- package/dist/render/meta.js +118 -37
- package/dist/render/text.d.ts +22 -0
- package/dist/render/text.js +163 -0
- package/dist/render/theme.js +4 -1
- package/dist/run.d.ts +4 -2
- package/dist/run.js +96 -50
- package/dist/status.d.ts +28 -0
- package/dist/status.js +63 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +5 -2
- package/package.json +17 -5
package/dist/status.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type Environment = Record<string, string | undefined>;
|
|
2
|
+
export type SignalPulseContext = {
|
|
3
|
+
stdoutIsTTY: boolean;
|
|
4
|
+
stderrIsTTY: boolean;
|
|
5
|
+
/** Width of the stream that receives the pulse, when the TTY exposes it. */
|
|
6
|
+
stderrColumns?: number;
|
|
7
|
+
env: Environment;
|
|
8
|
+
};
|
|
9
|
+
export type SignalPulseStream = {
|
|
10
|
+
write(chunk: string): unknown;
|
|
11
|
+
};
|
|
12
|
+
export declare const MIN_SIGNAL_PULSE_COLUMNS = 28;
|
|
13
|
+
export declare function hasNoColor(env: Environment): boolean;
|
|
14
|
+
export declare function isCiEnvironment(env: Environment): boolean;
|
|
15
|
+
/** Pure capability check kept separate from the deterministic runCli API. */
|
|
16
|
+
export declare function shouldAnimateSignalPulse(argv: string[], context: SignalPulseContext): boolean;
|
|
17
|
+
export declare function signalPulseLabel(argv: string[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* A deliberately brief, color-cycling pulse. It writes only to an explicitly
|
|
20
|
+
* approved TTY stream and erases itself before normal CLI output is emitted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function playSignalPulse(stream: SignalPulseStream, options: {
|
|
23
|
+
ascii: boolean;
|
|
24
|
+
label: string;
|
|
25
|
+
intervalMs?: number;
|
|
26
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
export {};
|
package/dist/status.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
2
|
+
import { makeChalk } from "./render/theme.js";
|
|
3
|
+
// The longest built-in pulse is 24 cells (glyph, space, and label). Keep a
|
|
4
|
+
// small margin so terminals that eagerly wrap in their final column never
|
|
5
|
+
// leave a ghost line behind.
|
|
6
|
+
export const MIN_SIGNAL_PULSE_COLUMNS = 28;
|
|
7
|
+
export function hasNoColor(env) {
|
|
8
|
+
return Object.prototype.hasOwnProperty.call(env, "NO_COLOR");
|
|
9
|
+
}
|
|
10
|
+
export function isCiEnvironment(env) {
|
|
11
|
+
const value = env.CI;
|
|
12
|
+
if (value !== undefined && value !== "" && !/^(?:0|false)$/i.test(value))
|
|
13
|
+
return true;
|
|
14
|
+
return Boolean(env.GITHUB_ACTIONS || env.BUILDKITE || env.TF_BUILD || env.TEAMCITY_VERSION);
|
|
15
|
+
}
|
|
16
|
+
/** Pure capability check kept separate from the deterministic runCli API. */
|
|
17
|
+
export function shouldAnimateSignalPulse(argv, context) {
|
|
18
|
+
if (!context.stdoutIsTTY || !context.stderrIsTTY || argv.length === 0)
|
|
19
|
+
return false;
|
|
20
|
+
if (context.stderrColumns !== undefined &&
|
|
21
|
+
(!Number.isFinite(context.stderrColumns) || context.stderrColumns < MIN_SIGNAL_PULSE_COLUMNS)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (isCiEnvironment(context.env) || context.env.TERM?.toLowerCase() === "dumb")
|
|
25
|
+
return false;
|
|
26
|
+
if (hasNoColor(context.env) || context.env.PINHUB_NO_MOTION || context.env.NO_MOTION)
|
|
27
|
+
return false;
|
|
28
|
+
const disablesMotion = argv.some((argument) => ["help", "-h", "--help", "-v", "-V", "--version", "--json", "--no-motion", "--no-color"].includes(argument));
|
|
29
|
+
return !disablesMotion;
|
|
30
|
+
}
|
|
31
|
+
export function signalPulseLabel(argv) {
|
|
32
|
+
switch (argv[0]) {
|
|
33
|
+
case "list":
|
|
34
|
+
return "Scanning board catalog";
|
|
35
|
+
case "search":
|
|
36
|
+
return "Tuning board search";
|
|
37
|
+
case "info":
|
|
38
|
+
return "Reading board signals";
|
|
39
|
+
default:
|
|
40
|
+
return "Mapping pin signals";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A deliberately brief, color-cycling pulse. It writes only to an explicitly
|
|
45
|
+
* approved TTY stream and erases itself before normal CLI output is emitted.
|
|
46
|
+
*/
|
|
47
|
+
export async function playSignalPulse(stream, options) {
|
|
48
|
+
const c = makeChalk(true);
|
|
49
|
+
const frames = options.ascii ? [".", "o", "O", "o"] : ["◇", "◈", "◆", "◈"];
|
|
50
|
+
const colors = [c.cyan, c.blueBright, c.magentaBright, c.yellowBright];
|
|
51
|
+
const sleep = options.sleep ?? ((milliseconds) => delay(milliseconds));
|
|
52
|
+
const intervalMs = options.intervalMs ?? 45;
|
|
53
|
+
const clear = "\r\u001b[2K";
|
|
54
|
+
try {
|
|
55
|
+
for (let index = 0; index < frames.length; index += 1) {
|
|
56
|
+
stream.write(`${clear}${colors[index](frames[index])} ${c.dim(options.label)}`);
|
|
57
|
+
await sleep(intervalMs);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
stream.write(clear);
|
|
62
|
+
}
|
|
63
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare const VERSION
|
|
1
|
+
/** The installed package version, read from the package manifest. */
|
|
2
|
+
export declare const VERSION: string;
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
const packageJson = require("../package.json");
|
|
4
|
+
/** The installed package version, read from the package manifest. */
|
|
5
|
+
export const VERSION = packageJson.version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dheerajsom/pinhub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Hardware board pinout diagrams in your terminal. `ph rpi5` and go.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pinout",
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
"terminal"
|
|
15
15
|
],
|
|
16
16
|
"license": "MIT",
|
|
17
|
+
"homepage": "https://github.com/Dheerajsom/PinHub#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/Dheerajsom/PinHub/issues"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/Dheerajsom/PinHub.git",
|
|
24
|
+
"directory": "cli"
|
|
25
|
+
},
|
|
17
26
|
"type": "module",
|
|
18
27
|
"bin": {
|
|
19
28
|
"ph": "dist/cli.js"
|
|
@@ -25,6 +34,7 @@
|
|
|
25
34
|
},
|
|
26
35
|
"files": [
|
|
27
36
|
"dist",
|
|
37
|
+
"CLI.md",
|
|
28
38
|
"SETUP.md"
|
|
29
39
|
],
|
|
30
40
|
"engines": {
|
|
@@ -33,16 +43,17 @@
|
|
|
33
43
|
"scripts": {
|
|
34
44
|
"dev": "tsx src/cli.ts",
|
|
35
45
|
"generate:boards": "tsx scripts/generate-boards.ts",
|
|
46
|
+
"check:boards": "tsx scripts/generate-boards.ts --check",
|
|
36
47
|
"build": "tsc -p tsconfig.json",
|
|
37
48
|
"test": "vitest run",
|
|
38
49
|
"lint": "eslint .",
|
|
39
50
|
"package:check": "npm pack --dry-run",
|
|
40
|
-
"
|
|
41
|
-
"prepublishOnly": "npm run lint && npm run test && npm run build"
|
|
51
|
+
"prepublishOnly": "npm run check:boards && npm run lint && npm run test && npm run build"
|
|
42
52
|
},
|
|
43
53
|
"dependencies": {
|
|
44
54
|
"chalk": "^5.4.1",
|
|
45
|
-
"commander": "^13.1.0"
|
|
55
|
+
"commander": "^13.1.0",
|
|
56
|
+
"string-width": "^7.2.0"
|
|
46
57
|
},
|
|
47
58
|
"devDependencies": {
|
|
48
59
|
"@eslint/js": "^9.20.0",
|
|
@@ -51,6 +62,7 @@
|
|
|
51
62
|
"tsx": "^4.19.0",
|
|
52
63
|
"typescript": "^5.7.3",
|
|
53
64
|
"typescript-eslint": "^8.24.0",
|
|
54
|
-
"
|
|
65
|
+
"vite": "6.4.3",
|
|
66
|
+
"vitest": "3.2.7"
|
|
55
67
|
}
|
|
56
68
|
}
|