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
package/src/commands/man.ts
CHANGED
|
@@ -1,154 +1,49 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
NAME
|
|
7
|
-
ls - list directory contents
|
|
8
|
-
|
|
9
|
-
SYNOPSIS
|
|
10
|
-
ls [OPTION]... [FILE]...
|
|
11
|
-
|
|
12
|
-
DESCRIPTION
|
|
13
|
-
List information about the FILEs (the current directory by default).
|
|
14
|
-
|
|
15
|
-
OPTIONS
|
|
16
|
-
-l use a long listing format
|
|
17
|
-
-a do not ignore entries starting with .
|
|
18
|
-
-h with -l, print human readable sizes
|
|
19
|
-
-r reverse order while sorting
|
|
20
|
-
-t sort by modification time
|
|
21
|
-
|
|
22
|
-
AUTHOR
|
|
23
|
-
Written by Richard M. Stallman and David MacKenzie.`,
|
|
24
|
-
|
|
25
|
-
cat: `CAT(1) User Commands CAT(1)
|
|
26
|
-
|
|
27
|
-
NAME
|
|
28
|
-
cat - concatenate files and print on the standard output
|
|
29
|
-
|
|
30
|
-
SYNOPSIS
|
|
31
|
-
cat [OPTION]... [FILE]...
|
|
32
|
-
|
|
33
|
-
DESCRIPTION
|
|
34
|
-
Concatenate FILE(s) to standard output.
|
|
35
|
-
|
|
36
|
-
OPTIONS
|
|
37
|
-
-n, --number number all output lines
|
|
38
|
-
-b, --number-nonblank number nonempty output lines`,
|
|
39
|
-
|
|
40
|
-
grep: `GREP(1) User Commands GREP(1)
|
|
41
|
-
|
|
42
|
-
NAME
|
|
43
|
-
grep, egrep, fgrep - print lines that match patterns
|
|
44
|
-
|
|
45
|
-
SYNOPSIS
|
|
46
|
-
grep [OPTION]... PATTERNS [FILE]...
|
|
47
|
-
|
|
48
|
-
OPTIONS
|
|
49
|
-
-i, --ignore-case ignore case distinctions in patterns and data
|
|
50
|
-
-v, --invert-match select non-matching lines
|
|
51
|
-
-n, --line-number print line number with output lines
|
|
52
|
-
-r, --recursive read all files under each directory, recursively`,
|
|
53
|
-
|
|
54
|
-
apt: `APT(8) APT APT(8)
|
|
55
|
-
|
|
56
|
-
NAME
|
|
57
|
-
apt - command-line interface
|
|
58
|
-
|
|
59
|
-
SYNOPSIS
|
|
60
|
-
apt [options] command
|
|
61
|
-
|
|
62
|
-
DESCRIPTION
|
|
63
|
-
apt provides a high-level commandline interface for the package
|
|
64
|
-
management system.
|
|
65
|
-
|
|
66
|
-
COMMANDS
|
|
67
|
-
install pkg... Install packages
|
|
68
|
-
remove pkg... Remove packages
|
|
69
|
-
update Download package information
|
|
70
|
-
upgrade Upgrade installed packages
|
|
71
|
-
search term Search in package descriptions
|
|
72
|
-
show pkg Show package information
|
|
73
|
-
list List packages`,
|
|
74
|
-
|
|
75
|
-
ssh: `SSH(1) OpenSSH SSH(1)
|
|
76
|
-
|
|
77
|
-
NAME
|
|
78
|
-
ssh - OpenSSH remote login client
|
|
79
|
-
|
|
80
|
-
SYNOPSIS
|
|
81
|
-
ssh [-p port] [user@]hostname [command]
|
|
82
|
-
|
|
83
|
-
DESCRIPTION
|
|
84
|
-
ssh (SSH client) is a program for logging into a remote machine and
|
|
85
|
-
for executing commands on a remote machine.`,
|
|
86
|
-
|
|
87
|
-
curl: `CURL(1) User Commands CURL(1)
|
|
88
|
-
|
|
89
|
-
NAME
|
|
90
|
-
curl - transfer a URL
|
|
91
|
-
|
|
92
|
-
SYNOPSIS
|
|
93
|
-
curl [options / URLs]
|
|
94
|
-
|
|
95
|
-
DESCRIPTION
|
|
96
|
-
curl is a tool for transferring data with URL syntax.
|
|
97
|
-
|
|
98
|
-
OPTIONS
|
|
99
|
-
-o, --output <file> Write output to <file>
|
|
100
|
-
-X, --request <method> Specify request method
|
|
101
|
-
-d, --data <data> HTTP POST data
|
|
102
|
-
-H, --header <header> Pass custom header
|
|
103
|
-
-s, --silent Silent mode
|
|
104
|
-
-I, --head Show document info only
|
|
105
|
-
-L, --location Follow redirects
|
|
106
|
-
-v, --verbose Make the operation more talkative`,
|
|
107
|
-
|
|
108
|
-
chmod: `CHMOD(1) User Commands CHMOD(1)
|
|
109
|
-
|
|
110
|
-
NAME
|
|
111
|
-
chmod - change file mode bits
|
|
112
|
-
|
|
113
|
-
SYNOPSIS
|
|
114
|
-
chmod [OPTION]... MODE[,MODE]... FILE...
|
|
115
|
-
chmod [OPTION]... OCTAL-MODE FILE...
|
|
116
|
-
|
|
117
|
-
DESCRIPTION
|
|
118
|
-
Change the file mode bits of each given file according to MODE.
|
|
119
|
-
|
|
120
|
-
EXAMPLES
|
|
121
|
-
chmod 755 script.sh rwxr-xr-x
|
|
122
|
-
chmod 644 file.txt rw-r--r--
|
|
123
|
-
chmod +x script.sh add execute permission`,
|
|
124
|
-
|
|
125
|
-
tar: `TAR(1) GNU tar Manual TAR(1)
|
|
126
|
-
|
|
127
|
-
NAME
|
|
128
|
-
tar - an archiving utility
|
|
129
|
-
|
|
130
|
-
SYNOPSIS
|
|
131
|
-
tar [OPTION...] [FILE]...
|
|
132
|
-
|
|
133
|
-
DESCRIPTION
|
|
134
|
-
tar saves many files together into a single tape or disk archive,
|
|
135
|
-
and can restore individual files from the archive.
|
|
136
|
-
|
|
137
|
-
OPTIONS
|
|
138
|
-
-c, --create create a new archive
|
|
139
|
-
-x, --extract extract files from an archive
|
|
140
|
-
-z, --gzip filter the archive through gzip
|
|
141
|
-
-f, --file=ARCHIVE use archive file or device ARCHIVE
|
|
142
|
-
-v, --verbose verbosely list files processed
|
|
143
|
-
-t, --list list the contents of an archive`,
|
|
3
|
+
const MANUAL_ALIASES: Record<string, string> = {
|
|
4
|
+
gunzip: "gzip",
|
|
144
5
|
};
|
|
145
6
|
|
|
7
|
+
const manualCache = new Map<string, string | null>();
|
|
8
|
+
const manualsBaseUrl = new URL("./manuals/", import.meta.url);
|
|
9
|
+
|
|
10
|
+
async function dynamicImport(specifier: string): Promise<unknown> {
|
|
11
|
+
const importer = new Function(
|
|
12
|
+
"moduleName",
|
|
13
|
+
"return import(moduleName)",
|
|
14
|
+
) as (moduleName: string) => Promise<unknown>;
|
|
15
|
+
return importer(specifier);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function loadBundledManual(commandName: string): Promise<string | null> {
|
|
19
|
+
const normalized = commandName.toLowerCase();
|
|
20
|
+
const lookupName = MANUAL_ALIASES[normalized] ?? normalized;
|
|
21
|
+
const cacheKey = `builtin:${lookupName}`;
|
|
22
|
+
if (manualCache.has(cacheKey)) {
|
|
23
|
+
return manualCache.get(cacheKey) ?? null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const fsModule = (await dynamicImport("node:fs/promises")) as {
|
|
28
|
+
readFile: (path: URL, encoding: "utf8") => Promise<string>;
|
|
29
|
+
};
|
|
30
|
+
const manualUrl = new URL(`${lookupName}.txt`, manualsBaseUrl);
|
|
31
|
+
const content = await fsModule.readFile(manualUrl, "utf8");
|
|
32
|
+
const page = content.replace(/\n$/, "");
|
|
33
|
+
manualCache.set(cacheKey, page);
|
|
34
|
+
return page;
|
|
35
|
+
} catch {
|
|
36
|
+
manualCache.set(cacheKey, null);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
146
41
|
export const manCommand: ShellModule = {
|
|
147
42
|
name: "man",
|
|
148
43
|
description: "Interface to the system reference manuals",
|
|
149
44
|
category: "shell",
|
|
150
45
|
params: ["<command>"],
|
|
151
|
-
run: ({ args, shell }) => {
|
|
46
|
+
run: async ({ args, shell }) => {
|
|
152
47
|
const name = args[0];
|
|
153
48
|
if (!name) return { stderr: "What manual page do you want?", exitCode: 1 };
|
|
154
49
|
|
|
@@ -158,7 +53,7 @@ export const manCommand: ShellModule = {
|
|
|
158
53
|
return { stdout: shell.vfs.readFile(manPath), exitCode: 0 };
|
|
159
54
|
}
|
|
160
55
|
|
|
161
|
-
const page =
|
|
56
|
+
const page = await loadBundledManual(name);
|
|
162
57
|
if (page) return { stdout: page, exitCode: 0 };
|
|
163
58
|
|
|
164
59
|
return { stderr: `No manual entry for ${name}`, exitCode: 16 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
APT-CACHE(8) APT APT-CACHE(8)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
apt-cache - query APT package cache
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
apt-cache command [args]
|
|
8
|
+
|
|
9
|
+
COMMANDS
|
|
10
|
+
search term search package names/descriptions
|
|
11
|
+
show pkg show package metadata
|
|
12
|
+
policy pkg show package policy and candidate versions
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
APT(8) APT APT(8)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
apt - command-line interface
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
apt [options] command
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
apt provides a high-level commandline interface for the package
|
|
11
|
+
management system.
|
|
12
|
+
|
|
13
|
+
COMMANDS
|
|
14
|
+
install pkg... Install packages
|
|
15
|
+
remove pkg... Remove packages
|
|
16
|
+
update Download package information
|
|
17
|
+
upgrade Upgrade installed packages
|
|
18
|
+
search term Search in package descriptions
|
|
19
|
+
show pkg Show package information
|
|
20
|
+
list List packages
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
AWK(1) User Commands AWK(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
awk - pattern scanning and processing language
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
awk [OPTION]... 'PROGRAM' [FILE]...
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
awk scans each input line, applies PROGRAM rules, and prints results.
|
|
11
|
+
|
|
12
|
+
OPTIONS
|
|
13
|
+
-F fs use fs as input field separator
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CAT(1) User Commands CAT(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
cat - concatenate files and print on the standard output
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
cat [OPTION]... [FILE]...
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
Concatenate FILE(s) to standard output.
|
|
11
|
+
|
|
12
|
+
OPTIONS
|
|
13
|
+
-n, --number number all output lines
|
|
14
|
+
-b, --number-nonblank number nonempty output lines
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
CHMOD(1) User Commands CHMOD(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
chmod - change file mode bits
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
chmod [OPTION]... MODE[,MODE]... FILE...
|
|
8
|
+
chmod [OPTION]... OCTAL-MODE FILE...
|
|
9
|
+
|
|
10
|
+
DESCRIPTION
|
|
11
|
+
Change the file mode bits of each given file according to MODE.
|
|
12
|
+
|
|
13
|
+
EXAMPLES
|
|
14
|
+
chmod 755 script.sh rwxr-xr-x
|
|
15
|
+
chmod 644 file.txt rw-r--r--
|
|
16
|
+
chmod +x script.sh add execute permission
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
CURL(1) User Commands CURL(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
curl - transfer a URL
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
curl [options / URLs]
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
curl is a tool for transferring data with URL syntax.
|
|
11
|
+
|
|
12
|
+
OPTIONS
|
|
13
|
+
-o, --output <file> Write output to <file>
|
|
14
|
+
-X, --request <method> Specify request method
|
|
15
|
+
-d, --data <data> HTTP POST data
|
|
16
|
+
-H, --header <header> Pass custom header
|
|
17
|
+
-s, --silent Silent mode
|
|
18
|
+
-I, --head Show document info only
|
|
19
|
+
-L, --location Follow redirects
|
|
20
|
+
-v, --verbose Make the operation more talkative
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
DPKG(1) User Commands DPKG(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
dpkg - package manager for Debian-like systems
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
dpkg [OPTION]... ACTION
|
|
8
|
+
|
|
9
|
+
OPTIONS
|
|
10
|
+
-l list installed packages
|
|
11
|
+
-s show package status
|
|
12
|
+
-L list files in package
|
|
13
|
+
-r remove package
|
|
14
|
+
-P purge package
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
GREP(1) User Commands GREP(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
grep, egrep, fgrep - print lines that match patterns
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
grep [OPTION]... PATTERNS [FILE]...
|
|
8
|
+
|
|
9
|
+
OPTIONS
|
|
10
|
+
-i, --ignore-case ignore case distinctions in patterns and data
|
|
11
|
+
-v, --invert-match select non-matching lines
|
|
12
|
+
-n, --line-number print line number with output lines
|
|
13
|
+
-r, --recursive read all files under each directory, recursively
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
LS(1) User Commands LS(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
ls - list directory contents
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
ls [OPTION]... [FILE]...
|
|
8
|
+
|
|
9
|
+
DESCRIPTION
|
|
10
|
+
List information about the FILEs (the current directory by default).
|
|
11
|
+
|
|
12
|
+
OPTIONS
|
|
13
|
+
-l use a long listing format
|
|
14
|
+
-a do not ignore entries starting with .
|
|
15
|
+
-h with -l, print human readable sizes
|
|
16
|
+
-r reverse order while sorting
|
|
17
|
+
-t sort by modification time
|
|
18
|
+
|
|
19
|
+
AUTHOR
|
|
20
|
+
Written by Richard M. Stallman and David MacKenzie.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LSB_RELEASE(1) User Commands LSB_RELEASE(1)
|
|
2
|
+
|
|
3
|
+
NAME
|
|
4
|
+
lsb_release - print distribution-specific information
|
|
5
|
+
|
|
6
|
+
SYNOPSIS
|
|
7
|
+
lsb_release [OPTION]...
|
|
8
|
+
|
|
9
|
+
OPTIONS
|
|
10
|
+
-a show all available information
|
|
11
|
+
-i show distributor ID
|
|
12
|
+
-d show description
|
|
13
|
+
-r show release number
|
|
14
|
+
-c show codename
|