@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# just-bash
|
|
2
2
|
|
|
3
|
+
## 3.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`00e40f9`](https://github.com/JerryAZR/just-bash/commit/00e40f927dfa0c6b77cadf063be094282ced2a5a) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Add `diff -r` (recursive directory comparison), `diff -rq` (brief recursive), and `diff -N` (treat absent files as empty). No new dependencies.
|
|
8
|
+
|
|
9
|
+
- [`00e40f9`](https://github.com/JerryAZR/just-bash/commit/00e40f927dfa0c6b77cadf063be094282ced2a5a) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Expose `maxJsMemoryBytes` in `ExecutionLimits` — the QuickJS heap limit (default 64MB) is now configurable per Bash instance. This is the only real cap on js-exec read/write sizes.
|
|
10
|
+
|
|
11
|
+
- [`00e40f9`](https://github.com/JerryAZR/just-bash/commit/00e40f927dfa0c6b77cadf063be094282ced2a5a) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Add `readOnly` option to `VfsTemplateOptions` — when true, all fork overlay mounts are read-only (EROFS on writes).
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`00e40f9`](https://github.com/JerryAZR/just-bash/commit/00e40f927dfa0c6b77cadf063be094282ced2a5a) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Fix a class of CI failures where js-exec guest output was lost: loop `executePendingJobs()` until all QuickJS jobs drain, not just the first batch.
|
|
16
|
+
|
|
17
|
+
## 3.8.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [`30e7df8`](https://github.com/JerryAZR/just-bash/commit/30e7df8689f93409d50702df49f9dc5da1484d1c) Thanks [@trieloff](https://github.com/trieloff)! - `diff` now defaults to POSIX normal format (`2c2` / `<` / `---` / `>`) instead of unified, matching GNU diffutils and POSIX. **This changes the default output and will break anything parsing the previous unified-by-default output** — pass `-u` to keep unified.
|
|
22
|
+
|
|
23
|
+
Previously `-u` was parsed and discarded, `createTwoFilesPatch` was the only output path, and every invocation was prefixed with jsdiff's 67-character `===...===` banner, which is not valid output in any GNU format. Normal format was unreachable by any flag, so `diff a b | grep '^<'` — the canonical "lines only in A" idiom — silently matched nothing and exited cleanly on files that differ.
|
|
24
|
+
|
|
25
|
+
- `-u` / `--unified` now selects unified format, and `--normal` selects the default explicitly.
|
|
26
|
+
- New `-c` / `--context` for context format (`*** ` / `--- ` / `***************` / `! `).
|
|
27
|
+
- New `--version`.
|
|
28
|
+
- The `===` banner is gone from every format. The `-u` / `-c` file headers carry no timestamp, so output is reproducible; GNU puts each file's mtime there.
|
|
29
|
+
- Filenames in `-u` / `-c` headers are quoted and escaped as GNU does, so a filename containing a newline can no longer forge header or `@@` lines in the emitted patch.
|
|
30
|
+
- Two output styles at once (for example `diff -u -c`) is now an error, as in GNU: `diff: conflicting output style options`, exit 2.
|
|
31
|
+
- `` is reported in all three formats.
|
|
32
|
+
|
|
33
|
+
`-q`, `-s`, `-i`, `-` for stdin, and the exit codes are unchanged.
|
|
34
|
+
|
|
35
|
+
Hunk selection is unchanged: where several equally minimal edit scripts exist, just-bash may group ambiguous changes differently than GNU. The output is always a correct, equally minimal patch, but the `NcN` line numbers can differ on such inputs.
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [`fa769ce`](https://github.com/JerryAZR/just-bash/commit/fa769ce277a6f1e137e5751082d7a84ab5e0badc) Thanks [@trieloff](https://github.com/trieloff)! - interpreter: give a bare assignment exit status 0 instead of the previous command's
|
|
40
|
+
|
|
41
|
+
A command with no command word — `x=1`, `arr=(a b)`, `> file`, a `$empty` that expands to nothing — reported whatever `$?` already held rather than success. Bash gives such a command status 0 unless a command substitution ran while expanding it.
|
|
42
|
+
|
|
43
|
+
The leak is invisible until something reads `$?`, and an `else` branch is where it bites: the branch runs with `$?` set to 1 by the condition that just failed, so an `else` branch ending in an assignment made the whole `if` report failure. Under `set -e` that ended the script with no output and no diagnostic:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
set -e
|
|
47
|
+
if false; then :; else x=1; fi
|
|
48
|
+
echo done # never ran
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
A command substitution still sets the status where bash says it does. It counts from an assigned value or a redirection word, assignments expanded first and the last substitution winning: `x=$(exit 7)` is 7, `> /dev/null$(exit 5)` is 5, and `x=$(exit 7) > /dev/null$(exit 5)` is 5. A redirection onto fd 0 discards it and reports 0, matching bash 5.x, which forks a child to perform such a command's redirections. Process substitution never contributes, and neither does a command substitution in `PS4` under `set -x`.
|
|
52
|
+
|
|
53
|
+
- [`e6ae113`](https://github.com/JerryAZR/just-bash/commit/e6ae113b4dccbf7877028257511b19a52b0ddc78) Thanks [@mutewinter](https://github.com/mutewinter)! - Report gzip files from their header instead of inflating them. `file` no longer enters `file-type`'s nested gzip probe, which decompressed up to 16 MB of input to look for an inner tar and leaked an `AbortError` unhandled rejection after the command had already returned. Gzipped tar archives now read as `gzip compressed data` rather than `gzip archive data`, matching `file`.
|
|
54
|
+
|
|
55
|
+
- [`689d409`](https://github.com/JerryAZR/just-bash/commit/689d409f3de2cee192cac6afbe13df89328f6eb4) Thanks [@taoche](https://github.com/taoche)! - Run lazy file providers in the defense-in-depth trusted scope during materialization. Host-supplied providers doing real async I/O (`setTimeout`, `fetch`, `process.env`) previously tripped the blocked-globals traps when a script first read the file mid-exec, surfacing as a `SecurityViolationError` (formerly a silent empty read / ENOENT). Fixes [#253](https://github.com/JerryAZR/just-bash/issues/253).
|
|
56
|
+
|
|
57
|
+
- [`68f6984`](https://github.com/JerryAZR/just-bash/commit/68f69840ef018f7a0df0964b086b8d2403ad8abe) Thanks [@trieloff](https://github.com/trieloff)! - Bound `ls` directory entry collections before per-entry work. A filesystem backend returning a very large directory could previously drive `ls` into sorting, statting, classifying and formatting every entry before any limit applied, and piping to `head` did not help because pipeline producers are materialized before consumers run. Oversized listings now fail with exit code 126 (`array element limit exceeded` / `filesystem traversal entry limit exceeded`), the recursive descent no longer fans out across sibling directories, and every operand of a multi-directory listing is charged to the same budget.
|
|
58
|
+
|
|
59
|
+
- [`04dad0d`](https://github.com/JerryAZR/just-bash/commit/04dad0dcbdb90622587eb1273080286a2a4cd4b7) Thanks [@taoche](https://github.com/taoche)! - regex: cache compiled RE2 patterns across `UserRegex` constructions
|
|
60
|
+
|
|
61
|
+
Every `createUserRegex()` call recompiled its pattern from source
|
|
62
|
+
(`translateRegExp` → parse → simplify → compile). Commands that build a
|
|
63
|
+
`UserRegex` inside a per-row loop therefore recompiled the same pattern once per
|
|
64
|
+
row: jq's `test`/`match`/`capture`/`scan`/`splits`/`sub`/`gsub`, awk's `~`/`!~`
|
|
65
|
+
and `sub`/`gsub`/`match`/`split`, and sed's `s///` (which compiled the same
|
|
66
|
+
pattern twice per line for the `g` and Nth-occurrence paths). Compiling costs
|
|
67
|
+
~23µs against ~1.5µs to match with an already-compiled pattern, so compilation
|
|
68
|
+
dominated these workloads.
|
|
69
|
+
|
|
70
|
+
Compiled patterns are now memoized in a 256-entry cache keyed on the pattern and
|
|
71
|
+
the RE2 flags, mirroring the existing glob regex cache in `src/utils/glob.ts`.
|
|
72
|
+
Patterns longer than 1024 characters are compiled but not retained, bounding the
|
|
73
|
+
cache's retained pattern source at 256 KiB. Only the compiled pattern is shared — `lastIndex`, the reusable matcher, result
|
|
74
|
+
limits and the abort signal stay per-instance, so matching semantics are
|
|
75
|
+
unchanged. Over 100k rows: jq `test()` 8.96s → 4.26s, awk `~` 4.15s → 2.55s,
|
|
76
|
+
awk `gsub` 7.16s → 6.10s, sed `s///g` 10.46s → 8.29s. Commands that already
|
|
77
|
+
hoisted compilation out of their loop (grep, rg) are unaffected.
|
|
78
|
+
|
|
79
|
+
- [`3820a66`](https://github.com/JerryAZR/just-bash/commit/3820a660b692c9e9638d8c88cb713b43691cdc02) Thanks [@JerryAZR](https://github.com/JerryAZR)! - Replace the custom js-exec QuickJS worker with run, using synchronous host bindings and native module loading while preserving filesystem, tools, process, fetch, output-limit, and cancellation behavior. Keep queue admission inside the JavaScript deadline, restore argv-only `spawnSync` execution, top-level-await module detection, optional tool exposure, and the historical 8 MiB per-call bridge ceiling. Make the aggregate bridge request ceiling configurable, bound filesystem and module reads before allocation, preserve module-loader and bootstrap diagnostics, and enforce source, generated guest configuration, and combined-output byte limits without allowing `process.exit()` to clear limit failures. Preserve binary `Buffer` filesystem writes and the `ArrayBuffer` filesystem contract, project command results before they cross into the guest, gate bootstrap-only host behavior to the bootstrap phase, parse guest stacks with bounded linear work, redact runtime stack paths, and forward cancellation through the companion executor into inline tool contexts and SDK Effect execution.
|
|
80
|
+
|
|
3
81
|
## 3.7.0
|
|
4
82
|
|
|
5
83
|
### Minor Changes
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a,b}from"./chunk-
|
|
3
|
+
import{a,b}from"./chunk-ZVG47PYA.js";import"./chunk-MROECM42.js";import"./chunk-42AMF6EE.js";import"./chunk-YXPSX3SI.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import"./chunk-YERKK5B3.js";import"./chunk-I57EACSL.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as awkCommand2,b as flagsForFuzzing};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a,b}from"./chunk-
|
|
3
|
+
import{a,b}from"./chunk-T6OIISUC.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import"./chunk-I57EACSL.js";import"./chunk-MBREBDZQ.js";import"./chunk-HWK7KFGB.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as chmodCommand,b as flagsForFuzzing};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{d as C}from"./chunk-
|
|
3
|
+
import{d as C}from"./chunk-MBREBDZQ.js";import{a as g}from"./chunk-NE4R2FVV.js";import{a as v}from"./chunk-I4IRHQDW.js";var y=`Usage: rmdir [-pv] DIRECTORY...
|
|
4
4
|
Remove empty directories.
|
|
5
5
|
|
|
6
6
|
Options:
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
import{d as X}from"./chunk-I57EACSL.js";import{d as I}from"./chunk-MBREBDZQ.js";import{l as W,m as Z}from"./chunk-FUT3X2GJ.js";import{a as G}from"./chunk-CPKBPQ2C.js";import{a as V}from"./chunk-NE4R2FVV.js";import{a as q,b as Q}from"./chunk-MUFNRCMY.js";function h(s,t,e){if(G(e)>s.limits.maxOutputSize-G(t))throw new W(`ls: output size limit exceeded (${s.limits.maxOutputSize} bytes)`,"output_size");return t+e}function tt(s,t){if(t>s.limits.maxArrayElements)throw new W(`ls: array element limit exceeded (${s.limits.maxArrayElements})`,"array_elements")}function ot(s,t,e){tt(s,e),t.reserve(e)}function x(s,t){let e=new X(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 j(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 B(s){let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][s.getMonth()],l=String(s.getDate()).padStart(2," "),m=new Date,g=new Date(m.getTime()-4320*60*60*1e3);if(s>g){let D=String(s.getHours()).padStart(2,"0"),u=String(s.getMinutes()).padStart(2,"0");return`${e} ${l} ${D}:${u}`}let b=s.getFullYear();return`${e} ${l} ${b}`}function H(s){return s.isDirectory?"/":s.isSymbolicLink?"@":(s.mode&73)!==0?"*":""}var it={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"]},at={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"}},gt={name:"ls",async execute(s,t){if(Q(s))return q(it);let e=V("ls",s,at);if(!e.ok)return e.error;let l=e.result.flags.showAll,m=e.result.flags.showAlmostAll,g=e.result.flags.longFormat,b=e.result.flags.humanReadable,D=e.result.flags.recursive,u=e.result.flags.reverse,w=e.result.flags.classifyFiles,P=e.result.flags.directoryOnly,R=lt(s,e.result.flags.sortBySize,e.result.flags.sortByTime);e.result.flags.onePerLine;let z=e.result.positional;z.length===0&&z.push(".");let $="",E="",C=0,O=new I({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"});if(P){for(let n of await K(z,t,R,u,O)){O.visit(0);let i=t.fs.resolvePath(t.cwd,n);try{let v=await t.fs.stat(i);if(g){let L=v.isDirectory?"drwxr-xr-x":"-rw-r--r--",c=w?H(await t.fs.lstat(i)):"",S=v.size??0,y=b?j(S).padStart(5):String(S).padStart(5),f=v.mtime??new Date(0),o=B(f);$=h(t,$,`${L} 1 user user ${y} ${o} ${n}${c}
|
|
6
|
+
`)}else{let L=w?H(await t.fs.lstat(i)):"";$=h(t,$,`${n}${L}
|
|
7
|
+
`)}}catch{E=h(t,E,`ls: cannot access '${n}': No such file or directory
|
|
8
|
+
`),C=2}}return{stdout:$,stderr:E,exitCode:C}}let d=[],p=[];for(let n of z){O.visit(0);try{(await t.fs.stat(t.fs.resolvePath(t.cwd,n))).isDirectory?(p.length>0&&O.reserve(1),p.push(n)):d.push(n)}catch{E=h(t,E,`ls: ${n}: No such file or directory
|
|
9
|
+
`),C=2}}let k=async(n,i)=>{let v=await et(n,t,l,m,g,D,i,u,b,R,w,!1,O,0,new Set,!0);$=h(t,$,v.stdout),E=h(t,E,v.stderr),v.exitCode!==0&&(C=v.exitCode)};for(let n of await K(d,t,R,u,O))await k(n,!1);let N=z.length>1;for(let n of await K(p,t,R,u,O))$&&($=h(t,$,`
|
|
10
|
+
`)),await k(n,N);return{stdout:$,stderr:E,exitCode:C}}};function lt(s,t,e){if(!t&&!e)return"name";if(t!==e)return t?"size":"time";let l="name";for(let m of s){if(m==="--")break;if(!(!m.startsWith("-")||m.startsWith("--")))for(let g of m.slice(1))g==="S"?l="size":g==="t"&&(l="time")}return l}async function K(s,t,e,l,m){return await U(s,g=>t.fs.resolvePath(t.cwd,g),t,e,l,m)}async function U(s,t,e,l,m,g){let b=[...s];if(l==="name")b.sort();else{g?.checkpoint(b.length);let D=new Map;for(let u of b)try{let w=await e.fs.lstat(t(u));D.set(u,l==="size"?w.size??0:(w.mtime??new Date(0)).getTime())}catch{D.set(u,0)}b.sort((u,w)=>{let P=(D.get(w)??0)-(D.get(u)??0);return P!==0?P:u<w?-1:u>w?1:0})}return m&&b.reverse(),b}async function et(s,t,e,l,m,g,b,D=!1,u=!1,w="name",P=!1,R=!1,z=new I({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"}),$=0,E=new Set,C=!1){let O=e||l,d=t.fs.resolvePath(t.cwd,s);try{C||z.visit($);let p=await t.fs.stat(d);if(!p.isDirectory){let c=P?H(await t.fs.lstat(d)):"";if(m){let S=p.size??0,y=u?j(S).padStart(5):String(S).padStart(5),f=p.mtime??new Date(0),o=B(f);return{stdout:`-rw-r--r-- 1 user user ${y} ${o} ${s}${c}
|
|
11
|
+
`,stderr:"",exitCode:0}}return{stdout:`${s}${c}
|
|
12
|
+
`,stderr:"",exitCode:0}}let k=p.identity??(p.dev!==void 0&&p.ino!==void 0?`${String(p.dev)}:${String(p.ino)}`:await t.fs.realpath(d).catch(()=>{}));if(k!==void 0&&E.has(k))return{stdout:"",stderr:`ls: ${s}: symbolic link cycle detected
|
|
13
|
+
`,exitCode:2};let N=new Set(E);k!==void 0&&N.add(k);let n=await t.fs.readdir(d);z.checkpoint(),ot(t,z,n.length+(e?2:0)),O||(n=n.filter(c=>!c.startsWith("."))),n=await U(n,c=>d==="/"?`/${c}`:`${d}/${c}`,t,w,!1,z),e&&(n=[".","..",...n]),D&&n.reverse();let i="",v="",L=0;if((g||b)&&(i=h(t,i,`${s}:
|
|
14
|
+
`)),m){i=h(t,i,`total ${n.length}
|
|
15
|
+
`);let c=n.filter(o=>o==="."||o===".."),S=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 y=[];for(let o=0;o<S.length;o+=100){let F=S.slice(o,o+100),r=await Promise.all(F.map(async a=>{let M=d==="/"?`/${a}`:`${d}/${a}`;try{let A=await t.fs.stat(M),J=A.isDirectory?"drwxr-xr-x":"-rw-r--r--",_=P?H(await t.fs.lstat(M)):"",Y=A.size??0,st=u?j(Y).padStart(5):String(Y).padStart(5),rt=A.mtime??new Date(0),nt=B(rt);return{name:a,line:`${J} 1 user user ${st} ${nt} ${a}${_}
|
|
17
|
+
`}}catch{return{name:a,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${a}
|
|
18
|
+
`}}}));y.push(...r)}let f=new Map(S.map((o,F)=>[o,F]));y.sort((o,F)=>(f.get(o.name)??0)-(f.get(F.name)??0));for(let{line:o}of y)i=h(t,i,o)}else if(P){let c=[],S=n.filter(f=>f!=="."&&f!==".."),y=n.filter(f=>f==="."||f==="..");for(let f of y)c.push(`${f}/`);for(let f=0;f<S.length;f+=100){let o=S.slice(f,f+100),F=await Promise.all(o.map(async r=>{let a=d==="/"?`/${r}`:`${d}/${r}`;try{let M=await t.fs.lstat(a);return`${r}${H(M)}`}catch{return r}}));c.push(...F)}i=h(t,i,x(t,c))}else i=h(t,i,x(t,n));if(g){let c=n.filter(r=>r!=="."&&r!==".."),S=new Set(c),y=[];if(t.fs.readdirWithFileTypes){let r=await t.fs.readdirWithFileTypes(d);z.checkpoint(),tt(t,r.length),y=r.filter(a=>a.isDirectory&&S.has(a.name)).map(a=>({name:a.name,isDirectory:!0}))}else for(let r=0;r<c.length;r+=100){let a=c.slice(r,r+100),M=await Promise.all(a.map(async A=>{let J=d==="/"?`/${A}`:`${d}/${A}`;try{let _=await t.fs.stat(J);return{name:A,isDirectory:_.isDirectory}}catch{return{name:A,isDirectory:!1}}}));y.push(...M.filter(A=>A.isDirectory))}let f=await U(y.map(r=>r.name),r=>d==="/"?`/${r}`:`${d}/${r}`,t,w,D,z),o=new Map(f.map((r,a)=>[r,a]));y.sort((r,a)=>(o.get(r.name)??0)-(o.get(a.name)??0));let F=[];for(let r of y){let a=s==="."?`./${r.name}`:`${s}/${r.name}`,M=await et(a,t,e,l,m,g,!1,D,u,w,P,!0,z,$+1,N);F.push({name:r.name,result:M})}F.sort((r,a)=>(o.get(r.name)??0)-(o.get(a.name)??0));for(let{result:r}of F)i=h(t,i,`
|
|
19
|
+
`),i=h(t,i,r.stdout),v=h(t,v,r.stderr),r.exitCode!==0&&(L=r.exitCode)}return{stdout:i,stderr:v,exitCode:L}}catch(p){if(p instanceof W||p instanceof Z)throw p;return{stdout:"",stderr:`ls: ${s}: No such file or directory
|
|
20
|
+
`,exitCode:2}}}var yt={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{gt as a,yt as b};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as W}from"./chunk-3DWQCLNP.js";import{c as $}from"./chunk-42AMF6EE.js";import{b as C}from"./chunk-HWI42GQO.js";import{a as V}from"./chunk-
|
|
3
|
+
import{a as W}from"./chunk-3DWQCLNP.js";import{c as $}from"./chunk-42AMF6EE.js";import{b as C}from"./chunk-HWI42GQO.js";import{a as V}from"./chunk-MBREBDZQ.js";import{b as I}from"./chunk-CPKBPQ2C.js";import{a as B,b}from"./chunk-PBOVSFTJ.js";import{a as x}from"./chunk-I4IRHQDW.js";import{a as N,b as R}from"./chunk-MUFNRCMY.js";import{existsSync as ce}from"node:fs";import{dirname as de,join as T,sep as Q}from"node:path";import{fileURLToPath as me}from"node:url";import{Worker as he}from"node:worker_threads";import pe from"sql.js";function K(e,t){return e==null?Buffer.byteLength(t,"utf8"):e instanceof Uint8Array||Buffer.isBuffer(e)?e.byteLength:Buffer.byteLength(String(e),"utf8")}function X(e,t,r){let n=r.maxOutputSize??Number.MAX_SAFE_INTEGER,s=Buffer.byteLength(r.separator,"utf8");s+=Buffer.byteLength(r.newline,"utf8");for(let a of e)s+=Buffer.byteLength(a,"utf8");for(let a of t){s+=a.length*16;for(let i of a)s+=K(i,r.nullValue);if(s>n)break}let o=s*8+(t.length+3)*(e.length+3)*16;if(!Number.isSafeInteger(o)||o>n)throw new Error(`formatted output exceeds ${n} byte limit`);return n}function _(e,t,r){let n=X(e,t,r),s;switch(r.mode){case"list":s=Y(e,t,r);break;case"csv":s=Z(e,t,r);break;case"json":s=te(e,t);break;case"line":s=re(e,t,r);break;case"column":s=ne(e,t,r);break;case"table":s=se(e,t,r);break;case"markdown":s=oe(e,t,r);break;case"tabs":s=ie(e,t,r);break;case"box":s=ae(e,t,r);break;case"quote":s=le(e,t,r);break;case"html":s=fe(e,t,r);break;case"ascii":s=ue(e,t,r);break}if(Buffer.byteLength(s,"utf8")>n)throw new Error(`formatted output exceeds ${n} byte limit`);return s}function m(e,t){return e==null?t:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="number"&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,""):String(e)}function Y(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.join(r.separator));for(let s of t)n.push(s.map(o=>m(o,r.nullValue)).join(r.separator));return n.length>0?`${n.join(r.newline)}${r.newline}`:""}function Z(e,t,r){let n=[];r.header&&e.length>0&&n.push(e.map(v).join(","));for(let s of t)n.push(s.map(o=>v(m(o,r.nullValue))).join(","));return n.length>0?`${n.join(`
|
|
4
4
|
`)}
|
|
5
5
|
`:""}function v(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
|
|
6
6
|
`)?`"${e.replace(/"/g,'""')}"`:e}function F(e){return e.toPrecision(17).replace(/\.?0+$/,"")}function ee(e){return e===null?"null":typeof e=="number"?Number.isInteger(e)?String(e):F(e):JSON.stringify(e)}function te(e,t){return t.length===0?"":`[${t.map(n=>`{${e.map((o,a)=>`${JSON.stringify(o)}:${ee(n[a])}`).join(",")}}`).join(`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{b as P,c as O,d as T,e as k}from"./chunk-
|
|
3
|
+
import{b as P,c as O,d as T,e as k}from"./chunk-MBREBDZQ.js";import{f as F}from"./chunk-HWK7KFGB.js";import{l as v,m as w}from"./chunk-FUT3X2GJ.js";import{c as S}from"./chunk-OHFB3M3X.js";import{a as E}from"./chunk-NE4R2FVV.js";import{a as D}from"./chunk-I4IRHQDW.js";import{a as $,b as C}from"./chunk-MUFNRCMY.js";var H={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},I={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},q={name:"cp",async execute(u,e){if(C(u))return $(H);let s=E("cp",u,I);if(!s.ok)return s.error;let d=s.result.flags.recursive||s.result.flags.recursiveUpper,A=s.result.flags.noClobber,N=s.result.flags.preserve,R=s.result.flags.verbose,p=s.result.positional;if(p.length<2)return{stdout:"",stderr:`cp: missing destination file operand
|
|
4
4
|
`,exitCode:1};let m=p.pop()??"",g=p,l=e.fs.resolvePath(e.cwd,m),y="",n="",i=0,h=new T({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"cp"}),f=!1;try{f=(await e.fs.stat(l)).isDirectory}catch{}if(g.length>1&&!f)return{stdout:"",stderr:`cp: target '${m}' is not a directory
|
|
5
5
|
`,exitCode:1};for(let t of g)try{let o=e.fs.resolvePath(e.cwd,t),a=await e.fs.stat(o),r=l;if(f){let c=t.split("/").pop()||t;r=l==="/"?`/${c}`:`${l}/${c}`}if(a.isDirectory&&!d){n+=`cp: -r not specified; omitting directory '${t}'
|
|
6
6
|
`,i=1;continue}if(a.isDirectory){let c=await O(e.fs,o,r,h);if(F(o,r)||c==="inside"){n+=`cp: cannot copy '${t}' into itself, '${r}'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{d as k}from"./chunk-
|
|
3
|
+
import{d as k}from"./chunk-MBREBDZQ.js";import{l as u,m}from"./chunk-FUT3X2GJ.js";import{a as h,b as p,c as g}from"./chunk-MUFNRCMY.js";var w={name:"readlink",summary:"print resolved symbolic links or canonical file names",usage:"readlink [OPTIONS] FILE...",options:["-f canonicalize by following every symlink in every component of the given name recursively"," --help display this help and exit"]},x={name:"readlink",async execute(r,n){if(p(r))return h(w);let l=!1,t=0;for(;t<r.length&&r[t].startsWith("-");){let i=r[t];if(i==="-f"||i==="--canonicalize")l=!0,t++;else if(i==="--"){t++;break}else return g("readlink",i)}let c=r.slice(t);if(c.length===0)return{stdout:"",stderr:`readlink: missing operand
|
|
4
4
|
`,exitCode:1};let a="",d=!1,y=new k({limits:n.limits,signal:n.signal,executionScope:n.executionScope,site:"readlink",label:"symlink traversal"});for(let i of c){let s=n.fs.resolvePath(n.cwd,i);try{if(l){let e=s,o=new Set;for(;y.visit(o.size),!o.has(e);){o.add(e);try{let f=await n.fs.readlink(e);if(f.startsWith("/"))e=f;else{let b=e.substring(0,e.lastIndexOf("/"))||"/";e=n.fs.resolvePath(b,f)}}catch{break}}a+=`${e}
|
|
5
5
|
`}else{let e=await n.fs.readlink(s);a+=`${e}
|
|
6
6
|
`}}catch(e){if(e instanceof u||e instanceof m)throw e;l?a+=`${s}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as $,b as F,c as b,d as j,e as Ze,f as et,g as C,h as tt,i as nt,j as k,k as ie,l as ae}from"./chunk-V4U26ZWL.js";import{b as V,d as Qe}from"./chunk-
|
|
3
|
+
import{a as $,b as F,c as b,d as j,e as Ze,f as et,g as C,h as tt,i as nt,j as k,k as ie,l as ae}from"./chunk-V4U26ZWL.js";import{b as V,d as Qe}from"./chunk-ONF4KUYV.js";import{d as Ge,f as Xe,g as oe}from"./chunk-47IFMQYS.js";import{a as Z}from"./chunk-YXPSX3SI.js";import{b as Ye}from"./chunk-2UV6ZFHK.js";import{b as q}from"./chunk-GR4ZHKXI.js";import{a as W,c as se,d as re}from"./chunk-I57EACSL.js";import{l as E}from"./chunk-FUT3X2GJ.js";import{a as K,b as Y}from"./chunk-CPKBPQ2C.js";import{a as J,b as ne}from"./chunk-MUFNRCMY.js";var G=class{input;pos=0;tokens=[];maxSourceLength;maxTokens;constructor(t,n={}){this.input=t,this.maxSourceLength=n.maxSourceLength??1024*1024,this.maxTokens=n.maxTokens??1e5}tokenize(){if(this.input.length>this.maxSourceLength)throw new E(`xan: expression length limit exceeded (${this.maxSourceLength})`,"string_length");for(;this.pos<this.input.length&&(this.skipWhitespace(),!(this.pos>=this.input.length));){let t=this.nextToken();t&&(this.assertTokenCapacity(),this.tokens.push(t))}return this.assertTokenCapacity(),this.tokens.push({type:"eof",value:"",pos:this.pos}),this.tokens}assertTokenCapacity(){if(this.tokens.length>=this.maxTokens)throw new E(`xan: expression token limit exceeded (${this.maxTokens})`,"array_elements")}skipWhitespace(){for(;this.pos<this.input.length;){let t=this.input[this.pos];if(t===" "||t===" "||t===`
|
|
4
4
|
`||t==="\r")this.pos++;else if(t==="#")for(;this.pos<this.input.length&&this.input[this.pos]!==`
|
|
5
5
|
`;)this.pos++;else break}}nextToken(){let t=this.pos,n=this.input[this.pos];if(n>="0"&&n<="9")return this.readNumber();if(n==='"'||n==="'"||n==="`")return this.readString(n);if(n==="b"&&this.pos+1<this.input.length){let o=this.input[this.pos+1];if(o==='"'||o==="'"||o==="`")return this.pos++,this.readString(o)}if(n==="/"){let o=this.tokens[this.tokens.length-1];return o&&(o.type==="int"||o.type==="float"||o.type==="string"||o.type==="ident"||o.type===")"||o.type==="]")?this.input[this.pos+1]==="/"?(this.pos+=2,{type:"//",value:"//",pos:t}):(this.pos++,{type:"/",value:"/",pos:t}):this.readRegex()}if(this.match("not in"))return{type:"not in",value:"not in",pos:t};if(this.match("=>"))return{type:"=>",value:"=>",pos:t};if(this.match("**"))return{type:"**",value:"**",pos:t};if(this.match("++"))return{type:"++",value:"++",pos:t};if(this.match("//"))return{type:"//",value:"//",pos:t};if(this.match("=="))return{type:"==",value:"==",pos:t};if(this.match("!="))return{type:"!=",value:"!=",pos:t};if(this.match("<="))return{type:"<=",value:"<=",pos:t};if(this.match(">="))return{type:">=",value:">=",pos:t};if(this.match("&&"))return{type:"&&",value:"&&",pos:t};if(this.match("||"))return{type:"||",value:"||",pos:t};let r=new Map([["(","("],[")",")"],["[","["],["]","]"],["{","{"],["}","}"],[",",","],[":",":"],[";",";"],["+","+"],["-","-"],["*","*"],["%","%"],["<","<"],[">",">"],["!","!"],[".","."],["|","|"],["=","="]]).get(n);if(r!==void 0)return this.pos++,{type:r,value:n,pos:t};if(this.isIdentStart(n))return this.readIdentifier();throw new Error(`Unexpected character '${n}' at position ${this.pos}`)}match(t){if(this.input.slice(this.pos,this.pos+t.length)===t){if(/^[a-zA-Z]/.test(t)){let n=this.input[this.pos+t.length];if(n&&this.isIdentChar(n))return!1}return this.pos+=t.length,!0}return!1}isIdentStart(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}isIdentChar(t){return this.isIdentStart(t)||t>="0"&&t<="9"}readNumber(){let t=this.pos,n=!1,s=!1;for(;this.pos<this.input.length;){let o=this.input[this.pos];if(o>="0"&&o<="9")this.pos++;else if(o==="_")this.pos++;else if(o==="."&&!n&&!s)n=!0,this.pos++;else if((o==="e"||o==="E")&&!s)s=!0,n=!0,this.pos++,this.pos<this.input.length&&(this.input[this.pos]==="+"||this.input[this.pos]==="-")&&this.pos++;else break}let r=this.input.slice(t,this.pos).replace(/_/g,"");return{type:n?"float":"int",value:r,pos:t}}readString(t){let n=this.pos;this.pos++;let s="";for(;this.pos<this.input.length;){let r=this.input[this.pos];if(r===t)return this.pos++,{type:"string",value:s,pos:n};if(r==="\\"){if(this.pos++,this.pos<this.input.length){let o=this.input[this.pos];switch(o){case"n":s+=`
|
|
6
6
|
`;break;case"r":s+="\r";break;case"t":s+=" ";break;case"\\":s+="\\";break;case'"':s+='"';break;case"'":s+="'";break;case"`":s+="`";break;case"0":s+="\0";break;default:s+=o}this.pos++}}else s+=r,this.pos++}throw new Error(`Unterminated string starting at position ${n}`)}readRegex(){let t=this.pos;this.pos++;let n="",s="";for(;this.pos<this.input.length;){let r=this.input[this.pos];if(r==="/"){for(this.pos++;this.pos<this.input.length&&this.input[this.pos]==="i";)s+=this.input[this.pos],this.pos++;return{type:"regex",value:n+(s?`/${s}`:""),pos:t}}r==="\\"?(n+=r,this.pos++,this.pos<this.input.length&&(n+=this.input[this.pos],this.pos++)):(n+=r,this.pos++)}throw new Error(`Unterminated regex starting at position ${t}`)}readIdentifier(){let t=this.pos;for(;this.pos<this.input.length&&this.isIdentChar(this.input[this.pos]);)this.pos++;let n=!1;this.pos<this.input.length&&this.input[this.pos]==="?"&&(n=!0,this.pos++);let s=this.input.slice(t,n?this.pos-1:this.pos);n&&(s+="?");let r=new Map([["true","true"],["false","false"],["null","null"],["and","and"],["or","or"],["eq","eq"],["ne","ne"],["lt","lt"],["le","le"],["gt","gt"],["ge","ge"],["in","in"],["as","as"],["_","_"]]),o=s.replace(/\?$/,""),i=r.get(o);return i!==void 0&&!n?{type:i,value:o,pos:t}:{type:"ident",value:s,pos:t}}};function z(e){return{maxSourceLength:e.limits.maxStringLength,maxTokens:e.limits.maxQueryTokens,maxAstNodes:e.limits.maxQueryElements,maxOperations:e.limits.maxJqIterations,maxDepth:e.limits.maxQueryDepth}}var D={PIPE:1,OR:2,AND:3,EQUALITY:4,COMPARISON:5,ADDITIVE:6,MULTIPLICATIVE:7,POWER:8,UNARY:9,POSTFIX:10},ee=class{pos=0;tokens;depth=0;operations=0;astNodes=0;limits;constructor(t,n={}){this.tokens=t,this.limits={maxSourceLength:n.maxSourceLength??1024*1024,maxTokens:n.maxTokens??1e5,maxDepth:n.maxDepth??100,maxOperations:n.maxOperations??1e5,maxAstNodes:n.maxAstNodes??1e5};let s=0;for(let r of t)this.useOperation(),r.type==="("||r.type==="["||r.type==="{"?(s++,s>this.limits.maxDepth&&this.throwDepthLimit()):(r.type===")"||r.type==="]"||r.type==="}")&&(s=Math.max(0,s-1))}parse(){let t=this.parseExpr(0);if(this.peek().type!=="eof")throw new Error(`Unexpected token: ${this.peek().value}`);return t}parseExpr(t){return this.withDepth(()=>this.parseExprInner(t))}parseExprInner(t){let n=this.parsePrefix();for(;;){let s=this.peek(),r=this.getInfixPrec(s.type);if(r<t)break;n=this.parseInfix(n,r)}return n}useOperation(t=1){if(t>this.limits.maxOperations-this.operations)throw new E(`xan: expression parser operation limit exceeded (${this.limits.maxOperations})`,"iterations");this.operations+=t}withDepth(t){this.depth>=this.limits.maxDepth&&this.throwDepthLimit(),this.depth++;try{return t()}finally{this.depth--}}throwDepthLimit(){throw new E(`xan: expression parser depth limit exceeded (${this.limits.maxDepth})`,"recursion")}addAstNode(){if(this.astNodes>=this.limits.maxAstNodes)throw new E(`xan: expression AST node limit exceeded (${this.limits.maxAstNodes})`,"array_elements");this.astNodes++}parsePrefix(){let t=this.peek();switch(t.type){case"int":return this.advance(),{type:"int",value:Number.parseInt(t.value,10)};case"float":return this.advance(),{type:"float",value:Number.parseFloat(t.value)};case"string":return this.advance(),{type:"string",value:t.value};case"regex":{this.advance();let n=t.value.split("/"),s=n.length>1?n[n.length-1]:"";return{type:"regex",pattern:n.slice(0,-1).join("/")||t.value,caseInsensitive:s.includes("i")}}case"true":return this.advance(),{type:"bool",value:!0};case"false":return this.advance(),{type:"bool",value:!1};case"null":return this.advance(),{type:"null"};case"_":return this.advance(),{type:"underscore"};case"ident":{let n=t.value,s=n.endsWith("?"),r=s?n.slice(0,-1):n;if(this.advance(),this.peek().type==="(")return this.parseFunctionCall(r);if(this.peek().type==="=>"){this.advance();let o=this.parseExpr(0);return this.bindLambdaArgs({type:"lambda",params:[r],body:o},[r])}return{type:"identifier",name:r,unsure:s}}case"(":{this.advance();let n=this.pos;if(this.peek().type===")"){if(this.advance(),this.peek().type==="=>"){this.advance();let r=this.parseExpr(0);return{type:"lambda",params:[],body:r}}throw new Error("Empty parentheses not allowed")}if(this.peek().type==="ident"){let r=[this.peek().value];this.advance();let o=!0;for(;this.peek().type===",";)if(this.advance(),this.peek().type==="ident")r.push(this.peek().value),this.advance();else{o=!1;break}if(o&&this.peek().type===")"&&this.peekAt(1).type==="=>"){this.advance(),this.advance();let i=this.parseExpr(0);return this.bindLambdaArgs({type:"lambda",params:r,body:i},r)}this.pos=n}let s=this.parseExpr(0);return this.expect(")"),s}case"[":return this.parseList();case"{":return this.parseMap();case"-":{this.advance();let n=this.parseExpr(D.UNARY);return n.type==="int"?{type:"int",value:-n.value}:n.type==="float"?{type:"float",value:-n.value}:{type:"func",name:"neg",args:[{expr:n}]}}case"!":return this.advance(),{type:"func",name:"not",args:[{expr:this.parseExpr(D.UNARY)}]};default:throw new Error(`Unexpected token: ${t.type} (${t.value})`)}}parseFunctionCall(t){this.expect("(");let n=[];if(this.peek().type!==")")do{n.length>0&&this.peek().type===","&&this.advance();let s;if(this.peek().type==="ident"){let o=this.peek().value,i=this.pos+1;i<this.tokens.length&&this.tokens[i].type==="="&&(s=o,this.advance(),this.advance())}let r=this.parseExpr(0);n.push({name:s,expr:r})}while(this.peek().type===",");return this.expect(")"),{type:"func",name:t.toLowerCase(),args:n}}parseList(){this.expect("[");let t=[];if(this.peek().type!=="]")do t.length>0&&this.peek().type===","&&this.advance(),t.push(this.parseExpr(0));while(this.peek().type===",");return this.expect("]"),{type:"list",elements:t}}parseMap(){this.expect("{");let t=[];if(this.peek().type!=="}")do{t.length>0&&this.peek().type===","&&this.advance();let n;if(this.peek().type==="ident")n=this.peek().value,this.advance();else if(this.peek().type==="string")n=this.peek().value,this.advance();else throw new Error(`Expected map key, got ${this.peek().type}`);this.expect(":");let s=this.parseExpr(0);t.push({key:n,value:s})}while(this.peek().type===",");return this.expect("}"),{type:"map",entries:t}}parseInfix(t,n){let s=this.peek(),o=new Map([["+","add"],["-","sub"],["*","mul"],["/","div"],["//","idiv"],["%","mod"],["**","pow"],["++","concat"],["==","=="],["!=","!="],["<","<"],["<=","<="],[">",">"],[">=",">="],["eq","eq"],["ne","ne"],["lt","lt"],["le","le"],["gt","gt"],["ge","ge"],["&&","and"],["and","and"],["||","or"],["or","or"]]).get(s.type);if(o!==void 0){this.advance();let i=this.parseExpr(n+(this.isRightAssoc(s.type)?0:1));return{type:"func",name:o,args:[{expr:t},{expr:i}]}}if(s.type==="|"){this.advance();let i=this.parseExpr(n);return this.handlePipe(t,i)}if(s.type===".")return this.advance(),this.handleDot(t);if(s.type==="[")return this.advance(),this.handleIndexing(t);if(s.type==="in")return this.advance(),{type:"func",name:"contains",args:[{expr:this.parseExpr(n+1)},{expr:t}]};if(s.type==="not in")return this.advance(),{type:"func",name:"not",args:[{expr:{type:"func",name:"contains",args:[{expr:this.parseExpr(n+1)},{expr:t}]}}]};throw new Error(`Unexpected infix token: ${s.type}`)}handlePipe(t,n){if(n.type==="identifier")return{type:"func",name:n.name,args:[{expr:t}]};if(n.type==="func"){let s=this.countUnderscores(n);return s===0?n:s===1?this.fillUnderscore(n,t):{type:"pipeline",exprs:[t,n]}}return this.countUnderscores(n)===1?this.fillUnderscore(n,t):n}handleDot(t){let n=this.peek();if(n.type==="ident"){let s=n.value;if(this.advance(),this.peek().type==="("){let r=this.parseFunctionCall(s);return r.type==="func"&&r.args.unshift({expr:t}),r}return{type:"func",name:"get",args:[{expr:t},{expr:{type:"string",value:s}}]}}if(n.type==="int"){let s=Number.parseInt(n.value,10);return this.advance(),{type:"func",name:"get",args:[{expr:t},{expr:{type:"int",value:s}}]}}if(n.type==="string"){let s=n.value;return this.advance(),{type:"func",name:"get",args:[{expr:t},{expr:{type:"string",value:s}}]}}throw new Error(`Expected identifier, number, or string after dot, got ${n.type}`)}handleIndexing(t){if(this.peek().type===":"){if(this.advance(),this.peek().type==="]")return this.advance(),{type:"func",name:"slice",args:[{expr:t}]};let s=this.parseExpr(0);return this.expect("]"),{type:"func",name:"slice",args:[{expr:t},{expr:{type:"int",value:0}},{expr:s}]}}let n=this.parseExpr(0);if(this.peek().type===":"){if(this.advance(),this.peek().type==="]")return this.advance(),{type:"func",name:"slice",args:[{expr:t},{expr:n}]};let s=this.parseExpr(0);return this.expect("]"),{type:"func",name:"slice",args:[{expr:t},{expr:n},{expr:s}]}}return this.expect("]"),{type:"func",name:"get",args:[{expr:t},{expr:n}]}}countUnderscores(t){let n=[t],s=0;for(;n.length>0;){this.useOperation();let r=n.pop();if(!r)break;if(r.type==="underscore")s++;else if(r.type==="func")for(let o of r.args)n.push(o.expr);else if(r.type==="list")n.push(...r.elements);else if(r.type==="map")for(let o of r.entries)n.push(o.value);if(n.length>this.limits.maxAstNodes)throw new E(`xan: expression AST node limit exceeded (${this.limits.maxAstNodes})`,"array_elements")}return s}fillUnderscore(t,n){return this.withDepth(()=>this.fillUnderscoreInner(t,n))}fillUnderscoreInner(t,n){return this.useOperation(),t.type==="underscore"?n:t.type==="func"?{...t,args:t.args.map(s=>({...s,expr:this.fillUnderscore(s.expr,n)}))}:t.type==="list"?{...t,elements:t.elements.map(s=>this.fillUnderscore(s,n))}:t.type==="map"?{...t,entries:t.entries.map(s=>({...s,value:this.fillUnderscore(s.value,n)}))}:t}bindLambdaArgs(t,n){return{...t,body:this.bindLambdaArgsInExpr(t.body,n)}}bindLambdaArgsInExpr(t,n){return this.withDepth(()=>this.bindLambdaArgsInExprInner(t,n))}bindLambdaArgsInExprInner(t,n){return this.useOperation(),t.type==="identifier"&&n.includes(t.name)?{type:"lambdaBinding",name:t.name}:t.type==="func"?{...t,args:t.args.map(s=>({...s,expr:this.bindLambdaArgsInExpr(s.expr,n)}))}:t.type==="list"?{...t,elements:t.elements.map(s=>this.bindLambdaArgsInExpr(s,n))}:t.type==="map"?{...t,entries:t.entries.map(s=>({...s,value:this.bindLambdaArgsInExpr(s.value,n)}))}:t}getInfixPrec(t){switch(t){case"|":return D.PIPE;case"||":case"or":return D.OR;case"&&":case"and":return D.AND;case"==":case"!=":case"eq":case"ne":return D.EQUALITY;case"<":case"<=":case">":case">=":case"lt":case"le":case"gt":case"ge":case"in":case"not in":return D.COMPARISON;case"+":case"-":case"++":return D.ADDITIVE;case"*":case"/":case"//":case"%":return D.MULTIPLICATIVE;case"**":return D.POWER;case".":case"[":return D.POSTFIX;default:return-1}}isRightAssoc(t){return t==="**"}peek(){return this.tokens[this.pos]||{type:"eof",value:"",pos:0}}peekAt(t){return this.tokens[this.pos+t]||{type:"eof",value:"",pos:0}}advance(){return this.useOperation(),this.addAstNode(),this.tokens[this.pos++]}expect(t){let n=this.peek();if(n.type!==t)throw new Error(`Expected ${t}, got ${n.type}`);return this.advance()}};function X(e,t={}){let n=[],r=new G(e,{maxSourceLength:t.maxSourceLength,maxTokens:t.maxTokens}).tokenize(),o=0,i=()=>r[o]||{type:"eof",value:"",pos:0},p=()=>r[o++];for(;i().type!=="eof";){if(i().type===","&&n.length>0){p();continue}let h=[],m=0,c=o;for(;i().type!=="eof";){let l=i();if((l.type===","||l.type==="as")&&m===0)break;(l.type==="("||l.type==="["||l.type==="{")&&m++,(l.type===")"||l.type==="]"||l.type==="}")&&m--,h.push(p())}h.push({type:"eof",value:"",pos:0});let d=new ee(h,t).parse(),u;if(i().type==="as")if(p(),i().type==="("){p();let l=[];for(;i().type!==")"&&i().type!=="eof";)if((i().type==="ident"||i().type==="string")&&(l.push(i().value),p()),i().type===",")p();else if(i().type!==")"&&i().type!=="eof")throw new Error(`Expected tuple alias, got ${i().type}`);if(i().type!==")")throw new Error("Expected ')' after tuple alias");p(),u=l}else if(i().type==="ident"||i().type==="string")u=i().value,p();else throw new Error(`Expected name after 'as', got ${i().type}`);else u=e.slice(r[c].pos,r[o-1]?.pos||e.length).trim(),d.type==="identifier"&&(u=d.name);n.push({expr:d,name:u})}return n}function B(e,t={}){let s=new G(e,{maxSourceLength:t.maxSourceLength,maxTokens:t.maxTokens}).tokenize();return new ee(s,t).parse()}function R(e,t){return t.length===0?O(e,[]):t.length===1?{type:"Pipe",left:t[0],right:O(e,[])}:{type:"Pipe",left:t[0],right:O(e,t.slice(1))}}var le={add:e=>L("+",e[0],e[1]),sub:e=>L("-",e[0],e[1]),mul:e=>L("*",e[0],e[1]),div:e=>L("/",e[0],e[1]),mod:e=>L("%",e[0],e[1]),idiv:e=>O("floor",[L("/",e[0],e[1])]),pow:e=>R("pow",e),neg:e=>({type:"UnaryOp",op:"-",operand:e[0]}),"==":e=>L("==",e[0],e[1]),"!=":e=>L("!=",e[0],e[1]),"<":e=>L("<",e[0],e[1]),"<=":e=>L("<=",e[0],e[1]),">":e=>L(">",e[0],e[1]),">=":e=>L(">=",e[0],e[1]),eq:e=>L("==",M(e[0]),M(e[1])),ne:e=>L("!=",M(e[0]),M(e[1])),lt:e=>L("<",M(e[0]),M(e[1])),le:e=>L("<=",M(e[0]),M(e[1])),gt:e=>L(">",M(e[0]),M(e[1])),ge:e=>L(">=",M(e[0]),M(e[1])),and:e=>L("and",e[0],e[1]),or:e=>L("or",e[0],e[1]),not:e=>({type:"UnaryOp",op:"not",operand:e[0]}),len:e=>R("length",e),length:e=>R("length",e),upper:e=>R("ascii_upcase",e),lower:e=>R("ascii_downcase",e),trim:e=>R("trim",e),ltrim:e=>e.length===0?O("ltrimstr",[{type:"Literal",value:" "}]):{type:"Pipe",left:e[0],right:O("ltrimstr",[{type:"Literal",value:" "}])},rtrim:e=>e.length===0?O("rtrimstr",[{type:"Literal",value:" "}]):{type:"Pipe",left:e[0],right:O("rtrimstr",[{type:"Literal",value:" "}])},split:e=>R("split",e),join:e=>e.length===1?O("join",[{type:"Literal",value:""}]):R("join",e),concat:e=>L("+",e[0],e[1]),startswith:e=>R("startswith",e),endswith:e=>R("endswith",e),contains:e=>R("contains",e),replace:e=>R("gsub",e),substr:e=>e.length===2?{type:"Slice",base:e[0],start:e[1]}:{type:"Slice",base:e[0],start:e[1],end:L("+",e[1],e[2])},abs:e=>R("fabs",e),floor:e=>R("floor",e),ceil:e=>R("ceil",e),round:e=>R("round",e),sqrt:e=>R("sqrt",e),log:e=>R("log",e),log10:e=>R("log10",e),log2:e=>R("log2",e),exp:e=>R("exp",e),sin:e=>R("sin",e),cos:e=>R("cos",e),tan:e=>R("tan",e),asin:e=>R("asin",e),acos:e=>R("acos",e),atan:e=>R("atan",e),min:e=>R("min",e),max:e=>R("max",e),first:e=>e.length===0?{type:"Index",index:{type:"Literal",value:0}}:{type:"Index",index:{type:"Literal",value:0},base:e[0]},last:e=>e.length===0?{type:"Index",index:{type:"Literal",value:-1}}:{type:"Index",index:{type:"Literal",value:-1},base:e[0]},get:e=>e.length===1?{type:"Index",index:e[0]}:{type:"Index",index:e[1],base:e[0]},slice:e=>e.length===1?{type:"Slice",base:e[0]}:e.length===2?{type:"Slice",base:e[0],start:e[1]}:{type:"Slice",base:e[0],start:e[1],end:e[2]},keys:"keys",values:"values",entries:e=>O("to_entries",e),from_entries:"from_entries",reverse:"reverse",sort:"sort",sort_by:"sort_by",group_by:"group_by",unique:"unique",unique_by:"unique_by",flatten:"flatten",map:e=>({type:"Pipe",left:e[0],right:{type:"Array",elements:e[1]}}),select:e=>O("select",e),empty:()=>O("empty",[]),count:()=>O("length",[]),sum:e=>e.length===0?O("add",[]):{type:"Pipe",left:{type:"Array",elements:e[0]},right:O("add",[])},mean:e=>e.length===0?{type:"Pipe",left:{type:"Identity"},right:L("/",O("add",[]),O("length",[]))}:{type:"Pipe",left:{type:"Array",elements:e[0]},right:L("/",O("add",[]),O("length",[]))},avg:e=>e.length===0?{type:"Pipe",left:{type:"Identity"},right:L("/",O("add",[]),O("length",[]))}:{type:"Pipe",left:{type:"Array",elements:e[0]},right:L("/",O("add",[]),O("length",[]))},type:"type",isnull:e=>e.length===0?L("==",{type:"Identity"},{type:"Literal",value:null}):L("==",e[0],{type:"Literal",value:null}),isempty:e=>e.length===0?L("==",{type:"Identity"},{type:"Literal",value:""}):L("==",e[0],{type:"Literal",value:""}),tonumber:e=>e.length===0?O("tonumber",[]):O("tonumber",e),tostring:e=>e.length===0?O("tostring",[]):O("tostring",e),if:e=>st(e[0],e[1],e[2]),coalesce:e=>{if(e.length===0)return{type:"Literal",value:null};if(e.length===1)return e[0];let t=e[e.length-1];for(let n=e.length-2;n>=0;n--){let s=e[n],r=L("and",L("!=",s,{type:"Literal",value:null}),L("!=",s,{type:"Literal",value:""}));t=st(r,s,t)}return t},index:()=>({type:"Field",name:"_row_index"}),now:()=>O("now",[]),fmt:e=>O("tostring",e),format:e=>O("tostring",e)};Object.setPrototypeOf(le,null);function L(e,t,n){return{type:"BinaryOp",op:e,left:t,right:n}}function O(e,t){return{type:"Call",name:e,args:t}}var mt="then";function st(e,t,n){let s=Xe({type:"Cond",cond:e,elifs:[],else:n||{type:"Literal",value:null}});return s[mt]=t,s}function M(e){return{type:"Pipe",left:e,right:{type:"Call",name:"tostring",args:[]}}}function U(e,t=!0,n={}){let s={nodes:0,operations:0,maxNodes:n.maxAstNodes??1e5,maxOperations:n.maxOperations??1e5,maxDepth:n.maxDepth??100};return rt(e,t,s,0)}function rt(e,t,n,s){if(s>=n.maxDepth)throw new E(`xan: expression conversion depth limit exceeded (${n.maxDepth})`,"recursion");if(++n.nodes>n.maxNodes)throw new E(`xan: expression conversion AST limit exceeded (${n.maxNodes})`,"array_elements");if(++n.operations>n.maxOperations)throw new E(`xan: expression conversion operation limit exceeded (${n.maxOperations})`,"iterations");let r=o=>rt(o,t,n,s+1);switch(e.type){case"int":case"float":return{type:"Literal",value:e.value};case"string":return{type:"Literal",value:e.value};case"bool":return{type:"Literal",value:e.value};case"null":return{type:"Literal",value:null};case"underscore":return{type:"Index",base:{type:"Identity"},index:{type:"Literal",value:"_"}};case"identifier":return t?{type:"Field",name:e.name}:{type:"VarRef",name:e.name};case"lambdaBinding":return{type:"VarRef",name:e.name};case"func":{if(e.args.length>n.maxNodes-n.nodes)throw new E(`xan: expression conversion AST limit exceeded (${n.maxNodes})`,"array_elements");let o=e.args.map(p=>r(p.expr));if(e.name==="coalesce"){let p=Math.max(0,o.length-1)*7;if(p>n.maxNodes-n.nodes)throw new E(`xan: expression conversion AST limit exceeded (${n.maxNodes})`,"array_elements");if(n.nodes+=p,n.operations+=o.length,n.operations>n.maxOperations)throw new E(`xan: expression conversion operation limit exceeded (${n.maxOperations})`,"iterations")}let i=Object.hasOwn(le,e.name)?le[e.name]:void 0;return typeof i=="function"?i(o):O(typeof i=="string"?i:e.name,o)}case"list":return e.elements.length===0?{type:"Array"}:{type:"Array",elements:e.elements.reduce((o,i,p)=>{let h=r(i);return p===0?h:{type:"Comma",left:o,right:h}},null)};case"map":return{type:"Object",entries:e.entries.map(o=>({key:o.key,value:r(o.value)}))};case"regex":return{type:"Literal",value:e.pattern};case"slice":return{type:"Slice",start:e.start?r(e.start):void 0,end:e.end?r(e.end):void 0};case"lambda":return r(e.body);case"pipeline":return{type:"Identity"};default:throw new Error(`Unknown moonblade expression type: ${e.type}`)}}function Q(e){return e<2?0:Math.ceil(e*Math.log2(e))}function ue(e,t={}){let n=t.maxArrayElements??1e5,s=t.maxStringLength??10*1024*1024,r=t.maxIterations??1e5,o=t.maxDepth??100;if(K(e)>s)throw new E(`xan: aggregation expression length limit exceeded (${s} bytes)`,"string_length");let i=[],p=0,h=0,m=()=>{if(t.consumeWork?.(),++h>r)throw new E(`xan: aggregation parser operation limit exceeded (${r})`,"iterations")};for(;p<e.length;){for(m();p<e.length&&(e[p]===" "||e[p]===",");)p++;if(p>=e.length)break;let c=p;for(;p<e.length&&/\w/.test(e[p]);)p++;let a=e.slice(c,p);for(;p<e.length&&e[p]===" ";)p++;if(e[p]!=="(")break;p++;let d=1,u=p;for(;p<e.length&&d>0;){if(m(),e[p]==="("?d++:e[p]===")"&&d--,d>o)throw new E(`xan: aggregation parser depth limit exceeded (${o})`,"recursion");d>0&&p++}let l=e.slice(u,p).trim();for(p++;p<e.length&&e[p]===" ";)p++;let f="";if(e.slice(p,p+3).toLowerCase()==="as "){for(p+=3;p<e.length&&e[p]===" ";)p++;let x=p;for(;p<e.length&&/\w/.test(e[p]);)p++;f=e.slice(x,p)}if(f||(f=l?`${a}(${l})`:`${a}()`),i.length>=n)throw new E(`xan: aggregation specification limit exceeded (${n})`,"array_elements");i.push({func:a,expr:l,alias:f})}return i}function ft(e){return/^\w+$/.test(e)}function ht(e,t,n){let s=V(e,t,n);return s.length>0?s[0]:null}function ce(e,t,n={},s={}){let{func:r,expr:o}=t,i=s.maxArrayElements??1e5,p=s.maxStringLength??10*1024*1024,h=s.maxIterations??1e5,m={maxSourceLength:p,maxTokens:i,maxAstNodes:i,maxOperations:h,maxDepth:s.maxDepth??100};if(e.length>i)throw new E(`xan: aggregation input limit exceeded (${i})`,"array_elements");if(r==="count"&&!o)return e.length;let c=ft(o),a=c?null:U(B(o,m),!0,m),d;if(c)d=f=>f[o];else{if(a===null)throw new Error("xan: missing compiled aggregation expression");d=f=>ht(f,a,n)}if(r==="all"||r==="any"){let f=0;for(let x of e){if(s.consumeWork?.(),++f>h)throw new E(`xan: aggregation iteration limit exceeded (${h})`,"iterations");let g=!!d(x);if(r==="all"&&!g)return!1;if(r==="any"&&g)return!0}return r==="all"}let u=[],l=0;for(let f of e){if(s.consumeWork?.(),++l>h)throw new E(`xan: aggregation iteration limit exceeded (${h})`,"iterations");let x=d(f);if(x!=null){if(u.length>=i)throw new E(`xan: aggregation value limit exceeded (${i})`,"array_elements");u.push(x)}}switch(r){case"count":{if(c)return u.length;let f=0;for(let x of u)s.consumeWork?.(),x&&f++;return f}case"sum":{let f=0;for(let x of u)s.consumeWork?.(),f+=typeof x=="number"?x:Number.parseFloat(String(x));return f}case"mean":case"avg":{let f=0;for(let x of u)s.consumeWork?.(),f+=typeof x=="number"?x:Number.parseFloat(String(x));return u.length>0?f/u.length:0}case"min":{let f=null;for(let x of u){s.consumeWork?.();let g=typeof x=="number"?x:Number.parseFloat(String(x));f=f===null?g:Math.min(f,g)}return f}case"max":{let f=null;for(let x of u){s.consumeWork?.();let g=typeof x=="number"?x:Number.parseFloat(String(x));f=f===null?g:Math.max(f,g)}return f}case"first":return u.length>0?u[0]:null;case"last":return u.length>0?u[u.length-1]:null;case"median":{let f=[];for(let g of u){s.consumeWork?.();let y=typeof g=="number"?g:Number.parseFloat(String(g));Number.isNaN(y)||f.push(y)}if(s.consumeWork?.(Q(f.length)),f.sort((g,y)=>g-y),f.length===0)return null;let x=Math.floor(f.length/2);return f.length%2===0?(f[x-1]+f[x])/2:f[x]}case"mode":{let f=new Map;for(let y of u){s.consumeWork?.();let w=String(y);f.set(w,(f.get(w)||0)+1)}let x=0,g=null;for(let[y,w]of f)s.consumeWork?.(),w>x&&(x=w,g=y);return g}case"cardinality":{let f=new Set;for(let x of u)s.consumeWork?.(),f.add(String(x));return f.size}case"values":return ot(u,!1,p,s);case"distinct_values":return ot(u,!0,p,s);default:return null}}function it(e,t,n={},s={}){let r=F();for(let o of t)b(r,o.alias,ce(e,o,n,s));return r}function ot(e,t,n,s){let r=[],o=t?new Set:null,i=0;for(let p of e){s.consumeWork?.();let h=String(p);if(o?.has(h))continue;o?.add(h);let m=K(h)+(r.length>0?1:0);if(m>n-i)throw new E(`xan: aggregation string limit exceeded (${n} bytes)`,"string_length");r.push(h),i+=m}return t&&(s.consumeWork?.(Q(r.length)),r.sort()),r.join("|")}function lt(e,t){return{maxArrayElements:e.limits.maxArrayElements,maxStringLength:e.limits.maxStringLength,maxIterations:e.limits.maxJqIterations,maxDepth:e.limits.maxQueryDepth,consumeWork:(n=1)=>t.consumeWork(n)}}function at(e,t,n){let s=e.size-(t&&e.has("")?1:0);return n>0?Math.min(s,n):s}async function pe(e,t){let n="",s=[];for(let d of e)d.startsWith("-")||(n?s.push(d):n=d);if(!n)return{stdout:"",stderr:`xan agg: no aggregation expression
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as we}from"./chunk-BIJXTWZ4.js";import{a as Y}from"./chunk-
|
|
3
|
+
import{a as we}from"./chunk-BIJXTWZ4.js";import{a as Y}from"./chunk-IOKQFPM6.js";import{a as le}from"./chunk-3MRB66F4.js";import{a as be}from"./chunk-K27FY3ES.js";import{a as ae}from"./chunk-YXPSX3SI.js";import{b as ue,c as de,d as he}from"./chunk-YERKK5B3.js";import{d as ge}from"./chunk-MBREBDZQ.js";import{l as ie}from"./chunk-FUT3X2GJ.js";import{a as re}from"./chunk-CPKBPQ2C.js";import{a as me,b as ye}from"./chunk-MUFNRCMY.js";function z(e,t){switch(e.type){case"name":{let n=e.pattern,s=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(s){let a=s[1],o=t.name;if(e.ignoreCase){if(!o.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!o.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Y(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,s=t.relativePath,a=n.split("/");for(let u=0;u<a.length-1;u++){let r=a[u];if(r&&r!=="."&&r!==".."&&!r.includes("*")&&!r.includes("?")&&!r.includes("[")){let i=`/${r}/`;if(e.ignoreCase){if(!s.toLowerCase().includes(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.includes(i))return{matches:!1,pruned:!1,printed:!1}}}let o=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(o){let u=o[1];if(e.ignoreCase){if(!s.toLowerCase().endsWith(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.endsWith(u))return{matches:!1,pruned:!1,printed:!1}}return{matches:Y(s,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:ae(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let s=(Date.now()-t.mtime)/(1e3*60*60*24),a;return e.comparison==="more"?a=s>e.days:e.comparison==="less"?a=s<e.days:a=Math.floor(s)===e.days,{matches:a,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let s;return e.comparison==="more"?s=t.size>n:e.comparison==="less"?s=t.size<n:e.unit==="b"?s=Math.ceil(t.size/512)===e.value:s=t.size===n,{matches:s,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,s=e.mode&511,a;return e.matchType==="exact"?a=n===s:e.matchType==="all"?a=(n&s)===s:a=(n&s)!==0,{matches:a,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let n=z(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1,actions:n.actions}}case"and":{let n=z(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1,actions:n.actions};let s=z(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:n.printed||s.printed,actions:[...n.actions??[],...s.actions??[]]}}case"or":{let n=z(e.left,t);if(n.matches)return n;let s=z(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:s.printed,actions:[...n.actions??[],...s.actions??[]]}}}}function Z(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!1;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return Z(e.expr);case"and":case"or":return Z(e.left)||Z(e.right)}}function J(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return J(e.expr);case"and":case"or":return J(e.left)||J(e.right);default:return!1}}function Se(e){let t=[],n=s=>{s&&(s.type==="newer"?t.push(s.refPath):s.type==="not"?n(s.expr):(s.type==="and"||s.type==="or")&&(n(s.left),n(s.right)))};return n(e),t}function V(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return V(e.expr);case"and":case"or":return V(e.left)&&V(e.right)}}function B(e,t,n,s,a){switch(e.type){case"name":{let o=e.pattern,u=o.match(/^\*(\.[a-zA-Z0-9]+)$/);if(u){let r=u[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(r.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(r))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Y(t,o,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let o=e.pattern,u=o.split("/");for(let i=0;i<u.length-1;i++){let l=u[i];if(l&&l!=="."&&l!==".."&&!l.includes("*")&&!l.includes("?")&&!l.includes("[")){let p=`/${l}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(p.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(p))return{matches:!1,pruned:!1,printed:!1}}}let r=o.match(/\*(\.[a-zA-Z0-9]+)$/);if(r){let i=r[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(i))return{matches:!1,pruned:!1,printed:!1}}return{matches:Y(n,o,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let o=e.ignoreCase?"i":"";return{matches:ae(e.pattern,o).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s,pruned:!1,printed:!1}:e.fileType==="d"?{matches:a,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let o=B(e.expr,t,n,s,a);return{matches:!o.matches,pruned:o.pruned,printed:!1,actions:o.actions}}case"and":{let o=B(e.left,t,n,s,a);if(!o.matches)return{matches:!1,pruned:o.pruned,printed:!1,actions:o.actions};let u=B(e.right,t,n,s,a);return{matches:u.matches,pruned:o.pruned||u.pruned,printed:o.printed||u.printed,actions:[...o.actions??[],...u.actions??[]]}}case"or":{let o=B(e.left,t,n,s,a);if(o.matches)return o;let u=B(e.right,t,n,s,a);return{matches:u.matches,pruned:o.pruned||u.pruned,printed:u.printed,actions:[...o.actions??[],...u.actions??[]]}}default:return{matches:!1,pruned:!1,printed:!1}}}function _(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return _(e.expr);case"and":case"or":return _(e.left)||_(e.right);default:return!1}}function L(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return L(e.expr);case"and":case"or":return L(e.left)&&L(e.right)}}function Te(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!L(e))return oe(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:z(e,n).pruned}}function oe(e,t){switch(e.type){case"or":{if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(z(e.left,n).pruned)return{shouldPrune:!0}}return oe(e.right,t)}case"and":{if(L(e.left)&&L(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:z(e,n).pruned}}if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return z(e.left,n).matches?oe(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}function Ce(e,t){let n=[],s=t,a=r=>({expr:null,pathIndex:s,error:`find: missing argument to \`${r}'
|
|
4
4
|
`}),o=(r,i)=>({expr:null,pathIndex:s,error:`find: invalid argument \`${i}' to \`${r}'
|
|
5
5
|
`});for(;s<e.length;){let r=e[s];if(r==="("||r==="\\("){n.push({type:"lparen"}),s++;continue}if(r===")"||r==="\\)"){n.push({type:"rparen"}),s++;continue}if(r==="-name"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s]}})}else if(r==="-iname"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}})}else if(r==="-path"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s]}})}else if(r==="-ipath"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}})}else if(r==="-regex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}})}else if(r==="-iregex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}})}else if(r==="-type"){if(s+1>=e.length)return a(r);let i=e[++s];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${i}
|
|
6
6
|
`}}else if(r==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(r==="-mtime"){if(s+1>=e.length)return a(r);let i=e[++s],l="exact",p=i;if(i.startsWith("+")?(l="more",p=i.slice(1)):i.startsWith("-")&&(l="less",p=i.slice(1)),!/^\d+$/.test(p))return o(r,i);let I=Number(p);if(!Number.isSafeInteger(I))return o(r,i);n.push({type:"expr",expr:{type:"mtime",days:I,comparison:l}})}else if(r==="-newer"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(r==="-size"){if(s+1>=e.length)return a(r);let i=e[++s],l="exact",p=i;i.startsWith("+")?(l="more",p=i.slice(1)):i.startsWith("-")&&(l="less",p=i.slice(1));let I=p.match(/^(\d+)([ckMGb])?$/);if(!I)return o(r,i);let N=Number(I[1]);if(!Number.isSafeInteger(N))return o(r,i);let P=I[2]||"b",j=P==="G"?1024**3:P==="M"?1024**2:P==="k"?1024:P==="b"?512:1;if(!Number.isSafeInteger(N*j))return o(r,i);n.push({type:"expr",expr:{type:"size",value:N,unit:P,comparison:l}})}else if(r==="-perm"){if(s+1>=e.length)return a(r);let i=e[++s],l="exact",p=i;if(i.startsWith("-")?(l="all",p=i.slice(1)):i.startsWith("/")&&(l="any",p=i.slice(1)),!/^[0-7]{1,4}$/.test(p))return o(r,i);let I=Number.parseInt(p,8);n.push({type:"expr",expr:{type:"perm",mode:I,matchType:l}})}else if(r==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(r==="-not"||r==="!")n.push({type:"not"});else if(r==="-o"||r==="-or")n.push({type:"op",op:"or"});else if(r==="-a"||r==="-and")n.push({type:"op",op:"and"});else if(r==="-maxdepth"||r==="-mindepth"){if(s+1>=e.length)return a(r);s++}else if(r!=="-depth")if(r==="-exec"){let i=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)i.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n"};if(i.length===0)return a("-exec");let l=e[s]==="+";if(l&&(i.at(-1)!=="{}"||i.filter(p=>p==="{}").length!==1))return o("-exec","+");n.push({type:"expr",expr:{type:"action",action:{type:"exec",command:i,batchMode:l}}})}else if(r==="-print")n.push({type:"expr",expr:{type:"action",action:{type:"print"}}});else if(r==="-print0")n.push({type:"expr",expr:{type:"action",action:{type:"print0"}}});else if(r==="-printf"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"action",action:{type:"printf",format:i}}})}else if(r==="-delete")n.push({type:"expr",expr:{type:"action",action:{type:"delete"}}});else return r.startsWith("-")?{expr:null,pathIndex:s,error:`find: unknown predicate '${r}'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{a as m}from"./chunk-
|
|
3
|
+
import{a as m}from"./chunk-YXPSX3SI.js";import{b as x}from"./chunk-GR4ZHKXI.js";import{a as w}from"./chunk-PBOVSFTJ.js";var k={name:"expr",async execute(i,a){if(i.length===0)return{stdout:"",stderr:`expr: missing operand
|
|
4
4
|
`,exitCode:2};try{let t=S(i,h=>a.executionScope?.consumeWork(h,"expr index")),f=t==="0"||t===""?1:0;return{stdout:`${t}
|
|
5
5
|
`,stderr:"",exitCode:f}}catch(t){return x(t),{stdout:"",stderr:`expr: ${w(t.message)}
|
|
6
6
|
`,exitCode:2}}}};function S(i,a){if(i.length===1)return i[0];let t=0;function f(){let e=h();for(;t<i.length&&i[t]==="|";){t++;let r=h();if(e!=="0"&&e!=="")return e;e=r}return e}function h(){let e=g();for(;t<i.length&&i[t]==="&";){t++;let r=g();(e==="0"||e===""||r==="0"||r==="")&&(e="0")}return e}function g(){let e=p();for(;t<i.length;){let r=i[t];if(["=","!=","<",">","<=",">="].includes(r)){t++;let s=p(),o=parseInt(e,10),n=parseInt(s,10),l=!Number.isNaN(o)&&!Number.isNaN(n),c;r==="="?c=l?o===n:e===s:r==="!="?c=l?o!==n:e!==s:r==="<"?c=l?o<n:e<s:r===">"?c=l?o>n:e>s:r==="<="?c=l?o<=n:e<=s:c=l?o>=n:e>=s,e=c?"1":"0"}else break}return e}function p(){let e=N();for(;t<i.length;){let r=i[t];if(r==="+"||r==="-"){t++;let s=N(),o=parseInt(e,10),n=parseInt(s,10);if(Number.isNaN(o)||Number.isNaN(n))throw new Error("non-integer argument");e=String(r==="+"?o+n:o-n)}else break}return e}function N(){let e=d();for(;t<i.length;){let r=i[t];if(r==="*"||r==="/"||r==="%"){t++;let s=d(),o=parseInt(e,10),n=parseInt(s,10);if(Number.isNaN(o)||Number.isNaN(n))throw new Error("non-integer argument");if((r==="/"||r==="%")&&n===0)throw new Error("division by zero");r==="*"?e=String(o*n):r==="/"?e=String(Math.trunc(o/n)):e=String(o%n)}else break}return e}function d(){let e=u();for(;t<i.length&&i[t]===":";){t++;let r=u(),o=m(`^${r}`).match(e);o?e=o[1]!==void 0?o[1]:String(o[0].length):e="0"}return e}function u(){if(t>=i.length)throw new Error("syntax error");let e=i[t];if(e==="match"){t++;let r=u(),s=u(),n=m(s).match(r);return n?n[1]!==void 0?n[1]:String(n[0].length):"0"}if(e==="substr"){t++;let r=u(),s=parseInt(u(),10),o=parseInt(u(),10);if(Number.isNaN(s)||Number.isNaN(o))throw new Error("non-integer argument");return r.substring(s-1,s-1+o)}if(e==="index"){t++;let r=u(),s=u();a(s.length+r.length);let o=new Set;for(let n=0;n<s.length;n++)o.add(s[n]);for(let n=0;n<r.length;n++)if(o.has(r[n]))return String(n+1);return"0"}if(e==="length"){t++;let r=u();return String(r.length)}if(e==="("){t++;let r=f();if(t>=i.length||i[t]!==")")throw new Error("syntax error");return t++,r}return t++,e}let b=f();if(t!==i.length)throw new Error("syntax error");return b}var C={name:"expr",flags:[],needsArgs:!0};export{k as a,C as b};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{e as F}from"./chunk-
|
|
3
|
+
import{e as F}from"./chunk-MBREBDZQ.js";import{l as d,m as h}from"./chunk-FUT3X2GJ.js";import{a as x}from"./chunk-NE4R2FVV.js";import{a as g,b as z}from"./chunk-MUFNRCMY.js";var $={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},b={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},R={name:"du",async execute(t,s){if(z(t))return g($);let a=x("du",t,b);if(!a.ok)return a.error;let l={allFiles:a.result.flags.allFiles,humanReadable:a.result.flags.humanReadable,summarize:a.result.flags.summarize,grandTotal:a.result.flags.grandTotal,maxDepth:a.result.flags.maxDepth??null},i=a.result.positional;i.length===0&&i.push(".");let n="",o="",e=0;for(let u of i){let f=s.fs.resolvePath(s.cwd,u);try{await s.fs.stat(f);let r=await w(s,f,u,l,0);n+=r.output,e+=r.totalSize,o+=r.stderr}catch(r){if(r instanceof d||r instanceof h)throw r;o+=`du: cannot access '${u}': No such file or directory
|
|
4
4
|
`}}return l.grandTotal&&i.length>0&&(n+=`${p(e,l.humanReadable)} total
|
|
5
5
|
`),{stdout:n,stderr:o,exitCode:o?1:0}}};async function w(t,s,a,l,i){let n={output:"",totalSize:0,stderr:""},o=new Map;return await F({fs:t.fs,root:s,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"du",symlinks:"never",includeLeave:!0},e=>{let u=e.path.slice(s.length).replace(/^\//,""),f=u?a==="."?u:`${a}/${u}`:a,r=e.path==="/"?"/":e.path.slice(0,e.path.lastIndexOf("/"))||"/";if(e.phase==="enter"){if(e.stat.isDirectory){o.set(e.path,0);return}o.set(r,(o.get(r)??0)+e.stat.size),(l.allFiles||e.depth===i)&&!l.summarize&&(n.output+=`${p(e.stat.size,l.humanReadable)} ${f}
|
|
6
6
|
`),e.depth===i&&(n.totalSize=e.stat.size);return}let m=o.get(e.path)??0;e.depth>i?o.set(r,(o.get(r)??0)+m):n.totalSize=m;let c=e.depth-i;(l.summarize&&c===0||!l.summarize&&(l.maxDepth===null||c<=l.maxDepth))&&(n.output+=`${p(m,l.humanReadable)} ${f}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
+
import{b as T}from"./chunk-CPKBPQ2C.js";import{a as R}from"./chunk-NE4R2FVV.js";import{a as _,b as k}from"./chunk-MUFNRCMY.js";var L=class{diff(t,o,e={}){let i;typeof e=="function"?(i=e,e={}):"callback"in e&&(i=e.callback);let s=this.castInput(t,e),f=this.castInput(o,e),l=this.removeEmpty(this.tokenize(s,e)),r=this.removeEmpty(this.tokenize(f,e));return this.diffWithOptionsObj(l,r,e,i)}diffWithOptionsObj(t,o,e,i){var s;let f=c=>{if(c=this.postProcess(c,e),i){setTimeout(function(){i(c)},0);return}else return c},l=o.length,r=t.length,a=1,u=l+r;e.maxEditLength!=null&&(u=Math.min(u,e.maxEditLength));let h=(s=e.timeout)!==null&&s!==void 0?s:1/0,w=Date.now()+h,C=[{oldPos:-1,lastComponent:void 0}],m=this.extractCommon(C[0],o,t,0,e);if(C[0].oldPos+1>=r&&m+1>=l)return f(this.buildValues(C[0].lastComponent,o,t));let d=-1/0,p=1/0,g=()=>{for(let c=Math.max(d,-a);c<=Math.min(p,a);c+=2){let $,P=C[c-1],y=C[c+1];P&&(C[c-1]=void 0);let v=!1;if(y){let W=y.oldPos-c;v=y&&0<=W&&W<l}let F=P&&P.oldPos+1<r;if(!v&&!F){C[c]=void 0;continue}if(!F||v&&P.oldPos<y.oldPos?$=this.addToPath(y,!0,!1,0,e):$=this.addToPath(P,!1,!0,1,e),m=this.extractCommon($,o,t,c,e),$.oldPos+1>=r&&m+1>=l)return f(this.buildValues($.lastComponent,o,t))||!0;C[c]=$,$.oldPos+1>=r&&(p=Math.min(p,c-1)),m+1>=l&&(d=Math.max(d,c+1))}a++};if(i)(function c(){setTimeout(function(){if(a>u||Date.now()>w)return i(void 0);g()||c()},0)})();else for(;a<=u&&Date.now()<=w;){let c=g();if(c)return c}}addToPath(t,o,e,i,s){let f=t.lastComponent;return f&&!s.oneChangePerToken&&f.added===o&&f.removed===e?{oldPos:t.oldPos+i,lastComponent:{count:f.count+1,added:o,removed:e,previousComponent:f.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:o,removed:e,previousComponent:f}}}extractCommon(t,o,e,i,s){let f=o.length,l=e.length,r=t.oldPos,a=r-i,u=0;for(;a+1<f&&r+1<l&&this.equals(e[r+1],o[a+1],s);)a++,r++,u++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!s.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=r,a}equals(t,o,e){return e.comparator?e.comparator(t,o):t===o||!!e.ignoreCase&&t.toLowerCase()===o.toLowerCase()}removeEmpty(t){let o=[];for(let e=0;e<t.length;e++)t[e]&&o.push(t[e]);return o}castInput(t,o){return t}tokenize(t,o){return Array.from(t)}join(t){return t.join("")}postProcess(t,o){return t}get useLongestToken(){return!1}buildValues(t,o,e){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let f=i.length,l=0,r=0,a=0;for(;l<f;l++){let u=i[l];if(u.removed)u.value=this.join(e.slice(a,a+u.count)),a+=u.count;else{if(!u.added&&this.useLongestToken){let h=o.slice(r,r+u.count);h=h.map(function(w,C){let m=e[a+C];return m.length>w.length?m:w}),u.value=this.join(h)}else u.value=this.join(o.slice(r,r+u.count));r+=u.count,u.added||(a+=u.count)}}return i}};var N=class extends L{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}},z=new N;function M(n,t,o){return z.diff(n,t,o)}var ne=`\
|
|
4
|
+
`,A=3;function j(n){if(n==="")return{lines:[],noEol:!1};let t=!n.endsWith(`
|
|
5
|
+
`),o=n.split(`
|
|
6
|
+
`);return t||o.pop(),{lines:o,noEol:t}}function H(n,t){let o=n.lines.length-1;return n.lines.map((e,i)=>{let s=i===o&&n.noEol?e:`${e}
|
|
7
|
+
`;return t?s.toLowerCase():s})}function B(n,t,o){let e=M(H(n,o),H(t,o)),i=[],s=0,f=0,l=0;for(;l<e.length;){let r=e[l];if(!r.added&&!r.removed){s+=r.count??r.value.length,f+=r.count??r.value.length,l++;continue}let a={oldStart:s,oldCount:0,newStart:f,newCount:0};for(;l<e.length&&(e[l].added||e[l].removed);){let u=e[l].count??e[l].value.length;e[l].removed?(a.oldCount+=u,s+=u):(a.newCount+=u,f+=u),l++}i.push(a)}return i}function x(n){if(!/[\s"\u0000-\u001f\u007f]/.test(n))return n;let t='"';for(let o of n)o==='"'||o==="\\"?t+=`\\${o}`:o===" "?t+="\\t":o===`
|
|
8
|
+
`?t+="\\n":o==="\r"?t+="\\r":o<" "||o==="\x7F"?t+=`\\${o.charCodeAt(0).toString(8).padStart(3,"0")}`:t+=o;return`${t}"`}function D(n,t,o,e){n.push(`${e}${t.lines[o]}
|
|
9
|
+
`),t.noEol&&o===t.lines.length-1&&n.push(ne)}function q(n,t){return t===0?String(n):t===1?String(n+1):`${n+1},${n+t}`}function J(n,t,o){let e=[];for(let i of o){let s=i.oldCount===0?"a":i.newCount===0?"d":"c";e.push(`${q(i.oldStart,i.oldCount)}${s}${q(i.newStart,i.newCount)}
|
|
10
|
+
`);for(let f=0;f<i.oldCount;f++)D(e,n,i.oldStart+f,"< ");s==="c"&&e.push(`---
|
|
11
|
+
`);for(let f=0;f<i.newCount;f++)D(e,t,i.newStart+f,"> ")}return e.join("")}function Y(n,t){let o=[],e=[];for(let i of n){let s=e[e.length-1];s&&i.oldStart-(s.oldStart+s.oldCount)>2*t&&(o.push(e),e=[]),e.push(i)}return e.length>0&&o.push(e),o}function G(n,t,o,e){let i=n[0],s=n[n.length-1];return{oldFrom:Math.max(0,i.oldStart-e),oldTo:Math.min(t.lines.length,s.oldStart+s.oldCount+e),newFrom:Math.max(0,i.newStart-e),newTo:Math.min(o.lines.length,s.newStart+s.newCount+e)}}function U(n,t){let o=t-n;return o===0?`${n},0`:o===1?String(n+1):`${n+1},${o}`}function K(n,t,o,e,i,s){let f=[`--- ${x(n)}
|
|
12
|
+
`,`+++ ${x(t)}
|
|
13
|
+
`];for(let l of Y(i,s)){let r=G(l,o,e,s);f.push(`@@ -${U(r.oldFrom,r.oldTo)} +${U(r.newFrom,r.newTo)} @@
|
|
14
|
+
`);let a=r.oldFrom;for(let u of l){for(;a<u.oldStart;a++)D(f,o,a," ");for(let h=0;h<u.oldCount;h++)D(f,o,u.oldStart+h,"-");for(let h=0;h<u.newCount;h++)D(f,e,u.newStart+h,"+");a=u.oldStart+u.oldCount}for(;a<r.oldTo;a++)D(f,o,a," ")}return f.join("")}function V(n,t){let o=t-n;return o===0?String(n):o===1?String(n+1):`${n+1},${t}`}function X(n,t,o,e,i,s){if(!o.some(r=>(s?r.oldCount:r.newCount)>0))return;let l=e;for(let r of o){let a=s?r.oldStart:r.newStart,u=s?r.oldCount:r.newCount;for(;l<a;l++)D(n,t,l," ");let h=r.oldCount>0&&r.newCount>0?"! ":s?"- ":"+ ";for(let w=0;w<u;w++)D(n,t,a+w,h);l=a+u}for(;l<i;l++)D(n,t,l," ")}function Q(n,t,o,e,i,s){let f=[`*** ${x(n)}
|
|
15
|
+
`,`--- ${x(t)}
|
|
16
|
+
`];for(let l of Y(i,s)){let r=G(l,o,e,s);f.push(`***************
|
|
17
|
+
`),f.push(`*** ${V(r.oldFrom,r.oldTo)} ****
|
|
18
|
+
`),X(f,o,l,r.oldFrom,r.oldTo,!0),f.push(`--- ${V(r.newFrom,r.newTo)} ----
|
|
19
|
+
`),X(f,e,l,r.newFrom,r.newTo,!1)}return f.join("")}var re={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:[" --normal output a normal diff (default)","-u, --unified output a unified diff","-c, --context output a context diff","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences","-r, --recursive recursively compare directories","-N, --new-file treat absent files as empty"," --version output version information and exit"," --help display this help and exit"]},ie={normal:{long:"normal",type:"boolean"},unified:{short:"u",long:"unified",type:"boolean"},context:{short:"c",long:"context",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"},recursive:{short:"r",long:"recursive",type:"boolean"},newFile:{short:"N",long:"new-file",type:"boolean"},version:{long:"version",type:"boolean"}},E=100;function S(n,t,o,e,i){let s=o,f=e;if(i.ignoreCase&&(s=s.toLowerCase(),f=f.toLowerCase()),s===f)return i.reportSame?{output:`Files ${n} and ${t} are identical
|
|
20
|
+
`,differs:!1}:{output:"",differs:!1};if(i.brief)return{output:`Files ${n} and ${t} differ
|
|
21
|
+
`,differs:!0};let l=j(o),r=j(e),a=B(l,r,i.ignoreCase),u;return i.unified?u=K(n,t,l,r,a,A):i.context?u=Q(n,t,l,r,a,A):u=J(l,r,a),{output:u,differs:!0}}async function b(n,t){return n.fs.readFile(n.fs.resolvePath(n.cwd,t))}async function Z(n,t){try{let o=n.fs.resolvePath(n.cwd,t),e=await n.fs.stat(o);return{isFile:e.isFile,isDirectory:e.isDirectory}}catch{return null}}async function I(n,t){if(n.fs.readdirWithFileTypes)return n.fs.readdirWithFileTypes(t);let o=await n.fs.readdir(t),e=[];for(let i of o)try{let s=await n.fs.stat(`${t}/${i}`);e.push({name:i,isFile:s.isFile,isDirectory:s.isDirectory,isSymbolicLink:s.isSymbolicLink??!1})}catch{}return e}function ee(n){return n.isDirectory?"directory":n.isSymbolicLink?"symbolic link":"regular file"}async function te(n,t,o,e,i=0){if(i>E)return{output:`diff: maximum recursion depth exceeded (${E})
|
|
22
|
+
`,differs:!0};let s=o.fs.resolvePath(o.cwd,n),f=o.fs.resolvePath(o.cwd,t),l=await I(o,s),r=await I(o,f),a=new Set(l.map(p=>p.name)),u=new Set(r.map(p=>p.name)),h=[...new Set([...a,...u])].sort(),w=new Map(l.map(p=>[p.name,p])),C=new Map(r.map(p=>[p.name,p])),m="",d=!1;for(let p of h){let g=`${n}/${p}`,c=`${t}/${p}`,$=w.get(p),P=C.get(p);if($&&P)if($.isDirectory&&P.isDirectory){let y=await te(g,c,o,e,i+1);m+=y.output,d=d||y.differs}else if($.isFile&&P.isFile)try{let y=await b(o,g),v=await b(o,c),F=S(g,c,y,v,e);F.differs&&!e.brief&&F.output&&(m+=`${e.headerPrefix} ${g} ${c}
|
|
23
|
+
`),m+=F.output,d=d||F.differs}catch{m+=`diff: ${g}: No such file or directory
|
|
24
|
+
`,d=!0}else m+=`File ${g} is a ${ee($)} while file ${c} is a ${ee(P)}
|
|
25
|
+
`,d=!0;else if($)if(e.newFile)if($.isDirectory){let y=await O(g,c,o,e,!0,i+1);m+=y.output,d=d||y.differs}else if($.isFile){let y=await b(o,g),v=S(g,c,y,"",e);v.differs&&!e.brief&&v.output&&(m+=`${e.headerPrefix} ${g} ${c}
|
|
26
|
+
`),m+=v.output,d=d||v.differs}else m+=`Only in ${n}: ${p}
|
|
27
|
+
`,d=!0;else m+=`Only in ${n}: ${p}
|
|
28
|
+
`,d=!0;else if(P)if(e.newFile)if(P.isDirectory){let y=await O(c,g,o,e,!1,i+1);m+=y.output,d=d||y.differs}else if(P.isFile){let y=await b(o,c),v=S(g,c,"",y,e);v.differs&&!e.brief&&v.output&&(m+=`${e.headerPrefix} ${g} ${c}
|
|
29
|
+
`),m+=v.output,d=d||v.differs}else m+=`Only in ${t}: ${p}
|
|
30
|
+
`,d=!0;else m+=`Only in ${t}: ${p}
|
|
31
|
+
`,d=!0}return{output:m,differs:d}}async function O(n,t,o,e,i,s=0){if(s>E)return{output:`diff: maximum recursion depth exceeded (${E})
|
|
32
|
+
`,differs:!0};let f=o.fs.resolvePath(o.cwd,n),r=[...await I(o,f)].sort((h,w)=>h.name<w.name?-1:h.name>w.name?1:0),a="",u=!1;for(let h of r){let w=`${n}/${h.name}`,C=`${t}/${h.name}`;if(h.isDirectory){let m=await O(w,C,o,e,i,s+1);a+=m.output,u=u||m.differs}else if(h.isFile){let m=await b(o,w),d=i?m:"",p=i?"":m,g=i?w:C,c=i?C:w,$=S(g,c,d,p,e);$.differs&&!e.brief&&$.output&&(a+=`${e.headerPrefix} ${g} ${c}
|
|
33
|
+
`),a+=$.output,u=u||$.differs}}return{output:a,differs:u}}var he={name:"diff",async execute(n,t){if(k(n))return _(re);let o=R("diff",n,ie);if(!o.ok)return o.error;let e=o.result.flags;if(e.version)return{stdout:`diff (just-bash)
|
|
34
|
+
`,stderr:"",exitCode:0};if(Number(e.normal)+Number(e.unified)+Number(e.context)>1)return{stdout:"",stderr:`diff: conflicting output style options
|
|
35
|
+
diff: Try 'diff --help' for more information.
|
|
36
|
+
`,exitCode:2};let s="diff -r";e.unified&&(s+="u"),e.context&&(s+="c"),e.newFile&&(s+="N"),e.ignoreCase&&(s+="i"),e.brief&&(s+="q");let f={unified:e.unified,context:e.context,brief:e.brief,reportSame:e.reportSame,ignoreCase:e.ignoreCase,newFile:e.newFile,headerPrefix:s},l=o.result.positional;if(l.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
37
|
+
`,exitCode:2};let[r,a]=l;if(e.recursive){let C=await Z(t,r),m=await Z(t,a);if(C?.isFile&&m?.isDirectory){let d=`${a}/${r.split("/").pop()}`,p;try{p=await b(t,r)}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
38
|
+
`,exitCode:2}}let g;try{g=await b(t,d)}catch{if(f.newFile)g="";else return{stdout:"",stderr:`diff: ${d}: No such file or directory
|
|
39
|
+
`,exitCode:2}}let c=S(r,d,p,g,f);return{stdout:c.output,stderr:"",exitCode:c.differs?1:0}}if(C?.isDirectory&&m?.isFile){let d=`${r}/${a.split("/").pop()}`,p;try{p=await b(t,d)}catch{if(f.newFile)p="";else return{stdout:"",stderr:`diff: ${d}: No such file or directory
|
|
40
|
+
`,exitCode:2}}let g;try{g=await b(t,a)}catch{return{stdout:"",stderr:`diff: ${a}: No such file or directory
|
|
41
|
+
`,exitCode:2}}let c=S(d,a,p,g,f);return{stdout:c.output,stderr:"",exitCode:c.differs?1:0}}if(!C||!m)return{stdout:"",stderr:`diff: ${C?a:r}: No such file or directory
|
|
42
|
+
`,exitCode:2};if(C.isDirectory&&m.isDirectory){let d=await te(r,a,t,f);return{stdout:d.output,stderr:"",exitCode:d.differs?1:0}}}let u,h;try{u=r==="-"?T(t.stdin):await b(t,r)}catch{if(f.newFile)u="";else return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
43
|
+
`,exitCode:2}}try{h=a==="-"?T(t.stdin):await b(t,a)}catch{if(f.newFile)h="";else return{stdout:"",stderr:`diff: ${a}: No such file or directory
|
|
44
|
+
`,exitCode:2}}let w=S(r,a,u,h,f);return{stdout:w.output,stderr:"",exitCode:w.differs?1:0}}},ge={name:"diff",flags:[{flag:"--normal",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-N",type:"boolean"}],needsArgs:!0,minArgs:2};export{he as a,ge as b};
|