@eidos.space/just-bash 3.0.2 → 3.0.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/{curl-PLHETP4J.js → curl-DCSPNPEW.js} +1 -1
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/{curl-PLHETP4J.js → curl-DCSPNPEW.js} +1 -1
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/browser.js +655 -583
- package/dist/bundle/chunks/chunk-LXDNRKHV.js +28 -0
- package/dist/bundle/chunks/chunk-MUGJLS3O.js +15 -0
- package/dist/bundle/chunks/chunk-RLAAFSP3.js +19 -0
- package/dist/bundle/chunks/chunk-UZR7BRBM.js +84 -0
- package/dist/bundle/chunks/{curl-GRYA74XW.js → curl-PAWGO3EH.js} +1 -1
- package/dist/bundle/chunks/{diff-MWJFIG7X.js → diff-5MIVVRRQ.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-XWSYNE72.js → flag-coverage-YKB23BRI.js} +1 -1
- package/dist/bundle/chunks/{html-to-markdown-JW4MSQZO.js → html-to-markdown-WGBAMDHY.js} +1 -1
- package/dist/bundle/chunks/{ls-ZJGQER7M.js → ls-GFWJAGZ5.js} +1 -1
- package/dist/bundle/chunks/{printf-TWGXF445.js → printf-H2KM2USM.js} +1 -1
- package/dist/bundle/index.cjs +1287 -1198
- package/dist/bundle/index.js +1 -1
- package/package.json +4 -4
- package/dist/bundle/chunks/chunk-CBJVD2XA.js +0 -7
- package/dist/bundle/chunks/chunk-GIUR5SNU.js +0 -15
- package/dist/bundle/chunks/chunk-R4IFXNY5.js +0 -28
- package/dist/bundle/chunks/chunk-R74UQCKX.js +0 -5
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{a as I}from"./chunk-QIQMJJZ4.js";import{a as K,b as V}from"./chunk-QAYAQNCG.js";var B=(i,t,e)=>{let s=i instanceof RegExp?Y(i,e):i,n=t instanceof RegExp?Y(t,e):t,r=s!==null&&n!=null&&Et(s,n,e);return r&&{start:r[0],end:r[1],pre:e.slice(0,r[0]),body:e.slice(r[0]+s.length,r[1]),post:e.slice(r[1]+n.length)}},Y=(i,t)=>{let e=t.match(i);return e?e[0]:null},Et=(i,t,e)=>{let s,n,r,o,l,h=e.indexOf(i),c=e.indexOf(t,h+1),g=h;if(h>=0&&c>0){if(i===t)return[h,c];for(s=[],r=e.length;g>=0&&!l;){if(g===h)s.push(g),h=e.indexOf(i,g+1);else if(s.length===1){let a=s.pop();a!==void 0&&(l=[a,c])}else n=s.pop(),n!==void 0&&n<r&&(r=n,o=c),c=e.indexOf(t,g+1);g=h<c&&h>=0?h:c}s.length&&o!==void 0&&(l=[r,o])}return l};var Q="\0SLASH"+Math.random()+"\0",tt="\0OPEN"+Math.random()+"\0",q="\0CLOSE"+Math.random()+"\0",et="\0COMMA"+Math.random()+"\0",st="\0PERIOD"+Math.random()+"\0",Mt=new RegExp(Q,"g"),At=new RegExp(tt,"g"),Pt=new RegExp(q,"g"),Tt=new RegExp(et,"g"),Nt=new RegExp(st,"g"),Rt=/\\\\/g,vt=/\\{/g,Ot=/\\}/g,zt=/\\,/g,Ct=/\\\./g,Wt=1e5;function H(i){return isNaN(i)?i.charCodeAt(0):parseInt(i,10)}function Dt(i){return i.replace(Rt,Q).replace(vt,tt).replace(Ot,q).replace(zt,et).replace(Ct,st)}function jt(i){return i.replace(Mt,"\\").replace(At,"{").replace(Pt,"}").replace(Tt,",").replace(Nt,".")}function nt(i){if(!i)return[""];let t=[],e=B("{","}",i);if(!e)return i.split(",");let{pre:s,body:n,post:r}=e,o=s.split(",");o[o.length-1]+="{"+n+"}";let l=nt(r);return r.length&&(o[o.length-1]+=l.shift(),o.push.apply(o,l)),t.push.apply(t,o),t}function it(i,t={}){if(!i)return[];let{max:e=Wt}=t;return i.slice(0,2)==="{}"&&(i="\\{\\}"+i.slice(2)),j(Dt(i),e,!0).map(jt)}function Lt(i){return"{"+i+"}"}function kt(i){return/^-?0\d/.test(i)}function _t(i,t){return i<=t}function Gt(i,t){return i>=t}function j(i,t,e){let s=[],n=B("{","}",i);if(!n)return[i];let r=n.pre,o=n.post.length?j(n.post,t,!1):[""];if(/\$$/.test(n.pre))for(let l=0;l<o.length&&l<t;l++){let h=r+"{"+n.body+"}"+o[l];s.push(h)}else{let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),h=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=l||h,g=n.body.indexOf(",")>=0;if(!c&&!g)return n.post.match(/,(?!,).*\}/)?(i=n.pre+"{"+n.body+q+n.post,j(i,t,!0)):[i];let a;if(c)a=n.body.split(/\.\./);else if(a=nt(n.body),a.length===1&&a[0]!==void 0&&(a=j(a[0],t,!1).map(Lt),a.length===1))return o.map(u=>n.pre+a[0]+u);let p;if(c&&a[0]!==void 0&&a[1]!==void 0){let u=H(a[0]),d=H(a[1]),f=Math.max(a[0].length,a[1].length),$=a.length===3&&a[2]!==void 0?Math.max(Math.abs(H(a[2])),1):1,S=_t;d<u&&($*=-1,S=Gt);let b=a.some(kt);p=[];for(let y=u;S(y,d);y+=$){let w;if(h)w=String.fromCharCode(y),w==="\\"&&(w="");else if(w=String(y),b){let E=f-w.length;if(E>0){let x=new Array(E+1).join("0");y<0?w="-"+x+w.slice(1):w=x+w}}p.push(w)}}else{p=[];for(let u=0;u<a.length;u++)p.push.apply(p,j(a[u],t,!1))}for(let u=0;u<p.length;u++)for(let d=0;d<o.length&&s.length<t;d++){let f=r+p[u]+o[d];(!e||c||f)&&s.push(f)}}return s}var L=i=>{if(typeof i!="string")throw new TypeError("invalid pattern");if(i.length>65536)throw new TypeError("pattern is too long")};var Ft={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},k=i=>i.replace(/[[\]\\-]/g,"\\$&"),Bt=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),rt=i=>i.join(""),ot=(i,t)=>{let e=t;if(i.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],n=[],r=e+1,o=!1,l=!1,h=!1,c=!1,g=e,a="";t:for(;r<i.length;){let f=i.charAt(r);if((f==="!"||f==="^")&&r===e+1){c=!0,r++;continue}if(f==="]"&&o&&!h){g=r+1;break}if(o=!0,f==="\\"&&!h){h=!0,r++;continue}if(f==="["&&!h){for(let[$,[S,m,b]]of Object.entries(Ft))if(i.startsWith($,r)){if(a)return["$.",!1,i.length-e,!0];r+=$.length,b?n.push(S):s.push(S),l=l||m;continue t}}if(h=!1,a){f>a?s.push(k(a)+"-"+k(f)):f===a&&s.push(k(f)),a="",r++;continue}if(i.startsWith("-]",r+1)){s.push(k(f+"-")),r+=2;continue}if(i.startsWith("-",r+1)){a=f,r+=2;continue}s.push(k(f)),r++}if(g<r)return["",!1,0,!1];if(!s.length&&!n.length)return["$.",!1,i.length-e,!0];if(n.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!c){let f=s[0].length===2?s[0].slice(-1):s[0];return[Bt(f),!1,g-e,!1]}let p="["+(c?"^":"")+rt(s)+"]",u="["+(c?"":"^")+rt(n)+"]";return[s.length&&n.length?"("+p+"|"+u+")":s.length?p:u,l,g-e,!0]};var v=(i,{windowsPathsNoEscape:t=!1,magicalBraces:e=!0}={})=>e?t?i.replace(/\[([^/\\])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?i.replace(/\[([^/\\{}])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var T,Ht=new Set(["!","?","+","*","@"]),J=i=>Ht.has(i),at=i=>J(i.type),qt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Jt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Ut=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),lt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Zt="(?!(?:^|/)\\.\\.?(?:$|/))",_="(?!\\.)",Xt=new Set(["[","."]),Kt=new Set(["..","."]),Vt=new Set("().*{}+?[]^$\\!"),It=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),U="[^/]",ct=U+"*?",ht=U+"+?",Yt=0,z=class{type;#s;#n;#i=!1;#t=[];#e;#a;#c;#l=!1;#r;#o;#h=!1;id=++Yt;get depth(){return(this.#e?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#s.id,parent:this.#e?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(t,e,s={}){this.type=t,t&&(this.#n=!0),this.#e=e,this.#s=this.#e?this.#e.#s:this,this.#r=this.#s===this?s:this.#s.#r,this.#c=this.#s===this?[]:this.#s.#c,t==="!"&&!this.#s.#l&&this.#c.push(this),this.#a=this.#e?this.#e.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#o=this.#t.map(t=>String(t)).join("")}#y(){if(this!==this.#s)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let e=t,s=e.#e;for(;s;){for(let n=e.#a+1;!s.type&&n<s.#t.length;n++)for(let r of t.#t){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(s.#t[n])}e=s,s=e.#e}}return this}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof T&&e.#e===this))throw new Error("invalid part: "+e);this.#t.push(e)}}toJSON(){let t=this.type===null?this.#t.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#t.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#s||this.#s.#l&&this.#e?.type==="!")&&t.push({}),t}isStart(){if(this.#s===this)return!0;if(!this.#e?.isStart())return!1;if(this.#a===0)return!0;let t=this.#e;for(let e=0;e<this.#a;e++){let s=t.#t[e];if(!(s instanceof T&&s.type==="!"))return!1}return!0}isEnd(){if(this.#s===this||this.#e?.type==="!")return!0;if(!this.#e?.isEnd())return!1;if(!this.type)return this.#e?.isEnd();let t=this.#e?this.#e.#t.length:0;return this.#a===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new T(this.type,t);for(let s of this.#t)e.copyIn(s);return e}static#f(t,e,s,n,r){let o=n.maxExtglobRecursion??2,l=!1,h=!1,c=-1,g=!1;if(e.type===null){let f=s,$="";for(;f<t.length;){let S=t.charAt(f++);if(l||S==="\\"){l=!l,$+=S;continue}if(h){f===c+1?(S==="^"||S==="!")&&(g=!0):S==="]"&&!(f===c+2&&g)&&(h=!1),$+=S;continue}else if(S==="["){h=!0,c=f,g=!1,$+=S;continue}if(!n.noext&&J(S)&&t.charAt(f)==="("&&r<=o){e.push($),$="";let b=new T(S,e);f=T.#f(t,b,f,n,r+1),e.push(b);continue}$+=S}return e.push($),f}let a=s+1,p=new T(null,e),u=[],d="";for(;a<t.length;){let f=t.charAt(a++);if(l||f==="\\"){l=!l,d+=f;continue}if(h){a===c+1?(f==="^"||f==="!")&&(g=!0):f==="]"&&!(a===c+2&&g)&&(h=!1),d+=f;continue}else if(f==="["){h=!0,c=a,g=!1,d+=f;continue}if(!n.noext&&J(f)&&t.charAt(a)==="("&&(r<=o||e&&e.#u(f))){let S=e&&e.#u(f)?0:1;p.push(d),d="";let m=new T(f,p);p.push(m),a=T.#f(t,m,a,n,r+S);continue}if(f==="|"){p.push(d),d="",u.push(p),p=new T(null,e);continue}if(f===")")return d===""&&e.#t.length===0&&(e.#h=!0),p.push(d),d="",e.push(...u,p),a;d+=f}return e.type=null,e.#n=void 0,e.#t=[t.substring(s-1)],a}#w(t){return this.#g(t,Jt)}#g(t,e=qt){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null)return!1;let s=t.#t[0];return!s||typeof s!="object"||s.type===null?!1:this.#u(s.type,e)}#u(t,e=Ut){return!!e.get(this.type)?.includes(t)}#S(t,e){let s=t.#t[0],n=new T(null,s,this.options);n.#t.push(""),s.push(n),this.#d(t,e)}#d(t,e){let s=t.#t[0];this.#t.splice(e,1,...s.#t);for(let n of s.#t)typeof n=="object"&&(n.#e=this);this.#o=void 0}#$(t){return!!lt.get(this.type)?.has(t)}#b(t){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let e=t.#t[0];return!e||typeof e!="object"||e.type===null?!1:this.#$(e.type)}#x(t){let e=lt.get(this.type),s=t.#t[0],n=e?.get(s.type);if(!n)return!1;this.#t=s.#t;for(let r of this.#t)typeof r=="object"&&(r.#e=this);this.type=n,this.#o=void 0,this.#h=!1}static fromGlob(t,e={}){let s=new T(null,void 0,e);return T.#f(t,s,0,e,0),s}toMMPattern(){if(this!==this.#s)return this.#s.toMMPattern();let t=this.toString(),[e,s,n,r]=this.toRegExpSource();if(!(n||this.#n||this.#r.nocase&&!this.#r.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let l=(this.#r.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,l),{_src:e,_glob:t})}get options(){return this.#r}toRegExpSource(t){let e=t??!!this.#r.dot;if(this.#s===this&&(this.#p(),this.#y()),!at(this)){let h=this.isStart()&&this.isEnd()&&!this.#t.some(u=>typeof u!="string"),c=this.#t.map(u=>{let[d,f,$,S]=typeof u=="string"?T.#E(u,this.#n,h):u.toRegExpSource(t);return this.#n=this.#n||$,this.#i=this.#i||S,d}).join(""),g="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Kt.has(this.#t[0]))){let d=Xt,f=e&&d.has(c.charAt(0))||c.startsWith("\\.")&&d.has(c.charAt(2))||c.startsWith("\\.\\.")&&d.has(c.charAt(4)),$=!e&&!t&&d.has(c.charAt(0));g=f?Zt:$?_:""}let a="";return this.isEnd()&&this.#s.#l&&this.#e?.type==="!"&&(a="(?:$|\\/)"),[g+c+a,v(c),this.#n=!!this.#n,this.#i]}let s=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",r=this.#m(e);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let h=this.toString(),c=this;return c.#t=[h],c.type=null,c.#n=void 0,[h,v(this.toString()),!1,!1]}let o=!s||t||e||!_?"":this.#m(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let l="";if(this.type==="!"&&this.#h)l=(this.isStart()&&!e?_:"")+ht;else{let h=this.type==="!"?"))"+(this.isStart()&&!e&&!t?_:"")+ct+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;l=n+r+h}return[l,v(r),this.#n=!!this.#n,this.#i]}#p(){if(at(this)){let t=0,e=!1;do{e=!0;for(let s=0;s<this.#t.length;s++){let n=this.#t[s];typeof n=="object"&&(n.#p(),this.#g(n)?(e=!1,this.#d(n,s)):this.#w(n)?(e=!1,this.#S(n,s)):this.#b(n)&&(e=!1,this.#x(n)))}}while(!e&&++t<10)}else for(let t of this.#t)typeof t=="object"&&t.#p();this.#o=void 0}#m(t){return this.#t.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,n,r,o]=e.toRegExpSource(t);return this.#i=this.#i||o,s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#E(t,e,s=!1){let n=!1,r="",o=!1,l=!1;for(let h=0;h<t.length;h++){let c=t.charAt(h);if(n){n=!1,r+=(Vt.has(c)?"\\":"")+c;continue}if(c==="*"){if(l)continue;l=!0,r+=s&&/^[*]+$/.test(t)?ht:ct,e=!0;continue}else l=!1;if(c==="\\"){h===t.length-1?r+="\\\\":n=!0;continue}if(c==="["){let[g,a,p,u]=ot(t,h);if(p){r+=g,o=o||a,h+=p-1,e=e||u;continue}}if(c==="?"){r+=U,e=!0;continue}r+=It(c)}return[r,v(t),!!e,o]}};T=z;var Z=(i,{windowsPathsNoEscape:t=!1,magicalBraces:e=!1}={})=>e?t?i.replace(/[?*()[\]{}]/g,"[$&]"):i.replace(/[?*()[\]\\{}]/g,"\\$&"):t?i.replace(/[?*()[\]]/g,"[$&]"):i.replace(/[?*()[\]\\]/g,"\\$&");var M=(i,t,e={})=>(L(t),!e.nocomment&&t.charAt(0)==="#"?!1:new D(t,e).match(i)),Qt=/^\*+([^+@!?*[(]*)$/,te=i=>t=>!t.startsWith(".")&&t.endsWith(i),ee=i=>t=>t.endsWith(i),se=i=>(i=i.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(i)),ne=i=>(i=i.toLowerCase(),t=>t.toLowerCase().endsWith(i)),ie=/^\*+\.\*+$/,re=i=>!i.startsWith(".")&&i.includes("."),oe=i=>i!=="."&&i!==".."&&i.includes("."),ae=/^\.\*+$/,le=i=>i!=="."&&i!==".."&&i.startsWith("."),ce=/^\*+$/,he=i=>i.length!==0&&!i.startsWith("."),fe=i=>i.length!==0&&i!=="."&&i!=="..",ue=/^\?+([^+@!?*[(]*)?$/,pe=([i,t=""])=>{let e=pt([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},ge=([i,t=""])=>{let e=gt([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},de=([i,t=""])=>{let e=gt([i]);return t?s=>e(s)&&s.endsWith(t):e},me=([i,t=""])=>{let e=pt([i]);return t?s=>e(s)&&s.endsWith(t):e},pt=([i])=>{let t=i.length;return e=>e.length===t&&!e.startsWith(".")},gt=([i])=>{let t=i.length;return e=>e.length===t&&e!=="."&&e!==".."},dt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ft={win32:{sep:"\\"},posix:{sep:"/"}},ye=dt==="win32"?ft.win32.sep:ft.posix.sep;M.sep=ye;var A=Symbol("globstar **");M.GLOBSTAR=A;var we="[^/]",Se=we+"*?",$e="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",be="(?:(?!(?:\\/|^)\\.).)*?",xe=(i,t={})=>e=>M(e,i,t);M.filter=xe;var N=(i,t={})=>Object.assign({},i,t),Ee=i=>{if(!i||typeof i!="object"||!Object.keys(i).length)return M;let t=M;return Object.assign((s,n,r={})=>t(s,n,N(i,r)),{Minimatch:class extends t.Minimatch{constructor(n,r={}){super(n,N(i,r))}static defaults(n){return t.defaults(N(i,n)).Minimatch}},AST:class extends t.AST{constructor(n,r,o={}){super(n,r,N(i,o))}static fromGlob(n,r={}){return t.AST.fromGlob(n,N(i,r))}},unescape:(s,n={})=>t.unescape(s,N(i,n)),escape:(s,n={})=>t.escape(s,N(i,n)),filter:(s,n={})=>t.filter(s,N(i,n)),defaults:s=>t.defaults(N(i,s)),makeRe:(s,n={})=>t.makeRe(s,N(i,n)),braceExpand:(s,n={})=>t.braceExpand(s,N(i,n)),match:(s,n,r={})=>t.match(s,n,N(i,r)),sep:t.sep,GLOBSTAR:A})};M.defaults=Ee;var mt=(i,t={})=>(L(i),t.nobrace||!/\{(?:(?!\{).)*\}/.test(i)?[i]:it(i,{max:t.braceExpandMax}));M.braceExpand=mt;var Me=(i,t={})=>new D(i,t).makeRe();M.makeRe=Me;var Ae=(i,t,e={})=>{let s=new D(t,e);return i=i.filter(n=>s.match(n)),s.options.nonull&&!i.length&&i.push(t),i};M.match=Ae;var ut=/[?*]|[+@!]\(.*?\)|\[|\]/,Pe=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),D=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,e={}){L(t),e=e||{},this.options=e,this.maxGlobstarRecursion=e.maxGlobstarRecursion??200,this.pattern=t,this.platform=e.platform||dt,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e[s]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let n=this.globParts.map((r,o,l)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=r[0]===""&&r[1]===""&&(r[2]==="?"||!ut.test(r[2]))&&!ut.test(r[3]),c=/^[a-z]:/i.test(r[0]);if(h)return[...r.slice(0,4),...r.slice(4).map(g=>this.parse(g))];if(c)return[r[0],...r.slice(1).map(g=>this.parse(g))]}return r.map(h=>this.parse(h))});if(this.debug(this.pattern,n),this.set=n.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let s of t)for(let n=0;n<s.length;n++)s[n]==="**"&&(s[n]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let n=s;for(;e[n+1]==="**";)n++;n!==s&&e.splice(s,n-s)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((s,n)=>{let r=s[s.length-1];return n==="**"&&r==="**"?s:n===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(n),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let n=1;n<t.length-1;n++){let r=t[n];n===1&&r===""&&t[0]===""||(r==="."||r==="")&&(e=!0,t.splice(n,1),n--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let s=0;for(;(s=t.indexOf("..",s+1))!==-1;){let n=t[s-1];n&&n!=="."&&n!==".."&&n!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(n))&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let n=-1;for(;(n=s.indexOf("**",n+1))!==-1;){let o=n;for(;s[o+1]==="**";)o++;o>n&&s.splice(n+1,o-n);let l=s[n+1],h=s[n+2],c=s[n+3];if(l!==".."||!h||h==="."||h===".."||!c||c==="."||c==="..")continue;e=!0,s.splice(n,1);let g=s.slice(0);g[n]="**",t.push(g),n--}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let l=s[o];o===1&&l===""&&s[0]===""||(l==="."||l==="")&&(e=!0,s.splice(o,1),o--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let o=s[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;let h=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...h),s.length===0&&s.push(""),r-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){let n=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);if(n){t[e]=[],t[s]=n;break}}return t.filter(e=>e.length)}partsMatch(t,e,s=!1){let n=0,r=0,o=[],l="";for(;n<t.length&&r<e.length;)if(t[n]===e[r])o.push(l==="b"?e[r]:t[n]),n++,r++;else if(s&&t[n]==="**"&&e[r]===t[n+1])o.push(t[n]),n++;else if(s&&e[r]==="**"&&t[n]===e[r+1])o.push(e[r]),r++;else if(t[n]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(l==="b")return!1;l="a",o.push(t[n]),n++,r++}else if(e[r]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(l==="a")return!1;l="b",o.push(e[r]),n++,r++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,s=0;for(let n=0;n<t.length&&t.charAt(n)==="!";n++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){let n=0,r=0;if(this.isWindows){let l=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),h=!l&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),g=!c&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),a=h?3:l?0:void 0,p=g?3:c?0:void 0;if(typeof a=="number"&&typeof p=="number"){let[u,d]=[t[a],e[p]];u.toLowerCase()===d.toLowerCase()&&(e[p]=u,r=p,n=a)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),e.includes(A)?this.#s(t,e,s,n,r):this.#i(t,e,s,n,r)}#s(t,e,s,n,r){let o=e.indexOf(A,r),l=e.lastIndexOf(A),[h,c,g]=s?[e.slice(r,o),e.slice(o+1),[]]:[e.slice(r,o),e.slice(o+1,l),e.slice(l+1)];if(h.length){let m=t.slice(n,n+h.length);if(!this.#i(m,h,s,0,0))return!1;n+=h.length,r+=h.length}let a=0;if(g.length){if(g.length+n>t.length)return!1;let m=t.length-g.length;if(this.#i(t,g,s,m,0))a=g.length;else{if(t[t.length-1]!==""||n+g.length===t.length||(m--,!this.#i(t,g,s,m,0)))return!1;a=g.length+1}}if(!c.length){let m=!!a;for(let b=n;b<t.length-a;b++){let y=String(t[b]);if(m=!0,y==="."||y===".."||!this.options.dot&&y.startsWith("."))return!1}return s||m}let p=[[[],0]],u=p[0],d=0,f=[0];for(let m of c)m===A?(f.push(d),u=[[],0],p.push(u)):(u[0].push(m),d++);let $=p.length-1,S=t.length-a;for(let m of p)m[1]=S-(f[$--]+m[0].length);return!!this.#n(t,p,n,0,s,0,!!a)}#n(t,e,s,n,r,o,l){let h=e[n];if(!h){for(let a=s;a<t.length;a++){l=!0;let p=t[a];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return l}let[c,g]=h;for(;s<=g;){if(this.#i(t.slice(0,s+c.length),c,r,s,0)&&o<this.maxGlobstarRecursion){let u=this.#n(t,e,s+c.length,n+1,r,o+1,l);if(u!==!1)return u}let p=t[s];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;s++}return r||null}#i(t,e,s,n,r){let o,l,h,c;for(o=n,l=r,c=t.length,h=e.length;o<c&&l<h;o++,l++){this.debug("matchOne loop");let g=e[l],a=t[o];if(this.debug(e,g,a),g===!1||g===A)return!1;let p;if(typeof g=="string"?(p=a===g,this.debug("string match",g,a,p)):(p=g.test(a),this.debug("pattern match",g,a,p)),!p)return!1}if(o===c&&l===h)return!0;if(o===c)return s;if(l===h)return o===c-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return mt(this.pattern,this.options)}parse(t){L(t);let e=this.options;if(t==="**")return A;if(t==="")return"";let s,n=null;(s=t.match(ce))?n=e.dot?fe:he:(s=t.match(Qt))?n=(e.nocase?e.dot?ne:se:e.dot?ee:te)(s[1]):(s=t.match(ue))?n=(e.nocase?e.dot?ge:pe:e.dot?de:me)(s):(s=t.match(ie))?n=e.dot?oe:re:(s=t.match(ae))&&(n=le);let r=z.fromGlob(t,this.options).toMMPattern();return n&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:n}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?Se:e.dot?$e:be,n=new Set(e.nocase?["i"]:[]),r=t.map(h=>{let c=h.map(a=>{if(a instanceof RegExp)for(let p of a.flags.split(""))n.add(p);return typeof a=="string"?Pe(a):a===A?A:a._src});c.forEach((a,p)=>{let u=c[p+1],d=c[p-1];a!==A||d===A||(d===void 0?u!==void 0&&u!==A?c[p+1]="(?:\\/|"+s+"\\/)?"+u:c[p]=s:u===void 0?c[p-1]=d+"(?:\\/|\\/"+s+")?":u!==A&&(c[p-1]=d+"(?:\\/|\\/"+s+"\\/)"+u,c[p+1]=A))});let g=c.filter(a=>a!==A);if(this.partial&&g.length>=1){let a=[];for(let p=1;p<=g.length;p++)a.push(g.slice(0,p).join("/"));return"(?:"+a.join("|")+")"}return g.join("/")}).join("|"),[o,l]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+l+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+l+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...n].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let n=this.slashSplit(t);this.debug(this.pattern,"split",n);let r=this.set;this.debug(this.pattern,"set",r);let o=n[n.length-1];if(!o)for(let l=n.length-2;!o&&l>=0;l--)o=n[l];for(let l of r){let h=n;if(s.matchBase&&l.length===1&&(h=[o]),this.matchOne(h,l,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return M.defaults(t).Minimatch}};M.AST=z;M.Minimatch=D;M.escape=Z;M.unescape=v;function G(i){if(i<1024)return String(i);if(i<1024*1024){let e=i/1024;return e<10?`${e.toFixed(1)}K`:`${Math.round(e)}K`}if(i<1024*1024*1024){let e=i/1048576;return e<10?`${e.toFixed(1)}M`:`${Math.round(e)}M`}let t=i/(1024*1024*1024);return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function F(i){let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][i.getMonth()],s=String(i.getDate()).padStart(2," "),n=new Date,r=new Date(n.getTime()-4320*60*60*1e3);if(i>r){let l=String(i.getHours()).padStart(2,"0"),h=String(i.getMinutes()).padStart(2,"0");return`${e} ${s} ${l}:${h}`}let o=i.getFullYear();return`${e} ${s} ${o}`}function C(i){return i.isDirectory?"/":i.isSymbolicLink?"@":(i.mode&73)!==0?"*":""}var Te={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"]},Ne={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"}},es={name:"ls",async execute(i,t){if(V(i))return K(Te);let e=I("ls",i,Ne);if(!e.ok)return e.error;let s=e.result.flags.showAll,n=e.result.flags.showAlmostAll,r=e.result.flags.longFormat,o=e.result.flags.humanReadable,l=e.result.flags.recursive,h=e.result.flags.reverse,c=e.result.flags.sortBySize,g=e.result.flags.classifyFiles,a=e.result.flags.directoryOnly,p=e.result.flags.sortByTime;e.result.flags.onePerLine;let u=e.result.positional;u.length===0&&u.push(".");let d="",f="",$=0;for(let S=0;S<u.length;S++){let m=u[S];if(S>0&&d&&!d.endsWith(`
|
|
3
|
+
|
|
4
|
+
`)&&(d+=`
|
|
5
|
+
`),a){let b=t.fs.resolvePath(t.cwd,m);try{let y=await t.fs.stat(b);if(r){let w=y.isDirectory?"drwxr-xr-x":"-rw-r--r--",E=g?C(await t.fs.lstat(b)):y.isDirectory?"/":"",x=y.size??0,P=o?G(x).padStart(5):String(x).padStart(5),R=y.mtime??new Date(0),W=F(R);d+=`${w} 1 user user ${P} ${W} ${m}${E}
|
|
6
|
+
`}else{let w=g?C(await t.fs.lstat(b)):"";d+=`${m}${w}
|
|
7
|
+
`}}catch{f+=`ls: cannot access '${m}': No such file or directory
|
|
8
|
+
`,$=2}continue}if(m.includes("*")||m.includes("?")||m.includes("[")){let b=await Re(m,t,s,n,r,h,o,c,g);d+=b.stdout,f+=b.stderr,b.exitCode!==0&&($=b.exitCode)}else{let b=await yt(m,t,s,n,r,l,u.length>1,h,o,c,g);d+=b.stdout,f+=b.stderr,b.exitCode!==0&&($=b.exitCode)}}return{stdout:d,stderr:f,exitCode:$}}};async function Re(i,t,e,s,n,r=!1,o=!1,l=!1,h=!1){let c=e||s,g=t.fs.getAllPaths(),a=t.fs.resolvePath(t.cwd,"."),p=[];for(let u of g){let d=u.startsWith(a)&&u.slice(a.length+1)||u;if(M(d,i)||M(u,i)){let f=d.split("/").pop()||d;if(!c&&f.startsWith("."))continue;p.push(d||u)}}if(p.length===0)return{stdout:"",stderr:`ls: ${i}: No such file or directory
|
|
9
|
+
`,exitCode:2};if(l){let u=[];for(let d of p){let f=t.fs.resolvePath(t.cwd,d);try{let $=await t.fs.stat(f);u.push({path:d,size:$.size??0})}catch{u.push({path:d,size:0})}}u.sort((d,f)=>f.size-d.size),p.length=0,p.push(...u.map(d=>d.path))}else p.sort();if(r&&p.reverse(),n){let u=[];for(let d of p){let f=t.fs.resolvePath(t.cwd,d);try{let $=await t.fs.stat(f),S=$.isDirectory?"drwxr-xr-x":"-rw-r--r--",m=h?C(await t.fs.lstat(f)):$.isDirectory?"/":"",b=$.size??0,y=o?G(b).padStart(5):String(b).padStart(5),w=$.mtime??new Date(0),E=F(w);u.push(`${S} 1 user user ${y} ${E} ${d}${m}`)}catch{u.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${d}`)}}return{stdout:`${u.join(`
|
|
10
|
+
`)}
|
|
11
|
+
`,stderr:"",exitCode:0}}if(h){let u=[];for(let d of p){let f=t.fs.resolvePath(t.cwd,d);try{let $=await t.fs.lstat(f);u.push(`${d}${C($)}`)}catch{u.push(d)}}return{stdout:`${u.join(`
|
|
12
|
+
`)}
|
|
13
|
+
`,stderr:"",exitCode:0}}return{stdout:`${p.join(`
|
|
14
|
+
`)}
|
|
15
|
+
`,stderr:"",exitCode:0}}async function yt(i,t,e,s,n,r,o,l=!1,h=!1,c=!1,g=!1,a=!1){let p=e||s,u=t.fs.resolvePath(t.cwd,i);try{let d=await t.fs.stat(u);if(!d.isDirectory){let S=g?C(await t.fs.lstat(u)):"";if(n){let m=d.size??0,b=h?G(m).padStart(5):String(m).padStart(5),y=d.mtime??new Date(0),w=F(y);return{stdout:`-rw-r--r-- 1 user user ${b} ${w} ${i}${S}
|
|
16
|
+
`,stderr:"",exitCode:0}}return{stdout:`${i}${S}
|
|
17
|
+
`,stderr:"",exitCode:0}}let f=await t.fs.readdir(u);if(p||(f=f.filter(S=>!S.startsWith("."))),c){let S=[];for(let m of f){let b=u==="/"?`/${m}`:`${u}/${m}`;try{let y=await t.fs.stat(b);S.push({name:m,size:y.size??0})}catch{S.push({name:m,size:0})}}S.sort((m,b)=>b.size-m.size),f=S.map(m=>m.name)}else f.sort();e&&(f=[".","..",...f]),l&&f.reverse();let $="";if((r||o)&&($+=`${i}:
|
|
18
|
+
`),n){$+=`total ${f.length}
|
|
19
|
+
`;let S=f.filter(w=>w==="."||w===".."),m=f.filter(w=>w!=="."&&w!=="..");for(let w of S)$+=`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${w}
|
|
20
|
+
`;let b=[];for(let w=0;w<m.length;w+=100){let E=m.slice(w,w+100),x=await Promise.all(E.map(async P=>{let R=u==="/"?`/${P}`:`${u}/${P}`;try{let W=await t.fs.stat(R),wt=W.isDirectory?"drwxr-xr-x":"-rw-r--r--",St=g?C(await t.fs.lstat(R)):W.isDirectory?"/":"",X=W.size??0,$t=h?G(X).padStart(5):String(X).padStart(5),bt=W.mtime??new Date(0),xt=F(bt);return{name:P,line:`${wt} 1 user user ${$t} ${xt} ${P}${St}
|
|
21
|
+
`}}catch{return{name:P,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${P}
|
|
22
|
+
`}}}));b.push(...x)}let y=new Map(m.map((w,E)=>[w,E]));b.sort((w,E)=>(y.get(w.name)??0)-(y.get(E.name)??0));for(let{line:w}of b)$+=w}else if(g){let S=[],m=f.filter(y=>y!=="."&&y!==".."),b=f.filter(y=>y==="."||y==="..");for(let y of b)S.push(`${y}/`);for(let y=0;y<m.length;y+=100){let w=m.slice(y,y+100),E=await Promise.all(w.map(async x=>{let P=u==="/"?`/${x}`:`${u}/${x}`;try{let R=await t.fs.lstat(P);return`${x}${C(R)}`}catch{return x}}));S.push(...E)}$+=S.join(`
|
|
23
|
+
`)+(S.length?`
|
|
24
|
+
`:"")}else $+=f.join(`
|
|
25
|
+
`)+(f.length?`
|
|
26
|
+
`:"");if(r){let S=f.filter(y=>y!=="."&&y!==".."),m=[];if(t.fs.readdirWithFileTypes)m=(await t.fs.readdirWithFileTypes(u)).filter(w=>w.isDirectory&&S.includes(w.name)).map(w=>({name:w.name,isDirectory:!0}));else for(let y=0;y<S.length;y+=100){let w=S.slice(y,y+100),E=await Promise.all(w.map(async x=>{let P=u==="/"?`/${x}`:`${u}/${x}`;try{let R=await t.fs.stat(P);return{name:x,isDirectory:R.isDirectory}}catch{return{name:x,isDirectory:!1}}}));m.push(...E.filter(x=>x.isDirectory))}m.sort((y,w)=>y.name.localeCompare(w.name)),l&&m.reverse();let b=[];for(let y=0;y<m.length;y+=100){let w=m.slice(y,y+100),E=await Promise.all(w.map(async x=>{let P=i==="."?`./${x.name}`:`${i}/${x.name}`,R=await yt(P,t,e,s,n,r,!1,l,h,c,g,!0);return{name:x.name,result:R}}));b.push(...E)}b.sort((y,w)=>y.name.localeCompare(w.name)),l&&b.reverse();for(let{result:y}of b)$+=`
|
|
27
|
+
`,$+=y.stdout}return{stdout:$,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`ls: ${i}: No such file or directory
|
|
28
|
+
`,exitCode:2}}}var ss={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{es as a,ss as b};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{a as _,c as W}from"./chunk-27JIFWUR.js";import{k as T}from"./chunk-SAI2SPQQ.js";import{a as D}from"./chunk-W5DWRFSU.js";import{a as N,b as A}from"./chunk-QAYAQNCG.js";import{c as H,e as L}from"./chunk-BZUGFHVS.js";var z=H(C=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function a(c){return e(n(c),arguments)}function r(c,i){return a.apply(null,[c].concat(i||[]))}function e(c,i){var u=1,l=c.length,o,m="",p,d,f,h,y,S,k,x;for(p=0;p<l;p++)if(typeof c[p]=="string")m+=c[p];else if(typeof c[p]=="object"){if(f=c[p],f.keys)for(o=i[u],d=0;d<f.keys.length;d++){if(o==null)throw new Error(a('[sprintf] Cannot access property "%s" of undefined value "%s"',f.keys[d],f.keys[d-1]));o=o[f.keys[d]]}else f.param_no?o=i[f.param_no]:o=i[u++];if(t.not_type.test(f.type)&&t.not_primitive.test(f.type)&&o instanceof Function&&(o=o()),t.numeric_arg.test(f.type)&&typeof o!="number"&&isNaN(o))throw new TypeError(a("[sprintf] expecting number but found %T",o));switch(t.number.test(f.type)&&(k=o>=0),f.type){case"b":o=parseInt(o,10).toString(2);break;case"c":o=String.fromCharCode(parseInt(o,10));break;case"d":case"i":o=parseInt(o,10);break;case"j":o=JSON.stringify(o,null,f.width?parseInt(f.width):0);break;case"e":o=f.precision?parseFloat(o).toExponential(f.precision):parseFloat(o).toExponential();break;case"f":o=f.precision?parseFloat(o).toFixed(f.precision):parseFloat(o);break;case"g":o=f.precision?String(Number(o.toPrecision(f.precision))):parseFloat(o);break;case"o":o=(parseInt(o,10)>>>0).toString(8);break;case"s":o=String(o),o=f.precision?o.substring(0,f.precision):o;break;case"t":o=String(!!o),o=f.precision?o.substring(0,f.precision):o;break;case"T":o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=f.precision?o.substring(0,f.precision):o;break;case"u":o=parseInt(o,10)>>>0;break;case"v":o=o.valueOf(),o=f.precision?o.substring(0,f.precision):o;break;case"x":o=(parseInt(o,10)>>>0).toString(16);break;case"X":o=(parseInt(o,10)>>>0).toString(16).toUpperCase();break}t.json.test(f.type)?m+=o:(t.number.test(f.type)&&(!k||f.sign)?(x=k?"+":"-",o=o.toString().replace(t.sign,"")):x="",y=f.pad_char?f.pad_char==="0"?"0":f.pad_char.charAt(1):" ",S=f.width-(x+o).length,h=f.width&&S>0?y.repeat(S):"",m+=f.align?x+o+h:y==="0"?x+h+o:h+x+o)}return m}var s=Object.create(null);function n(c){if(s[c])return s[c];for(var i=c,u,l=[],o=0;i;){if((u=t.text.exec(i))!==null)l.push(u[0]);else if((u=t.modulo.exec(i))!==null)l.push("%");else if((u=t.placeholder.exec(i))!==null){if(u[2]){o|=1;var m=[],p=u[2],d=[];if((d=t.key.exec(p))!==null)for(m.push(d[1]);(p=p.substring(d[0].length))!=="";)if((d=t.key_access.exec(p))!==null)m.push(d[1]);else if((d=t.index_access.exec(p))!==null)m.push(d[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");u[2]=m}else o|=2;if(o===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");l.push({placeholder:u[0],param_no:u[1],keys:u[2],sign:u[3],pad_char:u[4],align:u[5],width:u[6],precision:u[7],type:u[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");i=i.substring(u[0].length)}return s[c]=l}typeof C<"u"&&(C.sprintf=a,C.vsprintf=r),typeof window<"u"&&(window.sprintf=a,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:a,vsprintf:r}}))})()});var $=L(z(),1);function P(t,a,r){let e=new Date(a*1e3),s="",n=0;for(;n<t.length;)if(t[n]==="%"&&n+1<t.length){let c=t[n+1],i=R(e,c,r);i!==null?(s+=i,n+=2):(s+=t[n],n++)}else s+=t[n],n++;return s}function G(t,a){let r={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",weekday:"short",hour12:!1,timeZone:a};try{let s=new Intl.DateTimeFormat("en-US",r).formatToParts(t),n=u=>s.find(l=>l.type===u)?.value??"",c=new Map([["Sun",0],["Mon",1],["Tue",2],["Wed",3],["Thu",4],["Fri",5],["Sat",6]]),i=n("weekday");return{year:Number.parseInt(n("year"),10)||t.getFullYear(),month:Number.parseInt(n("month"),10)||t.getMonth()+1,day:Number.parseInt(n("day"),10)||t.getDate(),hour:Number.parseInt(n("hour"),10)||t.getHours(),minute:Number.parseInt(n("minute"),10)||t.getMinutes(),second:Number.parseInt(n("second"),10)||t.getSeconds(),weekday:c.get(i)??t.getDay()}}catch{return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),weekday:t.getDay()}}}function R(t,a,r){let e=G(t,r),s=(u,l=2)=>String(u).padStart(l,"0"),n=Z(e.year,e.month,e.day),c=j(e.year,e.month,e.day,e.weekday,0),i=j(e.year,e.month,e.day,e.weekday,1);switch(a){case"a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.weekday];case"A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e.weekday];case"b":case"h":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.month-1];case"B":return["January","February","March","April","May","June","July","August","September","October","November","December"][e.month-1];case"c":return`${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.weekday]} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.month-1]} ${String(e.day).padStart(2," ")} ${s(e.hour)}:${s(e.minute)}:${s(e.second)} ${e.year}`;case"C":return s(Math.floor(e.year/100));case"d":return s(e.day);case"D":return`${s(e.month)}/${s(e.day)}/${s(e.year%100)}`;case"e":return String(e.day).padStart(2," ");case"F":return`${e.year}-${s(e.month)}-${s(e.day)}`;case"g":return s(O(e.year,e.month,e.day)%100);case"G":return String(O(e.year,e.month,e.day));case"H":return s(e.hour);case"I":return s(e.hour%12||12);case"j":return String(n).padStart(3,"0");case"k":return String(e.hour).padStart(2," ");case"l":return String(e.hour%12||12).padStart(2," ");case"m":return s(e.month);case"M":return s(e.minute);case"n":return`
|
|
3
|
+
`;case"N":return"000000000";case"p":return e.hour<12?"AM":"PM";case"P":return e.hour<12?"am":"pm";case"r":return`${s(e.hour%12||12)}:${s(e.minute)}:${s(e.second)} ${e.hour<12?"AM":"PM"}`;case"R":return`${s(e.hour)}:${s(e.minute)}`;case"s":return String(Math.floor(t.getTime()/1e3));case"S":return s(e.second);case"t":return" ";case"T":return`${s(e.hour)}:${s(e.minute)}:${s(e.second)}`;case"u":return String(e.weekday===0?7:e.weekday);case"U":return s(c);case"V":return s(Q(e.year,e.month,e.day));case"w":return String(e.weekday);case"W":return s(i);case"x":return`${s(e.month)}/${s(e.day)}/${s(e.year%100)}`;case"X":return`${s(e.hour)}:${s(e.minute)}:${s(e.second)}`;case"y":return s(e.year%100);case"Y":return String(e.year);case"z":return V(t,r);case"Z":return q(t,r);case"%":return"%";default:return null}}function V(t,a){if(!a){let c=-t.getTimezoneOffset(),i=c>=0?"+":"-",u=Math.floor(Math.abs(c)/60),l=Math.abs(c)%60;return`${i}${String(u).padStart(2,"0")}${String(l).padStart(2,"0")}`}try{let u=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).formatToParts(t).find(l=>l.type==="timeZoneName");if(u){let l=u.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(l)return`${l[1]}${l[2]}${l[3]}`;if(u.value==="GMT"||u.value==="UTC")return"+0000"}}catch{}let r=-t.getTimezoneOffset(),e=r>=0?"+":"-",s=Math.floor(Math.abs(r)/60),n=Math.abs(r)%60;return`${e}${String(s).padStart(2,"0")}${String(n).padStart(2,"0")}`}function q(t,a){try{return new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"short"}).formatToParts(t).find(n=>n.type==="timeZoneName")?.value??"UTC"}catch{return"UTC"}}function Z(t,a,r){let e=[31,28,31,30,31,30,31,31,30,31,30,31];(t%4===0&&t%100!==0||t%400===0)&&(e[1]=29);let n=r;for(let c=0;c<a-1;c++)n+=e[c];return n}function j(t,a,r,e,s){let n=Z(t,a,r),u=(new Date(t,0,1).getDay()-s+7)%7,l=(e-s+7)%7,o=n-1+u;return Math.floor((o-l+7)/7)}function Q(t,a,r){let e=new Date(t,a-1,r,12,0,0);e.setDate(e.getDate()+3-(e.getDay()+6)%7);let s=new Date(e.getFullYear(),0,4);s.setDate(s.getDate()+3-(s.getDay()+6)%7);let n=e.getTime()-s.getTime();return 1+Math.round(n/(10080*60*1e3))}function O(t,a,r){let e=new Date(t,a-1,r,12,0,0);return e.setDate(e.getDate()+3-(e.getDay()+6)%7),e.getFullYear()}function B(t){let a="",r=0;for(;r<t.length;){let e=t[r];if(e<128){a+=String.fromCharCode(e),r++;continue}if((e&224)===192){if(r+1<t.length&&(t[r+1]&192)===128&&e>=194){let s=(e&31)<<6|t[r+1]&63;a+=String.fromCharCode(s),r+=2;continue}a+=String.fromCharCode(e),r++;continue}if((e&240)===224){if(r+2<t.length&&(t[r+1]&192)===128&&(t[r+2]&192)===128){if(e===224&&t[r+1]<160){a+=String.fromCharCode(e),r++;continue}let s=(e&15)<<12|(t[r+1]&63)<<6|t[r+2]&63;if(s>=55296&&s<=57343){a+=String.fromCharCode(e),r++;continue}a+=String.fromCharCode(s),r+=3;continue}a+=String.fromCharCode(e),r++;continue}if((e&248)===240&&e<=244){if(r+3<t.length&&(t[r+1]&192)===128&&(t[r+2]&192)===128&&(t[r+3]&192)===128){if(e===240&&t[r+1]<144){a+=String.fromCharCode(e),r++;continue}let s=(e&7)<<18|(t[r+1]&63)<<12|(t[r+2]&63)<<6|t[r+3]&63;if(s>1114111){a+=String.fromCharCode(e),r++;continue}a+=String.fromCodePoint(s),r+=4;continue}a+=String.fromCharCode(e),r++;continue}a+=String.fromCharCode(e),r++}return a}var K={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},ge={name:"printf",async execute(t,a){if(A(t))return N(K);if(t.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
|
|
4
|
+
`,exitCode:2};let r=null,e=0;for(;e<t.length;){let c=t[e];if(c==="--"){e++;break}if(c==="-v"){if(e+1>=t.length)return{stdout:"",stderr:`printf: -v: option requires an argument
|
|
5
|
+
`,exitCode:1};if(r=t[e+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(\[[a-zA-Z0-9_@*"'$]+\])?$/.test(r))return{stdout:"",stderr:`printf: \`${r}': not a valid identifier
|
|
6
|
+
`,exitCode:2};e+=2}else{if(c.startsWith("-")&&c!=="-")break;break}}if(e>=t.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
|
|
7
|
+
`,exitCode:1};let s=t[e],n=t.slice(e+1);try{let c=W(s),i="",u=0,l=!1,o="",m=a.env.get("TZ"),p=a.limits?.maxStringLength;do{let{result:d,argsConsumed:f,error:h,errMsg:y,stopped:S}=ee(c,n,u,m);if(i+=d,p!==void 0&&p>0&&i.length>p)throw new T(`printf: output size limit exceeded (${p} bytes)`,"string_length");if(u+=f,h&&(l=!0,y&&(o=y)),S)break}while(u<n.length&&u>0);if(u===0&&n.length>0,r){let d=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(d){let f=d[1],h=d[3];h=h.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(y,S)=>a.env.get(S)??""),a.env.set(`${f}_${h}`,i)}else a.env.set(r,i);return{stdout:"",stderr:o,exitCode:l?1:0}}return{stdout:i,stderr:o,exitCode:l?1:0}}catch(c){if(c instanceof T)throw c;return{stdout:"",stderr:`printf: ${D(c)}
|
|
8
|
+
`,exitCode:1}}}};function ee(t,a,r,e){let s="",n=0,c=0,i=!1,u="";for(;n<t.length;)if(t[n]==="%"&&n+1<t.length){let l=n;if(n++,t[n]==="%"){s+="%",n++;continue}let o=t.slice(l).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(o){let b=o[1]?parseInt(o[1],10):0,I=o[2]?parseInt(o[2],10):-1,Y=o[3],X=o[0],v=a[r+c]||"";c++;let M;v===""||v==="-1"||v==="-2"?M=Math.floor(Date.now()/1e3):M=parseInt(v,10)||0;let w=P(Y,M,e);if(I>=0&&w.length>I&&(w=w.slice(0,I)),b!==0){let F=Math.abs(b);w.length<F&&(b<0?w=w.padEnd(F," "):w=w.padStart(F," "))}s+=w,n=l+X.length;continue}for(;n<t.length&&"+-0 #'".includes(t[n]);)n++;let m=!1;if(t[n]==="*")m=!0,n++;else for(;n<t.length&&/\d/.test(t[n]);)n++;let p=!1;if(t[n]===".")if(n++,t[n]==="*")p=!0,n++;else for(;n<t.length&&/\d/.test(t[n]);)n++;n<t.length&&"hlL".includes(t[n])&&n++;let d=t[n]||"";n++;let h=t.slice(l,n);if(m){let b=parseInt(a[r+c]||"0",10);c++,h=h.replace("*",String(b))}if(p){let b=parseInt(a[r+c]||"0",10);c++,h=h.replace(".*",`.${b}`)}let y=a[r+c]||"";c++;let{value:S,parseError:k,parseErrMsg:x,stopped:J}=te(h,d,y);if(s+=S,k&&(i=!0,x&&(u=x)),J)return{result:s,argsConsumed:c,error:i,errMsg:u,stopped:!0}}else s+=t[n],n++;return{result:s,argsConsumed:c,error:i,errMsg:u,stopped:!1}}function te(t,a,r){let e=!1,s="";switch(a){case"d":case"i":{let n=E(r);return e=g,e&&(s=`printf: ${r}: invalid number
|
|
9
|
+
`),{value:U(t,n),parseError:e,parseErrMsg:s}}case"o":{let n=E(r);return e=g,e&&(s=`printf: ${r}: invalid number
|
|
10
|
+
`),{value:re(t,n),parseError:e,parseErrMsg:s}}case"u":{let n=E(r);e=g,e&&(s=`printf: ${r}: invalid number
|
|
11
|
+
`);let c=n<0?n>>>0:n;return{value:U(t.replace("u","d"),c),parseError:e,parseErrMsg:s}}case"x":case"X":{let n=E(r);return e=g,e&&(s=`printf: ${r}: invalid number
|
|
12
|
+
`),{value:ne(t,n),parseError:e,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":{let n=parseFloat(r)||0;return{value:oe(t,a,n),parseError:!1,parseErrMsg:""}}case"c":{if(r==="")return{value:"",parseError:!1,parseErrMsg:""};let i=new TextEncoder().encode(r)[0];return{value:String.fromCharCode(i),parseError:!1,parseErrMsg:""}}case"s":return{value:ae(t,r),parseError:!1,parseErrMsg:""};case"q":return{value:ie(t,r),parseError:!1,parseErrMsg:""};case"b":{let n=ce(r);return{value:n.value,parseError:!1,parseErrMsg:"",stopped:n.stopped}}default:try{return{value:(0,$.sprintf)(t,r),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
|
|
13
|
+
`}}}}var g=!1;function E(t){g=!1;let a=t.trimStart(),r=a!==a.trimEnd();if(t=a.trimEnd(),t.startsWith("'")&&t.length>=2||t.startsWith('"')&&t.length>=2)return t.charCodeAt(1);if(t.startsWith("\\'")&&t.length>=3||t.startsWith('\\"')&&t.length>=3)return t.charCodeAt(2);if(t.startsWith("+")&&(t=t.slice(1)),t.startsWith("0x")||t.startsWith("0X")){let e=parseInt(t,16);return Number.isNaN(e)?(g=!0,0):(r&&(g=!0),e)}if(t.startsWith("0")&&t.length>1&&/^-?0[0-7]+$/.test(t))return r&&(g=!0),parseInt(t,8)||0;if(/^\d+#/.test(t)){g=!0;let e=t.match(/^(\d+)#/);return e?parseInt(e[1],10):0}if(t!==""&&!/^-?\d+$/.test(t)){g=!0;let e=parseInt(t,10);return Number.isNaN(e)?0:e}return r&&(g=!0),parseInt(t,10)||0}function U(t,a){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!r)return(0,$.sprintf)(t.replace(/\.\d*/,""),a);let e=r[1]||"",s=r[2]?parseInt(r[2],10):0,n=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,c=a<0,i=Math.abs(a),u=String(i);n>=0&&(u=u.padStart(n,"0"));let l="";c?l="-":e.includes("+")?l="+":e.includes(" ")&&(l=" ");let o=l+u;return s>o.length&&(e.includes("-")?o=o.padEnd(s," "):e.includes("0")&&n<0?o=l+u.padStart(s-l.length,"0"):o=o.padStart(s," ")),o}function re(t,a){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!r)return(0,$.sprintf)(t,a);let e=r[1]||"",s=r[2]?parseInt(r[2],10):0,n=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,c=Math.abs(a).toString(8);n>=0&&(c=c.padStart(n,"0")),e.includes("#")&&!c.startsWith("0")&&(c=`0${c}`);let i=c;return s>i.length&&(e.includes("-")?i=i.padEnd(s," "):e.includes("0")&&n<0?i=i.padStart(s,"0"):i=i.padStart(s," ")),i}function ne(t,a){let r=t.includes("X"),e=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!e)return(0,$.sprintf)(t,a);let s=e[1]||"",n=e[2]?parseInt(e[2],10):0,c=e[3]!==void 0?e[4]?parseInt(e[4],10):0:-1,i=Math.abs(a).toString(16);r&&(i=i.toUpperCase()),c>=0&&(i=i.padStart(c,"0"));let u="";s.includes("#")&&a!==0&&(u=r?"0X":"0x");let l=u+i;return n>l.length&&(s.includes("-")?l=l.padEnd(n," "):s.includes("0")&&c<0?l=u+i.padStart(n-u.length,"0"):l=l.padStart(n," ")),l}function se(t){if(t==="")return"''";if(/^[a-zA-Z0-9_./-]+$/.test(t))return t;if(/[\x00-\x1f\x7f-\xff]/.test(t)){let e="$'";for(let s of t){let n=s.charCodeAt(0);s==="'"?e+="\\'":s==="\\"?e+="\\\\":s===`
|
|
14
|
+
`?e+="\\n":s===" "?e+="\\t":s==="\r"?e+="\\r":s==="\x07"?e+="\\a":s==="\b"?e+="\\b":s==="\f"?e+="\\f":s==="\v"?e+="\\v":s==="\x1B"?e+="\\E":n<32||n>=127&&n<=255?e+=`\\${n.toString(8).padStart(3,"0")}`:s==='"'?e+='\\"':e+=s}return e+="'",e}let r="";for(let e of t)" |&;<>()$`\\\"'*?[#~=%!{}".includes(e)?r+=`\\${e}`:r+=e;return r}function ae(t,a){let r=t.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!r)return(0,$.sprintf)(t.replace(/0+(?=\d)/,""),a);let e=r[1]==="-",s=r[2]?parseInt(r[2],10):0,n=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,c=e?-s:s;return _(a,c,n)}function ie(t,a){let r=se(a),e=t.match(/^%(-?)(\d*)q$/);if(!e)return r;let s=e[1]==="-",n=e[2]?parseInt(e[2],10):0,c=r;return n>c.length&&(s?c=c.padEnd(n," "):c=c.padStart(n," ")),c}function oe(t,a,r){let e=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!e)return(0,$.sprintf)(t,r);let s=e[1]||"",n=e[2]?parseInt(e[2],10):0,c=e[3]!==void 0?e[4]?parseInt(e[4],10):0:6,i,u=a.toLowerCase();if(u==="e"?(i=r.toExponential(c),i=i.replace(/e([+-])(\d)$/,"e$10$2"),a==="E"&&(i=i.toUpperCase())):u==="f"?(i=r.toFixed(c),s.includes("#")&&c===0&&!i.includes(".")&&(i+=".")):u==="g"?(i=r.toPrecision(c||1),s.includes("#")||(i=i.replace(/\.?0+$/,""),i=i.replace(/\.?0+e/,"e")),i=i.replace(/e([+-])(\d)$/,"e$10$2"),a==="G"&&(i=i.toUpperCase())):i=r.toString(),r>=0&&(s.includes("+")?i=`+${i}`:s.includes(" ")&&(i=` ${i}`)),n>i.length)if(s.includes("-"))i=i.padEnd(n," ");else if(s.includes("0")){let l=i.match(/^[+ -]/)?.[0]||"",o=l?i.slice(1):i;i=l+o.padStart(n-l.length,"0")}else i=i.padStart(n," ");return i}function ce(t){let a="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length)switch(t[r+1]){case"n":a+=`
|
|
15
|
+
`,r+=2;break;case"t":a+=" ",r+=2;break;case"r":a+="\r",r+=2;break;case"\\":a+="\\",r+=2;break;case"a":a+="\x07",r+=2;break;case"b":a+="\b",r+=2;break;case"f":a+="\f",r+=2;break;case"v":a+="\v",r+=2;break;case"c":return{value:a,stopped:!0};case"x":{let s=[],n=r;for(;n+1<t.length&&t[n]==="\\"&&t[n+1]==="x";){let c="",i=n+2;for(;i<t.length&&i<n+4&&/[0-9a-fA-F]/.test(t[i]);)c+=t[i],i++;if(c)s.push(parseInt(c,16)),n=i;else break}s.length>0?(a+=B(s),r=n):(a+="\\x",r+=2);break}case"u":{let s="",n=r+2;for(;n<t.length&&n<r+6&&/[0-9a-fA-F]/.test(t[n]);)s+=t[n],n++;s?(a+=String.fromCodePoint(parseInt(s,16)),r=n):(a+="\\u",r+=2);break}case"0":{let s="",n=r+2;for(;n<t.length&&n<r+5&&/[0-7]/.test(t[n]);)s+=t[n],n++;s?a+=String.fromCharCode(parseInt(s,8)):a+="\0",r=n;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",n=r+1;for(;n<t.length&&n<r+4&&/[0-7]/.test(t[n]);)s+=t[n],n++;a+=String.fromCharCode(parseInt(s,8)),r=n;break}default:a+=t[r],r++}else a+=t[r],r++;return{value:a,stopped:!1}}var ye={name:"printf",flags:[{flag:"-v",type:"value",valueHint:"string"}],stdinType:"none",needsArgs:!0};export{ge as a,ye as b};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{c as D}from"./chunk-NRSASXYY.js";import{a as N}from"./chunk-QIQMJJZ4.js";import{a as H,b as A}from"./chunk-QAYAQNCG.js";var b=class{diff(e,n,t={}){let i;typeof t=="function"?(i=t,t={}):"callback"in t&&(i=t.callback);let d=this.castInput(e,t),o=this.castInput(n,t),s=this.removeEmpty(this.tokenize(d,t)),a=this.removeEmpty(this.tokenize(o,t));return this.diffWithOptionsObj(s,a,t,i)}diffWithOptionsObj(e,n,t,i){var d;let o=l=>{if(l=this.postProcess(l,t),i){setTimeout(function(){i(l)},0);return}else return l},s=n.length,a=e.length,u=1,r=s+a;t.maxEditLength!=null&&(r=Math.min(r,t.maxEditLength));let g=(d=t.timeout)!==null&&d!==void 0?d:1/0,w=Date.now()+g,m=[{oldPos:-1,lastComponent:void 0}],C=this.extractCommon(m[0],n,e,0,t);if(m[0].oldPos+1>=a&&C+1>=s)return o(this.buildValues(m[0].lastComponent,n,e));let P=-1/0,x=1/0,L=()=>{for(let l=Math.max(P,-u);l<=Math.min(x,u);l+=2){let c,h=m[l-1],p=m[l+1];h&&(m[l-1]=void 0);let y=!1;if(p){let S=p.oldPos-l;y=p&&0<=S&&S<s}let v=h&&h.oldPos+1<a;if(!y&&!v){m[l]=void 0;continue}if(!v||y&&h.oldPos<p.oldPos?c=this.addToPath(p,!0,!1,0,t):c=this.addToPath(h,!1,!0,1,t),C=this.extractCommon(c,n,e,l,t),c.oldPos+1>=a&&C+1>=s)return o(this.buildValues(c.lastComponent,n,e))||!0;m[l]=c,c.oldPos+1>=a&&(x=Math.min(x,l-1)),C+1>=s&&(P=Math.max(P,l+1))}u++};if(i)(function l(){setTimeout(function(){if(u>r||Date.now()>w)return i(void 0);L()||l()},0)})();else for(;u<=r&&Date.now()<=w;){let l=L();if(l)return l}}addToPath(e,n,t,i,d){let o=e.lastComponent;return o&&!d.oneChangePerToken&&o.added===n&&o.removed===t?{oldPos:e.oldPos+i,lastComponent:{count:o.count+1,added:n,removed:t,previousComponent:o.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:n,removed:t,previousComponent:o}}}extractCommon(e,n,t,i,d){let o=n.length,s=t.length,a=e.oldPos,u=a-i,r=0;for(;u+1<o&&a+1<s&&this.equals(t[a+1],n[u+1],d);)u++,a++,r++,d.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return r&&!d.oneChangePerToken&&(e.lastComponent={count:r,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,u}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let i=[],d;for(;e;)i.push(e),d=e.previousComponent,delete e.previousComponent,e=d;i.reverse();let o=i.length,s=0,a=0,u=0;for(;s<o;s++){let r=i[s];if(r.removed)r.value=this.join(t.slice(u,u+r.count)),u+=r.count;else{if(!r.added&&this.useLongestToken){let g=n.slice(a,a+r.count);g=g.map(function(w,m){let C=t[u+m];return C.length>w.length?C:w}),r.value=this.join(g)}else r.value=this.join(n.slice(a,a+r.count));a+=r.count,r.added||(u+=r.count)}}return i}};var I=class extends b{constructor(){super(...arguments),this.tokenize=W}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
|
|
3
|
+
`))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
|
|
4
|
+
`))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
|
|
5
|
+
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
6
|
+
`)&&(n=n.slice(0,-1))),super.equals(e,n,t)}},O=new I;function T(f,e,n){return O.diff(f,e,n)}function W(f,e){e.stripTrailingCr&&(f=f.replace(/\r\n/g,`
|
|
7
|
+
`));let n=[],t=f.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(let i=0;i<t.length;i++){let d=t[i];i%2&&!e.newlineIsToken?n[n.length-1]+=d:n.push(d)}return n}var j={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function F(f,e,n,t,i,d,o){let s;o?typeof o=="function"?s={callback:o}:s=o:s={},typeof s.context>"u"&&(s.context=4);let a=s.context;if(s.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(s.callback){let{callback:r}=s;T(n,t,Object.assign(Object.assign({},s),{callback:g=>{let w=u(g);r(w)}}))}else return u(T(n,t,s));function u(r){if(!r)return;r.push({value:"",lines:[]});function g(l){return l.map(function(c){return" "+c})}let w=[],m=0,C=0,P=[],x=1,L=1;for(let l=0;l<r.length;l++){let c=r[l],h=c.lines||R(c.value);if(c.lines=h,c.added||c.removed){if(!m){let p=r[l-1];m=x,C=L,p&&(P=a>0?g(p.lines.slice(-a)):[],m-=P.length,C-=P.length)}for(let p of h)P.push((c.added?"+":"-")+p);c.added?L+=h.length:x+=h.length}else{if(m)if(h.length<=a*2&&l<r.length-2)for(let p of g(h))P.push(p);else{let p=Math.min(h.length,a);for(let v of g(h.slice(0,p)))P.push(v);let y={oldStart:m,oldLines:x-m+p,newStart:C,newLines:L-C+p,lines:P};w.push(y),m=0,C=0,P=[]}x+=h.length,L+=h.length}}for(let l of w)for(let c=0;c<l.lines.length;c++)l.lines[c].endsWith(`
|
|
8
|
+
`)?l.lines[c]=l.lines[c].slice(0,-1):(l.lines.splice(c+1,0,"\"),c++);return{oldFileName:f,newFileName:e,oldHeader:i,newHeader:d,hunks:w}}}function E(f,e){if(e||(e=j),Array.isArray(f)){if(f.length>1&&!e.includeFileHeaders)throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return f.map(t=>E(t,e)).join(`
|
|
9
|
+
`)}let n=[];e.includeIndex&&f.oldFileName==f.newFileName&&n.push("Index: "+f.oldFileName),e.includeUnderline&&n.push("==================================================================="),e.includeFileHeaders&&(n.push("--- "+f.oldFileName+(typeof f.oldHeader>"u"?"":" "+f.oldHeader)),n.push("+++ "+f.newFileName+(typeof f.newHeader>"u"?"":" "+f.newHeader)));for(let t=0;t<f.hunks.length;t++){let i=f.hunks[t];i.oldLines===0&&(i.oldStart-=1),i.newLines===0&&(i.newStart-=1),n.push("@@ -"+i.oldStart+","+i.oldLines+" +"+i.newStart+","+i.newLines+" @@");for(let d of i.lines)n.push(d)}return n.join(`
|
|
10
|
+
`)+`
|
|
11
|
+
`}function k(f,e,n,t,i,d,o){if(typeof o=="function"&&(o={callback:o}),o?.callback){let{callback:s}=o;F(f,e,n,t,i,d,Object.assign(Object.assign({},o),{callback:a=>{s(a?E(a,o.headerOptions):void 0)}}))}else{let s=F(f,e,n,t,i,d,o);return s?E(s,o?.headerOptions):void 0}}function R(f){let e=f.endsWith(`
|
|
12
|
+
`),n=f.split(`
|
|
13
|
+
`).map(t=>t+`
|
|
14
|
+
`);return e?n.pop():n.push(n.pop().slice(0,-1)),n}var z={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},_={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},ee={name:"diff",async execute(f,e){if(A(f))return H(z);let n=N("diff",f,_);if(!n.ok)return n.error;let t=n.result.flags.brief,i=n.result.flags.reportSame,d=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
15
|
+
`,exitCode:2};let s,a,[u,r]=o;try{s=u==="-"?D(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
|
|
16
|
+
`,exitCode:2}}try{a=r==="-"?D(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,r))}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
17
|
+
`,exitCode:2}}let g=s,w=a;return d&&(g=g.toLowerCase(),w=w.toLowerCase()),g===w?i?{stdout:`Files ${u} and ${r} are identical
|
|
18
|
+
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:t?{stdout:`Files ${u} and ${r} differ
|
|
19
|
+
`,stderr:"",exitCode:1}:{stdout:k(u,r,s,a,"","",{context:3}),stderr:"",exitCode:1}}},ne={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{ee as a,ne as b};
|