typescript-virtual-container 1.3.4 → 1.4.1
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 +674 -1504
- package/benchmark-results.txt +21 -21
- package/builds/self-standalone.js +282 -332
- package/builds/self-standalone.js.map +4 -4
- package/builds/standalone-wo-sftp.js +218 -282
- package/builds/standalone-wo-sftp.js.map +4 -4
- package/builds/standalone.js +271 -335
- package/builds/standalone.js.map +4 -4
- package/builds/web-full-api.min.js +3 -3
- package/builds/web-full-api.min.js.map +4 -4
- package/builds/web.min.js +2 -2
- package/builds/web.min.js.map +4 -4
- package/bun.lock +14 -12
- package/dist/SSHClient/index.d.ts.map +1 -1
- package/dist/SSHClient/index.js +5 -3
- package/dist/SSHMimic/executor.d.ts +1 -3
- package/dist/SSHMimic/executor.d.ts.map +1 -1
- package/dist/SSHMimic/executor.js +20 -22
- package/dist/SSHMimic/index.d.ts.map +1 -1
- package/dist/SSHMimic/index.js +5 -3
- package/dist/SSHMimic/sftp.d.ts.map +1 -1
- package/dist/SSHMimic/sftp.js +26 -21
- 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 +25 -3
- package/dist/VirtualShell/shellParser.d.ts +1 -8
- package/dist/VirtualShell/shellParser.d.ts.map +1 -1
- package/dist/VirtualShell/shellParser.js +2 -81
- package/dist/VirtualUserManager/index.d.ts +7 -1
- package/dist/VirtualUserManager/index.d.ts.map +1 -1
- package/dist/VirtualUserManager/index.js +47 -16
- package/dist/commands/adduser.d.ts +10 -4
- package/dist/commands/adduser.d.ts.map +1 -1
- package/dist/commands/adduser.js +75 -12
- package/dist/commands/alias.d.ts +5 -0
- package/dist/commands/alias.d.ts.map +1 -1
- package/dist/commands/alias.js +5 -0
- package/dist/commands/apt.d.ts +5 -0
- package/dist/commands/apt.d.ts.map +1 -1
- package/dist/commands/apt.js +5 -0
- package/dist/commands/awk.d.ts +10 -8
- package/dist/commands/awk.d.ts.map +1 -1
- package/dist/commands/awk.js +156 -28
- package/dist/commands/cd.d.ts.map +1 -1
- package/dist/commands/cd.js +0 -3
- package/dist/commands/clear.d.ts +5 -0
- package/dist/commands/clear.d.ts.map +1 -1
- package/dist/commands/clear.js +5 -0
- package/dist/commands/command-helpers.d.ts.map +1 -1
- package/dist/commands/command-helpers.js +8 -0
- package/dist/commands/curl.d.ts.map +1 -1
- package/dist/commands/curl.js +2 -1
- package/dist/commands/declare.d.ts +5 -0
- package/dist/commands/declare.d.ts.map +1 -1
- package/dist/commands/declare.js +5 -0
- package/dist/commands/deluser.d.ts +12 -0
- package/dist/commands/deluser.d.ts.map +1 -1
- package/dist/commands/deluser.js +72 -6
- package/dist/commands/df.d.ts +5 -0
- package/dist/commands/df.d.ts.map +1 -1
- package/dist/commands/df.js +5 -0
- package/dist/commands/du.d.ts +5 -0
- package/dist/commands/du.d.ts.map +1 -1
- package/dist/commands/du.js +5 -0
- package/dist/commands/export.d.ts +5 -0
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +5 -0
- package/dist/commands/grep.d.ts.map +1 -1
- package/dist/commands/grep.js +22 -4
- package/dist/commands/groups.d.ts +5 -0
- package/dist/commands/groups.d.ts.map +1 -1
- package/dist/commands/groups.js +5 -0
- package/dist/commands/gzip.d.ts +5 -2
- package/dist/commands/gzip.d.ts.map +1 -1
- package/dist/commands/gzip.js +54 -28
- package/dist/commands/head.d.ts.map +1 -1
- package/dist/commands/head.js +12 -3
- package/dist/commands/htop.d.ts +5 -0
- package/dist/commands/htop.d.ts.map +1 -1
- package/dist/commands/htop.js +5 -0
- package/dist/commands/kill.d.ts +5 -0
- package/dist/commands/kill.d.ts.map +1 -1
- package/dist/commands/kill.js +5 -0
- package/dist/commands/ln.d.ts +2 -0
- package/dist/commands/ln.d.ts.map +1 -1
- package/dist/commands/ln.js +22 -0
- package/dist/commands/ls.d.ts.map +1 -1
- package/dist/commands/ls.js +15 -0
- package/dist/commands/lsb-release.d.ts +5 -0
- package/dist/commands/lsb-release.d.ts.map +1 -1
- package/dist/commands/lsb-release.js +5 -0
- package/dist/commands/man.d.ts.map +1 -1
- package/dist/commands/man.js +30 -136
- package/dist/commands/mkdir.d.ts +5 -0
- package/dist/commands/mkdir.d.ts.map +1 -1
- package/dist/commands/mkdir.js +5 -0
- package/dist/commands/mv.d.ts +5 -0
- package/dist/commands/mv.d.ts.map +1 -1
- package/dist/commands/mv.js +5 -0
- package/dist/commands/nano.d.ts +5 -0
- package/dist/commands/nano.d.ts.map +1 -1
- package/dist/commands/nano.js +5 -0
- package/dist/commands/neofetch.d.ts +5 -0
- package/dist/commands/neofetch.d.ts.map +1 -1
- package/dist/commands/neofetch.js +14 -5
- package/dist/commands/passwd.d.ts +8 -0
- package/dist/commands/passwd.d.ts.map +1 -1
- package/dist/commands/passwd.js +32 -11
- package/dist/commands/ping.d.ts +5 -0
- package/dist/commands/ping.d.ts.map +1 -1
- package/dist/commands/ping.js +5 -0
- package/dist/commands/printf.d.ts +5 -0
- package/dist/commands/printf.d.ts.map +1 -1
- package/dist/commands/printf.js +43 -12
- package/dist/commands/ps.d.ts +5 -0
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +5 -0
- package/dist/commands/read.d.ts +5 -0
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +5 -0
- package/dist/commands/registry.d.ts.map +1 -1
- package/dist/commands/registry.js +4 -1
- package/dist/commands/rm.d.ts +5 -0
- package/dist/commands/rm.d.ts.map +1 -1
- package/dist/commands/rm.js +5 -0
- package/dist/commands/runtime.d.ts.map +1 -1
- package/dist/commands/runtime.js +1 -57
- package/dist/commands/sed.d.ts +5 -0
- package/dist/commands/sed.d.ts.map +1 -1
- package/dist/commands/sed.js +5 -0
- package/dist/commands/set.d.ts +5 -6
- package/dist/commands/set.d.ts.map +1 -1
- package/dist/commands/set.js +5 -22
- package/dist/commands/sh.d.ts +6 -0
- package/dist/commands/sh.d.ts.map +1 -1
- package/dist/commands/sh.js +6 -0
- package/dist/commands/shift.d.ts +10 -0
- package/dist/commands/shift.d.ts.map +1 -1
- package/dist/commands/shift.js +10 -0
- package/dist/commands/sleep.d.ts +5 -0
- package/dist/commands/sleep.d.ts.map +1 -1
- package/dist/commands/sleep.js +5 -0
- package/dist/commands/sort.d.ts +5 -0
- package/dist/commands/sort.d.ts.map +1 -1
- package/dist/commands/sort.js +5 -0
- package/dist/commands/source.d.ts +5 -0
- package/dist/commands/source.d.ts.map +1 -1
- package/dist/commands/source.js +5 -0
- package/dist/commands/stat.d.ts +7 -0
- package/dist/commands/stat.d.ts.map +1 -0
- package/dist/commands/stat.js +56 -0
- package/dist/commands/su.d.ts +13 -0
- package/dist/commands/su.d.ts.map +1 -1
- package/dist/commands/su.js +45 -14
- package/dist/commands/sudo.d.ts.map +1 -1
- package/dist/commands/sudo.js +5 -0
- package/dist/commands/tail.d.ts +5 -0
- package/dist/commands/tail.d.ts.map +1 -1
- package/dist/commands/tail.js +15 -3
- package/dist/commands/tar.d.ts +5 -0
- package/dist/commands/tar.d.ts.map +1 -1
- package/dist/commands/tar.js +40 -10
- package/dist/commands/tee.d.ts +5 -0
- package/dist/commands/tee.d.ts.map +1 -1
- package/dist/commands/tee.js +5 -0
- package/dist/commands/touch.d.ts +5 -0
- package/dist/commands/touch.d.ts.map +1 -1
- package/dist/commands/touch.js +5 -0
- package/dist/commands/tr.d.ts.map +1 -1
- package/dist/commands/tr.js +45 -10
- package/dist/commands/tree.d.ts +5 -0
- package/dist/commands/tree.d.ts.map +1 -1
- package/dist/commands/tree.js +5 -0
- package/dist/commands/true.d.ts +10 -0
- package/dist/commands/true.d.ts.map +1 -1
- package/dist/commands/true.js +10 -0
- package/dist/commands/type.d.ts +5 -0
- package/dist/commands/type.d.ts.map +1 -1
- package/dist/commands/type.js +5 -0
- package/dist/commands/uname.d.ts +5 -0
- package/dist/commands/uname.d.ts.map +1 -1
- package/dist/commands/uname.js +5 -0
- package/dist/commands/uniq.d.ts +5 -0
- package/dist/commands/uniq.d.ts.map +1 -1
- package/dist/commands/uniq.js +5 -0
- package/dist/commands/unset.d.ts +5 -0
- package/dist/commands/unset.d.ts.map +1 -1
- package/dist/commands/unset.js +5 -0
- package/dist/commands/uptime.d.ts +5 -0
- package/dist/commands/uptime.d.ts.map +1 -1
- package/dist/commands/uptime.js +5 -0
- package/dist/commands/wc.d.ts +5 -0
- package/dist/commands/wc.d.ts.map +1 -1
- package/dist/commands/wc.js +5 -0
- package/dist/commands/wget.d.ts +5 -0
- package/dist/commands/wget.d.ts.map +1 -1
- package/dist/commands/wget.js +16 -1
- package/dist/commands/who.d.ts +5 -0
- package/dist/commands/who.d.ts.map +1 -1
- package/dist/commands/who.js +5 -0
- package/dist/commands/whoami.d.ts +5 -0
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +5 -0
- package/dist/commands/xargs.d.ts +5 -0
- package/dist/commands/xargs.d.ts.map +1 -1
- package/dist/commands/xargs.js +5 -0
- package/dist/self-standalone.js +254 -30
- package/dist/types/commands.d.ts +36 -0
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/utils/tokenize.d.ts +20 -0
- package/dist/utils/tokenize.d.ts.map +1 -0
- package/dist/utils/tokenize.js +74 -0
- package/examples/web.min.js +2 -2
- package/package.json +2 -2
- package/src/SSHClient/index.ts +6 -3
- package/src/SSHMimic/executor.ts +21 -44
- package/src/SSHMimic/index.ts +7 -5
- package/src/SSHMimic/sftp.ts +28 -21
- package/src/VirtualPackageManager/index.ts +29 -1
- package/src/VirtualShell/shell.ts +34 -4
- package/src/VirtualShell/shellParser.ts +2 -103
- package/src/VirtualUserManager/index.ts +43 -19
- package/src/commands/adduser.ts +86 -13
- package/src/commands/alias.ts +5 -0
- package/src/commands/apt.ts +5 -0
- package/src/commands/awk.ts +154 -29
- package/src/commands/cd.ts +0 -4
- package/src/commands/clear.ts +5 -0
- package/src/commands/command-helpers.ts +9 -0
- package/src/commands/curl.ts +2 -1
- package/src/commands/declare.ts +5 -0
- package/src/commands/deluser.ts +84 -7
- package/src/commands/df.ts +5 -0
- package/src/commands/du.ts +5 -0
- package/src/commands/export.ts +5 -0
- package/src/commands/grep.ts +21 -8
- package/src/commands/groups.ts +5 -0
- package/src/commands/gzip.ts +61 -28
- package/src/commands/head.ts +14 -4
- package/src/commands/htop.ts +5 -0
- package/src/commands/kill.ts +5 -0
- package/src/commands/ln.ts +22 -0
- package/src/commands/ls.ts +17 -0
- package/src/commands/lsb-release.ts +5 -0
- 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/mkdir.ts +5 -0
- package/src/commands/mv.ts +5 -0
- package/src/commands/nano.ts +5 -0
- package/src/commands/neofetch.ts +15 -6
- package/src/commands/passwd.ts +35 -12
- package/src/commands/ping.ts +5 -0
- package/src/commands/printf.ts +30 -13
- package/src/commands/ps.ts +5 -0
- package/src/commands/read.ts +5 -0
- package/src/commands/registry.ts +4 -1
- package/src/commands/rm.ts +5 -0
- package/src/commands/runtime.ts +1 -61
- package/src/commands/sed.ts +5 -0
- package/src/commands/set.ts +5 -24
- package/src/commands/sh.ts +9 -3
- package/src/commands/shift.ts +10 -0
- package/src/commands/sleep.ts +5 -0
- package/src/commands/sort.ts +5 -0
- package/src/commands/source.ts +5 -0
- package/src/commands/stat.ts +61 -0
- package/src/commands/su.ts +54 -16
- package/src/commands/sudo.ts +5 -0
- package/src/commands/tail.ts +17 -3
- package/src/commands/tar.ts +38 -15
- package/src/commands/tee.ts +5 -0
- package/src/commands/touch.ts +5 -0
- package/src/commands/tr.ts +54 -10
- package/src/commands/tree.ts +5 -0
- package/src/commands/true.ts +10 -0
- package/src/commands/type.ts +5 -0
- package/src/commands/uname.ts +5 -0
- package/src/commands/uniq.ts +5 -0
- package/src/commands/unset.ts +5 -0
- package/src/commands/uptime.ts +5 -0
- package/src/commands/wc.ts +5 -0
- package/src/commands/wget.ts +17 -1
- package/src/commands/who.ts +5 -0
- package/src/commands/whoami.ts +5 -0
- package/src/commands/xargs.ts +5 -0
- package/src/self-standalone.ts +316 -33
- package/src/types/commands.ts +37 -0
- package/src/utils/tokenize.ts +78 -0
- package/tests/new-features.test.ts +2 -2
- package/builds/web-iife.min.js +0 -13
- package/builds/web-iife.min.js.map +0 -7
package/dist/commands/adduser.js
CHANGED
|
@@ -1,26 +1,89 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Add a new user
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Add a new user interactively.
|
|
3
|
+
*
|
|
4
|
+
* Usage: `adduser <username>`
|
|
5
|
+
*
|
|
6
|
+
* Prompts for:
|
|
7
|
+
* New password: ****
|
|
8
|
+
* Retype new password: ****
|
|
9
|
+
*
|
|
10
|
+
* Mirrors the real `adduser` behaviour — password is never passed on the
|
|
11
|
+
* command line. Root-only.
|
|
6
12
|
*/
|
|
7
13
|
export const adduserCommand = {
|
|
8
14
|
name: "adduser",
|
|
9
15
|
description: "Add a new user",
|
|
10
16
|
category: "users",
|
|
11
|
-
params: ["<username>
|
|
12
|
-
run:
|
|
17
|
+
params: ["<username>"],
|
|
18
|
+
run: ({ authUser, shell, args }) => {
|
|
13
19
|
if (authUser !== "root") {
|
|
14
|
-
return { stderr: "adduser: permission denied", exitCode: 1 };
|
|
20
|
+
return { stderr: "adduser: permission denied\n", exitCode: 1 };
|
|
15
21
|
}
|
|
16
|
-
const
|
|
17
|
-
if (!username
|
|
22
|
+
const username = args[0];
|
|
23
|
+
if (!username) {
|
|
18
24
|
return {
|
|
19
|
-
stderr: "
|
|
25
|
+
stderr: "Usage: adduser <username>\n",
|
|
20
26
|
exitCode: 1,
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
// Reject if user already exists
|
|
30
|
+
if (shell.users.listUsers().includes(username)) {
|
|
31
|
+
return {
|
|
32
|
+
stderr: `adduser: user '${username}' already exists\n`,
|
|
33
|
+
exitCode: 1,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
let newPassword = "";
|
|
37
|
+
let step = "new";
|
|
38
|
+
const onPassword = async (input, sh) => {
|
|
39
|
+
if (step === "new") {
|
|
40
|
+
if (input.length < 1) {
|
|
41
|
+
return {
|
|
42
|
+
result: {
|
|
43
|
+
stderr: "adduser: password cannot be empty\n",
|
|
44
|
+
exitCode: 1,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
newPassword = input;
|
|
49
|
+
step = "retype";
|
|
50
|
+
return { result: null, nextPrompt: "Retype new password: " };
|
|
51
|
+
}
|
|
52
|
+
// step === "retype"
|
|
53
|
+
if (input !== newPassword) {
|
|
54
|
+
return {
|
|
55
|
+
result: {
|
|
56
|
+
stderr: "adduser: passwords do not match — user not created\n",
|
|
57
|
+
exitCode: 1,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
await sh.users.addUser(username, newPassword);
|
|
62
|
+
return {
|
|
63
|
+
result: {
|
|
64
|
+
stdout: `${[
|
|
65
|
+
`Adding user '${username}' ...`,
|
|
66
|
+
`Adding new group '${username}' (1001) ...`,
|
|
67
|
+
`Adding new user '${username}' (1001) with group '${username}' ...`,
|
|
68
|
+
`Creating home directory '/home/${username}' ...`,
|
|
69
|
+
`passwd: password set for '${username}'`,
|
|
70
|
+
`adduser: done.`,
|
|
71
|
+
].join("\n")}\n`,
|
|
72
|
+
exitCode: 0,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
sudoChallenge: {
|
|
78
|
+
username,
|
|
79
|
+
targetUser: username,
|
|
80
|
+
commandLine: null,
|
|
81
|
+
loginShell: false,
|
|
82
|
+
prompt: "New password: ",
|
|
83
|
+
mode: "passwd",
|
|
84
|
+
onPassword,
|
|
85
|
+
},
|
|
86
|
+
exitCode: 0,
|
|
87
|
+
};
|
|
25
88
|
},
|
|
26
89
|
};
|
package/dist/commands/alias.d.ts
CHANGED
|
@@ -5,5 +5,10 @@ import type { ShellModule } from "../types/commands";
|
|
|
5
5
|
* @params ["[name[=value] ...]"]
|
|
6
6
|
*/
|
|
7
7
|
export declare const aliasCommand: ShellModule;
|
|
8
|
+
/**
|
|
9
|
+
* Remove shell aliases.
|
|
10
|
+
* @category shell
|
|
11
|
+
* @params ["<name...>"]
|
|
12
|
+
*/
|
|
8
13
|
export declare const unaliasCommand: ShellModule;
|
|
9
14
|
//# sourceMappingURL=alias.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias.d.ts","sourceRoot":"","sources":["../../src/commands/alias.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,WAkC1B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,WAoB5B,CAAC"}
|
|
1
|
+
{"version":3,"file":"alias.d.ts","sourceRoot":"","sources":["../../src/commands/alias.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,WAkC1B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,WAoB5B,CAAC"}
|
package/dist/commands/alias.js
CHANGED
|
@@ -40,6 +40,11 @@ export const aliasCommand = {
|
|
|
40
40
|
return { stdout: lines.join("\n") || undefined, exitCode: 0 };
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Remove shell aliases.
|
|
45
|
+
* @category shell
|
|
46
|
+
* @params ["<name...>"]
|
|
47
|
+
*/
|
|
43
48
|
export const unaliasCommand = {
|
|
44
49
|
name: "unalias",
|
|
45
50
|
description: "Remove alias definitions",
|
package/dist/commands/apt.d.ts
CHANGED
|
@@ -5,5 +5,10 @@ import type { ShellModule } from "../types/commands";
|
|
|
5
5
|
* @params ["<install|remove|update|upgrade|search|show|list> [pkg...]"]
|
|
6
6
|
*/
|
|
7
7
|
export declare const aptCommand: ShellModule;
|
|
8
|
+
/**
|
|
9
|
+
* Query the package cache and retrieve package information.
|
|
10
|
+
* @category package
|
|
11
|
+
* @params ["<search|show|policy> [pkg]"]
|
|
12
|
+
*/
|
|
8
13
|
export declare const aptCacheCommand: ShellModule;
|
|
9
14
|
//# sourceMappingURL=apt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apt.d.ts","sourceRoot":"","sources":["../../src/commands/apt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,WAyJxB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,WA+D7B,CAAC"}
|
|
1
|
+
{"version":3,"file":"apt.d.ts","sourceRoot":"","sources":["../../src/commands/apt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,WAyJxB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,WA+D7B,CAAC"}
|
package/dist/commands/apt.js
CHANGED
|
@@ -139,6 +139,11 @@ export const aptCommand = {
|
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Query the package cache and retrieve package information.
|
|
144
|
+
* @category package
|
|
145
|
+
* @params ["<search|show|policy> [pkg]"]
|
|
146
|
+
*/
|
|
142
147
|
export const aptCacheCommand = {
|
|
143
148
|
name: "apt-cache",
|
|
144
149
|
description: "Query the package cache",
|
package/dist/commands/awk.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
2
|
/**
|
|
3
|
-
* Minimal
|
|
4
|
-
* @category text
|
|
5
|
-
* @params ["[-F <sep>] '<program>' [file]"]
|
|
3
|
+
* Minimal awk-like pattern scanner.
|
|
6
4
|
*
|
|
7
|
-
* Supported
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* Supported:
|
|
6
|
+
* - `NR==N` pattern (line number condition)
|
|
7
|
+
* - `NF` (number of fields)
|
|
8
|
+
* - `/regex/` pattern
|
|
9
|
+
* - `{ print $N, $M, ... }` action
|
|
10
|
+
* - `{ print }` / `{ print $0 }`
|
|
11
|
+
* - `BEGIN { ... }` and `END { ... }` blocks (no side effects)
|
|
12
|
+
* - `$NF` (last field)
|
|
13
|
+
* - `-F sep` field separator
|
|
12
14
|
*/
|
|
13
15
|
export declare const awkCommand: ShellModule;
|
|
14
16
|
//# sourceMappingURL=awk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"awk.d.ts","sourceRoot":"","sources":["../../src/commands/awk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"awk.d.ts","sourceRoot":"","sources":["../../src/commands/awk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,EAAE,WAuJxB,CAAC"}
|
package/dist/commands/awk.js
CHANGED
|
@@ -1,42 +1,170 @@
|
|
|
1
1
|
import { getFlag } from "./command-helpers";
|
|
2
|
+
import { resolvePath, assertPathAccess } from "./helpers";
|
|
2
3
|
/**
|
|
3
|
-
* Minimal
|
|
4
|
-
* @category text
|
|
5
|
-
* @params ["[-F <sep>] '<program>' [file]"]
|
|
4
|
+
* Minimal awk-like pattern scanner.
|
|
6
5
|
*
|
|
7
|
-
* Supported
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* Supported:
|
|
7
|
+
* - `NR==N` pattern (line number condition)
|
|
8
|
+
* - `NF` (number of fields)
|
|
9
|
+
* - `/regex/` pattern
|
|
10
|
+
* - `{ print $N, $M, ... }` action
|
|
11
|
+
* - `{ print }` / `{ print $0 }`
|
|
12
|
+
* - `BEGIN { ... }` and `END { ... }` blocks (no side effects)
|
|
13
|
+
* - `$NF` (last field)
|
|
14
|
+
* - `-F sep` field separator
|
|
12
15
|
*/
|
|
13
16
|
export const awkCommand = {
|
|
14
17
|
name: "awk",
|
|
15
|
-
description: "Pattern scanning and processing language
|
|
18
|
+
description: "Pattern scanning and processing language",
|
|
16
19
|
category: "text",
|
|
17
20
|
params: ["[-F <sep>] '<program>' [file]"],
|
|
18
|
-
run: ({ args, stdin }) => {
|
|
21
|
+
run: ({ authUser, args, stdin, cwd, shell }) => {
|
|
19
22
|
const sep = getFlag(args, ["-F"]) ?? " ";
|
|
20
|
-
const
|
|
23
|
+
const nonFlagArgs = args.filter((a) => !a.startsWith("-") && a !== sep);
|
|
24
|
+
const prog = nonFlagArgs[0];
|
|
25
|
+
const fileArg = nonFlagArgs[1];
|
|
21
26
|
if (!prog)
|
|
22
27
|
return { stderr: "awk: no program", exitCode: 1 };
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
let input = stdin ?? "";
|
|
29
|
+
if (fileArg) {
|
|
30
|
+
const filePath = resolvePath(cwd, fileArg);
|
|
31
|
+
try {
|
|
32
|
+
assertPathAccess(authUser, filePath, "awk");
|
|
33
|
+
input = shell.vfs.readFile(filePath);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { stderr: `awk: ${fileArg}: No such file or directory`, exitCode: 1 };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const lines = input.split("\n");
|
|
40
|
+
// Remove empty last element if input ends with \n
|
|
41
|
+
if (lines[lines.length - 1] === "")
|
|
42
|
+
lines.pop();
|
|
43
|
+
const clauses = [];
|
|
44
|
+
const progTrim = prog.trim();
|
|
45
|
+
// Handle single unbraced pattern (NR==2, /regex/)
|
|
46
|
+
if (!progTrim.startsWith("{") && !progTrim.includes("{")) {
|
|
47
|
+
clauses.push({ pattern: progTrim, action: "print $0" });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// Parse "pattern { action } pattern2 { action2 }"
|
|
51
|
+
const clauseRe = /([^{]*)\{([^}]*)\}/g;
|
|
52
|
+
let m2 = clauseRe.exec(progTrim);
|
|
53
|
+
while (m2 !== null) {
|
|
54
|
+
clauses.push({ pattern: m2[1].trim(), action: m2[2].trim() });
|
|
55
|
+
m2 = clauseRe.exec(progTrim);
|
|
56
|
+
}
|
|
57
|
+
if (clauses.length === 0) {
|
|
58
|
+
clauses.push({ pattern: "", action: progTrim.replace(/[{}]/g, "").trim() });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const out = [];
|
|
62
|
+
// BEGIN / END
|
|
63
|
+
const beginClause = clauses.find((c) => c.pattern === "BEGIN");
|
|
64
|
+
const endClause = clauses.find((c) => c.pattern === "END");
|
|
65
|
+
const mainClauses = clauses.filter((c) => c.pattern !== "BEGIN" && c.pattern !== "END");
|
|
66
|
+
function splitFields(line) {
|
|
67
|
+
if (sep === " ")
|
|
68
|
+
return line.trim().split(/\s+/).filter(Boolean);
|
|
69
|
+
return line.split(sep);
|
|
70
|
+
}
|
|
71
|
+
function evalAction(action, line, nr) {
|
|
72
|
+
const parts = splitFields(line);
|
|
73
|
+
const nf = parts.length;
|
|
74
|
+
// Expand variables
|
|
75
|
+
const resolve = (expr) => {
|
|
76
|
+
expr = expr.trim();
|
|
77
|
+
if (expr === "NR")
|
|
78
|
+
return String(nr);
|
|
79
|
+
if (expr === "NF")
|
|
80
|
+
return String(nf);
|
|
81
|
+
if (expr === "$0")
|
|
34
82
|
return line;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
83
|
+
if (expr === "$NF")
|
|
84
|
+
return parts[nf - 1] ?? "";
|
|
85
|
+
if (/^\$\d+$/.test(expr))
|
|
86
|
+
return parts[parseInt(expr.slice(1), 10) - 1] ?? "";
|
|
87
|
+
// Arithmetic NR+1, NF-1
|
|
88
|
+
const arith = expr.replace(/\bNR\b/g, String(nr)).replace(/\bNF\b/g, String(nf));
|
|
89
|
+
if (/^[\d\s+\-*/()]+$/.test(arith)) {
|
|
90
|
+
// biome-ignore lint/security/noGlobalEval: safe arithmetic — input contains only digits and operators after variable substitution
|
|
91
|
+
try {
|
|
92
|
+
return String(Function(`"use strict"; return (${arith});`)());
|
|
93
|
+
}
|
|
94
|
+
catch { }
|
|
95
|
+
}
|
|
96
|
+
return expr.replace(/"/g, "");
|
|
97
|
+
};
|
|
98
|
+
const stmts = action.split(";").map((s) => s.trim()).filter(Boolean);
|
|
99
|
+
for (const stmt of stmts) {
|
|
100
|
+
if (stmt === "print" || stmt === "print $0") {
|
|
101
|
+
out.push(line);
|
|
102
|
+
}
|
|
103
|
+
else if (stmt.startsWith("print ")) {
|
|
104
|
+
const args2 = stmt.slice(6).split(/\s*,\s*/);
|
|
105
|
+
out.push(args2.map(resolve).join("\t"));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function matchPattern(pattern, line, nr) {
|
|
110
|
+
if (!pattern)
|
|
111
|
+
return true;
|
|
112
|
+
if (pattern === "1")
|
|
113
|
+
return true;
|
|
114
|
+
// NR==N or NR>N etc.
|
|
115
|
+
const nrCond = pattern.match(/^NR\s*([=!<>]=?|==)\s*(\d+)$/);
|
|
116
|
+
if (nrCond) {
|
|
117
|
+
const op = nrCond[1];
|
|
118
|
+
const val = parseInt(nrCond[2], 10);
|
|
119
|
+
switch (op) {
|
|
120
|
+
case "==": return nr === val;
|
|
121
|
+
case "!=": return nr !== val;
|
|
122
|
+
case ">": return nr > val;
|
|
123
|
+
case ">=": return nr >= val;
|
|
124
|
+
case "<": return nr < val;
|
|
125
|
+
case "<=": return nr <= val;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// NR%N==M
|
|
129
|
+
const nrMod = pattern.match(/^NR%(\d+)==(\d+)$/);
|
|
130
|
+
if (nrMod) {
|
|
131
|
+
return nr % parseInt(nrMod[1], 10) === parseInt(nrMod[2], 10);
|
|
132
|
+
}
|
|
133
|
+
// /regex/ pattern
|
|
134
|
+
if (pattern.startsWith("/") && pattern.endsWith("/")) {
|
|
135
|
+
try {
|
|
136
|
+
return new RegExp(pattern.slice(1, -1)).test(line);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// $N~/regex/
|
|
143
|
+
const fieldMatch = pattern.match(/^\$(\d+)~\/(.*)\/$/);
|
|
144
|
+
if (fieldMatch) {
|
|
145
|
+
const parts = splitFields(line);
|
|
146
|
+
const field = parts[parseInt(fieldMatch[1], 10) - 1] ?? "";
|
|
147
|
+
try {
|
|
148
|
+
return new RegExp(fieldMatch[2]).test(field);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (beginClause)
|
|
157
|
+
evalAction(beginClause.action, "", 0);
|
|
158
|
+
for (let nr = 1; nr <= lines.length; nr++) {
|
|
159
|
+
const line = lines[nr - 1];
|
|
160
|
+
for (const clause of mainClauses) {
|
|
161
|
+
if (matchPattern(clause.pattern, line, nr)) {
|
|
162
|
+
evalAction(clause.action, line, nr);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (endClause)
|
|
167
|
+
evalAction(endClause.action, "", lines.length + 1);
|
|
168
|
+
return { stdout: out.join("\n") + (out.length > 0 ? "\n" : ""), exitCode: 0 };
|
|
41
169
|
},
|
|
42
170
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cd.d.ts","sourceRoot":"","sources":["../../src/commands/cd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"cd.d.ts","sourceRoot":"","sources":["../../src/commands/cd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,WAevB,CAAC"}
|
package/dist/commands/cd.js
CHANGED
package/dist/commands/clear.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,YAAY,EAAE,WAO1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,WAO1B,CAAC"}
|
package/dist/commands/clear.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-helpers.d.ts","sourceRoot":"","sources":["../../src/commands/command-helpers.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;
|
|
1
|
+
{"version":3,"file":"command-helpers.d.ts","sourceRoot":"","sources":["../../src/commands/command-helpers.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAwFF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAYxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CACtB,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GACtB,MAAM,GAAG,IAAI,GAAG,SAAS,CA0B3B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CACrB,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAAoB,GAC3B,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACxB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAC3D;IACF,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB,CAiDA"}
|
|
@@ -5,10 +5,18 @@ function matchFlagToken(token, flag) {
|
|
|
5
5
|
if (token === flag) {
|
|
6
6
|
return { matched: true, inlineValue: null };
|
|
7
7
|
}
|
|
8
|
+
// --flag=value style
|
|
8
9
|
const prefix = `${flag}=`;
|
|
9
10
|
if (token.startsWith(prefix)) {
|
|
10
11
|
return { matched: true, inlineValue: token.slice(prefix.length) };
|
|
11
12
|
}
|
|
13
|
+
// Short flag inline value: -f2, -d: (single char flag like -f, -d, -n)
|
|
14
|
+
// Only applies to single-char flags (-X), not long flags (--flag)
|
|
15
|
+
if (flag.length === 2 && flag.startsWith("-") && !flag.startsWith("--")) {
|
|
16
|
+
if (token.startsWith(flag) && token.length > flag.length) {
|
|
17
|
+
return { matched: true, inlineValue: token.slice(flag.length) };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
12
20
|
return { matched: false, inlineValue: null };
|
|
13
21
|
}
|
|
14
22
|
function collectPositionals(args, options = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/commands/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/commands/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAyIzB,CAAC"}
|
package/dist/commands/curl.js
CHANGED
|
@@ -81,7 +81,8 @@ export const curlCommand = {
|
|
|
81
81
|
}
|
|
82
82
|
let response;
|
|
83
83
|
try {
|
|
84
|
-
|
|
84
|
+
const urlWithHttp = url.startsWith("http://") || url.startsWith("https://") ? url : `http://${url}`;
|
|
85
|
+
response = await fetch(urlWithHttp, fetchOpts);
|
|
85
86
|
}
|
|
86
87
|
catch (err) {
|
|
87
88
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
|
+
/**
|
|
3
|
+
* Declare variables and give them attributes (integer, readonly, export, array).
|
|
4
|
+
* @category shell
|
|
5
|
+
* @params ["[-i] [-r] [-x] [-a] [name[=value]...]"]
|
|
6
|
+
*/
|
|
2
7
|
export declare const declareCommand: ShellModule;
|
|
3
8
|
//# sourceMappingURL=declare.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declare.d.ts","sourceRoot":"","sources":["../../src/commands/declare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,eAAO,MAAM,cAAc,EAAE,WAwC5B,CAAC"}
|
|
1
|
+
{"version":3,"file":"declare.d.ts","sourceRoot":"","sources":["../../src/commands/declare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,WAwC5B,CAAC"}
|
package/dist/commands/declare.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { ifFlag } from "./command-helpers";
|
|
2
|
+
/**
|
|
3
|
+
* Declare variables and give them attributes (integer, readonly, export, array).
|
|
4
|
+
* @category shell
|
|
5
|
+
* @params ["[-i] [-r] [-x] [-a] [name[=value]...]"]
|
|
6
|
+
*/
|
|
2
7
|
export const declareCommand = {
|
|
3
8
|
name: "declare",
|
|
4
9
|
aliases: ["local", "typeset"],
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import type { ShellModule } from "../types/commands";
|
|
2
|
+
/**
|
|
3
|
+
* Delete a user. Root-only.
|
|
4
|
+
*
|
|
5
|
+
* Without `-f`: prompts for confirmation — the user must type the exact
|
|
6
|
+
* username to proceed.
|
|
7
|
+
*
|
|
8
|
+
* With `-f` / `--force`: deletes without confirmation.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* deluser <username>
|
|
12
|
+
* deluser -f <username>
|
|
13
|
+
*/
|
|
2
14
|
export declare const deluserCommand: ShellModule;
|
|
3
15
|
//# sourceMappingURL=deluser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deluser.d.ts","sourceRoot":"","sources":["../../src/commands/deluser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"deluser.d.ts","sourceRoot":"","sources":["../../src/commands/deluser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGpE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,EAAE,WAkF5B,CAAC"}
|
package/dist/commands/deluser.js
CHANGED
|
@@ -1,17 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a user. Root-only.
|
|
3
|
+
*
|
|
4
|
+
* Without `-f`: prompts for confirmation — the user must type the exact
|
|
5
|
+
* username to proceed.
|
|
6
|
+
*
|
|
7
|
+
* With `-f` / `--force`: deletes without confirmation.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* deluser <username>
|
|
11
|
+
* deluser -f <username>
|
|
12
|
+
*/
|
|
1
13
|
export const deluserCommand = {
|
|
2
14
|
name: "deluser",
|
|
3
15
|
description: "Delete a user",
|
|
4
16
|
category: "users",
|
|
5
|
-
params: ["<username>"],
|
|
17
|
+
params: ["[-f] <username>"],
|
|
6
18
|
run: async ({ authUser, args, shell }) => {
|
|
7
19
|
if (authUser !== "root") {
|
|
8
|
-
return { stderr: "deluser: permission denied", exitCode: 1 };
|
|
20
|
+
return { stderr: "deluser: permission denied\n", exitCode: 1 };
|
|
9
21
|
}
|
|
10
|
-
const
|
|
22
|
+
const force = args.includes("-f") ||
|
|
23
|
+
args.includes("--force") ||
|
|
24
|
+
args.includes("-y");
|
|
25
|
+
const username = args.find((a) => !a.startsWith("-"));
|
|
11
26
|
if (!username) {
|
|
12
|
-
return {
|
|
27
|
+
return {
|
|
28
|
+
stderr: "Usage: deluser [-f] <username>\n",
|
|
29
|
+
exitCode: 1,
|
|
30
|
+
};
|
|
13
31
|
}
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
if (!shell.users.listUsers().includes(username)) {
|
|
33
|
+
return {
|
|
34
|
+
stderr: `deluser: user '${username}' does not exist\n`,
|
|
35
|
+
exitCode: 1,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (username === "root") {
|
|
39
|
+
return {
|
|
40
|
+
stderr: "deluser: cannot remove the root account\n",
|
|
41
|
+
exitCode: 1,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Force mode — delete without confirmation
|
|
45
|
+
if (force) {
|
|
46
|
+
await shell.users.deleteUser(username);
|
|
47
|
+
return {
|
|
48
|
+
stdout: `Removing user '${username}' ...\ndeluser: done.\n`,
|
|
49
|
+
exitCode: 0,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Interactive confirmation
|
|
53
|
+
const onPassword = async (input, sh) => {
|
|
54
|
+
if (input.trim() !== username) {
|
|
55
|
+
return {
|
|
56
|
+
result: {
|
|
57
|
+
stderr: "deluser: confirmation did not match — user not deleted\n",
|
|
58
|
+
exitCode: 1,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
await sh.users.deleteUser(username);
|
|
63
|
+
return {
|
|
64
|
+
result: {
|
|
65
|
+
stdout: `Removing user '${username}' ...\ndeluser: done.\n`,
|
|
66
|
+
exitCode: 0,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
sudoChallenge: {
|
|
72
|
+
username,
|
|
73
|
+
targetUser: username,
|
|
74
|
+
commandLine: null,
|
|
75
|
+
loginShell: false,
|
|
76
|
+
prompt: `Warning: deleting user '${username}'.\nType the username to confirm: `,
|
|
77
|
+
mode: "confirm",
|
|
78
|
+
onPassword,
|
|
79
|
+
},
|
|
80
|
+
exitCode: 0,
|
|
81
|
+
};
|
|
16
82
|
},
|
|
17
83
|
};
|
package/dist/commands/df.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"df.d.ts","sourceRoot":"","sources":["../../src/commands/df.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,SAAS,EAAE,WAevB,CAAC"}
|
|
1
|
+
{"version":3,"file":"df.d.ts","sourceRoot":"","sources":["../../src/commands/df.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,WAevB,CAAC"}
|
package/dist/commands/df.js
CHANGED
package/dist/commands/du.d.ts
CHANGED