@lifo-sh/core 0.5.0 → 0.5.6
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/dist/args-BhoL0JcG.js +58 -0
- package/dist/awk-DahiO6Jl.js +170 -0
- package/dist/base64-Dj_AnQAH.js +92 -0
- package/dist/basename-D8sjWfzX.js +14 -0
- package/dist/bc-CCuJi0IY.js +230 -0
- package/dist/browser-B0dadKCA.js +43 -0
- package/dist/cal-DQsLvArw.js +85 -0
- package/dist/cat-KYGveROo.js +32 -0
- package/dist/chmod-gYZdg3Kv.js +81 -0
- package/dist/chown-DoPi7NLO.js +32 -0
- package/dist/commands/net/curl.d.ts +2 -2
- package/dist/commands/net/curl.d.ts.map +1 -1
- package/dist/commands/net/forward.d.ts +14 -0
- package/dist/commands/net/forward.d.ts.map +1 -0
- package/dist/commands/net/host.d.ts +14 -0
- package/dist/commands/net/host.d.ts.map +1 -0
- package/dist/commands/net/ifconfig.d.ts +8 -0
- package/dist/commands/net/ifconfig.d.ts.map +1 -0
- package/dist/commands/net/ip.d.ts +14 -0
- package/dist/commands/net/ip.d.ts.map +1 -0
- package/dist/commands/net/netstat.d.ts +8 -0
- package/dist/commands/net/netstat.d.ts.map +1 -0
- package/dist/commands/net/ports.d.ts +8 -0
- package/dist/commands/net/ports.d.ts.map +1 -0
- package/dist/commands/net/route.d.ts +8 -0
- package/dist/commands/net/route.d.ts.map +1 -0
- package/dist/commands/net/test-registry.d.ts +8 -0
- package/dist/commands/net/test-registry.d.ts.map +1 -0
- package/dist/commands/net/tunnel-v2.d.ts +4 -0
- package/dist/commands/net/tunnel-v2.d.ts.map +1 -0
- package/dist/commands/net/tunnel.d.ts +6 -0
- package/dist/commands/net/tunnel.d.ts.map +1 -0
- package/dist/commands/registry.d.ts +1 -0
- package/dist/commands/registry.d.ts.map +1 -1
- package/dist/commands/system/kill.d.ts +2 -2
- package/dist/commands/system/kill.d.ts.map +1 -1
- package/dist/commands/system/lifo.d.ts +19 -2
- package/dist/commands/system/lifo.d.ts.map +1 -1
- package/dist/commands/system/newtab.d.ts +8 -0
- package/dist/commands/system/newtab.d.ts.map +1 -0
- package/dist/commands/system/node.d.ts +3 -2
- package/dist/commands/system/node.d.ts.map +1 -1
- package/dist/commands/system/npm.d.ts +20 -7
- package/dist/commands/system/npm.d.ts.map +1 -1
- package/dist/commands/system/ps.d.ts +3 -2
- package/dist/commands/system/ps.d.ts.map +1 -1
- package/dist/commands/system/systemctl.d.ts +4 -0
- package/dist/commands/system/systemctl.d.ts.map +1 -0
- package/dist/commands/system/top.d.ts +2 -2
- package/dist/commands/system/top.d.ts.map +1 -1
- package/dist/commands/system/watch.d.ts.map +1 -1
- package/dist/commands/system/whoami.d.ts.map +1 -1
- package/dist/commands/types.d.ts +3 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/cp-BP7-nkZi.js +29 -0
- package/dist/cut-Dg3Sxlw_.js +84 -0
- package/dist/date-DqL4oCg8.js +91 -0
- package/dist/df-CEHqyq91.js +47 -0
- package/dist/diff-aYLFp43G.js +250 -0
- package/dist/dig-0_V5UoWW.js +91 -0
- package/dist/dirname-ByojkmnI.js +14 -0
- package/dist/du-feoEC53Q.js +89 -0
- package/dist/env-CIcDulqw.js +10 -0
- package/dist/fastfetch-CRfsfb4t.js +378 -0
- package/dist/file-BHHCgjt9.js +79 -0
- package/dist/find-C-pGJyTZ.js +63 -0
- package/dist/free-DCkGta9v.js +33 -0
- package/dist/grep-Bv7fu1qw.js +179 -0
- package/dist/gunzip-BZk2000a.js +57 -0
- package/dist/gzip-D55LwDu8.js +70 -0
- package/dist/head-CQQ8pAha.js +66 -0
- package/dist/hostname-Ba0tnCzG.js +8 -0
- package/dist/index-GLjTMF7C.js +22717 -0
- package/dist/index.d.ts +44 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +99 -72
- package/dist/less-C-8XcQ_A.js +294 -0
- package/dist/ln-CpXREm6e.js +15 -0
- package/dist/ls-Ce1mcASB.js +132 -0
- package/dist/{man-Dg26tZ-a.js → man-DjxHeM01.js} +46 -27
- package/dist/mime-B5knsVEw.js +101 -0
- package/dist/mkdir-CtDdaiaM.js +31 -0
- package/dist/mktemp-DwAY8Lz2.js +44 -0
- package/dist/mv-vS020rcy.js +29 -0
- package/dist/nano-DKfqXthq.js +445 -0
- package/dist/nl-DHh-MmKX.js +66 -0
- package/dist/ping-BQO3Z9CT.js +72 -0
- package/dist/pkg/PackageManager.d.ts +2 -2
- package/dist/pkg/PackageManager.d.ts.map +1 -1
- package/dist/pkg/lifo-dev.d.ts +6 -6
- package/dist/pkg/lifo-dev.d.ts.map +1 -1
- package/dist/pkg/lifo-runtime.d.ts +3 -3
- package/dist/pkg/lifo-runtime.d.ts.map +1 -1
- package/dist/pkg/loader.d.ts +2 -2
- package/dist/pkg/loader.d.ts.map +1 -1
- package/dist/printf-CdBVx2dT.js +81 -0
- package/dist/realpath-CZ_ja3FL.js +27 -0
- package/dist/rev-KZ9O5vNS.js +42 -0
- package/dist/rm-dW7YB25j.js +48 -0
- package/dist/rmdir-Db2wctQ6.js +42 -0
- package/dist/runtime/ContextSerialization.d.ts +7 -0
- package/dist/runtime/ContextSerialization.d.ts.map +1 -0
- package/dist/runtime/ProcessExecutor.d.ts +14 -0
- package/dist/runtime/ProcessExecutor.d.ts.map +1 -0
- package/dist/runtime/command-worker.d.ts +9 -0
- package/dist/runtime/command-worker.d.ts.map +1 -0
- package/dist/sandbox/Sandbox.d.ts +1 -2
- package/dist/sandbox/Sandbox.d.ts.map +1 -1
- package/dist/sandbox/SandboxFs.d.ts +2 -2
- package/dist/sandbox/SandboxFs.d.ts.map +1 -1
- package/dist/sandbox/types.d.ts +1 -2
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sed-BK_pjM2M.js +142 -0
- package/dist/seq-B0yurkx9.js +64 -0
- package/dist/sha256sum-BP0l9D35.js +85 -0
- package/dist/shell/ProcessRegistry.d.ts +152 -0
- package/dist/shell/ProcessRegistry.d.ts.map +1 -0
- package/dist/shell/ProcessRegistry.example.d.ts +8 -0
- package/dist/shell/ProcessRegistry.example.d.ts.map +1 -0
- package/dist/shell/ProcessRegistry.test.d.ts +2 -0
- package/dist/shell/ProcessRegistry.test.d.ts.map +1 -0
- package/dist/shell/Shell.d.ts +13 -4
- package/dist/shell/Shell.d.ts.map +1 -1
- package/dist/shell/completer.d.ts +2 -2
- package/dist/shell/completer.d.ts.map +1 -1
- package/dist/shell/expander.d.ts +2 -2
- package/dist/shell/expander.d.ts.map +1 -1
- package/dist/shell/history.d.ts +2 -2
- package/dist/shell/history.d.ts.map +1 -1
- package/dist/shell/interpreter.d.ts +8 -2
- package/dist/shell/interpreter.d.ts.map +1 -1
- package/dist/shell/test-builtin.d.ts +2 -2
- package/dist/shell/test-builtin.d.ts.map +1 -1
- package/dist/sl-BmMNz7ir.js +200 -0
- package/dist/sleep-C_3mjcFi.js +25 -0
- package/dist/sort-DYZuiMaO.js +87 -0
- package/dist/stat-CXSSmsrA.js +38 -0
- package/dist/strings-BwqQy-zL.js +63 -0
- package/dist/tac-CuZSbu_c.js +32 -0
- package/dist/tail-DH7xR0rW.js +62 -0
- package/dist/tar-AnR03GXP.js +155 -0
- package/dist/tee-ByHsMExU.js +29 -0
- package/dist/touch-CcmnMpg5.js +26 -0
- package/dist/tr-D_cg13q8.js +92 -0
- package/dist/tree-Ck1ymlSv.js +64 -0
- package/dist/uname-07bQ7DTD.js +50 -0
- package/dist/uniq-BHkwpex3.js +76 -0
- package/dist/unzip-DVjk3GA4.js +91 -0
- package/dist/uptime-ujk4Nb77.js +17 -0
- package/dist/utils/archive.d.ts +2 -2
- package/dist/utils/archive.d.ts.map +1 -1
- package/dist/utils/glob.d.ts +2 -2
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/wc-CK9Flybx.js +98 -0
- package/dist/wget-Cww1uNE2.js +84 -0
- package/dist/{which-D3u0cwyh.js → which-CJwCjtVK.js} +25 -14
- package/dist/whoami-EHyrQ1q-.js +25 -0
- package/dist/xargs-I1ZWqhOp.js +40 -0
- package/dist/yes-XolnW6bp.js +11 -0
- package/dist/zip-BTmRwUYQ.js +40 -0
- package/package.json +16 -10
- package/dist/args-CG6b9cZt.js +0 -43
- package/dist/awk-CC_Qo0hQ.js +0 -123
- package/dist/base64-BBckAmkE.js +0 -72
- package/dist/basename-BIICW06y.js +0 -12
- package/dist/bc-BYiKVTNg.js +0 -200
- package/dist/cal-DPULSAhj.js +0 -56
- package/dist/cat-Jv35D4BV.js +0 -29
- package/dist/chmod-Bh-u8XOr.js +0 -56
- package/dist/chown-Dv7xfl2a.js +0 -28
- package/dist/cp-CB-sGTRH.js +0 -19
- package/dist/cut-B79kgCm4.js +0 -65
- package/dist/date-C8NB8v8G.js +0 -86
- package/dist/df-CeZb4WOr.js +0 -34
- package/dist/diff-D5Ej-JEe.js +0 -150
- package/dist/dig-BEJ8Ky96.js +0 -69
- package/dist/dirname-w2Y6csox.js +0 -13
- package/dist/du-UupzdKc_.js +0 -77
- package/dist/env-DXzvDKsN.js +0 -9
- package/dist/fastfetch-aPM9Z3ym.js +0 -310
- package/dist/file-DOl4Wjtc.js +0 -70
- package/dist/find-C0T-P7sl.js +0 -36
- package/dist/free-DAxE4b2U.js +0 -23
- package/dist/grep-Blwrv9k5.js +0 -147
- package/dist/gunzip-R7EtgP15.js +0 -47
- package/dist/gzip-BxF7M1np.js +0 -57
- package/dist/head-CJwcsX18.js +0 -53
- package/dist/hostname-BxU2S3nT.js +0 -8
- package/dist/index-BjKSFBDg.js +0 -8640
- package/dist/kernel/index.d.ts +0 -26
- package/dist/kernel/index.d.ts.map +0 -1
- package/dist/kernel/persistence/PersistenceManager.d.ts +0 -12
- package/dist/kernel/persistence/PersistenceManager.d.ts.map +0 -1
- package/dist/kernel/persistence/backends.d.ts +0 -22
- package/dist/kernel/persistence/backends.d.ts.map +0 -1
- package/dist/kernel/persistence/index.d.ts +0 -6
- package/dist/kernel/persistence/index.d.ts.map +0 -1
- package/dist/kernel/persistence/serializer.d.ts +0 -21
- package/dist/kernel/persistence/serializer.d.ts.map +0 -1
- package/dist/kernel/samples.d.ts +0 -3
- package/dist/kernel/samples.d.ts.map +0 -1
- package/dist/kernel/storage/BlobStore.d.ts +0 -31
- package/dist/kernel/storage/BlobStore.d.ts.map +0 -1
- package/dist/kernel/storage/ContentStore.d.ts +0 -52
- package/dist/kernel/storage/ContentStore.d.ts.map +0 -1
- package/dist/kernel/storage/index.d.ts +0 -7
- package/dist/kernel/storage/index.d.ts.map +0 -1
- package/dist/kernel/vfs/VFS.d.ts +0 -64
- package/dist/kernel/vfs/VFS.d.ts.map +0 -1
- package/dist/kernel/vfs/index.d.ts +0 -7
- package/dist/kernel/vfs/index.d.ts.map +0 -1
- package/dist/kernel/vfs/providers/DevProvider.d.ts +0 -11
- package/dist/kernel/vfs/providers/DevProvider.d.ts.map +0 -1
- package/dist/kernel/vfs/providers/NativeFsProvider.d.ts +0 -63
- package/dist/kernel/vfs/providers/NativeFsProvider.d.ts.map +0 -1
- package/dist/kernel/vfs/providers/ProcProvider.d.ts +0 -14
- package/dist/kernel/vfs/providers/ProcProvider.d.ts.map +0 -1
- package/dist/kernel/vfs/types.d.ts +0 -70
- package/dist/kernel/vfs/types.d.ts.map +0 -1
- package/dist/less-B0gFLJ_7.js +0 -230
- package/dist/ln-Bf3f3jVA.js +0 -11
- package/dist/ls-YnhMRefh.js +0 -106
- package/dist/mkdir-DY1P3Jxj.js +0 -27
- package/dist/mktemp-BRzo2c8y.js +0 -31
- package/dist/mv-bH08L-F_.js +0 -19
- package/dist/nano-CueO2oS0.js +0 -304
- package/dist/nl-D26SSOD4.js +0 -51
- package/dist/node-compat/buffer.d.ts +0 -44
- package/dist/node-compat/buffer.d.ts.map +0 -1
- package/dist/node-compat/child_process.d.ts +0 -10
- package/dist/node-compat/child_process.d.ts.map +0 -1
- package/dist/node-compat/console.d.ts +0 -21
- package/dist/node-compat/console.d.ts.map +0 -1
- package/dist/node-compat/crypto.d.ts +0 -17
- package/dist/node-compat/crypto.d.ts.map +0 -1
- package/dist/node-compat/events.d.ts +0 -19
- package/dist/node-compat/events.d.ts.map +0 -1
- package/dist/node-compat/fs.d.ts +0 -175
- package/dist/node-compat/fs.d.ts.map +0 -1
- package/dist/node-compat/http.d.ts +0 -87
- package/dist/node-compat/http.d.ts.map +0 -1
- package/dist/node-compat/index.d.ts +0 -19
- package/dist/node-compat/index.d.ts.map +0 -1
- package/dist/node-compat/os.d.ts +0 -39
- package/dist/node-compat/os.d.ts.map +0 -1
- package/dist/node-compat/path.d.ts +0 -58
- package/dist/node-compat/path.d.ts.map +0 -1
- package/dist/node-compat/process.d.ts +0 -62
- package/dist/node-compat/process.d.ts.map +0 -1
- package/dist/node-compat/stream.d.ts +0 -36
- package/dist/node-compat/stream.d.ts.map +0 -1
- package/dist/node-compat/string_decoder.d.ts +0 -11
- package/dist/node-compat/string_decoder.d.ts.map +0 -1
- package/dist/node-compat/timers.d.ts +0 -16
- package/dist/node-compat/timers.d.ts.map +0 -1
- package/dist/node-compat/url.d.ts +0 -53
- package/dist/node-compat/url.d.ts.map +0 -1
- package/dist/node-compat/util.d.ts +0 -27
- package/dist/node-compat/util.d.ts.map +0 -1
- package/dist/node-compat/zlib.d.ts +0 -66
- package/dist/node-compat/zlib.d.ts.map +0 -1
- package/dist/ping-DtVEwwda.js +0 -50
- package/dist/printf-Cc2o7KZx.js +0 -70
- package/dist/realpath-BH29Lem_.js +0 -24
- package/dist/rev-ySwmRf_K.js +0 -39
- package/dist/rm-D7iWUUE2.js +0 -37
- package/dist/rmdir-BLtdNjt1.js +0 -35
- package/dist/sed-DwBPYYFb.js +0 -95
- package/dist/seq-B01YKIbO.js +0 -37
- package/dist/sha256sum-DED6ePiU.js +0 -64
- package/dist/sl-Dv4iPBN6.js +0 -138
- package/dist/sleep-B4C3fZiR.js +0 -19
- package/dist/sort-OXqZY83v.js +0 -64
- package/dist/stat-BvwNpE5B.js +0 -29
- package/dist/strings-BesRwUt_.js +0 -42
- package/dist/tac-D4BMSdj9.js +0 -31
- package/dist/tail-xVmLkzJK.js +0 -52
- package/dist/tar-BHRJ0-4j.js +0 -120
- package/dist/tee-DxygINEJ.js +0 -17
- package/dist/touch-DCb9Qn5q.js +0 -23
- package/dist/tr-DsCiwSIu.js +0 -60
- package/dist/tree-4QpgsnA0.js +0 -46
- package/dist/uname-BCn8HlJD.js +0 -37
- package/dist/uniq-xmgE0zRj.js +0 -54
- package/dist/unzip-CDKcoB0B.js +0 -81
- package/dist/uptime-CgBJegqU.js +0 -8
- package/dist/wc-B-jNRfLa.js +0 -69
- package/dist/wget-CO-45JoL.js +0 -53
- package/dist/whoami-Y18wqme3.js +0 -25
- package/dist/xargs-DfbCRFFd.js +0 -35
- package/dist/yes-DXEyHHD2.js +0 -10
- package/dist/zip-Cu1DzbAu.js +0 -33
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
|
|
2
|
+
import { i as isBinaryMime, g as getMimeType } from "./mime-B5knsVEw.js";
|
|
3
|
+
const command = async (ctx) => {
|
|
4
|
+
let showCount = false;
|
|
5
|
+
let onlyDuplicates = false;
|
|
6
|
+
let onlyUnique = false;
|
|
7
|
+
const files = [];
|
|
8
|
+
for (const arg of ctx.args) {
|
|
9
|
+
if (arg.startsWith("-") && arg.length > 1) {
|
|
10
|
+
for (let j = 1; j < arg.length; j++) {
|
|
11
|
+
switch (arg[j]) {
|
|
12
|
+
case "c":
|
|
13
|
+
showCount = true;
|
|
14
|
+
break;
|
|
15
|
+
case "d":
|
|
16
|
+
onlyDuplicates = true;
|
|
17
|
+
break;
|
|
18
|
+
case "u":
|
|
19
|
+
onlyUnique = true;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
files.push(arg);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
let text = "";
|
|
28
|
+
if (files.length === 0) {
|
|
29
|
+
if (ctx.stdin) {
|
|
30
|
+
text = await ctx.stdin.readAll();
|
|
31
|
+
} else {
|
|
32
|
+
ctx.stderr.write("uniq: missing file operand\n");
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
const path = resolve(ctx.cwd, files[0]);
|
|
37
|
+
if (isBinaryMime(getMimeType(path))) {
|
|
38
|
+
ctx.stderr.write(`uniq: ${files[0]}: binary file, skipping
|
|
39
|
+
`);
|
|
40
|
+
return 1;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
text = ctx.vfs.readFileString(path);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
if (e instanceof VFSError) {
|
|
46
|
+
ctx.stderr.write(`uniq: ${files[0]}: ${e.message}
|
|
47
|
+
`);
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const lines = text.replace(/\n$/, "").split("\n");
|
|
54
|
+
const groups = [];
|
|
55
|
+
for (const line of lines) {
|
|
56
|
+
if (groups.length > 0 && groups[groups.length - 1].line === line) {
|
|
57
|
+
groups[groups.length - 1].count++;
|
|
58
|
+
} else {
|
|
59
|
+
groups.push({ line, count: 1 });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const group of groups) {
|
|
63
|
+
if (onlyDuplicates && group.count < 2) continue;
|
|
64
|
+
if (onlyUnique && group.count > 1) continue;
|
|
65
|
+
if (showCount) {
|
|
66
|
+
ctx.stdout.write(`${String(group.count).padStart(7)} ${group.line}
|
|
67
|
+
`);
|
|
68
|
+
} else {
|
|
69
|
+
ctx.stdout.write(group.line + "\n");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return 0;
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
command as default
|
|
76
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { r as resolve, k as parseZip, i as dirname, V as VFSError } from "./index-GLjTMF7C.js";
|
|
2
|
+
const command = async (ctx) => {
|
|
3
|
+
let listOnly = false;
|
|
4
|
+
let destDir = "";
|
|
5
|
+
let archiveFile = "";
|
|
6
|
+
for (let i = 0; i < ctx.args.length; i++) {
|
|
7
|
+
const arg = ctx.args[i];
|
|
8
|
+
switch (arg) {
|
|
9
|
+
case "-l":
|
|
10
|
+
case "--list":
|
|
11
|
+
listOnly = true;
|
|
12
|
+
break;
|
|
13
|
+
case "-d":
|
|
14
|
+
destDir = ctx.args[++i] || "";
|
|
15
|
+
break;
|
|
16
|
+
case "--help":
|
|
17
|
+
ctx.stdout.write("Usage: unzip [-l] [-d dir] archive.zip\n");
|
|
18
|
+
ctx.stdout.write(" -l list contents\n");
|
|
19
|
+
ctx.stdout.write(" -d dir extract to directory\n");
|
|
20
|
+
return 0;
|
|
21
|
+
default:
|
|
22
|
+
if (arg.startsWith("-")) {
|
|
23
|
+
ctx.stderr.write(`unzip: unknown option: ${arg}
|
|
24
|
+
`);
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
archiveFile = arg;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!archiveFile) {
|
|
31
|
+
ctx.stderr.write("unzip: missing archive operand\n");
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
const archivePath = resolve(ctx.cwd, archiveFile);
|
|
35
|
+
const targetDir = destDir ? resolve(ctx.cwd, destDir) : ctx.cwd;
|
|
36
|
+
try {
|
|
37
|
+
const data = ctx.vfs.readFile(archivePath);
|
|
38
|
+
const entries = parseZip(data);
|
|
39
|
+
if (listOnly) {
|
|
40
|
+
ctx.stdout.write(" Length Name\n");
|
|
41
|
+
ctx.stdout.write("--------- ----\n");
|
|
42
|
+
let totalSize = 0;
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
const size = entry.data.length;
|
|
45
|
+
totalSize += size;
|
|
46
|
+
const path = entry.isDirectory ? entry.path + "/" : entry.path;
|
|
47
|
+
ctx.stdout.write(`${String(size).padStart(9)} ${path}
|
|
48
|
+
`);
|
|
49
|
+
}
|
|
50
|
+
ctx.stdout.write("--------- ----\n");
|
|
51
|
+
ctx.stdout.write(`${String(totalSize).padStart(9)} ${entries.length} file(s)
|
|
52
|
+
`);
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
if (destDir) {
|
|
56
|
+
try {
|
|
57
|
+
ctx.vfs.mkdir(targetDir, { recursive: true });
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
const entryPath = resolve(targetDir, entry.path);
|
|
63
|
+
if (entry.isDirectory) {
|
|
64
|
+
try {
|
|
65
|
+
ctx.vfs.mkdir(entryPath, { recursive: true });
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
const parent = dirname(entryPath);
|
|
70
|
+
try {
|
|
71
|
+
ctx.vfs.mkdir(parent, { recursive: true });
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
ctx.vfs.writeFile(entryPath, entry.data);
|
|
75
|
+
}
|
|
76
|
+
ctx.stdout.write(` extracting: ${entry.path}${entry.isDirectory ? "/" : ""}
|
|
77
|
+
`);
|
|
78
|
+
}
|
|
79
|
+
} catch (e) {
|
|
80
|
+
if (e instanceof VFSError) {
|
|
81
|
+
ctx.stderr.write(`unzip: ${e.message}
|
|
82
|
+
`);
|
|
83
|
+
return 1;
|
|
84
|
+
}
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
return 0;
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
command as default
|
|
91
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const command = async (ctx) => {
|
|
2
|
+
const ms = performance.now();
|
|
3
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
4
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
5
|
+
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
6
|
+
const seconds = totalSeconds % 60;
|
|
7
|
+
const parts = [];
|
|
8
|
+
if (hours > 0) parts.push(`${hours} hour${hours !== 1 ? "s" : ""}`);
|
|
9
|
+
if (minutes > 0) parts.push(`${minutes} minute${minutes !== 1 ? "s" : ""}`);
|
|
10
|
+
parts.push(`${seconds} second${seconds !== 1 ? "s" : ""}`);
|
|
11
|
+
ctx.stdout.write(`up ${parts.join(", ")}
|
|
12
|
+
`);
|
|
13
|
+
return 0;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
command as default
|
|
17
|
+
};
|
package/dist/utils/archive.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IKernelVfs } from '@lifo-sh/kernel';
|
|
2
2
|
export declare function crc32(data: Uint8Array): number;
|
|
3
3
|
export declare function compressGzip(data: Uint8Array): Promise<Uint8Array>;
|
|
4
4
|
export declare function decompressGzip(data: Uint8Array): Promise<Uint8Array>;
|
|
@@ -18,5 +18,5 @@ export interface ZipEntry {
|
|
|
18
18
|
}
|
|
19
19
|
export declare function createZip(entries: ZipEntry[]): Uint8Array;
|
|
20
20
|
export declare function parseZip(data: Uint8Array): ZipEntry[];
|
|
21
|
-
export declare function collectFiles(vfs:
|
|
21
|
+
export declare function collectFiles(vfs: IKernelVfs, basePath: string, paths: string[]): TarEntry[];
|
|
22
22
|
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/utils/archive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/utils/archive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAelD,wBAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAM9C;AAID,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAcxE;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAc1E;AAID,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAkCD,wBAAgB,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,CA6CzD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,EAAE,CAyCrD;AAID,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB;AAsBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,CA6EzD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,EAAE,CA6CrD;AAID,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAuC3F"}
|
package/dist/utils/glob.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IKernelVfs } from '@lifo-sh/kernel';
|
|
2
2
|
/**
|
|
3
3
|
* Match a glob pattern against a text string.
|
|
4
4
|
* Supports: * ? [abc] [!abc] [a-z]
|
|
@@ -8,5 +8,5 @@ export declare function globMatch(pattern: string, text: string): boolean;
|
|
|
8
8
|
* Expand a glob pattern against the VFS.
|
|
9
9
|
* Returns sorted matching paths, or [pattern] if no matches.
|
|
10
10
|
*/
|
|
11
|
-
export declare function expandGlob(pattern: string, cwd: string, vfs:
|
|
11
|
+
export declare function expandGlob(pattern: string, cwd: string, vfs: IKernelVfs): string[];
|
|
12
12
|
//# sourceMappingURL=glob.d.ts.map
|
package/dist/utils/glob.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/utils/glob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/utils/glob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CA0DhE;AAoCD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,EAAE,CA8DlF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
|
|
2
|
+
import { i as isBinaryMime, g as getMimeType } from "./mime-B5knsVEw.js";
|
|
3
|
+
const command = async (ctx) => {
|
|
4
|
+
let showLines = false;
|
|
5
|
+
let showWords = false;
|
|
6
|
+
let showBytes = false;
|
|
7
|
+
const files = [];
|
|
8
|
+
for (const arg of ctx.args) {
|
|
9
|
+
if (arg.startsWith("-") && arg.length > 1) {
|
|
10
|
+
for (let j = 1; j < arg.length; j++) {
|
|
11
|
+
switch (arg[j]) {
|
|
12
|
+
case "l":
|
|
13
|
+
showLines = true;
|
|
14
|
+
break;
|
|
15
|
+
case "w":
|
|
16
|
+
showWords = true;
|
|
17
|
+
break;
|
|
18
|
+
case "c":
|
|
19
|
+
showBytes = true;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
files.push(arg);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!showLines && !showWords && !showBytes) {
|
|
28
|
+
showLines = showWords = showBytes = true;
|
|
29
|
+
}
|
|
30
|
+
function countText(text) {
|
|
31
|
+
const lines = text === "" ? 0 : text.split("\n").length - (text.endsWith("\n") ? 1 : 0);
|
|
32
|
+
const words = text.trim() === "" ? 0 : text.trim().split(/\s+/).length;
|
|
33
|
+
const bytes = new TextEncoder().encode(text).length;
|
|
34
|
+
return { lines, words, bytes };
|
|
35
|
+
}
|
|
36
|
+
function formatCounts(c, name) {
|
|
37
|
+
const parts = [];
|
|
38
|
+
if (showLines) parts.push(String(c.lines).padStart(8));
|
|
39
|
+
if (showWords) parts.push(String(c.words).padStart(8));
|
|
40
|
+
if (showBytes) parts.push(String(c.bytes).padStart(8));
|
|
41
|
+
if (name) parts.push(" " + name);
|
|
42
|
+
return parts.join("") + "\n";
|
|
43
|
+
}
|
|
44
|
+
if (files.length === 0) {
|
|
45
|
+
if (ctx.stdin) {
|
|
46
|
+
const text = await ctx.stdin.readAll();
|
|
47
|
+
const counts = countText(text);
|
|
48
|
+
ctx.stdout.write(formatCounts(counts));
|
|
49
|
+
} else {
|
|
50
|
+
ctx.stderr.write("wc: missing file operand\n");
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
let exitCode = 0;
|
|
56
|
+
let totalLines = 0;
|
|
57
|
+
let totalWords = 0;
|
|
58
|
+
let totalBytes = 0;
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
const path = resolve(ctx.cwd, file);
|
|
61
|
+
try {
|
|
62
|
+
ctx.vfs.stat(path);
|
|
63
|
+
if (isBinaryMime(getMimeType(path))) {
|
|
64
|
+
if (showBytes && !showLines && !showWords) {
|
|
65
|
+
const data = ctx.vfs.readFile(path);
|
|
66
|
+
const counts2 = { lines: 0, words: 0, bytes: data.byteLength };
|
|
67
|
+
totalBytes += counts2.bytes;
|
|
68
|
+
ctx.stdout.write(formatCounts(counts2, file));
|
|
69
|
+
} else {
|
|
70
|
+
ctx.stderr.write(`wc: ${file}: binary file, skipping
|
|
71
|
+
`);
|
|
72
|
+
}
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const content = ctx.vfs.readFileString(path);
|
|
76
|
+
const counts = countText(content);
|
|
77
|
+
totalLines += counts.lines;
|
|
78
|
+
totalWords += counts.words;
|
|
79
|
+
totalBytes += counts.bytes;
|
|
80
|
+
ctx.stdout.write(formatCounts(counts, file));
|
|
81
|
+
} catch (e) {
|
|
82
|
+
if (e instanceof VFSError) {
|
|
83
|
+
ctx.stderr.write(`wc: ${file}: ${e.message}
|
|
84
|
+
`);
|
|
85
|
+
exitCode = 1;
|
|
86
|
+
} else {
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (files.length > 1) {
|
|
92
|
+
ctx.stdout.write(formatCounts({ lines: totalLines, words: totalWords, bytes: totalBytes }, "total"));
|
|
93
|
+
}
|
|
94
|
+
return exitCode;
|
|
95
|
+
};
|
|
96
|
+
export {
|
|
97
|
+
command as default
|
|
98
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { r as resolve } from "./index-GLjTMF7C.js";
|
|
2
|
+
const command = async (ctx) => {
|
|
3
|
+
let outputFile;
|
|
4
|
+
let quiet = false;
|
|
5
|
+
let url;
|
|
6
|
+
const args = ctx.args;
|
|
7
|
+
for (let i = 0; i < args.length; i++) {
|
|
8
|
+
const arg = args[i];
|
|
9
|
+
switch (arg) {
|
|
10
|
+
case "-O":
|
|
11
|
+
outputFile = args[++i] ?? "";
|
|
12
|
+
break;
|
|
13
|
+
case "-q":
|
|
14
|
+
case "--quiet":
|
|
15
|
+
quiet = true;
|
|
16
|
+
break;
|
|
17
|
+
default:
|
|
18
|
+
if (!arg.startsWith("-")) {
|
|
19
|
+
url = arg;
|
|
20
|
+
}
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!url) {
|
|
25
|
+
ctx.stderr.write("wget: missing URL\n");
|
|
26
|
+
ctx.stderr.write("Usage: wget [-O file] [-q] url\n");
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
|
30
|
+
url = "https://" + url;
|
|
31
|
+
}
|
|
32
|
+
if (!outputFile) {
|
|
33
|
+
try {
|
|
34
|
+
const urlObj = new URL(url);
|
|
35
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
36
|
+
outputFile = pathSegments.length > 0 ? pathSegments[pathSegments.length - 1] : "index.html";
|
|
37
|
+
} catch {
|
|
38
|
+
outputFile = "index.html";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!quiet) {
|
|
42
|
+
ctx.stderr.write(`-- ${url}
|
|
43
|
+
`);
|
|
44
|
+
ctx.stderr.write(`Connecting... `);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(url, { signal: ctx.signal });
|
|
48
|
+
if (!quiet) {
|
|
49
|
+
ctx.stderr.write(`connected.
|
|
50
|
+
`);
|
|
51
|
+
ctx.stderr.write(`HTTP request sent, awaiting response... ${response.status} ${response.statusText}
|
|
52
|
+
`);
|
|
53
|
+
}
|
|
54
|
+
const body = await response.text();
|
|
55
|
+
const path = resolve(ctx.cwd, outputFile);
|
|
56
|
+
ctx.vfs.writeFile(path, body);
|
|
57
|
+
if (!quiet) {
|
|
58
|
+
ctx.stderr.write(`Saving to: '${outputFile}'
|
|
59
|
+
`);
|
|
60
|
+
ctx.stderr.write(`${body.length} bytes saved.
|
|
61
|
+
`);
|
|
62
|
+
}
|
|
63
|
+
return response.ok ? 0 : 1;
|
|
64
|
+
} catch (e) {
|
|
65
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
66
|
+
if (!quiet) {
|
|
67
|
+
ctx.stderr.write(`failed.
|
|
68
|
+
`);
|
|
69
|
+
}
|
|
70
|
+
if (msg.includes("Failed to fetch") || msg.includes("NetworkError") || msg.includes("CORS")) {
|
|
71
|
+
ctx.stderr.write(`wget: unable to connect to ${url}
|
|
72
|
+
`);
|
|
73
|
+
ctx.stderr.write(`Note: This may be a CORS restriction. The target server must allow cross-origin requests.
|
|
74
|
+
`);
|
|
75
|
+
} else {
|
|
76
|
+
ctx.stderr.write(`wget: ${msg}
|
|
77
|
+
`);
|
|
78
|
+
}
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
command as default
|
|
84
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const BUILTINS = /* @__PURE__ */ new Set([
|
|
2
2
|
"cd",
|
|
3
3
|
"pwd",
|
|
4
4
|
"echo",
|
|
@@ -15,7 +15,8 @@ const i = /* @__PURE__ */ new Set([
|
|
|
15
15
|
".",
|
|
16
16
|
"alias",
|
|
17
17
|
"unalias"
|
|
18
|
-
])
|
|
18
|
+
]);
|
|
19
|
+
const REGISTERED = /* @__PURE__ */ new Set([
|
|
19
20
|
"ls",
|
|
20
21
|
"cat",
|
|
21
22
|
"mkdir",
|
|
@@ -88,18 +89,28 @@ const i = /* @__PURE__ */ new Set([
|
|
|
88
89
|
"bc",
|
|
89
90
|
"man",
|
|
90
91
|
"help"
|
|
91
|
-
])
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
]);
|
|
93
|
+
const command = async (ctx) => {
|
|
94
|
+
if (ctx.args.length === 0) {
|
|
95
|
+
ctx.stderr.write("which: missing operand\n");
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
let exitCode = 0;
|
|
99
|
+
for (const name of ctx.args) {
|
|
100
|
+
if (BUILTINS.has(name)) {
|
|
101
|
+
ctx.stdout.write(`${name}: shell built-in command
|
|
102
|
+
`);
|
|
103
|
+
} else if (REGISTERED.has(name)) {
|
|
104
|
+
ctx.stdout.write(`${name}
|
|
105
|
+
`);
|
|
106
|
+
} else {
|
|
107
|
+
ctx.stderr.write(`which: ${name}: not found
|
|
108
|
+
`);
|
|
109
|
+
exitCode = 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return exitCode;
|
|
102
113
|
};
|
|
103
114
|
export {
|
|
104
|
-
|
|
115
|
+
command as default
|
|
105
116
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const AUTH_URL = process.env.LIFO_BASE_URL || "https://lifo.sh";
|
|
2
|
+
const command = async (ctx) => {
|
|
3
|
+
const token = ctx.env.LIFO_AUTH_TOKEN;
|
|
4
|
+
if (!token) {
|
|
5
|
+
ctx.stdout.write((ctx.env.USER || "user") + "\n");
|
|
6
|
+
return 0;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const res = await fetch(`${AUTH_URL}/api/me`, {
|
|
10
|
+
headers: { authorization: `Bearer ${token}` }
|
|
11
|
+
});
|
|
12
|
+
if (res.ok) {
|
|
13
|
+
const { email } = await res.json();
|
|
14
|
+
ctx.stdout.write(email + "\n");
|
|
15
|
+
} else {
|
|
16
|
+
ctx.stdout.write((ctx.env.USER || "user") + "\n");
|
|
17
|
+
}
|
|
18
|
+
} catch {
|
|
19
|
+
ctx.stdout.write((ctx.env.USER || "user") + "\n");
|
|
20
|
+
}
|
|
21
|
+
return 0;
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
command as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const command = async (ctx) => {
|
|
2
|
+
let maxArgs = 0;
|
|
3
|
+
let cmdName = "echo";
|
|
4
|
+
const cmdArgs = [];
|
|
5
|
+
let i = 0;
|
|
6
|
+
while (i < ctx.args.length) {
|
|
7
|
+
const arg = ctx.args[i];
|
|
8
|
+
if (arg === "-n" && i + 1 < ctx.args.length) {
|
|
9
|
+
maxArgs = parseInt(ctx.args[++i], 10);
|
|
10
|
+
} else {
|
|
11
|
+
cmdName = arg;
|
|
12
|
+
i++;
|
|
13
|
+
while (i < ctx.args.length) {
|
|
14
|
+
cmdArgs.push(ctx.args[i++]);
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
i++;
|
|
19
|
+
}
|
|
20
|
+
let input = "";
|
|
21
|
+
if (ctx.stdin) {
|
|
22
|
+
input = await ctx.stdin.readAll();
|
|
23
|
+
}
|
|
24
|
+
const inputArgs = input.trim().split(/\s+/).filter(Boolean);
|
|
25
|
+
if (inputArgs.length === 0) return 0;
|
|
26
|
+
if (maxArgs > 0) {
|
|
27
|
+
for (let j = 0; j < inputArgs.length; j += maxArgs) {
|
|
28
|
+
const batch = inputArgs.slice(j, j + maxArgs);
|
|
29
|
+
const line = [cmdName, ...cmdArgs, ...batch].join(" ");
|
|
30
|
+
ctx.stdout.write(line + "\n");
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
const line = [cmdName, ...cmdArgs, ...inputArgs].join(" ");
|
|
34
|
+
ctx.stdout.write(line + "\n");
|
|
35
|
+
}
|
|
36
|
+
return 0;
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
command as default
|
|
40
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const command = async (ctx) => {
|
|
2
|
+
const text = ctx.args.length > 0 ? ctx.args.join(" ") : "y";
|
|
3
|
+
while (!ctx.signal.aborted) {
|
|
4
|
+
ctx.stdout.write(text + "\n");
|
|
5
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
6
|
+
}
|
|
7
|
+
return 0;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
command as default
|
|
11
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { r as resolve, c as collectFiles, j as createZip, V as VFSError } from "./index-GLjTMF7C.js";
|
|
2
|
+
const command = async (ctx) => {
|
|
3
|
+
if (ctx.args.length === 0 || ctx.args[0] === "--help") {
|
|
4
|
+
ctx.stdout.write("Usage: zip archive.zip file1 [file2 ...]\n");
|
|
5
|
+
return ctx.args.length === 0 ? 1 : 0;
|
|
6
|
+
}
|
|
7
|
+
const archiveFile = ctx.args[0];
|
|
8
|
+
const files = ctx.args.slice(1);
|
|
9
|
+
if (files.length === 0) {
|
|
10
|
+
ctx.stderr.write("zip: no files to archive\n");
|
|
11
|
+
return 1;
|
|
12
|
+
}
|
|
13
|
+
const archivePath = resolve(ctx.cwd, archiveFile);
|
|
14
|
+
try {
|
|
15
|
+
const tarEntries = collectFiles(ctx.vfs, ctx.cwd, files);
|
|
16
|
+
const zipEntries = tarEntries.map((e) => ({
|
|
17
|
+
path: e.path,
|
|
18
|
+
data: e.data,
|
|
19
|
+
isDirectory: e.type === "directory"
|
|
20
|
+
}));
|
|
21
|
+
const data = createZip(zipEntries);
|
|
22
|
+
ctx.vfs.writeFile(archivePath, data);
|
|
23
|
+
for (const entry of zipEntries) {
|
|
24
|
+
const label = entry.isDirectory ? "adding:" : "adding:";
|
|
25
|
+
ctx.stdout.write(` ${label} ${entry.path}${entry.isDirectory ? "/" : ""}
|
|
26
|
+
`);
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
if (e instanceof VFSError) {
|
|
30
|
+
ctx.stderr.write(`zip: ${e.message}
|
|
31
|
+
`);
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
return 0;
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
command as default
|
|
40
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifo-sh/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Linux-like OS engine for JavaScript -- kernel, shell, VFS, and 60+ commands",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,9 +35,20 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@lifo-sh/kernel": "^0.1.7",
|
|
46
|
+
"@lifo-sh/node-compat": "^0.1.8",
|
|
47
|
+
"@lifo-sh/node-runner": "^0.1.10",
|
|
48
|
+
"ws": "^8.19.0"
|
|
49
|
+
},
|
|
39
50
|
"peerDependencies": {
|
|
40
|
-
"@lifo-sh/ui": "
|
|
51
|
+
"@lifo-sh/ui": "workspace:*"
|
|
41
52
|
},
|
|
42
53
|
"peerDependenciesMeta": {
|
|
43
54
|
"@lifo-sh/ui": {
|
|
@@ -45,15 +56,10 @@
|
|
|
45
56
|
}
|
|
46
57
|
},
|
|
47
58
|
"devDependencies": {
|
|
59
|
+
"@types/ws": "^8.18.1",
|
|
48
60
|
"typescript": "^5.7.0",
|
|
49
61
|
"vite": "^6.0.0",
|
|
50
62
|
"vite-plugin-dts": "^4.5.0",
|
|
51
63
|
"vitest": "^3.0.0"
|
|
52
|
-
},
|
|
53
|
-
"scripts": {
|
|
54
|
-
"build": "vite build",
|
|
55
|
-
"typecheck": "tsc --noEmit",
|
|
56
|
-
"test": "vitest run",
|
|
57
|
-
"test:watch": "vitest"
|
|
58
64
|
}
|
|
59
|
-
}
|
|
65
|
+
}
|
package/dist/args-CG6b9cZt.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
function g(c, i) {
|
|
2
|
-
const s = {}, f = [], a = {};
|
|
3
|
-
for (const [n, t] of Object.entries(i))
|
|
4
|
-
t.short && (a[t.short] = n), s[n] = t.type === "boolean" ? !1 : "";
|
|
5
|
-
let u = !1;
|
|
6
|
-
for (let n = 0; n < c.length; n++) {
|
|
7
|
-
const t = c[n];
|
|
8
|
-
if (u || !t.startsWith("-") || t === "-") {
|
|
9
|
-
f.push(t);
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
if (t === "--") {
|
|
13
|
-
u = !0;
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
if (t.startsWith("--")) {
|
|
17
|
-
const o = t.indexOf("=");
|
|
18
|
-
if (o !== -1) {
|
|
19
|
-
const e = t.slice(2, o), l = t.slice(o + 1);
|
|
20
|
-
e in i && (s[e] = i[e].type === "boolean" ? !0 : l);
|
|
21
|
-
} else {
|
|
22
|
-
const e = t.slice(2);
|
|
23
|
-
e in i && (i[e].type === "string" ? s[e] = c[++n] ?? "" : s[e] = !0);
|
|
24
|
-
}
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const r = t.slice(1);
|
|
28
|
-
for (let o = 0; o < r.length; o++) {
|
|
29
|
-
const e = r[o], l = a[e];
|
|
30
|
-
if (l)
|
|
31
|
-
if (i[l].type === "string") {
|
|
32
|
-
const h = r.slice(o + 1);
|
|
33
|
-
s[l] = h || (c[++n] ?? "");
|
|
34
|
-
break;
|
|
35
|
-
} else
|
|
36
|
-
s[l] = !0;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return { flags: s, positional: f };
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
g as p
|
|
43
|
-
};
|