@jerryan/just-bash 3.7.0 → 3.9.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/CHANGELOG.md +78 -0
- package/dist/bin/chunks/{awk2-KO7ZE3P7.js → awk2-NTRVFXRA.js} +1 -1
- package/dist/bin/chunks/{chmod-G2BCCQGF.js → chmod-GX5SYTRL.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-THFQI5LV.js → chunks/chunk-3ROYEBJI.js} +1 -1
- package/dist/bin/chunks/chunk-6FGMEZZP.js +20 -0
- package/dist/bin/{shell/chunks/chunk-RRECHBUS.js → chunks/chunk-6JEDM6CZ.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-FO7XJH3J.js → chunks/chunk-6JUPBMCR.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-HYLF56CC.js → chunks/chunk-ABP4OLJV.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-7PUOS2OO.js → chunks/chunk-ANX7U57Q.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-2UKTHDUM.js → chunks/chunk-BB5VTPMQ.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-WFHYGSLJ.js → chunks/chunk-CNVNOT67.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-ADI36B7X.js → chunks/chunk-DRPHNXG7.js} +1 -1
- package/dist/bin/chunks/chunk-GBKR5KTT.js +44 -0
- package/dist/bin/{shell/chunks/chunk-OXLC2WWX.js → chunks/chunk-H7PD6FLC.js} +10 -10
- package/dist/bin/{shell/chunks/chunk-QYZN33JA.js → chunks/chunk-IOKQFPM6.js} +1 -1
- package/dist/bin/chunks/{chunk-7KMOGI3N.js → chunk-KMYJMEON.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-RPUFEP5O.js → chunks/chunk-M3Z5NZXT.js} +1 -1
- package/dist/bin/chunks/{chunk-NBTZL3VS.js → chunk-MBREBDZQ.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-F3UDTTI7.js → chunks/chunk-ONF4KUYV.js} +1 -1
- package/dist/bin/chunks/{chunk-V2XF3TTW.js → chunk-PRVPFKTC.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-7VWOECJ3.js → chunks/chunk-PTUQEN6I.js} +1 -1
- package/dist/bin/chunks/{chunk-R2J5MJOM.js → chunk-QFOXSCOD.js} +1 -1
- package/dist/bin/chunks/{chunk-PEUGMGJJ.js → chunk-QJWFCA7P.js} +1 -1
- package/dist/bin/chunks/{chunk-66UHJFN6.js → chunk-RTN6X652.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-6O4Z6BQT.js → chunks/chunk-T6OIISUC.js} +1 -1
- package/dist/bin/chunks/{chunk-R76AK3KD.js → chunk-U5JLGI56.js} +1 -1
- package/dist/bin/chunks/{chunk-7PPAWLUI.js → chunk-V4S4A7M6.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-E26NQEH2.js → chunks/chunk-VPSBWWXM.js} +1 -1
- package/dist/bin/chunks/{chunk-GA5TPRMF.js → chunk-YXPSX3SI.js} +11 -11
- package/dist/bin/chunks/{chunk-472JZJ2D.js → chunk-ZVG47PYA.js} +1 -1
- package/dist/bin/{shell/chunks/cp-TMDR6USI.js → chunks/cp-YLP7ULVT.js} +1 -1
- package/dist/bin/{shell/chunks/diff-YXZZCUSQ.js → chunks/diff-DM47S5PT.js} +1 -1
- package/dist/bin/{shell/chunks/du-UKFUX7KM.js → chunks/du-DH76GZJ3.js} +1 -1
- package/dist/bin/chunks/{expr-NNMDHOCN.js → expr-PQEPO5TE.js} +1 -1
- package/dist/bin/chunks/{file-4T64QNLS.js → file-JA7QI2YT.js} +1 -1
- package/dist/bin/chunks/{find-W2RZWTOF.js → find-MHC4QV6H.js} +1 -1
- package/dist/bin/chunks/{flag-coverage-QJ5ZQKCF.js → flag-coverage-LLAQBVIG.js} +1 -1
- package/dist/bin/chunks/{grep-IHDO3L72.js → grep-VXWNMIDD.js} +1 -1
- package/dist/bin/chunks/{gzip-WUK63QLL.js → gzip-UQZL4R74.js} +1 -1
- package/dist/bin/{shell/chunks/jq-V7OTAVU5.js → chunks/jq-YS4PR46D.js} +1 -1
- package/dist/bin/chunks/{js-exec-BE37X4L2.js → js-exec-ZAAIZQWI.js} +3 -3
- package/dist/bin/chunks/js-exec-worker.js +8 -2
- package/dist/bin/{shell/chunks/ls-EROTXGTC.js → chunks/ls-5Z45FV4U.js} +1 -1
- package/dist/bin/chunks/{mv-HDNKXPO6.js → mv-EOOP2TO3.js} +1 -1
- package/dist/bin/{shell/chunks/readlink-ZUIECKQC.js → chunks/readlink-EJ3IKLWW.js} +1 -1
- package/dist/bin/{shell/chunks/rg-ODJAYIKX.js → chunks/rg-WHVR3YDT.js} +1 -1
- package/dist/bin/{shell/chunks/rmdir-W5NBOJ7E.js → chunks/rmdir-PRNISPBA.js} +1 -1
- package/dist/bin/{shell/chunks/sed-4LVDFHIJ.js → chunks/sed-SY63U2YX.js} +1 -1
- package/dist/bin/chunks/{split-TVJYLTIJ.js → split-HIFKSV2A.js} +1 -1
- package/dist/bin/chunks/{sqlite3-5BGAK7VX.js → sqlite3-CXQTZRPZ.js} +1 -1
- package/dist/bin/chunks/{tar-7HGZIMZD.js → tar-7XOP7VOX.js} +1 -1
- package/dist/bin/chunks/{xan-WW53ETXT.js → xan-RMH6JEXM.js} +1 -1
- package/dist/bin/chunks/{yq-MYZOS2WN.js → yq-CWBZMGUV.js} +1 -1
- package/dist/bin/just-bash.js +262 -262
- package/dist/bin/shell/chunks/{awk2-KO7ZE3P7.js → awk2-NTRVFXRA.js} +1 -1
- package/dist/bin/shell/chunks/{chmod-G2BCCQGF.js → chmod-GX5SYTRL.js} +1 -1
- package/dist/bin/{chunks/chunk-THFQI5LV.js → shell/chunks/chunk-3ROYEBJI.js} +1 -1
- package/dist/bin/shell/chunks/chunk-6FGMEZZP.js +20 -0
- package/dist/bin/{chunks/chunk-RRECHBUS.js → shell/chunks/chunk-6JEDM6CZ.js} +1 -1
- package/dist/bin/{chunks/chunk-FO7XJH3J.js → shell/chunks/chunk-6JUPBMCR.js} +1 -1
- package/dist/bin/{chunks/chunk-HYLF56CC.js → shell/chunks/chunk-ABP4OLJV.js} +1 -1
- package/dist/bin/{chunks/chunk-7PUOS2OO.js → shell/chunks/chunk-ANX7U57Q.js} +1 -1
- package/dist/bin/{chunks/chunk-2UKTHDUM.js → shell/chunks/chunk-BB5VTPMQ.js} +1 -1
- package/dist/bin/{chunks/chunk-WFHYGSLJ.js → shell/chunks/chunk-CNVNOT67.js} +1 -1
- package/dist/bin/{chunks/chunk-ADI36B7X.js → shell/chunks/chunk-DRPHNXG7.js} +1 -1
- package/dist/bin/shell/chunks/chunk-GBKR5KTT.js +44 -0
- package/dist/bin/{chunks/chunk-OXLC2WWX.js → shell/chunks/chunk-H7PD6FLC.js} +10 -10
- package/dist/bin/{chunks/chunk-QYZN33JA.js → shell/chunks/chunk-IOKQFPM6.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-7KMOGI3N.js → chunk-KMYJMEON.js} +1 -1
- package/dist/bin/{chunks/chunk-RPUFEP5O.js → shell/chunks/chunk-M3Z5NZXT.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-NBTZL3VS.js → chunk-MBREBDZQ.js} +1 -1
- package/dist/bin/{chunks/chunk-F3UDTTI7.js → shell/chunks/chunk-ONF4KUYV.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-V2XF3TTW.js → chunk-PRVPFKTC.js} +1 -1
- package/dist/bin/{chunks/chunk-7VWOECJ3.js → shell/chunks/chunk-PTUQEN6I.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-R2J5MJOM.js → chunk-QFOXSCOD.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-PEUGMGJJ.js → chunk-QJWFCA7P.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-66UHJFN6.js → chunk-RTN6X652.js} +1 -1
- package/dist/bin/{chunks/chunk-6O4Z6BQT.js → shell/chunks/chunk-T6OIISUC.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-R76AK3KD.js → chunk-U5JLGI56.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-7PPAWLUI.js → chunk-V4S4A7M6.js} +1 -1
- package/dist/bin/{chunks/chunk-E26NQEH2.js → shell/chunks/chunk-VPSBWWXM.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-GA5TPRMF.js → chunk-YXPSX3SI.js} +11 -11
- package/dist/bin/shell/chunks/{chunk-472JZJ2D.js → chunk-ZVG47PYA.js} +1 -1
- package/dist/bin/{chunks/cp-TMDR6USI.js → shell/chunks/cp-YLP7ULVT.js} +1 -1
- package/dist/bin/{chunks/diff-YXZZCUSQ.js → shell/chunks/diff-DM47S5PT.js} +1 -1
- package/dist/bin/{chunks/du-UKFUX7KM.js → shell/chunks/du-DH76GZJ3.js} +1 -1
- package/dist/bin/shell/chunks/{expr-NNMDHOCN.js → expr-PQEPO5TE.js} +1 -1
- package/dist/bin/shell/chunks/{file-4T64QNLS.js → file-JA7QI2YT.js} +1 -1
- package/dist/bin/shell/chunks/{find-W2RZWTOF.js → find-MHC4QV6H.js} +1 -1
- package/dist/bin/shell/chunks/{flag-coverage-QJ5ZQKCF.js → flag-coverage-LLAQBVIG.js} +1 -1
- package/dist/bin/shell/chunks/{grep-IHDO3L72.js → grep-VXWNMIDD.js} +1 -1
- package/dist/bin/shell/chunks/{gzip-WUK63QLL.js → gzip-UQZL4R74.js} +1 -1
- package/dist/bin/{chunks/jq-V7OTAVU5.js → shell/chunks/jq-YS4PR46D.js} +1 -1
- package/dist/bin/shell/chunks/{js-exec-BE37X4L2.js → js-exec-ZAAIZQWI.js} +3 -3
- package/dist/bin/{chunks/ls-EROTXGTC.js → shell/chunks/ls-5Z45FV4U.js} +1 -1
- package/dist/bin/shell/chunks/{mv-HDNKXPO6.js → mv-EOOP2TO3.js} +1 -1
- package/dist/bin/{chunks/readlink-ZUIECKQC.js → shell/chunks/readlink-EJ3IKLWW.js} +1 -1
- package/dist/bin/{chunks/rg-ODJAYIKX.js → shell/chunks/rg-WHVR3YDT.js} +1 -1
- package/dist/bin/{chunks/rmdir-W5NBOJ7E.js → shell/chunks/rmdir-PRNISPBA.js} +1 -1
- package/dist/bin/{chunks/sed-4LVDFHIJ.js → shell/chunks/sed-SY63U2YX.js} +1 -1
- package/dist/bin/shell/chunks/{split-TVJYLTIJ.js → split-HIFKSV2A.js} +1 -1
- package/dist/bin/shell/chunks/{sqlite3-5BGAK7VX.js → sqlite3-CXQTZRPZ.js} +1 -1
- package/dist/bin/shell/chunks/{tar-7HGZIMZD.js → tar-7XOP7VOX.js} +1 -1
- package/dist/bin/shell/chunks/{xan-WW53ETXT.js → xan-RMH6JEXM.js} +1 -1
- package/dist/bin/shell/chunks/{yq-MYZOS2WN.js → yq-CWBZMGUV.js} +1 -1
- package/dist/bin/shell/shell.js +263 -263
- package/dist/bundle/browser.js +633 -597
- package/dist/bundle/chunks/{awk2-W6BNZEJN.js → awk2-VS5QVYHU.js} +1 -1
- package/dist/bundle/chunks/{chmod-XZNKTJHL.js → chmod-TEY5MD2W.js} +1 -1
- package/dist/bundle/chunks/{chunk-26GP3ACY.js → chunk-35MBA3VY.js} +1 -1
- package/dist/bundle/chunks/{chunk-IYJLVOVE.js → chunk-3OBCZP7T.js} +1 -1
- package/dist/bundle/chunks/{chunk-OR544SGH.js → chunk-45QZRGYF.js} +1 -1
- package/dist/bundle/chunks/{chunk-73JQKNZT.js → chunk-4KZT23KR.js} +11 -11
- package/dist/bundle/chunks/{chunk-PJM5C3HZ.js → chunk-5EI7WSRV.js} +10 -10
- package/dist/bundle/chunks/{chunk-T6DNSPYO.js → chunk-6BSOPPZH.js} +1 -1
- package/dist/bundle/chunks/{chunk-YNYC232D.js → chunk-6HO6HX7V.js} +1 -1
- package/dist/bundle/chunks/{chunk-2T7PBFL4.js → chunk-6QAM55HM.js} +1 -1
- package/dist/bundle/chunks/{chunk-SBOTR4JQ.js → chunk-ATGOUOX2.js} +1 -1
- package/dist/bundle/chunks/{chunk-2TSZPVPI.js → chunk-BLPYR4TN.js} +1 -1
- package/dist/bundle/chunks/{chunk-VJ6UXG2R.js → chunk-CH7SUFFO.js} +1 -1
- package/dist/bundle/chunks/{chunk-FQUVK4Q5.js → chunk-DDPD7SIB.js} +1 -1
- package/dist/bundle/chunks/chunk-E2F4A3CM.js +43 -0
- package/dist/bundle/chunks/{chunk-YUOBBH7P.js → chunk-FSKXIFYT.js} +1 -1
- package/dist/bundle/chunks/{chunk-FZZL53S2.js → chunk-GRUZ4SBY.js} +1 -1
- package/dist/bundle/chunks/{chunk-E3ABCXE4.js → chunk-H3A45X3W.js} +1 -1
- package/dist/bundle/chunks/{chunk-PMBXJ3OQ.js → chunk-HCKTU6IR.js} +1 -1
- package/dist/bundle/chunks/{chunk-4EDQZIAN.js → chunk-LGIJSCWH.js} +1 -1
- package/dist/bundle/chunks/chunk-MWL2I5BV.js +19 -0
- package/dist/bundle/chunks/{chunk-PPEXVPHR.js → chunk-O452S4KX.js} +1 -1
- package/dist/bundle/chunks/{chunk-3BMWRGU2.js → chunk-RWQWFXMH.js} +1 -1
- package/dist/bundle/chunks/{chunk-D5FHVW27.js → chunk-S6DNKKUL.js} +1 -1
- package/dist/bundle/chunks/{chunk-OPYVVD5P.js → chunk-SE23TEGG.js} +1 -1
- package/dist/bundle/chunks/{chunk-ULXTDFQC.js → chunk-U57DSHID.js} +1 -1
- package/dist/bundle/chunks/{chunk-ACVD6PQF.js → chunk-WE7BJ7YU.js} +1 -1
- package/dist/bundle/chunks/{chunk-5I5U6IYI.js → chunk-XQ2ZZFO6.js} +1 -1
- package/dist/bundle/chunks/{chunk-5DMO6LFU.js → chunk-Y6JBSHCM.js} +1 -1
- package/dist/bundle/chunks/{cp-NWITRTH3.js → cp-UR762VVT.js} +1 -1
- package/dist/bundle/chunks/{diff-CSARC7WF.js → diff-R7TXVVLN.js} +1 -1
- package/dist/bundle/chunks/{du-IFLWEM6M.js → du-EQKH3UNA.js} +1 -1
- package/dist/bundle/chunks/{expr-XSBELPAC.js → expr-A5XITHQD.js} +1 -1
- package/dist/bundle/chunks/{file-URNAD6FQ.js → file-6AYYTULJ.js} +1 -1
- package/dist/bundle/chunks/{find-EW6OHRPJ.js → find-RLKBCGJR.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-PIF5QRO7.js → flag-coverage-YQGACUSN.js} +1 -1
- package/dist/bundle/chunks/{grep-QDFNKAUW.js → grep-Q2O5EIXQ.js} +1 -1
- package/dist/bundle/chunks/{gzip-HBDKZBIP.js → gzip-KC5ENBD2.js} +1 -1
- package/dist/bundle/chunks/{jq-NY7PCVMH.js → jq-UKAA3QWU.js} +1 -1
- package/dist/bundle/chunks/{js-exec-IREGAOMH.js → js-exec-MUZRDUJ3.js} +3 -3
- package/dist/bundle/chunks/js-exec-worker.js +8 -2
- package/dist/bundle/chunks/{ls-WJ7EIFVM.js → ls-WH5S4PPL.js} +1 -1
- package/dist/bundle/chunks/{mv-E2NFLGRQ.js → mv-WE7DBLEK.js} +1 -1
- package/dist/bundle/chunks/{readlink-XCFO7YD2.js → readlink-JSRKXLLQ.js} +1 -1
- package/dist/bundle/chunks/{rg-J7XDRV3B.js → rg-JKB7DR66.js} +1 -1
- package/dist/bundle/chunks/{rmdir-UMUDM2L2.js → rmdir-3WTXMVKI.js} +1 -1
- package/dist/bundle/chunks/{sed-LIRH26EA.js → sed-6G32B25J.js} +1 -1
- package/dist/bundle/chunks/{split-D4HPO4G5.js → split-HUKVGJTW.js} +1 -1
- package/dist/bundle/chunks/{sqlite3-3HL2ECCQ.js → sqlite3-DQNCWDG5.js} +1 -1
- package/dist/bundle/chunks/{tar-B72KU357.js → tar-LE7LAAIX.js} +1 -1
- package/dist/bundle/chunks/{xan-UIGVJCMA.js → xan-UIL24CGT.js} +1 -1
- package/dist/bundle/chunks/{yq-FGNXZCGX.js → yq-ZRNZKDLE.js} +1 -1
- package/dist/bundle/index.cjs +827 -791
- package/dist/bundle/index.js +218 -218
- package/dist/commands/diff/format.d.ts +46 -0
- package/dist/commands/js-exec/js-exec-worker.d.ts +2 -0
- package/dist/fs/traversal.d.ts +9 -0
- package/dist/fs/vfs-template.d.ts +6 -0
- package/dist/interpreter/helpers/substitution-status.d.ts +34 -0
- package/dist/interpreter/types.d.ts +7 -0
- package/dist/limits.d.ts +2 -0
- package/package.json +1 -1
- package/dist/bin/chunks/chunk-23OI2XDJ.js +0 -20
- package/dist/bin/chunks/chunk-U7YR5CDD.js +0 -20
- package/dist/bin/shell/chunks/chunk-23OI2XDJ.js +0 -20
- package/dist/bin/shell/chunks/chunk-U7YR5CDD.js +0 -20
- package/dist/bundle/chunks/chunk-HMM3NGUJ.js +0 -19
- package/dist/bundle/chunks/chunk-UTKGYVUZ.js +0 -7
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output formatters for diff.
|
|
3
|
+
*
|
|
4
|
+
* The three formats GNU diff can produce: POSIX normal format (the default),
|
|
5
|
+
* unified format (-u) and context format (-c). Layout was derived by running
|
|
6
|
+
* GNU diffutils 3.12 and matching the bytes it emits.
|
|
7
|
+
*
|
|
8
|
+
* Two intentional deviations from GNU:
|
|
9
|
+
*
|
|
10
|
+
* - The -u/-c file header carries no timestamp. GNU appends a tab and the
|
|
11
|
+
* file's mtime; inside a virtual filesystem that is often synthetic or
|
|
12
|
+
* absent, and it would make output non-reproducible. Patch consumers ignore
|
|
13
|
+
* the field.
|
|
14
|
+
* - When several minimal edit scripts exist for the same pair of files, which
|
|
15
|
+
* one comes out is arbitrary, and this picks a different one than GNU on
|
|
16
|
+
* some inputs. Hunks are still minimal and the formats are exact; only the
|
|
17
|
+
* grouping of ambiguous changes can differ.
|
|
18
|
+
*/
|
|
19
|
+
/** Number of context lines GNU shows around a change for -u and -c. */
|
|
20
|
+
export declare const DEFAULT_CONTEXT = 3;
|
|
21
|
+
export interface FileLines {
|
|
22
|
+
/** Lines with their trailing newline stripped. */
|
|
23
|
+
lines: string[];
|
|
24
|
+
/** True when the last line is not newline-terminated. */
|
|
25
|
+
noEol: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A run of adjacent deleted and/or inserted lines. Starts are 0-based indices
|
|
29
|
+
* into the corresponding `FileLines.lines`.
|
|
30
|
+
*/
|
|
31
|
+
export interface Change {
|
|
32
|
+
oldStart: number;
|
|
33
|
+
oldCount: number;
|
|
34
|
+
newStart: number;
|
|
35
|
+
newCount: number;
|
|
36
|
+
}
|
|
37
|
+
/** Splits file content into lines, remembering a missing final newline. */
|
|
38
|
+
export declare function splitLines(content: string): FileLines;
|
|
39
|
+
/** Computes the runs of deleted and/or inserted lines between two files. */
|
|
40
|
+
export declare function computeChanges(oldFile: FileLines, newFile: FileLines, ignoreCase: boolean): Change[];
|
|
41
|
+
/** POSIX normal format: `2c2` / `< old` / `---` / `> new`. */
|
|
42
|
+
export declare function formatNormal(oldFile: FileLines, newFile: FileLines, changes: Change[]): string;
|
|
43
|
+
/** Unified format (-u): `--- old`, `+++ new`, `@@` hunks. */
|
|
44
|
+
export declare function formatUnified(oldName: string, newName: string, oldFile: FileLines, newFile: FileLines, changes: Change[], context: number): string;
|
|
45
|
+
/** Context format (-c): `*** old`, `--- new`, `***************` hunks. */
|
|
46
|
+
export declare function formatContext(oldName: string, newName: string, oldFile: FileLines, newFile: FileLines, changes: Change[], context: number): string;
|
|
@@ -21,6 +21,8 @@ export interface JsExecWorkerInput {
|
|
|
21
21
|
isModule?: boolean;
|
|
22
22
|
stripTypes?: boolean;
|
|
23
23
|
timeoutMs?: number;
|
|
24
|
+
/** QuickJS heap limit in bytes. Defaults to 64MB. */
|
|
25
|
+
memoryBytes?: number;
|
|
24
26
|
/** When true, the QuickJS guest gets a `tools` proxy that calls the host's invokeTool hook. */
|
|
25
27
|
hasInvokeTool?: boolean;
|
|
26
28
|
}
|
package/dist/fs/traversal.d.ts
CHANGED
|
@@ -67,6 +67,15 @@ export declare class FileTraversalBudget {
|
|
|
67
67
|
constructor(options: TraversalBudgetOptions);
|
|
68
68
|
checkpoint(work?: number): void;
|
|
69
69
|
visit(depth: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* Reserve directory children against the entry ceiling without charging for
|
|
72
|
+
* work not yet done. A single readdir can return far more entries than the
|
|
73
|
+
* traversal is allowed to retain, so the collection has to be admitted
|
|
74
|
+
* before it is held, but reading a directory is one filesystem operation
|
|
75
|
+
* however many names come back. Callers that go on to touch each child
|
|
76
|
+
* should use `discover` instead, which also charges the work.
|
|
77
|
+
*/
|
|
78
|
+
reserve(count: number): void;
|
|
70
79
|
/**
|
|
71
80
|
* Reserve directory children before retaining work items for them. A single
|
|
72
81
|
* readdir can return far more entries than the traversal is allowed to
|
|
@@ -20,6 +20,12 @@ export interface VfsTemplateOptions {
|
|
|
20
20
|
* default.
|
|
21
21
|
*/
|
|
22
22
|
maxMemoryBytes?: number;
|
|
23
|
+
/**
|
|
24
|
+
* When true, overlay mounts are read-only: writes through the
|
|
25
|
+
* overlay fail with EROFS. Forks can read the host filesystem
|
|
26
|
+
* but cannot modify it. Default: false.
|
|
27
|
+
*/
|
|
28
|
+
readOnly?: boolean;
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
31
|
* Template for cheap parallel forks (see
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exit-status bookkeeping for command substitutions.
|
|
3
|
+
*/
|
|
4
|
+
import type { RedirectionNode } from "../../ast/types.js";
|
|
5
|
+
import type { InterpreterState } from "../types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Record the exit status of a command substitution.
|
|
8
|
+
*
|
|
9
|
+
* `$?` and the "a substitution ran here" marker have to move together: a
|
|
10
|
+
* command with no command word (`x=1`, `> file`, an expansion that came out
|
|
11
|
+
* empty) reports the status of the last substitution that ran inside it, and
|
|
12
|
+
* 0 when none did. Setting `lastExitCode` without the marker leaves such a
|
|
13
|
+
* command reporting the *previous* command's status instead.
|
|
14
|
+
*/
|
|
15
|
+
export declare function recordSubstitutionExit(state: InterpreterState, exitCode: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* The status bash gives a command that has no command word.
|
|
18
|
+
*
|
|
19
|
+
* It is the status of the last command substitution performed while expanding
|
|
20
|
+
* the command — assigned values and redirection words alike, in that order —
|
|
21
|
+
* and 0 when no substitution ran. A bare `x=1` is therefore 0 rather than
|
|
22
|
+
* whatever the previous command left in `$?`.
|
|
23
|
+
*
|
|
24
|
+
* A redirection onto fd 0 overrides all of that with 0. bash performs the
|
|
25
|
+
* redirections of a null command in a forked child when one of them reads
|
|
26
|
+
* stdin (`execute_null_command`'s `forcefork`), so the shell reports the
|
|
27
|
+
* child's status and any substitution in the words is discarded:
|
|
28
|
+
* `x=$(exit 7) < /dev/null` is 0, while `x=$(exit 7) 3< /dev/null` is 7.
|
|
29
|
+
*
|
|
30
|
+
* Verified against GNU bash 5.3. bash 3.2 predates the fork and reports 7 for
|
|
31
|
+
* both; this follows 5.x, which is what the comparison fixtures are recorded
|
|
32
|
+
* against.
|
|
33
|
+
*/
|
|
34
|
+
export declare function nullCommandExitStatus(state: InterpreterState, redirections: readonly RedirectionNode[]): number;
|
|
@@ -320,6 +320,13 @@ export interface InterpreterState extends VariableAttributeState, LocalScopingSt
|
|
|
320
320
|
previousDir: string;
|
|
321
321
|
/** Exit code of last executed command */
|
|
322
322
|
lastExitCode: number;
|
|
323
|
+
/**
|
|
324
|
+
* Exit status of the most recent command substitution, or `null` when none
|
|
325
|
+
* has run since the current simple command began expanding. A command with
|
|
326
|
+
* no command word takes its status from this, not from `lastExitCode`:
|
|
327
|
+
* `x=$(exit 7)` is 7, while a plain `x=1` is 0 no matter what ran before it.
|
|
328
|
+
*/
|
|
329
|
+
lastSubstitutionExitCode: number | null;
|
|
323
330
|
/** Last argument of previous command, for $_ expansion */
|
|
324
331
|
lastArg: string;
|
|
325
332
|
/** Current line number being executed (for $LINENO) */
|
package/dist/limits.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ export interface ExecutionLimits {
|
|
|
82
82
|
maxPythonTimeoutMs?: number;
|
|
83
83
|
/** Maximum JavaScript execution time in milliseconds (normal default: 30000) */
|
|
84
84
|
maxJsTimeoutMs?: number;
|
|
85
|
+
/** Maximum QuickJS heap size in bytes (normal default: 64 MiB) */
|
|
86
|
+
maxJsMemoryBytes?: number;
|
|
85
87
|
/** Maximum glob filesystem operations (normal default: 1000000) */
|
|
86
88
|
maxGlobOperations?: number;
|
|
87
89
|
/** Maximum string length in bytes (normal default: 64 MiB) */
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{b as D}from"./chunk-CPKBPQ2C.js";import{a as N}from"./chunk-NE4R2FVV.js";import{a as H,b as A}from"./chunk-MUFNRCMY.js";var b=class{diff(e,n,t={}){let i;typeof t=="function"?(i=t,t={}):"callback"in t&&(i=t.callback);let d=this.castInput(e,t),o=this.castInput(n,t),s=this.removeEmpty(this.tokenize(d,t)),a=this.removeEmpty(this.tokenize(o,t));return this.diffWithOptionsObj(s,a,t,i)}diffWithOptionsObj(e,n,t,i){var d;let o=l=>{if(l=this.postProcess(l,t),i){setTimeout(function(){i(l)},0);return}else return l},s=n.length,a=e.length,u=1,r=s+a;t.maxEditLength!=null&&(r=Math.min(r,t.maxEditLength));let g=(d=t.timeout)!==null&&d!==void 0?d:1/0,w=Date.now()+g,m=[{oldPos:-1,lastComponent:void 0}],C=this.extractCommon(m[0],n,e,0,t);if(m[0].oldPos+1>=a&&C+1>=s)return o(this.buildValues(m[0].lastComponent,n,e));let P=-1/0,x=1/0,L=()=>{for(let l=Math.max(P,-u);l<=Math.min(x,u);l+=2){let c,h=m[l-1],p=m[l+1];h&&(m[l-1]=void 0);let y=!1;if(p){let S=p.oldPos-l;y=p&&0<=S&&S<s}let v=h&&h.oldPos+1<a;if(!y&&!v){m[l]=void 0;continue}if(!v||y&&h.oldPos<p.oldPos?c=this.addToPath(p,!0,!1,0,t):c=this.addToPath(h,!1,!0,1,t),C=this.extractCommon(c,n,e,l,t),c.oldPos+1>=a&&C+1>=s)return o(this.buildValues(c.lastComponent,n,e))||!0;m[l]=c,c.oldPos+1>=a&&(x=Math.min(x,l-1)),C+1>=s&&(P=Math.max(P,l+1))}u++};if(i)(function l(){setTimeout(function(){if(u>r||Date.now()>w)return i(void 0);L()||l()},0)})();else for(;u<=r&&Date.now()<=w;){let l=L();if(l)return l}}addToPath(e,n,t,i,d){let o=e.lastComponent;return o&&!d.oneChangePerToken&&o.added===n&&o.removed===t?{oldPos:e.oldPos+i,lastComponent:{count:o.count+1,added:n,removed:t,previousComponent:o.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:n,removed:t,previousComponent:o}}}extractCommon(e,n,t,i,d){let o=n.length,s=t.length,a=e.oldPos,u=a-i,r=0;for(;u+1<o&&a+1<s&&this.equals(t[a+1],n[u+1],d);)u++,a++,r++,d.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return r&&!d.oneChangePerToken&&(e.lastComponent={count:r,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,u}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let i=[],d;for(;e;)i.push(e),d=e.previousComponent,delete e.previousComponent,e=d;i.reverse();let o=i.length,s=0,a=0,u=0;for(;s<o;s++){let r=i[s];if(r.removed)r.value=this.join(t.slice(u,u+r.count)),u+=r.count;else{if(!r.added&&this.useLongestToken){let g=n.slice(a,a+r.count);g=g.map(function(w,m){let C=t[u+m];return C.length>w.length?C:w}),r.value=this.join(g)}else r.value=this.join(n.slice(a,a+r.count));a+=r.count,r.added||(u+=r.count)}}return i}};var I=class extends b{constructor(){super(...arguments),this.tokenize=W}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
|
|
4
|
-
`))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
|
|
5
|
-
`))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
|
|
6
|
-
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
7
|
-
`)&&(n=n.slice(0,-1))),super.equals(e,n,t)}},O=new I;function T(f,e,n){return O.diff(f,e,n)}function W(f,e){e.stripTrailingCr&&(f=f.replace(/\r\n/g,`
|
|
8
|
-
`));let n=[],t=f.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(let i=0;i<t.length;i++){let d=t[i];i%2&&!e.newlineIsToken?n[n.length-1]+=d:n.push(d)}return n}var j={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function F(f,e,n,t,i,d,o){let s;o?typeof o=="function"?s={callback:o}:s=o:s={},typeof s.context>"u"&&(s.context=4);let a=s.context;if(s.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(s.callback){let{callback:r}=s;T(n,t,Object.assign(Object.assign({},s),{callback:g=>{let w=u(g);r(w)}}))}else return u(T(n,t,s));function u(r){if(!r)return;r.push({value:"",lines:[]});function g(l){return l.map(function(c){return" "+c})}let w=[],m=0,C=0,P=[],x=1,L=1;for(let l=0;l<r.length;l++){let c=r[l],h=c.lines||R(c.value);if(c.lines=h,c.added||c.removed){if(!m){let p=r[l-1];m=x,C=L,p&&(P=a>0?g(p.lines.slice(-a)):[],m-=P.length,C-=P.length)}for(let p of h)P.push((c.added?"+":"-")+p);c.added?L+=h.length:x+=h.length}else{if(m)if(h.length<=a*2&&l<r.length-2)for(let p of g(h))P.push(p);else{let p=Math.min(h.length,a);for(let v of g(h.slice(0,p)))P.push(v);let y={oldStart:m,oldLines:x-m+p,newStart:C,newLines:L-C+p,lines:P};w.push(y),m=0,C=0,P=[]}x+=h.length,L+=h.length}}for(let l of w)for(let c=0;c<l.lines.length;c++)l.lines[c].endsWith(`
|
|
9
|
-
`)?l.lines[c]=l.lines[c].slice(0,-1):(l.lines.splice(c+1,0,"\"),c++);return{oldFileName:f,newFileName:e,oldHeader:i,newHeader:d,hunks:w}}}function E(f,e){if(e||(e=j),Array.isArray(f)){if(f.length>1&&!e.includeFileHeaders)throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return f.map(t=>E(t,e)).join(`
|
|
10
|
-
`)}let n=[];e.includeIndex&&f.oldFileName==f.newFileName&&n.push("Index: "+f.oldFileName),e.includeUnderline&&n.push("==================================================================="),e.includeFileHeaders&&(n.push("--- "+f.oldFileName+(typeof f.oldHeader>"u"?"":" "+f.oldHeader)),n.push("+++ "+f.newFileName+(typeof f.newHeader>"u"?"":" "+f.newHeader)));for(let t=0;t<f.hunks.length;t++){let i=f.hunks[t];i.oldLines===0&&(i.oldStart-=1),i.newLines===0&&(i.newStart-=1),n.push("@@ -"+i.oldStart+","+i.oldLines+" +"+i.newStart+","+i.newLines+" @@");for(let d of i.lines)n.push(d)}return n.join(`
|
|
11
|
-
`)+`
|
|
12
|
-
`}function k(f,e,n,t,i,d,o){if(typeof o=="function"&&(o={callback:o}),o?.callback){let{callback:s}=o;F(f,e,n,t,i,d,Object.assign(Object.assign({},o),{callback:a=>{s(a?E(a,o.headerOptions):void 0)}}))}else{let s=F(f,e,n,t,i,d,o);return s?E(s,o?.headerOptions):void 0}}function R(f){let e=f.endsWith(`
|
|
13
|
-
`),n=f.split(`
|
|
14
|
-
`).map(t=>t+`
|
|
15
|
-
`);return e?n.pop():n.push(n.pop().slice(0,-1)),n}var z={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},_={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},ee={name:"diff",async execute(f,e){if(A(f))return H(z);let n=N("diff",f,_);if(!n.ok)return n.error;let t=n.result.flags.brief,i=n.result.flags.reportSame,d=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
16
|
-
`,exitCode:2};let s,a,[u,r]=o;try{s=u==="-"?D(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
|
|
17
|
-
`,exitCode:2}}try{a=r==="-"?D(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,r))}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
18
|
-
`,exitCode:2}}let g=s,w=a;return d&&(g=g.toLowerCase(),w=w.toLowerCase()),g===w?i?{stdout:`Files ${u} and ${r} are identical
|
|
19
|
-
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:t?{stdout:`Files ${u} and ${r} differ
|
|
20
|
-
`,stderr:"",exitCode:1}:{stdout:k(u,r,s,a,"","",{context:3}),stderr:"",exitCode:1}}},ne={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{ee as a,ne as b};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{d as V}from"./chunk-I57EACSL.js";import{d as B}from"./chunk-NBTZL3VS.js";import{l as _,m as Y}from"./chunk-FUT3X2GJ.js";import{a as J}from"./chunk-CPKBPQ2C.js";import{a as Q}from"./chunk-NE4R2FVV.js";import{a as Z,b as q}from"./chunk-MUFNRCMY.js";function h(s,t,e){if(J(e)>s.limits.maxOutputSize-J(t))throw new _(`ls: output size limit exceeded (${s.limits.maxOutputSize} bytes)`,"output_size");return t+e}function X(s,t){let e=new V(s.limits.maxOutputSize,"ls");for(let l=0;l<t.length;l++)l>0&&e.append(`
|
|
4
|
-
`),e.append(t[l]);return t.length>0&&e.append(`
|
|
5
|
-
`),e.build()}function I(s){if(s<1024)return String(s);if(s<1024*1024){let e=s/1024;return e<10?`${e.toFixed(1)}K`:`${Math.round(e)}K`}if(s<1024*1024*1024){let e=s/1048576;return e<10?`${e.toFixed(1)}M`:`${Math.round(e)}M`}let t=s/(1024*1024*1024);return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function K(s){let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()],l=String(s.getDate()).padStart(2," "),p=new Date,g=new Date(p.getTime()-4320*60*60*1e3);if(s>g){let z=String(s.getHours()).padStart(2,"0"),d=String(s.getMinutes()).padStart(2,"0");return`${e} ${l} ${z}:${d}`}let b=s.getFullYear();return`${e} ${l} ${b}`}function W(s){return s.isDirectory?"/":s.isSymbolicLink?"@":(s.mode&73)!==0?"*":""}var nt={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-F, --classify append indicator (one of */=>@) to entries","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},ot={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},classifyFiles:{short:"F",long:"classify",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},pt={name:"ls",async execute(s,t){if(q(s))return Z(nt);let e=Q("ls",s,ot);if(!e.ok)return e.error;let l=e.result.flags.showAll,p=e.result.flags.showAlmostAll,g=e.result.flags.longFormat,b=e.result.flags.humanReadable,z=e.result.flags.recursive,d=e.result.flags.reverse,$=e.result.flags.classifyFiles,O=e.result.flags.directoryOnly,R=it(s,e.result.flags.sortBySize,e.result.flags.sortByTime);e.result.flags.onePerLine;let F=e.result.positional;F.length===0&&F.push(".");let S="",P="",C=0,M=new B({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"});if(O){for(let n of await G(F,t,R,d,M)){M.visit(0);let i=t.fs.resolvePath(t.cwd,n);try{let D=await t.fs.stat(i);if(g){let L=D.isDirectory?"drwxr-xr-x":"-rw-r--r--",c=$?W(await t.fs.lstat(i)):"",u=D.size??0,A=b?I(u).padStart(5):String(u).padStart(5),a=D.mtime??new Date(0),o=K(a);S=h(t,S,`${L} 1 user user ${A} ${o} ${n}${c}
|
|
6
|
-
`)}else{let L=$?W(await t.fs.lstat(i)):"";S=h(t,S,`${n}${L}
|
|
7
|
-
`)}}catch{P=h(t,P,`ls: cannot access '${n}': No such file or directory
|
|
8
|
-
`),C=2}}return{stdout:S,stderr:P,exitCode:C}}let m=[],y=[];for(let n of F){M.visit(0);try{((await t.fs.stat(t.fs.resolvePath(t.cwd,n))).isDirectory?y:m).push(n)}catch{P=h(t,P,`ls: ${n}: No such file or directory
|
|
9
|
-
`),C=2}}let T=async(n,i)=>{let D=await x(n,t,l,p,g,z,i,d,b,R,$,!1,M,0,new Set,!0);S=h(t,S,D.stdout),P=h(t,P,D.stderr),D.exitCode!==0&&(C=D.exitCode)};for(let n of await G(m,t,R,d,M))await T(n,!1);let N=F.length>1;for(let n of await G(y,t,R,d,M))S&&(S=h(t,S,`
|
|
10
|
-
`)),await T(n,N);return{stdout:S,stderr:P,exitCode:C}}};function it(s,t,e){if(!t&&!e)return"name";if(t!==e)return t?"size":"time";let l="name";for(let p of s){if(p==="--")break;if(!(!p.startsWith("-")||p.startsWith("--")))for(let g of p.slice(1))g==="S"?l="size":g==="t"&&(l="time")}return l}async function G(s,t,e,l,p){return await j(s,g=>t.fs.resolvePath(t.cwd,g),t,e,l,p)}async function j(s,t,e,l,p,g){let b=[...s];if(l==="name")b.sort();else{g?.checkpoint(b.length);let z=new Map;for(let d of b)try{let $=await e.fs.lstat(t(d));z.set(d,l==="size"?$.size??0:($.mtime??new Date(0)).getTime())}catch{z.set(d,0)}b.sort((d,$)=>{let O=(z.get($)??0)-(z.get(d)??0);return O!==0?O:d<$?-1:d>$?1:0})}return p&&b.reverse(),b}async function x(s,t,e,l,p,g,b,z=!1,d=!1,$="name",O=!1,R=!1,F=new B({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"}),S=0,P=new Set,C=!1){let M=e||l,m=t.fs.resolvePath(t.cwd,s);try{C||F.visit(S);let y=await t.fs.stat(m);if(!y.isDirectory){let c=O?W(await t.fs.lstat(m)):"";if(p){let u=y.size??0,A=d?I(u).padStart(5):String(u).padStart(5),a=y.mtime??new Date(0),o=K(a);return{stdout:`-rw-r--r-- 1 user user ${A} ${o} ${s}${c}
|
|
11
|
-
`,stderr:"",exitCode:0}}return{stdout:`${s}${c}
|
|
12
|
-
`,stderr:"",exitCode:0}}let T=y.identity??(y.dev!==void 0&&y.ino!==void 0?`${String(y.dev)}:${String(y.ino)}`:await t.fs.realpath(m).catch(()=>{}));if(T!==void 0&&P.has(T))return{stdout:"",stderr:`ls: ${s}: symbolic link cycle detected
|
|
13
|
-
`,exitCode:2};let N=new Set(P);T!==void 0&&N.add(T);let n=await t.fs.readdir(m);F.checkpoint(),M||(n=n.filter(c=>!c.startsWith("."))),n=await j(n,c=>m==="/"?`/${c}`:`${m}/${c}`,t,$,!1,F),e&&(n=[".","..",...n]),z&&n.reverse();let i="",D="",L=0;if((g||b)&&(i=h(t,i,`${s}:
|
|
14
|
-
`)),p){i=h(t,i,`total ${n.length}
|
|
15
|
-
`);let c=n.filter(o=>o==="."||o===".."),u=n.filter(o=>o!=="."&&o!=="..");for(let o of c)i=h(t,i,`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${o}
|
|
16
|
-
`);let A=[];for(let o=0;o<u.length;o+=100){let r=u.slice(o,o+100),f=await Promise.all(r.map(async v=>{let w=m==="/"?`/${v}`:`${m}/${v}`;try{let k=await t.fs.stat(w),H=k.isDirectory?"drwxr-xr-x":"-rw-r--r--",tt=O?W(await t.fs.lstat(w)):"",U=k.size??0,et=d?I(U).padStart(5):String(U).padStart(5),st=k.mtime??new Date(0),rt=K(st);return{name:v,line:`${H} 1 user user ${et} ${rt} ${v}${tt}
|
|
17
|
-
`}}catch{return{name:v,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${v}
|
|
18
|
-
`}}}));A.push(...f)}let a=new Map(u.map((o,r)=>[o,r]));A.sort((o,r)=>(a.get(o.name)??0)-(a.get(r.name)??0));for(let{line:o}of A)i=h(t,i,o)}else if(O){let c=[],u=n.filter(a=>a!=="."&&a!==".."),A=n.filter(a=>a==="."||a==="..");for(let a of A)c.push(`${a}/`);for(let a=0;a<u.length;a+=100){let o=u.slice(a,a+100),r=await Promise.all(o.map(async f=>{let v=m==="/"?`/${f}`:`${m}/${f}`;try{let w=await t.fs.lstat(v);return`${f}${W(w)}`}catch{return f}}));c.push(...r)}i=h(t,i,X(t,c))}else i=h(t,i,X(t,n));if(g){let c=n.filter(r=>r!=="."&&r!==".."),u=[];if(t.fs.readdirWithFileTypes)u=(await t.fs.readdirWithFileTypes(m)).filter(f=>f.isDirectory&&c.includes(f.name)).map(f=>({name:f.name,isDirectory:!0}));else for(let r=0;r<c.length;r+=100){let f=c.slice(r,r+100),v=await Promise.all(f.map(async w=>{let k=m==="/"?`/${w}`:`${m}/${w}`;try{let H=await t.fs.stat(k);return{name:w,isDirectory:H.isDirectory}}catch{return{name:w,isDirectory:!1}}}));u.push(...v.filter(w=>w.isDirectory))}let A=await j(u.map(r=>r.name),r=>m==="/"?`/${r}`:`${m}/${r}`,t,$,z,F),a=new Map(A.map((r,f)=>[r,f]));u.sort((r,f)=>(a.get(r.name)??0)-(a.get(f.name)??0));let o=[];for(let r=0;r<u.length;r+=100){let f=u.slice(r,r+100),v=await Promise.all(f.map(async w=>{let k=s==="."?`./${w.name}`:`${s}/${w.name}`,H=await x(k,t,e,l,p,g,!1,z,d,$,O,!0,F,S+1,N);return{name:w.name,result:H}}));o.push(...v)}o.sort((r,f)=>(a.get(r.name)??0)-(a.get(f.name)??0));for(let{result:r}of o)i=h(t,i,`
|
|
19
|
-
`),i=h(t,i,r.stdout),D=h(t,D,r.stderr),r.exitCode!==0&&(L=r.exitCode)}return{stdout:i,stderr:D,exitCode:L}}catch(y){if(y instanceof _||y instanceof Y)throw y;return{stdout:"",stderr:`ls: ${s}: No such file or directory
|
|
20
|
-
`,exitCode:2}}}var ht={name:"ls",flags:[{flag:"-a",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-1",type:"boolean"}],needsFiles:!0};export{pt as a,ht as b};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{b as D}from"./chunk-CPKBPQ2C.js";import{a as N}from"./chunk-NE4R2FVV.js";import{a as H,b as A}from"./chunk-MUFNRCMY.js";var b=class{diff(e,n,t={}){let i;typeof t=="function"?(i=t,t={}):"callback"in t&&(i=t.callback);let d=this.castInput(e,t),o=this.castInput(n,t),s=this.removeEmpty(this.tokenize(d,t)),a=this.removeEmpty(this.tokenize(o,t));return this.diffWithOptionsObj(s,a,t,i)}diffWithOptionsObj(e,n,t,i){var d;let o=l=>{if(l=this.postProcess(l,t),i){setTimeout(function(){i(l)},0);return}else return l},s=n.length,a=e.length,u=1,r=s+a;t.maxEditLength!=null&&(r=Math.min(r,t.maxEditLength));let g=(d=t.timeout)!==null&&d!==void 0?d:1/0,w=Date.now()+g,m=[{oldPos:-1,lastComponent:void 0}],C=this.extractCommon(m[0],n,e,0,t);if(m[0].oldPos+1>=a&&C+1>=s)return o(this.buildValues(m[0].lastComponent,n,e));let P=-1/0,x=1/0,L=()=>{for(let l=Math.max(P,-u);l<=Math.min(x,u);l+=2){let c,h=m[l-1],p=m[l+1];h&&(m[l-1]=void 0);let y=!1;if(p){let S=p.oldPos-l;y=p&&0<=S&&S<s}let v=h&&h.oldPos+1<a;if(!y&&!v){m[l]=void 0;continue}if(!v||y&&h.oldPos<p.oldPos?c=this.addToPath(p,!0,!1,0,t):c=this.addToPath(h,!1,!0,1,t),C=this.extractCommon(c,n,e,l,t),c.oldPos+1>=a&&C+1>=s)return o(this.buildValues(c.lastComponent,n,e))||!0;m[l]=c,c.oldPos+1>=a&&(x=Math.min(x,l-1)),C+1>=s&&(P=Math.max(P,l+1))}u++};if(i)(function l(){setTimeout(function(){if(u>r||Date.now()>w)return i(void 0);L()||l()},0)})();else for(;u<=r&&Date.now()<=w;){let l=L();if(l)return l}}addToPath(e,n,t,i,d){let o=e.lastComponent;return o&&!d.oneChangePerToken&&o.added===n&&o.removed===t?{oldPos:e.oldPos+i,lastComponent:{count:o.count+1,added:n,removed:t,previousComponent:o.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:n,removed:t,previousComponent:o}}}extractCommon(e,n,t,i,d){let o=n.length,s=t.length,a=e.oldPos,u=a-i,r=0;for(;u+1<o&&a+1<s&&this.equals(t[a+1],n[u+1],d);)u++,a++,r++,d.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return r&&!d.oneChangePerToken&&(e.lastComponent={count:r,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,u}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let i=[],d;for(;e;)i.push(e),d=e.previousComponent,delete e.previousComponent,e=d;i.reverse();let o=i.length,s=0,a=0,u=0;for(;s<o;s++){let r=i[s];if(r.removed)r.value=this.join(t.slice(u,u+r.count)),u+=r.count;else{if(!r.added&&this.useLongestToken){let g=n.slice(a,a+r.count);g=g.map(function(w,m){let C=t[u+m];return C.length>w.length?C:w}),r.value=this.join(g)}else r.value=this.join(n.slice(a,a+r.count));a+=r.count,r.added||(u+=r.count)}}return i}};var I=class extends b{constructor(){super(...arguments),this.tokenize=W}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
|
|
4
|
-
`))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
|
|
5
|
-
`))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
|
|
6
|
-
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
7
|
-
`)&&(n=n.slice(0,-1))),super.equals(e,n,t)}},O=new I;function T(f,e,n){return O.diff(f,e,n)}function W(f,e){e.stripTrailingCr&&(f=f.replace(/\r\n/g,`
|
|
8
|
-
`));let n=[],t=f.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(let i=0;i<t.length;i++){let d=t[i];i%2&&!e.newlineIsToken?n[n.length-1]+=d:n.push(d)}return n}var j={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function F(f,e,n,t,i,d,o){let s;o?typeof o=="function"?s={callback:o}:s=o:s={},typeof s.context>"u"&&(s.context=4);let a=s.context;if(s.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(s.callback){let{callback:r}=s;T(n,t,Object.assign(Object.assign({},s),{callback:g=>{let w=u(g);r(w)}}))}else return u(T(n,t,s));function u(r){if(!r)return;r.push({value:"",lines:[]});function g(l){return l.map(function(c){return" "+c})}let w=[],m=0,C=0,P=[],x=1,L=1;for(let l=0;l<r.length;l++){let c=r[l],h=c.lines||R(c.value);if(c.lines=h,c.added||c.removed){if(!m){let p=r[l-1];m=x,C=L,p&&(P=a>0?g(p.lines.slice(-a)):[],m-=P.length,C-=P.length)}for(let p of h)P.push((c.added?"+":"-")+p);c.added?L+=h.length:x+=h.length}else{if(m)if(h.length<=a*2&&l<r.length-2)for(let p of g(h))P.push(p);else{let p=Math.min(h.length,a);for(let v of g(h.slice(0,p)))P.push(v);let y={oldStart:m,oldLines:x-m+p,newStart:C,newLines:L-C+p,lines:P};w.push(y),m=0,C=0,P=[]}x+=h.length,L+=h.length}}for(let l of w)for(let c=0;c<l.lines.length;c++)l.lines[c].endsWith(`
|
|
9
|
-
`)?l.lines[c]=l.lines[c].slice(0,-1):(l.lines.splice(c+1,0,"\"),c++);return{oldFileName:f,newFileName:e,oldHeader:i,newHeader:d,hunks:w}}}function E(f,e){if(e||(e=j),Array.isArray(f)){if(f.length>1&&!e.includeFileHeaders)throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return f.map(t=>E(t,e)).join(`
|
|
10
|
-
`)}let n=[];e.includeIndex&&f.oldFileName==f.newFileName&&n.push("Index: "+f.oldFileName),e.includeUnderline&&n.push("==================================================================="),e.includeFileHeaders&&(n.push("--- "+f.oldFileName+(typeof f.oldHeader>"u"?"":" "+f.oldHeader)),n.push("+++ "+f.newFileName+(typeof f.newHeader>"u"?"":" "+f.newHeader)));for(let t=0;t<f.hunks.length;t++){let i=f.hunks[t];i.oldLines===0&&(i.oldStart-=1),i.newLines===0&&(i.newStart-=1),n.push("@@ -"+i.oldStart+","+i.oldLines+" +"+i.newStart+","+i.newLines+" @@");for(let d of i.lines)n.push(d)}return n.join(`
|
|
11
|
-
`)+`
|
|
12
|
-
`}function k(f,e,n,t,i,d,o){if(typeof o=="function"&&(o={callback:o}),o?.callback){let{callback:s}=o;F(f,e,n,t,i,d,Object.assign(Object.assign({},o),{callback:a=>{s(a?E(a,o.headerOptions):void 0)}}))}else{let s=F(f,e,n,t,i,d,o);return s?E(s,o?.headerOptions):void 0}}function R(f){let e=f.endsWith(`
|
|
13
|
-
`),n=f.split(`
|
|
14
|
-
`).map(t=>t+`
|
|
15
|
-
`);return e?n.pop():n.push(n.pop().slice(0,-1)),n}var z={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},_={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},ee={name:"diff",async execute(f,e){if(A(f))return H(z);let n=N("diff",f,_);if(!n.ok)return n.error;let t=n.result.flags.brief,i=n.result.flags.reportSame,d=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
16
|
-
`,exitCode:2};let s,a,[u,r]=o;try{s=u==="-"?D(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
|
|
17
|
-
`,exitCode:2}}try{a=r==="-"?D(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,r))}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
18
|
-
`,exitCode:2}}let g=s,w=a;return d&&(g=g.toLowerCase(),w=w.toLowerCase()),g===w?i?{stdout:`Files ${u} and ${r} are identical
|
|
19
|
-
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:t?{stdout:`Files ${u} and ${r} differ
|
|
20
|
-
`,stderr:"",exitCode:1}:{stdout:k(u,r,s,a,"","",{context:3}),stderr:"",exitCode:1}}},ne={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{ee as a,ne as b};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{d as V}from"./chunk-I57EACSL.js";import{d as B}from"./chunk-NBTZL3VS.js";import{l as _,m as Y}from"./chunk-FUT3X2GJ.js";import{a as J}from"./chunk-CPKBPQ2C.js";import{a as Q}from"./chunk-NE4R2FVV.js";import{a as Z,b as q}from"./chunk-MUFNRCMY.js";function h(s,t,e){if(J(e)>s.limits.maxOutputSize-J(t))throw new _(`ls: output size limit exceeded (${s.limits.maxOutputSize} bytes)`,"output_size");return t+e}function X(s,t){let e=new V(s.limits.maxOutputSize,"ls");for(let l=0;l<t.length;l++)l>0&&e.append(`
|
|
4
|
-
`),e.append(t[l]);return t.length>0&&e.append(`
|
|
5
|
-
`),e.build()}function I(s){if(s<1024)return String(s);if(s<1024*1024){let e=s/1024;return e<10?`${e.toFixed(1)}K`:`${Math.round(e)}K`}if(s<1024*1024*1024){let e=s/1048576;return e<10?`${e.toFixed(1)}M`:`${Math.round(e)}M`}let t=s/(1024*1024*1024);return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function K(s){let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()],l=String(s.getDate()).padStart(2," "),p=new Date,g=new Date(p.getTime()-4320*60*60*1e3);if(s>g){let z=String(s.getHours()).padStart(2,"0"),d=String(s.getMinutes()).padStart(2,"0");return`${e} ${l} ${z}:${d}`}let b=s.getFullYear();return`${e} ${l} ${b}`}function W(s){return s.isDirectory?"/":s.isSymbolicLink?"@":(s.mode&73)!==0?"*":""}var nt={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-F, --classify append indicator (one of */=>@) to entries","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},ot={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},classifyFiles:{short:"F",long:"classify",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},pt={name:"ls",async execute(s,t){if(q(s))return Z(nt);let e=Q("ls",s,ot);if(!e.ok)return e.error;let l=e.result.flags.showAll,p=e.result.flags.showAlmostAll,g=e.result.flags.longFormat,b=e.result.flags.humanReadable,z=e.result.flags.recursive,d=e.result.flags.reverse,$=e.result.flags.classifyFiles,O=e.result.flags.directoryOnly,R=it(s,e.result.flags.sortBySize,e.result.flags.sortByTime);e.result.flags.onePerLine;let F=e.result.positional;F.length===0&&F.push(".");let S="",P="",C=0,M=new B({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"});if(O){for(let n of await G(F,t,R,d,M)){M.visit(0);let i=t.fs.resolvePath(t.cwd,n);try{let D=await t.fs.stat(i);if(g){let L=D.isDirectory?"drwxr-xr-x":"-rw-r--r--",c=$?W(await t.fs.lstat(i)):"",u=D.size??0,A=b?I(u).padStart(5):String(u).padStart(5),a=D.mtime??new Date(0),o=K(a);S=h(t,S,`${L} 1 user user ${A} ${o} ${n}${c}
|
|
6
|
-
`)}else{let L=$?W(await t.fs.lstat(i)):"";S=h(t,S,`${n}${L}
|
|
7
|
-
`)}}catch{P=h(t,P,`ls: cannot access '${n}': No such file or directory
|
|
8
|
-
`),C=2}}return{stdout:S,stderr:P,exitCode:C}}let m=[],y=[];for(let n of F){M.visit(0);try{((await t.fs.stat(t.fs.resolvePath(t.cwd,n))).isDirectory?y:m).push(n)}catch{P=h(t,P,`ls: ${n}: No such file or directory
|
|
9
|
-
`),C=2}}let T=async(n,i)=>{let D=await x(n,t,l,p,g,z,i,d,b,R,$,!1,M,0,new Set,!0);S=h(t,S,D.stdout),P=h(t,P,D.stderr),D.exitCode!==0&&(C=D.exitCode)};for(let n of await G(m,t,R,d,M))await T(n,!1);let N=F.length>1;for(let n of await G(y,t,R,d,M))S&&(S=h(t,S,`
|
|
10
|
-
`)),await T(n,N);return{stdout:S,stderr:P,exitCode:C}}};function it(s,t,e){if(!t&&!e)return"name";if(t!==e)return t?"size":"time";let l="name";for(let p of s){if(p==="--")break;if(!(!p.startsWith("-")||p.startsWith("--")))for(let g of p.slice(1))g==="S"?l="size":g==="t"&&(l="time")}return l}async function G(s,t,e,l,p){return await j(s,g=>t.fs.resolvePath(t.cwd,g),t,e,l,p)}async function j(s,t,e,l,p,g){let b=[...s];if(l==="name")b.sort();else{g?.checkpoint(b.length);let z=new Map;for(let d of b)try{let $=await e.fs.lstat(t(d));z.set(d,l==="size"?$.size??0:($.mtime??new Date(0)).getTime())}catch{z.set(d,0)}b.sort((d,$)=>{let O=(z.get($)??0)-(z.get(d)??0);return O!==0?O:d<$?-1:d>$?1:0})}return p&&b.reverse(),b}async function x(s,t,e,l,p,g,b,z=!1,d=!1,$="name",O=!1,R=!1,F=new B({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"}),S=0,P=new Set,C=!1){let M=e||l,m=t.fs.resolvePath(t.cwd,s);try{C||F.visit(S);let y=await t.fs.stat(m);if(!y.isDirectory){let c=O?W(await t.fs.lstat(m)):"";if(p){let u=y.size??0,A=d?I(u).padStart(5):String(u).padStart(5),a=y.mtime??new Date(0),o=K(a);return{stdout:`-rw-r--r-- 1 user user ${A} ${o} ${s}${c}
|
|
11
|
-
`,stderr:"",exitCode:0}}return{stdout:`${s}${c}
|
|
12
|
-
`,stderr:"",exitCode:0}}let T=y.identity??(y.dev!==void 0&&y.ino!==void 0?`${String(y.dev)}:${String(y.ino)}`:await t.fs.realpath(m).catch(()=>{}));if(T!==void 0&&P.has(T))return{stdout:"",stderr:`ls: ${s}: symbolic link cycle detected
|
|
13
|
-
`,exitCode:2};let N=new Set(P);T!==void 0&&N.add(T);let n=await t.fs.readdir(m);F.checkpoint(),M||(n=n.filter(c=>!c.startsWith("."))),n=await j(n,c=>m==="/"?`/${c}`:`${m}/${c}`,t,$,!1,F),e&&(n=[".","..",...n]),z&&n.reverse();let i="",D="",L=0;if((g||b)&&(i=h(t,i,`${s}:
|
|
14
|
-
`)),p){i=h(t,i,`total ${n.length}
|
|
15
|
-
`);let c=n.filter(o=>o==="."||o===".."),u=n.filter(o=>o!=="."&&o!=="..");for(let o of c)i=h(t,i,`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${o}
|
|
16
|
-
`);let A=[];for(let o=0;o<u.length;o+=100){let r=u.slice(o,o+100),f=await Promise.all(r.map(async v=>{let w=m==="/"?`/${v}`:`${m}/${v}`;try{let k=await t.fs.stat(w),H=k.isDirectory?"drwxr-xr-x":"-rw-r--r--",tt=O?W(await t.fs.lstat(w)):"",U=k.size??0,et=d?I(U).padStart(5):String(U).padStart(5),st=k.mtime??new Date(0),rt=K(st);return{name:v,line:`${H} 1 user user ${et} ${rt} ${v}${tt}
|
|
17
|
-
`}}catch{return{name:v,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${v}
|
|
18
|
-
`}}}));A.push(...f)}let a=new Map(u.map((o,r)=>[o,r]));A.sort((o,r)=>(a.get(o.name)??0)-(a.get(r.name)??0));for(let{line:o}of A)i=h(t,i,o)}else if(O){let c=[],u=n.filter(a=>a!=="."&&a!==".."),A=n.filter(a=>a==="."||a==="..");for(let a of A)c.push(`${a}/`);for(let a=0;a<u.length;a+=100){let o=u.slice(a,a+100),r=await Promise.all(o.map(async f=>{let v=m==="/"?`/${f}`:`${m}/${f}`;try{let w=await t.fs.lstat(v);return`${f}${W(w)}`}catch{return f}}));c.push(...r)}i=h(t,i,X(t,c))}else i=h(t,i,X(t,n));if(g){let c=n.filter(r=>r!=="."&&r!==".."),u=[];if(t.fs.readdirWithFileTypes)u=(await t.fs.readdirWithFileTypes(m)).filter(f=>f.isDirectory&&c.includes(f.name)).map(f=>({name:f.name,isDirectory:!0}));else for(let r=0;r<c.length;r+=100){let f=c.slice(r,r+100),v=await Promise.all(f.map(async w=>{let k=m==="/"?`/${w}`:`${m}/${w}`;try{let H=await t.fs.stat(k);return{name:w,isDirectory:H.isDirectory}}catch{return{name:w,isDirectory:!1}}}));u.push(...v.filter(w=>w.isDirectory))}let A=await j(u.map(r=>r.name),r=>m==="/"?`/${r}`:`${m}/${r}`,t,$,z,F),a=new Map(A.map((r,f)=>[r,f]));u.sort((r,f)=>(a.get(r.name)??0)-(a.get(f.name)??0));let o=[];for(let r=0;r<u.length;r+=100){let f=u.slice(r,r+100),v=await Promise.all(f.map(async w=>{let k=s==="."?`./${w.name}`:`${s}/${w.name}`,H=await x(k,t,e,l,p,g,!1,z,d,$,O,!0,F,S+1,N);return{name:w.name,result:H}}));o.push(...v)}o.sort((r,f)=>(a.get(r.name)??0)-(a.get(f.name)??0));for(let{result:r}of o)i=h(t,i,`
|
|
19
|
-
`),i=h(t,i,r.stdout),D=h(t,D,r.stderr),r.exitCode!==0&&(L=r.exitCode)}return{stdout:i,stderr:D,exitCode:L}}catch(y){if(y instanceof _||y instanceof Y)throw y;return{stdout:"",stderr:`ls: ${s}: No such file or directory
|
|
20
|
-
`,exitCode:2}}}var ht={name:"ls",flags:[{flag:"-a",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-1",type:"boolean"}],needsFiles:!0};export{pt as a,ht as b};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{d as V}from"./chunk-FTET43KM.js";import{d as B}from"./chunk-D5FHVW27.js";import{l as _,m as Y}from"./chunk-TVCZIH6M.js";import{a as J}from"./chunk-GN6CQ3J4.js";import{a as Q}from"./chunk-QIQMJJZ4.js";import{a as Z,b as q}from"./chunk-QAYAQNCG.js";function h(s,t,e){if(J(e)>s.limits.maxOutputSize-J(t))throw new _(`ls: output size limit exceeded (${s.limits.maxOutputSize} bytes)`,"output_size");return t+e}function X(s,t){let e=new V(s.limits.maxOutputSize,"ls");for(let l=0;l<t.length;l++)l>0&&e.append(`
|
|
3
|
-
`),e.append(t[l]);return t.length>0&&e.append(`
|
|
4
|
-
`),e.build()}function I(s){if(s<1024)return String(s);if(s<1024*1024){let e=s/1024;return e<10?`${e.toFixed(1)}K`:`${Math.round(e)}K`}if(s<1024*1024*1024){let e=s/1048576;return e<10?`${e.toFixed(1)}M`:`${Math.round(e)}M`}let t=s/(1024*1024*1024);return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function K(s){let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()],l=String(s.getDate()).padStart(2," "),p=new Date,g=new Date(p.getTime()-4320*60*60*1e3);if(s>g){let z=String(s.getHours()).padStart(2,"0"),d=String(s.getMinutes()).padStart(2,"0");return`${e} ${l} ${z}:${d}`}let b=s.getFullYear();return`${e} ${l} ${b}`}function W(s){return s.isDirectory?"/":s.isSymbolicLink?"@":(s.mode&73)!==0?"*":""}var nt={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-F, --classify append indicator (one of */=>@) to entries","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},ot={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},classifyFiles:{short:"F",long:"classify",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},pt={name:"ls",async execute(s,t){if(q(s))return Z(nt);let e=Q("ls",s,ot);if(!e.ok)return e.error;let l=e.result.flags.showAll,p=e.result.flags.showAlmostAll,g=e.result.flags.longFormat,b=e.result.flags.humanReadable,z=e.result.flags.recursive,d=e.result.flags.reverse,$=e.result.flags.classifyFiles,O=e.result.flags.directoryOnly,R=it(s,e.result.flags.sortBySize,e.result.flags.sortByTime);e.result.flags.onePerLine;let F=e.result.positional;F.length===0&&F.push(".");let S="",P="",C=0,M=new B({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"});if(O){for(let n of await G(F,t,R,d,M)){M.visit(0);let i=t.fs.resolvePath(t.cwd,n);try{let D=await t.fs.stat(i);if(g){let L=D.isDirectory?"drwxr-xr-x":"-rw-r--r--",c=$?W(await t.fs.lstat(i)):"",u=D.size??0,A=b?I(u).padStart(5):String(u).padStart(5),a=D.mtime??new Date(0),o=K(a);S=h(t,S,`${L} 1 user user ${A} ${o} ${n}${c}
|
|
5
|
-
`)}else{let L=$?W(await t.fs.lstat(i)):"";S=h(t,S,`${n}${L}
|
|
6
|
-
`)}}catch{P=h(t,P,`ls: cannot access '${n}': No such file or directory
|
|
7
|
-
`),C=2}}return{stdout:S,stderr:P,exitCode:C}}let m=[],y=[];for(let n of F){M.visit(0);try{((await t.fs.stat(t.fs.resolvePath(t.cwd,n))).isDirectory?y:m).push(n)}catch{P=h(t,P,`ls: ${n}: No such file or directory
|
|
8
|
-
`),C=2}}let T=async(n,i)=>{let D=await x(n,t,l,p,g,z,i,d,b,R,$,!1,M,0,new Set,!0);S=h(t,S,D.stdout),P=h(t,P,D.stderr),D.exitCode!==0&&(C=D.exitCode)};for(let n of await G(m,t,R,d,M))await T(n,!1);let N=F.length>1;for(let n of await G(y,t,R,d,M))S&&(S=h(t,S,`
|
|
9
|
-
`)),await T(n,N);return{stdout:S,stderr:P,exitCode:C}}};function it(s,t,e){if(!t&&!e)return"name";if(t!==e)return t?"size":"time";let l="name";for(let p of s){if(p==="--")break;if(!(!p.startsWith("-")||p.startsWith("--")))for(let g of p.slice(1))g==="S"?l="size":g==="t"&&(l="time")}return l}async function G(s,t,e,l,p){return await j(s,g=>t.fs.resolvePath(t.cwd,g),t,e,l,p)}async function j(s,t,e,l,p,g){let b=[...s];if(l==="name")b.sort();else{g?.checkpoint(b.length);let z=new Map;for(let d of b)try{let $=await e.fs.lstat(t(d));z.set(d,l==="size"?$.size??0:($.mtime??new Date(0)).getTime())}catch{z.set(d,0)}b.sort((d,$)=>{let O=(z.get($)??0)-(z.get(d)??0);return O!==0?O:d<$?-1:d>$?1:0})}return p&&b.reverse(),b}async function x(s,t,e,l,p,g,b,z=!1,d=!1,$="name",O=!1,R=!1,F=new B({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"}),S=0,P=new Set,C=!1){let M=e||l,m=t.fs.resolvePath(t.cwd,s);try{C||F.visit(S);let y=await t.fs.stat(m);if(!y.isDirectory){let c=O?W(await t.fs.lstat(m)):"";if(p){let u=y.size??0,A=d?I(u).padStart(5):String(u).padStart(5),a=y.mtime??new Date(0),o=K(a);return{stdout:`-rw-r--r-- 1 user user ${A} ${o} ${s}${c}
|
|
10
|
-
`,stderr:"",exitCode:0}}return{stdout:`${s}${c}
|
|
11
|
-
`,stderr:"",exitCode:0}}let T=y.identity??(y.dev!==void 0&&y.ino!==void 0?`${String(y.dev)}:${String(y.ino)}`:await t.fs.realpath(m).catch(()=>{}));if(T!==void 0&&P.has(T))return{stdout:"",stderr:`ls: ${s}: symbolic link cycle detected
|
|
12
|
-
`,exitCode:2};let N=new Set(P);T!==void 0&&N.add(T);let n=await t.fs.readdir(m);F.checkpoint(),M||(n=n.filter(c=>!c.startsWith("."))),n=await j(n,c=>m==="/"?`/${c}`:`${m}/${c}`,t,$,!1,F),e&&(n=[".","..",...n]),z&&n.reverse();let i="",D="",L=0;if((g||b)&&(i=h(t,i,`${s}:
|
|
13
|
-
`)),p){i=h(t,i,`total ${n.length}
|
|
14
|
-
`);let c=n.filter(o=>o==="."||o===".."),u=n.filter(o=>o!=="."&&o!=="..");for(let o of c)i=h(t,i,`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${o}
|
|
15
|
-
`);let A=[];for(let o=0;o<u.length;o+=100){let r=u.slice(o,o+100),f=await Promise.all(r.map(async v=>{let w=m==="/"?`/${v}`:`${m}/${v}`;try{let k=await t.fs.stat(w),H=k.isDirectory?"drwxr-xr-x":"-rw-r--r--",tt=O?W(await t.fs.lstat(w)):"",U=k.size??0,et=d?I(U).padStart(5):String(U).padStart(5),st=k.mtime??new Date(0),rt=K(st);return{name:v,line:`${H} 1 user user ${et} ${rt} ${v}${tt}
|
|
16
|
-
`}}catch{return{name:v,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${v}
|
|
17
|
-
`}}}));A.push(...f)}let a=new Map(u.map((o,r)=>[o,r]));A.sort((o,r)=>(a.get(o.name)??0)-(a.get(r.name)??0));for(let{line:o}of A)i=h(t,i,o)}else if(O){let c=[],u=n.filter(a=>a!=="."&&a!==".."),A=n.filter(a=>a==="."||a==="..");for(let a of A)c.push(`${a}/`);for(let a=0;a<u.length;a+=100){let o=u.slice(a,a+100),r=await Promise.all(o.map(async f=>{let v=m==="/"?`/${f}`:`${m}/${f}`;try{let w=await t.fs.lstat(v);return`${f}${W(w)}`}catch{return f}}));c.push(...r)}i=h(t,i,X(t,c))}else i=h(t,i,X(t,n));if(g){let c=n.filter(r=>r!=="."&&r!==".."),u=[];if(t.fs.readdirWithFileTypes)u=(await t.fs.readdirWithFileTypes(m)).filter(f=>f.isDirectory&&c.includes(f.name)).map(f=>({name:f.name,isDirectory:!0}));else for(let r=0;r<c.length;r+=100){let f=c.slice(r,r+100),v=await Promise.all(f.map(async w=>{let k=m==="/"?`/${w}`:`${m}/${w}`;try{let H=await t.fs.stat(k);return{name:w,isDirectory:H.isDirectory}}catch{return{name:w,isDirectory:!1}}}));u.push(...v.filter(w=>w.isDirectory))}let A=await j(u.map(r=>r.name),r=>m==="/"?`/${r}`:`${m}/${r}`,t,$,z,F),a=new Map(A.map((r,f)=>[r,f]));u.sort((r,f)=>(a.get(r.name)??0)-(a.get(f.name)??0));let o=[];for(let r=0;r<u.length;r+=100){let f=u.slice(r,r+100),v=await Promise.all(f.map(async w=>{let k=s==="."?`./${w.name}`:`${s}/${w.name}`,H=await x(k,t,e,l,p,g,!1,z,d,$,O,!0,F,S+1,N);return{name:w.name,result:H}}));o.push(...v)}o.sort((r,f)=>(a.get(r.name)??0)-(a.get(f.name)??0));for(let{result:r}of o)i=h(t,i,`
|
|
18
|
-
`),i=h(t,i,r.stdout),D=h(t,D,r.stderr),r.exitCode!==0&&(L=r.exitCode)}return{stdout:i,stderr:D,exitCode:L}}catch(y){if(y instanceof _||y instanceof Y)throw y;return{stdout:"",stderr:`ls: ${s}: No such file or directory
|
|
19
|
-
`,exitCode:2}}}var ht={name:"ls",flags:[{flag:"-a",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-1",type:"boolean"}],needsFiles:!0};export{pt as a,ht as b};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{d as a}from"./chunk-GN6CQ3J4.js";import{a as c}from"./chunk-QIQMJJZ4.js";import{a as u,b as p}from"./chunk-QAYAQNCG.js";import*as g from"diff";var b={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},C={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},L={name:"diff",async execute(d,e){if(p(d))return u(b);let t=c("diff",d,C);if(!t.ok)return t.error;let m=t.result.flags.brief,h=t.result.flags.reportSame,y=t.result.flags.ignoreCase,l=t.result.positional;if(t.result.flags.unified,l.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
3
|
-
`,exitCode:2};let i,s,[r,o]=l;try{i=r==="-"?a(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,r))}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
4
|
-
`,exitCode:2}}try{s=o==="-"?a(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,o))}catch{return{stdout:"",stderr:`diff: ${o}: No such file or directory
|
|
5
|
-
`,exitCode:2}}let f=i,n=s;return y&&(f=f.toLowerCase(),n=n.toLowerCase()),f===n?h?{stdout:`Files ${r} and ${o} are identical
|
|
6
|
-
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:m?{stdout:`Files ${r} and ${o} differ
|
|
7
|
-
`,stderr:"",exitCode:1}:{stdout:g.createTwoFilesPatch(r,o,i,s,"","",{context:3}),stderr:"",exitCode:1}}},P={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{L as a,P as b};
|