typescript-virtual-container 1.2.8 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +0 -1
- package/README.md +462 -44
- package/biome.json +7 -0
- package/dist/SSHMimic/exec.d.ts.map +1 -1
- package/dist/SSHMimic/executor.d.ts.map +1 -1
- package/dist/SSHMimic/executor.js +35 -21
- package/dist/SSHMimic/index.d.ts.map +1 -1
- package/dist/SSHMimic/index.js +20 -6
- package/dist/VirtualFileSystem/binaryPack.d.ts.map +1 -1
- package/dist/VirtualFileSystem/binaryPack.js +29 -6
- package/dist/VirtualFileSystem/index.d.ts.map +1 -1
- package/dist/VirtualFileSystem/index.js +36 -13
- package/dist/VirtualPackageManager/index.d.ts +202 -0
- package/dist/VirtualPackageManager/index.d.ts.map +1 -0
- package/dist/VirtualPackageManager/index.js +825 -0
- package/dist/VirtualShell/index.d.ts +93 -12
- package/dist/VirtualShell/index.d.ts.map +1 -1
- package/dist/VirtualShell/index.js +95 -13
- package/dist/VirtualShell/shell.d.ts.map +1 -1
- package/dist/VirtualShell/shell.js +3 -1
- package/dist/VirtualShell/shellParser.d.ts.map +1 -1
- package/dist/VirtualUserManager/index.d.ts +52 -20
- package/dist/VirtualUserManager/index.d.ts.map +1 -1
- package/dist/VirtualUserManager/index.js +54 -20
- package/dist/commands/adduser.d.ts +6 -0
- package/dist/commands/adduser.d.ts.map +1 -1
- package/dist/commands/adduser.js +6 -0
- package/dist/commands/alias.d.ts +9 -0
- package/dist/commands/alias.d.ts.map +1 -0
- package/dist/commands/alias.js +63 -0
- package/dist/commands/apt.d.ts +9 -0
- package/dist/commands/apt.d.ts.map +1 -0
- package/dist/commands/apt.js +205 -0
- package/dist/commands/awk.d.ts +11 -0
- package/dist/commands/awk.d.ts.map +1 -1
- package/dist/commands/awk.js +15 -2
- package/dist/commands/base64.d.ts +5 -0
- package/dist/commands/base64.d.ts.map +1 -1
- package/dist/commands/base64.js +9 -1
- package/dist/commands/cat.d.ts +5 -0
- package/dist/commands/cat.d.ts.map +1 -1
- package/dist/commands/cat.js +35 -8
- package/dist/commands/cd.d.ts +5 -0
- package/dist/commands/cd.d.ts.map +1 -1
- package/dist/commands/cd.js +5 -0
- package/dist/commands/chmod.d.ts +5 -0
- package/dist/commands/chmod.d.ts.map +1 -1
- package/dist/commands/chmod.js +57 -3
- package/dist/commands/command-helpers.d.ts +78 -4
- package/dist/commands/command-helpers.d.ts.map +1 -1
- package/dist/commands/command-helpers.js +78 -4
- package/dist/commands/cp.d.ts +5 -0
- package/dist/commands/cp.d.ts.map +1 -1
- package/dist/commands/cp.js +5 -0
- package/dist/commands/curl.d.ts +5 -0
- package/dist/commands/curl.d.ts.map +1 -1
- package/dist/commands/curl.js +106 -26
- package/dist/commands/cut.d.ts +5 -0
- package/dist/commands/cut.d.ts.map +1 -1
- package/dist/commands/cut.js +8 -1
- package/dist/commands/date.d.ts +5 -0
- package/dist/commands/date.d.ts.map +1 -1
- package/dist/commands/date.js +7 -1
- package/dist/commands/declare.d.ts +3 -0
- package/dist/commands/declare.d.ts.map +1 -0
- package/dist/commands/declare.js +39 -0
- package/dist/commands/diff.d.ts +5 -0
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +5 -0
- package/dist/commands/dpkg.d.ts +9 -0
- package/dist/commands/dpkg.d.ts.map +1 -0
- package/dist/commands/dpkg.js +161 -0
- package/dist/commands/du.d.ts.map +1 -1
- package/dist/commands/du.js +8 -2
- package/dist/commands/echo.d.ts +5 -0
- package/dist/commands/echo.d.ts.map +1 -1
- package/dist/commands/echo.js +33 -12
- package/dist/commands/env.d.ts +5 -0
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +11 -1
- package/dist/commands/exit.d.ts +5 -0
- package/dist/commands/exit.d.ts.map +1 -1
- package/dist/commands/exit.js +12 -2
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +3 -1
- package/dist/commands/find.d.ts +5 -0
- package/dist/commands/find.d.ts.map +1 -1
- package/dist/commands/find.js +5 -0
- package/dist/commands/free.d.ts +8 -0
- package/dist/commands/free.d.ts.map +1 -0
- package/dist/commands/free.js +43 -0
- package/dist/commands/grep.d.ts +5 -0
- package/dist/commands/grep.d.ts.map +1 -1
- package/dist/commands/grep.js +12 -2
- package/dist/commands/gzip.d.ts +5 -0
- package/dist/commands/gzip.d.ts.map +1 -1
- package/dist/commands/gzip.js +18 -2
- package/dist/commands/head.d.ts +5 -0
- package/dist/commands/head.d.ts.map +1 -1
- package/dist/commands/head.js +5 -0
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +98 -45
- package/dist/commands/helpers.d.ts +3 -0
- package/dist/commands/helpers.d.ts.map +1 -1
- package/dist/commands/helpers.js +3 -0
- package/dist/commands/history.d.ts +8 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +26 -0
- package/dist/commands/hostname.d.ts +5 -0
- package/dist/commands/hostname.d.ts.map +1 -1
- package/dist/commands/hostname.js +5 -0
- package/dist/commands/id.d.ts.map +1 -1
- package/dist/commands/id.js +4 -1
- package/dist/commands/index.d.ts +2 -10
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -231
- package/dist/commands/ls.d.ts.map +1 -1
- package/dist/commands/ls.js +6 -3
- package/dist/commands/lsb-release.d.ts +3 -0
- package/dist/commands/lsb-release.d.ts.map +1 -0
- package/dist/commands/lsb-release.js +56 -0
- package/dist/commands/man.d.ts +3 -0
- package/dist/commands/man.d.ts.map +1 -0
- package/dist/commands/man.js +155 -0
- package/dist/commands/nano.js +1 -1
- package/dist/commands/neofetch.d.ts.map +1 -1
- package/dist/commands/neofetch.js +6 -1
- package/dist/commands/node.d.ts +9 -0
- package/dist/commands/node.d.ts.map +1 -0
- package/dist/commands/node.js +316 -0
- package/dist/commands/npm.d.ts +19 -0
- package/dist/commands/npm.d.ts.map +1 -0
- package/dist/commands/npm.js +109 -0
- package/dist/commands/ping.d.ts.map +1 -1
- package/dist/commands/ping.js +7 -2
- package/dist/commands/printf.d.ts +3 -0
- package/dist/commands/printf.d.ts.map +1 -0
- package/dist/commands/printf.js +113 -0
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +30 -6
- package/dist/commands/python.d.ts +30 -0
- package/dist/commands/python.d.ts.map +1 -0
- package/dist/commands/python.js +2058 -0
- package/dist/commands/read.d.ts +3 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +34 -0
- package/dist/commands/registry.d.ts +8 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +229 -0
- package/dist/commands/runtime.d.ts +6 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +280 -0
- package/dist/commands/sed.d.ts.map +1 -1
- package/dist/commands/sed.js +11 -3
- package/dist/commands/set.d.ts.map +1 -1
- package/dist/commands/set.js +9 -3
- package/dist/commands/sh.d.ts.map +1 -1
- package/dist/commands/sh.js +69 -30
- package/dist/commands/shift.d.ts +5 -0
- package/dist/commands/shift.d.ts.map +1 -0
- package/dist/commands/shift.js +52 -0
- package/dist/commands/sleep.d.ts.map +1 -1
- package/dist/commands/sort.d.ts.map +1 -1
- package/dist/commands/sort.js +4 -2
- package/dist/commands/source.d.ts +3 -0
- package/dist/commands/source.d.ts.map +1 -0
- package/dist/commands/source.js +34 -0
- package/dist/commands/sudo.js +1 -1
- package/dist/commands/tar.d.ts.map +1 -1
- package/dist/commands/tar.js +11 -3
- package/dist/commands/tee.d.ts.map +1 -1
- package/dist/commands/tee.js +8 -6
- package/dist/commands/test.d.ts +3 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +114 -0
- package/dist/commands/tr.d.ts.map +1 -1
- package/dist/commands/tr.js +3 -1
- package/dist/commands/true.d.ts +4 -0
- package/dist/commands/true.d.ts.map +1 -0
- package/dist/commands/true.js +14 -0
- package/dist/commands/type.d.ts +3 -0
- package/dist/commands/type.d.ts.map +1 -0
- package/dist/commands/type.js +34 -0
- package/dist/commands/uname.d.ts.map +1 -1
- package/dist/commands/uname.js +4 -1
- package/dist/commands/uniq.d.ts.map +1 -1
- package/dist/commands/uptime.d.ts +3 -0
- package/dist/commands/uptime.d.ts.map +1 -0
- package/dist/commands/uptime.js +43 -0
- package/dist/commands/wget.d.ts.map +1 -1
- package/dist/commands/wget.js +92 -96
- package/dist/commands/which.d.ts +3 -0
- package/dist/commands/which.d.ts.map +1 -0
- package/dist/commands/which.js +32 -0
- package/dist/commands/xargs.d.ts.map +1 -1
- package/dist/commands/xargs.js +1 -1
- package/dist/index.d.ts +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -8
- package/dist/modules/linuxRootfs.d.ts +41 -0
- package/dist/modules/linuxRootfs.d.ts.map +1 -0
- package/dist/modules/linuxRootfs.js +440 -0
- package/dist/modules/neofetch.d.ts.map +1 -1
- package/dist/modules/neofetch.js +1 -0
- package/dist/standalone-wo-sftp.d.ts +2 -0
- package/dist/standalone-wo-sftp.d.ts.map +1 -0
- package/dist/standalone-wo-sftp.js +30 -0
- package/dist/utils/expand.d.ts +50 -0
- package/dist/utils/expand.d.ts.map +1 -0
- package/dist/utils/expand.js +183 -0
- package/dist/utils/vfsDiff.d.ts +90 -0
- package/dist/utils/vfsDiff.d.ts.map +1 -0
- package/dist/utils/vfsDiff.js +177 -0
- package/package.json +3 -1
- package/src/SSHMimic/exec.ts +10 -1
- package/src/SSHMimic/executor.ts +105 -21
- package/src/SSHMimic/index.ts +49 -15
- package/src/VirtualFileSystem/binaryPack.ts +35 -8
- package/src/VirtualFileSystem/index.ts +78 -28
- package/src/VirtualPackageManager/index.ts +979 -0
- package/src/VirtualShell/index.ts +133 -14
- package/src/VirtualShell/shell.ts +23 -3
- package/src/VirtualShell/shellParser.ts +134 -36
- package/src/VirtualUserManager/index.ts +62 -22
- package/src/commands/adduser.ts +6 -0
- package/src/commands/alias.ts +64 -0
- package/src/commands/apt.ts +228 -0
- package/src/commands/awk.ts +20 -6
- package/src/commands/base64.ts +13 -2
- package/src/commands/cat.ts +40 -8
- package/src/commands/cd.ts +5 -0
- package/src/commands/chmod.ts +53 -3
- package/src/commands/command-helpers.ts +78 -4
- package/src/commands/cp.ts +5 -0
- package/src/commands/curl.ts +118 -33
- package/src/commands/cut.ts +8 -1
- package/src/commands/date.ts +7 -1
- package/src/commands/declare.ts +44 -0
- package/src/commands/diff.ts +17 -3
- package/src/commands/dpkg.ts +180 -0
- package/src/commands/du.ts +17 -5
- package/src/commands/echo.ts +41 -12
- package/src/commands/env.ts +11 -1
- package/src/commands/exit.ts +12 -2
- package/src/commands/export.ts +3 -1
- package/src/commands/find.ts +5 -0
- package/src/commands/free.ts +47 -0
- package/src/commands/grep.ts +12 -2
- package/src/commands/gzip.ts +28 -4
- package/src/commands/head.ts +5 -0
- package/src/commands/help.ts +121 -47
- package/src/commands/helpers.ts +8 -0
- package/src/commands/history.ts +34 -0
- package/src/commands/hostname.ts +5 -0
- package/src/commands/id.ts +4 -1
- package/src/commands/index.ts +9 -255
- package/src/commands/ls.ts +6 -3
- package/src/commands/lsb-release.ts +58 -0
- package/src/commands/man.ts +166 -0
- package/src/commands/nano.ts +1 -1
- package/src/commands/neofetch.ts +6 -1
- package/src/commands/node.ts +341 -0
- package/src/commands/npm.ts +132 -0
- package/src/commands/ping.ts +10 -3
- package/src/commands/printf.ts +112 -0
- package/src/commands/ps.ts +40 -6
- package/src/commands/python.ts +2229 -0
- package/src/commands/read.ts +41 -0
- package/src/commands/registry.ts +244 -0
- package/src/commands/runtime.ts +353 -0
- package/src/commands/sed.ts +27 -9
- package/src/commands/set.ts +9 -3
- package/src/commands/sh.ts +170 -44
- package/src/commands/shift.ts +53 -0
- package/src/commands/sleep.ts +2 -1
- package/src/commands/sort.ts +10 -6
- package/src/commands/source.ts +47 -0
- package/src/commands/sudo.ts +1 -1
- package/src/commands/tar.ts +28 -7
- package/src/commands/tee.ts +7 -1
- package/src/commands/test.ts +135 -0
- package/src/commands/tr.ts +3 -1
- package/src/commands/true.ts +17 -0
- package/src/commands/type.ts +43 -0
- package/src/commands/uname.ts +5 -1
- package/src/commands/uniq.ts +8 -2
- package/src/commands/uptime.ts +49 -0
- package/src/commands/wget.ts +105 -119
- package/src/commands/which.ts +37 -0
- package/src/commands/xargs.ts +11 -2
- package/src/index.ts +27 -18
- package/src/modules/linuxRootfs.ts +642 -0
- package/src/modules/neofetch.ts +1 -0
- package/src/standalone-wo-sftp.ts +38 -0
- package/src/utils/expand.ts +238 -0
- package/src/utils/vfsDiff.ts +275 -0
- package/standalone-wo-sftp.js +507 -0
- package/standalone-wo-sftp.js.map +7 -0
- package/standalone.js +486 -109
- package/standalone.js.map +4 -4
- package/tests/bun-test-shim.ts +9 -1
- package/tests/command-helpers.test.ts +1 -5
- package/tests/new-features.test.ts +1036 -0
- package/tests/parser-executor.test.ts +27 -27
- package/tests/sftp.test.ts +122 -42
- package/tests/users.test.ts +23 -5
- package/CHANGELOG.md +0 -150
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render a printf format string with given arguments.
|
|
3
|
+
* Supports: %s %d %i %f %o %x %X %% \n \t \r \\
|
|
4
|
+
*/
|
|
5
|
+
function renderPrintf(fmt, args) {
|
|
6
|
+
let argIdx = 0;
|
|
7
|
+
let out = "";
|
|
8
|
+
let i = 0;
|
|
9
|
+
while (i < fmt.length) {
|
|
10
|
+
if (fmt[i] === "\\" && i + 1 < fmt.length) {
|
|
11
|
+
switch (fmt[i + 1]) {
|
|
12
|
+
case "n":
|
|
13
|
+
out += "\n";
|
|
14
|
+
i += 2;
|
|
15
|
+
continue;
|
|
16
|
+
case "t":
|
|
17
|
+
out += "\t";
|
|
18
|
+
i += 2;
|
|
19
|
+
continue;
|
|
20
|
+
case "r":
|
|
21
|
+
out += "\r";
|
|
22
|
+
i += 2;
|
|
23
|
+
continue;
|
|
24
|
+
case "\\":
|
|
25
|
+
out += "\\";
|
|
26
|
+
i += 2;
|
|
27
|
+
continue;
|
|
28
|
+
case "a":
|
|
29
|
+
out += "\x07";
|
|
30
|
+
i += 2;
|
|
31
|
+
continue;
|
|
32
|
+
case "b":
|
|
33
|
+
out += "\x08";
|
|
34
|
+
i += 2;
|
|
35
|
+
continue;
|
|
36
|
+
case "f":
|
|
37
|
+
out += "\x0C";
|
|
38
|
+
i += 2;
|
|
39
|
+
continue;
|
|
40
|
+
case "v":
|
|
41
|
+
out += "\x0B";
|
|
42
|
+
i += 2;
|
|
43
|
+
continue;
|
|
44
|
+
default:
|
|
45
|
+
out += fmt[i];
|
|
46
|
+
i++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (fmt[i] === "%" && i + 1 < fmt.length) {
|
|
51
|
+
// Optional width/precision: %[-][width][.prec]spec
|
|
52
|
+
let j = i + 1;
|
|
53
|
+
if (fmt[j] === "-")
|
|
54
|
+
j++;
|
|
55
|
+
while (j < fmt.length && /\d/.test(fmt[j]))
|
|
56
|
+
j++;
|
|
57
|
+
if (fmt[j] === ".") {
|
|
58
|
+
j++;
|
|
59
|
+
while (j < fmt.length && /\d/.test(fmt[j]))
|
|
60
|
+
j++;
|
|
61
|
+
}
|
|
62
|
+
const spec = fmt[j];
|
|
63
|
+
const arg = args[argIdx++] ?? "";
|
|
64
|
+
switch (spec) {
|
|
65
|
+
case "s":
|
|
66
|
+
out += arg;
|
|
67
|
+
break;
|
|
68
|
+
case "d":
|
|
69
|
+
case "i":
|
|
70
|
+
out += String(parseInt(arg, 10) || 0);
|
|
71
|
+
break;
|
|
72
|
+
case "f":
|
|
73
|
+
out += String(parseFloat(arg) || 0);
|
|
74
|
+
break;
|
|
75
|
+
case "o":
|
|
76
|
+
out += (parseInt(arg, 10) || 0).toString(8);
|
|
77
|
+
break;
|
|
78
|
+
case "x":
|
|
79
|
+
out += (parseInt(arg, 10) || 0).toString(16);
|
|
80
|
+
break;
|
|
81
|
+
case "X":
|
|
82
|
+
out += (parseInt(arg, 10) || 0).toString(16).toUpperCase();
|
|
83
|
+
break;
|
|
84
|
+
case "%":
|
|
85
|
+
out += "%";
|
|
86
|
+
argIdx--;
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
out += fmt[i];
|
|
90
|
+
i++;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
i = j + 1;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
out += fmt[i];
|
|
97
|
+
i++;
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
export const printfCommand = {
|
|
102
|
+
name: "printf",
|
|
103
|
+
description: "Format and print data",
|
|
104
|
+
category: "shell",
|
|
105
|
+
params: ["<format> [args...]"],
|
|
106
|
+
run: ({ args }) => {
|
|
107
|
+
const fmt = args[0];
|
|
108
|
+
if (!fmt)
|
|
109
|
+
return { stderr: "printf: missing format string", exitCode: 1 };
|
|
110
|
+
const output = renderPrintf(fmt, args.slice(1));
|
|
111
|
+
return { stdout: output, exitCode: 0 };
|
|
112
|
+
},
|
|
113
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ps.d.ts","sourceRoot":"","sources":["../../src/commands/ps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ps.d.ts","sourceRoot":"","sources":["../../src/commands/ps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,eAAO,MAAM,SAAS,EAAE,WAiDvB,CAAC"}
|
package/dist/commands/ps.js
CHANGED
|
@@ -1,17 +1,41 @@
|
|
|
1
|
+
import { ifFlag } from "./command-helpers";
|
|
1
2
|
export const psCommand = {
|
|
2
3
|
name: "ps",
|
|
3
4
|
description: "Report process status",
|
|
4
5
|
category: "system",
|
|
5
|
-
params: ["[-a] [-u] [-x]"],
|
|
6
|
-
run: ({ authUser, shell }) => {
|
|
6
|
+
params: ["[-a] [-u] [-x] [aux]"],
|
|
7
|
+
run: ({ authUser, shell, args }) => {
|
|
7
8
|
const sessions = shell.users.listActiveSessions();
|
|
8
|
-
const
|
|
9
|
+
const showUser = ifFlag(args, ["-u"]) ||
|
|
10
|
+
args.includes("u") ||
|
|
11
|
+
args.includes("aux") ||
|
|
12
|
+
args.includes("au");
|
|
13
|
+
const showAll = ifFlag(args, ["-a", "-x"]) || args.includes("a") || args.includes("aux");
|
|
14
|
+
if (showUser) {
|
|
15
|
+
const header = "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND";
|
|
16
|
+
const rows = [header];
|
|
17
|
+
let pid = 1000;
|
|
18
|
+
for (const s of sessions) {
|
|
19
|
+
const user = s.username.padEnd(10).slice(0, 10);
|
|
20
|
+
const mem = (Math.random() * 0.5).toFixed(1);
|
|
21
|
+
const vsz = Math.floor(Math.random() * 20000 + 5000);
|
|
22
|
+
const rss = Math.floor(Math.random() * 5000 + 1000);
|
|
23
|
+
rows.push(`${user} ${String(pid).padStart(6)} 0.0 ${mem.padStart(4)} ${String(vsz).padStart(6)} ${String(rss).padStart(5)} ${s.tty.padEnd(8)} Ss 00:00 0:00 bash`);
|
|
24
|
+
pid++;
|
|
25
|
+
}
|
|
26
|
+
rows.push(`root ${String(pid).padStart(6)} 0.0 0.0 0 0 ? S 00:00 0:00 ps`);
|
|
27
|
+
return { stdout: rows.join("\n"), exitCode: 0 };
|
|
28
|
+
}
|
|
29
|
+
const header = " PID TTY TIME CMD";
|
|
30
|
+
const rows = [header];
|
|
9
31
|
let pid = 1000;
|
|
10
32
|
for (const s of sessions) {
|
|
11
|
-
|
|
33
|
+
if (!showAll && s.username !== authUser)
|
|
34
|
+
continue;
|
|
35
|
+
rows.push(`${String(pid).padStart(5)} ${s.tty.padEnd(12)} 00:00:00 ${s.username === authUser ? "bash" : `bash (${s.username})`}`);
|
|
12
36
|
pid++;
|
|
13
37
|
}
|
|
14
|
-
|
|
15
|
-
return { stdout:
|
|
38
|
+
rows.push(`${String(pid).padStart(5)} pts/0 00:00:00 ps`);
|
|
39
|
+
return { stdout: rows.join("\n"), exitCode: 0 };
|
|
16
40
|
},
|
|
17
41
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: intentional side-effect forEach */
|
|
2
|
+
/**
|
|
3
|
+
* python.ts — Virtual Python 3 interpreter.
|
|
4
|
+
*
|
|
5
|
+
* Implements a genuine mini-interpreter capable of:
|
|
6
|
+
* - print(), len(), type(), range(), list(), str(), int(), float(), bool()
|
|
7
|
+
* - max(), min(), abs(), sum(), sorted(), reversed(), enumerate(), zip()
|
|
8
|
+
* - str methods: upper(), lower(), strip(), split(), join(), replace(),
|
|
9
|
+
* startswith(), endswith(), format(), count(), find()
|
|
10
|
+
* - list methods: append(), extend(), pop(), sort(), reverse(), index()
|
|
11
|
+
* - dict: keys(), values(), items(), get()
|
|
12
|
+
* - import os, sys, math, json, re (stubs)
|
|
13
|
+
* - f-strings, multi-line scripts, assignments, for/while loops, if/elif/else
|
|
14
|
+
* - functions (def), return, class basics
|
|
15
|
+
*/
|
|
16
|
+
import type { ShellModule } from "../types/commands";
|
|
17
|
+
declare global {
|
|
18
|
+
interface Map<K, V> {
|
|
19
|
+
also?: ((fn: (m: Map<K, V>) => void) => Map<K, V>) | undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Virtual Python 3 interpreter command. Implements a small Python subset
|
|
24
|
+
* for scripts and `-c` invocations. Requires `apt install python3` in the
|
|
25
|
+
* virtual package manager to be available.
|
|
26
|
+
* @category system
|
|
27
|
+
* @params ["[--version] [-c <code>] [-V] [file]"]
|
|
28
|
+
*/
|
|
29
|
+
export declare const python3Command: ShellModule;
|
|
30
|
+
//# sourceMappingURL=python.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/commands/python.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAqlErD,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;KAC/D;CACD;AAID;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,WAiE5B,CAAC"}
|