just-binary 3.2.0 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/chunks/chunk-XX3NME7M.js +9 -0
- package/dist/bin/{shell/chunks/date-K253WXCF.js → chunks/date-B3RZR4NV.js} +1 -1
- package/dist/bin/{shell/chunks/flag-coverage-GI5UJZB7.js → chunks/flag-coverage-4EZGBV6F.js} +1 -1
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/chunk-XX3NME7M.js +9 -0
- package/dist/bin/{chunks/date-K253WXCF.js → shell/chunks/date-B3RZR4NV.js} +1 -1
- package/dist/bin/{chunks/flag-coverage-GI5UJZB7.js → shell/chunks/flag-coverage-4EZGBV6F.js} +1 -1
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/browser.js +737 -734
- package/dist/bundle/chunks/chunk-HYWVOWFI.js +8 -0
- package/dist/bundle/chunks/{date-3ASQNZYJ.js → date-FQF5KOV7.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-ICCKNUY3.js → flag-coverage-MFTK2J2P.js} +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/commands/date/date.d.ts +1 -1
- package/package.json +1 -1
- package/dist/bin/chunks/chunk-OCVX56N5.js +0 -6
- package/dist/bin/shell/chunks/chunk-OCVX56N5.js +0 -6
- package/dist/bundle/chunks/chunk-5O326FL2.js +0 -5
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as Y,b as _,c as S}from"./chunk-PQPG4QOY.js";import{b as $,e as w}from"./chunk-7USKQKOT.js";import{k as F,l as H}from"./chunk-DEQBZDPB.js";var Z={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)"," --timezone=TZ use the named IANA time zone (e.g. America/New_York)","-r, --reference=FILE display the last modification time of FILE","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --rfc-3339=FMT output RFC 3339 (FMT: date | seconds | ns)"," --help display this help and exit","","If --timezone is not given, the TZ environment variable is used."]},v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],E=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],W=["January","February","March","April","May","June","July","August","September","October","November","December"],x={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},L={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6},G={second:1e3,minute:6e4,hour:36e5,day:864e5,week:7*864e5};function i(n,r=2){return String(n).padStart(r,"0")}function M(n,r){let a=new Intl.DateTimeFormat("en-US",{timeZone:r,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e={};for(let t of a.formatToParts(n))e[t.type]=t.value;let s=Number.parseInt(e.hour,10);return s===24&&(s=0),{Y:Number.parseInt(e.year,10),m:Number.parseInt(e.month,10)-1,D:Number.parseInt(e.day,10),H:s,M:Number.parseInt(e.minute,10),S:Number.parseInt(e.second,10),w:x[e.weekday]??0}}function I(n,r){let a=M(n,r),e=Date.UTC(a.Y,a.m,a.D,a.H,a.M,a.S);return Math.round((e-n.getTime())/6e4)}function P(n,r){let a=n>=0?"+":"-",e=Math.abs(n),s=Math.floor(e/60),t=e%60;return r===0?`${a}${i(s)}${i(t)}`:r===1?`${a}${i(s)}:${i(t)}`:r===2?`${a}${i(s)}:${i(t)}:00`:t===0?`${a}${i(s)}`:`${a}${i(s)}:${i(t)}`}function z(n,r,a){let e=new Intl.DateTimeFormat("en-US",{timeZone:r,timeZoneName:a});for(let s of e.formatToParts(n))if(s.type==="timeZoneName")return s.value;return""}function J(n,r){let a=z(n,r,"short");if(a&&!/^(GMT|UTC)[+-]/.test(a))return a;let e=z(n,r,"long");if(!e)return a||r||"";if(/^Coordinated Universal Time$/i.test(e))return"UTC";let s=e.match(/\b[A-Z]/g);return s?s.join(""):a}function j(n,r,a){let e=Date.UTC(n,0,1),s=Date.UTC(n,r,a);return Math.round((s-e)/864e5)+1}function N(n,r,a){let e=new Date(Date.UTC(n,r,a)),s=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-s);let t=e.getUTCFullYear(),u=new Date(Date.UTC(t,0,1));return{week:Math.ceil(((e.getTime()-u.getTime())/864e5+1)/7),year:t}}function D(n,r){return r==="^"?n.toUpperCase():r==="#"?/[a-z]/.test(n)?n.toUpperCase():n.toLowerCase():n}function m(n,r,a,e){let s=String(n);return e==="-"?s:e==="_"?s.padStart(r," "):e==="0"?s.padStart(r,"0"):s.padStart(r,a)}function X(n,r){let a=(n.getTime()%1e3+1e3)%1e3,e=`${i(a,3)}000000`;return r<=0||r>=9?e:e.slice(0,r)}function T(n,r,a){let e=M(n,a),s=I(n,a),t="",u=0;for(;u<r.length;){let h=r[u];if(h!=="%"||u+1>=r.length){t+=h,u++;continue}u++;let o=null;"-_0^#".includes(r[u]??"")&&(o=r[u],u++);let f=0;for(;u<r.length&&/\d/.test(r[u]);)f=f*10+(r.charCodeAt(u)-48),u++;let b=0;for(;r[u]===":";)b++,u++;let c=r[u]??"";u++;let d=y=>y;switch(c){case"%":t+="%";break;case"n":t+=`
|
|
2
|
+
`;break;case"t":t+=" ";break;case"a":t+=D(v[e.w],o);break;case"A":t+=D(E[e.w],o);break;case"b":case"h":t+=D(A[e.m],o);break;case"B":t+=D(W[e.m],o);break;case"C":t+=m(Math.floor(e.Y/100),2,"0",o);break;case"d":t+=m(e.D,2,"0",o);break;case"D":t+=`${i(e.m+1)}/${i(e.D)}/${i(e.Y%100)}`;break;case"e":t+=m(e.D,2," ",o);break;case"F":t+=`${i(e.Y,4)}-${i(e.m+1)}-${i(e.D)}`;break;case"g":{let y=N(e.Y,e.m,e.D).year%100;t+=m(y,2,"0",o);break}case"G":t+=m(N(e.Y,e.m,e.D).year,4,"0",o);break;case"H":t+=m(e.H,2,"0",o);break;case"I":t+=m(e.H%12||12,2,"0",o);break;case"j":t+=m(j(e.Y,e.m,e.D),3,"0",o);break;case"k":t+=m(e.H,2," ",o);break;case"l":t+=m(e.H%12||12,2," ",o);break;case"m":t+=m(e.m+1,2,"0",o);break;case"M":t+=m(e.M,2,"0",o);break;case"N":t+=X(n,f||9);break;case"p":t+=D(e.H<12?"AM":"PM",o);break;case"P":t+=D(e.H<12?"am":"pm",o);break;case"q":t+=m(Math.floor(e.m/3)+1,1,"0",o);break;case"r":t+=`${i(e.H%12||12)}:${i(e.M)}:${i(e.S)} ${e.H<12?"AM":"PM"}`;break;case"R":t+=`${i(e.H)}:${i(e.M)}`;break;case"s":t+=String(Math.floor(n.getTime()/1e3));break;case"S":t+=m(e.S,2,"0",o);break;case"T":case"X":t+=`${i(e.H)}:${i(e.M)}:${i(e.S)}`;break;case"u":t+=String(e.w||7);break;case"V":t+=m(N(e.Y,e.m,e.D).week,2,"0",o);break;case"w":t+=String(e.w);break;case"x":t+=`${i(e.m+1)}/${i(e.D)}/${i(e.Y%100)}`;break;case"y":t+=m(e.Y%100,2,"0",o);break;case"Y":t+=m(e.Y,4,"0",o);break;case"z":t+=P(s,b);break;case"Z":t+=J(n,a);break;case"c":t+=`${v[e.w]} ${A[e.m]} ${String(e.D).padStart(2," ")} ${i(e.H)}:${i(e.M)}:${i(e.S)} ${e.Y}`;break;default:{let y=o??"",g=f>0?String(f):"",l=":".repeat(b);t+=d(`%${y}${g}${l}${c}`);break}}}return t}function K(n){return/(Z|[+-]\d{2}:?\d{2}|\s(UTC|GMT))$/i.test(n.trim())}function O(n,r){let a;/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2})?$/.test(n)?a=`${n.replace(" ","T")}Z`:/^\d{4}-\d{2}-\d{2}$/.test(n)?a=`${n}T00:00:00Z`:a=`${n} UTC`;let e=new Date(a);if(Number.isNaN(e.getTime()))return null;let s=I(e,r),t=e.getTime()-s*6e4,u=I(new Date(t),r);return u!==s&&(t=e.getTime()-u*6e4),new Date(t)}function C(n,r,a){let e=a.toLowerCase().replace(/s$/,"");if(e==="month"){let t=new Date(n.getTime());return t.setUTCMonth(t.getUTCMonth()+r),t}if(e==="year"){let t=new Date(n.getTime());return t.setUTCFullYear(t.getUTCFullYear()+r),t}let s=G[e];return s===void 0?n:new Date(n.getTime()+r*s)}function V(n,r,a){let e=new Date,s=M(e,a).w,t;return r==="next"?t=(n-s+7)%7||7:r==="last"?t=-((s-n+7)%7||7):t=(n-s+7)%7,new Date(e.getTime()+t*864e5)}function q(n,r,a,e,s){let t=M(n,s),u=`${i(t.Y,4)}-${i(t.m+1)}-${i(t.D)} ${i(r)}:${i(a)}:${i(e)}`;if(s){let o=O(u,s);if(o)return o}let h=new Date(u);return Number.isNaN(h.getTime())?n:h}var B=/^(\d+)\s+(second|minute|hour|day|week|month|year)s?\s+ago$/,Q=/^(\d+)\s+(second|minute|hour|day|week|month|year)s?$/,ee=/^(.+?)\s+([+-])\s+(\d+)\s+(second|minute|hour|day|week|month|year)s?$/i;function R(n,r){let a=r,e=n.match(/^\s*TZ=(?:"([^"]+)"|'([^']+)'|(\S+))\s+(.+)$/);e&&(a=e[1]??e[2]??e[3],n=e[4]),n=n.trim();let s=n.toLowerCase();if(s==="now"||s==="today")return new Date;if(s==="yesterday")return new Date(Date.now()-864e5);if(s==="tomorrow")return new Date(Date.now()+864e5);let t=s.match(/^(next|last)?\s*(sunday|monday|tuesday|wednesday|thursday|friday|saturday)$/);if(t){let c=t[1]??null;return V(L[t[2]],c,a)}let u=s.match(B);if(u)return C(new Date,-Number.parseInt(u[1],10),u[2]);let h=s.match(Q);if(h)return C(new Date,Number.parseInt(h[1],10),h[2]);let o=s.match(/^(now|today|yesterday|tomorrow)\s+(\d{1,2}):(\d{2})(?::(\d{2}))?$/);if(o){let c=o[1],d=new Date;return c==="yesterday"?d=new Date(Date.now()-864e5):c==="tomorrow"&&(d=new Date(Date.now()+864e5)),q(d,Number.parseInt(o[2],10),Number.parseInt(o[3],10),Number.parseInt(o[4]??"0",10),a)}let f=n.match(ee);if(f){let c=R(f[1],a);if(!c)return null;let d=f[2]==="+"?1:-1;return C(c,d*Number.parseInt(f[3],10),f[4])}if(/^@?\d+$/.test(n)){let c=Number.parseInt(n.replace(/^@/,""),10);return new Date(c*1e3)}if(K(n)){let c=new Date(n);return Number.isNaN(c.getTime())?null:c}if(a!==void 0){let c=O(n,a);if(c)return c}let b=new Date(n);return Number.isNaN(b.getTime())?null:b}var re={name:"date",async execute(n,r){let a=F(n);if(_(a))return Y(Z);let e=!1,s=null,t=null,u=!1,h=!1,o=null,f=null,b=null;for(let g=0;g<a.length;g++){let l=a[g];if(l==="-u"||l==="--utc")e=!0;else if(l==="-d"||l==="--date")s=a[++g]??"";else if(l.startsWith("--date="))s=l.slice(7);else if(l==="--timezone")f=a[++g]??"";else if(l.startsWith("--timezone="))f=l.slice(11);else if(l==="-r"||l==="--reference")b=a[++g]??"";else if(l.startsWith("--reference="))b=l.slice(12);else if(l==="-I"||l==="--iso-8601")u=!0;else if(l==="-R"||l==="--rfc-email")h=!0;else if(l.startsWith("--rfc-3339=")){let p=l.slice(11);if(p!=="date"&&p!=="seconds"&&p!=="ns")return{stdout:$(),stderr:w(`date: invalid argument '${p}' for '--rfc-3339'
|
|
3
|
+
Valid arguments are: 'date', 'seconds', 'ns'
|
|
4
|
+
`),exitCode:1};o=p}else if(l.startsWith("+"))t=l.slice(1);else{if(l.startsWith("--"))return S("date",l);if(l.startsWith("-"))for(let p=1;p<l.length;p++){let k=l[p];if(k==="u")e=!0;else if(k==="I")u=!0;else if(k==="R")h=!0;else if(k==="r"){let U=l.slice(p+1);b=U!==""?U:a[++g]??"";break}else return S("date",`-${k}`)}}}let c;if(e)c="UTC";else if(f!==null&&f!=="")c=f;else{let g=H(r.env,"TZ");g&&(c=g)}if(c!==void 0)try{new Intl.DateTimeFormat("en-US",{timeZone:c})}catch{return{stdout:$(),stderr:w(`date: invalid time zone '${c}'
|
|
5
|
+
`),exitCode:1}}let d;if(b!==null)try{d=(await r.fs.stat(b)).mtime}catch{return{stdout:$(),stderr:w(`date: cannot stat '${b}': No such file or directory
|
|
6
|
+
`),exitCode:1}}else if(s!==null){if(d=R(s,c),!d)return{stdout:$(),stderr:w(`date: invalid date '${s}'
|
|
7
|
+
`),exitCode:1}}else d=new Date;let y;return t?y=T(d,t,c):o==="date"?y=T(d,"%Y-%m-%d",c):o==="seconds"?y=T(d,"%Y-%m-%d %H:%M:%S%:z",c):o==="ns"?y=T(d,"%Y-%m-%d %H:%M:%S.%N%:z",c):u?y=T(d,"%Y-%m-%dT%H:%M:%S%z",c):h?y=T(d,"%a, %d %b %Y %H:%M:%S %z",c):y=T(d,"%a %b %e %H:%M:%S %Z %Y",c),{stdout:w(`${y}
|
|
8
|
+
`),stderr:$(),exitCode:0}}},se={name:"date",flags:[{flag:"-d",type:"value",valueHint:"string"},{flag:"-u",type:"boolean"},{flag:"-I",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-r",type:"value",valueHint:"string"},{flag:"--timezone",type:"value",valueHint:"string"},{flag:"--rfc-3339",type:"value",valueHint:"string"}]};export{re as a,se as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-HYWVOWFI.js";import"./chunk-PQPG4QOY.js";import"./chunk-7USKQKOT.js";import"./chunk-DEQBZDPB.js";export{a as dateCommand,b as flagsForFuzzing};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as yr}from"./chunk-VKPVP3LD.js";import{d as Ir,e as Mr,f as jr}from"./chunk-M5Z2PSET.js";import{b as Ar}from"./chunk-MOCB6GPI.js";import{b as $r}from"./chunk-BXVXYDEI.js";import{b as Sr}from"./chunk-YZPQ2W3A.js";import"./chunk-53I2XH4A.js";import"./chunk-SPETXYUM.js";import{b as Tr}from"./chunk-W4YQKIRV.js";import{b as hr}from"./chunk-GNXHG75U.js";import{b as wr}from"./chunk-BJQMZYH3.js";import{b as xr}from"./chunk-KRXVUD4L.js";import{b as vr}from"./chunk-2WN53CVO.js";import{b as kr}from"./chunk-ZEHOKNGQ.js";import{b as qr}from"./chunk-WMCZEPWH.js";import{b as Cr}from"./chunk-PEPBD26Q.js";import{b as br}from"./chunk-C44B5265.js";import{b as nr}from"./chunk-
|
|
1
|
+
import{b as yr}from"./chunk-VKPVP3LD.js";import{d as Ir,e as Mr,f as jr}from"./chunk-M5Z2PSET.js";import{b as Ar}from"./chunk-MOCB6GPI.js";import{b as $r}from"./chunk-BXVXYDEI.js";import{b as Sr}from"./chunk-YZPQ2W3A.js";import"./chunk-53I2XH4A.js";import"./chunk-SPETXYUM.js";import{b as Tr}from"./chunk-W4YQKIRV.js";import{b as hr}from"./chunk-GNXHG75U.js";import{b as wr}from"./chunk-BJQMZYH3.js";import{b as xr}from"./chunk-KRXVUD4L.js";import{b as vr}from"./chunk-2WN53CVO.js";import{b as kr}from"./chunk-ZEHOKNGQ.js";import{b as qr}from"./chunk-WMCZEPWH.js";import{b as Cr}from"./chunk-PEPBD26Q.js";import{b as br}from"./chunk-C44B5265.js";import{b as nr}from"./chunk-HYWVOWFI.js";import{b as tr}from"./chunk-IAFRFK2O.js";import{b as lr}from"./chunk-2AMXQD57.js";import{b as ur}from"./chunk-5PIFIDMP.js";import{b as pr}from"./chunk-R7SSLDTN.js";import{b as er}from"./chunk-ZILSBZZ6.js";import{b as dr}from"./chunk-5BF5Z7CI.js";import{b as cr}from"./chunk-YR4NQYT4.js";import"./chunk-K374E7Q4.js";import{b as rr}from"./chunk-5J57FRET.js";import{c as or,d as ar}from"./chunk-SMOO4IXI.js";import{b as sr}from"./chunk-6V537K6X.js";import{b as ir}from"./chunk-6RAG3BOS.js";import{c as gr,d as mr}from"./chunk-INJTM5VR.js";import{b as Fr}from"./chunk-PLMPLLOW.js";import"./chunk-3ANOKDIL.js";import"./chunk-7MKBHGLS.js";import{b as zr}from"./chunk-5PV2QBWC.js";import{b as fr}from"./chunk-LBJIRX7Z.js";import{b as Q}from"./chunk-WVUVOYGQ.js";import{b as R}from"./chunk-72YPFG2Z.js";import{b as U}from"./chunk-QOFUETQV.js";import{b as V}from"./chunk-QPHABKP3.js";import{b as W}from"./chunk-ULK572PS.js";import{c as X,d as Y}from"./chunk-ATPJVO6F.js";import{c as Z,d as _}from"./chunk-D4LWWAJ2.js";import{b as N}from"./chunk-DNPCEBCN.js";import{b as E}from"./chunk-U5Z7TJRO.js";import{b as G}from"./chunk-2OIUNVMP.js";import{b as H}from"./chunk-OZ76IUC5.js";import{b as J}from"./chunk-TOK4OQFP.js";import{b as K}from"./chunk-PES2WOIM.js";import{b as L}from"./chunk-C325X4RB.js";import{b as O}from"./chunk-JJ5E4XJI.js";import{b as P}from"./chunk-SF2462OV.js";import{b as M}from"./chunk-XZZ3XIZH.js";import{b as j}from"./chunk-KBCEHRTU.js";import{b as A}from"./chunk-Z6DABRIE.js";import{b as $}from"./chunk-URMOT4S7.js";import{b as S}from"./chunk-RZ4GSKWY.js";import{b as T}from"./chunk-2V4QPJXQ.js";import{b as B}from"./chunk-SJ7F47VW.js";import{b as D}from"./chunk-GMCBEP44.js";import{b as h}from"./chunk-BTTTDUMD.js";import{b as w}from"./chunk-JMFP263D.js";import"./chunk-YJHMB6QD.js";import{b as x}from"./chunk-SYTEZ2Y4.js";import{b as v}from"./chunk-EHY6GWKP.js";import{d as k,e as q,f as C}from"./chunk-GET3OC3O.js";import"./chunk-IJXFPKNC.js";import{b}from"./chunk-NDPSDM3Q.js";import"./chunk-D3IE6KOV.js";import{b as y}from"./chunk-BQFHZOZH.js";import{b as I}from"./chunk-WTT2UCIA.js";import{b as n}from"./chunk-H5X25CTO.js";import{b as t}from"./chunk-F77E6PCM.js";import{b as l}from"./chunk-XZMBEDQL.js";import{b as u}from"./chunk-26VNLF3H.js";import{b as p}from"./chunk-PUUP54QP.js";import{b as e}from"./chunk-4PFDHMBC.js";import{b as d}from"./chunk-USGCTFXK.js";import{b as c}from"./chunk-K7ZRPFN6.js";import"./chunk-MIFIRXNI.js";import"./chunk-UBLR5ACC.js";import"./chunk-YNYSPYQ5.js";import{b as i}from"./chunk-3P5XOPF6.js";import{b as g}from"./chunk-Q5XZ24VX.js";import"./chunk-J7YL5K5B.js";import{b as m}from"./chunk-XXS34VJC.js";import"./chunk-BMKJMOWP.js";import"./chunk-JSLN56GJ.js";import{b as F}from"./chunk-26DNZXYZ.js";import"./chunk-NUFRM6SI.js";import{b as z}from"./chunk-RTGKIAVM.js";import{b as f}from"./chunk-EHRCEDXN.js";import"./chunk-44UOCSGV.js";import"./chunk-GQSJJXDG.js";import"./chunk-PQPG4QOY.js";import"./chunk-7USKQKOT.js";import"./chunk-DEQBZDPB.js";var Gr=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,y,I,M,j,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,yr,Ir,Mr,jr,Ar,$r,ir,Sr,Tr];function Br(){return Gr}var Dr=new Map;for(let r of Br())Dr.set(r.name,new Set(r.flags.map(o=>o.flag)));function fa(r,o,Er){let a=Dr.get(o);if(!(!a||a.size===0))for(let s of Er)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{fa as emitFlagCoverage};
|
package/dist/bundle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as Ss,C as zr,D as Wr,E as ge,F as Ze,G as ae,H as xe,I as Ft,J as Vr,K as V,L as Br,M as jr,N as Ie,O as $s,P as Lt,Q as tt,R as K,a as Nr,b as gs,c as Tr,d as Or,e as Rt,f as ne,g as Z,h as Te,i as ce,j as Oe,k as je,l as ws,m as Mt,n as Dr,o as vs,p as Ir,q as ye,r as Le,s as Rr,t as Mr,u as bs,v as Es,w as De,x as Fr,y as Lr,z as Ce}from"./chunks/chunk-U6GF4IJH.js";import{a as xr}from"./chunks/chunk-MIFIRXNI.js";import{a as Be,b as _e}from"./chunks/chunk-UBLR5ACC.js";import{a as bt}from"./chunks/chunk-YNYSPYQ5.js";import{a as Ee,b as Se,c as me,d as Ae,e as _r,f as Y,g as qe,h as Ot,i as Dt,j as Cr,k as de,l as Ve,m as It,n as ke}from"./chunks/chunk-JSLN56GJ.js";import"./chunks/chunk-NUFRM6SI.js";import{a as Fe}from"./chunks/chunk-44UOCSGV.js";import{a as et,b as w,c as se,d as he,e as C,f as H,g as Ge,h as O,i as Tt,j as ys,k as ki,l as _i,m as Ci}from"./chunks/chunk-7USKQKOT.js";import{a as vt,g as F,h as B,i as j,j as Ar,k as Je,l as T,m as g,n as kr}from"./chunks/chunk-DEQBZDPB.js";var Xe=[{name:"echo",load:async()=>(await import("./chunks/echo-ZPFMTGPQ.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-KHANCARN.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-223LFYZL.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-JAO4QNWZ.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-O74MZREV.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-LGJXG7S3.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-7BNOFP74.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-NIZVTCU7.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-FD6I3O6B.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-66ALAQRO.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-N3OWFM3J.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-A3HCFC4L.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-BP6H5JPD.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-JL7TKP5U.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-CIKXFGO5.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-GJ536HFQ.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-PWYVRT3X.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-2CKLARLN.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-KLQ4A2OH.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-KLQ4A2OH.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-KLQ4A2OH.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-RA3U4BVJ.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-JJ3WRWYT.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-LA5EZ6UJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-BNPU2P3T.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-ZHYLWEFM.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-47FVEMHB.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-LQZW2NZP.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-Y7CG4TKC.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-TB6CSIUV.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-UN4ZHPP5.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-JSPXHHOM.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-6O4H3AW4.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-Y7EMR5BJ.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-LDC3OTY4.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-LG7URPXR.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-SVMZIFGF.js")).split},{name:"column",load:async()=>(await import("./chunks/column-OUJRIWLX.js")).column},{name:"join",load:async()=>(await import("./chunks/join-CFMKSF44.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-PJ6B6JJF.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-BYG3GTNV.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-NCIQLNXY.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-IVA4YYRE.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-4XRVONUX.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-H4GJHM4R.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-ZCKP6263.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-ZCKP6263.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JHV3WNPA.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JHV3WNPA.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-N2VRLHEO.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-CB3LOKW5.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-4UI5ZW75.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-4UI5ZW75.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-7SIFUXVD.js")).clearCommand},{name:"yes",load:async()=>(await import("./chunks/yes-2J55KNKF.js")).yesCommand},{name:"bash",load:async()=>(await import("./chunks/bash-CN3UUJ3N.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-CN3UUJ3N.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-BE76GAFF.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-DP3BVL7J.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-7ZYMEVUP.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-3ASQNZYJ.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-YQMDXMVK.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-SXUKTL7R.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-IENYNVU4.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-SXS6YKWX.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-WDFXVU43.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-ZK2D5HMO.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BB464H3H.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-PPJUHZ6A.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-7WSECN2B.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-ZDG5GHHM.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-B2UCSYQN.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-EIT2IJGG.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-NXGTFB5T.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-W7U3GOEK.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-QZJHAL2R.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-NUINXLUX.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-BYGAV4XY.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-BYGAV4XY.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-BYGAV4XY.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Xe.push({name:"tar",load:async()=>(await import("./chunks/tar-3KCFO6WZ.js")).tarCommand}),Xe.push({name:"yq",load:async()=>(await import("./chunks/yq-JFXSVU6G.js")).yqCommand}),Xe.push({name:"xan",load:async()=>(await import("./chunks/xan-JDD2TEQH.js")).xanCommand}),Xe.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-PZGLI6XB.js")).sqlite3Command}));var zt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(zt.push({name:"python3",load:async()=>(await import("./chunks/python3-2KEMASKS.js")).python3Command}),zt.push({name:"python",load:async()=>(await import("./chunks/python3-2KEMASKS.js")).pythonCommand}));var Hr=[{name:"curl",load:async()=>(await import("./chunks/curl-3MHMRKXA.js")).curlCommand}],Ur=new Map;function Ps(e){return{name:e.name,async execute(t,s){let r=Ur.get(e.name);if(r||(r=await e.load(),Ur.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-ICCKNUY3.js"),{decodeArgs:i}=await import("./chunks/bytes-JUNATFIO.js");n(s.coverage,e.name,i(t))}return r.execute(t,s)}}}function xi(){return Xe.map(e=>e.name)}function Ni(){return Hr.map(e=>e.name)}function Gr(e){return(e?Xe.filter(s=>e.includes(s.name)):Xe).map(Ps)}function qr(){return Hr.map(Ps)}function Ti(){return zt.map(e=>e.name)}function Zr(){return zt.map(Ps)}function Xr(e){return"load"in e&&typeof e.load=="function"}function Oi(e,t){return{name:e,async execute(s,r){let n={...r,env:kr(r.env)},i=await t(Je(s),n);return typeof i.stdout=="string"?{stdout:C(i.stdout),stderr:C(i.stderr),exitCode:i.exitCode}:i}}}function Yr(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var Di=new TextEncoder;function Ii(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function Ri(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)s[r/2]=parseInt(e.slice(r,r+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,n=>n.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}return Di.encode(e)}function Qr(e){if(e.length===0)return[];if(e.length<=et)return[e];let t=[];for(let s=0;s<e.length;s+=et)t.push(e.subarray(s,Math.min(s+et,e.length)));return t}function st(e,t){let s=Ri(e,t);return{chunks:Qr(s),size:s.length}}async function ze(e,t){if(Ii(e)){let s=[],r=0;for await(let n of ys(e))if(n.length<=et)s.push(n),r+=n.length;else for(let i of Qr(n))s.push(i),r+=i.length;return{chunks:s,size:r}}return st(e,t)}function Wt(e,t){if(t==="base64")return btoa(xr(Kr(e)));if(t==="hex"){let n="";for(let i of e)for(let o=0;o<i.length;o++)n+=i[o].toString(16).padStart(2,"0");return n}if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(Kr(e)).toString(t);let n=65536,i="";for(let o of e)if(o.length<=n)i+=String.fromCharCode(...o);else for(let a=0;a<o.length;a+=n){let l=o.subarray(a,a+n);i+=String.fromCharCode(...l)}return i}let s=new TextDecoder,r="";for(let n of e)n.length>0&&(r+=s.decode(n,{stream:!0}));return r+=s.decode(),r}function Kr(e){let t=0;for(let n of e)t+=n.length;if(t===0)return new Uint8Array(0);if(e.length===1)return e[0];let s=new Uint8Array(t),r=0;for(let n of e)s.set(n,r),r+=n.length;return s}function $e(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}function rt(e,t){if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new Error(`EINVAL: invalid offset (must be a non-negative integer): ${e}`);if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new Error(`EINVAL: invalid length (must be a non-negative integer): ${t}`)}function Vt(e,t,s,r){if(s>=t||r===0)return new Uint8Array(0);let n=Math.min(s+r,t),i=n-s,o=new Uint8Array(i),a=0,l=0;for(let u of e){if(a>=i)break;let c=l+u.length;if(c>s&&l<n){let f=Math.max(0,s-l),h=Math.min(u.length,n-l),d=u.subarray(f,h);o.set(d,a),a+=d.length}l=c}return o}function Mi(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&!(e instanceof ReadableStream)&&"content"in e}function ie(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var We=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))if(Mi(r)){if(r.content instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime})}else{if(r instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,r)}}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){ie(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=$e(r),{chunks:a,size:l}=st(s,o);this.data.set(i,{type:"file",chunks:a,size:l,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t){ie(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return he(r.chunks)}async readRange(t,s,r){rt(s,r),ie(t,"open");let n=this.resolvePathWithSymlinks(t),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(i.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return Vt(i.chunks,i.size,s,r)}async readFileText(t,s){ie(t,"open");let r=this.resolvePathWithSymlinks(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);let i=$e(s);return Wt(n.chunks,i)}async writeFile(t,s,r){ie(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n);let i=$e(r),{chunks:o,size:a}=await ze(s,i);this.data.set(n,{type:"file",chunks:o,size:a,mode:420,mtime:new Date})}async appendFile(t,s,r){ie(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=$e(r),{chunks:a,size:l}=await ze(s,o);i?.type==="file"?this.data.set(n,{type:"file",chunks:[...i.chunks,...a],size:i.size+l,mode:i.mode,mtime:new Date}):(this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:a,size:l,mode:420,mtime:new Date}))}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){ie(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=0;return r.type==="file"&&(n=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){ie(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let n=0;return r.type==="file"&&(n=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),u=0,c=40;for(;l&&l.type==="symlink"&&u<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,l.target),l=this.data.get(n),u++}if(u>=c)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,u=40;for(;a&&a.type==="symlink"&&l<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=this.resolveSymlink(n,a.target),a=this.data.get(n),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){ie(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=this.dirname(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){ie(t,"scandir");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let u=a.slice(i.length),c=u.split("/")[0];c&&!u.includes("/",c.length)&&!o.has(c)&&o.set(c,{name:c,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){ie(t,"rm");let r=this.normalizePath(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){ie(t,"cp"),ie(s,"cp");let n=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{type:"file",chunks:[...o.chunks],size:o.size,mode:o.mode,mtime:o.mtime});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let u=n==="/"?`/${l}`:`${n}/${l}`,c=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(u,c,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}async chmod(t,s){ie(t,"chmod");let r=this.normalizePath(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){ie(s,"symlink");let r=this.normalizePath(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){ie(t,"link"),ie(s,"link");let r=this.normalizePath(t),n=this.normalizePath(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:[...i.chunks],size:i.size,mode:i.mode,mtime:i.mtime})}async readlink(t){ie(t,"readlink");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){ie(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){ie(t,"utimes");let n=this.normalizePath(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function Fi(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Li(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function zi(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function Wi(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Nr}
|
|
1
|
+
import{A as Ss,C as zr,D as Wr,E as ge,F as Ze,G as ae,H as xe,I as Ft,J as Vr,K as V,L as Br,M as jr,N as Ie,O as $s,P as Lt,Q as tt,R as K,a as Nr,b as gs,c as Tr,d as Or,e as Rt,f as ne,g as Z,h as Te,i as ce,j as Oe,k as je,l as ws,m as Mt,n as Dr,o as vs,p as Ir,q as ye,r as Le,s as Rr,t as Mr,u as bs,v as Es,w as De,x as Fr,y as Lr,z as Ce}from"./chunks/chunk-U6GF4IJH.js";import{a as xr}from"./chunks/chunk-MIFIRXNI.js";import{a as Be,b as _e}from"./chunks/chunk-UBLR5ACC.js";import{a as bt}from"./chunks/chunk-YNYSPYQ5.js";import{a as Ee,b as Se,c as me,d as Ae,e as _r,f as Y,g as qe,h as Ot,i as Dt,j as Cr,k as de,l as Ve,m as It,n as ke}from"./chunks/chunk-JSLN56GJ.js";import"./chunks/chunk-NUFRM6SI.js";import{a as Fe}from"./chunks/chunk-44UOCSGV.js";import{a as et,b as w,c as se,d as he,e as C,f as H,g as Ge,h as O,i as Tt,j as ys,k as ki,l as _i,m as Ci}from"./chunks/chunk-7USKQKOT.js";import{a as vt,g as F,h as B,i as j,j as Ar,k as Je,l as T,m as g,n as kr}from"./chunks/chunk-DEQBZDPB.js";var Xe=[{name:"echo",load:async()=>(await import("./chunks/echo-ZPFMTGPQ.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-KHANCARN.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-223LFYZL.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-JAO4QNWZ.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-O74MZREV.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-LGJXG7S3.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-7BNOFP74.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-NIZVTCU7.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-FD6I3O6B.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-66ALAQRO.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-N3OWFM3J.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-A3HCFC4L.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-BP6H5JPD.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-JL7TKP5U.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-CIKXFGO5.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-GJ536HFQ.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-PWYVRT3X.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-2CKLARLN.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-KLQ4A2OH.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-KLQ4A2OH.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-KLQ4A2OH.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-RA3U4BVJ.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-JJ3WRWYT.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-LA5EZ6UJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-BNPU2P3T.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-ZHYLWEFM.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-47FVEMHB.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-LQZW2NZP.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-Y7CG4TKC.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-TB6CSIUV.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-UN4ZHPP5.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-JSPXHHOM.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-6O4H3AW4.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-Y7EMR5BJ.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-LDC3OTY4.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-LG7URPXR.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-SVMZIFGF.js")).split},{name:"column",load:async()=>(await import("./chunks/column-OUJRIWLX.js")).column},{name:"join",load:async()=>(await import("./chunks/join-CFMKSF44.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-PJ6B6JJF.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-BYG3GTNV.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-NCIQLNXY.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-IVA4YYRE.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-4XRVONUX.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-H4GJHM4R.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-ZCKP6263.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-ZCKP6263.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JHV3WNPA.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JHV3WNPA.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-N2VRLHEO.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-CB3LOKW5.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-4UI5ZW75.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-4UI5ZW75.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-7SIFUXVD.js")).clearCommand},{name:"yes",load:async()=>(await import("./chunks/yes-2J55KNKF.js")).yesCommand},{name:"bash",load:async()=>(await import("./chunks/bash-CN3UUJ3N.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-CN3UUJ3N.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-BE76GAFF.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-DP3BVL7J.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-7ZYMEVUP.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-FQF5KOV7.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-YQMDXMVK.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-SXUKTL7R.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-IENYNVU4.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-SXS6YKWX.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-WDFXVU43.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-ZK2D5HMO.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BB464H3H.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-PPJUHZ6A.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-7WSECN2B.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-ZDG5GHHM.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-B2UCSYQN.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-EIT2IJGG.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-NXGTFB5T.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-W7U3GOEK.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-QZJHAL2R.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-NUINXLUX.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-BYGAV4XY.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-BYGAV4XY.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-BYGAV4XY.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Xe.push({name:"tar",load:async()=>(await import("./chunks/tar-3KCFO6WZ.js")).tarCommand}),Xe.push({name:"yq",load:async()=>(await import("./chunks/yq-JFXSVU6G.js")).yqCommand}),Xe.push({name:"xan",load:async()=>(await import("./chunks/xan-JDD2TEQH.js")).xanCommand}),Xe.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-PZGLI6XB.js")).sqlite3Command}));var zt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(zt.push({name:"python3",load:async()=>(await import("./chunks/python3-2KEMASKS.js")).python3Command}),zt.push({name:"python",load:async()=>(await import("./chunks/python3-2KEMASKS.js")).pythonCommand}));var Hr=[{name:"curl",load:async()=>(await import("./chunks/curl-3MHMRKXA.js")).curlCommand}],Ur=new Map;function Ps(e){return{name:e.name,async execute(t,s){let r=Ur.get(e.name);if(r||(r=await e.load(),Ur.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-MFTK2J2P.js"),{decodeArgs:i}=await import("./chunks/bytes-JUNATFIO.js");n(s.coverage,e.name,i(t))}return r.execute(t,s)}}}function xi(){return Xe.map(e=>e.name)}function Ni(){return Hr.map(e=>e.name)}function Gr(e){return(e?Xe.filter(s=>e.includes(s.name)):Xe).map(Ps)}function qr(){return Hr.map(Ps)}function Ti(){return zt.map(e=>e.name)}function Zr(){return zt.map(Ps)}function Xr(e){return"load"in e&&typeof e.load=="function"}function Oi(e,t){return{name:e,async execute(s,r){let n={...r,env:kr(r.env)},i=await t(Je(s),n);return typeof i.stdout=="string"?{stdout:C(i.stdout),stderr:C(i.stderr),exitCode:i.exitCode}:i}}}function Yr(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var Di=new TextEncoder;function Ii(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function Ri(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)s[r/2]=parseInt(e.slice(r,r+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,n=>n.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}return Di.encode(e)}function Qr(e){if(e.length===0)return[];if(e.length<=et)return[e];let t=[];for(let s=0;s<e.length;s+=et)t.push(e.subarray(s,Math.min(s+et,e.length)));return t}function st(e,t){let s=Ri(e,t);return{chunks:Qr(s),size:s.length}}async function ze(e,t){if(Ii(e)){let s=[],r=0;for await(let n of ys(e))if(n.length<=et)s.push(n),r+=n.length;else for(let i of Qr(n))s.push(i),r+=i.length;return{chunks:s,size:r}}return st(e,t)}function Wt(e,t){if(t==="base64")return btoa(xr(Kr(e)));if(t==="hex"){let n="";for(let i of e)for(let o=0;o<i.length;o++)n+=i[o].toString(16).padStart(2,"0");return n}if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(Kr(e)).toString(t);let n=65536,i="";for(let o of e)if(o.length<=n)i+=String.fromCharCode(...o);else for(let a=0;a<o.length;a+=n){let l=o.subarray(a,a+n);i+=String.fromCharCode(...l)}return i}let s=new TextDecoder,r="";for(let n of e)n.length>0&&(r+=s.decode(n,{stream:!0}));return r+=s.decode(),r}function Kr(e){let t=0;for(let n of e)t+=n.length;if(t===0)return new Uint8Array(0);if(e.length===1)return e[0];let s=new Uint8Array(t),r=0;for(let n of e)s.set(n,r),r+=n.length;return s}function $e(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}function rt(e,t){if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new Error(`EINVAL: invalid offset (must be a non-negative integer): ${e}`);if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new Error(`EINVAL: invalid length (must be a non-negative integer): ${t}`)}function Vt(e,t,s,r){if(s>=t||r===0)return new Uint8Array(0);let n=Math.min(s+r,t),i=n-s,o=new Uint8Array(i),a=0,l=0;for(let u of e){if(a>=i)break;let c=l+u.length;if(c>s&&l<n){let f=Math.max(0,s-l),h=Math.min(u.length,n-l),d=u.subarray(f,h);o.set(d,a),a+=d.length}l=c}return o}function Mi(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&!(e instanceof ReadableStream)&&"content"in e}function ie(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var We=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))if(Mi(r)){if(r.content instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime})}else{if(r instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,r)}}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){ie(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=$e(r),{chunks:a,size:l}=st(s,o);this.data.set(i,{type:"file",chunks:a,size:l,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t){ie(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return he(r.chunks)}async readRange(t,s,r){rt(s,r),ie(t,"open");let n=this.resolvePathWithSymlinks(t),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(i.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return Vt(i.chunks,i.size,s,r)}async readFileText(t,s){ie(t,"open");let r=this.resolvePathWithSymlinks(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);let i=$e(s);return Wt(n.chunks,i)}async writeFile(t,s,r){ie(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n);let i=$e(r),{chunks:o,size:a}=await ze(s,i);this.data.set(n,{type:"file",chunks:o,size:a,mode:420,mtime:new Date})}async appendFile(t,s,r){ie(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=$e(r),{chunks:a,size:l}=await ze(s,o);i?.type==="file"?this.data.set(n,{type:"file",chunks:[...i.chunks,...a],size:i.size+l,mode:i.mode,mtime:new Date}):(this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:a,size:l,mode:420,mtime:new Date}))}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){ie(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=0;return r.type==="file"&&(n=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){ie(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let n=0;return r.type==="file"&&(n=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),u=0,c=40;for(;l&&l.type==="symlink"&&u<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,l.target),l=this.data.get(n),u++}if(u>=c)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,u=40;for(;a&&a.type==="symlink"&&l<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=this.resolveSymlink(n,a.target),a=this.data.get(n),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){ie(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=this.dirname(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){ie(t,"scandir");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let u=a.slice(i.length),c=u.split("/")[0];c&&!u.includes("/",c.length)&&!o.has(c)&&o.set(c,{name:c,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){ie(t,"rm");let r=this.normalizePath(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){ie(t,"cp"),ie(s,"cp");let n=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{type:"file",chunks:[...o.chunks],size:o.size,mode:o.mode,mtime:o.mtime});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let u=n==="/"?`/${l}`:`${n}/${l}`,c=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(u,c,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}async chmod(t,s){ie(t,"chmod");let r=this.normalizePath(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){ie(s,"symlink");let r=this.normalizePath(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){ie(t,"link"),ie(s,"link");let r=this.normalizePath(t),n=this.normalizePath(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:[...i.chunks],size:i.size,mode:i.mode,mtime:i.mtime})}async readlink(t){ie(t,"readlink");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){ie(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){ie(t,"utimes");let n=this.normalizePath(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function Fi(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Li(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function zi(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function Wi(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Nr}
|
|
2
2
|
`),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
|
|
3
3
|
`),e.writeFileSync("/proc/self/status",Tr()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function Jr(e,t){Fi(e)&&(Li(e,t),zi(e),Wi(e))}var Vi=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Bi=["braceexpand","hashall","interactive-comments"];function As(e){let t=[],s=[...Bi.map(r=>({name:r,enabled:!0})),...Vi.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(":")}function nt(e){g(e.state.env,"SHELLOPTS",As(e.state.options))}var ji=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function ks(e){let t=[];for(let s of ji)e[s]&&t.push(s);return t.join(":")}function _s(e){g(e.state.env,"BASHOPTS",ks(e.state.shoptOptions))}var Ui="BASH_ALIAS_";function en(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function tn(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function sn(e,t){let s=e.env.get(`${Ui}${t}`);return s!==void 0?j(s):void 0}function Cs(e,t,s){if(!t.name||!en(t.name))return t;let r=tn(t.name);if(!r)return t;let n=sn(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new Z,o=n,a=n.endsWith(" ");if(!a)for(let f of t.args){let h=nn(f);o+=` ${h}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof Rt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return rn(t,n);let u=l.statements[0].pipelines[0].commands[0];if(u.type!=="SimpleCommand")return rn(t,n);let c={...u,assignments:[...t.assignments,...u.assignments],redirections:[...u.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(c={...c,args:[...c.args,...t.args]},c.args.length>0)){let f=c.args[0];if(en(f)){let h=tn(f);if(h&&sn(e,h)){let d={type:"SimpleCommand",name:f,args:c.args.slice(1),assignments:[],redirections:[]},m=Cs(e,d,s);m!==d&&(c={...c,name:m.name,args:[...m.args]})}}}return c}catch(i){throw s.delete(r),i}}function rn(e,t){let s=t;for(let o of e.args){let a=nn(o);s+=` ${a}`}let r=new Z,n=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function nn(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function on(e,t){let s=t.parts.map(c=>c.type==="Literal"?c.value:"\0").join(""),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!s.endsWith(")"))return null;let n=r[1],i=[],o=!1,a="",l=!1;for(let c of t.parts)if(c.type==="Literal"){let f=c.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let d of h)/^\s+$/.test(d)?(a||l)&&(i.push(a),a="",l=!1):d&&(a+=d)}}else if(o)if(c.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Mt({type:"Word",parts:[c]});else{(a||l)&&(i.push(a),a="",l=!1);let h=await Ie(e,{type:"Word",parts:[c]});i.push(...h.values)}else{(c.type==="SingleQuoted"||c.type==="DoubleQuoted"||c.type==="Escaped")&&(l=!0);let f=await V(e,{type:"Word",parts:[c]});a+=f}(a||l)&&i.push(a);let u=i.map(c=>/^\[.+\]=/.test(c)?c:c===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(c)&&!c.startsWith("'")&&!c.startsWith('"')?`'${c.replace(/'/g,"'\\''")}'`:c);return`${n}=(${u.join(" ")})`}async function an(e,t){let s=-1,r=-1,n=!1;for(let p=0;p<t.parts.length;p++){let v=t.parts[p];if(v.type==="Literal"){let y=v.value.indexOf("+=");if(y!==-1){let A=v.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(A)){s=p,r=y,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(A)){s=p,r=y,n=!0;break}}let S=v.value.indexOf("=");if(S!==-1&&(S===0||v.value[S-1]!=="+")){let A=v.value.slice(0,S);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(A)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(A)){s=p,r=S;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!=="Literal")return null;let a=n?2:1,l=o.value.slice(0,r),u=o.value.slice(r+a),c=t.parts.slice(s+1),f="";for(let p of i)f+=await V(e,{type:"Word",parts:[p]});f+=l;let h={type:"Word",parts:u!==""?[{type:"Literal",value:u},...c]:c},d=h.parts.length>0?await V(e,h):"";return`${f}${n?"+=":"="}${d}`}var Hi=["tar","yq","xan","sqlite3","python3","python"];function ln(e){return Hi.includes(e)}function U(){return{stdout:w(),stderr:w(),exitCode:0}}var it={get stdout(){return w()},get stderr(){return w()},exitCode:0};function Pe(e=w()){return{stdout:e,stderr:w(),exitCode:0}}function X(e){return{stdout:C(e),stderr:w(),exitCode:0}}function k(e,t=1){return{stdout:w(),stderr:C(e),exitCode:t}}function R(e,t,s){return{stdout:e instanceof Uint8Array?se(e):e,stderr:t instanceof Uint8Array?se(t):t,exitCode:s}}function re(e){return{stdout:w(),stderr:w(),exitCode:e?0:1}}function Ne(e,t,s,r){let n=s===void 0?w():s instanceof Uint8Array?se(s):s,i=r===void 0?void 0:r instanceof Uint8Array?se(r):r;throw new de(e,t,n,i)}function xs(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ve;return U()}if(t.length>1)throw new Y(1,w(),C(`bash: break: too many arguments
|
|
4
4
|
`));let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new Y(128,w(),C(`bash: break: ${t[0]}: numeric argument required
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* date - Display the current date and time
|
|
3
3
|
*/
|
|
4
4
|
import type { Command } from "../../types.js";
|
|
5
|
-
export declare const dateCommand: Command;
|
|
6
5
|
import type { CommandFuzzInfo } from "../fuzz-flags-types.js";
|
|
6
|
+
export declare const dateCommand: Command;
|
|
7
7
|
export declare const flagsForFuzzing: CommandFuzzInfo;
|
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as y,b as M,c as k}from"./chunk-DFAHK2EQ.js";import{b as g,e as h}from"./chunk-RAUBS6MJ.js";import{k as T,l as w}from"./chunk-463VWH7H.js";var I={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)"," --timezone=TZ use the named IANA time zone (e.g. America/New_York)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit","","If --timezone is not given, the TZ environment variable is used."]},N=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],H=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function i(r,n=2){return String(r).padStart(n,"0")}var v={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};function D(r,n){let a=new Intl.DateTimeFormat("en-US",{timeZone:n,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e={};for(let t of a.formatToParts(r))e[t.type]=t.value;let o=Number.parseInt(e.hour,10);return o===24&&(o=0),{Y:Number.parseInt(e.year,10),m:Number.parseInt(e.month,10)-1,D:Number.parseInt(e.day,10),H:o,M:Number.parseInt(e.minute,10),S:Number.parseInt(e.second,10),w:v[e.weekday]??0}}function $(r,n){let a=D(r,n),e=Date.UTC(a.Y,a.m,a.D,a.H,a.M,a.S);return Math.round((e-r.getTime())/6e4)}function F(r){let n=r>=0?"+":"-",a=Math.abs(r);return`${n}${i(Math.floor(a/60))}${i(a%60)}`}function z(r,n){let a=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"short"});for(let e of a.formatToParts(r))if(e.type==="timeZoneName")return e.value;return n??""}function S(r,n,a){let e=D(r,a),o=$(r,a),t="",u=0;for(;u<n.length;){if(n[u]==="%"&&u+1<n.length){let f=n[++u];switch(f){case"%":t+="%";break;case"a":t+=N[e.w];break;case"b":case"h":t+=H[e.m];break;case"d":t+=i(e.D);break;case"e":t+=String(e.D).padStart(2," ");break;case"F":t+=`${e.Y}-${i(e.m+1)}-${i(e.D)}`;break;case"H":t+=i(e.H);break;case"I":t+=i(e.H%12||12);break;case"m":t+=i(e.m+1);break;case"M":t+=i(e.M);break;case"n":t+=`
|
|
3
|
-
`;break;case"p":t+=e.H<12?"AM":"PM";break;case"P":t+=e.H<12?"am":"pm";break;case"R":t+=`${i(e.H)}:${i(e.M)}`;break;case"s":t+=Math.floor(r.getTime()/1e3);break;case"S":t+=i(e.S);break;case"t":t+=" ";break;case"T":t+=`${i(e.H)}:${i(e.M)}:${i(e.S)}`;break;case"u":t+=e.w||7;break;case"w":t+=e.w;break;case"y":t+=i(e.Y%100);break;case"Y":t+=e.Y;break;case"z":t+=F(o);break;case"Z":t+=z(r,a);break;default:t+=`%${f}`}}else t+=n[u];u++}return t}function Y(r){let n=new Date(r);if(!Number.isNaN(n.getTime()))return n;if(/^\d+$/.test(r))return new Date(Number.parseInt(r,10)*1e3);let a=r.toLowerCase();return a==="now"||a==="today"?new Date:a==="yesterday"?new Date(Date.now()-864e5):a==="tomorrow"?new Date(Date.now()+864e5):null}var O={name:"date",async execute(r,n){let a=T(r);if(M(a))return y(I);let e=!1,o=null,t=null,u=!1,f=!1,d=null;for(let c=0;c<a.length;c++){let s=a[c];if(s==="-u"||s==="--utc")e=!0;else if(s==="-d"||s==="--date")o=a[++c]??"";else if(s.startsWith("--date="))o=s.slice(7);else if(s==="--timezone")d=a[++c]??"";else if(s.startsWith("--timezone="))d=s.slice(11);else if(s==="-I"||s==="--iso-8601")u=!0;else if(s==="-R"||s==="--rfc-email")f=!0;else if(s.startsWith("+"))t=s.slice(1);else{if(s.startsWith("--"))return k("date",s);if(s.startsWith("-"))for(let p of s.slice(1))if(p==="u")e=!0;else if(p==="I")u=!0;else if(p==="R")f=!0;else return k("date",`-${p}`)}}let l;if(e)l="UTC";else if(d!==null&&d!=="")l=d;else{let c=w(n.env,"TZ");c&&(l=c)}if(l!==void 0)try{new Intl.DateTimeFormat("en-US",{timeZone:l})}catch{return{stdout:g(),stderr:h(`date: invalid time zone '${l}'
|
|
4
|
-
`),exitCode:1}}let m=o!==null?Y(o):new Date;if(!m)return{stdout:g(),stderr:h(`date: invalid date '${o}'
|
|
5
|
-
`),exitCode:1};let b;return t?b=S(m,t,l):u?b=S(m,"%Y-%m-%dT%H:%M:%S%z",l):f?b=S(m,"%a, %d %b %Y %H:%M:%S %z",l):b=S(m,"%a %b %e %H:%M:%S %Z %Y",l),{stdout:h(`${b}
|
|
6
|
-
`),stderr:g(),exitCode:0}}},U={name:"date",flags:[{flag:"-d",type:"value",valueHint:"string"},{flag:"-u",type:"boolean"},{flag:"-I",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"--timezone",type:"value",valueHint:"string"}]};export{O as a,U as b};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as y,b as M,c as k}from"./chunk-DFAHK2EQ.js";import{b as g,e as h}from"./chunk-RAUBS6MJ.js";import{k as T,l as w}from"./chunk-463VWH7H.js";var I={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)"," --timezone=TZ use the named IANA time zone (e.g. America/New_York)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit","","If --timezone is not given, the TZ environment variable is used."]},N=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],H=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function i(r,n=2){return String(r).padStart(n,"0")}var v={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};function D(r,n){let a=new Intl.DateTimeFormat("en-US",{timeZone:n,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e={};for(let t of a.formatToParts(r))e[t.type]=t.value;let o=Number.parseInt(e.hour,10);return o===24&&(o=0),{Y:Number.parseInt(e.year,10),m:Number.parseInt(e.month,10)-1,D:Number.parseInt(e.day,10),H:o,M:Number.parseInt(e.minute,10),S:Number.parseInt(e.second,10),w:v[e.weekday]??0}}function $(r,n){let a=D(r,n),e=Date.UTC(a.Y,a.m,a.D,a.H,a.M,a.S);return Math.round((e-r.getTime())/6e4)}function F(r){let n=r>=0?"+":"-",a=Math.abs(r);return`${n}${i(Math.floor(a/60))}${i(a%60)}`}function z(r,n){let a=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"short"});for(let e of a.formatToParts(r))if(e.type==="timeZoneName")return e.value;return n??""}function S(r,n,a){let e=D(r,a),o=$(r,a),t="",u=0;for(;u<n.length;){if(n[u]==="%"&&u+1<n.length){let f=n[++u];switch(f){case"%":t+="%";break;case"a":t+=N[e.w];break;case"b":case"h":t+=H[e.m];break;case"d":t+=i(e.D);break;case"e":t+=String(e.D).padStart(2," ");break;case"F":t+=`${e.Y}-${i(e.m+1)}-${i(e.D)}`;break;case"H":t+=i(e.H);break;case"I":t+=i(e.H%12||12);break;case"m":t+=i(e.m+1);break;case"M":t+=i(e.M);break;case"n":t+=`
|
|
3
|
-
`;break;case"p":t+=e.H<12?"AM":"PM";break;case"P":t+=e.H<12?"am":"pm";break;case"R":t+=`${i(e.H)}:${i(e.M)}`;break;case"s":t+=Math.floor(r.getTime()/1e3);break;case"S":t+=i(e.S);break;case"t":t+=" ";break;case"T":t+=`${i(e.H)}:${i(e.M)}:${i(e.S)}`;break;case"u":t+=e.w||7;break;case"w":t+=e.w;break;case"y":t+=i(e.Y%100);break;case"Y":t+=e.Y;break;case"z":t+=F(o);break;case"Z":t+=z(r,a);break;default:t+=`%${f}`}}else t+=n[u];u++}return t}function Y(r){let n=new Date(r);if(!Number.isNaN(n.getTime()))return n;if(/^\d+$/.test(r))return new Date(Number.parseInt(r,10)*1e3);let a=r.toLowerCase();return a==="now"||a==="today"?new Date:a==="yesterday"?new Date(Date.now()-864e5):a==="tomorrow"?new Date(Date.now()+864e5):null}var O={name:"date",async execute(r,n){let a=T(r);if(M(a))return y(I);let e=!1,o=null,t=null,u=!1,f=!1,d=null;for(let c=0;c<a.length;c++){let s=a[c];if(s==="-u"||s==="--utc")e=!0;else if(s==="-d"||s==="--date")o=a[++c]??"";else if(s.startsWith("--date="))o=s.slice(7);else if(s==="--timezone")d=a[++c]??"";else if(s.startsWith("--timezone="))d=s.slice(11);else if(s==="-I"||s==="--iso-8601")u=!0;else if(s==="-R"||s==="--rfc-email")f=!0;else if(s.startsWith("+"))t=s.slice(1);else{if(s.startsWith("--"))return k("date",s);if(s.startsWith("-"))for(let p of s.slice(1))if(p==="u")e=!0;else if(p==="I")u=!0;else if(p==="R")f=!0;else return k("date",`-${p}`)}}let l;if(e)l="UTC";else if(d!==null&&d!=="")l=d;else{let c=w(n.env,"TZ");c&&(l=c)}if(l!==void 0)try{new Intl.DateTimeFormat("en-US",{timeZone:l})}catch{return{stdout:g(),stderr:h(`date: invalid time zone '${l}'
|
|
4
|
-
`),exitCode:1}}let m=o!==null?Y(o):new Date;if(!m)return{stdout:g(),stderr:h(`date: invalid date '${o}'
|
|
5
|
-
`),exitCode:1};let b;return t?b=S(m,t,l):u?b=S(m,"%Y-%m-%dT%H:%M:%S%z",l):f?b=S(m,"%a, %d %b %Y %H:%M:%S %z",l):b=S(m,"%a %b %e %H:%M:%S %Z %Y",l),{stdout:h(`${b}
|
|
6
|
-
`),stderr:g(),exitCode:0}}},U={name:"date",flags:[{flag:"-d",type:"value",valueHint:"string"},{flag:"-u",type:"boolean"},{flag:"-I",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"--timezone",type:"value",valueHint:"string"}]};export{O as a,U as b};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as y,b as M,c as k}from"./chunk-PQPG4QOY.js";import{b as g,e as h}from"./chunk-7USKQKOT.js";import{k as T,l as w}from"./chunk-DEQBZDPB.js";var I={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)"," --timezone=TZ use the named IANA time zone (e.g. America/New_York)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit","","If --timezone is not given, the TZ environment variable is used."]},N=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],H=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function i(r,n=2){return String(r).padStart(n,"0")}var v={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};function D(r,n){let a=new Intl.DateTimeFormat("en-US",{timeZone:n,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e={};for(let t of a.formatToParts(r))e[t.type]=t.value;let o=Number.parseInt(e.hour,10);return o===24&&(o=0),{Y:Number.parseInt(e.year,10),m:Number.parseInt(e.month,10)-1,D:Number.parseInt(e.day,10),H:o,M:Number.parseInt(e.minute,10),S:Number.parseInt(e.second,10),w:v[e.weekday]??0}}function $(r,n){let a=D(r,n),e=Date.UTC(a.Y,a.m,a.D,a.H,a.M,a.S);return Math.round((e-r.getTime())/6e4)}function F(r){let n=r>=0?"+":"-",a=Math.abs(r);return`${n}${i(Math.floor(a/60))}${i(a%60)}`}function z(r,n){let a=new Intl.DateTimeFormat("en-US",{timeZone:n,timeZoneName:"short"});for(let e of a.formatToParts(r))if(e.type==="timeZoneName")return e.value;return n??""}function S(r,n,a){let e=D(r,a),o=$(r,a),t="",u=0;for(;u<n.length;){if(n[u]==="%"&&u+1<n.length){let f=n[++u];switch(f){case"%":t+="%";break;case"a":t+=N[e.w];break;case"b":case"h":t+=H[e.m];break;case"d":t+=i(e.D);break;case"e":t+=String(e.D).padStart(2," ");break;case"F":t+=`${e.Y}-${i(e.m+1)}-${i(e.D)}`;break;case"H":t+=i(e.H);break;case"I":t+=i(e.H%12||12);break;case"m":t+=i(e.m+1);break;case"M":t+=i(e.M);break;case"n":t+=`
|
|
2
|
-
`;break;case"p":t+=e.H<12?"AM":"PM";break;case"P":t+=e.H<12?"am":"pm";break;case"R":t+=`${i(e.H)}:${i(e.M)}`;break;case"s":t+=Math.floor(r.getTime()/1e3);break;case"S":t+=i(e.S);break;case"t":t+=" ";break;case"T":t+=`${i(e.H)}:${i(e.M)}:${i(e.S)}`;break;case"u":t+=e.w||7;break;case"w":t+=e.w;break;case"y":t+=i(e.Y%100);break;case"Y":t+=e.Y;break;case"z":t+=F(o);break;case"Z":t+=z(r,a);break;default:t+=`%${f}`}}else t+=n[u];u++}return t}function Y(r){let n=new Date(r);if(!Number.isNaN(n.getTime()))return n;if(/^\d+$/.test(r))return new Date(Number.parseInt(r,10)*1e3);let a=r.toLowerCase();return a==="now"||a==="today"?new Date:a==="yesterday"?new Date(Date.now()-864e5):a==="tomorrow"?new Date(Date.now()+864e5):null}var O={name:"date",async execute(r,n){let a=T(r);if(M(a))return y(I);let e=!1,o=null,t=null,u=!1,f=!1,d=null;for(let c=0;c<a.length;c++){let s=a[c];if(s==="-u"||s==="--utc")e=!0;else if(s==="-d"||s==="--date")o=a[++c]??"";else if(s.startsWith("--date="))o=s.slice(7);else if(s==="--timezone")d=a[++c]??"";else if(s.startsWith("--timezone="))d=s.slice(11);else if(s==="-I"||s==="--iso-8601")u=!0;else if(s==="-R"||s==="--rfc-email")f=!0;else if(s.startsWith("+"))t=s.slice(1);else{if(s.startsWith("--"))return k("date",s);if(s.startsWith("-"))for(let p of s.slice(1))if(p==="u")e=!0;else if(p==="I")u=!0;else if(p==="R")f=!0;else return k("date",`-${p}`)}}let l;if(e)l="UTC";else if(d!==null&&d!=="")l=d;else{let c=w(n.env,"TZ");c&&(l=c)}if(l!==void 0)try{new Intl.DateTimeFormat("en-US",{timeZone:l})}catch{return{stdout:g(),stderr:h(`date: invalid time zone '${l}'
|
|
3
|
-
`),exitCode:1}}let m=o!==null?Y(o):new Date;if(!m)return{stdout:g(),stderr:h(`date: invalid date '${o}'
|
|
4
|
-
`),exitCode:1};let b;return t?b=S(m,t,l):u?b=S(m,"%Y-%m-%dT%H:%M:%S%z",l):f?b=S(m,"%a, %d %b %Y %H:%M:%S %z",l):b=S(m,"%a %b %e %H:%M:%S %Z %Y",l),{stdout:h(`${b}
|
|
5
|
-
`),stderr:g(),exitCode:0}}},U={name:"date",flags:[{flag:"-d",type:"value",valueHint:"string"},{flag:"-u",type:"boolean"},{flag:"-I",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"--timezone",type:"value",valueHint:"string"}]};export{O as a,U as b};
|