typescript-virtual-container 1.4.0 → 1.4.2
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/.vscode/settings.json +2 -0
- package/README.md +5 -1
- package/benchmark-virtualshell.ts +3 -11
- package/builds/self-standalone.js +230 -346
- package/builds/self-standalone.js.map +3 -3
- package/builds/standalone-wo-sftp.js +156 -272
- package/builds/standalone-wo-sftp.js.map +3 -3
- package/builds/standalone.js +151 -267
- package/builds/standalone.js.map +3 -3
- package/dist/VirtualPackageManager/index.d.ts.map +1 -1
- package/dist/VirtualPackageManager/index.js +29 -1
- package/dist/VirtualShell/shell.d.ts.map +1 -1
- package/dist/VirtualShell/shell.js +6 -10
- package/dist/VirtualUserManager/index.d.ts.map +1 -1
- package/dist/VirtualUserManager/index.js +4 -4
- package/dist/commands/curl.d.ts.map +1 -1
- package/dist/commands/curl.js +2 -1
- package/dist/commands/gzip.d.ts.map +1 -1
- package/dist/commands/gzip.js +6 -0
- package/dist/commands/helpers.js +1 -1
- package/dist/commands/history.js +2 -2
- package/dist/commands/man.d.ts.map +1 -1
- package/dist/commands/man.js +30 -136
- package/dist/commands/neofetch.d.ts.map +1 -1
- package/dist/commands/neofetch.js +6 -0
- package/dist/commands/wget.d.ts.map +1 -1
- package/dist/commands/wget.js +11 -1
- package/dist/modules/linuxRootfs.d.ts +1 -1
- package/dist/modules/linuxRootfs.d.ts.map +1 -1
- package/dist/modules/linuxRootfs.js +5 -5
- package/dist/self-standalone.js +149 -102
- package/package.json +2 -2
- package/src/VirtualPackageManager/index.ts +29 -1
- package/src/VirtualShell/shell.ts +6 -11
- package/src/VirtualUserManager/index.ts +4 -4
- package/src/commands/curl.ts +2 -1
- package/src/commands/gzip.ts +7 -0
- package/src/commands/helpers.ts +1 -1
- package/src/commands/history.ts +2 -2
- package/src/commands/man.ts +38 -143
- package/src/commands/manuals/adduser.txt +11 -0
- package/src/commands/manuals/apt-cache.txt +12 -0
- package/src/commands/manuals/apt.txt +20 -0
- package/src/commands/manuals/awk.txt +13 -0
- package/src/commands/manuals/cat.txt +14 -0
- package/src/commands/manuals/cd.txt +16 -0
- package/src/commands/manuals/chmod.txt +16 -0
- package/src/commands/manuals/clear.txt +10 -0
- package/src/commands/manuals/cp.txt +10 -0
- package/src/commands/manuals/curl.txt +20 -0
- package/src/commands/manuals/date.txt +14 -0
- package/src/commands/manuals/declare.txt +12 -0
- package/src/commands/manuals/deluser.txt +10 -0
- package/src/commands/manuals/df.txt +10 -0
- package/src/commands/manuals/dpkg-query.txt +11 -0
- package/src/commands/manuals/dpkg.txt +14 -0
- package/src/commands/manuals/du.txt +11 -0
- package/src/commands/manuals/echo.txt +11 -0
- package/src/commands/manuals/false.txt +10 -0
- package/src/commands/manuals/find.txt +11 -0
- package/src/commands/manuals/free.txt +12 -0
- package/src/commands/manuals/grep.txt +13 -0
- package/src/commands/manuals/groups.txt +10 -0
- package/src/commands/manuals/gzip.txt +11 -0
- package/src/commands/manuals/head.txt +10 -0
- package/src/commands/manuals/help.txt +11 -0
- package/src/commands/manuals/history.txt +11 -0
- package/src/commands/manuals/hostname.txt +10 -0
- package/src/commands/manuals/id.txt +10 -0
- package/src/commands/manuals/kill.txt +13 -0
- package/src/commands/manuals/ls.txt +20 -0
- package/src/commands/manuals/lsb_release.txt +14 -0
- package/src/commands/manuals/mkdir.txt +10 -0
- package/src/commands/manuals/mv.txt +10 -0
- package/src/commands/manuals/nano.txt +11 -0
- package/src/commands/manuals/neofetch.txt +10 -0
- package/src/commands/manuals/node.txt +13 -0
- package/src/commands/manuals/npm.txt +13 -0
- package/src/commands/manuals/npx.txt +13 -0
- package/src/commands/manuals/passwd.txt +11 -0
- package/src/commands/manuals/ping.txt +10 -0
- package/src/commands/manuals/printf.txt +11 -0
- package/src/commands/manuals/ps.txt +10 -0
- package/src/commands/manuals/pwd.txt +10 -0
- package/src/commands/manuals/python3.txt +13 -0
- package/src/commands/manuals/readlink.txt +10 -0
- package/src/commands/manuals/return.txt +10 -0
- package/src/commands/manuals/rm.txt +10 -0
- package/src/commands/manuals/sed.txt +11 -0
- package/src/commands/manuals/set.txt +11 -0
- package/src/commands/manuals/shift.txt +10 -0
- package/src/commands/manuals/sleep.txt +10 -0
- package/src/commands/manuals/sort.txt +12 -0
- package/src/commands/manuals/source.txt +11 -0
- package/src/commands/manuals/ssh.txt +11 -0
- package/src/commands/manuals/stat.txt +10 -0
- package/src/commands/manuals/su.txt +13 -0
- package/src/commands/manuals/sudo.txt +11 -0
- package/src/commands/manuals/tail.txt +10 -0
- package/src/commands/manuals/tar.txt +19 -0
- package/src/commands/manuals/tee.txt +10 -0
- package/src/commands/manuals/test.txt +11 -0
- package/src/commands/manuals/touch.txt +11 -0
- package/src/commands/manuals/tr.txt +10 -0
- package/src/commands/manuals/trap.txt +10 -0
- package/src/commands/manuals/true.txt +10 -0
- package/src/commands/manuals/type.txt +10 -0
- package/src/commands/manuals/uname.txt +12 -0
- package/src/commands/manuals/uniq.txt +12 -0
- package/src/commands/manuals/unset.txt +10 -0
- package/src/commands/manuals/uptime.txt +11 -0
- package/src/commands/manuals/wc.txt +12 -0
- package/src/commands/manuals/wget.txt +12 -0
- package/src/commands/manuals/which.txt +10 -0
- package/src/commands/manuals/whoami.txt +10 -0
- package/src/commands/manuals/xargs.txt +10 -0
- package/src/commands/neofetch.ts +7 -0
- package/src/commands/wget.ts +12 -1
- package/src/modules/linuxRootfs.ts +6 -6
- package/src/self-standalone.ts +190 -141
- package/tests/helpers.test.ts +3 -3
- package/tests/new-features.test.ts +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
NODE(1) User Commands NODE(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
node - virtual JavaScript runtime entry point
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
node [--version] [-e SCRIPT] [-p EXPR]
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
Execute JavaScript snippets in the virtual runtime.
|
|
11
|
+
|
|
12
|
+
NOTES
|
|
13
|
+
Requires package installation: apt install nodejs.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
NPM(1) User Commands NPM(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
npm - virtual Node.js package manager interface
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
npm [--version] [COMMAND]
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
Manage packages and run scripts in the virtual environment.
|
|
11
|
+
|
|
12
|
+
NOTES
|
|
13
|
+
Requires package installation: apt install npm.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
PYTHON3(1) User Commands PYTHON3(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
python3 - virtual Python 3 interpreter entry point
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
python3 [--version] [-V] [-c COMMAND]
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
Execute Python snippets in the virtual runtime.
|
|
11
|
+
|
|
12
|
+
NOTES
|
|
13
|
+
Requires package installation: apt install python3.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
SORT(1) User Commands SORT(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
sort - sort lines of text files
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
sort [OPTION]... [FILE]...
|
|
8
|
+
|
|
9
|
+
OPTIONS
|
|
10
|
+
-r reverse the result of comparisons
|
|
11
|
+
-n compare according to string numerical value
|
|
12
|
+
-u output only the first of an equal run
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
TAR(1) GNU tar Manual TAR(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
tar - an archiving utility
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
tar [OPTION...] [FILE]...
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
tar saves many files together into a single tape or disk archive,
|
|
11
|
+
and can restore individual files from the archive.
|
|
12
|
+
|
|
13
|
+
OPTIONS
|
|
14
|
+
-c, --create create a new archive
|
|
15
|
+
-x, --extract extract files from an archive
|
|
16
|
+
-z, --gzip filter the archive through gzip
|
|
17
|
+
-f, --file=ARCHIVE use archive file or device ARCHIVE
|
|
18
|
+
-v, --verbose verbosely list files processed
|
|
19
|
+
-t, --list list the contents of an archive
|
package/src/commands/neofetch.ts
CHANGED
|
@@ -13,6 +13,13 @@ export const neofetchCommand: ShellModule = {
|
|
|
13
13
|
category: "system",
|
|
14
14
|
params: ["[--off]"],
|
|
15
15
|
run: ({ args, authUser, hostname, shell, env }) => {
|
|
16
|
+
if (!shell.packageManager.isInstalled("neofetch")) {
|
|
17
|
+
return {
|
|
18
|
+
stderr:
|
|
19
|
+
"bash: neofetch: command not found\nHint: install it with: apt install neofetch\n",
|
|
20
|
+
exitCode: 127,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
16
23
|
if (ifFlag(args, "--help")) {
|
|
17
24
|
return {
|
|
18
25
|
stdout: "Usage: neofetch [--off]",
|
package/src/commands/wget.ts
CHANGED
|
@@ -49,7 +49,18 @@ export const wgetCommand: ShellModule = {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const
|
|
52
|
+
const urlWithoutProtocol = positionals[0];
|
|
53
|
+
if (!urlWithoutProtocol) {
|
|
54
|
+
return {
|
|
55
|
+
stderr: "wget: missing URL\nUsage: wget [OPTION]... [URL]...",
|
|
56
|
+
exitCode: 1,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const url = urlWithoutProtocol.startsWith("http://") ||
|
|
61
|
+
urlWithoutProtocol.startsWith("https://")
|
|
62
|
+
? urlWithoutProtocol
|
|
63
|
+
: `http://${urlWithoutProtocol}`;
|
|
53
64
|
if (!url)
|
|
54
65
|
return {
|
|
55
66
|
stderr: "wget: missing URL\nUsage: wget [OPTION]... [URL]...",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import * as os from "node:os";
|
|
11
|
-
import type { ShellProperties } from "../VirtualShell";
|
|
12
11
|
import type VirtualFileSystem from "../VirtualFileSystem";
|
|
12
|
+
import type { ShellProperties } from "../VirtualShell";
|
|
13
13
|
import type { VirtualUserManager } from "../VirtualUserManager";
|
|
14
14
|
|
|
15
15
|
// ─── helpers ────────────────────────────────────────────────────────────────
|
|
@@ -584,7 +584,7 @@ function bootstrapRoot(vfs: VirtualFileSystem): void {
|
|
|
584
584
|
ensureDir(vfs, "/root", 0o700);
|
|
585
585
|
ensureFile(
|
|
586
586
|
vfs,
|
|
587
|
-
"/root/.bashrc",
|
|
587
|
+
"/home/root/.bashrc",
|
|
588
588
|
`${[
|
|
589
589
|
"# root .bashrc",
|
|
590
590
|
"export PS1='\\[\\033[0;31m\\]\\u@\\h\\[\\033[0m\\]:\\[\\033[0;34m\\]\\w\\[\\033[0m\\]# '",
|
|
@@ -593,11 +593,11 @@ function bootstrapRoot(vfs: VirtualFileSystem): void {
|
|
|
593
593
|
"alias la='ls -A'",
|
|
594
594
|
].join("\n")}\n`,
|
|
595
595
|
);
|
|
596
|
-
ensureFile(vfs, "/root/.profile", "[ -f ~/.bashrc ] && . ~/.bashrc\n");
|
|
596
|
+
ensureFile(vfs, "/home/root/.profile", "[ -f ~/.bashrc ] && . ~/.bashrc\n");
|
|
597
597
|
// Fix: /home/root should map to /root for root user
|
|
598
|
-
if (!vfs.exists("/home/root")) {
|
|
599
|
-
|
|
600
|
-
}
|
|
598
|
+
// if (!vfs.exists("/home/root")) {
|
|
599
|
+
// vfs.symlink("/root", "/home/root");
|
|
600
|
+
// }
|
|
601
601
|
}
|
|
602
602
|
|
|
603
603
|
// ─── /opt + /srv + /mnt + /media ─────────────────────────────────────────────
|