typescript-virtual-container 1.2.8 → 1.3.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.
Files changed (307) hide show
  1. package/.vscode/settings.json +0 -1
  2. package/README.md +462 -44
  3. package/biome.json +7 -0
  4. package/dist/SSHMimic/exec.d.ts.map +1 -1
  5. package/dist/SSHMimic/executor.d.ts.map +1 -1
  6. package/dist/SSHMimic/executor.js +35 -21
  7. package/dist/SSHMimic/index.d.ts.map +1 -1
  8. package/dist/SSHMimic/index.js +20 -6
  9. package/dist/VirtualFileSystem/binaryPack.d.ts.map +1 -1
  10. package/dist/VirtualFileSystem/binaryPack.js +29 -6
  11. package/dist/VirtualFileSystem/index.d.ts.map +1 -1
  12. package/dist/VirtualFileSystem/index.js +36 -13
  13. package/dist/VirtualPackageManager/index.d.ts +202 -0
  14. package/dist/VirtualPackageManager/index.d.ts.map +1 -0
  15. package/dist/VirtualPackageManager/index.js +825 -0
  16. package/dist/VirtualShell/index.d.ts +93 -12
  17. package/dist/VirtualShell/index.d.ts.map +1 -1
  18. package/dist/VirtualShell/index.js +95 -13
  19. package/dist/VirtualShell/shell.d.ts.map +1 -1
  20. package/dist/VirtualShell/shell.js +3 -1
  21. package/dist/VirtualShell/shellParser.d.ts.map +1 -1
  22. package/dist/VirtualUserManager/index.d.ts +52 -20
  23. package/dist/VirtualUserManager/index.d.ts.map +1 -1
  24. package/dist/VirtualUserManager/index.js +54 -20
  25. package/dist/commands/adduser.d.ts +6 -0
  26. package/dist/commands/adduser.d.ts.map +1 -1
  27. package/dist/commands/adduser.js +6 -0
  28. package/dist/commands/alias.d.ts +9 -0
  29. package/dist/commands/alias.d.ts.map +1 -0
  30. package/dist/commands/alias.js +63 -0
  31. package/dist/commands/apt.d.ts +9 -0
  32. package/dist/commands/apt.d.ts.map +1 -0
  33. package/dist/commands/apt.js +205 -0
  34. package/dist/commands/awk.d.ts +11 -0
  35. package/dist/commands/awk.d.ts.map +1 -1
  36. package/dist/commands/awk.js +15 -2
  37. package/dist/commands/base64.d.ts +5 -0
  38. package/dist/commands/base64.d.ts.map +1 -1
  39. package/dist/commands/base64.js +9 -1
  40. package/dist/commands/cat.d.ts +5 -0
  41. package/dist/commands/cat.d.ts.map +1 -1
  42. package/dist/commands/cat.js +35 -8
  43. package/dist/commands/cd.d.ts +5 -0
  44. package/dist/commands/cd.d.ts.map +1 -1
  45. package/dist/commands/cd.js +5 -0
  46. package/dist/commands/chmod.d.ts +5 -0
  47. package/dist/commands/chmod.d.ts.map +1 -1
  48. package/dist/commands/chmod.js +57 -3
  49. package/dist/commands/command-helpers.d.ts +78 -4
  50. package/dist/commands/command-helpers.d.ts.map +1 -1
  51. package/dist/commands/command-helpers.js +78 -4
  52. package/dist/commands/cp.d.ts +5 -0
  53. package/dist/commands/cp.d.ts.map +1 -1
  54. package/dist/commands/cp.js +5 -0
  55. package/dist/commands/curl.d.ts +5 -0
  56. package/dist/commands/curl.d.ts.map +1 -1
  57. package/dist/commands/curl.js +106 -26
  58. package/dist/commands/cut.d.ts +5 -0
  59. package/dist/commands/cut.d.ts.map +1 -1
  60. package/dist/commands/cut.js +8 -1
  61. package/dist/commands/date.d.ts +5 -0
  62. package/dist/commands/date.d.ts.map +1 -1
  63. package/dist/commands/date.js +7 -1
  64. package/dist/commands/declare.d.ts +3 -0
  65. package/dist/commands/declare.d.ts.map +1 -0
  66. package/dist/commands/declare.js +39 -0
  67. package/dist/commands/diff.d.ts +5 -0
  68. package/dist/commands/diff.d.ts.map +1 -1
  69. package/dist/commands/diff.js +5 -0
  70. package/dist/commands/dpkg.d.ts +9 -0
  71. package/dist/commands/dpkg.d.ts.map +1 -0
  72. package/dist/commands/dpkg.js +161 -0
  73. package/dist/commands/du.d.ts.map +1 -1
  74. package/dist/commands/du.js +8 -2
  75. package/dist/commands/echo.d.ts +5 -0
  76. package/dist/commands/echo.d.ts.map +1 -1
  77. package/dist/commands/echo.js +33 -12
  78. package/dist/commands/env.d.ts +5 -0
  79. package/dist/commands/env.d.ts.map +1 -1
  80. package/dist/commands/env.js +11 -1
  81. package/dist/commands/exit.d.ts +5 -0
  82. package/dist/commands/exit.d.ts.map +1 -1
  83. package/dist/commands/exit.js +12 -2
  84. package/dist/commands/export.d.ts.map +1 -1
  85. package/dist/commands/export.js +3 -1
  86. package/dist/commands/find.d.ts +5 -0
  87. package/dist/commands/find.d.ts.map +1 -1
  88. package/dist/commands/find.js +5 -0
  89. package/dist/commands/free.d.ts +8 -0
  90. package/dist/commands/free.d.ts.map +1 -0
  91. package/dist/commands/free.js +43 -0
  92. package/dist/commands/grep.d.ts +5 -0
  93. package/dist/commands/grep.d.ts.map +1 -1
  94. package/dist/commands/grep.js +12 -2
  95. package/dist/commands/gzip.d.ts +5 -0
  96. package/dist/commands/gzip.d.ts.map +1 -1
  97. package/dist/commands/gzip.js +18 -2
  98. package/dist/commands/head.d.ts +5 -0
  99. package/dist/commands/head.d.ts.map +1 -1
  100. package/dist/commands/head.js +5 -0
  101. package/dist/commands/help.d.ts.map +1 -1
  102. package/dist/commands/help.js +98 -45
  103. package/dist/commands/helpers.d.ts +3 -0
  104. package/dist/commands/helpers.d.ts.map +1 -1
  105. package/dist/commands/helpers.js +3 -0
  106. package/dist/commands/history.d.ts +8 -0
  107. package/dist/commands/history.d.ts.map +1 -0
  108. package/dist/commands/history.js +26 -0
  109. package/dist/commands/hostname.d.ts +5 -0
  110. package/dist/commands/hostname.d.ts.map +1 -1
  111. package/dist/commands/hostname.js +5 -0
  112. package/dist/commands/id.d.ts.map +1 -1
  113. package/dist/commands/id.js +4 -1
  114. package/dist/commands/index.d.ts +2 -10
  115. package/dist/commands/index.d.ts.map +1 -1
  116. package/dist/commands/index.js +2 -231
  117. package/dist/commands/ls.d.ts.map +1 -1
  118. package/dist/commands/ls.js +6 -3
  119. package/dist/commands/lsb-release.d.ts +3 -0
  120. package/dist/commands/lsb-release.d.ts.map +1 -0
  121. package/dist/commands/lsb-release.js +56 -0
  122. package/dist/commands/man.d.ts +3 -0
  123. package/dist/commands/man.d.ts.map +1 -0
  124. package/dist/commands/man.js +155 -0
  125. package/dist/commands/nano.js +1 -1
  126. package/dist/commands/neofetch.d.ts.map +1 -1
  127. package/dist/commands/neofetch.js +6 -1
  128. package/dist/commands/node.d.ts +9 -0
  129. package/dist/commands/node.d.ts.map +1 -0
  130. package/dist/commands/node.js +316 -0
  131. package/dist/commands/npm.d.ts +19 -0
  132. package/dist/commands/npm.d.ts.map +1 -0
  133. package/dist/commands/npm.js +109 -0
  134. package/dist/commands/ping.d.ts.map +1 -1
  135. package/dist/commands/ping.js +7 -2
  136. package/dist/commands/printf.d.ts +3 -0
  137. package/dist/commands/printf.d.ts.map +1 -0
  138. package/dist/commands/printf.js +113 -0
  139. package/dist/commands/ps.d.ts.map +1 -1
  140. package/dist/commands/ps.js +30 -6
  141. package/dist/commands/python.d.ts +30 -0
  142. package/dist/commands/python.d.ts.map +1 -0
  143. package/dist/commands/python.js +2058 -0
  144. package/dist/commands/read.d.ts +3 -0
  145. package/dist/commands/read.d.ts.map +1 -0
  146. package/dist/commands/read.js +34 -0
  147. package/dist/commands/registry.d.ts +8 -0
  148. package/dist/commands/registry.d.ts.map +1 -0
  149. package/dist/commands/registry.js +229 -0
  150. package/dist/commands/runtime.d.ts +6 -0
  151. package/dist/commands/runtime.d.ts.map +1 -0
  152. package/dist/commands/runtime.js +280 -0
  153. package/dist/commands/sed.d.ts.map +1 -1
  154. package/dist/commands/sed.js +11 -3
  155. package/dist/commands/set.d.ts.map +1 -1
  156. package/dist/commands/set.js +9 -3
  157. package/dist/commands/sh.d.ts.map +1 -1
  158. package/dist/commands/sh.js +69 -30
  159. package/dist/commands/shift.d.ts +5 -0
  160. package/dist/commands/shift.d.ts.map +1 -0
  161. package/dist/commands/shift.js +52 -0
  162. package/dist/commands/sleep.d.ts.map +1 -1
  163. package/dist/commands/sort.d.ts.map +1 -1
  164. package/dist/commands/sort.js +4 -2
  165. package/dist/commands/source.d.ts +3 -0
  166. package/dist/commands/source.d.ts.map +1 -0
  167. package/dist/commands/source.js +34 -0
  168. package/dist/commands/sudo.js +1 -1
  169. package/dist/commands/tar.d.ts.map +1 -1
  170. package/dist/commands/tar.js +11 -3
  171. package/dist/commands/tee.d.ts.map +1 -1
  172. package/dist/commands/tee.js +8 -6
  173. package/dist/commands/test.d.ts +3 -0
  174. package/dist/commands/test.d.ts.map +1 -0
  175. package/dist/commands/test.js +114 -0
  176. package/dist/commands/tr.d.ts.map +1 -1
  177. package/dist/commands/tr.js +3 -1
  178. package/dist/commands/true.d.ts +4 -0
  179. package/dist/commands/true.d.ts.map +1 -0
  180. package/dist/commands/true.js +14 -0
  181. package/dist/commands/type.d.ts +3 -0
  182. package/dist/commands/type.d.ts.map +1 -0
  183. package/dist/commands/type.js +34 -0
  184. package/dist/commands/uname.d.ts.map +1 -1
  185. package/dist/commands/uname.js +4 -1
  186. package/dist/commands/uniq.d.ts.map +1 -1
  187. package/dist/commands/uptime.d.ts +3 -0
  188. package/dist/commands/uptime.d.ts.map +1 -0
  189. package/dist/commands/uptime.js +43 -0
  190. package/dist/commands/wget.d.ts.map +1 -1
  191. package/dist/commands/wget.js +92 -96
  192. package/dist/commands/which.d.ts +3 -0
  193. package/dist/commands/which.d.ts.map +1 -0
  194. package/dist/commands/which.js +32 -0
  195. package/dist/commands/xargs.d.ts.map +1 -1
  196. package/dist/commands/xargs.js +1 -1
  197. package/dist/index.d.ts +15 -11
  198. package/dist/index.d.ts.map +1 -1
  199. package/dist/index.js +9 -8
  200. package/dist/modules/linuxRootfs.d.ts +41 -0
  201. package/dist/modules/linuxRootfs.d.ts.map +1 -0
  202. package/dist/modules/linuxRootfs.js +440 -0
  203. package/dist/modules/neofetch.d.ts.map +1 -1
  204. package/dist/modules/neofetch.js +1 -0
  205. package/dist/standalone-wo-sftp.d.ts +2 -0
  206. package/dist/standalone-wo-sftp.d.ts.map +1 -0
  207. package/dist/standalone-wo-sftp.js +30 -0
  208. package/dist/utils/expand.d.ts +50 -0
  209. package/dist/utils/expand.d.ts.map +1 -0
  210. package/dist/utils/expand.js +183 -0
  211. package/dist/utils/vfsDiff.d.ts +90 -0
  212. package/dist/utils/vfsDiff.d.ts.map +1 -0
  213. package/dist/utils/vfsDiff.js +177 -0
  214. package/package.json +3 -1
  215. package/src/SSHMimic/exec.ts +10 -1
  216. package/src/SSHMimic/executor.ts +105 -21
  217. package/src/SSHMimic/index.ts +49 -15
  218. package/src/VirtualFileSystem/binaryPack.ts +35 -8
  219. package/src/VirtualFileSystem/index.ts +78 -28
  220. package/src/VirtualPackageManager/index.ts +979 -0
  221. package/src/VirtualShell/index.ts +133 -14
  222. package/src/VirtualShell/shell.ts +23 -3
  223. package/src/VirtualShell/shellParser.ts +134 -36
  224. package/src/VirtualUserManager/index.ts +62 -22
  225. package/src/commands/adduser.ts +6 -0
  226. package/src/commands/alias.ts +64 -0
  227. package/src/commands/apt.ts +228 -0
  228. package/src/commands/awk.ts +20 -6
  229. package/src/commands/base64.ts +13 -2
  230. package/src/commands/cat.ts +40 -8
  231. package/src/commands/cd.ts +5 -0
  232. package/src/commands/chmod.ts +53 -3
  233. package/src/commands/command-helpers.ts +78 -4
  234. package/src/commands/cp.ts +5 -0
  235. package/src/commands/curl.ts +118 -33
  236. package/src/commands/cut.ts +8 -1
  237. package/src/commands/date.ts +7 -1
  238. package/src/commands/declare.ts +44 -0
  239. package/src/commands/diff.ts +17 -3
  240. package/src/commands/dpkg.ts +180 -0
  241. package/src/commands/du.ts +17 -5
  242. package/src/commands/echo.ts +41 -12
  243. package/src/commands/env.ts +11 -1
  244. package/src/commands/exit.ts +12 -2
  245. package/src/commands/export.ts +3 -1
  246. package/src/commands/find.ts +5 -0
  247. package/src/commands/free.ts +47 -0
  248. package/src/commands/grep.ts +12 -2
  249. package/src/commands/gzip.ts +28 -4
  250. package/src/commands/head.ts +5 -0
  251. package/src/commands/help.ts +121 -47
  252. package/src/commands/helpers.ts +8 -0
  253. package/src/commands/history.ts +34 -0
  254. package/src/commands/hostname.ts +5 -0
  255. package/src/commands/id.ts +4 -1
  256. package/src/commands/index.ts +9 -255
  257. package/src/commands/ls.ts +6 -3
  258. package/src/commands/lsb-release.ts +58 -0
  259. package/src/commands/man.ts +166 -0
  260. package/src/commands/nano.ts +1 -1
  261. package/src/commands/neofetch.ts +6 -1
  262. package/src/commands/node.ts +341 -0
  263. package/src/commands/npm.ts +132 -0
  264. package/src/commands/ping.ts +10 -3
  265. package/src/commands/printf.ts +112 -0
  266. package/src/commands/ps.ts +40 -6
  267. package/src/commands/python.ts +2229 -0
  268. package/src/commands/read.ts +41 -0
  269. package/src/commands/registry.ts +244 -0
  270. package/src/commands/runtime.ts +353 -0
  271. package/src/commands/sed.ts +27 -9
  272. package/src/commands/set.ts +9 -3
  273. package/src/commands/sh.ts +170 -44
  274. package/src/commands/shift.ts +53 -0
  275. package/src/commands/sleep.ts +2 -1
  276. package/src/commands/sort.ts +10 -6
  277. package/src/commands/source.ts +47 -0
  278. package/src/commands/sudo.ts +1 -1
  279. package/src/commands/tar.ts +28 -7
  280. package/src/commands/tee.ts +7 -1
  281. package/src/commands/test.ts +135 -0
  282. package/src/commands/tr.ts +3 -1
  283. package/src/commands/true.ts +17 -0
  284. package/src/commands/type.ts +43 -0
  285. package/src/commands/uname.ts +5 -1
  286. package/src/commands/uniq.ts +8 -2
  287. package/src/commands/uptime.ts +49 -0
  288. package/src/commands/wget.ts +105 -119
  289. package/src/commands/which.ts +37 -0
  290. package/src/commands/xargs.ts +11 -2
  291. package/src/index.ts +27 -18
  292. package/src/modules/linuxRootfs.ts +642 -0
  293. package/src/modules/neofetch.ts +1 -0
  294. package/src/standalone-wo-sftp.ts +38 -0
  295. package/src/utils/expand.ts +238 -0
  296. package/src/utils/vfsDiff.ts +275 -0
  297. package/standalone-wo-sftp.js +507 -0
  298. package/standalone-wo-sftp.js.map +7 -0
  299. package/standalone.js +486 -109
  300. package/standalone.js.map +4 -4
  301. package/tests/bun-test-shim.ts +9 -1
  302. package/tests/command-helpers.test.ts +1 -5
  303. package/tests/new-features.test.ts +1036 -0
  304. package/tests/parser-executor.test.ts +27 -27
  305. package/tests/sftp.test.ts +122 -42
  306. package/tests/users.test.ts +23 -5
  307. package/CHANGELOG.md +0 -150
@@ -1,70 +1,123 @@
1
- import { getCommandModulesPublic } from "./index";
2
- const CATEGORY_ORDER = ["navigation", "files", "text", "archive", "system", "network", "shell", "users", "misc"];
1
+ import { getCommandModulesPublic } from "./registry";
2
+ // ─── category config ──────────────────────────────────────────────────────────
3
+ const CATEGORY_ORDER = [
4
+ "navigation",
5
+ "files",
6
+ "text",
7
+ "archive",
8
+ "system",
9
+ "package",
10
+ "network",
11
+ "shell",
12
+ "users",
13
+ "misc",
14
+ ];
3
15
  const CATEGORY_LABELS = {
4
16
  navigation: "Navigation",
5
17
  files: "Files & Filesystem",
6
18
  text: "Text Processing",
7
19
  archive: "Archive & Compression",
8
20
  system: "System",
21
+ package: "Package Management",
9
22
  network: "Network",
10
- shell: "Shell",
23
+ shell: "Shell & Scripting",
11
24
  users: "Users & Permissions",
12
25
  misc: "Miscellaneous",
13
26
  };
14
- function padRight(s, n) {
27
+ // ─── formatting helpers ───────────────────────────────────────────────────────
28
+ const BOLD = "\x1b[1m";
29
+ const RESET = "\x1b[0m";
30
+ const CYAN = "\x1b[36m";
31
+ const YLW = "\x1b[33m";
32
+ const DIM = "\x1b[2m";
33
+ const GREEN = "\x1b[32m";
34
+ function pad(s, n) {
15
35
  return s.length >= n ? s : s + " ".repeat(n - s.length);
16
36
  }
37
+ function formatCmdLine(mod) {
38
+ const aliases = mod.aliases?.length
39
+ ? ` ${DIM}(${mod.aliases.join(", ")})${RESET}`
40
+ : "";
41
+ return ` ${CYAN}${pad(mod.name, 16)}${RESET}${aliases}${pad("", mod.aliases?.length ? 0 : 0)} ${mod.description ?? ""}`;
42
+ }
43
+ // ─── full grouped listing ─────────────────────────────────────────────────────
44
+ function renderFull(modules) {
45
+ const grouped = {};
46
+ for (const mod of modules) {
47
+ const cat = mod.category ?? "misc";
48
+ if (!grouped[cat])
49
+ grouped[cat] = [];
50
+ grouped[cat].push(mod);
51
+ }
52
+ const lines = [
53
+ `${BOLD}Available commands${RESET}`,
54
+ `${DIM}Type 'help <command>' for detailed usage.${RESET}`,
55
+ "",
56
+ ];
57
+ const cats = [
58
+ ...CATEGORY_ORDER.filter((c) => grouped[c]),
59
+ ...Object.keys(grouped)
60
+ .filter((c) => !CATEGORY_ORDER.includes(c))
61
+ .sort(),
62
+ ];
63
+ for (const cat of cats) {
64
+ const mods = grouped[cat];
65
+ if (!mods?.length)
66
+ continue;
67
+ lines.push(`${YLW}${CATEGORY_LABELS[cat] ?? cat}${RESET}`);
68
+ const sorted = [...mods].sort((a, b) => a.name.localeCompare(b.name));
69
+ for (const mod of sorted) {
70
+ lines.push(formatCmdLine(mod));
71
+ }
72
+ lines.push("");
73
+ }
74
+ const total = modules.length;
75
+ lines.push(`${DIM}${total} commands available.${RESET}`);
76
+ return lines.join("\n");
77
+ }
78
+ // ─── single-command detail ────────────────────────────────────────────────────
79
+ function renderDetail(mod) {
80
+ const lines = [];
81
+ lines.push(`${BOLD}${mod.name}${RESET} — ${mod.description ?? "no description"}`);
82
+ if (mod.aliases?.length) {
83
+ lines.push(`${DIM}Aliases: ${mod.aliases.join(", ")}${RESET}`);
84
+ }
85
+ lines.push("");
86
+ lines.push(`${GREEN}Usage:${RESET}`);
87
+ if (mod.params.length) {
88
+ for (const p of mod.params) {
89
+ lines.push(` ${mod.name} ${p}`);
90
+ }
91
+ }
92
+ else {
93
+ lines.push(` ${mod.name}`);
94
+ }
95
+ const catLabel = CATEGORY_LABELS[mod.category ?? "misc"] ?? mod.category ?? "misc";
96
+ lines.push("");
97
+ lines.push(`${DIM}Category: ${catLabel}${RESET}`);
98
+ return lines.join("\n");
99
+ }
100
+ // ─── export ───────────────────────────────────────────────────────────────────
17
101
  export function createHelpCommand(_getNames) {
18
102
  return {
19
103
  name: "help",
20
- description: "Display this help message",
104
+ description: "List all commands, or show usage for a specific command",
21
105
  category: "shell",
22
106
  params: ["[command]"],
23
107
  run: ({ args }) => {
24
108
  const modules = getCommandModulesPublic();
25
- // help <command>
26
109
  if (args[0]) {
27
- const mod = modules.find((m) => m.name === args[0] || m.aliases?.includes(args[0]));
28
- if (!mod)
29
- return { stderr: `help: no help for '${args[0]}'`, exitCode: 1 };
30
- const aliases = mod.aliases?.length ? ` aliases: ${mod.aliases.join(", ")}\n` : "";
31
- const params = mod.params.map((p) => ` ${mod.name} ${p}`).join("\n");
32
- return {
33
- stdout: [
34
- `\x1b[1m${mod.name}\x1b[0m — ${mod.description ?? "no description"}`,
35
- aliases,
36
- "Usage:",
37
- params || ` ${mod.name}`,
38
- ].filter(Boolean).join("\n"),
39
- exitCode: 0,
40
- };
41
- }
42
- // Full help — grouped by category
43
- const grouped = {};
44
- for (const mod of modules) {
45
- const cat = mod.category ?? "misc";
46
- if (!grouped[cat])
47
- grouped[cat] = [];
48
- grouped[cat].push(mod);
49
- }
50
- const lines = [];
51
- lines.push("\x1b[1mAvailable commands\x1b[0m");
52
- lines.push("");
53
- const cats = [
54
- ...CATEGORY_ORDER.filter((c) => grouped[c]),
55
- ...Object.keys(grouped).filter((c) => !CATEGORY_ORDER.includes(c)),
56
- ];
57
- for (const cat of cats) {
58
- const mods = grouped[cat];
59
- if (!mods || mods.length === 0)
60
- continue;
61
- lines.push(`\x1b[33m${CATEGORY_LABELS[cat] ?? cat}\x1b[0m`);
62
- const sorted = [...mods].sort((a, b) => a.name.localeCompare(b.name));
63
- for (const mod of sorted) {
64
- lines.push(` \x1b[36m${padRight(mod.name, 14)}\x1b[0m ${mod.description ?? ""}`);
110
+ const target = args[0].toLowerCase();
111
+ const mod = modules.find((m) => m.name === target || m.aliases?.includes(target));
112
+ if (!mod) {
113
+ return {
114
+ stderr: `help: no help entry for '${args[0]}'`,
115
+ exitCode: 1,
116
+ };
65
117
  }
118
+ return { stdout: renderDetail(mod), exitCode: 0 };
66
119
  }
67
- return { stdout: lines.join("\n"), exitCode: 0 };
120
+ return { stdout: renderFull(modules), exitCode: 0 };
68
121
  },
69
122
  };
70
123
  }
@@ -1,4 +1,6 @@
1
1
  import type VirtualFileSystem from "../VirtualFileSystem";
2
+ import type { VirtualPackageManager } from "../VirtualPackageManager";
3
+ import type { VirtualShell } from "../VirtualShell";
2
4
  export declare function normalizeTerminalOutput(text: string): string;
3
5
  export declare function resolvePath(cwd: string, inputPath: string): string;
4
6
  export declare function assertPathAccess(authUser: string, targetPath: string, operation: string): void;
@@ -23,4 +25,5 @@ export declare function resolveReadablePath(vfs: VirtualFileSystem, cwd: string,
23
25
  export declare function joinListWithType(cwd: string, items: string[], statAt: (p: string) => {
24
26
  type: "file" | "directory";
25
27
  }): string;
28
+ export declare function getPackageManager(shell: VirtualShell): VirtualPackageManager | undefined;
26
29
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/commands/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAY1D,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY5D;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAOlE;AAYD,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GACf,IAAI,CAQN;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAsB,aAAa,CAClC,GAAG,EAAE,MAAM,GACT,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAQvE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,GACZ,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA8D/D;AA4BD,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,iBAAiB,EACtB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GACf,MAAM,CAyBR;AAED,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK;IAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,GACnD,MAAM,CAQR"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/commands/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAYpD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY5D;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAOlE;AAYD,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GACf,IAAI,CAQN;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAsB,aAAa,CAClC,GAAG,EAAE,MAAM,GACT,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAQvE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,GACZ,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA8D/D;AA4BD,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,iBAAiB,EACtB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GACf,MAAM,CAyBR;AAED,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK;IAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,GACnD,MAAM,CAQR;AAED,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,YAAY,GACjB,qBAAqB,GAAG,SAAS,CAEnC"}
@@ -158,3 +158,6 @@ export function joinListWithType(cwd, items, statAt) {
158
158
  })
159
159
  .join(" ");
160
160
  }
161
+ export function getPackageManager(shell) {
162
+ return shell.packageManager;
163
+ }
@@ -0,0 +1,8 @@
1
+ import type { ShellModule } from "../types/commands";
2
+ /**
3
+ * Display persisted command history for the session (from VFS).
4
+ * @category shell
5
+ * @params ["[n]"]
6
+ */
7
+ export declare const historyCommand: ShellModule;
8
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,WA0B5B,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Display persisted command history for the session (from VFS).
3
+ * @category shell
4
+ * @params ["[n]"]
5
+ */
6
+ export const historyCommand = {
7
+ name: "history",
8
+ description: "Display command history",
9
+ category: "shell",
10
+ params: ["[n]"],
11
+ run: ({ args, shell }) => {
12
+ // History is persisted in the VFS by the interactive shell
13
+ const histPath = "/virtual-env-js/.bash_history";
14
+ if (!shell.vfs.exists(histPath)) {
15
+ return { stdout: "", exitCode: 0 };
16
+ }
17
+ const raw = shell.vfs.readFile(histPath);
18
+ const lines = raw.split("\n").filter(Boolean);
19
+ const nArg = args[0];
20
+ const n = nArg ? parseInt(nArg, 10) : null;
21
+ const slice = n && !Number.isNaN(n) ? lines.slice(-n) : lines;
22
+ const offset = lines.length - slice.length + 1;
23
+ const numbered = slice.map((line, i) => `${String(offset + i).padStart(5)} ${line}`);
24
+ return { stdout: numbered.join("\n"), exitCode: 0 };
25
+ },
26
+ };
@@ -1,3 +1,8 @@
1
1
  import type { ShellModule } from "../types/commands";
2
+ /**
3
+ * Print the configured hostname for the virtual shell.
4
+ * @category system
5
+ * @params []
6
+ */
2
7
  export declare const hostnameCommand: ShellModule;
3
8
  //# sourceMappingURL=hostname.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hostname.d.ts","sourceRoot":"","sources":["../../src/commands/hostname.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,eAAe,EAAE,WAM7B,CAAC"}
1
+ {"version":3,"file":"hostname.d.ts","sourceRoot":"","sources":["../../src/commands/hostname.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,WAM7B,CAAC"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Print the configured hostname for the virtual shell.
3
+ * @category system
4
+ * @params []
5
+ */
1
6
  export const hostnameCommand = {
2
7
  name: "hostname",
3
8
  description: "Print hostname",
@@ -1 +1 @@
1
- {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/commands/id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,SAAS,EAAE,WAavB,CAAC"}
1
+ {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/commands/id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,SAAS,EAAE,WAgBvB,CAAC"}
@@ -9,6 +9,9 @@ export const idCommand = {
9
9
  const gid = uid;
10
10
  const isSudo = shell.users.isSudoer(target);
11
11
  const groups = isSudo ? `${gid}(${target}),0(root)` : `${gid}(${target})`;
12
- return { stdout: `uid=${uid}(${target}) gid=${gid}(${target}) groups=${groups}`, exitCode: 0 };
12
+ return {
13
+ stdout: `uid=${uid}(${target}) gid=${gid}(${target}) groups=${groups}`,
14
+ exitCode: 0,
15
+ };
13
16
  },
14
17
  };
@@ -1,11 +1,3 @@
1
- /** biome-ignore-all lint/style/useNamingConvention: ENV VARIABLES */
2
- import type { VirtualShell } from "../VirtualShell";
3
- import type { CommandContext, CommandMode, CommandResult, ShellEnv, ShellModule } from "../types/commands";
4
- export declare function registerCommand(module: ShellModule): void;
5
- export declare function createCustomCommand(name: string, params: string[], run: (ctx: CommandContext) => CommandResult | Promise<CommandResult>): ShellModule;
6
- export declare function getCommandNames(): string[];
7
- export declare function getCommandModulesPublic(): ShellModule[];
8
- export declare function resolveModule(name: string): ShellModule | undefined;
9
- export declare function makeDefaultEnv(authUser: string, hostname: string): ShellEnv;
10
- export declare function runCommand(rawInput: string, authUser: string, hostname: string, mode: CommandMode, cwd: string, shell: VirtualShell, stdin?: string, env?: ShellEnv): Promise<CommandResult>;
1
+ export { createCustomCommand, getCommandModulesPublic, getCommandNames, registerCommand, resolveModule } from "./registry";
2
+ export { makeDefaultEnv, runCommand, runCommandDirect } from "./runtime";
11
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EACX,cAAc,EACd,WAAW,EACX,aAAa,EACb,QAAQ,EACR,WAAW,EACX,MAAM,mBAAmB,CAAC;AA8G3B,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAYzD;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,GAAG,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,GAClE,WAAW,CAEb;AAED,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAG1C;AAED,wBAAgB,uBAAuB,IAAI,WAAW,EAAE,CAEvD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAGnE;AA8BD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAc3E;AAED,wBAAsB,UAAU,CAC/B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,QAAQ,GACZ,OAAO,CAAC,aAAa,CAAC,CA+CxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EACf,eAAe,EACf,aAAa,EACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
@@ -1,231 +1,2 @@
1
- import { adduserCommand } from "./adduser";
2
- import { awkCommand } from "./awk";
3
- import { base64Command } from "./base64";
4
- import { catCommand } from "./cat";
5
- import { cdCommand } from "./cd";
6
- import { chmodCommand } from "./chmod";
7
- import { clearCommand } from "./clear";
8
- import { cpCommand } from "./cp";
9
- import { curlCommand } from "./curl";
10
- import { cutCommand } from "./cut";
11
- import { dateCommand } from "./date";
12
- import { deluserCommand } from "./deluser";
13
- import { dfCommand } from "./df";
14
- import { diffCommand } from "./diff";
15
- import { duCommand } from "./du";
16
- import { echoCommand } from "./echo";
17
- import { envCommand } from "./env";
18
- import { exitCommand } from "./exit";
19
- import { exportCommand } from "./export";
20
- import { findCommand } from "./find";
21
- import { grepCommand } from "./grep";
22
- import { groupsCommand } from "./groups";
23
- import { gunzipCommand, gzipCommand } from "./gzip";
24
- import { headCommand } from "./head";
25
- import { createHelpCommand } from "./help";
26
- import { hostnameCommand } from "./hostname";
27
- import { htopCommand } from "./htop";
28
- import { idCommand } from "./id";
29
- import { killCommand } from "./kill";
30
- import { lnCommand } from "./ln";
31
- import { lsCommand } from "./ls";
32
- import { mkdirCommand } from "./mkdir";
33
- import { mvCommand } from "./mv";
34
- import { nanoCommand } from "./nano";
35
- import { neofetchCommand } from "./neofetch";
36
- import { passwdCommand } from "./passwd";
37
- import { pingCommand } from "./ping";
38
- import { psCommand } from "./ps";
39
- import { pwdCommand } from "./pwd";
40
- import { rmCommand } from "./rm";
41
- import { sedCommand } from "./sed";
42
- import { setCommand } from "./set";
43
- import { shCommand } from "./sh";
44
- import { sleepCommand } from "./sleep";
45
- import { sortCommand } from "./sort";
46
- import { suCommand } from "./su";
47
- import { sudoCommand } from "./sudo";
48
- import { tailCommand } from "./tail";
49
- import { tarCommand } from "./tar";
50
- import { teeCommand } from "./tee";
51
- import { touchCommand } from "./touch";
52
- import { trCommand } from "./tr";
53
- import { treeCommand } from "./tree";
54
- import { unameCommand } from "./uname";
55
- import { uniqCommand } from "./uniq";
56
- import { unsetCommand } from "./unset";
57
- import { wcCommand } from "./wc";
58
- import { wgetCommand } from "./wget";
59
- import { whoCommand } from "./who";
60
- import { whoamiCommand } from "./whoami";
61
- import { xargsCommand } from "./xargs";
62
- const BASE_COMMANDS = [
63
- // Navigation
64
- pwdCommand, cdCommand, lsCommand, treeCommand,
65
- // Files
66
- catCommand, touchCommand, rmCommand, mkdirCommand, cpCommand, mvCommand, lnCommand,
67
- chmodCommand, findCommand,
68
- // Text processing
69
- grepCommand, sedCommand, awkCommand, sortCommand, uniqCommand, wcCommand,
70
- headCommand, tailCommand, cutCommand, trCommand, teeCommand, xargsCommand,
71
- diffCommand,
72
- // Archives
73
- tarCommand, gzipCommand, gunzipCommand, base64Command,
74
- // System info
75
- whoamiCommand, whoCommand, hostnameCommand, idCommand, groupsCommand, unameCommand,
76
- psCommand, killCommand, dfCommand, duCommand, dateCommand, sleepCommand, pingCommand,
77
- // Shell
78
- echoCommand, envCommand, exportCommand, setCommand, unsetCommand, shCommand,
79
- clearCommand, exitCommand,
80
- // Editors
81
- nanoCommand, htopCommand,
82
- // Network
83
- curlCommand, wgetCommand,
84
- // Users
85
- adduserCommand, passwdCommand, deluserCommand, sudoCommand, suCommand,
86
- // Misc
87
- neofetchCommand,
88
- ];
89
- const customCommands = [];
90
- const commandRegistry = new Map();
91
- let cachedCommandNames = null;
92
- const helpCommand = createHelpCommand(() => getCommandModules().map((cmd) => cmd.name));
93
- function buildCache() {
94
- commandRegistry.clear();
95
- for (const mod of getCommandModules()) {
96
- commandRegistry.set(mod.name, mod);
97
- for (const alias of mod.aliases ?? [])
98
- commandRegistry.set(alias, mod);
99
- }
100
- cachedCommandNames = Array.from(commandRegistry.keys()).sort();
101
- }
102
- function getCommandModules() {
103
- return [...BASE_COMMANDS, ...customCommands, helpCommand];
104
- }
105
- export function registerCommand(module) {
106
- const normalized = {
107
- ...module,
108
- name: module.name.trim().toLowerCase(),
109
- aliases: module.aliases?.map((a) => a.trim().toLowerCase()),
110
- };
111
- const names = [normalized.name, ...(normalized.aliases ?? [])];
112
- if (names.some((n) => n.length === 0 || /\s/.test(n))) {
113
- throw new Error("Command names must be non-empty and contain no spaces");
114
- }
115
- customCommands.push(normalized);
116
- buildCache();
117
- }
118
- export function createCustomCommand(name, params, run) {
119
- return { name, params, run };
120
- }
121
- export function getCommandNames() {
122
- if (!cachedCommandNames)
123
- buildCache();
124
- return cachedCommandNames;
125
- }
126
- export function getCommandModulesPublic() {
127
- return getCommandModules();
128
- }
129
- export function resolveModule(name) {
130
- if (!cachedCommandNames)
131
- buildCache();
132
- return commandRegistry.get(name.toLowerCase());
133
- }
134
- function splitArgsRespectingQuotes(input) {
135
- const tokens = [];
136
- let current = "";
137
- let inQuotes = false;
138
- let quoteChar = "";
139
- for (let i = 0; i < input.length; i++) {
140
- const ch = input[i] || "";
141
- const prev = i > 0 ? input[i - 1] : "";
142
- if ((ch === '"' || ch === "'") && prev !== "\\") {
143
- if (!inQuotes) {
144
- inQuotes = true;
145
- quoteChar = ch;
146
- continue;
147
- }
148
- if (ch === quoteChar) {
149
- inQuotes = false;
150
- quoteChar = "";
151
- continue;
152
- }
153
- }
154
- if (/\s/.test(ch) && !inQuotes) {
155
- if (current.length > 0) {
156
- tokens.push(current);
157
- current = "";
158
- }
159
- continue;
160
- }
161
- current += ch;
162
- }
163
- if (current.length > 0)
164
- tokens.push(current);
165
- return tokens;
166
- }
167
- function parseInput(rawInput) {
168
- const parts = splitArgsRespectingQuotes(rawInput.trim());
169
- return { commandName: parts[0]?.toLowerCase() ?? "", args: parts.slice(1) };
170
- }
171
- export function makeDefaultEnv(authUser, hostname) {
172
- return {
173
- vars: {
174
- PATH: "/usr/local/bin:/usr/bin:/bin",
175
- HOME: `/home/${authUser}`,
176
- USER: authUser,
177
- LOGNAME: authUser,
178
- SHELL: "/bin/sh",
179
- TERM: "xterm-256color",
180
- HOSTNAME: hostname,
181
- PS1: "\\u@\\h:\\w\\$ ",
182
- },
183
- lastExitCode: 0,
184
- };
185
- }
186
- export async function runCommand(rawInput, authUser, hostname, mode, cwd, shell, stdin, env) {
187
- const trimmed = rawInput.trim();
188
- if (trimmed.length === 0)
189
- return { exitCode: 0 };
190
- const shellEnv = env ?? makeDefaultEnv(authUser, hostname);
191
- // Detect shell operators
192
- if (/(?<![|&])[|](?![|])/.test(trimmed) ||
193
- trimmed.includes(">") ||
194
- trimmed.includes("<") ||
195
- trimmed.includes("&&") ||
196
- trimmed.includes("||") ||
197
- trimmed.includes(";")) {
198
- const { parseScript } = await import("../VirtualShell/shellParser");
199
- const { executeStatements } = await import("../SSHMimic/executor");
200
- const script = parseScript(trimmed);
201
- if (!script.isValid)
202
- return { stderr: script.error || "Syntax error", exitCode: 1 };
203
- try {
204
- return await executeStatements(script.statements, authUser, hostname, mode, cwd, shell, shellEnv);
205
- }
206
- catch (error) {
207
- return { stderr: error instanceof Error ? error.message : "Execution failed", exitCode: 1 };
208
- }
209
- }
210
- const { commandName, args } = parseInput(trimmed);
211
- const mod = resolveModule(commandName);
212
- if (!mod)
213
- return { stderr: `${commandName}: command not found`, exitCode: 127 };
214
- try {
215
- return await mod.run({
216
- authUser,
217
- hostname,
218
- activeSessions: shell.users.listActiveSessions(),
219
- rawInput: trimmed,
220
- mode,
221
- args,
222
- stdin,
223
- cwd,
224
- shell,
225
- env: shellEnv,
226
- });
227
- }
228
- catch (error) {
229
- return { stderr: error instanceof Error ? error.message : "Command failed", exitCode: 1 };
230
- }
231
- }
1
+ export { createCustomCommand, getCommandModulesPublic, getCommandNames, registerCommand, resolveModule } from "./registry";
2
+ export { makeDefaultEnv, runCommand, runCommandDirect } from "./runtime";
@@ -1 +1 @@
1
- {"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../src/commands/ls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA4BrD,eAAO,MAAM,SAAS,EAAE,WAyBvB,CAAC"}
1
+ {"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../src/commands/ls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA4BrD,eAAO,MAAM,SAAS,EAAE,WA4BvB,CAAC"}
@@ -25,15 +25,18 @@ export const lsCommand = {
25
25
  name: "ls",
26
26
  description: "List directory contents",
27
27
  category: "navigation",
28
- params: ["[path]"],
28
+ params: ["[-la] [path]"],
29
29
  run: ({ authUser, shell, cwd, args }) => {
30
30
  const longFormat = ifFlag(args, ["-l", "--long"]);
31
- const targetArg = getArg(args, 0, { flags: ["-l", "--long"] });
31
+ const showHidden = ifFlag(args, ["-a", "--all"]);
32
+ const targetArg = getArg(args, 0, {
33
+ flags: ["-l", "--long", "-a", "--all", "-la", "-al"],
34
+ });
32
35
  const target = resolvePath(cwd, targetArg ?? cwd);
33
36
  assertPathAccess(authUser, target, "ls");
34
37
  const items = shell.vfs
35
38
  .list(target)
36
- .filter((name) => !name.startsWith("."));
39
+ .filter((name) => showHidden || !name.startsWith("."));
37
40
  const rendered = longFormat
38
41
  ? items
39
42
  .map((name) => {
@@ -0,0 +1,3 @@
1
+ import type { ShellModule } from "../types/commands";
2
+ export declare const lsbReleaseCommand: ShellModule;
3
+ //# sourceMappingURL=lsb-release.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lsb-release.d.ts","sourceRoot":"","sources":["../../src/commands/lsb-release.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,eAAO,MAAM,iBAAiB,EAAE,WAsD/B,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { ifFlag } from "./command-helpers";
2
+ export const lsbReleaseCommand = {
3
+ name: "lsb_release",
4
+ description: "Print distribution-specific information",
5
+ category: "system",
6
+ params: ["[-a] [-i] [-d] [-r] [-c]"],
7
+ run: ({ args, shell }) => {
8
+ let osName = shell.properties?.os ?? "Fortune GNU/Linux x64";
9
+ let codename = "aurora";
10
+ let version = "1.0";
11
+ try {
12
+ const content = shell.vfs.readFile("/etc/os-release");
13
+ for (const line of content.split("\n")) {
14
+ if (line.startsWith("PRETTY_NAME="))
15
+ osName = line
16
+ .slice("PRETTY_NAME=".length)
17
+ .replace(/^"|"$/g, "")
18
+ .trim();
19
+ if (line.startsWith("VERSION_CODENAME="))
20
+ codename = line.slice("VERSION_CODENAME=".length).trim();
21
+ if (line.startsWith("VERSION_ID="))
22
+ version = line
23
+ .slice("VERSION_ID=".length)
24
+ .replace(/^"|"$/g, "")
25
+ .trim();
26
+ }
27
+ }
28
+ catch { }
29
+ const all = ifFlag(args, ["-a", "--all"]);
30
+ const showId = ifFlag(args, ["-i", "--id"]);
31
+ const showDesc = ifFlag(args, ["-d", "--description"]);
32
+ const showRelease = ifFlag(args, ["-r", "--release"]);
33
+ const showCodename = ifFlag(args, ["-c", "--codename"]);
34
+ if (all || args.length === 0) {
35
+ return {
36
+ stdout: [
37
+ `Distributor ID:\tFortune`,
38
+ `Description:\t${osName}`,
39
+ `Release:\t${version}`,
40
+ `Codename:\t${codename}`,
41
+ ].join("\n"),
42
+ exitCode: 0,
43
+ };
44
+ }
45
+ const lines = [];
46
+ if (showId)
47
+ lines.push(`Distributor ID:\tFortune`);
48
+ if (showDesc)
49
+ lines.push(`Description:\t${osName}`);
50
+ if (showRelease)
51
+ lines.push(`Release:\t${version}`);
52
+ if (showCodename)
53
+ lines.push(`Codename:\t${codename}`);
54
+ return { stdout: lines.join("\n"), exitCode: 0 };
55
+ },
56
+ };
@@ -0,0 +1,3 @@
1
+ import type { ShellModule } from "../types/commands";
2
+ export declare const manCommand: ShellModule;
3
+ //# sourceMappingURL=man.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"man.d.ts","sourceRoot":"","sources":["../../src/commands/man.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiJrD,eAAO,MAAM,UAAU,EAAE,WAoBxB,CAAC"}