typescript-virtual-container 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builds/self-standalone.js +321 -272
- package/builds/self-standalone.js.map +4 -4
- package/builds/standalone-wo-sftp.js +261 -212
- package/builds/standalone-wo-sftp.js.map +4 -4
- package/builds/standalone.js +265 -216
- package/builds/standalone.js.map +4 -4
- package/builds/web-full-api.min.js +5 -5
- package/builds/web-full-api.min.js.map +3 -3
- package/builds/web.min.js +5 -5
- package/builds/web.min.js.map +3 -3
- package/bun.lock +97 -0
- package/dist/Honeypot/index.d.ts.map +1 -0
- package/dist/Honeypot/index.js +299 -0
- package/dist/Honeypot/index.js.map +1 -0
- package/dist/SSHClient/index.d.ts.map +1 -0
- package/dist/SSHClient/index.js +238 -0
- package/dist/SSHClient/index.js.map +1 -0
- package/dist/SSHMimic/exec.d.ts.map +1 -0
- package/dist/SSHMimic/exec.js +28 -0
- package/dist/SSHMimic/exec.js.map +1 -0
- package/dist/SSHMimic/executor.d.ts.map +1 -0
- package/dist/SSHMimic/executor.js +161 -0
- package/dist/SSHMimic/executor.js.map +1 -0
- package/dist/SSHMimic/hostKey.d.ts.map +1 -0
- package/dist/SSHMimic/hostKey.js +18 -0
- package/dist/SSHMimic/hostKey.js.map +1 -0
- package/dist/SSHMimic/index.d.ts.map +1 -0
- package/dist/SSHMimic/index.js +250 -0
- package/dist/SSHMimic/index.js.map +1 -0
- package/dist/SSHMimic/loginBanner.d.ts.map +1 -0
- package/dist/SSHMimic/loginBanner.js +23 -0
- package/dist/SSHMimic/loginBanner.js.map +1 -0
- package/dist/SSHMimic/loginFormat.d.ts.map +1 -0
- package/dist/SSHMimic/loginFormat.js +11 -0
- package/dist/SSHMimic/loginFormat.js.map +1 -0
- package/dist/SSHMimic/prompt.d.ts.map +1 -0
- package/dist/SSHMimic/prompt.js +10 -0
- package/dist/SSHMimic/prompt.js.map +1 -0
- package/dist/SSHMimic/sftp.d.ts.map +1 -0
- package/dist/SSHMimic/sftp.js +620 -0
- package/dist/SSHMimic/sftp.js.map +1 -0
- package/dist/VirtualFileSystem/binaryPack.d.ts.map +1 -0
- package/dist/VirtualFileSystem/binaryPack.js +217 -0
- package/dist/VirtualFileSystem/binaryPack.js.map +1 -0
- package/dist/VirtualFileSystem/index.d.ts.map +1 -0
- package/dist/VirtualFileSystem/index.js +690 -0
- package/dist/VirtualFileSystem/index.js.map +1 -0
- package/dist/VirtualFileSystem/internalTypes.d.ts.map +1 -0
- package/dist/VirtualFileSystem/internalTypes.js +1 -0
- package/dist/VirtualFileSystem/internalTypes.js.map +1 -0
- package/dist/VirtualFileSystem/path.d.ts.map +1 -0
- package/dist/VirtualFileSystem/path.js +50 -0
- package/dist/VirtualFileSystem/path.js.map +1 -0
- package/dist/VirtualPackageManager/index.d.ts.map +1 -0
- package/dist/VirtualPackageManager/index.js +854 -0
- package/dist/VirtualPackageManager/index.js.map +1 -0
- package/dist/VirtualShell/index.d.ts.map +1 -0
- package/dist/VirtualShell/index.js +285 -0
- package/dist/VirtualShell/index.js.map +1 -0
- package/dist/VirtualShell/shell.d.ts.map +1 -0
- package/dist/VirtualShell/shell.js +503 -0
- package/dist/VirtualShell/shell.js.map +1 -0
- package/dist/VirtualShell/shellParser.d.ts.map +1 -0
- package/dist/VirtualShell/shellParser.js +266 -0
- package/dist/VirtualShell/shellParser.js.map +1 -0
- package/dist/VirtualUserManager/index.d.ts.map +1 -0
- package/dist/VirtualUserManager/index.js +608 -0
- package/dist/VirtualUserManager/index.js.map +1 -0
- package/dist/commands/adduser.d.ts.map +1 -0
- package/dist/commands/adduser.js +90 -0
- package/dist/commands/adduser.js.map +1 -0
- package/dist/commands/alias.d.ts.map +1 -0
- package/dist/commands/alias.js +69 -0
- package/dist/commands/alias.js.map +1 -0
- package/dist/commands/apt.d.ts.map +1 -0
- package/dist/commands/apt.js +211 -0
- package/dist/commands/apt.js.map +1 -0
- package/dist/commands/awk.d.ts.map +1 -0
- package/dist/commands/awk.js +170 -0
- package/dist/commands/awk.js.map +1 -0
- package/dist/commands/base64.d.ts.map +1 -0
- package/dist/commands/base64.js +29 -0
- package/dist/commands/base64.js.map +1 -0
- package/dist/commands/cat.d.ts.map +1 -0
- package/dist/commands/cat.js +45 -0
- package/dist/commands/cat.js.map +1 -0
- package/dist/commands/cd.d.ts.map +1 -0
- package/dist/commands/cd.js +22 -0
- package/dist/commands/cd.js.map +1 -0
- package/dist/commands/chmod.d.ts.map +1 -0
- package/dist/commands/chmod.js +88 -0
- package/dist/commands/chmod.js.map +1 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +14 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/command-helpers.d.ts.map +1 -0
- package/dist/commands/command-helpers.js +222 -0
- package/dist/commands/command-helpers.js.map +1 -0
- package/dist/commands/cp.d.ts.map +1 -0
- package/dist/commands/cp.js +76 -0
- package/dist/commands/cp.js.map +1 -0
- package/dist/commands/curl.d.ts.map +1 -0
- package/dist/commands/curl.js +128 -0
- package/dist/commands/curl.js.map +1 -0
- package/dist/commands/cut.d.ts.map +1 -0
- package/dist/commands/cut.js +35 -0
- package/dist/commands/cut.js.map +1 -0
- package/dist/commands/date.d.ts.map +1 -0
- package/dist/commands/date.js +29 -0
- package/dist/commands/date.js.map +1 -0
- package/dist/commands/declare.d.ts.map +1 -0
- package/dist/commands/declare.js +45 -0
- package/dist/commands/declare.js.map +1 -0
- package/dist/commands/deluser.d.ts.map +1 -0
- package/dist/commands/deluser.js +84 -0
- package/dist/commands/deluser.js.map +1 -0
- package/dist/commands/df.d.ts.map +1 -0
- package/dist/commands/df.js +22 -0
- package/dist/commands/df.js.map +1 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +46 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/dpkg.d.ts.map +1 -0
- package/dist/commands/dpkg.js +162 -0
- package/dist/commands/dpkg.js.map +1 -0
- package/dist/commands/du.d.ts.map +1 -0
- package/dist/commands/du.js +51 -0
- package/dist/commands/du.js.map +1 -0
- package/dist/commands/echo.d.ts.map +1 -0
- package/dist/commands/echo.js +46 -0
- package/dist/commands/echo.js.map +1 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +21 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/exit.d.ts.map +1 -0
- package/dist/commands/exit.js +17 -0
- package/dist/commands/exit.js.map +1 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +34 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/find.d.ts.map +1 -0
- package/dist/commands/find.js +56 -0
- package/dist/commands/find.js.map +1 -0
- package/dist/commands/free.d.ts.map +1 -0
- package/dist/commands/free.js +44 -0
- package/dist/commands/free.js.map +1 -0
- package/dist/commands/grep.d.ts.map +1 -0
- package/dist/commands/grep.js +121 -0
- package/dist/commands/grep.js.map +1 -0
- package/dist/commands/groups.d.ts.map +1 -0
- package/dist/commands/groups.js +18 -0
- package/dist/commands/groups.js.map +1 -0
- package/dist/commands/gzip.d.ts.map +1 -0
- package/dist/commands/gzip.js +83 -0
- package/dist/commands/gzip.js.map +1 -0
- package/dist/commands/head.d.ts.map +1 -0
- package/dist/commands/head.js +47 -0
- package/dist/commands/head.js.map +1 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +124 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/helpers.d.ts.map +1 -0
- package/dist/commands/helpers.js +167 -0
- package/dist/commands/helpers.js.map +1 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +27 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/hostname.d.ts.map +1 -0
- package/dist/commands/hostname.js +13 -0
- package/dist/commands/hostname.js.map +1 -0
- package/dist/commands/htop.d.ts.map +1 -0
- package/dist/commands/htop.js +18 -0
- package/dist/commands/htop.js.map +1 -0
- package/dist/commands/id.d.ts.map +1 -0
- package/dist/commands/id.js +18 -0
- package/dist/commands/id.js.map +1 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +3 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/kill.d.ts.map +1 -0
- package/dist/commands/kill.js +19 -0
- package/dist/commands/kill.js.map +1 -0
- package/dist/commands/ln.d.ts.map +1 -0
- package/dist/commands/ln.js +67 -0
- package/dist/commands/ln.js.map +1 -0
- package/dist/commands/ls.d.ts.map +1 -0
- package/dist/commands/ls.js +201 -0
- package/dist/commands/ls.js.map +1 -0
- package/dist/commands/lsb-release.d.ts.map +1 -0
- package/dist/commands/lsb-release.js +62 -0
- package/dist/commands/lsb-release.js.map +1 -0
- package/dist/commands/man.d.ts.map +1 -0
- package/dist/commands/man.js +50 -0
- package/dist/commands/man.js.map +1 -0
- package/dist/commands/mkdir.d.ts.map +1 -0
- package/dist/commands/mkdir.js +29 -0
- package/dist/commands/mkdir.js.map +1 -0
- package/dist/commands/mv.d.ts.map +1 -0
- package/dist/commands/mv.js +43 -0
- package/dist/commands/mv.js.map +1 -0
- package/dist/commands/nano.d.ts.map +1 -0
- package/dist/commands/nano.js +35 -0
- package/dist/commands/nano.js.map +1 -0
- package/dist/commands/neofetch.d.ts.map +1 -0
- package/dist/commands/neofetch.js +49 -0
- package/dist/commands/neofetch.js.map +1 -0
- package/dist/commands/node.d.ts.map +1 -0
- package/dist/commands/node.js +317 -0
- package/dist/commands/node.js.map +1 -0
- package/dist/commands/npm.d.ts.map +1 -0
- package/dist/commands/npm.js +110 -0
- package/dist/commands/npm.js.map +1 -0
- package/dist/commands/passwd.d.ts.map +1 -0
- package/dist/commands/passwd.js +45 -0
- package/dist/commands/passwd.js.map +1 -0
- package/dist/commands/ping.d.ts.map +1 -0
- package/dist/commands/ping.js +29 -0
- package/dist/commands/ping.js.map +1 -0
- package/dist/commands/printf.d.ts.map +1 -0
- package/dist/commands/printf.js +145 -0
- package/dist/commands/printf.js.map +1 -0
- package/dist/commands/ps.d.ts.map +1 -0
- package/dist/commands/ps.js +47 -0
- package/dist/commands/ps.js.map +1 -0
- package/dist/commands/pwd.d.ts.map +1 -0
- package/dist/commands/pwd.js +8 -0
- package/dist/commands/pwd.js.map +1 -0
- package/dist/commands/python.d.ts.map +1 -0
- package/dist/commands/python.js +2059 -0
- package/dist/commands/python.js.map +1 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +40 -0
- package/dist/commands/read.js.map +1 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +235 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/rm.d.ts.map +1 -0
- package/dist/commands/rm.js +37 -0
- package/dist/commands/rm.js.map +1 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +286 -0
- package/dist/commands/runtime.js.map +1 -0
- package/dist/commands/sed.d.ts.map +1 -0
- package/dist/commands/sed.js +61 -0
- package/dist/commands/sed.js.map +1 -0
- package/dist/commands/seq.d.ts.map +1 -0
- package/dist/commands/seq.js +51 -0
- package/dist/commands/seq.js.map +1 -0
- package/dist/commands/set.d.ts.map +1 -0
- package/dist/commands/set.js +27 -0
- package/dist/commands/set.js.map +1 -0
- package/dist/commands/sh.d.ts.map +1 -0
- package/dist/commands/sh.js +432 -0
- package/dist/commands/sh.js.map +1 -0
- package/dist/commands/shift.d.ts.map +1 -0
- package/dist/commands/shift.js +63 -0
- package/dist/commands/shift.js.map +1 -0
- package/dist/commands/sleep.d.ts.map +1 -0
- package/dist/commands/sleep.js +19 -0
- package/dist/commands/sleep.js.map +1 -0
- package/dist/commands/sort.d.ts.map +1 -0
- package/dist/commands/sort.js +45 -0
- package/dist/commands/sort.js.map +1 -0
- package/dist/commands/source.d.ts.map +1 -0
- package/dist/commands/source.js +40 -0
- package/dist/commands/source.js.map +1 -0
- package/dist/commands/stat.d.ts.map +1 -0
- package/dist/commands/stat.js +57 -0
- package/dist/commands/stat.js.map +1 -0
- package/dist/commands/su.d.ts.map +1 -0
- package/dist/commands/su.js +58 -0
- package/dist/commands/su.js.map +1 -0
- package/dist/commands/sudo.d.ts.map +1 -0
- package/dist/commands/sudo.js +55 -0
- package/dist/commands/sudo.js.map +1 -0
- package/dist/commands/tail.d.ts.map +1 -0
- package/dist/commands/tail.js +48 -0
- package/dist/commands/tail.js.map +1 -0
- package/dist/commands/tar.d.ts.map +1 -0
- package/dist/commands/tar.js +103 -0
- package/dist/commands/tar.js.map +1 -0
- package/dist/commands/tee.d.ts.map +1 -0
- package/dist/commands/tee.js +37 -0
- package/dist/commands/tee.js.map +1 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +115 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/touch.d.ts.map +1 -0
- package/dist/commands/touch.js +26 -0
- package/dist/commands/touch.js.map +1 -0
- package/dist/commands/tr.d.ts.map +1 -0
- package/dist/commands/tr.js +62 -0
- package/dist/commands/tr.js.map +1 -0
- package/dist/commands/tree.d.ts.map +1 -0
- package/dist/commands/tree.js +19 -0
- package/dist/commands/tree.js.map +1 -0
- package/dist/commands/true.d.ts.map +1 -0
- package/dist/commands/true.js +25 -0
- package/dist/commands/true.js.map +1 -0
- package/dist/commands/type.d.ts.map +1 -0
- package/dist/commands/type.js +40 -0
- package/dist/commands/type.js.map +1 -0
- package/dist/commands/uname.d.ts.map +1 -0
- package/dist/commands/uname.js +30 -0
- package/dist/commands/uname.js.map +1 -0
- package/dist/commands/uniq.d.ts.map +1 -0
- package/dist/commands/uniq.js +39 -0
- package/dist/commands/uniq.js.map +1 -0
- package/dist/commands/unset.d.ts.map +1 -0
- package/dist/commands/unset.js +17 -0
- package/dist/commands/unset.js.map +1 -0
- package/dist/commands/uptime.d.ts.map +1 -0
- package/dist/commands/uptime.js +49 -0
- package/dist/commands/uptime.js.map +1 -0
- package/dist/commands/wc.d.ts.map +1 -0
- package/dist/commands/wc.js +56 -0
- package/dist/commands/wc.js.map +1 -0
- package/dist/commands/wget.d.ts.map +1 -0
- package/dist/commands/wget.js +127 -0
- package/dist/commands/wget.js.map +1 -0
- package/dist/commands/which.d.ts.map +1 -0
- package/dist/commands/which.js +33 -0
- package/dist/commands/which.js.map +1 -0
- package/dist/commands/who.d.ts.map +1 -0
- package/dist/commands/who.js +23 -0
- package/dist/commands/who.js.map +1 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +13 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/commands/xargs.d.ts.map +1 -0
- package/dist/commands/xargs.js +22 -0
- package/dist/commands/xargs.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/linuxRootfs.d.ts.map +1 -0
- package/dist/modules/linuxRootfs.js +620 -0
- package/dist/modules/linuxRootfs.js.map +1 -0
- package/dist/modules/neofetch.d.ts.map +1 -0
- package/dist/modules/neofetch.js +285 -0
- package/dist/modules/neofetch.js.map +1 -0
- package/dist/modules/shellInteractive.d.ts.map +1 -0
- package/dist/modules/shellInteractive.js +27 -0
- package/dist/modules/shellInteractive.js.map +1 -0
- package/dist/modules/shellRuntime.d.ts.map +1 -0
- package/dist/modules/shellRuntime.js +53 -0
- package/dist/modules/shellRuntime.js.map +1 -0
- package/dist/self-standalone.d.ts.map +1 -0
- package/dist/self-standalone.js +419 -0
- package/dist/self-standalone.js.map +1 -0
- package/dist/standalone-wo-sftp.d.ts.map +1 -0
- package/dist/standalone-wo-sftp.js +31 -0
- package/dist/standalone-wo-sftp.js.map +1 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/standalone.js +36 -0
- package/dist/standalone.js.map +1 -0
- package/dist/types/commands.d.ts.map +1 -0
- package/dist/types/commands.js +1 -0
- package/dist/types/commands.js.map +1 -0
- package/dist/types/pipeline.d.ts.map +1 -0
- package/dist/types/pipeline.js +1 -0
- package/dist/types/pipeline.js.map +1 -0
- package/dist/types/streams.d.ts.map +1 -0
- package/dist/types/streams.js +1 -0
- package/dist/types/streams.js.map +1 -0
- package/dist/types/vfs.d.ts.map +1 -0
- package/dist/types/vfs.js +1 -0
- package/dist/types/vfs.js.map +1 -0
- package/dist/utils/expand.d.ts.map +1 -0
- package/dist/utils/expand.js +477 -0
- package/dist/utils/expand.js.map +1 -0
- package/dist/utils/perfLogger.d.ts.map +1 -0
- package/dist/utils/perfLogger.js +50 -0
- package/dist/utils/perfLogger.js.map +1 -0
- package/dist/utils/tokenize.d.ts.map +1 -0
- package/dist/utils/tokenize.js +115 -0
- package/dist/utils/tokenize.js.map +1 -0
- package/dist/utils/vfsDiff.d.ts.map +1 -0
- package/dist/utils/vfsDiff.js +178 -0
- package/dist/utils/vfsDiff.js.map +1 -0
- package/dist/web-api.d.ts.map +1 -0
- package/dist/web-api.js +47 -0
- package/dist/web-api.js.map +1 -0
- package/dist/web-full.d.ts.map +1 -0
- package/dist/web-full.js +9 -0
- package/dist/web-full.js.map +1 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +774 -0
- package/dist/web.js.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +162 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1633 -0
- package/docs/classes/HoneyPot.html +31 -0
- package/docs/classes/SshClient.html +66 -0
- package/docs/classes/VirtualFileSystem.html +262 -0
- package/docs/classes/VirtualPackageManager.html +63 -0
- package/docs/classes/VirtualSftpServer.html +169 -0
- package/docs/classes/VirtualShell.html +265 -0
- package/docs/classes/VirtualSshServer.html +177 -0
- package/docs/classes/VirtualUserManager.html +276 -0
- package/docs/docs/.nojekyll +1 -0
- package/docs/docs/assets/hierarchy.js +1 -0
- package/docs/docs/assets/highlight.css +162 -0
- package/docs/docs/assets/icons.js +18 -0
- package/docs/docs/assets/icons.svg +1 -0
- package/docs/docs/assets/main.js +60 -0
- package/docs/docs/assets/navigation.js +1 -0
- package/docs/docs/assets/search.js +1 -0
- package/docs/docs/assets/style.css +1633 -0
- package/docs/docs/hierarchy.html +1 -0
- package/docs/docs/index.html +1842 -0
- package/docs/docs/media/LICENSE +21 -0
- package/docs/docs/modules.html +1 -0
- package/docs/functions/assertDiff.html +6 -0
- package/docs/functions/diffSnapshots.html +7 -0
- package/docs/functions/formatDiff.html +6 -0
- package/docs/functions/getArg.html +13 -0
- package/docs/functions/getFlag.html +15 -0
- package/docs/functions/ifFlag.html +11 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +1842 -0
- package/docs/interfaces/AuditLogEntry.html +6 -0
- package/docs/interfaces/CommandContext.html +22 -0
- package/docs/interfaces/CommandResult.html +26 -0
- package/docs/interfaces/ExecStream.html +11 -0
- package/docs/interfaces/HoneyPotStats.html +14 -0
- package/docs/interfaces/InstalledPackage.html +20 -0
- package/docs/interfaces/NanoEditorSession.html +8 -0
- package/docs/interfaces/PackageDefinition.html +30 -0
- package/docs/interfaces/PackageFile.html +8 -0
- package/docs/interfaces/RemoveOptions.html +4 -0
- package/docs/interfaces/ShellEnv.html +6 -0
- package/docs/interfaces/ShellModule.html +14 -0
- package/docs/interfaces/ShellProperties.html +14 -0
- package/docs/interfaces/ShellStream.html +11 -0
- package/docs/interfaces/SudoChallenge.html +24 -0
- package/docs/interfaces/VfsBaseNode.html +12 -0
- package/docs/interfaces/VfsDiff.html +10 -0
- package/docs/interfaces/VfsDiffEntry.html +6 -0
- package/docs/interfaces/VfsDiffModified.html +10 -0
- package/docs/interfaces/VfsDirectoryNode.html +15 -0
- package/docs/interfaces/VfsFileNode.html +17 -0
- package/docs/interfaces/VfsOptions.html +12 -0
- package/docs/interfaces/VfsSnapshot.html +3 -0
- package/docs/interfaces/VfsSnapshotBaseNode.html +8 -0
- package/docs/interfaces/VfsSnapshotDirectoryNode.html +10 -0
- package/docs/interfaces/VfsSnapshotFileNode.html +12 -0
- package/docs/interfaces/WriteFileOptions.html +6 -0
- package/docs/media/LICENSE +21 -0
- package/docs/modules.html +1 -0
- package/docs/types/CommandMode.html +2 -0
- package/docs/types/CommandOutcome.html +2 -0
- package/docs/types/VfsNodeStats.html +2 -0
- package/docs/types/VfsNodeType.html +2 -0
- package/docs/types/VfsPersistenceMode.html +5 -0
- package/docs/types/VfsSnapshotNode.html +2 -0
- package/examples/web.min.js +5 -5
- package/package.json +4 -2
- package/tsconfig.json +7 -2
- package/typedoc.json +8 -0
- package/src/Honeypot/index.d.ts.map +0 -1
- package/src/Honeypot/index.js +0 -298
- package/src/SSHClient/index.d.ts.map +0 -1
- package/src/SSHClient/index.js +0 -237
- package/src/SSHMimic/exec.d.ts.map +0 -1
- package/src/SSHMimic/exec.js +0 -27
- package/src/SSHMimic/executor.d.ts.map +0 -1
- package/src/SSHMimic/executor.js +0 -160
- package/src/SSHMimic/hostKey.d.ts.map +0 -1
- package/src/SSHMimic/hostKey.js +0 -17
- package/src/SSHMimic/index.d.ts.map +0 -1
- package/src/SSHMimic/index.js +0 -249
- package/src/SSHMimic/loginBanner.d.ts.map +0 -1
- package/src/SSHMimic/loginBanner.js +0 -22
- package/src/SSHMimic/loginFormat.d.ts.map +0 -1
- package/src/SSHMimic/loginFormat.js +0 -10
- package/src/SSHMimic/prompt.d.ts.map +0 -1
- package/src/SSHMimic/prompt.js +0 -9
- package/src/SSHMimic/sftp.d.ts.map +0 -1
- package/src/SSHMimic/sftp.js +0 -619
- package/src/VirtualFileSystem/binaryPack.d.ts.map +0 -1
- package/src/VirtualFileSystem/binaryPack.js +0 -216
- package/src/VirtualFileSystem/index.d.ts.map +0 -1
- package/src/VirtualFileSystem/index.js +0 -689
- package/src/VirtualFileSystem/internalTypes.d.ts.map +0 -1
- package/src/VirtualFileSystem/internalTypes.js +0 -0
- package/src/VirtualFileSystem/path.d.ts.map +0 -1
- package/src/VirtualFileSystem/path.js +0 -49
- package/src/VirtualPackageManager/index.d.ts.map +0 -1
- package/src/VirtualPackageManager/index.js +0 -853
- package/src/VirtualShell/index.d.ts.map +0 -1
- package/src/VirtualShell/index.js +0 -284
- package/src/VirtualShell/shell.d.ts.map +0 -1
- package/src/VirtualShell/shell.js +0 -502
- package/src/VirtualShell/shellParser.d.ts.map +0 -1
- package/src/VirtualShell/shellParser.js +0 -265
- package/src/VirtualUserManager/index.d.ts.map +0 -1
- package/src/VirtualUserManager/index.js +0 -607
- package/src/commands/adduser.d.ts.map +0 -1
- package/src/commands/adduser.js +0 -89
- package/src/commands/alias.d.ts.map +0 -1
- package/src/commands/alias.js +0 -68
- package/src/commands/apt.d.ts.map +0 -1
- package/src/commands/apt.js +0 -210
- package/src/commands/awk.d.ts.map +0 -1
- package/src/commands/awk.js +0 -169
- package/src/commands/base64.d.ts.map +0 -1
- package/src/commands/base64.js +0 -28
- package/src/commands/cat.d.ts.map +0 -1
- package/src/commands/cat.js +0 -44
- package/src/commands/cd.d.ts.map +0 -1
- package/src/commands/cd.js +0 -21
- package/src/commands/chmod.d.ts.map +0 -1
- package/src/commands/chmod.js +0 -87
- package/src/commands/clear.d.ts.map +0 -1
- package/src/commands/clear.js +0 -13
- package/src/commands/command-helpers.d.ts.map +0 -1
- package/src/commands/command-helpers.js +0 -221
- package/src/commands/cp.d.ts.map +0 -1
- package/src/commands/cp.js +0 -75
- package/src/commands/curl.d.ts.map +0 -1
- package/src/commands/curl.js +0 -127
- package/src/commands/cut.d.ts.map +0 -1
- package/src/commands/cut.js +0 -34
- package/src/commands/date.d.ts.map +0 -1
- package/src/commands/date.js +0 -28
- package/src/commands/declare.d.ts.map +0 -1
- package/src/commands/declare.js +0 -44
- package/src/commands/deluser.d.ts.map +0 -1
- package/src/commands/deluser.js +0 -83
- package/src/commands/df.d.ts.map +0 -1
- package/src/commands/df.js +0 -21
- package/src/commands/diff.d.ts.map +0 -1
- package/src/commands/diff.js +0 -45
- package/src/commands/dpkg.d.ts.map +0 -1
- package/src/commands/dpkg.js +0 -161
- package/src/commands/du.d.ts.map +0 -1
- package/src/commands/du.js +0 -50
- package/src/commands/echo.d.ts.map +0 -1
- package/src/commands/echo.js +0 -45
- package/src/commands/env.d.ts.map +0 -1
- package/src/commands/env.js +0 -20
- package/src/commands/exit.d.ts.map +0 -1
- package/src/commands/exit.js +0 -16
- package/src/commands/export.d.ts.map +0 -1
- package/src/commands/export.js +0 -33
- package/src/commands/find.d.ts.map +0 -1
- package/src/commands/find.js +0 -55
- package/src/commands/free.d.ts.map +0 -1
- package/src/commands/free.js +0 -43
- package/src/commands/grep.d.ts.map +0 -1
- package/src/commands/grep.js +0 -120
- package/src/commands/groups.d.ts.map +0 -1
- package/src/commands/groups.js +0 -17
- package/src/commands/gzip.d.ts.map +0 -1
- package/src/commands/gzip.js +0 -82
- package/src/commands/head.d.ts.map +0 -1
- package/src/commands/head.js +0 -46
- package/src/commands/help.d.ts.map +0 -1
- package/src/commands/help.js +0 -123
- package/src/commands/helpers.d.ts.map +0 -1
- package/src/commands/helpers.js +0 -166
- package/src/commands/history.d.ts.map +0 -1
- package/src/commands/history.js +0 -26
- package/src/commands/hostname.d.ts.map +0 -1
- package/src/commands/hostname.js +0 -12
- package/src/commands/htop.d.ts.map +0 -1
- package/src/commands/htop.js +0 -17
- package/src/commands/id.d.ts.map +0 -1
- package/src/commands/id.js +0 -17
- package/src/commands/index.d.ts.map +0 -1
- package/src/commands/index.js +0 -2
- package/src/commands/kill.d.ts.map +0 -1
- package/src/commands/kill.js +0 -18
- package/src/commands/ln.d.ts.map +0 -1
- package/src/commands/ln.js +0 -66
- package/src/commands/ls.d.ts.map +0 -1
- package/src/commands/ls.js +0 -200
- package/src/commands/lsb-release.d.ts.map +0 -1
- package/src/commands/lsb-release.js +0 -61
- package/src/commands/man.d.ts.map +0 -1
- package/src/commands/man.js +0 -49
- package/src/commands/mkdir.d.ts.map +0 -1
- package/src/commands/mkdir.js +0 -28
- package/src/commands/mv.d.ts.map +0 -1
- package/src/commands/mv.js +0 -42
- package/src/commands/nano.d.ts.map +0 -1
- package/src/commands/nano.js +0 -34
- package/src/commands/neofetch.d.ts.map +0 -1
- package/src/commands/neofetch.js +0 -48
- package/src/commands/node.d.ts.map +0 -1
- package/src/commands/node.js +0 -316
- package/src/commands/npm.d.ts.map +0 -1
- package/src/commands/npm.js +0 -109
- package/src/commands/passwd.d.ts.map +0 -1
- package/src/commands/passwd.js +0 -44
- package/src/commands/ping.d.ts.map +0 -1
- package/src/commands/ping.js +0 -28
- package/src/commands/printf.d.ts.map +0 -1
- package/src/commands/printf.js +0 -144
- package/src/commands/ps.d.ts.map +0 -1
- package/src/commands/ps.js +0 -46
- package/src/commands/pwd.d.ts.map +0 -1
- package/src/commands/pwd.js +0 -7
- package/src/commands/python.d.ts.map +0 -1
- package/src/commands/python.js +0 -2058
- package/src/commands/read.d.ts.map +0 -1
- package/src/commands/read.js +0 -39
- package/src/commands/registry.d.ts.map +0 -1
- package/src/commands/registry.js +0 -234
- package/src/commands/rm.d.ts.map +0 -1
- package/src/commands/rm.js +0 -36
- package/src/commands/runtime.d.ts.map +0 -1
- package/src/commands/runtime.js +0 -285
- package/src/commands/sed.d.ts.map +0 -1
- package/src/commands/sed.js +0 -60
- package/src/commands/seq.d.ts.map +0 -1
- package/src/commands/seq.js +0 -50
- package/src/commands/set.d.ts.map +0 -1
- package/src/commands/set.js +0 -26
- package/src/commands/sh.d.ts.map +0 -1
- package/src/commands/sh.js +0 -431
- package/src/commands/shift.d.ts.map +0 -1
- package/src/commands/shift.js +0 -62
- package/src/commands/sleep.d.ts.map +0 -1
- package/src/commands/sleep.js +0 -18
- package/src/commands/sort.d.ts.map +0 -1
- package/src/commands/sort.js +0 -44
- package/src/commands/source.d.ts.map +0 -1
- package/src/commands/source.js +0 -39
- package/src/commands/stat.d.ts.map +0 -1
- package/src/commands/stat.js +0 -56
- package/src/commands/su.d.ts.map +0 -1
- package/src/commands/su.js +0 -57
- package/src/commands/sudo.d.ts.map +0 -1
- package/src/commands/sudo.js +0 -54
- package/src/commands/tail.d.ts.map +0 -1
- package/src/commands/tail.js +0 -47
- package/src/commands/tar.d.ts.map +0 -1
- package/src/commands/tar.js +0 -102
- package/src/commands/tee.d.ts.map +0 -1
- package/src/commands/tee.js +0 -36
- package/src/commands/test.d.ts.map +0 -1
- package/src/commands/test.js +0 -114
- package/src/commands/touch.d.ts.map +0 -1
- package/src/commands/touch.js +0 -25
- package/src/commands/tr.d.ts.map +0 -1
- package/src/commands/tr.js +0 -61
- package/src/commands/tree.d.ts.map +0 -1
- package/src/commands/tree.js +0 -18
- package/src/commands/true.d.ts.map +0 -1
- package/src/commands/true.js +0 -24
- package/src/commands/type.d.ts.map +0 -1
- package/src/commands/type.js +0 -39
- package/src/commands/uname.d.ts.map +0 -1
- package/src/commands/uname.js +0 -29
- package/src/commands/uniq.d.ts.map +0 -1
- package/src/commands/uniq.js +0 -38
- package/src/commands/unset.d.ts.map +0 -1
- package/src/commands/unset.js +0 -16
- package/src/commands/uptime.d.ts.map +0 -1
- package/src/commands/uptime.js +0 -48
- package/src/commands/wc.d.ts.map +0 -1
- package/src/commands/wc.js +0 -55
- package/src/commands/wget.d.ts.map +0 -1
- package/src/commands/wget.js +0 -126
- package/src/commands/which.d.ts.map +0 -1
- package/src/commands/which.js +0 -32
- package/src/commands/who.d.ts.map +0 -1
- package/src/commands/who.js +0 -22
- package/src/commands/whoami.d.ts.map +0 -1
- package/src/commands/whoami.js +0 -12
- package/src/commands/xargs.d.ts.map +0 -1
- package/src/commands/xargs.js +0 -21
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -9
- package/src/modules/linuxRootfs.d.ts.map +0 -1
- package/src/modules/linuxRootfs.js +0 -619
- package/src/modules/neofetch.d.ts.map +0 -1
- package/src/modules/neofetch.js +0 -284
- package/src/modules/shellInteractive.d.ts.map +0 -1
- package/src/modules/shellInteractive.js +0 -26
- package/src/modules/shellRuntime.d.ts.map +0 -1
- package/src/modules/shellRuntime.js +0 -52
- package/src/self-standalone.d.ts.map +0 -1
- package/src/self-standalone.js +0 -418
- package/src/standalone-wo-sftp.d.ts.map +0 -1
- package/src/standalone-wo-sftp.js +0 -30
- package/src/standalone.d.ts.map +0 -1
- package/src/standalone.js +0 -35
- package/src/types/commands.d.ts.map +0 -1
- package/src/types/commands.js +0 -0
- package/src/types/pipeline.d.ts.map +0 -1
- package/src/types/pipeline.js +0 -0
- package/src/types/streams.d.ts.map +0 -1
- package/src/types/streams.js +0 -0
- package/src/types/vfs.d.ts.map +0 -1
- package/src/types/vfs.js +0 -0
- package/src/utils/expand.d.ts.map +0 -1
- package/src/utils/expand.js +0 -476
- package/src/utils/perfLogger.d.ts.map +0 -1
- package/src/utils/perfLogger.js +0 -49
- package/src/utils/tokenize.d.ts.map +0 -1
- package/src/utils/tokenize.js +0 -114
- package/src/utils/vfsDiff.d.ts.map +0 -1
- package/src/utils/vfsDiff.js +0 -177
- package/src/web-api.d.ts.map +0 -1
- package/src/web-api.js +0 -46
- package/src/web-full.d.ts.map +0 -1
- package/src/web-full.js +0 -8
- package/src/web.d.ts.map +0 -1
- package/src/web.js +0 -773
- package/tests/command-helpers.test.d.ts +0 -2
- package/tests/command-helpers.test.d.ts.map +0 -1
- package/tests/command-helpers.test.js +0 -92
- package/tests/commands-admin-net.test.d.ts +0 -2
- package/tests/commands-admin-net.test.d.ts.map +0 -1
- package/tests/commands-admin-net.test.js +0 -353
- package/tests/commands-advanced.test.d.ts +0 -2
- package/tests/commands-advanced.test.d.ts.map +0 -1
- package/tests/commands-advanced.test.js +0 -378
- package/tests/commands-core.test.d.ts +0 -2
- package/tests/commands-core.test.d.ts.map +0 -1
- package/tests/commands-core.test.js +0 -477
- package/tests/commands-missing.test.d.ts +0 -2
- package/tests/commands-missing.test.d.ts.map +0 -1
- package/tests/commands-missing.test.js +0 -470
- package/tests/commands-specific-units.test.d.ts +0 -2
- package/tests/commands-specific-units.test.d.ts.map +0 -1
- package/tests/commands-specific-units.test.js +0 -264
- package/tests/commands-text-sys.test.d.ts +0 -2
- package/tests/commands-text-sys.test.d.ts.map +0 -1
- package/tests/commands-text-sys.test.js +0 -366
- package/tests/expand.test.d.ts +0 -2
- package/tests/expand.test.d.ts.map +0 -1
- package/tests/expand.test.js +0 -138
- package/tests/helpers.test.d.ts +0 -2
- package/tests/helpers.test.d.ts.map +0 -1
- package/tests/helpers.test.js +0 -52
- package/tests/new-features.test.d.ts +0 -2
- package/tests/new-features.test.d.ts.map +0 -1
- package/tests/new-features.test.js +0 -850
- package/tests/parser-executor.test.d.ts +0 -2
- package/tests/parser-executor.test.d.ts.map +0 -1
- package/tests/parser-executor.test.js +0 -25
- package/tests/sftp.test.d.ts +0 -2
- package/tests/sftp.test.d.ts.map +0 -1
- package/tests/sftp.test.js +0 -246
- package/tests/ssh-exec.test.d.ts +0 -2
- package/tests/ssh-exec.test.d.ts.map +0 -1
- package/tests/ssh-exec.test.js +0 -39
- package/tests/test-helper.d.ts +0 -56
- package/tests/test-helper.d.ts.map +0 -1
- package/tests/test-helper.js +0 -71
- package/tests/users.test.d.ts +0 -2
- package/tests/users.test.d.ts.map +0 -1
- package/tests/users.test.js +0 -71
- package/tests/web.test.d.ts +0 -2
- package/tests/web.test.d.ts.map +0 -1
- package/tests/web.test.js +0 -149
- /package/{src → dist}/Honeypot/index.d.ts +0 -0
- /package/{src → dist}/SSHClient/index.d.ts +0 -0
- /package/{src → dist}/SSHMimic/exec.d.ts +0 -0
- /package/{src → dist}/SSHMimic/executor.d.ts +0 -0
- /package/{src → dist}/SSHMimic/hostKey.d.ts +0 -0
- /package/{src → dist}/SSHMimic/index.d.ts +0 -0
- /package/{src → dist}/SSHMimic/loginBanner.d.ts +0 -0
- /package/{src → dist}/SSHMimic/loginFormat.d.ts +0 -0
- /package/{src → dist}/SSHMimic/prompt.d.ts +0 -0
- /package/{src → dist}/SSHMimic/sftp.d.ts +0 -0
- /package/{src → dist}/VirtualFileSystem/binaryPack.d.ts +0 -0
- /package/{src → dist}/VirtualFileSystem/index.d.ts +0 -0
- /package/{src → dist}/VirtualFileSystem/internalTypes.d.ts +0 -0
- /package/{src → dist}/VirtualFileSystem/path.d.ts +0 -0
- /package/{src → dist}/VirtualPackageManager/index.d.ts +0 -0
- /package/{src → dist}/VirtualShell/index.d.ts +0 -0
- /package/{src → dist}/VirtualShell/shell.d.ts +0 -0
- /package/{src → dist}/VirtualShell/shellParser.d.ts +0 -0
- /package/{src → dist}/VirtualUserManager/index.d.ts +0 -0
- /package/{src → dist}/commands/adduser.d.ts +0 -0
- /package/{src → dist}/commands/alias.d.ts +0 -0
- /package/{src → dist}/commands/apt.d.ts +0 -0
- /package/{src → dist}/commands/awk.d.ts +0 -0
- /package/{src → dist}/commands/base64.d.ts +0 -0
- /package/{src → dist}/commands/cat.d.ts +0 -0
- /package/{src → dist}/commands/cd.d.ts +0 -0
- /package/{src → dist}/commands/chmod.d.ts +0 -0
- /package/{src → dist}/commands/clear.d.ts +0 -0
- /package/{src → dist}/commands/command-helpers.d.ts +0 -0
- /package/{src → dist}/commands/cp.d.ts +0 -0
- /package/{src → dist}/commands/curl.d.ts +0 -0
- /package/{src → dist}/commands/cut.d.ts +0 -0
- /package/{src → dist}/commands/date.d.ts +0 -0
- /package/{src → dist}/commands/declare.d.ts +0 -0
- /package/{src → dist}/commands/deluser.d.ts +0 -0
- /package/{src → dist}/commands/df.d.ts +0 -0
- /package/{src → dist}/commands/diff.d.ts +0 -0
- /package/{src → dist}/commands/dpkg.d.ts +0 -0
- /package/{src → dist}/commands/du.d.ts +0 -0
- /package/{src → dist}/commands/echo.d.ts +0 -0
- /package/{src → dist}/commands/env.d.ts +0 -0
- /package/{src → dist}/commands/exit.d.ts +0 -0
- /package/{src → dist}/commands/export.d.ts +0 -0
- /package/{src → dist}/commands/find.d.ts +0 -0
- /package/{src → dist}/commands/free.d.ts +0 -0
- /package/{src → dist}/commands/grep.d.ts +0 -0
- /package/{src → dist}/commands/groups.d.ts +0 -0
- /package/{src → dist}/commands/gzip.d.ts +0 -0
- /package/{src → dist}/commands/head.d.ts +0 -0
- /package/{src → dist}/commands/help.d.ts +0 -0
- /package/{src → dist}/commands/helpers.d.ts +0 -0
- /package/{src → dist}/commands/history.d.ts +0 -0
- /package/{src → dist}/commands/hostname.d.ts +0 -0
- /package/{src → dist}/commands/htop.d.ts +0 -0
- /package/{src → dist}/commands/id.d.ts +0 -0
- /package/{src → dist}/commands/index.d.ts +0 -0
- /package/{src → dist}/commands/kill.d.ts +0 -0
- /package/{src → dist}/commands/ln.d.ts +0 -0
- /package/{src → dist}/commands/ls.d.ts +0 -0
- /package/{src → dist}/commands/lsb-release.d.ts +0 -0
- /package/{src → dist}/commands/man.d.ts +0 -0
- /package/{src → dist}/commands/mkdir.d.ts +0 -0
- /package/{src → dist}/commands/mv.d.ts +0 -0
- /package/{src → dist}/commands/nano.d.ts +0 -0
- /package/{src → dist}/commands/neofetch.d.ts +0 -0
- /package/{src → dist}/commands/node.d.ts +0 -0
- /package/{src → dist}/commands/npm.d.ts +0 -0
- /package/{src → dist}/commands/passwd.d.ts +0 -0
- /package/{src → dist}/commands/ping.d.ts +0 -0
- /package/{src → dist}/commands/printf.d.ts +0 -0
- /package/{src → dist}/commands/ps.d.ts +0 -0
- /package/{src → dist}/commands/pwd.d.ts +0 -0
- /package/{src → dist}/commands/python.d.ts +0 -0
- /package/{src → dist}/commands/read.d.ts +0 -0
- /package/{src → dist}/commands/registry.d.ts +0 -0
- /package/{src → dist}/commands/rm.d.ts +0 -0
- /package/{src → dist}/commands/runtime.d.ts +0 -0
- /package/{src → dist}/commands/sed.d.ts +0 -0
- /package/{src → dist}/commands/seq.d.ts +0 -0
- /package/{src → dist}/commands/set.d.ts +0 -0
- /package/{src → dist}/commands/sh.d.ts +0 -0
- /package/{src → dist}/commands/shift.d.ts +0 -0
- /package/{src → dist}/commands/sleep.d.ts +0 -0
- /package/{src → dist}/commands/sort.d.ts +0 -0
- /package/{src → dist}/commands/source.d.ts +0 -0
- /package/{src → dist}/commands/stat.d.ts +0 -0
- /package/{src → dist}/commands/su.d.ts +0 -0
- /package/{src → dist}/commands/sudo.d.ts +0 -0
- /package/{src → dist}/commands/tail.d.ts +0 -0
- /package/{src → dist}/commands/tar.d.ts +0 -0
- /package/{src → dist}/commands/tee.d.ts +0 -0
- /package/{src → dist}/commands/test.d.ts +0 -0
- /package/{src → dist}/commands/touch.d.ts +0 -0
- /package/{src → dist}/commands/tr.d.ts +0 -0
- /package/{src → dist}/commands/tree.d.ts +0 -0
- /package/{src → dist}/commands/true.d.ts +0 -0
- /package/{src → dist}/commands/type.d.ts +0 -0
- /package/{src → dist}/commands/uname.d.ts +0 -0
- /package/{src → dist}/commands/uniq.d.ts +0 -0
- /package/{src → dist}/commands/unset.d.ts +0 -0
- /package/{src → dist}/commands/uptime.d.ts +0 -0
- /package/{src → dist}/commands/wc.d.ts +0 -0
- /package/{src → dist}/commands/wget.d.ts +0 -0
- /package/{src → dist}/commands/which.d.ts +0 -0
- /package/{src → dist}/commands/who.d.ts +0 -0
- /package/{src → dist}/commands/whoami.d.ts +0 -0
- /package/{src → dist}/commands/xargs.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/modules/linuxRootfs.d.ts +0 -0
- /package/{src → dist}/modules/neofetch.d.ts +0 -0
- /package/{src → dist}/modules/shellInteractive.d.ts +0 -0
- /package/{src → dist}/modules/shellRuntime.d.ts +0 -0
- /package/{src → dist}/self-standalone.d.ts +0 -0
- /package/{src → dist}/standalone-wo-sftp.d.ts +0 -0
- /package/{src → dist}/standalone.d.ts +0 -0
- /package/{src → dist}/types/commands.d.ts +0 -0
- /package/{src → dist}/types/pipeline.d.ts +0 -0
- /package/{src → dist}/types/streams.d.ts +0 -0
- /package/{src → dist}/types/vfs.d.ts +0 -0
- /package/{src → dist}/utils/expand.d.ts +0 -0
- /package/{src → dist}/utils/perfLogger.d.ts +0 -0
- /package/{src → dist}/utils/tokenize.d.ts +0 -0
- /package/{src → dist}/utils/vfsDiff.d.ts +0 -0
- /package/{src → dist}/web-api.d.ts +0 -0
- /package/{src → dist}/web-full.d.ts +0 -0
- /package/{src → dist}/web.d.ts +0 -0
|
@@ -1,850 +0,0 @@
|
|
|
1
|
-
import { beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
-
import { VirtualShell } from "../src";
|
|
3
|
-
import { SshClient } from "../src/SSHClient";
|
|
4
|
-
// ─── shared shell ─────────────────────────────────────────────────────────────
|
|
5
|
-
let shell;
|
|
6
|
-
let client;
|
|
7
|
-
beforeAll(async () => {
|
|
8
|
-
shell = new VirtualShell("test-vm");
|
|
9
|
-
await shell.ensureInitialized();
|
|
10
|
-
client = new SshClient(shell, "root");
|
|
11
|
-
});
|
|
12
|
-
// ─── Phase 1: Linux rootfs ────────────────────────────────────────────────────
|
|
13
|
-
describe("Linux rootfs", () => {
|
|
14
|
-
test("/etc/os-release exists and has correct distro", async () => {
|
|
15
|
-
const r = await client.cat("/etc/os-release");
|
|
16
|
-
expect(r.exitCode).toBe(0);
|
|
17
|
-
expect(r.stdout).toContain("Fortune GNU/Linux");
|
|
18
|
-
});
|
|
19
|
-
test("/etc/hostname exists", async () => {
|
|
20
|
-
const r = await client.cat("/etc/hostname");
|
|
21
|
-
expect(r.exitCode).toBe(0);
|
|
22
|
-
expect(r.stdout?.trim()).toBe("test-vm");
|
|
23
|
-
});
|
|
24
|
-
test("/etc/hosts has localhost", async () => {
|
|
25
|
-
const r = await client.cat("/etc/hosts");
|
|
26
|
-
expect(r.stdout).toContain("127.0.0.1");
|
|
27
|
-
expect(r.stdout).toContain("localhost");
|
|
28
|
-
});
|
|
29
|
-
test("/proc/meminfo is populated", async () => {
|
|
30
|
-
const r = await client.cat("/proc/meminfo");
|
|
31
|
-
expect(r.exitCode).toBe(0);
|
|
32
|
-
expect(r.stdout).toContain("MemTotal:");
|
|
33
|
-
expect(r.stdout).toContain("MemFree:");
|
|
34
|
-
});
|
|
35
|
-
test("/proc/cpuinfo is populated", async () => {
|
|
36
|
-
const r = await client.cat("/proc/cpuinfo");
|
|
37
|
-
expect(r.exitCode).toBe(0);
|
|
38
|
-
expect(r.stdout).toContain("processor");
|
|
39
|
-
expect(r.stdout).toContain("model name");
|
|
40
|
-
});
|
|
41
|
-
test("/proc/version is populated", async () => {
|
|
42
|
-
const r = await client.cat("/proc/version");
|
|
43
|
-
expect(r.exitCode).toBe(0);
|
|
44
|
-
expect(r.stdout).toContain("Linux version");
|
|
45
|
-
expect(r.stdout).toContain("1.0.0+itsrealfortune");
|
|
46
|
-
});
|
|
47
|
-
test("/sys/devices/virtual/dmi/id/sys_vendor exists", async () => {
|
|
48
|
-
const r = await client.cat("/sys/devices/virtual/dmi/id/sys_vendor");
|
|
49
|
-
expect(r.exitCode).toBe(0);
|
|
50
|
-
expect(r.stdout?.trim()).toBe("Fortune Systems");
|
|
51
|
-
});
|
|
52
|
-
test("/var/lib/dpkg/status is created", () => {
|
|
53
|
-
expect(shell.vfs.exists("/var/lib/dpkg/status")).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
test("/bin is symlink to /usr/bin", () => {
|
|
56
|
-
expect(shell.vfs.isSymlink("/bin")).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
test("/tmp has sticky bit", () => {
|
|
59
|
-
const stat = shell.vfs.stat("/tmp");
|
|
60
|
-
expect(stat.type).toBe("directory");
|
|
61
|
-
});
|
|
62
|
-
test("/etc/passwd contains root", async () => {
|
|
63
|
-
const r = await client.cat("/etc/passwd");
|
|
64
|
-
expect(r.stdout).toContain("root:x:0:0");
|
|
65
|
-
});
|
|
66
|
-
test("/usr/bin stubs for builtins exist", () => {
|
|
67
|
-
expect(shell.vfs.exists("/usr/bin/ls")).toBe(true);
|
|
68
|
-
expect(shell.vfs.exists("/usr/bin/grep")).toBe(true);
|
|
69
|
-
expect(shell.vfs.exists("/usr/bin/curl")).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
test("lsb_release -a returns Fortune distro info", async () => {
|
|
72
|
-
const r = await client.exec("lsb_release -a");
|
|
73
|
-
expect(r.exitCode).toBe(0);
|
|
74
|
-
expect(r.stdout).toContain("Fortune");
|
|
75
|
-
expect(r.stdout).toContain("Distributor ID");
|
|
76
|
-
});
|
|
77
|
-
test("uname -a shows kernel from properties", async () => {
|
|
78
|
-
const r = await client.exec("uname -a");
|
|
79
|
-
expect(r.exitCode).toBe(0);
|
|
80
|
-
expect(r.stdout).toContain("1.0.0+itsrealfortune+1-amd64");
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
// ─── Phase 2: apt / dpkg ──────────────────────────────────────────────────────
|
|
84
|
-
describe("Package manager (apt/dpkg)", () => {
|
|
85
|
-
test("apt list shows available packages", async () => {
|
|
86
|
-
const r = await client.exec("apt list");
|
|
87
|
-
expect(r.exitCode).toBe(0);
|
|
88
|
-
expect(r.stdout).toContain("vim");
|
|
89
|
-
expect(r.stdout).toContain("git");
|
|
90
|
-
expect(r.stdout).toContain("python3");
|
|
91
|
-
});
|
|
92
|
-
test("apt install vim installs package and writes files", async () => {
|
|
93
|
-
const r = await client.exec("apt install vim");
|
|
94
|
-
expect(r.exitCode).toBe(0);
|
|
95
|
-
expect(r.stdout).toContain("Setting up vim");
|
|
96
|
-
expect(shell.vfs.exists("/usr/bin/vim")).toBe(true);
|
|
97
|
-
expect(shell.vfs.exists("/usr/bin/vi")).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
test("apt list --installed shows vim after install", async () => {
|
|
100
|
-
const r = await client.exec("apt list --installed");
|
|
101
|
-
expect(r.stdout).toContain("vim");
|
|
102
|
-
expect(r.stdout).toContain("[installed]");
|
|
103
|
-
});
|
|
104
|
-
test("dpkg -l shows installed packages", async () => {
|
|
105
|
-
const r = await client.exec("dpkg -l");
|
|
106
|
-
expect(r.exitCode).toBe(0);
|
|
107
|
-
expect(r.stdout).toContain("vim");
|
|
108
|
-
expect(r.stdout).toContain("ii");
|
|
109
|
-
});
|
|
110
|
-
test("dpkg -s vim shows package status", async () => {
|
|
111
|
-
await client.exec("apt install vim"); // ensure installed
|
|
112
|
-
const r = await client.exec("dpkg -s vim");
|
|
113
|
-
expect(r.exitCode).toBe(0);
|
|
114
|
-
expect(r.stdout).toContain("Package: vim");
|
|
115
|
-
expect(r.stdout).toContain("Status: install ok installed");
|
|
116
|
-
});
|
|
117
|
-
test("dpkg -L vim lists installed files", async () => {
|
|
118
|
-
await client.exec("apt install vim"); // ensure installed
|
|
119
|
-
const r = await client.exec("dpkg -L vim");
|
|
120
|
-
expect(r.exitCode).toBe(0);
|
|
121
|
-
expect(r.stdout).toContain("/usr/bin/vim");
|
|
122
|
-
});
|
|
123
|
-
test("apt install resolves dependencies", async () => {
|
|
124
|
-
// npm depends on nodejs
|
|
125
|
-
const r = await client.exec("apt install npm");
|
|
126
|
-
expect(r.exitCode).toBe(0);
|
|
127
|
-
// nodejs should be auto-installed
|
|
128
|
-
expect(shell.vfs.exists("/usr/bin/node")).toBe(true);
|
|
129
|
-
expect(shell.vfs.exists("/usr/bin/npm")).toBe(true);
|
|
130
|
-
});
|
|
131
|
-
test("apt install non-existent package fails", async () => {
|
|
132
|
-
const r = await client.exec("apt install fakepackage999");
|
|
133
|
-
expect(r.exitCode).not.toBe(0);
|
|
134
|
-
expect(r.stdout).toContain("Unable to locate package");
|
|
135
|
-
});
|
|
136
|
-
test("apt remove vim removes package", async () => {
|
|
137
|
-
await client.exec("apt install vim");
|
|
138
|
-
const r = await client.exec("apt remove vim");
|
|
139
|
-
expect(r.exitCode).toBe(0);
|
|
140
|
-
expect(r.stdout).toContain("Removing vim");
|
|
141
|
-
});
|
|
142
|
-
test("apt search finds packages by term", async () => {
|
|
143
|
-
const r = await client.exec("apt search editor");
|
|
144
|
-
expect(r.exitCode).toBe(0);
|
|
145
|
-
expect(r.stdout).toContain("vim");
|
|
146
|
-
});
|
|
147
|
-
test("apt show displays package metadata", async () => {
|
|
148
|
-
const r = await client.exec("apt show git");
|
|
149
|
-
expect(r.exitCode).toBe(0);
|
|
150
|
-
expect(r.stdout).toContain("Package: git");
|
|
151
|
-
expect(r.stdout).toContain("Version:");
|
|
152
|
-
});
|
|
153
|
-
test("apt-cache search works", async () => {
|
|
154
|
-
const r = await client.exec("apt-cache search python");
|
|
155
|
-
expect(r.exitCode).toBe(0);
|
|
156
|
-
expect(r.stdout).toContain("python3");
|
|
157
|
-
});
|
|
158
|
-
test("apt-cache show works", async () => {
|
|
159
|
-
const r = await client.exec("apt-cache show curl");
|
|
160
|
-
expect(r.exitCode).toBe(0);
|
|
161
|
-
expect(r.stdout).toContain("Package: curl");
|
|
162
|
-
});
|
|
163
|
-
test("apt-cache policy works", async () => {
|
|
164
|
-
const r = await client.exec("apt-cache policy nodejs");
|
|
165
|
-
expect(r.exitCode).toBe(0);
|
|
166
|
-
expect(r.stdout).toContain("Candidate:");
|
|
167
|
-
});
|
|
168
|
-
test("dpkg-query -W lists packages", async () => {
|
|
169
|
-
await client.exec("apt install git"); // ensure git installed
|
|
170
|
-
// dpkg-query -W shows tab-separated name\tversion for all installed
|
|
171
|
-
const r = await client.exec("dpkg-query -W git");
|
|
172
|
-
expect(r.exitCode).toBe(0);
|
|
173
|
-
expect(r.stdout).toContain("git");
|
|
174
|
-
});
|
|
175
|
-
test("apt update simulates package index refresh", async () => {
|
|
176
|
-
const r = await client.exec("apt update");
|
|
177
|
-
expect(r.exitCode).toBe(0);
|
|
178
|
-
expect(r.stdout).toContain("Reading package lists");
|
|
179
|
-
});
|
|
180
|
-
test("non-root apt install is blocked", async () => {
|
|
181
|
-
// adduser alice
|
|
182
|
-
await shell.users.addUser("alice", "pass");
|
|
183
|
-
const aliceClient = new SshClient(shell, "alice");
|
|
184
|
-
const r = await aliceClient.exec("apt install vim");
|
|
185
|
-
expect(r.exitCode).not.toBe(0);
|
|
186
|
-
expect(r.stderr).toContain("Permission denied");
|
|
187
|
-
});
|
|
188
|
-
test("neofetch shows package count after installs", async () => {
|
|
189
|
-
await client.exec("apt install curl wget htop neofetch");
|
|
190
|
-
const r = await client.exec("neofetch");
|
|
191
|
-
expect(r.exitCode).toBe(0);
|
|
192
|
-
expect(r.stdout).toContain("(dpkg)");
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
// ─── Phase 3: pure fetch curl/wget ───────────────────────────────────────────
|
|
196
|
-
describe("curl / wget (pure fetch)", () => {
|
|
197
|
-
test("curl --help works without host binary", async () => {
|
|
198
|
-
const r = await client.exec("curl --help");
|
|
199
|
-
expect(r.exitCode).toBe(0);
|
|
200
|
-
expect(r.stdout).toContain("Usage: curl");
|
|
201
|
-
});
|
|
202
|
-
test("wget --help works without host binary", async () => {
|
|
203
|
-
const r = await client.exec("wget --help");
|
|
204
|
-
expect(r.exitCode).toBe(0);
|
|
205
|
-
expect(r.stdout).toContain("Usage: wget");
|
|
206
|
-
});
|
|
207
|
-
test("wget --version works", async () => {
|
|
208
|
-
const r = await client.exec("wget --version");
|
|
209
|
-
expect(r.exitCode).toBe(0);
|
|
210
|
-
expect(r.stdout).toContain("GNU Wget");
|
|
211
|
-
});
|
|
212
|
-
test("curl fetches real URL and returns body", async () => {
|
|
213
|
-
const r = await client.exec("curl https://httpbin.org/get");
|
|
214
|
-
// In sandboxed env network may be blocked — accept 0 (ok), 6 (dns), 22 (http err), or 1 (fetch error)
|
|
215
|
-
expect([0, 1, 6, 22]).toContain(r.exitCode ?? -1);
|
|
216
|
-
});
|
|
217
|
-
test("curl -o saves to VFS", async () => {
|
|
218
|
-
try {
|
|
219
|
-
await client.exec("curl -o /tmp/test-curl.txt https://httpbin.org/get");
|
|
220
|
-
}
|
|
221
|
-
catch { }
|
|
222
|
-
// Just check no ENOENT crash; file may or may not exist depending on network
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
// ─── Phase 4: /proc VFS ───────────────────────────────────────────────────────
|
|
226
|
-
describe("/proc filesystem", () => {
|
|
227
|
-
test("cat /proc/uptime returns numeric uptime", async () => {
|
|
228
|
-
const r = await client.cat("/proc/uptime");
|
|
229
|
-
expect(r.exitCode).toBe(0);
|
|
230
|
-
const parts = r.stdout?.trim().split(" ");
|
|
231
|
-
expect(parts?.length).toBeGreaterThanOrEqual(1);
|
|
232
|
-
expect(Number(parts?.[0])).toBeGreaterThanOrEqual(0);
|
|
233
|
-
});
|
|
234
|
-
test("cat /proc/loadavg returns values", async () => {
|
|
235
|
-
const r = await client.cat("/proc/loadavg");
|
|
236
|
-
expect(r.exitCode).toBe(0);
|
|
237
|
-
expect(r.stdout).toMatch(/\d+\.\d+/);
|
|
238
|
-
});
|
|
239
|
-
test("cat /proc/net/dev has eth0", async () => {
|
|
240
|
-
const r = await client.cat("/proc/net/dev");
|
|
241
|
-
expect(r.exitCode).toBe(0);
|
|
242
|
-
expect(r.stdout).toContain("eth0");
|
|
243
|
-
});
|
|
244
|
-
test("refreshProcFs updates /proc/uptime", async () => {
|
|
245
|
-
// const before = shell.vfs.readFile("/proc/uptime");
|
|
246
|
-
await new Promise((r) => setTimeout(r, 50));
|
|
247
|
-
shell.refreshProcFs();
|
|
248
|
-
const after = shell.vfs.readFile("/proc/uptime");
|
|
249
|
-
// Uptime value is based on Date.now(), content is same format
|
|
250
|
-
expect(after).toContain(".00");
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
// ─── Extras: which, type, man, uptime, free, alias, $() ──────────────────────
|
|
254
|
-
describe("Extra commands", () => {
|
|
255
|
-
test("which ls finds /usr/bin/ls", async () => {
|
|
256
|
-
const r = await client.exec("which ls");
|
|
257
|
-
expect(r.exitCode).toBe(0);
|
|
258
|
-
expect(r.stdout?.trim()).toBe("/usr/bin/ls");
|
|
259
|
-
});
|
|
260
|
-
test("which nonexistent returns exit 1", async () => {
|
|
261
|
-
const r = await client.exec("which thisdoesnotexist");
|
|
262
|
-
expect(r.exitCode).toBe(1);
|
|
263
|
-
});
|
|
264
|
-
test("type ls reports builtin", async () => {
|
|
265
|
-
const r = await client.exec("type ls");
|
|
266
|
-
expect(r.exitCode).toBe(0);
|
|
267
|
-
expect(r.stdout).toContain("ls");
|
|
268
|
-
});
|
|
269
|
-
test("man ls shows manual page", async () => {
|
|
270
|
-
const r = await client.exec("man ls");
|
|
271
|
-
expect(r.exitCode).toBe(0);
|
|
272
|
-
expect(r.stdout).toContain("NAME");
|
|
273
|
-
expect(r.stdout).toContain("list directory");
|
|
274
|
-
});
|
|
275
|
-
test("man nonexistent returns error", async () => {
|
|
276
|
-
const r = await client.exec("man fakecmd999");
|
|
277
|
-
expect(r.exitCode).not.toBe(0);
|
|
278
|
-
expect(r.stderr).toContain("No manual entry");
|
|
279
|
-
});
|
|
280
|
-
test("uptime returns formatted string", async () => {
|
|
281
|
-
const r = await client.exec("uptime");
|
|
282
|
-
expect(r.exitCode).toBe(0);
|
|
283
|
-
expect(r.stdout).toMatch(/up/);
|
|
284
|
-
});
|
|
285
|
-
test("uptime -p returns pretty format", async () => {
|
|
286
|
-
const r = await client.exec("uptime -p");
|
|
287
|
-
expect(r.exitCode).toBe(0);
|
|
288
|
-
expect(r.stdout).toContain("up");
|
|
289
|
-
expect(r.stdout).toMatch(/minute|hour|day/);
|
|
290
|
-
});
|
|
291
|
-
test("free shows memory table", async () => {
|
|
292
|
-
const r = await client.exec("free");
|
|
293
|
-
expect(r.exitCode).toBe(0);
|
|
294
|
-
expect(r.stdout).toContain("Mem:");
|
|
295
|
-
expect(r.stdout).toContain("Swap:");
|
|
296
|
-
});
|
|
297
|
-
test("free -h shows human readable", async () => {
|
|
298
|
-
const r = await client.exec("free -h");
|
|
299
|
-
expect(r.exitCode).toBe(0);
|
|
300
|
-
expect(r.stdout).toMatch(/[0-9.]+[GMK]/);
|
|
301
|
-
});
|
|
302
|
-
test("alias sets and retrieves alias", async () => {
|
|
303
|
-
// alias env is per-session; use sh -c to test in one exec
|
|
304
|
-
const r = await client.exec("alias ll='ls -la'; alias ll");
|
|
305
|
-
expect(r.exitCode).toBe(0);
|
|
306
|
-
// alias output may be in stdout
|
|
307
|
-
const out = (r.stdout ?? "") + (r.stderr ?? "");
|
|
308
|
-
expect(out).toContain("ll");
|
|
309
|
-
});
|
|
310
|
-
test("alias -a lists all aliases", async () => {
|
|
311
|
-
await client.exec("alias hello='echo hello'");
|
|
312
|
-
const r = await client.exec("alias");
|
|
313
|
-
expect(r.exitCode).toBe(0);
|
|
314
|
-
});
|
|
315
|
-
test("unalias removes an alias", async () => {
|
|
316
|
-
await client.exec("alias myfoo='echo foo'");
|
|
317
|
-
const r = await client.exec("unalias myfoo");
|
|
318
|
-
expect(r.exitCode).toBe(0);
|
|
319
|
-
});
|
|
320
|
-
test("lsb_release -a returns distro info", async () => {
|
|
321
|
-
const r = await client.exec("lsb_release -a");
|
|
322
|
-
expect(r.stdout).toContain("Fortune");
|
|
323
|
-
expect(r.stdout).toContain("aurora");
|
|
324
|
-
});
|
|
325
|
-
test("lsb_release -d returns description", async () => {
|
|
326
|
-
const r = await client.exec("lsb_release -d");
|
|
327
|
-
expect(r.stdout).toContain("Description:");
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
// ─── $(cmd) substitution ──────────────────────────────────────────────────────
|
|
331
|
-
describe("Command substitution $(cmd)", () => {
|
|
332
|
-
test("echo $(echo hello) works", async () => {
|
|
333
|
-
const r = await client.exec("echo $(echo hello)");
|
|
334
|
-
expect(r.exitCode).toBe(0);
|
|
335
|
-
expect(r.stdout?.trim()).toBe("hello");
|
|
336
|
-
});
|
|
337
|
-
test("echo $(hostname) returns hostname", async () => {
|
|
338
|
-
const r = await client.exec("echo $(hostname)");
|
|
339
|
-
expect(r.exitCode).toBe(0);
|
|
340
|
-
expect(r.stdout?.trim()).toBe("test-vm");
|
|
341
|
-
});
|
|
342
|
-
test("echo $(whoami) returns user", async () => {
|
|
343
|
-
const r = await client.exec("echo $(whoami)");
|
|
344
|
-
expect(r.exitCode).toBe(0);
|
|
345
|
-
expect(r.stdout?.trim()).toBe("root");
|
|
346
|
-
});
|
|
347
|
-
test("nested substitution in variable context", async () => {
|
|
348
|
-
const r = await client.exec("echo user=$(whoami)");
|
|
349
|
-
expect(r.stdout?.trim()).toBe("user=root");
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
// ─── syncPasswd ───────────────────────────────────────────────────────────────
|
|
353
|
-
describe("syncPasswd", () => {
|
|
354
|
-
test("syncPasswd after addUser updates /etc/passwd", async () => {
|
|
355
|
-
await shell.users.addUser("bob", "pass123");
|
|
356
|
-
shell.syncPasswd();
|
|
357
|
-
const r = await client.cat("/etc/passwd");
|
|
358
|
-
expect(r.stdout).toContain("bob");
|
|
359
|
-
});
|
|
360
|
-
test("/etc/group has sudo group with sudoers", async () => {
|
|
361
|
-
const r = await client.cat("/etc/group");
|
|
362
|
-
expect(r.stdout).toContain("sudo:");
|
|
363
|
-
expect(r.stdout).toContain("root");
|
|
364
|
-
});
|
|
365
|
-
test("/etc/shadow exists with restricted permissions", () => {
|
|
366
|
-
expect(shell.vfs.exists("/etc/shadow")).toBe(true);
|
|
367
|
-
const stat = shell.vfs.stat("/etc/shadow");
|
|
368
|
-
expect(stat.type).toBe("file");
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
// ─── Bug fixes ────────────────────────────────────────────────────────────────
|
|
372
|
-
describe("Bug fixes", () => {
|
|
373
|
-
let shell2;
|
|
374
|
-
let c;
|
|
375
|
-
beforeAll(async () => {
|
|
376
|
-
shell2 = new VirtualShell("fix-vm");
|
|
377
|
-
await shell2.ensureInitialized();
|
|
378
|
-
c = new SshClient(shell2, "root");
|
|
379
|
-
});
|
|
380
|
-
// echo
|
|
381
|
-
test("echo adds newline — >> append works", async () => {
|
|
382
|
-
await c.exec("echo line1 > /tmp/append.txt");
|
|
383
|
-
await c.exec("echo line2 >> /tmp/append.txt");
|
|
384
|
-
const content = shell2.vfs.readFile("/tmp/append.txt");
|
|
385
|
-
expect(content).toBe("line1\nline2\n");
|
|
386
|
-
});
|
|
387
|
-
test("echo -e interprets escape sequences", async () => {
|
|
388
|
-
const r = await c.exec("echo -e 'a\\tb'");
|
|
389
|
-
expect(r.stdout?.trim()).toBe("a\tb");
|
|
390
|
-
});
|
|
391
|
-
test("echo -n suppresses trailing newline", async () => {
|
|
392
|
-
const r = await c.exec("echo -n hello");
|
|
393
|
-
expect(r.stdout).toBe("hello");
|
|
394
|
-
});
|
|
395
|
-
test("echo uses session env.vars for $VAR", async () => {
|
|
396
|
-
const r = await c.exec("export MYVAR=world && echo $MYVAR");
|
|
397
|
-
expect(r.stdout?.trim()).toBe("world");
|
|
398
|
-
});
|
|
399
|
-
// ls -a
|
|
400
|
-
test("ls -a shows dotfiles", async () => {
|
|
401
|
-
await c.exec("touch /tmp/.hidden && touch /tmp/visible");
|
|
402
|
-
const normal = await c.exec("ls /tmp");
|
|
403
|
-
const all = await c.exec("ls -a /tmp");
|
|
404
|
-
expect(normal.stdout).not.toContain(".hidden");
|
|
405
|
-
expect(all.stdout).toContain(".hidden");
|
|
406
|
-
expect(all.stdout).toContain("visible");
|
|
407
|
-
});
|
|
408
|
-
// chmod symbolic
|
|
409
|
-
test("chmod +x adds execute bit", async () => {
|
|
410
|
-
await c.exec("touch /tmp/script.sh");
|
|
411
|
-
const before = shell2.vfs.stat("/tmp/script.sh").mode;
|
|
412
|
-
await c.exec("chmod +x /tmp/script.sh");
|
|
413
|
-
const after = shell2.vfs.stat("/tmp/script.sh").mode;
|
|
414
|
-
expect(after & 0o111).toBeGreaterThan(0);
|
|
415
|
-
expect(before & 0o111).toBe(0);
|
|
416
|
-
});
|
|
417
|
-
test("chmod u+x adds only user execute bit", async () => {
|
|
418
|
-
await c.exec("touch /tmp/u.sh && chmod 644 /tmp/u.sh");
|
|
419
|
-
await c.exec("chmod u+x /tmp/u.sh");
|
|
420
|
-
const mode = shell2.vfs.stat("/tmp/u.sh").mode;
|
|
421
|
-
expect(mode & 0o100).toBe(0o100); // user x set
|
|
422
|
-
expect(mode & 0o010).toBe(0); // group x not set
|
|
423
|
-
});
|
|
424
|
-
test("chmod go-r removes group+other read", async () => {
|
|
425
|
-
await c.exec("touch /tmp/priv.sh && chmod 755 /tmp/priv.sh");
|
|
426
|
-
await c.exec("chmod go-r /tmp/priv.sh");
|
|
427
|
-
const mode = shell2.vfs.stat("/tmp/priv.sh").mode;
|
|
428
|
-
expect(mode & 0o044).toBe(0);
|
|
429
|
-
});
|
|
430
|
-
// cat -n
|
|
431
|
-
test("cat -n numbers lines", async () => {
|
|
432
|
-
await c.exec("echo -e 'foo\\nbar' > /tmp/cattest.txt");
|
|
433
|
-
const r = await c.exec("cat -n /tmp/cattest.txt");
|
|
434
|
-
expect(r.stdout).toContain("1\t");
|
|
435
|
-
expect(r.stdout).toContain("2\t");
|
|
436
|
-
});
|
|
437
|
-
// ping -c
|
|
438
|
-
test("ping -c 2 sends exactly 2 packets", async () => {
|
|
439
|
-
const r = await c.exec("ping -c 2 localhost");
|
|
440
|
-
const dataLines = r.stdout
|
|
441
|
-
?.split("\n")
|
|
442
|
-
.filter((l) => l.includes("icmp_seq="));
|
|
443
|
-
expect(dataLines?.length).toBe(2);
|
|
444
|
-
});
|
|
445
|
-
// test / [ command
|
|
446
|
-
test("[ -f path ] returns 0 for existing file", async () => {
|
|
447
|
-
await c.exec("touch /tmp/testfile");
|
|
448
|
-
const r = await c.exec("[ -f /tmp/testfile ] && echo yes || echo no");
|
|
449
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
450
|
-
});
|
|
451
|
-
test("[ -d path ] returns 0 for existing directory", async () => {
|
|
452
|
-
const r = await c.exec("[ -d /etc ] && echo yes || echo no");
|
|
453
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
454
|
-
});
|
|
455
|
-
test("[ -f path ] returns 1 for non-existent file", async () => {
|
|
456
|
-
const r = await c.exec("[ -f /tmp/doesnotexist999 ] && echo yes || echo no");
|
|
457
|
-
expect(r.stdout?.trim()).toBe("no");
|
|
458
|
-
});
|
|
459
|
-
test("[ -e path ] returns 0 for existing path", async () => {
|
|
460
|
-
const r = await c.exec("[ -e /etc/hostname ] && echo yes || echo no");
|
|
461
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
462
|
-
});
|
|
463
|
-
test("test string comparison = works", async () => {
|
|
464
|
-
const r = await c.exec("[ hello = hello ] && echo yes || echo no");
|
|
465
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
466
|
-
});
|
|
467
|
-
test("test numeric -eq works", async () => {
|
|
468
|
-
const r = await c.exec("[ 5 -eq 5 ] && echo yes || echo no");
|
|
469
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
470
|
-
});
|
|
471
|
-
test("test numeric -lt works", async () => {
|
|
472
|
-
const r = await c.exec("[ 3 -lt 5 ] && echo yes || echo no");
|
|
473
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
474
|
-
});
|
|
475
|
-
test("test -z empty string", async () => {
|
|
476
|
-
const r = await c.exec("[ -z '' ] && echo yes || echo no");
|
|
477
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
478
|
-
});
|
|
479
|
-
test("test -n non-empty string", async () => {
|
|
480
|
-
const r = await c.exec("[ -n hello ] && echo yes || echo no");
|
|
481
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
482
|
-
});
|
|
483
|
-
// source / .
|
|
484
|
-
test("source executes file in current env", async () => {
|
|
485
|
-
shell2.vfs.writeFile("/tmp/setup.sh", "export SOURCED=yes\n");
|
|
486
|
-
const r = await c.exec("source /tmp/setup.sh && echo $SOURCED");
|
|
487
|
-
expect(r.stdout?.trim()).toBe("yes");
|
|
488
|
-
});
|
|
489
|
-
test(". (dot) is alias for source", async () => {
|
|
490
|
-
shell2.vfs.writeFile("/tmp/dot.sh", "export DOTTED=ok\n");
|
|
491
|
-
const r = await c.exec(". /tmp/dot.sh && echo $DOTTED");
|
|
492
|
-
expect(r.stdout?.trim()).toBe("ok");
|
|
493
|
-
});
|
|
494
|
-
// sh -c with $(cmd)
|
|
495
|
-
test("sh -c handles $(cmd) substitution", async () => {
|
|
496
|
-
const r = await c.exec("sh -c 'echo user=$(whoami)'");
|
|
497
|
-
expect(r.stdout?.trim()).toBe("user=root");
|
|
498
|
-
});
|
|
499
|
-
test("sh -c for loop with $(cmd)", async () => {
|
|
500
|
-
const r = await c.exec("sh -c 'for x in a b; do echo $(echo $x); done'");
|
|
501
|
-
expect(r.stdout?.trim()).toBe("a\nb");
|
|
502
|
-
});
|
|
503
|
-
// history
|
|
504
|
-
test("history command returns command list", async () => {
|
|
505
|
-
// history reads from VFS .bash_history (written by interactive shell)
|
|
506
|
-
// in non-interactive context it may be empty — just check it doesn't crash
|
|
507
|
-
const r = await c.exec("history");
|
|
508
|
-
expect(r.exitCode).toBe(0);
|
|
509
|
-
});
|
|
510
|
-
// ps -u
|
|
511
|
-
test("ps -u shows USER column", async () => {
|
|
512
|
-
const r = await c.exec("ps -u");
|
|
513
|
-
expect(r.stdout).toContain("USER");
|
|
514
|
-
expect(r.stdout).toContain("PID");
|
|
515
|
-
expect(r.stdout).toContain("%CPU");
|
|
516
|
-
});
|
|
517
|
-
test("ps aux shows extended format", async () => {
|
|
518
|
-
const r = await c.exec("ps aux");
|
|
519
|
-
expect(r.stdout).toContain("USER");
|
|
520
|
-
expect(r.exitCode).toBe(0);
|
|
521
|
-
});
|
|
522
|
-
// wc -l with pipe (after echo -e fix)
|
|
523
|
-
test("wc -l counts newlines correctly via pipe", async () => {
|
|
524
|
-
const r = await c.exec("echo -e 'a\\nb\\nc' | wc -l");
|
|
525
|
-
expect(r.stdout?.trim()).toBe("3");
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
// ─── Roadmap features ────────────────────────────────────────────────────────
|
|
529
|
-
describe("/proc/self and /proc/<pid>", () => {
|
|
530
|
-
let shell4;
|
|
531
|
-
let c4;
|
|
532
|
-
beforeAll(async () => {
|
|
533
|
-
shell4 = new VirtualShell("proc-vm");
|
|
534
|
-
await shell4.ensureInitialized();
|
|
535
|
-
c4 = new SshClient(shell4, "root");
|
|
536
|
-
});
|
|
537
|
-
test("/proc/self exists and has comm file", async () => {
|
|
538
|
-
expect(shell4.vfs.exists("/proc/self")).toBe(true);
|
|
539
|
-
expect(shell4.vfs.exists("/proc/self/comm")).toBe(true);
|
|
540
|
-
});
|
|
541
|
-
test("/proc/self/status has Name field", async () => {
|
|
542
|
-
const r = await c4.exec("cat /proc/self/status");
|
|
543
|
-
expect(r.exitCode).toBe(0);
|
|
544
|
-
expect(r.stdout).toContain("Name:");
|
|
545
|
-
});
|
|
546
|
-
test("/proc/self/cmdline is readable", async () => {
|
|
547
|
-
const r = await c4.exec("cat /proc/self/cmdline");
|
|
548
|
-
expect(r.exitCode).toBe(0);
|
|
549
|
-
});
|
|
550
|
-
test("/proc/1 (init) exists", async () => {
|
|
551
|
-
expect(shell4.vfs.exists("/proc/1")).toBe(true);
|
|
552
|
-
expect(shell4.vfs.exists("/proc/1/status")).toBe(true);
|
|
553
|
-
});
|
|
554
|
-
test("/proc/1/status has correct pid", async () => {
|
|
555
|
-
const r = await c4.exec("cat /proc/1/status");
|
|
556
|
-
expect(r.stdout).toContain("Pid:");
|
|
557
|
-
expect(r.stdout).toContain("1");
|
|
558
|
-
});
|
|
559
|
-
test("refreshProcFs updates /proc contents", () => {
|
|
560
|
-
shell4.refreshProcFs();
|
|
561
|
-
expect(shell4.vfs.exists("/proc/uptime")).toBe(true);
|
|
562
|
-
expect(shell4.vfs.exists("/proc/self")).toBe(true);
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
import { assertDiff, diffSnapshots, formatDiff } from "../src";
|
|
566
|
-
describe("VFS snapshot diff tooling", () => {
|
|
567
|
-
let shell5;
|
|
568
|
-
let c5;
|
|
569
|
-
beforeAll(async () => {
|
|
570
|
-
shell5 = new VirtualShell("diff-vm");
|
|
571
|
-
await shell5.ensureInitialized();
|
|
572
|
-
c5 = new SshClient(shell5, "root");
|
|
573
|
-
});
|
|
574
|
-
test("diffSnapshots returns clean diff for identical snapshots", () => {
|
|
575
|
-
const snap = shell5.vfs.toSnapshot();
|
|
576
|
-
const diff = diffSnapshots(snap, snap);
|
|
577
|
-
expect(diff.clean).toBe(true);
|
|
578
|
-
expect(diff.added).toHaveLength(0);
|
|
579
|
-
expect(diff.removed).toHaveLength(0);
|
|
580
|
-
expect(diff.modified).toHaveLength(0);
|
|
581
|
-
});
|
|
582
|
-
test("diffSnapshots detects added file", async () => {
|
|
583
|
-
const before = shell5.vfs.toSnapshot();
|
|
584
|
-
await c5.exec("echo test > /tmp/diff-test.txt");
|
|
585
|
-
const after = shell5.vfs.toSnapshot();
|
|
586
|
-
const diff = diffSnapshots(before, after, { ignore: ["/proc"] });
|
|
587
|
-
const paths = diff.added.map((e) => e.path);
|
|
588
|
-
expect(paths).toContain("/tmp/diff-test.txt");
|
|
589
|
-
expect(diff.clean).toBe(false);
|
|
590
|
-
});
|
|
591
|
-
test("diffSnapshots detects added directory", async () => {
|
|
592
|
-
const before = shell5.vfs.toSnapshot();
|
|
593
|
-
shell5.vfs.mkdir("/tmp/diff-newdir", 0o755);
|
|
594
|
-
const after = shell5.vfs.toSnapshot();
|
|
595
|
-
const diff = diffSnapshots(before, after, { ignore: ["/proc"] });
|
|
596
|
-
const paths = diff.added.map((e) => e.path);
|
|
597
|
-
expect(paths).toContain("/tmp/diff-newdir");
|
|
598
|
-
});
|
|
599
|
-
test("diffSnapshots detects modified file", async () => {
|
|
600
|
-
shell5.vfs.writeFile("/tmp/modtest.txt", "before");
|
|
601
|
-
const before = shell5.vfs.toSnapshot();
|
|
602
|
-
shell5.vfs.writeFile("/tmp/modtest.txt", "after");
|
|
603
|
-
const after = shell5.vfs.toSnapshot();
|
|
604
|
-
const diff = diffSnapshots(before, after, { ignore: ["/proc"] });
|
|
605
|
-
const mod = diff.modified.find((e) => e.path === "/tmp/modtest.txt");
|
|
606
|
-
expect(mod).toBeDefined();
|
|
607
|
-
expect(mod?.before).toBe("before");
|
|
608
|
-
expect(mod?.after).toBe("after");
|
|
609
|
-
});
|
|
610
|
-
test("diffSnapshots detects removed file", async () => {
|
|
611
|
-
shell5.vfs.writeFile("/tmp/toremove.txt", "bye");
|
|
612
|
-
const before = shell5.vfs.toSnapshot();
|
|
613
|
-
shell5.vfs.remove("/tmp/toremove.txt");
|
|
614
|
-
const after = shell5.vfs.toSnapshot();
|
|
615
|
-
const diff = diffSnapshots(before, after, { ignore: ["/proc"] });
|
|
616
|
-
const paths = diff.removed.map((e) => e.path);
|
|
617
|
-
expect(paths).toContain("/tmp/toremove.txt");
|
|
618
|
-
});
|
|
619
|
-
test("diffSnapshots ignores specified prefixes", async () => {
|
|
620
|
-
shell5.vfs.writeFile("/proc/uptime", "999.00 888.00\n");
|
|
621
|
-
const before = shell5.vfs.toSnapshot();
|
|
622
|
-
shell5.vfs.writeFile("/proc/uptime", "1000.00 900.00\n");
|
|
623
|
-
const after = shell5.vfs.toSnapshot();
|
|
624
|
-
const diff = diffSnapshots(before, after, { ignore: ["/proc"] });
|
|
625
|
-
expect(diff.modified.map((e) => e.path)).not.toContain("/proc/uptime");
|
|
626
|
-
});
|
|
627
|
-
test("formatDiff returns (no changes) for clean diff", () => {
|
|
628
|
-
const snap = shell5.vfs.toSnapshot();
|
|
629
|
-
const diff = diffSnapshots(snap, snap);
|
|
630
|
-
expect(formatDiff(diff)).toBe("(no changes)");
|
|
631
|
-
});
|
|
632
|
-
test("formatDiff includes change summary", async () => {
|
|
633
|
-
const before = shell5.vfs.toSnapshot();
|
|
634
|
-
shell5.vfs.writeFile("/tmp/format-test.txt", "x");
|
|
635
|
-
const after = shell5.vfs.toSnapshot();
|
|
636
|
-
const diff = diffSnapshots(before, after, { ignore: ["/proc"] });
|
|
637
|
-
const formatted = formatDiff(diff);
|
|
638
|
-
expect(formatted).toContain("added");
|
|
639
|
-
});
|
|
640
|
-
test("assertDiff passes when paths match", async () => {
|
|
641
|
-
shell5.vfs.writeFile("/tmp/assert-test.txt", "hello");
|
|
642
|
-
const before = shell5.vfs.toSnapshot();
|
|
643
|
-
shell5.vfs.writeFile("/tmp/assert-new.txt", "new");
|
|
644
|
-
shell5.vfs.remove("/tmp/assert-test.txt");
|
|
645
|
-
const after = shell5.vfs.toSnapshot();
|
|
646
|
-
const diff = diffSnapshots(before, after, { ignore: ["/proc"] });
|
|
647
|
-
expect(() => assertDiff(diff, {
|
|
648
|
-
added: ["/tmp/assert-new.txt"],
|
|
649
|
-
removed: ["/tmp/assert-test.txt"],
|
|
650
|
-
})).not.toThrow();
|
|
651
|
-
});
|
|
652
|
-
test("assertDiff throws when expected path is missing", () => {
|
|
653
|
-
const snap = shell5.vfs.toSnapshot();
|
|
654
|
-
const diff = diffSnapshots(snap, snap);
|
|
655
|
-
expect(() => assertDiff(diff, { added: ["/nonexistent"] })).toThrow();
|
|
656
|
-
});
|
|
657
|
-
});
|
|
658
|
-
describe("node and python3 REPL stubs", () => {
|
|
659
|
-
let shell6;
|
|
660
|
-
let c6;
|
|
661
|
-
beforeAll(async () => {
|
|
662
|
-
shell6 = new VirtualShell("repl-vm");
|
|
663
|
-
await shell6.ensureInitialized();
|
|
664
|
-
c6 = new SshClient(shell6, "root");
|
|
665
|
-
await c6.exec("apt install nodejs python3");
|
|
666
|
-
});
|
|
667
|
-
test("node --version returns v18", async () => {
|
|
668
|
-
const r = await c6.exec("node --version");
|
|
669
|
-
expect(r.exitCode).toBe(0);
|
|
670
|
-
expect(r.stdout?.trim()).toBe("v18.19.0");
|
|
671
|
-
});
|
|
672
|
-
test("node -e evaluates arithmetic", async () => {
|
|
673
|
-
const r = await c6.exec("node -e '2 + 3'");
|
|
674
|
-
expect(r.exitCode).toBe(0);
|
|
675
|
-
expect(r.stdout?.trim()).toBe("5");
|
|
676
|
-
});
|
|
677
|
-
test("node -e console.log works", async () => {
|
|
678
|
-
const r = await c6.exec("node -e 'console.log(42)'");
|
|
679
|
-
expect(r.stdout?.trim()).toBe("42");
|
|
680
|
-
});
|
|
681
|
-
test("node executes VFS file", async () => {
|
|
682
|
-
shell6.vfs.writeFile("/tmp/test.js", "console.log(10 + 5);\n");
|
|
683
|
-
const r = await c6.exec("node /tmp/test.js");
|
|
684
|
-
expect(r.stdout?.trim()).toBe("15");
|
|
685
|
-
});
|
|
686
|
-
test("node missing file returns exit 1", async () => {
|
|
687
|
-
const r = await c6.exec("node /tmp/nonexistent.js");
|
|
688
|
-
expect(r.exitCode).toBe(1);
|
|
689
|
-
expect(r.stderr).toContain("No such file or directory");
|
|
690
|
-
});
|
|
691
|
-
test("python3 --version returns Python 3.11", async () => {
|
|
692
|
-
const r = await c6.exec("python3 --version");
|
|
693
|
-
expect(r.exitCode).toBe(0);
|
|
694
|
-
expect(r.stdout?.trim()).toContain("Python 3.11");
|
|
695
|
-
});
|
|
696
|
-
test("python3 -c print arithmetic", async () => {
|
|
697
|
-
const r = await c6.exec("python3 -c 'print(2 + 3)'");
|
|
698
|
-
expect(r.stdout?.trim()).toBe("5");
|
|
699
|
-
});
|
|
700
|
-
test("python3 -c f-string", async () => {
|
|
701
|
-
const r = await c6.exec("python3 -c 'print(f\"result: {1+1}\")'");
|
|
702
|
-
expect(r.stdout?.trim()).toBe("result: 2");
|
|
703
|
-
});
|
|
704
|
-
test("python3 executes VFS script", async () => {
|
|
705
|
-
shell6.vfs.writeFile("/tmp/test.py", "print(10 + 5)\n");
|
|
706
|
-
const r = await c6.exec("python3 /tmp/test.py");
|
|
707
|
-
expect(r.stdout?.trim()).toBe("15");
|
|
708
|
-
});
|
|
709
|
-
test("python alias works", async () => {
|
|
710
|
-
const r = await c6.exec("python --version");
|
|
711
|
-
expect(r.exitCode).toBe(0);
|
|
712
|
-
expect(r.stdout?.trim()).toContain("Python");
|
|
713
|
-
});
|
|
714
|
-
test("python3 missing file returns exit 2", async () => {
|
|
715
|
-
const r = await c6.exec("python3 /tmp/nonexistent.py");
|
|
716
|
-
expect(r.exitCode).toBe(2);
|
|
717
|
-
});
|
|
718
|
-
test("node is available as a shell command", async () => {
|
|
719
|
-
const r = await c6.exec("node --version");
|
|
720
|
-
expect(r.exitCode).toBe(0);
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
// ─── Enhanced REPL tests (post-rewrite) ──────────────────────────────────────
|
|
724
|
-
describe("node enhanced REPL", () => {
|
|
725
|
-
let shell7;
|
|
726
|
-
let c7;
|
|
727
|
-
beforeAll(async () => {
|
|
728
|
-
shell7 = new VirtualShell("node-vm");
|
|
729
|
-
await shell7.ensureInitialized();
|
|
730
|
-
c7 = new SshClient(shell7, "root");
|
|
731
|
-
await c7.exec("apt install nodejs");
|
|
732
|
-
});
|
|
733
|
-
test("node -e string methods", async () => {
|
|
734
|
-
shell7.vfs.writeFile("/tmp/str.js", "'hello'.toUpperCase()");
|
|
735
|
-
const r = await c7.exec("node /tmp/str.js");
|
|
736
|
-
expect(r.stdout?.trim()).toBe("HELLO");
|
|
737
|
-
});
|
|
738
|
-
test("node -e array methods", async () => {
|
|
739
|
-
shell7.vfs.writeFile("/tmp/arr.js", "[1,2,3].map(x => x*2).join(',')");
|
|
740
|
-
const r = await c7.exec("node /tmp/arr.js");
|
|
741
|
-
expect(r.stdout?.trim()).toBe("2,4,6");
|
|
742
|
-
});
|
|
743
|
-
test("node process.version is virtual", async () => {
|
|
744
|
-
const r = await c7.exec("node -e 'process.version'");
|
|
745
|
-
expect(r.stdout?.trim()).toBe("v18.19.0");
|
|
746
|
-
});
|
|
747
|
-
test("node require path works", async () => {
|
|
748
|
-
shell7.vfs.writeFile("/tmp/path.js", "const p = require('path'); console.log(p.join('a', 'b'))");
|
|
749
|
-
const r = await c7.exec("node /tmp/path.js");
|
|
750
|
-
expect(r.stdout?.trim()).toBe("a/b");
|
|
751
|
-
});
|
|
752
|
-
test("node require fs throws gracefully", async () => {
|
|
753
|
-
shell7.vfs.writeFile("/tmp/fs.js", "try { require('fs') } catch(e) { console.log('blocked') }");
|
|
754
|
-
const r = await c7.exec("node /tmp/fs.js");
|
|
755
|
-
expect(r.stdout?.trim()).toBe("blocked");
|
|
756
|
-
});
|
|
757
|
-
test("node console.log output", async () => {
|
|
758
|
-
shell7.vfs.writeFile("/tmp/log.js", "console.log('hello', 'world')");
|
|
759
|
-
const r = await c7.exec("node /tmp/log.js");
|
|
760
|
-
expect(r.stdout?.trim()).toBe("hello world");
|
|
761
|
-
});
|
|
762
|
-
test("node Math methods", async () => {
|
|
763
|
-
const r = await c7.exec("node -e 'Math.floor(3.9)'");
|
|
764
|
-
expect(r.stdout?.trim()).toBe("3");
|
|
765
|
-
});
|
|
766
|
-
test("node JSON.stringify", async () => {
|
|
767
|
-
const r = await c7.exec("node -e 'JSON.stringify({x:1})'");
|
|
768
|
-
expect(r.stdout?.trim()).toBe('{"x":1}');
|
|
769
|
-
});
|
|
770
|
-
});
|
|
771
|
-
describe("python3 enhanced interpreter", () => {
|
|
772
|
-
let shell8;
|
|
773
|
-
let c8;
|
|
774
|
-
beforeAll(async () => {
|
|
775
|
-
shell8 = new VirtualShell("python-vm");
|
|
776
|
-
await shell8.ensureInitialized();
|
|
777
|
-
c8 = new SshClient(shell8, "root");
|
|
778
|
-
await c8.exec("apt install python3");
|
|
779
|
-
});
|
|
780
|
-
const py = async (code) => {
|
|
781
|
-
shell8.vfs.writeFile("/tmp/t.py", code);
|
|
782
|
-
return c8.exec("python3 /tmp/t.py");
|
|
783
|
-
};
|
|
784
|
-
test("str.upper()", async () => {
|
|
785
|
-
const r = await py("print('hello'.upper())");
|
|
786
|
-
expect(r.stdout?.trim()).toBe("HELLO");
|
|
787
|
-
});
|
|
788
|
-
test("str.split()", async () => {
|
|
789
|
-
const r = await py("print('a,b,c'.split(','))");
|
|
790
|
-
expect(r.stdout?.trim()).toBe("['a', 'b', 'c']");
|
|
791
|
-
});
|
|
792
|
-
test("str.join()", async () => {
|
|
793
|
-
const r = await py("print(','.join(['a','b','c']))");
|
|
794
|
-
expect(r.stdout?.trim()).toBe("a,b,c");
|
|
795
|
-
});
|
|
796
|
-
test("list comprehension", async () => {
|
|
797
|
-
const r = await py("print([x**2 for x in range(5)])");
|
|
798
|
-
expect(r.stdout?.trim()).toBe("[0, 1, 4, 9, 16]");
|
|
799
|
-
});
|
|
800
|
-
test("list.sort() in-place", async () => {
|
|
801
|
-
const r = await py("nums=[3,1,4,1,5]\nnums.sort()\nprint(nums)");
|
|
802
|
-
expect(r.stdout?.trim()).toBe("[1, 1, 3, 4, 5]");
|
|
803
|
-
});
|
|
804
|
-
test("dict access and methods", async () => {
|
|
805
|
-
const r = await py("d={'x':1,'y':2}\nprint(d['x'])\nprint(list(d.keys()))");
|
|
806
|
-
expect(r.stdout).toContain("1");
|
|
807
|
-
expect(r.stdout).toContain("x");
|
|
808
|
-
});
|
|
809
|
-
test("class with __init__ and methods", async () => {
|
|
810
|
-
const r = await py("class Dog:\n def __init__(self, name):\n self.name = name\n def bark(self):\n return f'Woof! I am {self.name}'\nd = Dog('Rex')\nprint(d.bark())");
|
|
811
|
-
expect(r.stdout?.trim()).toBe("Woof! I am Rex");
|
|
812
|
-
});
|
|
813
|
-
test("import math and use functions", async () => {
|
|
814
|
-
const r = await py("import math\nprint(math.floor(3.9))\nprint(round(math.sqrt(16), 0))");
|
|
815
|
-
expect(r.stdout).toContain("3");
|
|
816
|
-
expect(r.stdout).toContain("4");
|
|
817
|
-
});
|
|
818
|
-
test("import os and getcwd", async () => {
|
|
819
|
-
const r = await py("import os\nprint(os.getcwd())");
|
|
820
|
-
expect(r.exitCode).toBe(0);
|
|
821
|
-
expect(r.stdout?.trim().length).toBeGreaterThan(0);
|
|
822
|
-
});
|
|
823
|
-
test("import sys and version", async () => {
|
|
824
|
-
const r = await py("import sys\nprint(sys.version[:5])");
|
|
825
|
-
expect(r.stdout?.trim()).toBe("3.11.");
|
|
826
|
-
});
|
|
827
|
-
test("import json dumps/loads", async () => {
|
|
828
|
-
const r = await py("import json\nd={'x':1}\nprint(json.dumps(d))\nprint(json.loads('{\"a\":2}')['a'])");
|
|
829
|
-
expect(r.stdout).toContain('"x"');
|
|
830
|
-
expect(r.stdout).toContain("2");
|
|
831
|
-
});
|
|
832
|
-
test("try/except handles errors", async () => {
|
|
833
|
-
const r = await py("try:\n x = 1/0\nexcept ZeroDivisionError:\n print('caught')");
|
|
834
|
-
expect(r.stdout?.trim()).toBe("caught");
|
|
835
|
-
});
|
|
836
|
-
test("f-string interpolation", async () => {
|
|
837
|
-
const r = await py("name='world'\nprint(f'hello {name}')");
|
|
838
|
-
expect(r.stdout?.trim()).toBe("hello world");
|
|
839
|
-
});
|
|
840
|
-
test("sorted() and reversed()", async () => {
|
|
841
|
-
const r = await py("print(sorted([3,1,2]))\nprint(list(reversed([1,2,3])))");
|
|
842
|
-
expect(r.stdout).toContain("[1, 2, 3]");
|
|
843
|
-
expect(r.stdout).toContain("[3, 2, 1]");
|
|
844
|
-
});
|
|
845
|
-
test("enumerate()", async () => {
|
|
846
|
-
const r = await py("for i,v in enumerate(['a','b']):\n print(i, v)");
|
|
847
|
-
expect(r.stdout).toContain("0 a");
|
|
848
|
-
expect(r.stdout).toContain("1 b");
|
|
849
|
-
});
|
|
850
|
-
});
|