xl1 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/index.js +6 -1
  2. package/package.json +5 -1
package/dist/index.js CHANGED
@@ -1 +1,6 @@
1
- "use strict";var S=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var b=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var w=b((P,q)=>{var O=S("fs"),r=S("xlsx"),R=s=>{let{file:e,sheet:o,range:a,defval:c,noNullRow:l}=s;if(!O.existsSync(e)){console.log("file not found, ",e);return}if(![".xlsx",".xlsm"].find(u=>e.endsWith(u))){console.log("file type error, ",e);return}let i=r.readFile(e,{bookSheets:!1});if(!i)return null;let g=i.Sheets[o||i.SheetNames[0]],k={range:a,blankrows:!1,defval:c},p=r.utils.sheet_to_json(g,k);return l?p.filter(u=>Object.values(u).some(x=>!!x)):p},Z=s=>{let{file:e,data:o,sheet:a}=s;if(!(e&&o&&Array.isArray(o)&&o.length>0))return;let c=Array.isArray(o[0])?r.utils.aoa_to_sheet(o):r.utils.json_to_sheet(o),l=O.existsSync(e)?r.readFile(e,{cellDates:!0}):r.utils.book_new();r.utils.book_append_sheet(l,c,a?a.substring(0,31):"Sheet1",!0),r.writeFile(l,e,{compression:!0})};q.exports={readXlsx:R,writeXlsx:Z}});var v=b((T,j)=>{var{readXlsx:D}=w(),W={command:"read",describe:"load excel file",builder:{file:{alias:"f",describe:"load xlsx file ",demandOption:!0,type:"string"},sheet:{alias:"s",describe:"xlsx sheet name",demandOption:!1,type:"string"},range:{alias:"r",describe:"range of excel",default:"A1:Z2000",demandOption:!1,type:"string"},defval:{describe:"defval of cell",demandOption:!1,default:void 0,type:"string"}},handler(s){(async()=>{let e=D(s);console.log(JSON.stringify(e,null,2))})()}};j.exports=W});var F=b((Y,X)=>{var{readXlsx:I,writeXlsx:B}=w(),H={command:"merge <files..>",describe:"merge multiple excel sheets into the first sheet. (format: file|sheet|range, file|Sheet1|A1:Z2000)",builder:{output:{alias:"o",describe:"output file name",default:"MergedBook.xlsx",type:"string"},sheet:{alias:"s",describe:"xlsx sheet name",demandOption:!1,type:"string"},debug:{alias:"d",describe:"print debug log",demandOption:!1,type:"boolean"}},handler(s){(async()=>{let e=t=>{let[n,_,f]=t.split("|");return{file:n,sheet:_,range:f||"A1:Z2000",defval:null,noNullRow:!0}},[o,...a]=s.files,c=e(o),l=a.map(e),i=t=>{let n=Object.values(t);return n&&n.length>0?n[0]:""},d=I(c),g=d.map(i);l.map(t=>I(t)).forEach((t,n)=>{t.map(i).forEach((f,M)=>{let y=g.findIndex(h=>f&&f===h);if(y>-1){let h=t[M],A=d[y];Object.keys(h).slice(1).forEach(m=>{m in A&&h[m]&&(A[m]=h[m])})}s.debug&&console.log(l[n].sheet,f,y>-1?"found in baseSheet":"not found in baseSheet")})}),console.log("Merge completed successfully.");let p=Object.keys(d[0]).map(t=>t.startsWith("__EMPTY")?null:t),u=d.slice(1).map(t=>Object.values(t)).filter(t=>t.some(n=>n!==null)),x=[p,...u];B({file:s.output,data:x,sheet:s.sheet||"MergedSheet"})})()}};X.exports=H});var E=b((z,N)=>{N.exports=()=>{let s=S("yargs").scriptName("xl1");s.command(v()),s.command(F());let e=s.parse();(!e._||e._.length===0)&&s.showHelp()}});E()();
1
+ "use strict";var k=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ue=S((Ps,tt)=>{var Ve=k("fs"),W=k("xlsx"),pr=e=>{let{file:t,sheet:r,range:s,defval:n,noNullRow:a}=e;if(!Ve.existsSync(t)){console.log("file not found, ",t);return}if(![".xlsx",".xlsm"].find(p=>t.endsWith(p))){console.log("file type error, ",t);return}let i=W.readFile(t,{bookSheets:!1});if(!i)return null;let o=i.Sheets[r||i.SheetNames[0]],u={range:s,blankrows:!1,defval:n},l=W.utils.sheet_to_json(o,u);return a?l.filter(p=>Object.values(p).some(h=>!!h)):l},vr=e=>{let{file:t,data:r,sheet:s}=e;if(!(t&&r&&Array.isArray(r)&&r.length>0))return;let n=Array.isArray(r[0])?W.utils.aoa_to_sheet(r):W.utils.json_to_sheet(r),a=Ve.existsSync(t)?W.readFile(t,{cellDates:!0}):W.utils.book_new();W.utils.book_append_sheet(a,n,s?s.substring(0,31):"Sheet1",!0),W.writeFile(a,t,{compression:!0})},ce=e=>{let[t,r]=e.split(":"),s=t.replace(/\D/g,""),n=r.replace(/\D/g,""),a=t.replace(/\d/g,""),i=r.replace(/\d/g,"");return{startRow:parseInt(s),endRow:parseInt(n),startCol:a,endCol:i,firstRow:`${t}:${i}${s}`,firstCol:`${t}:${a}${n}`}},et=(e,t,r,s,n)=>{let a=[];for(let i=t;i<=r;i++){let c=[];for(let o=s;o<=n;o++){let l=e[""];c.push(l?l.v:null)}a.push(c)}return a},_e=(e,t)=>{let r=ce(t);return et(e,r.startRow,r.endRow,r.startCol,r.endCol)},gr=(e,t)=>{let r=ce(t);return _e(e,r.firstRow)[0]},mr=(e,t)=>{let r=ce(t);return _e(e,r.firstCol)[0]};tt.exports={readXlsx:pr,writeXlsx:vr,getSheetData:_e,getSheetData2:et,parseRange:ce,getFirstRow:gr,getFirstCol:mr}});var rt=S(ke=>{var Q=k("path"),P=process.platform==="win32",G=k("fs"),yr=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function wr(){var e;if(yr){var t=new Error;e=r}else e=s;return e;function r(n){n&&(t.message=n.message,n=t,s(n))}function s(n){if(n){if(process.throwDeprecation)throw n;if(!process.noDeprecation){var a="fs: missing callback "+(n.stack||n.message);process.traceDeprecation?console.trace(a):console.error(a)}}}}function br(e){return typeof e=="function"?e:wr()}var Bs=Q.normalize;P?L=/(.*?)(?:[\/\\]+|$)/g:L=/(.*?)(?:[\/]+|$)/g;var L;P?ee=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/:ee=/^[\/]*/;var ee;ke.realpathSync=function(t,r){if(t=Q.resolve(t),r&&Object.prototype.hasOwnProperty.call(r,t))return r[t];var s=t,n={},a={},i,c,o,u;l();function l(){var v=ee.exec(t);i=v[0].length,c=v[0],o=v[0],u="",P&&!a[o]&&(G.lstatSync(o),a[o]=!0)}for(;i<t.length;){L.lastIndex=i;var p=L.exec(t);if(u=c,c+=p[0],o=u+p[1],i=L.lastIndex,!(a[o]||r&&r[o]===o)){var h;if(r&&Object.prototype.hasOwnProperty.call(r,o))h=r[o];else{var f=G.lstatSync(o);if(!f.isSymbolicLink()){a[o]=!0,r&&(r[o]=o);continue}var d=null;if(!P){var g=f.dev.toString(32)+":"+f.ino.toString(32);n.hasOwnProperty(g)&&(d=n[g])}d===null&&(G.statSync(o),d=G.readlinkSync(o)),h=Q.resolve(u,d),r&&(r[o]=h),P||(n[g]=d)}t=Q.resolve(h,t.slice(i)),l()}}return r&&(r[s]=t),t};ke.realpath=function(t,r,s){if(typeof s!="function"&&(s=br(r),r=null),t=Q.resolve(t),r&&Object.prototype.hasOwnProperty.call(r,t))return process.nextTick(s.bind(null,null,r[t]));var n=t,a={},i={},c,o,u,l;p();function p(){var v=ee.exec(t);c=v[0].length,o=v[0],u=v[0],l="",P&&!i[u]?G.lstat(u,function(y){if(y)return s(y);i[u]=!0,h()}):process.nextTick(h)}function h(){if(c>=t.length)return r&&(r[n]=t),s(null,t);L.lastIndex=c;var v=L.exec(t);return l=o,o+=v[0],u=l+v[1],c=L.lastIndex,i[u]||r&&r[u]===u?process.nextTick(h):r&&Object.prototype.hasOwnProperty.call(r,u)?g(r[u]):G.lstat(u,f)}function f(v,y){if(v)return s(v);if(!y.isSymbolicLink())return i[u]=!0,r&&(r[u]=u),process.nextTick(h);if(!P){var w=y.dev.toString(32)+":"+y.ino.toString(32);if(a.hasOwnProperty(w))return d(null,a[w],u)}G.stat(u,function(m){if(m)return s(m);G.readlink(u,function(b,O){P||(a[w]=O),d(b,O)})})}function d(v,y,w){if(v)return s(v);var m=Q.resolve(l,y);r&&(r[w]=m),g(m)}function g(v){t=Q.resolve(v,t.slice(c)),p()}}});var Ae=S((Hs,at)=>{at.exports=B;B.realpath=B;B.sync=Ee;B.realpathSync=Ee;B.monkeypatch=kr;B.unmonkeypatch=Sr;var K=k("fs"),Se=K.realpath,Oe=K.realpathSync,_r=process.version,st=/^v[0-5]\./.test(_r),nt=rt();function it(e){return e&&e.syscall==="realpath"&&(e.code==="ELOOP"||e.code==="ENOMEM"||e.code==="ENAMETOOLONG")}function B(e,t,r){if(st)return Se(e,t,r);typeof t=="function"&&(r=t,t=null),Se(e,t,function(s,n){it(s)?nt.realpath(e,t,r):r(s,n)})}function Ee(e,t){if(st)return Oe(e,t);try{return Oe(e,t)}catch(r){if(it(r))return nt.realpathSync(e,t);throw r}}function kr(){K.realpath=B,K.realpathSync=Ee}function Sr(){K.realpath=Se,K.realpathSync=Oe}});var ct=S((Js,ot)=>{ot.exports=function(e,t){for(var r=[],s=0;s<e.length;s++){var n=t(e[s],s);Or(n)?r.push.apply(r,n):r.push(n)}return r};var Or=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}});var dt=S((Qs,ft)=>{"use strict";ft.exports=lt;function lt(e,t,r){e instanceof RegExp&&(e=ut(e,r)),t instanceof RegExp&&(t=ut(t,r));var s=ht(e,t,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+e.length,s[1]),post:r.slice(s[1]+t.length)}}function ut(e,t){var r=t.match(e);return r?r[0]:null}lt.range=ht;function ht(e,t,r){var s,n,a,i,c,o=r.indexOf(e),u=r.indexOf(t,o+1),l=o;if(o>=0&&u>0){if(e===t)return[o,u];for(s=[],a=r.length;l>=0&&!c;)l==o?(s.push(l),o=r.indexOf(e,l+1)):s.length==1?c=[s.pop(),u]:(n=s.pop(),n<a&&(a=n,i=u),u=r.indexOf(t,l+1)),l=o<u&&o>=0?o:u;s.length&&(c=[a,i])}return c}});var _t=S((Us,bt)=>{var Er=ct(),pt=dt();bt.exports=jr;var vt="\0SLASH"+Math.random()+"\0",gt="\0OPEN"+Math.random()+"\0",je="\0CLOSE"+Math.random()+"\0",mt="\0COMMA"+Math.random()+"\0",yt="\0PERIOD"+Math.random()+"\0";function xe(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function Ar(e){return e.split("\\\\").join(vt).split("\\{").join(gt).split("\\}").join(je).split("\\,").join(mt).split("\\.").join(yt)}function xr(e){return e.split(vt).join("\\").split(gt).join("{").split(je).join("}").split(mt).join(",").split(yt).join(".")}function wt(e){if(!e)return[""];var t=[],r=pt("{","}",e);if(!r)return e.split(",");var s=r.pre,n=r.body,a=r.post,i=s.split(",");i[i.length-1]+="{"+n+"}";var c=wt(a);return a.length&&(i[i.length-1]+=c.shift(),i.push.apply(i,c)),t.push.apply(t,i),t}function jr(e){return e?(e.substr(0,2)==="{}"&&(e="\\{\\}"+e.substr(2)),Y(Ar(e),!0).map(xr)):[]}function Rr(e){return"{"+e+"}"}function Ir(e){return/^-?0\d/.test(e)}function qr(e,t){return e<=t}function Cr(e,t){return e>=t}function Y(e,t){var r=[],s=pt("{","}",e);if(!s||/\$$/.test(s.pre))return[e];var n=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),i=n||a,c=s.body.indexOf(",")>=0;if(!i&&!c)return s.post.match(/,.*\}/)?(e=s.pre+"{"+s.body+je+s.post,Y(e)):[e];var o;if(i)o=s.body.split(/\.\./);else if(o=wt(s.body),o.length===1&&(o=Y(o[0],!1).map(Rr),o.length===1)){var l=s.post.length?Y(s.post,!1):[""];return l.map(function($){return s.pre+o[0]+$})}var u=s.pre,l=s.post.length?Y(s.post,!1):[""],p;if(i){var h=xe(o[0]),f=xe(o[1]),d=Math.max(o[0].length,o[1].length),g=o.length==3?Math.abs(xe(o[2])):1,v=qr,y=f<h;y&&(g*=-1,v=Cr);var w=o.some(Ir);p=[];for(var m=h;v(m,f);m+=g){var b;if(a)b=String.fromCharCode(m),b==="\\"&&(b="");else if(b=String(m),w){var O=d-b.length;if(O>0){var N=new Array(O+1).join("0");m<0?b="-"+N+b.slice(1):b=N+b}}p.push(b)}}else p=Er(o,function(I){return Y(I,!1)});for(var j=0;j<p.length;j++)for(var R=0;R<l.length;R++){var E=u+p[j]+l[R];(!t||i||E)&&r.push(E)}return r}});var fe=S((Zs,At)=>{At.exports=q;q.Minimatch=x;var te=function(){try{return k("path")}catch (e2){}}()||{sep:"/"};q.sep=te.sep;var qe=q.GLOBSTAR=x.GLOBSTAR={},Nr=_t(),kt={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},Re="[^/]",Ie=Re+"*?",Dr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Fr="(?:(?!(?:\\/|^)\\.).)*?",St=Mr("().*{}+?[]^$\\!");function Mr(e){return e.split("").reduce(function(t,r){return t[r]=!0,t},{})}var Ot=/\/+/;q.filter=Lr;function Lr(e,t){return t=t||{},function(r,s,n){return q(r,e,t)}}function X(e,t){t=t||{};var r={};return Object.keys(e).forEach(function(s){r[s]=e[s]}),Object.keys(t).forEach(function(s){r[s]=t[s]}),r}q.defaults=function(e){if(!e||typeof e!="object"||!Object.keys(e).length)return q;var t=q,r=function(n,a,i){return t(n,a,X(e,i))};return r.Minimatch=function(n,a){return new t.Minimatch(n,X(e,a))},r.Minimatch.defaults=function(n){return t.defaults(X(e,n)).Minimatch},r.filter=function(n,a){return t.filter(n,X(e,a))},r.defaults=function(n){return t.defaults(X(e,n))},r.makeRe=function(n,a){return t.makeRe(n,X(e,a))},r.braceExpand=function(n,a){return t.braceExpand(n,X(e,a))},r.match=function(s,n,a){return t.match(s,n,X(e,a))},r};x.defaults=function(e){return q.defaults(e).Minimatch};function q(e,t,r){return he(t),r||(r={}),!r.nocomment&&t.charAt(0)==="#"?!1:new x(t,r).match(e)}function x(e,t){if(!(this instanceof x))return new x(e,t);he(e),t||(t={}),e=e.trim(),!t.allowWindowsEscape&&te.sep!=="/"&&(e=e.split(te.sep).join("/")),this.options=t,this.set=[],this.pattern=e,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.make()}x.prototype.debug=function(){};x.prototype.make=$r;function $r(){var e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate();var r=this.globSet=this.braceExpand();t.debug&&(this.debug=function(){console.error.apply(console,arguments)}),this.debug(this.pattern,r),r=this.globParts=r.map(function(s){return s.split(Ot)}),this.debug(this.pattern,r),r=r.map(function(s,n,a){return s.map(this.parse,this)},this),this.debug(this.pattern,r),r=r.filter(function(s){return s.indexOf(!1)===-1}),this.debug(this.pattern,r),this.set=r}x.prototype.parseNegate=Tr;function Tr(){var e=this.pattern,t=!1,r=this.options,s=0;if(!r.nonegate){for(var n=0,a=e.length;n<a&&e.charAt(n)==="!";n++)t=!t,s++;s&&(this.pattern=e.substr(s)),this.negate=t}}q.braceExpand=function(e,t){return Et(e,t)};x.prototype.braceExpand=Et;function Et(e,t){return t||(this instanceof x?t=this.options:t={}),e=typeof e>"u"?this.pattern:e,he(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Nr(e)}var Wr=1024*64,he=function(e){if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>Wr)throw new TypeError("pattern is too long")};x.prototype.parse=Gr;var le={};function Gr(e,t){he(e);var r=this.options;if(e==="**")if(r.noglobstar)e="*";else return qe;if(e==="")return"";var s="",n=!!r.nocase,a=!1,i=[],c=[],o,u=!1,l=-1,p=-1,h=e.charAt(0)==="."?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",f=this;function d(){if(o){switch(o){case"*":s+=Ie,n=!0;break;case"?":s+=Re,n=!0;break;default:s+="\\"+o;break}f.debug("clearStateChar %j %j",o,s),o=!1}}for(var g=0,v=e.length,y;g<v&&(y=e.charAt(g));g++){if(this.debug("%s %s %s %j",e,g,s,y),a&&St[y]){s+="\\"+y,a=!1;continue}switch(y){case"/":return!1;case"\\":d(),a=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",e,g,s,y),u){this.debug(" in class"),y==="!"&&g===p+1&&(y="^"),s+=y;continue}f.debug("call clearStateChar %j",o),d(),o=y,r.noext&&d();continue;case"(":if(u){s+="(";continue}if(!o){s+="\\(";continue}i.push({type:o,start:g-1,reStart:s.length,open:kt[o].open,close:kt[o].close}),s+=o==="!"?"(?:(?!(?:":"(?:",this.debug("plType %j %j",o,s),o=!1;continue;case")":if(u||!i.length){s+="\\)";continue}d(),n=!0;var w=i.pop();s+=w.close,w.type==="!"&&c.push(w),w.reEnd=s.length;continue;case"|":if(u||!i.length||a){s+="\\|",a=!1;continue}d(),s+="|";continue;case"[":if(d(),u){s+="\\"+y;continue}u=!0,p=g,l=s.length,s+=y;continue;case"]":if(g===p+1||!u){s+="\\"+y,a=!1;continue}var m=e.substring(p+1,g);try{RegExp("["+m+"]")}catch (e3){var b=this.parse(m,le);s=s.substr(0,l)+"\\["+b[0]+"\\]",n=n||b[1],u=!1;continue}n=!0,u=!1,s+=y;continue;default:d(),a?a=!1:St[y]&&!(y==="^"&&u)&&(s+="\\"),s+=y}}for(u&&(m=e.substr(p+1),b=this.parse(m,le),s=s.substr(0,l)+"\\["+b[0],n=n||b[1]),w=i.pop();w;w=i.pop()){var O=s.slice(w.reStart+w.open.length);this.debug("setting tail",s,w),O=O.replace(/((?:\\{2}){0,64})(\\?)\|/g,function(Ke,Ye,be){return be||(be="\\"),Ye+Ye+be+"|"}),this.debug(`tail=%j
2
+ %s`,O,O,w,s);var N=w.type==="*"?Ie:w.type==="?"?Re:"\\"+w.type;n=!0,s=s.slice(0,w.reStart)+N+"\\("+O}d(),a&&(s+="\\\\");var j=!1;switch(s.charAt(0)){case"[":case".":case"(":j=!0}for(var R=c.length-1;R>-1;R--){var E=c[R],I=s.slice(0,E.reStart),$=s.slice(E.reStart,E.reEnd-8),D=s.slice(E.reEnd-8,E.reEnd),M=s.slice(E.reEnd);D+=M;var J=I.split("(").length-1,F=M;for(g=0;g<J;g++)F=F.replace(/\)[+*?]?/,"");M=F;var T="";M===""&&t!==le&&(T="$");var ae=I+$+M+T+D;s=ae}if(s!==""&&n&&(s="(?=.)"+s),j&&(s=h+s),t===le)return[s,n];if(!n)return Br(e);var oe=r.nocase?"i":"";try{var we=new RegExp("^"+s+"$",oe)}catch (e4){return new RegExp("$.")}return we._glob=e,we._src=s,we}q.makeRe=function(e,t){return new x(e,t||{}).makeRe()};x.prototype.makeRe=Pr;function Pr(){if(this.regexp||this.regexp===!1)return this.regexp;var e=this.set;if(!e.length)return this.regexp=!1,this.regexp;var t=this.options,r=t.noglobstar?Ie:t.dot?Dr:Fr,s=t.nocase?"i":"",n=e.map(function(a){return a.map(function(i){return i===qe?r:typeof i=="string"?Xr(i):i._src}).join("\\/")}).join("|");n="^(?:"+n+")$",this.negate&&(n="^(?!"+n+").*$");try{this.regexp=new RegExp(n,s)}catch (e5){this.regexp=!1}return this.regexp}q.match=function(e,t,r){r=r||{};var s=new x(t,r);return e=e.filter(function(n){return s.match(n)}),s.options.nonull&&!e.length&&e.push(t),e};x.prototype.match=function(t,r){if(typeof r>"u"&&(r=this.partial),this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;var s=this.options;te.sep!=="/"&&(t=t.split(te.sep).join("/")),t=t.split(Ot),this.debug(this.pattern,"split",t);var n=this.set;this.debug(this.pattern,"set",n);var a,i;for(i=t.length-1;i>=0&&(a=t[i],!a);i--);for(i=0;i<n.length;i++){var c=n[i],o=t;s.matchBase&&c.length===1&&(o=[a]);var u=this.matchOne(o,c,r);if(u)return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate};x.prototype.matchOne=function(e,t,r){var s=this.options;this.debug("matchOne",{this:this,file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var n=0,a=0,i=e.length,c=t.length;n<i&&a<c;n++,a++){this.debug("matchOne loop");var o=t[a],u=e[n];if(this.debug(t,o,u),o===!1)return!1;if(o===qe){this.debug("GLOBSTAR",[t,o,u]);var l=n,p=a+1;if(p===c){for(this.debug("** at the end");n<i;n++)if(e[n]==="."||e[n]===".."||!s.dot&&e[n].charAt(0)===".")return!1;return!0}for(;l<i;){var h=e[l];if(this.debug(`
3
+ globstar while`,e,l,t,p,h),this.matchOne(e.slice(l),t.slice(p),r))return this.debug("globstar found match!",l,i,h),!0;if(h==="."||h===".."||!s.dot&&h.charAt(0)==="."){this.debug("dot detected!",e,l,t,p);break}this.debug("globstar swallow a segment, and continue"),l++}return!!(r&&(this.debug(`
4
+ >>> no match, partial?`,e,l,t,p),l===i))}var f;if(typeof o=="string"?(f=u===o,this.debug("string match",o,u,f)):(f=u.match(o),this.debug("pattern match",o,u,f)),!f)return!1}if(n===i&&a===c)return!0;if(n===i)return r;if(a===c)return n===i-1&&e[n]==="";throw new Error("wtf?")};function Br(e){return e.replace(/\\(.)/g,"$1")}function Xr(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}});var xt=S((zs,Ce)=>{typeof Object.create=="function"?Ce.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:Ce.exports=function(t,r){if(r){t.super_=r;var s=function(){};s.prototype=r.prototype,t.prototype=new s,t.prototype.constructor=t}}});var jt=S((Ks,De)=>{try{if(Ne=k("util"),typeof Ne.inherits!="function")throw"";De.exports=Ne.inherits}catch (e6){De.exports=xt()}var Ne});var pe=S((Ys,de)=>{"use strict";function Rt(e){return e.charAt(0)==="/"}function It(e){var t=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,r=t.exec(e),s=r[1]||"",n=!!(s&&s.charAt(1)!==":");return!!(r[2]||n)}de.exports=process.platform==="win32"?It:Rt;de.exports.posix=Rt;de.exports.win32=It});var Me=S(H=>{H.setopts=zr;H.ownProp=qt;H.makeAbs=re;H.finish=Kr;H.mark=Yr;H.isIgnored=Nt;H.childrenIgnored=Vr;function qt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Hr=k("fs"),V=k("path"),Jr=fe(),Ct=pe(),Fe=Jr.Minimatch;function Qr(e,t){return e.localeCompare(t,"en")}function Ur(e,t){e.ignore=t.ignore||[],Array.isArray(e.ignore)||(e.ignore=[e.ignore]),e.ignore.length&&(e.ignore=e.ignore.map(Zr))}function Zr(e){var t=null;if(e.slice(-3)==="/**"){var r=e.replace(/(\/\*\*)+$/,"");t=new Fe(r,{dot:!0})}return{matcher:new Fe(e,{dot:!0}),gmatcher:t}}function zr(e,t,r){if(r||(r={}),r.matchBase&&t.indexOf("/")===-1){if(r.noglobstar)throw new Error("base matching requires globstar");t="**/"+t}e.silent=!!r.silent,e.pattern=t,e.strict=r.strict!==!1,e.realpath=!!r.realpath,e.realpathCache=r.realpathCache||Object.create(null),e.follow=!!r.follow,e.dot=!!r.dot,e.mark=!!r.mark,e.nodir=!!r.nodir,e.nodir&&(e.mark=!0),e.sync=!!r.sync,e.nounique=!!r.nounique,e.nonull=!!r.nonull,e.nosort=!!r.nosort,e.nocase=!!r.nocase,e.stat=!!r.stat,e.noprocess=!!r.noprocess,e.absolute=!!r.absolute,e.fs=r.fs||Hr,e.maxLength=r.maxLength||1/0,e.cache=r.cache||Object.create(null),e.statCache=r.statCache||Object.create(null),e.symlinks=r.symlinks||Object.create(null),Ur(e,r),e.changedCwd=!1;var s=process.cwd();qt(r,"cwd")?(e.cwd=V.resolve(r.cwd),e.changedCwd=e.cwd!==s):e.cwd=s,e.root=r.root||V.resolve(e.cwd,"/"),e.root=V.resolve(e.root),process.platform==="win32"&&(e.root=e.root.replace(/\\/g,"/")),e.cwdAbs=Ct(e.cwd)?e.cwd:re(e,e.cwd),process.platform==="win32"&&(e.cwdAbs=e.cwdAbs.replace(/\\/g,"/")),e.nomount=!!r.nomount,r.nonegate=!0,r.nocomment=!0,r.allowWindowsEscape=!1,e.minimatch=new Fe(t,r),e.options=e.minimatch.options}function Kr(e){for(var t=e.nounique,r=t?[]:Object.create(null),s=0,n=e.matches.length;s<n;s++){var a=e.matches[s];if(!a||Object.keys(a).length===0){if(e.nonull){var i=e.minimatch.globSet[s];t?r.push(i):r[i]=!0}}else{var c=Object.keys(a);t?r.push.apply(r,c):c.forEach(function(o){r[o]=!0})}}if(t||(r=Object.keys(r)),e.nosort||(r=r.sort(Qr)),e.mark){for(var s=0;s<r.length;s++)r[s]=e._mark(r[s]);e.nodir&&(r=r.filter(function(o){var u=!/\/$/.test(o),l=e.cache[o]||e.cache[re(e,o)];return u&&l&&(u=l!=="DIR"&&!Array.isArray(l)),u}))}e.ignore.length&&(r=r.filter(function(o){return!Nt(e,o)})),e.found=r}function Yr(e,t){var r=re(e,t),s=e.cache[r],n=t;if(s){var a=s==="DIR"||Array.isArray(s),i=t.slice(-1)==="/";if(a&&!i?n+="/":!a&&i&&(n=n.slice(0,-1)),n!==t){var c=re(e,n);e.statCache[c]=e.statCache[r],e.cache[c]=e.cache[r]}}return n}function re(e,t){var r=t;return t.charAt(0)==="/"?r=V.join(e.root,t):Ct(t)||t===""?r=t:e.changedCwd?r=V.resolve(e.cwd,t):r=V.resolve(t),process.platform==="win32"&&(r=r.replace(/\\/g,"/")),r}function Nt(e,t){return e.ignore.length?e.ignore.some(function(r){return r.matcher.match(t)||!!(r.gmatcher&&r.gmatcher.match(t))}):!1}function Vr(e,t){return e.ignore.length?e.ignore.some(function(r){return!!(r.gmatcher&&r.gmatcher.match(t))}):!1}});var $t=S((sn,Lt)=>{Lt.exports=Mt;Mt.GlobSync=A;var es=Ae(),Dt=fe(),en=Dt.Minimatch,tn=Te().Glob,rn=k("util"),Le=k("path"),Ft=k("assert"),ve=pe(),U=Me(),ts=U.setopts,$e=U.ownProp,rs=U.childrenIgnored,ss=U.isIgnored;function Mt(e,t){if(typeof t=="function"||arguments.length===3)throw new TypeError(`callback provided to sync glob
5
+ See: https://github.com/isaacs/node-glob/issues/167`);return new A(e,t).found}function A(e,t){if(!e)throw new Error("must provide pattern");if(typeof t=="function"||arguments.length===3)throw new TypeError(`callback provided to sync glob
6
+ See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof A))return new A(e,t);if(ts(this,e,t),this.noprocess)return this;var r=this.minimatch.set.length;this.matches=new Array(r);for(var s=0;s<r;s++)this._process(this.minimatch.set[s],s,!1);this._finish()}A.prototype._finish=function(){if(Ft.ok(this instanceof A),this.realpath){var e=this;this.matches.forEach(function(t,r){var s=e.matches[r]=Object.create(null);for(var n in t)try{n=e._makeAbs(n);var a=es.realpathSync(n,e.realpathCache);s[a]=!0}catch(i){if(i.syscall==="stat")s[e._makeAbs(n)]=!0;else throw i}})}U.finish(this)};A.prototype._process=function(e,t,r){Ft.ok(this instanceof A);for(var s=0;typeof e[s]=="string";)s++;var n;switch(s){case e.length:this._processSimple(e.join("/"),t);return;case 0:n=null;break;default:n=e.slice(0,s).join("/");break}var a=e.slice(s),i;n===null?i=".":((ve(n)||ve(e.map(function(u){return typeof u=="string"?u:"[*]"}).join("/")))&&(!n||!ve(n))&&(n="/"+n),i=n);var c=this._makeAbs(i);if(!rs(this,i)){var o=a[0]===Dt.GLOBSTAR;o?this._processGlobStar(n,i,c,a,t,r):this._processReaddir(n,i,c,a,t,r)}};A.prototype._processReaddir=function(e,t,r,s,n,a){var i=this._readdir(r,a);if(i){for(var c=s[0],o=!!this.minimatch.negate,u=c._glob,l=this.dot||u.charAt(0)===".",p=[],h=0;h<i.length;h++){var f=i[h];if(f.charAt(0)!=="."||l){var d;o&&!e?d=!f.match(c):d=f.match(c),d&&p.push(f)}}var g=p.length;if(g!==0){if(s.length===1&&!this.mark&&!this.stat){this.matches[n]||(this.matches[n]=Object.create(null));for(var h=0;h<g;h++){var f=p[h];e&&(e.slice(-1)!=="/"?f=e+"/"+f:f=e+f),f.charAt(0)==="/"&&!this.nomount&&(f=Le.join(this.root,f)),this._emitMatch(n,f)}return}s.shift();for(var h=0;h<g;h++){var f=p[h],v;e?v=[e,f]:v=[f],this._process(v.concat(s),n,a)}}}};A.prototype._emitMatch=function(e,t){if(!ss(this,t)){var r=this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=r),!this.matches[e][t]){if(this.nodir){var s=this.cache[r];if(s==="DIR"||Array.isArray(s))return}this.matches[e][t]=!0,this.stat&&this._stat(t)}}};A.prototype._readdirInGlobStar=function(e){if(this.follow)return this._readdir(e,!1);var t,r,s;try{r=this.fs.lstatSync(e)}catch(a){if(a.code==="ENOENT")return null}var n=r&&r.isSymbolicLink();return this.symlinks[e]=n,!n&&r&&!r.isDirectory()?this.cache[e]="FILE":t=this._readdir(e,!1),t};A.prototype._readdir=function(e,t){var r;if(t&&!$e(this.symlinks,e))return this._readdirInGlobStar(e);if($e(this.cache,e)){var s=this.cache[e];if(!s||s==="FILE")return null;if(Array.isArray(s))return s}try{return this._readdirEntries(e,this.fs.readdirSync(e))}catch(n){return this._readdirError(e,n),null}};A.prototype._readdirEntries=function(e,t){if(!this.mark&&!this.stat)for(var r=0;r<t.length;r++){var s=t[r];e==="/"?s=e+s:s=e+"/"+s,this.cache[s]=!0}return this.cache[e]=t,t};A.prototype._readdirError=function(e,t){switch(t.code){case"ENOTSUP":case"ENOTDIR":var r=this._makeAbs(e);if(this.cache[r]="FILE",r===this.cwdAbs){var s=new Error(t.code+" invalid cwd "+this.cwd);throw s.path=this.cwd,s.code=t.code,s}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(e)]=!1;break;default:if(this.cache[this._makeAbs(e)]=!1,this.strict)throw t;this.silent||console.error("glob error",t);break}};A.prototype._processGlobStar=function(e,t,r,s,n,a){var i=this._readdir(r,a);if(i){var c=s.slice(1),o=e?[e]:[],u=o.concat(c);this._process(u,n,!1);var l=i.length,p=this.symlinks[r];if(!(p&&a))for(var h=0;h<l;h++){var f=i[h];if(!(f.charAt(0)==="."&&!this.dot)){var d=o.concat(i[h],c);this._process(d,n,!0);var g=o.concat(i[h],s);this._process(g,n,!0)}}}};A.prototype._processSimple=function(e,t){var r=this._stat(e);if(this.matches[t]||(this.matches[t]=Object.create(null)),!!r){if(e&&ve(e)&&!this.nomount){var s=/[\/\\]$/.test(e);e.charAt(0)==="/"?e=Le.join(this.root,e):(e=Le.resolve(this.root,e),s&&(e+="/"))}process.platform==="win32"&&(e=e.replace(/\\/g,"/")),this._emitMatch(t,e)}};A.prototype._stat=function(e){var t=this._makeAbs(e),r=e.slice(-1)==="/";if(e.length>this.maxLength)return!1;if(!this.stat&&$e(this.cache,t)){var i=this.cache[t];if(Array.isArray(i)&&(i="DIR"),!r||i==="DIR")return i;if(r&&i==="FILE")return!1}var s,n=this.statCache[t];if(!n){var a;try{a=this.fs.lstatSync(t)}catch(c){if(c&&(c.code==="ENOENT"||c.code==="ENOTDIR"))return this.statCache[t]=!1,!1}if(a&&a.isSymbolicLink())try{n=this.fs.statSync(t)}catch (e7){n=a}else n=a}this.statCache[t]=n;var i=!0;return n&&(i=n.isDirectory()?"DIR":"FILE"),this.cache[t]=this.cache[t]||i,r&&i==="FILE"?!1:i};A.prototype._mark=function(e){return U.mark(this,e)};A.prototype._makeAbs=function(e){return U.makeAbs(this,e)}});var We=S((nn,Wt)=>{Wt.exports=Tt;function Tt(e,t){if(e&&t)return Tt(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(s){r[s]=e[s]}),r;function r(){for(var s=new Array(arguments.length),n=0;n<s.length;n++)s[n]=arguments[n];var a=e.apply(this,s),i=s[s.length-1];return typeof a=="function"&&a!==i&&Object.keys(i).forEach(function(c){a[c]=i[c]}),a}}});var Pe=S((an,Ge)=>{var Gt=We();Ge.exports=Gt(ge);Ge.exports.strict=Gt(Pt);ge.proto=ge(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return ge(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Pt(this)},configurable:!0})});function ge(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Pt(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}});var Xt=S((on,Bt)=>{var ns=We(),se=Object.create(null),is=Pe();Bt.exports=ns(as);function as(e,t){return se[e]?(se[e].push(t),null):(se[e]=[t],os(e))}function os(e){return is(function t(){var r=se[e],s=r.length,n=cs(arguments);try{for(var a=0;a<s;a++)r[a].apply(null,n)}finally{r.length>s?(r.splice(0,s),process.nextTick(function(){t.apply(null,n)})):delete se[e]}})}function cs(e){for(var t=e.length,r=[],s=0;s<t;s++)r[s]=e[s];return r}});var Te=S((ln,Jt)=>{Jt.exports=Z;var us=Ae(),Ht=fe(),cn=Ht.Minimatch,ls=jt(),hs=k("events").EventEmitter,Be=k("path"),Xe=k("assert"),ne=pe(),Je=$t(),z=Me(),fs=z.setopts,He=z.ownProp,Qe=Xt(),un=k("util"),ds=z.childrenIgnored,ps=z.isIgnored,vs=Pe();function Z(e,t,r){if(typeof t=="function"&&(r=t,t={}),t||(t={}),t.sync){if(r)throw new TypeError("callback provided to sync glob");return Je(e,t)}return new _(e,t,r)}Z.sync=Je;var gs=Z.GlobSync=Je.GlobSync;Z.glob=Z;function ms(e,t){if(t===null||typeof t!="object")return e;for(var r=Object.keys(t),s=r.length;s--;)e[r[s]]=t[r[s]];return e}Z.hasMagic=function(e,t){var r=ms({},t);r.noprocess=!0;var s=new _(e,r),n=s.minimatch.set;if(!e)return!1;if(n.length>1)return!0;for(var a=0;a<n[0].length;a++)if(typeof n[0][a]!="string")return!0;return!1};Z.Glob=_;ls(_,hs);function _(e,t,r){if(typeof t=="function"&&(r=t,t=null),t&&t.sync){if(r)throw new TypeError("callback provided to sync glob");return new gs(e,t)}if(!(this instanceof _))return new _(e,t,r);fs(this,e,t),this._didRealPath=!1;var s=this.minimatch.set.length;this.matches=new Array(s),typeof r=="function"&&(r=vs(r),this.on("error",r),this.on("end",function(o){r(null,o)}));var n=this;if(this._processing=0,this._emitQueue=[],this._processQueue=[],this.paused=!1,this.noprocess)return this;if(s===0)return c();for(var a=!0,i=0;i<s;i++)this._process(this.minimatch.set[i],i,!1,c);a=!1;function c(){--n._processing,n._processing<=0&&(a?process.nextTick(function(){n._finish()}):n._finish())}}_.prototype._finish=function(){if(Xe(this instanceof _),!this.aborted){if(this.realpath&&!this._didRealpath)return this._realpath();z.finish(this),this.emit("end",this.found)}};_.prototype._realpath=function(){if(this._didRealpath)return;this._didRealpath=!0;var e=this.matches.length;if(e===0)return this._finish();for(var t=this,r=0;r<this.matches.length;r++)this._realpathSet(r,s);function s(){--e===0&&t._finish()}};_.prototype._realpathSet=function(e,t){var r=this.matches[e];if(!r)return t();var s=Object.keys(r),n=this,a=s.length;if(a===0)return t();var i=this.matches[e]=Object.create(null);s.forEach(function(c,o){c=n._makeAbs(c),us.realpath(c,n.realpathCache,function(u,l){u?u.syscall==="stat"?i[c]=!0:n.emit("error",u):i[l]=!0,--a===0&&(n.matches[e]=i,t())})})};_.prototype._mark=function(e){return z.mark(this,e)};_.prototype._makeAbs=function(e){return z.makeAbs(this,e)};_.prototype.abort=function(){this.aborted=!0,this.emit("abort")};_.prototype.pause=function(){this.paused||(this.paused=!0,this.emit("pause"))};_.prototype.resume=function(){if(this.paused){if(this.emit("resume"),this.paused=!1,this._emitQueue.length){var e=this._emitQueue.slice(0);this._emitQueue.length=0;for(var t=0;t<e.length;t++){var r=e[t];this._emitMatch(r[0],r[1])}}if(this._processQueue.length){var s=this._processQueue.slice(0);this._processQueue.length=0;for(var t=0;t<s.length;t++){var n=s[t];this._processing--,this._process(n[0],n[1],n[2],n[3])}}}};_.prototype._process=function(e,t,r,s){if(Xe(this instanceof _),Xe(typeof s=="function"),!this.aborted){if(this._processing++,this.paused){this._processQueue.push([e,t,r,s]);return}for(var n=0;typeof e[n]=="string";)n++;var a;switch(n){case e.length:this._processSimple(e.join("/"),t,s);return;case 0:a=null;break;default:a=e.slice(0,n).join("/");break}var i=e.slice(n),c;a===null?c=".":((ne(a)||ne(e.map(function(l){return typeof l=="string"?l:"[*]"}).join("/")))&&(!a||!ne(a))&&(a="/"+a),c=a);var o=this._makeAbs(c);if(ds(this,c))return s();var u=i[0]===Ht.GLOBSTAR;u?this._processGlobStar(a,c,o,i,t,r,s):this._processReaddir(a,c,o,i,t,r,s)}};_.prototype._processReaddir=function(e,t,r,s,n,a,i){var c=this;this._readdir(r,a,function(o,u){return c._processReaddir2(e,t,r,s,n,a,u,i)})};_.prototype._processReaddir2=function(e,t,r,s,n,a,i,c){if(!i)return c();for(var o=s[0],u=!!this.minimatch.negate,l=o._glob,p=this.dot||l.charAt(0)===".",h=[],f=0;f<i.length;f++){var d=i[f];if(d.charAt(0)!=="."||p){var g;u&&!e?g=!d.match(o):g=d.match(o),g&&h.push(d)}}var v=h.length;if(v===0)return c();if(s.length===1&&!this.mark&&!this.stat){this.matches[n]||(this.matches[n]=Object.create(null));for(var f=0;f<v;f++){var d=h[f];e&&(e!=="/"?d=e+"/"+d:d=e+d),d.charAt(0)==="/"&&!this.nomount&&(d=Be.join(this.root,d)),this._emitMatch(n,d)}return c()}s.shift();for(var f=0;f<v;f++){var d=h[f],y;e&&(e!=="/"?d=e+"/"+d:d=e+d),this._process([d].concat(s),n,a,c)}c()};_.prototype._emitMatch=function(e,t){if(!this.aborted&&!ps(this,t)){if(this.paused){this._emitQueue.push([e,t]);return}var r=ne(t)?t:this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=r),!this.matches[e][t]){if(this.nodir){var s=this.cache[r];if(s==="DIR"||Array.isArray(s))return}this.matches[e][t]=!0;var n=this.statCache[r];n&&this.emit("stat",t,n),this.emit("match",t)}}};_.prototype._readdirInGlobStar=function(e,t){if(this.aborted)return;if(this.follow)return this._readdir(e,!1,t);var r="lstat\0"+e,s=this,n=Qe(r,a);n&&s.fs.lstat(e,n);function a(i,c){if(i&&i.code==="ENOENT")return t();var o=c&&c.isSymbolicLink();s.symlinks[e]=o,!o&&c&&!c.isDirectory()?(s.cache[e]="FILE",t()):s._readdir(e,!1,t)}};_.prototype._readdir=function(e,t,r){if(!this.aborted&&(r=Qe("readdir\0"+e+"\0"+t,r),!!r)){if(t&&!He(this.symlinks,e))return this._readdirInGlobStar(e,r);if(He(this.cache,e)){var s=this.cache[e];if(!s||s==="FILE")return r();if(Array.isArray(s))return r(null,s)}var n=this;n.fs.readdir(e,ys(this,e,r))}};function ys(e,t,r){return function(s,n){s?e._readdirError(t,s,r):e._readdirEntries(t,n,r)}}_.prototype._readdirEntries=function(e,t,r){if(!this.aborted){if(!this.mark&&!this.stat)for(var s=0;s<t.length;s++){var n=t[s];e==="/"?n=e+n:n=e+"/"+n,this.cache[n]=!0}return this.cache[e]=t,r(null,t)}};_.prototype._readdirError=function(e,t,r){if(!this.aborted){switch(t.code){case"ENOTSUP":case"ENOTDIR":var s=this._makeAbs(e);if(this.cache[s]="FILE",s===this.cwdAbs){var n=new Error(t.code+" invalid cwd "+this.cwd);n.path=this.cwd,n.code=t.code,this.emit("error",n),this.abort()}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(e)]=!1;break;default:this.cache[this._makeAbs(e)]=!1,this.strict&&(this.emit("error",t),this.abort()),this.silent||console.error("glob error",t);break}return r()}};_.prototype._processGlobStar=function(e,t,r,s,n,a,i){var c=this;this._readdir(r,a,function(o,u){c._processGlobStar2(e,t,r,s,n,a,u,i)})};_.prototype._processGlobStar2=function(e,t,r,s,n,a,i,c){if(!i)return c();var o=s.slice(1),u=e?[e]:[],l=u.concat(o);this._process(l,n,!1,c);var p=this.symlinks[r],h=i.length;if(p&&a)return c();for(var f=0;f<h;f++){var d=i[f];if(!(d.charAt(0)==="."&&!this.dot)){var g=u.concat(i[f],o);this._process(g,n,!0,c);var v=u.concat(i[f],s);this._process(v,n,!0,c)}}c()};_.prototype._processSimple=function(e,t,r){var s=this;this._stat(e,function(n,a){s._processSimple2(e,t,n,a,r)})};_.prototype._processSimple2=function(e,t,r,s,n){if(this.matches[t]||(this.matches[t]=Object.create(null)),!s)return n();if(e&&ne(e)&&!this.nomount){var a=/[\/\\]$/.test(e);e.charAt(0)==="/"?e=Be.join(this.root,e):(e=Be.resolve(this.root,e),a&&(e+="/"))}process.platform==="win32"&&(e=e.replace(/\\/g,"/")),this._emitMatch(t,e),n()};_.prototype._stat=function(e,t){var r=this._makeAbs(e),s=e.slice(-1)==="/";if(e.length>this.maxLength)return t();if(!this.stat&&He(this.cache,r)){var n=this.cache[r];if(Array.isArray(n)&&(n="DIR"),!s||n==="DIR")return t(null,n);if(s&&n==="FILE")return t()}var a,i=this.statCache[r];if(i!==void 0){if(i===!1)return t(null,i);var c=i.isDirectory()?"DIR":"FILE";return s&&c==="FILE"?t():t(null,c,i)}var o=this,u=Qe("stat\0"+r,l);u&&o.fs.lstat(r,u);function l(p,h){if(h&&h.isSymbolicLink())return o.fs.stat(r,function(f,d){f?o._stat2(e,r,null,h,t):o._stat2(e,r,f,d,t)});o._stat2(e,r,p,h,t)}};_.prototype._stat2=function(e,t,r,s,n){if(r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))return this.statCache[t]=!1,n();var a=e.slice(-1)==="/";if(this.statCache[t]=s,t.slice(-1)==="/"&&s&&!s.isDirectory())return n(null,!1,s);var i=!0;return s&&(i=s.isDirectory()?"DIR":"FILE"),this.cache[t]=this.cache[t]||i,a&&i==="FILE"?n():n(null,i,s)}});var ze=S((hn,tr)=>{var Ue=k("path"),C=k("fs"),Ze=Te(),Qt=k("js-yaml"),me=k("xlsx"),{readXlsx:Ut,writeXlsx:Zt}=ue(),ws=k("json2xml"),ye=(e,t)=>{let r=Ue.dirname(t);C.existsSync(r)||C.mkdirSync(r,{recursive:!0}),C.writeFileSync(t,e,{encoding:"utf8"})},bs=e=>Ze.sync(Ue.join(e)),_s=e=>Ze.sync(Ue.join(e)).find(t=>t!==void 0),ks=e=>{let t=Ze.sync(e,{cwd:".",nocase:!0,nodir:!1});return t&&t.length>0},zt=e=>C.existsSync(e)?JSON.parse(C.readFileSync(e,"utf8")):null,Kt=e=>C.existsSync(e)?Qt.load(C.readFileSync(e,"utf8")):null,Yt=e=>{let{file:t,data:r}=e;if(Array.isArray(r)){let s=C.createWriteStream(t);s.write("[","utf-8"),r.map((n,a)=>s.write(JSON.stringify(n)+(a===r.length-1?"":","),"utf-8")),s.write("]","utf-8"),s.end(),s.on("finish",()=>{}),s.on("error",n=>{console.error(n)})}else C.writeFileSync(t,JSON.stringify(r,null,2),{encoding:"utf8"})},Vt=e=>{let{file:t,data:r}=e,s=Qt.dump(r);C.writeFileSync(t,s,"utf8")},Ss=e=>{let{file:t}=e;if(!C.existsSync(t))return null;if(t.endsWith(".json"))return zt(t);if(t.endsWith(".yaml")||t.endsWith(".yml"))return Kt(t);if(t.endsWith(".xlsx"))return Ut(e)},Os=e=>!![".json",".yaml",".xlsx",".yml"].find(r=>e.endsWith(r)),er=(e,t,r)=>{if(e.endsWith(".json"))return Yt({file:e,data:t});if(e.endsWith(".yaml")||e.endsWith(".yml"))return Vt({file:e,data:t});if(e.endsWith(".xlsx"))return Zt({file:e,data:t,sheet:r&&r.sheet?r.sheet:"Sheet1"});if(e.endsWith(".csv")){let s=me.utils.json_to_sheet(t),n=me.utils.sheet_to_csv(s);return ye(n,e)}if(e.endsWith(".tsv")){let s=me.utils.json_to_sheet(t),n=me.utils.sheet_to_csv(s,{FS:" "});return ye(n,e)}if(e.endsWith(".xml")){let s=ws(t,{header:!0});return ye(s,e)}console.error("not support type")},Es=e=>{let{files:t,data:r,sheet:s}=e;t&&t.length>0&&t.map(n=>{er(n,r,{sheet:s})})};tr.exports={save:ye,find:bs,findOne:_s,isExsit:ks,readJson:zt,writeJson:Yt,readYaml:Kt,writeYaml:Vt,readXlsx:Ut,writeXlsx:Zt,readFile:Ss,canReadFile:Os,writeFile:er,writeFiles:Es}});var sr=S((fn,rr)=>{var{readXlsx:As}=ue(),{writeFile:xs}=ze(),js={command:"read",describe:"load excel file",builder:{file:{alias:"f",describe:"load xlsx file ",demandOption:!0,type:"string"},sheet:{alias:"s",describe:"xlsx sheet name",demandOption:!1,type:"string"},range:{alias:"r",describe:"range of excel",default:"A1:Z2000",demandOption:!1,type:"string"},defval:{describe:"defval of cell",demandOption:!1,default:void 0,type:"string"},output:{alias:"o",describe:"output file: json, yaml, csv, tsv, xlsx",demandOption:!1,default:void 0,type:"string"}},handler(e){(async()=>{let t=As(e);e.output?xs(e.output,t):console.log(JSON.stringify(t,null,2))})()}};rr.exports=js});var ar=S((dn,ir)=>{var Rs=k("fs"),nr=k("exceljs"),Is=async e=>{let{file:t,sheet:r,range:s,defval:n,noNullRow:a}=e;if(!Rs.existsSync(t)){console.log("file not found, ",t);return}if(![".xlsx",".xlsm"].find(f=>t.endsWith(f))){console.log("file type error, ",t);return}let i=new nr.Workbook;await i.xlsx.readFile(t);let c=r?i.getWorksheet(r):i.worksheets[0];if(!c)return null;let{startRow:o,endRow:u,startCol:l,endCol:p}=ie(s||"A1:Z2000"),h=[];return c.eachRow({includeEmpty:!1},(f,d)=>{if(d>=o&&d<=u){let g={};f.eachCell({includeEmpty:!0},(v,y)=>{if(y>=l&&y<=p){let w=c.getRow(o).getCell(y).value||`__EMPTY_${y-1}`;g[w]=v.value!==null?v.value:n}}),(!a||Object.values(g).some(v=>v!==null))&&h.push(g)}}),h},qs=async e=>{let{file:t,data:r,sheet:s}=e;if(!(t&&r&&Array.isArray(r)&&r.length>0))return;let n=new nr.Workbook,a=n.addWorksheet(s?s.substring(0,31):"Sheet1");if(Array.isArray(r[0]))a.addRows(r);else{let i=Object.keys(r[0]);a.addRow(i),r.forEach(c=>{a.addRow(i.map(o=>c[o]))})}await n.xlsx.writeFile(t)},ie=e=>{let[t,r]=e.split(":"),s=t.replace(/\D/g,""),n=r.replace(/\D/g,""),a=t.replace(/\d/g,""),i=r.replace(/\d/g,"");return{startRow:parseInt(s),endRow:parseInt(n),startCol:a,endCol:i,firstRow:`${t}:${i}${t.replace(/\D/g,"")}`,firstCol:`${t}:${a}${r.replace(/\D/g,"")}`}},Cs=async(e,t)=>{let{startRow:r,endRow:s,startCol:n,endCol:a}=ie(t),i=[];for(let c=r;c<=s;c++){let o=[];for(let u=n;u<=a;u++){let l=e.getCell(c,u);o.push(l.value)}i.push(o)}return i},Ns=async(e,t)=>{let{startRow:r,startCol:s,endCol:n}=ie(t),a=[];for(let i=s;i<=n;i++){let c=e.getCell(r,i);a.push(c.value)}return a},Ds=async(e,t)=>{let{startRow:r,endRow:s,startCol:n}=ie(t),a=[];for(let i=r;i<=s;i++){let c=e.getCell(i,n);a.push(c.value)}return a};ir.exports={readXlsx:Is,writeXlsx:qs,getSheetData:Cs,parseRange:ie,getFirstRow:Ns,getFirstCol:Ds}});var ur=S((pn,cr)=>{var or=k("fs"),Fs=async e=>{let{readXlsx:t,parseRange:r}=ue(),s=k("xlsx"),n=(...m)=>{e.debug&&console.log(...m)},a=m=>{let[b,O,N]=m.split("|");return{file:b,sheet:O,range:N||"A1:Z2000",defval:null,noNullRow:!0,debug:e.debug}},i=m=>{let b=Object.values(m);return b&&b.length>0?b[0]:""},[c,...o]=e.files,u=a(c),l=s.readFile(u.file,{bookSheets:!1}),p=l.Sheets[u.sheet||l.SheetNames[0]],h=r(u.range),f=s.utils.sheet_to_json(p,{header:1,range:h.firstRow,blankrows:!0,defval:null})[0],d=s.utils.sheet_to_json(p,{header:1,range:h.firstCol,blankrows:!0,defval:null}).map(m=>m[0]);n(r(u.range)),n("Header",f),n("RowIds",d);let g=o.map(a);g.forEach((m,b)=>{let O=t(m),N=O.map(i);console.log(`================${m.sheet}=================`),N.forEach((j,R)=>{let E=d.findIndex(I=>j&&j===I);if(n(m.sheet,j,E>-1?"OK":"NG",`SheetProcess:${b+1}/${g.length}`),E>-1){let I=O[R],$=Object.keys(I).slice(1);$.forEach((D,M)=>{let J=f.findIndex(oe=>oe&&D===oe),F=E,T=J,ae=s.utils.encode_cell({r:F,c:T});p[ae]={t:"s",v:I[D]},e.debug&&console.log(m.sheet,j,`RowProcess:${(M+1)/$.length*100}%`,[ae,F,T,I[D]])})}})}),console.log("Merge completed successfully.");let v=e.output,y=or.existsSync(v)?s.readFile(v,{cellDates:!0}):s.utils.book_new(),w=(e.sheet||"MergedSheet").substring(0,31);s.utils.book_append_sheet(y,p,w,!0),s.writeFile(y,v,{compression:!0})},Ms=async e=>{let{readXlsx:t,parseRange:r}=ar(),s=k("exceljs"),n=(...w)=>{e.debug&&console.log(...w)},a=w=>{let[m,b,O]=w.split("|");return{file:m,sheet:b,range:O||"A1:Z2000",defval:null,noNullRow:!0,debug:e.debug}},i=w=>{let m=Object.values(w);return m&&m.length>0?m[0]:""},[c,...o]=e.files,u=a(c),l=new s.Workbook;await l.xlsx.readFile(u.file);let p=l.getWorksheet(u.sheet||l.worksheets[0].name),h=r(u.range),f=p.getRow(h.startRow).values.slice(h.startCol,h.endCol+1),d=p.getColumn(h.startCol).values.slice(h.startRow,h.endRow+1);n(r(u.range)),n("Header",f),n("RowIds",d);let g=o.map(a);for(let[w,m]of g.entries()){let b=await t(m),O=b.map(i);console.log(`================${m.sheet}=================`);for(let[N,j]of O.entries()){let R=d.findIndex(E=>j&&j===E);if(n(m.sheet,j,R>-1?"OK":"NG",`SheetProcess:${w+1}/${g.length}`),R>-1){let E=b[N],I=Object.keys(E).slice(1);for(let[$,D]of I.entries()){let M=f.findIndex(T=>T&&D===T),J=R+h.startRow,F=M+h.startCol;p.getCell(J,F).value=E[D],e.debug&&console.log(m.sheet,j,`RowProcess:${($+1)/I.length*100}%`,[p.getCell(J,F).address,J,F,E[D]])}}}}console.log("Merge completed successfully.");let v=e.output,y=(e.sheet||"MergedSheet").substring(0,31);if(or.existsSync(v)){let w=new s.Workbook;await w.xlsx.readFile(v);let m=w.getWorksheet(y);m&&w.removeWorksheet(m.id),w.addWorksheet(y,p),await w.xlsx.writeFile(v)}else p.name=y,await l.xlsx.writeFile(v)},Ls={command:"merge <files..>",describe:"merge multiple excel sheets into the first sheet. (format: file|sheet|range, file|Sheet1|A1:Z2000)",builder:{output:{alias:"o",describe:"output file name",default:"MergedBook.xlsx",type:"string"},sheet:{alias:"s",describe:"xlsx sheet name",demandOption:!1,type:"string"},engine:{alias:"e",describe:"excel engine, sheetjs|exceljs",default:"sheetjs",demandOption:!1,type:"string"},debug:{alias:"d",describe:"print debug log",demandOption:!1,type:"boolean"}},handler(e){e.engine==="exceljs"?Ms(e):Fs(e)}};cr.exports=Ls});var hr=S((vn,lr)=>{var{writeFiles:$s}=ze(),{getStdin:Ts}=k("ts-stdin"),Ws={command:"json2",describe:"convert json to yaml, csv, tsv, xlsx",builder:{data:{alias:"d",describe:"json data",demandOption:!1,default:void 0,type:"string"},output:{alias:"o",describe:"output the request data, type: yaml, csv, tsv, xlsx",demandOption:!0,type:"array"}},handler(e){(async()=>{let t=e.data?JSON.parse(e.data):JSON.parse(await Ts());e.output&&$s({files:e.output,data:t})})()}};lr.exports=Ws});var dr=S((gn,fr)=>{fr.exports=()=>{let e=k("yargs").scriptName("xl1");e.command(sr()),e.command(ur()),e.command(hr());let t=e.parse();(!t._||t._.length===0)&&e.showHelp()}});dr()();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xl1",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "just some xlsx script.",
5
5
  "bin": {
6
6
  "xl1": "bin/cli.js"
@@ -16,6 +16,10 @@
16
16
  "keywords": [],
17
17
  "author": "exia.huang",
18
18
  "dependencies": {
19
+ "exceljs": "^4.4.0",
20
+ "js-yaml": "^4.1.0",
21
+ "json2xml": "^0.1.3",
22
+ "ts-stdin": "^1.0.1",
19
23
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
20
24
  "yargs": "^17.7.2"
21
25
  }