@xynogen/pix-pretty 1.30.0 → 1.30.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/highlight.ts +41 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-pretty",
3
- "version": "1.30.0",
3
+ "version": "1.30.1",
4
4
  "description": "Enhanced tool output rendering with syntax highlighting, file icons, tree views, diff rendering, and FFF search",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/highlight.ts CHANGED
@@ -35,11 +35,52 @@ function forceChalkColor(): void {
35
35
  }
36
36
  }
37
37
 
38
+ // highlight.js bash only colors shell builtins, so `sleep`, `df`, `tail` stay plain.
39
+ // Add the standard external commands to its built_in list.
40
+ export const BASH_COMMANDS =
41
+ "awk basename cat chgrp chmod chown cp curl cut date dd df diff dirname du env file find " +
42
+ "free git grep gzip head hostname id kill ln ls mkdir mktemp mv nohup pgrep pkill ps rm " +
43
+ "rmdir sed seq sleep sort ssh scp tail tar tee touch tr uname uniq wc which whoami xargs";
44
+
45
+ // Windows native executables plus common cross-platform CLIs. highlight.js powershell
46
+ // only knows cmdlets and aliases, so `ipconfig` or `git` would stay plain.
47
+ export const POWERSHELL_COMMANDS =
48
+ "arp assoc attrib bcdedit certutil chkdsk choco cipher clip cmd cmdkey cscript curl diskpart " +
49
+ "docker driverquery fc find findstr format fsutil ftp getmac git gpresult gpupdate hostname " +
50
+ "icacls ipconfig klist logoff make msiexec nbtstat net netsh netstat nltest node npm npx " +
51
+ "nslookup pathping pip ping pnpm powercfg powershell pwsh python reg regsvr32 robocopy route " +
52
+ "scoop sfc shutdown ssh scp systeminfo takeown taskkill tasklist tar tracert tree uv " +
53
+ "w32tm wevtutil where whoami winget wmic xcopy bun cargo go yarn";
54
+
55
+ // ponytail: reach the highlight.js instance cli-highlight already loaded instead of
56
+ // declaring a second dependency. Pin highlight.js directly if cli-highlight drops it.
57
+ function extendBuiltIns(): void {
58
+ try {
59
+ const { createRequire } = require("node:module") as typeof import("node:module");
60
+ const sub = createRequire(require.resolve("cli-highlight"));
61
+ const hljs = sub("highlight.js");
62
+ for (const [name, commands] of [
63
+ ["bash", BASH_COMMANDS],
64
+ ["powershell", POWERSHELL_COMMANDS],
65
+ ] as const) {
66
+ const grammar = sub(`highlight.js/lib/languages/${name}`);
67
+ hljs.registerLanguage(name, (h: unknown) => {
68
+ const def = grammar(h);
69
+ def.keywords.built_in += ` ${commands}`;
70
+ return def;
71
+ });
72
+ }
73
+ } catch {
74
+ /* keep the stock grammars */
75
+ }
76
+ }
77
+
38
78
  function cliHighlight(): CliHighlight | null {
39
79
  if (_hl) return _hl;
40
80
  try {
41
81
  forceChalkColor();
42
82
  _hl = require("cli-highlight") as CliHighlight;
83
+ extendBuiltIns();
43
84
  } catch {
44
85
  _hl = null;
45
86
  }