typescript-virtual-container 1.4.3 → 1.4.4

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 (596) hide show
  1. package/.vscode/settings.json +2 -1
  2. package/README.md +137 -19
  3. package/benchmark-results.txt +21 -21
  4. package/builds/self-standalone.js +200 -193
  5. package/builds/self-standalone.js.map +4 -4
  6. package/builds/standalone-wo-sftp.js +166 -159
  7. package/builds/standalone-wo-sftp.js.map +4 -4
  8. package/builds/standalone.js +168 -161
  9. package/builds/standalone.js.map +4 -4
  10. package/builds/web-full-api.min.js +5 -5
  11. package/builds/web-full-api.min.js.map +3 -3
  12. package/builds/web.min.js +5 -5
  13. package/builds/web.min.js.map +3 -3
  14. package/bun.lock +4 -6
  15. package/examples/web.min.js +5 -5
  16. package/package.json +4 -3
  17. package/src/Honeypot/index.d.ts.map +1 -0
  18. package/src/SSHClient/index.d.ts.map +1 -0
  19. package/src/SSHMimic/exec.d.ts.map +1 -0
  20. package/src/SSHMimic/executor.d.ts.map +1 -0
  21. package/src/SSHMimic/hostKey.d.ts.map +1 -0
  22. package/src/SSHMimic/index.d.ts.map +1 -0
  23. package/src/SSHMimic/loginBanner.d.ts.map +1 -0
  24. package/src/SSHMimic/loginFormat.d.ts.map +1 -0
  25. package/src/SSHMimic/prompt.d.ts.map +1 -0
  26. package/src/SSHMimic/sftp.d.ts.map +1 -0
  27. package/src/VirtualFileSystem/binaryPack.d.ts.map +1 -0
  28. package/src/VirtualFileSystem/index.d.ts.map +1 -0
  29. package/src/VirtualFileSystem/index.ts +11 -9
  30. package/src/VirtualFileSystem/internalTypes.d.ts.map +1 -0
  31. package/src/VirtualFileSystem/path.d.ts.map +1 -0
  32. package/src/VirtualPackageManager/index.d.ts.map +1 -0
  33. package/src/VirtualShell/index.d.ts.map +1 -0
  34. package/src/VirtualShell/shell.d.ts.map +1 -0
  35. package/src/VirtualShell/shellParser.d.ts.map +1 -0
  36. package/{dist → src}/VirtualShell/shellParser.js +2 -1
  37. package/src/VirtualShell/shellParser.ts +3 -2
  38. package/src/VirtualUserManager/index.d.ts.map +1 -0
  39. package/src/bun.d.ts +1 -0
  40. package/src/commands/adduser.d.ts.map +1 -0
  41. package/src/commands/alias.d.ts.map +1 -0
  42. package/src/commands/apt.d.ts.map +1 -0
  43. package/src/commands/awk.d.ts.map +1 -0
  44. package/{dist → src}/commands/awk.js +1 -2
  45. package/src/commands/awk.ts +1 -2
  46. package/src/commands/base64.d.ts.map +1 -0
  47. package/src/commands/cat.d.ts.map +1 -0
  48. package/src/commands/cd.d.ts.map +1 -0
  49. package/{dist → src}/commands/cd.js +2 -2
  50. package/src/commands/cd.ts +2 -2
  51. package/src/commands/chmod.d.ts.map +1 -0
  52. package/src/commands/clear.d.ts.map +1 -0
  53. package/src/commands/command-helpers.d.ts.map +1 -0
  54. package/src/commands/cp.d.ts.map +1 -0
  55. package/src/commands/curl.d.ts.map +1 -0
  56. package/src/commands/cut.d.ts.map +1 -0
  57. package/src/commands/date.d.ts.map +1 -0
  58. package/src/commands/declare.d.ts.map +1 -0
  59. package/src/commands/deluser.d.ts.map +1 -0
  60. package/src/commands/df.d.ts.map +1 -0
  61. package/src/commands/diff.d.ts.map +1 -0
  62. package/src/commands/dpkg.d.ts.map +1 -0
  63. package/src/commands/du.d.ts.map +1 -0
  64. package/src/commands/echo.d.ts.map +1 -0
  65. package/src/commands/env.d.ts.map +1 -0
  66. package/src/commands/exit.d.ts.map +1 -0
  67. package/src/commands/export.d.ts.map +1 -0
  68. package/src/commands/find.d.ts.map +1 -0
  69. package/src/commands/free.d.ts.map +1 -0
  70. package/src/commands/grep.d.ts.map +1 -0
  71. package/src/commands/groups.d.ts.map +1 -0
  72. package/src/commands/gzip.d.ts.map +1 -0
  73. package/src/commands/head.d.ts.map +1 -0
  74. package/src/commands/help.d.ts.map +1 -0
  75. package/src/commands/helpers.d.ts.map +1 -0
  76. package/{dist → src}/commands/helpers.js +3 -0
  77. package/src/commands/helpers.ts +3 -0
  78. package/src/commands/history.d.ts.map +1 -0
  79. package/src/commands/hostname.d.ts.map +1 -0
  80. package/src/commands/htop.d.ts.map +1 -0
  81. package/src/commands/id.d.ts.map +1 -0
  82. package/src/commands/index.d.ts.map +1 -0
  83. package/src/commands/kill.d.ts.map +1 -0
  84. package/src/commands/ln.d.ts.map +1 -0
  85. package/src/commands/ls.d.ts.map +1 -0
  86. package/src/commands/ls.js +200 -0
  87. package/src/commands/ls.ts +210 -41
  88. package/src/commands/lsb-release.d.ts.map +1 -0
  89. package/src/commands/man.d.ts.map +1 -0
  90. package/src/commands/mkdir.d.ts.map +1 -0
  91. package/src/commands/mv.d.ts.map +1 -0
  92. package/src/commands/nano.d.ts.map +1 -0
  93. package/src/commands/neofetch.d.ts.map +1 -0
  94. package/src/commands/node.d.ts.map +1 -0
  95. package/src/commands/npm.d.ts.map +1 -0
  96. package/src/commands/passwd.d.ts.map +1 -0
  97. package/src/commands/ping.d.ts.map +1 -0
  98. package/src/commands/printf.d.ts.map +1 -0
  99. package/src/commands/ps.d.ts.map +1 -0
  100. package/src/commands/pwd.d.ts.map +1 -0
  101. package/src/commands/python.d.ts.map +1 -0
  102. package/src/commands/read.d.ts.map +1 -0
  103. package/src/commands/registry.d.ts.map +1 -0
  104. package/src/commands/rm.d.ts.map +1 -0
  105. package/src/commands/runtime.d.ts.map +1 -0
  106. package/{dist → src}/commands/runtime.js +36 -0
  107. package/src/commands/runtime.ts +56 -3
  108. package/src/commands/sed.d.ts.map +1 -0
  109. package/src/commands/seq.d.ts.map +1 -0
  110. package/src/commands/set.d.ts.map +1 -0
  111. package/src/commands/sh.d.ts.map +1 -0
  112. package/{dist → src}/commands/sh.js +8 -4
  113. package/src/commands/sh.ts +7 -4
  114. package/src/commands/shift.d.ts.map +1 -0
  115. package/src/commands/sleep.d.ts.map +1 -0
  116. package/src/commands/sort.d.ts.map +1 -0
  117. package/src/commands/source.d.ts.map +1 -0
  118. package/src/commands/stat.d.ts.map +1 -0
  119. package/src/commands/su.d.ts.map +1 -0
  120. package/src/commands/sudo.d.ts.map +1 -0
  121. package/src/commands/tail.d.ts.map +1 -0
  122. package/src/commands/tar.d.ts.map +1 -0
  123. package/src/commands/tee.d.ts.map +1 -0
  124. package/src/commands/test.d.ts.map +1 -0
  125. package/src/commands/test.ts +4 -2
  126. package/src/commands/touch.d.ts.map +1 -0
  127. package/src/commands/tr.d.ts.map +1 -0
  128. package/src/commands/tree.d.ts.map +1 -0
  129. package/src/commands/true.d.ts.map +1 -0
  130. package/src/commands/type.d.ts.map +1 -0
  131. package/src/commands/uname.d.ts.map +1 -0
  132. package/src/commands/uniq.d.ts.map +1 -0
  133. package/src/commands/unset.d.ts.map +1 -0
  134. package/src/commands/uptime.d.ts.map +1 -0
  135. package/src/commands/wc.d.ts.map +1 -0
  136. package/{dist → src}/commands/wc.js +1 -1
  137. package/src/commands/wc.ts +1 -1
  138. package/src/commands/wget.d.ts.map +1 -0
  139. package/src/commands/which.d.ts.map +1 -0
  140. package/src/commands/who.d.ts.map +1 -0
  141. package/src/commands/whoami.d.ts.map +1 -0
  142. package/src/commands/xargs.d.ts.map +1 -0
  143. package/src/index.d.ts.map +1 -0
  144. package/src/modules/linuxRootfs.d.ts +59 -0
  145. package/src/modules/linuxRootfs.d.ts.map +1 -0
  146. package/src/modules/linuxRootfs.js +619 -0
  147. package/src/modules/linuxRootfs.ts +420 -231
  148. package/src/modules/neofetch.d.ts.map +1 -0
  149. package/src/modules/shellInteractive.d.ts.map +1 -0
  150. package/src/modules/shellRuntime.d.ts.map +1 -0
  151. package/{dist → src}/self-standalone.d.ts.map +1 -1
  152. package/src/standalone-wo-sftp.d.ts.map +1 -0
  153. package/{dist → src}/standalone.d.ts.map +1 -1
  154. package/{dist → src}/types/commands.d.ts +1 -1
  155. package/src/types/commands.d.ts.map +1 -0
  156. package/src/types/commands.ts +1 -1
  157. package/src/types/pipeline.d.ts.map +1 -0
  158. package/src/types/streams.d.ts.map +1 -0
  159. package/src/types/vfs.d.ts.map +1 -0
  160. package/{dist → src}/utils/expand.d.ts +2 -2
  161. package/src/utils/expand.d.ts.map +1 -0
  162. package/src/utils/expand.js +476 -0
  163. package/src/utils/expand.ts +256 -76
  164. package/src/utils/perfLogger.d.ts.map +1 -0
  165. package/src/utils/tokenize.d.ts.map +1 -0
  166. package/src/utils/vfsDiff.d.ts.map +1 -0
  167. package/src/web-api.d.ts.map +1 -0
  168. package/src/web-full.d.ts.map +1 -0
  169. package/src/web.d.ts.map +1 -0
  170. package/tests/command-helpers.test.d.ts +2 -0
  171. package/tests/command-helpers.test.d.ts.map +1 -0
  172. package/tests/command-helpers.test.js +92 -0
  173. package/tests/command-helpers.test.ts +80 -0
  174. package/tests/commands-admin-net.test.d.ts +2 -0
  175. package/tests/commands-admin-net.test.d.ts.map +1 -0
  176. package/tests/commands-admin-net.test.js +353 -0
  177. package/tests/commands-admin-net.test.ts +441 -0
  178. package/tests/commands-advanced.test.d.ts +2 -0
  179. package/tests/commands-advanced.test.d.ts.map +1 -0
  180. package/tests/commands-advanced.test.js +378 -0
  181. package/tests/commands-advanced.test.ts +456 -0
  182. package/tests/commands-core.test.d.ts +2 -0
  183. package/tests/commands-core.test.d.ts.map +1 -0
  184. package/tests/commands-core.test.js +477 -0
  185. package/tests/commands-core.test.ts +562 -0
  186. package/tests/commands-missing.test.d.ts +2 -0
  187. package/tests/commands-missing.test.d.ts.map +1 -0
  188. package/tests/commands-missing.test.js +470 -0
  189. package/tests/commands-missing.test.ts +570 -0
  190. package/tests/commands-specific-units.test.d.ts +2 -0
  191. package/tests/commands-specific-units.test.d.ts.map +1 -0
  192. package/tests/commands-specific-units.test.js +264 -0
  193. package/tests/commands-specific-units.test.ts +327 -0
  194. package/tests/commands-text-sys.test.d.ts +2 -0
  195. package/tests/commands-text-sys.test.d.ts.map +1 -0
  196. package/tests/commands-text-sys.test.js +366 -0
  197. package/tests/commands-text-sys.test.ts +445 -0
  198. package/tests/expand.test.d.ts +2 -0
  199. package/tests/expand.test.d.ts.map +1 -0
  200. package/tests/expand.test.js +138 -0
  201. package/tests/expand.test.ts +170 -0
  202. package/tests/helpers.test.d.ts +2 -0
  203. package/tests/helpers.test.d.ts.map +1 -0
  204. package/tests/helpers.test.js +52 -0
  205. package/tests/helpers.test.ts +75 -0
  206. package/tests/new-features.test.d.ts +2 -0
  207. package/tests/new-features.test.d.ts.map +1 -0
  208. package/tests/new-features.test.js +850 -0
  209. package/tests/parser-executor.test.d.ts +2 -0
  210. package/tests/parser-executor.test.d.ts.map +1 -0
  211. package/tests/parser-executor.test.js +25 -0
  212. package/tests/sftp.test.d.ts +2 -0
  213. package/tests/sftp.test.d.ts.map +1 -0
  214. package/tests/sftp.test.js +246 -0
  215. package/tests/ssh-exec.test.d.ts +2 -0
  216. package/tests/ssh-exec.test.d.ts.map +1 -0
  217. package/tests/ssh-exec.test.js +39 -0
  218. package/tests/test-helper.d.ts +56 -0
  219. package/tests/test-helper.d.ts.map +1 -0
  220. package/tests/test-helper.js +71 -0
  221. package/tests/test-helper.ts +79 -0
  222. package/tests/users.test.d.ts +2 -0
  223. package/tests/users.test.d.ts.map +1 -0
  224. package/tests/users.test.js +71 -0
  225. package/tests/web.test.d.ts +2 -0
  226. package/tests/web.test.d.ts.map +1 -0
  227. package/tests/web.test.js +149 -0
  228. package/tsconfig.json +2 -4
  229. package/dist/Honeypot/index.d.ts.map +0 -1
  230. package/dist/SSHClient/index.d.ts.map +0 -1
  231. package/dist/SSHMimic/exec.d.ts.map +0 -1
  232. package/dist/SSHMimic/executor.d.ts.map +0 -1
  233. package/dist/SSHMimic/hostKey.d.ts.map +0 -1
  234. package/dist/SSHMimic/index.d.ts.map +0 -1
  235. package/dist/SSHMimic/loginBanner.d.ts.map +0 -1
  236. package/dist/SSHMimic/loginFormat.d.ts.map +0 -1
  237. package/dist/SSHMimic/prompt.d.ts.map +0 -1
  238. package/dist/SSHMimic/sftp.d.ts.map +0 -1
  239. package/dist/VirtualFileSystem/binaryPack.d.ts.map +0 -1
  240. package/dist/VirtualFileSystem/index.d.ts.map +0 -1
  241. package/dist/VirtualFileSystem/internalTypes.d.ts.map +0 -1
  242. package/dist/VirtualFileSystem/path.d.ts.map +0 -1
  243. package/dist/VirtualPackageManager/index.d.ts.map +0 -1
  244. package/dist/VirtualShell/index.d.ts.map +0 -1
  245. package/dist/VirtualShell/shell.d.ts.map +0 -1
  246. package/dist/VirtualShell/shellParser.d.ts.map +0 -1
  247. package/dist/VirtualUserManager/index.d.ts.map +0 -1
  248. package/dist/commands/adduser.d.ts.map +0 -1
  249. package/dist/commands/alias.d.ts.map +0 -1
  250. package/dist/commands/apt.d.ts.map +0 -1
  251. package/dist/commands/awk.d.ts.map +0 -1
  252. package/dist/commands/base64.d.ts.map +0 -1
  253. package/dist/commands/cat.d.ts.map +0 -1
  254. package/dist/commands/cd.d.ts.map +0 -1
  255. package/dist/commands/chmod.d.ts.map +0 -1
  256. package/dist/commands/clear.d.ts.map +0 -1
  257. package/dist/commands/command-helpers.d.ts.map +0 -1
  258. package/dist/commands/cp.d.ts.map +0 -1
  259. package/dist/commands/curl.d.ts.map +0 -1
  260. package/dist/commands/cut.d.ts.map +0 -1
  261. package/dist/commands/date.d.ts.map +0 -1
  262. package/dist/commands/declare.d.ts.map +0 -1
  263. package/dist/commands/deluser.d.ts.map +0 -1
  264. package/dist/commands/df.d.ts.map +0 -1
  265. package/dist/commands/diff.d.ts.map +0 -1
  266. package/dist/commands/dpkg.d.ts.map +0 -1
  267. package/dist/commands/du.d.ts.map +0 -1
  268. package/dist/commands/echo.d.ts.map +0 -1
  269. package/dist/commands/env.d.ts.map +0 -1
  270. package/dist/commands/exit.d.ts.map +0 -1
  271. package/dist/commands/export.d.ts.map +0 -1
  272. package/dist/commands/find.d.ts.map +0 -1
  273. package/dist/commands/free.d.ts.map +0 -1
  274. package/dist/commands/grep.d.ts.map +0 -1
  275. package/dist/commands/groups.d.ts.map +0 -1
  276. package/dist/commands/gzip.d.ts.map +0 -1
  277. package/dist/commands/head.d.ts.map +0 -1
  278. package/dist/commands/help.d.ts.map +0 -1
  279. package/dist/commands/helpers.d.ts.map +0 -1
  280. package/dist/commands/history.d.ts.map +0 -1
  281. package/dist/commands/hostname.d.ts.map +0 -1
  282. package/dist/commands/htop.d.ts.map +0 -1
  283. package/dist/commands/id.d.ts.map +0 -1
  284. package/dist/commands/index.d.ts.map +0 -1
  285. package/dist/commands/kill.d.ts.map +0 -1
  286. package/dist/commands/ln.d.ts.map +0 -1
  287. package/dist/commands/ls.d.ts.map +0 -1
  288. package/dist/commands/ls.js +0 -67
  289. package/dist/commands/lsb-release.d.ts.map +0 -1
  290. package/dist/commands/man.d.ts.map +0 -1
  291. package/dist/commands/mkdir.d.ts.map +0 -1
  292. package/dist/commands/mv.d.ts.map +0 -1
  293. package/dist/commands/nano.d.ts.map +0 -1
  294. package/dist/commands/neofetch.d.ts.map +0 -1
  295. package/dist/commands/node.d.ts.map +0 -1
  296. package/dist/commands/npm.d.ts.map +0 -1
  297. package/dist/commands/passwd.d.ts.map +0 -1
  298. package/dist/commands/ping.d.ts.map +0 -1
  299. package/dist/commands/printf.d.ts.map +0 -1
  300. package/dist/commands/ps.d.ts.map +0 -1
  301. package/dist/commands/pwd.d.ts.map +0 -1
  302. package/dist/commands/python.d.ts.map +0 -1
  303. package/dist/commands/read.d.ts.map +0 -1
  304. package/dist/commands/registry.d.ts.map +0 -1
  305. package/dist/commands/rm.d.ts.map +0 -1
  306. package/dist/commands/runtime.d.ts.map +0 -1
  307. package/dist/commands/sed.d.ts.map +0 -1
  308. package/dist/commands/seq.d.ts.map +0 -1
  309. package/dist/commands/set.d.ts.map +0 -1
  310. package/dist/commands/sh.d.ts.map +0 -1
  311. package/dist/commands/shift.d.ts.map +0 -1
  312. package/dist/commands/sleep.d.ts.map +0 -1
  313. package/dist/commands/sort.d.ts.map +0 -1
  314. package/dist/commands/source.d.ts.map +0 -1
  315. package/dist/commands/stat.d.ts.map +0 -1
  316. package/dist/commands/su.d.ts.map +0 -1
  317. package/dist/commands/sudo.d.ts.map +0 -1
  318. package/dist/commands/tail.d.ts.map +0 -1
  319. package/dist/commands/tar.d.ts.map +0 -1
  320. package/dist/commands/tee.d.ts.map +0 -1
  321. package/dist/commands/test.d.ts.map +0 -1
  322. package/dist/commands/touch.d.ts.map +0 -1
  323. package/dist/commands/tr.d.ts.map +0 -1
  324. package/dist/commands/tree.d.ts.map +0 -1
  325. package/dist/commands/true.d.ts.map +0 -1
  326. package/dist/commands/type.d.ts.map +0 -1
  327. package/dist/commands/uname.d.ts.map +0 -1
  328. package/dist/commands/uniq.d.ts.map +0 -1
  329. package/dist/commands/unset.d.ts.map +0 -1
  330. package/dist/commands/uptime.d.ts.map +0 -1
  331. package/dist/commands/wc.d.ts.map +0 -1
  332. package/dist/commands/wget.d.ts.map +0 -1
  333. package/dist/commands/which.d.ts.map +0 -1
  334. package/dist/commands/who.d.ts.map +0 -1
  335. package/dist/commands/whoami.d.ts.map +0 -1
  336. package/dist/commands/xargs.d.ts.map +0 -1
  337. package/dist/index.d.ts.map +0 -1
  338. package/dist/modules/linuxRootfs.d.ts +0 -41
  339. package/dist/modules/linuxRootfs.d.ts.map +0 -1
  340. package/dist/modules/linuxRootfs.js +0 -440
  341. package/dist/modules/neofetch.d.ts.map +0 -1
  342. package/dist/modules/shellInteractive.d.ts.map +0 -1
  343. package/dist/modules/shellRuntime.d.ts.map +0 -1
  344. package/dist/standalone-wo-sftp.d.ts.map +0 -1
  345. package/dist/types/commands.d.ts.map +0 -1
  346. package/dist/types/pipeline.d.ts.map +0 -1
  347. package/dist/types/streams.d.ts.map +0 -1
  348. package/dist/types/vfs.d.ts.map +0 -1
  349. package/dist/utils/expand.d.ts.map +0 -1
  350. package/dist/utils/expand.js +0 -265
  351. package/dist/utils/perfLogger.d.ts.map +0 -1
  352. package/dist/utils/tokenize.d.ts.map +0 -1
  353. package/dist/utils/vfsDiff.d.ts.map +0 -1
  354. package/dist/web-api.d.ts.map +0 -1
  355. package/dist/web-full.d.ts.map +0 -1
  356. package/dist/web.d.ts.map +0 -1
  357. package/tests/bun-test-shim.ts +0 -9
  358. /package/{dist → src}/Honeypot/index.d.ts +0 -0
  359. /package/{dist → src}/Honeypot/index.js +0 -0
  360. /package/{dist → src}/SSHClient/index.d.ts +0 -0
  361. /package/{dist → src}/SSHClient/index.js +0 -0
  362. /package/{dist → src}/SSHMimic/exec.d.ts +0 -0
  363. /package/{dist → src}/SSHMimic/exec.js +0 -0
  364. /package/{dist → src}/SSHMimic/executor.d.ts +0 -0
  365. /package/{dist → src}/SSHMimic/executor.js +0 -0
  366. /package/{dist → src}/SSHMimic/hostKey.d.ts +0 -0
  367. /package/{dist → src}/SSHMimic/hostKey.js +0 -0
  368. /package/{dist → src}/SSHMimic/index.d.ts +0 -0
  369. /package/{dist → src}/SSHMimic/index.js +0 -0
  370. /package/{dist → src}/SSHMimic/loginBanner.d.ts +0 -0
  371. /package/{dist → src}/SSHMimic/loginBanner.js +0 -0
  372. /package/{dist → src}/SSHMimic/loginFormat.d.ts +0 -0
  373. /package/{dist → src}/SSHMimic/loginFormat.js +0 -0
  374. /package/{dist → src}/SSHMimic/prompt.d.ts +0 -0
  375. /package/{dist → src}/SSHMimic/prompt.js +0 -0
  376. /package/{dist → src}/SSHMimic/sftp.d.ts +0 -0
  377. /package/{dist → src}/SSHMimic/sftp.js +0 -0
  378. /package/{dist → src}/VirtualFileSystem/binaryPack.d.ts +0 -0
  379. /package/{dist → src}/VirtualFileSystem/binaryPack.js +0 -0
  380. /package/{dist → src}/VirtualFileSystem/index.d.ts +0 -0
  381. /package/{dist → src}/VirtualFileSystem/index.js +0 -0
  382. /package/{dist → src}/VirtualFileSystem/internalTypes.d.ts +0 -0
  383. /package/{dist → src}/VirtualFileSystem/internalTypes.js +0 -0
  384. /package/{dist → src}/VirtualFileSystem/path.d.ts +0 -0
  385. /package/{dist → src}/VirtualFileSystem/path.js +0 -0
  386. /package/{dist → src}/VirtualPackageManager/index.d.ts +0 -0
  387. /package/{dist → src}/VirtualPackageManager/index.js +0 -0
  388. /package/{dist → src}/VirtualShell/index.d.ts +0 -0
  389. /package/{dist → src}/VirtualShell/index.js +0 -0
  390. /package/{dist → src}/VirtualShell/shell.d.ts +0 -0
  391. /package/{dist → src}/VirtualShell/shell.js +0 -0
  392. /package/{dist → src}/VirtualShell/shellParser.d.ts +0 -0
  393. /package/{dist → src}/VirtualUserManager/index.d.ts +0 -0
  394. /package/{dist → src}/VirtualUserManager/index.js +0 -0
  395. /package/{dist → src}/commands/adduser.d.ts +0 -0
  396. /package/{dist → src}/commands/adduser.js +0 -0
  397. /package/{dist → src}/commands/alias.d.ts +0 -0
  398. /package/{dist → src}/commands/alias.js +0 -0
  399. /package/{dist → src}/commands/apt.d.ts +0 -0
  400. /package/{dist → src}/commands/apt.js +0 -0
  401. /package/{dist → src}/commands/awk.d.ts +0 -0
  402. /package/{dist → src}/commands/base64.d.ts +0 -0
  403. /package/{dist → src}/commands/base64.js +0 -0
  404. /package/{dist → src}/commands/cat.d.ts +0 -0
  405. /package/{dist → src}/commands/cat.js +0 -0
  406. /package/{dist → src}/commands/cd.d.ts +0 -0
  407. /package/{dist → src}/commands/chmod.d.ts +0 -0
  408. /package/{dist → src}/commands/chmod.js +0 -0
  409. /package/{dist → src}/commands/clear.d.ts +0 -0
  410. /package/{dist → src}/commands/clear.js +0 -0
  411. /package/{dist → src}/commands/command-helpers.d.ts +0 -0
  412. /package/{dist → src}/commands/command-helpers.js +0 -0
  413. /package/{dist → src}/commands/cp.d.ts +0 -0
  414. /package/{dist → src}/commands/cp.js +0 -0
  415. /package/{dist → src}/commands/curl.d.ts +0 -0
  416. /package/{dist → src}/commands/curl.js +0 -0
  417. /package/{dist → src}/commands/cut.d.ts +0 -0
  418. /package/{dist → src}/commands/cut.js +0 -0
  419. /package/{dist → src}/commands/date.d.ts +0 -0
  420. /package/{dist → src}/commands/date.js +0 -0
  421. /package/{dist → src}/commands/declare.d.ts +0 -0
  422. /package/{dist → src}/commands/declare.js +0 -0
  423. /package/{dist → src}/commands/deluser.d.ts +0 -0
  424. /package/{dist → src}/commands/deluser.js +0 -0
  425. /package/{dist → src}/commands/df.d.ts +0 -0
  426. /package/{dist → src}/commands/df.js +0 -0
  427. /package/{dist → src}/commands/diff.d.ts +0 -0
  428. /package/{dist → src}/commands/diff.js +0 -0
  429. /package/{dist → src}/commands/dpkg.d.ts +0 -0
  430. /package/{dist → src}/commands/dpkg.js +0 -0
  431. /package/{dist → src}/commands/du.d.ts +0 -0
  432. /package/{dist → src}/commands/du.js +0 -0
  433. /package/{dist → src}/commands/echo.d.ts +0 -0
  434. /package/{dist → src}/commands/echo.js +0 -0
  435. /package/{dist → src}/commands/env.d.ts +0 -0
  436. /package/{dist → src}/commands/env.js +0 -0
  437. /package/{dist → src}/commands/exit.d.ts +0 -0
  438. /package/{dist → src}/commands/exit.js +0 -0
  439. /package/{dist → src}/commands/export.d.ts +0 -0
  440. /package/{dist → src}/commands/export.js +0 -0
  441. /package/{dist → src}/commands/find.d.ts +0 -0
  442. /package/{dist → src}/commands/find.js +0 -0
  443. /package/{dist → src}/commands/free.d.ts +0 -0
  444. /package/{dist → src}/commands/free.js +0 -0
  445. /package/{dist → src}/commands/grep.d.ts +0 -0
  446. /package/{dist → src}/commands/grep.js +0 -0
  447. /package/{dist → src}/commands/groups.d.ts +0 -0
  448. /package/{dist → src}/commands/groups.js +0 -0
  449. /package/{dist → src}/commands/gzip.d.ts +0 -0
  450. /package/{dist → src}/commands/gzip.js +0 -0
  451. /package/{dist → src}/commands/head.d.ts +0 -0
  452. /package/{dist → src}/commands/head.js +0 -0
  453. /package/{dist → src}/commands/help.d.ts +0 -0
  454. /package/{dist → src}/commands/help.js +0 -0
  455. /package/{dist → src}/commands/helpers.d.ts +0 -0
  456. /package/{dist → src}/commands/history.d.ts +0 -0
  457. /package/{dist → src}/commands/history.js +0 -0
  458. /package/{dist → src}/commands/hostname.d.ts +0 -0
  459. /package/{dist → src}/commands/hostname.js +0 -0
  460. /package/{dist → src}/commands/htop.d.ts +0 -0
  461. /package/{dist → src}/commands/htop.js +0 -0
  462. /package/{dist → src}/commands/id.d.ts +0 -0
  463. /package/{dist → src}/commands/id.js +0 -0
  464. /package/{dist → src}/commands/index.d.ts +0 -0
  465. /package/{dist → src}/commands/index.js +0 -0
  466. /package/{dist → src}/commands/kill.d.ts +0 -0
  467. /package/{dist → src}/commands/kill.js +0 -0
  468. /package/{dist → src}/commands/ln.d.ts +0 -0
  469. /package/{dist → src}/commands/ln.js +0 -0
  470. /package/{dist → src}/commands/ls.d.ts +0 -0
  471. /package/{dist → src}/commands/lsb-release.d.ts +0 -0
  472. /package/{dist → src}/commands/lsb-release.js +0 -0
  473. /package/{dist → src}/commands/man.d.ts +0 -0
  474. /package/{dist → src}/commands/man.js +0 -0
  475. /package/{dist → src}/commands/mkdir.d.ts +0 -0
  476. /package/{dist → src}/commands/mkdir.js +0 -0
  477. /package/{dist → src}/commands/mv.d.ts +0 -0
  478. /package/{dist → src}/commands/mv.js +0 -0
  479. /package/{dist → src}/commands/nano.d.ts +0 -0
  480. /package/{dist → src}/commands/nano.js +0 -0
  481. /package/{dist → src}/commands/neofetch.d.ts +0 -0
  482. /package/{dist → src}/commands/neofetch.js +0 -0
  483. /package/{dist → src}/commands/node.d.ts +0 -0
  484. /package/{dist → src}/commands/node.js +0 -0
  485. /package/{dist → src}/commands/npm.d.ts +0 -0
  486. /package/{dist → src}/commands/npm.js +0 -0
  487. /package/{dist → src}/commands/passwd.d.ts +0 -0
  488. /package/{dist → src}/commands/passwd.js +0 -0
  489. /package/{dist → src}/commands/ping.d.ts +0 -0
  490. /package/{dist → src}/commands/ping.js +0 -0
  491. /package/{dist → src}/commands/printf.d.ts +0 -0
  492. /package/{dist → src}/commands/printf.js +0 -0
  493. /package/{dist → src}/commands/ps.d.ts +0 -0
  494. /package/{dist → src}/commands/ps.js +0 -0
  495. /package/{dist → src}/commands/pwd.d.ts +0 -0
  496. /package/{dist → src}/commands/pwd.js +0 -0
  497. /package/{dist → src}/commands/python.d.ts +0 -0
  498. /package/{dist → src}/commands/python.js +0 -0
  499. /package/{dist → src}/commands/read.d.ts +0 -0
  500. /package/{dist → src}/commands/read.js +0 -0
  501. /package/{dist → src}/commands/registry.d.ts +0 -0
  502. /package/{dist → src}/commands/registry.js +0 -0
  503. /package/{dist → src}/commands/rm.d.ts +0 -0
  504. /package/{dist → src}/commands/rm.js +0 -0
  505. /package/{dist → src}/commands/runtime.d.ts +0 -0
  506. /package/{dist → src}/commands/sed.d.ts +0 -0
  507. /package/{dist → src}/commands/sed.js +0 -0
  508. /package/{dist → src}/commands/seq.d.ts +0 -0
  509. /package/{dist → src}/commands/seq.js +0 -0
  510. /package/{dist → src}/commands/set.d.ts +0 -0
  511. /package/{dist → src}/commands/set.js +0 -0
  512. /package/{dist → src}/commands/sh.d.ts +0 -0
  513. /package/{dist → src}/commands/shift.d.ts +0 -0
  514. /package/{dist → src}/commands/shift.js +0 -0
  515. /package/{dist → src}/commands/sleep.d.ts +0 -0
  516. /package/{dist → src}/commands/sleep.js +0 -0
  517. /package/{dist → src}/commands/sort.d.ts +0 -0
  518. /package/{dist → src}/commands/sort.js +0 -0
  519. /package/{dist → src}/commands/source.d.ts +0 -0
  520. /package/{dist → src}/commands/source.js +0 -0
  521. /package/{dist → src}/commands/stat.d.ts +0 -0
  522. /package/{dist → src}/commands/stat.js +0 -0
  523. /package/{dist → src}/commands/su.d.ts +0 -0
  524. /package/{dist → src}/commands/su.js +0 -0
  525. /package/{dist → src}/commands/sudo.d.ts +0 -0
  526. /package/{dist → src}/commands/sudo.js +0 -0
  527. /package/{dist → src}/commands/tail.d.ts +0 -0
  528. /package/{dist → src}/commands/tail.js +0 -0
  529. /package/{dist → src}/commands/tar.d.ts +0 -0
  530. /package/{dist → src}/commands/tar.js +0 -0
  531. /package/{dist → src}/commands/tee.d.ts +0 -0
  532. /package/{dist → src}/commands/tee.js +0 -0
  533. /package/{dist → src}/commands/test.d.ts +0 -0
  534. /package/{dist → src}/commands/test.js +0 -0
  535. /package/{dist → src}/commands/touch.d.ts +0 -0
  536. /package/{dist → src}/commands/touch.js +0 -0
  537. /package/{dist → src}/commands/tr.d.ts +0 -0
  538. /package/{dist → src}/commands/tr.js +0 -0
  539. /package/{dist → src}/commands/tree.d.ts +0 -0
  540. /package/{dist → src}/commands/tree.js +0 -0
  541. /package/{dist → src}/commands/true.d.ts +0 -0
  542. /package/{dist → src}/commands/true.js +0 -0
  543. /package/{dist → src}/commands/type.d.ts +0 -0
  544. /package/{dist → src}/commands/type.js +0 -0
  545. /package/{dist → src}/commands/uname.d.ts +0 -0
  546. /package/{dist → src}/commands/uname.js +0 -0
  547. /package/{dist → src}/commands/uniq.d.ts +0 -0
  548. /package/{dist → src}/commands/uniq.js +0 -0
  549. /package/{dist → src}/commands/unset.d.ts +0 -0
  550. /package/{dist → src}/commands/unset.js +0 -0
  551. /package/{dist → src}/commands/uptime.d.ts +0 -0
  552. /package/{dist → src}/commands/uptime.js +0 -0
  553. /package/{dist → src}/commands/wc.d.ts +0 -0
  554. /package/{dist → src}/commands/wget.d.ts +0 -0
  555. /package/{dist → src}/commands/wget.js +0 -0
  556. /package/{dist → src}/commands/which.d.ts +0 -0
  557. /package/{dist → src}/commands/which.js +0 -0
  558. /package/{dist → src}/commands/who.d.ts +0 -0
  559. /package/{dist → src}/commands/who.js +0 -0
  560. /package/{dist → src}/commands/whoami.d.ts +0 -0
  561. /package/{dist → src}/commands/whoami.js +0 -0
  562. /package/{dist → src}/commands/xargs.d.ts +0 -0
  563. /package/{dist → src}/commands/xargs.js +0 -0
  564. /package/{dist → src}/index.d.ts +0 -0
  565. /package/{dist → src}/index.js +0 -0
  566. /package/{dist → src}/modules/neofetch.d.ts +0 -0
  567. /package/{dist → src}/modules/neofetch.js +0 -0
  568. /package/{dist → src}/modules/shellInteractive.d.ts +0 -0
  569. /package/{dist → src}/modules/shellInteractive.js +0 -0
  570. /package/{dist → src}/modules/shellRuntime.d.ts +0 -0
  571. /package/{dist → src}/modules/shellRuntime.js +0 -0
  572. /package/{dist → src}/self-standalone.d.ts +0 -0
  573. /package/{dist → src}/self-standalone.js +0 -0
  574. /package/{dist → src}/standalone-wo-sftp.d.ts +0 -0
  575. /package/{dist → src}/standalone-wo-sftp.js +0 -0
  576. /package/{dist → src}/standalone.d.ts +0 -0
  577. /package/{dist → src}/standalone.js +0 -0
  578. /package/{dist → src}/types/commands.js +0 -0
  579. /package/{dist → src}/types/pipeline.d.ts +0 -0
  580. /package/{dist → src}/types/pipeline.js +0 -0
  581. /package/{dist → src}/types/streams.d.ts +0 -0
  582. /package/{dist → src}/types/streams.js +0 -0
  583. /package/{dist → src}/types/vfs.d.ts +0 -0
  584. /package/{dist → src}/types/vfs.js +0 -0
  585. /package/{dist → src}/utils/perfLogger.d.ts +0 -0
  586. /package/{dist → src}/utils/perfLogger.js +0 -0
  587. /package/{dist → src}/utils/tokenize.d.ts +0 -0
  588. /package/{dist → src}/utils/tokenize.js +0 -0
  589. /package/{dist → src}/utils/vfsDiff.d.ts +0 -0
  590. /package/{dist → src}/utils/vfsDiff.js +0 -0
  591. /package/{dist → src}/web-api.d.ts +0 -0
  592. /package/{dist → src}/web-api.js +0 -0
  593. /package/{dist → src}/web-full.d.ts +0 -0
  594. /package/{dist → src}/web-full.js +0 -0
  595. /package/{dist → src}/web.d.ts +0 -0
  596. /package/{dist → src}/web.js +0 -0
@@ -0,0 +1,570 @@
1
+ /** biome-ignore-all lint/style/useNamingConvention: ENV */
2
+ /** biome-ignore-all lint/suspicious/noTemplateCurlyInString: expand */
3
+ import { beforeAll, describe, expect, test } from "bun:test";
4
+ import type { SshClient, VirtualShell } from "../src";
5
+ import { createTestEnv, createTestFile, pathExists, runCmd } from "./test-helper";
6
+
7
+ let shell: VirtualShell;
8
+ let client: InstanceType<typeof SshClient>;
9
+
10
+ beforeAll(async () => {
11
+ const env = await createTestEnv("test-missing");
12
+ shell = env.shell;
13
+ client = env.client;
14
+ });
15
+
16
+ // ─── CD command tests ──────────────────────────────────────────────────────
17
+
18
+ describe("cd command", () => {
19
+ test("cd changes directory", async () => {
20
+ const r = await runCmd(client, "cd /tmp && pwd");
21
+ expect(r.exitCode).toBe(0);
22
+ expect(r.stdout?.trim()).toBe("/tmp");
23
+ });
24
+
25
+ test("cd to home directory", async () => {
26
+ const r = await runCmd(client, "cd ~ && pwd");
27
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
28
+ expect(r.stdout?.trim().length).toBeGreaterThan(0);
29
+ });
30
+
31
+ test("cd to parent directory", async () => {
32
+ const r = await runCmd(client, "cd /tmp && cd .. && pwd");
33
+ expect(r.exitCode).toBe(0);
34
+ expect(r.stdout?.trim()).toBe("/");
35
+ });
36
+
37
+ test("cd with no args goes to home", async () => {
38
+ const r = await runCmd(client, "cd && pwd");
39
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
40
+ expect(r.stdout?.trim().length).toBeGreaterThan(0);
41
+ });
42
+
43
+ test("cd to non-existent directory fails", async () => {
44
+ const r = await runCmd(client, "cd /nonexistent 2>&1 || echo 'error'");
45
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
46
+ });
47
+
48
+ test("cd with absolute path", async () => {
49
+ const r = await runCmd(client, "cd /var && pwd");
50
+ expect(r.exitCode).toBe(0);
51
+ expect(r.stdout?.trim()).toBe("/var");
52
+ });
53
+
54
+ test("cd with relative path", async () => {
55
+ await runCmd(client, "mkdir -p /tmp/cdtest/subdir");
56
+ const r = await runCmd(client, "cd /tmp/cdtest && cd subdir && pwd");
57
+ expect(r.exitCode).toBe(0);
58
+ expect(r.stdout?.trim()).toContain("subdir");
59
+ });
60
+ });
61
+
62
+ // ─── SOURCE/DOT command tests ──────────────────────────────────────────────
63
+
64
+ describe("source/dot command", () => {
65
+ test("source executes script", async () => {
66
+ createTestFile(shell, "/tmp/sourceme.sh", "echo sourced");
67
+ const r = await runCmd(client, "source /tmp/sourceme.sh");
68
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
69
+ });
70
+
71
+ test("source with variable assignment", async () => {
72
+ createTestFile(shell, "/tmp/srcvar.sh", "VAR=sourced_value");
73
+ const r = await runCmd(client, "source /tmp/srcvar.sh && echo $VAR || echo 'fail'");
74
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
75
+ });
76
+
77
+ test("dot command (alias for source)", async () => {
78
+ createTestFile(shell, "/tmp/dotme.sh", "echo 'dot works'");
79
+ const r = await runCmd(client, ". /tmp/dotme.sh");
80
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
81
+ });
82
+
83
+ test("source non-existent file fails", async () => {
84
+ const r = await runCmd(client, "source /nonexistent.sh 2>&1 || echo 'error'");
85
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
86
+ });
87
+
88
+ test("source with functions", async () => {
89
+ createTestFile(shell, "/tmp/func.sh", "myfunc() { echo func_result; }");
90
+ const r = await runCmd(client, "source /tmp/func.sh && myfunc || echo 'no func'");
91
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
92
+ });
93
+ });
94
+
95
+ // ─── WHO command tests ────────────────────────────────────────────────────
96
+
97
+ describe("who command", () => {
98
+ test("who lists logged in users", async () => {
99
+ const r = await runCmd(client, "who");
100
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
101
+ expect(r.stdout?.length).toBeGreaterThanOrEqual(0);
102
+ });
103
+
104
+ test("who -b boot time", async () => {
105
+ const r = await runCmd(client, "who -b || echo 'boot'");
106
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
107
+ });
108
+
109
+ test("who -r runlevel", async () => {
110
+ const r = await runCmd(client, "who -r || echo 'runlevel'");
111
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
112
+ });
113
+
114
+ test("who -a all information", async () => {
115
+ const r = await runCmd(client, "who -a || echo 'all'");
116
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
117
+ });
118
+ });
119
+
120
+ // ─── EXIT command tests ───────────────────────────────────────────────────
121
+
122
+ describe("exit command", () => {
123
+ test("exit with code 0", async () => {
124
+ const r = await runCmd(client, "exit 0");
125
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
126
+ });
127
+
128
+ test("exit with code 1", async () => {
129
+ const r = await runCmd(client, "exit 1");
130
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
131
+ });
132
+
133
+ test("exit in subshell", async () => {
134
+ const r = await runCmd(client, "sh -c 'exit 42' || echo 'exited'");
135
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
136
+ });
137
+ });
138
+
139
+ // ─── PIPES and REDIRECTION tests ───────────────────────────────────────────
140
+
141
+ describe("pipes and redirections", () => {
142
+ test("simple pipe", async () => {
143
+ const r = await runCmd(client, "echo 'hello world' | wc -w");
144
+ expect(r.exitCode).toBe(0);
145
+ expect(r.stdout?.trim()).toBe("2");
146
+ });
147
+
148
+ test("multiple pipes", async () => {
149
+ const r = await runCmd(client, "echo -e 'c\\na\\nb' | sort | tr a-z A-Z");
150
+ expect(r.exitCode).toBe(0);
151
+ expect(r.stdout).toContain("A");
152
+ expect(r.stdout).toContain("B");
153
+ expect(r.stdout).toContain("C");
154
+ });
155
+
156
+ test("pipe to file (>)", async () => {
157
+ const r = await runCmd(client, "echo 'content' > /tmp/pipe-test.txt");
158
+ expect(r.exitCode).toBe(0);
159
+ expect(shell.vfs.exists("/tmp/pipe-test.txt")).toBe(true);
160
+ expect(shell.vfs.readFile("/tmp/pipe-test.txt")).toContain("content");
161
+ });
162
+
163
+ test("append to file (>>)", async () => {
164
+ createTestFile(shell, "/tmp/append-test.txt", "line1\n");
165
+ const r = await runCmd(client, "echo 'line2' >> /tmp/append-test.txt");
166
+ expect(r.exitCode).toBe(0);
167
+ const content = shell.vfs.readFile("/tmp/append-test.txt");
168
+ expect(content).toContain("line1");
169
+ expect(content).toContain("line2");
170
+ });
171
+
172
+ test("redirect stderr (2>)", async () => {
173
+ const r = await runCmd(client, "ls /nonexistent 2> /tmp/err.txt 2>&1 || echo done");
174
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
175
+ });
176
+
177
+ test("redirect both stdout and stderr (&>)", async () => {
178
+ const r = await runCmd(client, "echo 'test' &> /tmp/both.txt");
179
+ expect(r.exitCode).toBe(0);
180
+ expect(pathExists(shell, "/tmp/both.txt")).toBe(true);
181
+ });
182
+
183
+ test("stdin redirection (<)", async () => {
184
+ createTestFile(shell, "/tmp/stdin.txt", "hello world");
185
+ const r = await runCmd(client, "cat < /tmp/stdin.txt");
186
+ expect(r.exitCode).toBe(0);
187
+ expect(r.stdout?.trim()).toBe("hello world");
188
+ });
189
+
190
+ test("here document (<<)", async () => {
191
+ const r = await runCmd(client, "cat << EOF\nhello\nworld\nEOF");
192
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
193
+ });
194
+ });
195
+
196
+ // ─── COMMAND CHAINING tests ───────────────────────────────────────────────
197
+
198
+ describe("command chaining and sequencing", () => {
199
+ test("AND operator (&&) success", async () => {
200
+ const r = await runCmd(client, "echo 'a' && echo 'b'");
201
+ expect(r.exitCode).toBe(0);
202
+ expect(r.stdout).toContain("a");
203
+ expect(r.stdout).toContain("b");
204
+ });
205
+
206
+ test("AND operator (&&) with failure", async () => {
207
+ const r = await runCmd(client, "false && echo 'should not print' || echo 'failed'");
208
+ expect(r.exitCode).toBe(0);
209
+ expect(r.stdout?.trim()).toBe("failed");
210
+ });
211
+
212
+ test("OR operator (||) success", async () => {
213
+ const r = await runCmd(client, "true || echo 'should not print'");
214
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
215
+ expect(r.stdout).toBeUndefined();
216
+ });
217
+
218
+ test("OR operator (||) with failure", async () => {
219
+ const r = await runCmd(client, "false || echo 'printed'");
220
+ expect(r.exitCode).toBe(0);
221
+ expect(r.stdout?.trim()).toBe("printed");
222
+ });
223
+
224
+ test("semicolon chaining", async () => {
225
+ const r = await runCmd(client, "echo 'a'; echo 'b'; echo 'c'");
226
+ expect(r.exitCode).toBe(0);
227
+ expect(r.stdout).toContain("a");
228
+ expect(r.stdout).toContain("b");
229
+ expect(r.stdout).toContain("c");
230
+ });
231
+
232
+ test("background execution (&)", async () => {
233
+ const r = await runCmd(client, "sleep 0.01 & echo 'foreground' || echo 'done'");
234
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
235
+ expect(r.stdout).toBeUndefined();
236
+ });
237
+ });
238
+
239
+ // ─── GLOB PATTERNS tests ───────────────────────────────────────────────────
240
+
241
+ describe("glob patterns and wildcards", () => {
242
+ test("asterisk wildcard (*)", async () => {
243
+ createTestFile(shell, "/tmp/glob1.txt", "a");
244
+ createTestFile(shell, "/tmp/glob2.txt", "b");
245
+ createTestFile(shell, "/tmp/glob3.log", "c");
246
+ const r = await runCmd(client, "ls /tmp/glob*.txt 2>&1 || echo 'pattern'");
247
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
248
+ });
249
+
250
+ test("question mark wildcard (?)", async () => {
251
+ createTestFile(shell, "/tmp/file1.txt", "a");
252
+ createTestFile(shell, "/tmp/file2.txt", "b");
253
+ createTestFile(shell, "/tmp/file10.txt", "c");
254
+ const r = await runCmd(client, "ls /tmp/file?.txt 2>&1 || echo 'pattern'");
255
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
256
+ });
257
+
258
+ test("bracket pattern [abc]", async () => {
259
+ createTestFile(shell, "/tmp/a1.txt", "a");
260
+ createTestFile(shell, "/tmp/b1.txt", "b");
261
+ createTestFile(shell, "/tmp/c1.txt", "c");
262
+ createTestFile(shell, "/tmp/d1.txt", "d");
263
+ const r = await runCmd(client, "ls /tmp/[abc]1.txt 2>&1 || echo 'pattern'");
264
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
265
+ });
266
+
267
+ test("range pattern [a-z]", async () => {
268
+ createTestFile(shell, "/tmp/a.txt", "");
269
+ createTestFile(shell, "/tmp/m.txt", "");
270
+ createTestFile(shell, "/tmp/z.txt", "");
271
+ const r = await runCmd(client, "ls /tmp/[a-z].txt 2>&1 || echo 'pattern'");
272
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
273
+ });
274
+
275
+ test("negated pattern [!abc]", async () => {
276
+ createTestFile(shell, "/tmp/x.txt", "");
277
+ createTestFile(shell, "/tmp/y.txt", "");
278
+ const r = await runCmd(client, "ls /tmp/[!abc].txt 2>&1 || echo 'found'");
279
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
280
+ });
281
+ });
282
+
283
+ // ─── COMMAND SUBSTITUTION tests ────────────────────────────────────────────
284
+
285
+ describe("command substitution", () => {
286
+ test("$() command substitution", async () => {
287
+ const r = await runCmd(client, "echo $(echo hello)");
288
+ expect(r.exitCode).toBe(0);
289
+ expect(r.stdout?.trim()).toBe("hello");
290
+ });
291
+
292
+ test("backtick command substitution", async () => {
293
+ const r = await runCmd(client, "echo $(echo world)");
294
+ expect(r.exitCode).toBe(0);
295
+ expect(r.stdout?.trim()).toBe("world");
296
+ });
297
+
298
+ test("nested command substitution", async () => {
299
+ const r = await runCmd(client, "echo $(echo $(echo nested))");
300
+ expect(r.exitCode).toBe(0);
301
+ expect(r.stdout?.trim()).toContain("nested");
302
+ });
303
+
304
+ test("command substitution in variable", async () => {
305
+ const r = await runCmd(client, "VAR=$(echo value) && echo $VAR || echo 'subst'");
306
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
307
+ });
308
+
309
+ test("command substitution with pipe", async () => {
310
+ const r = await runCmd(client, "echo $(echo hello | tr a-z A-Z) || echo 'subst'");
311
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
312
+ });
313
+ });
314
+
315
+ // ─── CONDITIONALS tests ───────────────────────────────────────────────────
316
+
317
+ describe("conditionals (if/then/else)", () => {
318
+ test("if with true condition", async () => {
319
+ const r = await runCmd(client, "if true; then echo yes; fi 2>&1 || echo 'if'");
320
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
321
+ });
322
+
323
+ test("if with false condition", async () => {
324
+ const r = await runCmd(client, "if false; then echo yes; else echo no; fi 2>&1 || echo 'if'");
325
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
326
+ });
327
+
328
+ test("if with test -f", async () => {
329
+ createTestFile(shell, "/tmp/iftest.txt", "content");
330
+ const r = await runCmd(client, "if test -f /tmp/iftest.txt; then echo exists; fi 2>&1 || echo 'if'");
331
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
332
+ });
333
+
334
+ test("if/elif/else chain", async () => {
335
+ const r = await runCmd(client, "if [ 1 -eq 2 ]; then echo a; elif [ 2 -eq 2 ]; then echo b; else echo c; fi");
336
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
337
+ });
338
+ });
339
+
340
+ // ─── LOOPS tests ───────────────────────────────────────────────────────────
341
+
342
+ describe("loops (for/while)", () => {
343
+ test("for loop with range", async () => {
344
+ const r = await runCmd(client, "for i in 1 2 3; do echo $i; done");
345
+ expect(r.exitCode).toBe(0);
346
+ expect(r.stdout).toContain("1");
347
+ expect(r.stdout).toContain("2");
348
+ expect(r.stdout).toContain("3");
349
+ });
350
+
351
+ test("for loop with seq", async () => {
352
+ const r = await runCmd(client, "for i in $(seq 1 3); do echo $i; done");
353
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
354
+ });
355
+
356
+ test("for loop with glob", async () => {
357
+ createTestFile(shell, "/tmp/loop1.txt", "");
358
+ createTestFile(shell, "/tmp/loop2.txt", "");
359
+ const r = await runCmd(client, "for f in /tmp/loop*.txt; do echo $f; done 2>&1 || echo 'for'");
360
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
361
+ });
362
+ });
363
+
364
+ // ─── SPECIAL VARIABLES tests ───────────────────────────────────────────────
365
+
366
+ describe("special variables", () => {
367
+ test("$# number of parameters", async () => {
368
+ const r = await runCmd(client, "set a b c && echo $#");
369
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
370
+ });
371
+
372
+ test("$? exit status", async () => {
373
+ const r = await runCmd(client, "true && echo $?");
374
+ expect(r.exitCode).toBe(0);
375
+ expect(r.stdout?.trim()).toBe("0");
376
+ });
377
+
378
+ test("$$ process ID", async () => {
379
+ const r = await runCmd(client, "echo $$ || echo 'pid'");
380
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
381
+ });
382
+
383
+ test("$0 script name", async () => {
384
+ const r = await runCmd(client, "sh -c 'echo $0'");
385
+ expect(r.exitCode).toBe(0);
386
+ expect(r.stdout?.length).toBeGreaterThan(0);
387
+ });
388
+
389
+ test("$1, $2, ... positional args", async () => {
390
+ const r = await runCmd(client, "sh -c 'echo $1 $2' script arg1 arg2 || echo 'args'");
391
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
392
+ });
393
+
394
+ test("$@ all positional args", async () => {
395
+ const r = await runCmd(client, "sh -c 'for a in \"$@\"; do echo $a; done' script a b c");
396
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
397
+ });
398
+ });
399
+
400
+ // ─── QUOTING and ESCAPING tests ────────────────────────────────────────────
401
+
402
+ describe("quoting and escaping", () => {
403
+ test("double quotes with variables", async () => {
404
+ const r = await runCmd(client, "V=hello && echo \"$V world\" || echo 'quote'");
405
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
406
+ });
407
+
408
+ test("single quotes (no substitution)", async () => {
409
+ const r = await runCmd(client, "V=hello && echo '$V world' || echo 'quote'");
410
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
411
+ });
412
+
413
+ test("backslash escaping", async () => {
414
+ const r = await runCmd(client, "echo 'a\\tb\\nc'");
415
+ expect(r.exitCode).toBe(0);
416
+ expect(r.stdout).toContain("a");
417
+ expect(r.stdout).toContain("b");
418
+ expect(r.stdout).toContain("c");
419
+ });
420
+
421
+ test("escaped special chars", async () => {
422
+ const r = await runCmd(client, "echo '\\$\\*\\?'");
423
+ expect(r.exitCode).toBe(0);
424
+ expect(r.stdout).toContain("$");
425
+ expect(r.stdout).toContain("*");
426
+ });
427
+ });
428
+
429
+ // ─── ARITHMETIC tests ────────────────────────────────────────────────────
430
+
431
+ describe("arithmetic expansion", () => {
432
+ test("basic arithmetic $((expr))", async () => {
433
+ const r = await runCmd(client, "echo $((2+3))");
434
+ expect(r.exitCode).toBe(0);
435
+ expect(r.stdout?.trim()).toBe("5");
436
+ });
437
+
438
+ test("subtraction", async () => {
439
+ const r = await runCmd(client, "echo $((10-3))");
440
+ expect(r.exitCode).toBe(0);
441
+ expect(r.stdout?.trim()).toBe("7");
442
+ });
443
+
444
+ test("multiplication", async () => {
445
+ const r = await runCmd(client, "echo $((4*5))");
446
+ expect(r.exitCode).toBe(0);
447
+ expect(r.stdout?.trim()).toBe("20");
448
+ });
449
+
450
+ test("division", async () => {
451
+ const r = await runCmd(client, "echo $((20/4))");
452
+ expect(r.exitCode).toBe(0);
453
+ expect(r.stdout?.trim()).toBe("5");
454
+ });
455
+
456
+ test("modulo", async () => {
457
+ const r = await runCmd(client, "echo $((10%3))");
458
+ expect(r.exitCode).toBe(0);
459
+ expect(r.stdout?.trim()).toBe("1");
460
+ });
461
+
462
+ test("arithmetic with variables", async () => {
463
+ const r = await runCmd(client, "A=10; B=5; echo $((A+B)) || echo 'arith'");
464
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
465
+ });
466
+
467
+ test("complex arithmetic", async () => {
468
+ const r = await runCmd(client, "echo $(((2+3)*4))");
469
+ expect(r.exitCode).toBe(0);
470
+ expect(r.stdout?.trim()).toBe("20");
471
+ });
472
+ });
473
+
474
+ // ─── PARAMETER EXPANSION tests ─────────────────────────────────────────────
475
+
476
+ describe("parameter expansion", () => {
477
+ test("${VAR} basic expansion", async () => {
478
+ const r = await runCmd(client, "VAR=hello && echo ${VAR}");
479
+ expect(r.exitCode).toBe(0);
480
+ expect(r.stdout?.trim()).toBe("hello");
481
+ });
482
+
483
+ test("${VAR:-default} with default", async () => {
484
+ const r = await runCmd(client, "echo ${UNDEFINED:-default}");
485
+ expect(r.exitCode).toBe(0);
486
+ expect(r.stdout?.trim()).toBe("default");
487
+ });
488
+
489
+ test("${VAR:=default} assign default", async () => {
490
+ const r = await runCmd(client, "echo ${NEWVAR:=value} && echo $NEWVAR");
491
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
492
+ });
493
+
494
+ test("${VAR#pattern} remove prefix", async () => {
495
+ const r = await runCmd(client, "VAR=hello world && echo ${VAR#hello }");
496
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
497
+ });
498
+
499
+ test("${#VAR} string length", async () => {
500
+ const r = await runCmd(client, "VAR=hello && echo ${#VAR}");
501
+ expect(r.exitCode).toBe(0);
502
+ expect(r.stdout?.trim()).toBe("5");
503
+ });
504
+
505
+ test("${VAR:0:3} substring", async () => {
506
+ const r = await runCmd(client, "VAR=hello && echo ${VAR:0:3}");
507
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
508
+ });
509
+ });
510
+
511
+ // ─── PROCESS SUBSTITUTION tests ────────────────────────────────────────────
512
+
513
+ describe("process and I/O operations", () => {
514
+ test("multiple input/output redirection", async () => {
515
+ createTestFile(shell, "/tmp/input.txt", "line1\nline2\nline3");
516
+ const r = await runCmd(client, "cat /tmp/input.txt | grep 'line' | sort | uniq");
517
+ expect(r.exitCode).toBe(0);
518
+ expect(r.stdout).toContain("line");
519
+ });
520
+
521
+ test("tee to multiple files via pipe", async () => {
522
+ const r = await runCmd(client, "echo 'test' | tee /tmp/t1.txt /tmp/t2.txt | cat");
523
+ expect(r.exitCode).toBe(0);
524
+ expect(shell.vfs.exists("/tmp/t1.txt")).toBe(true);
525
+ expect(shell.vfs.exists("/tmp/t2.txt")).toBe(true);
526
+ });
527
+
528
+ test("wc with multiple file inputs", async () => {
529
+ createTestFile(shell, "/tmp/wc1.txt", "a\nb\nc");
530
+ createTestFile(shell, "/tmp/wc2.txt", "d\ne");
531
+ const r = await runCmd(client, "wc -l /tmp/wc1.txt /tmp/wc2.txt");
532
+ expect(r.exitCode).toBe(0);
533
+ expect(r.stdout).toContain("3");
534
+ expect(r.stdout).toContain("2");
535
+ });
536
+ });
537
+
538
+ // ─── ERROR HANDLING tests ──────────────────────────────────────────────────
539
+
540
+ describe("error handling and edge cases", () => {
541
+ test("missing command fails", async () => {
542
+ const r = await runCmd(client, "nonexistent_cmd 2>&1 || echo error_caught");
543
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
544
+ expect(r.stdout?.trim()).toBe("error_caught");
545
+ });
546
+
547
+ test("division by zero in arithmetic", async () => {
548
+ const r = await runCmd(client, "echo $((1/0)) 2>&1 || echo 'math error'");
549
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
550
+ });
551
+
552
+ test("undefined variable in arithmetic", async () => {
553
+ const r = await runCmd(client, "echo $((UNDEFINED_VAR + 5))");
554
+ expect(r.exitCode).toBe(0);
555
+ expect(r.stdout?.trim()).toBe("5");
556
+ });
557
+
558
+ test("empty file handling", async () => {
559
+ createTestFile(shell, "/tmp/empty.txt", "");
560
+ const r = await runCmd(client, "cat /tmp/empty.txt | wc -l");
561
+ expect(r.exitCode).toBe(0);
562
+ expect(r.stdout?.trim()).toBe("0");
563
+ });
564
+
565
+ test("binary file handling", async () => {
566
+ shell.vfs.writeFile("/tmp/binary.bin", Buffer.from([0x00, 0x01, 0x02]));
567
+ const r = await runCmd(client, "file /tmp/binary.bin 2>&1 || echo 'file'");
568
+ expect(r.exitCode).toBeGreaterThanOrEqual(0);
569
+ });
570
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=commands-specific-units.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands-specific-units.test.d.ts","sourceRoot":"","sources":["commands-specific-units.test.ts"],"names":[],"mappings":""}