Merge pull request #129 from crazy-max/fxi-err-message

throw error message instead of exit code
This commit is contained in:
Tõnis Tiigi authored and GitHub committed 2024-04-15 16:54:03 -07:00
commit b7249025a9
3 files changed
+24 -6

No files matched your search

Generated Vendored
+1 -1
View File
@@ -22,5 +22,5 @@ e.exports=r(3765)},3583:(e,t,r)=>{"use strict";
*/
const i=r(7147);const s=r(2037);const a=r(1017);const n=r(6113);const o={fs:i.constants,os:s.constants};const c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",p=/XXXXXX/,l=3,A=(o.O_CREAT||o.fs.O_CREAT)|(o.O_EXCL||o.fs.O_EXCL)|(o.O_RDWR||o.fs.O_RDWR),d=s.platform()==="win32",u=o.EBADF||o.os.errno.EBADF,m=o.ENOENT||o.os.errno.ENOENT,g=448,h=384,E="exit",C=[],y=i.rmdirSync.bind(i);let I=false;function rimraf(e,t){return i.rm(e,{recursive:true},t)}function FN_RIMRAF_SYNC(e){return i.rmSync(e,{recursive:true})}function tmpName(e,t){const r=_parseArguments(e,t),s=r[0],a=r[1];try{_assertAndSanitizeOptions(s)}catch(e){return a(e)}let n=s.tries;(function _getUniqueName(){try{const e=_generateTmpName(s);i.stat(e,(function(t){if(!t){if(n-- >0)return _getUniqueName();return a(new Error("Could not get a unique tmp filename, max tries reached "+e))}a(null,e)}))}catch(e){a(e)}})()}function tmpNameSync(e){const t=_parseArguments(e),r=t[0];_assertAndSanitizeOptions(r);let s=r.tries;do{const e=_generateTmpName(r);try{i.statSync(e)}catch(t){return e}}while(s-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function file(e,t){const r=_parseArguments(e,t),s=r[0],a=r[1];tmpName(s,(function _tmpNameCreated(e,t){if(e)return a(e);i.open(t,A,s.mode||h,(function _fileCreated(e,r){if(e)return a(e);if(s.discardDescriptor){return i.close(r,(function _discardCallback(e){return a(e,t,undefined,_prepareTmpFileRemoveCallback(t,-1,s,false))}))}else{const e=s.discardDescriptor||s.detachDescriptor;a(null,t,r,_prepareTmpFileRemoveCallback(t,e?-1:r,s,false))}}))}))}function fileSync(e){const t=_parseArguments(e),r=t[0];const s=r.discardDescriptor||r.detachDescriptor;const a=tmpNameSync(r);var n=i.openSync(a,A,r.mode||h);if(r.discardDescriptor){i.closeSync(n);n=undefined}return{name:a,fd:n,removeCallback:_prepareTmpFileRemoveCallback(a,s?-1:n,r,true)}}function dir(e,t){const r=_parseArguments(e,t),s=r[0],a=r[1];tmpName(s,(function _tmpNameCreated(e,t){if(e)return a(e);i.mkdir(t,s.mode||g,(function _dirCreated(e){if(e)return a(e);a(null,t,_prepareTmpDirRemoveCallback(t,s,false))}))}))}function dirSync(e){const t=_parseArguments(e),r=t[0];const s=tmpNameSync(r);i.mkdirSync(s,r.mode||g);return{name:s,removeCallback:_prepareTmpDirRemoveCallback(s,r,true)}}function _removeFileAsync(e,t){const _handler=function(e){if(e&&!_isENOENT(e)){return t(e)}t()};if(0<=e[0])i.close(e[0],(function(){i.unlink(e[1],_handler)}));else i.unlink(e[1],_handler)}function _removeFileSync(e){let t=null;try{if(0<=e[0])i.closeSync(e[0])}catch(e){if(!_isEBADF(e)&&!_isENOENT(e))throw e}finally{try{i.unlinkSync(e[1])}catch(e){if(!_isENOENT(e))t=e}}if(t!==null){throw t}}function _prepareTmpFileRemoveCallback(e,t,r,i){const s=_prepareRemoveCallback(_removeFileSync,[t,e],i);const a=_prepareRemoveCallback(_removeFileAsync,[t,e],i,s);if(!r.keep)C.unshift(s);return i?s:a}function _prepareTmpDirRemoveCallback(e,t,r){const s=t.unsafeCleanup?rimraf:i.rmdir.bind(i);const a=t.unsafeCleanup?FN_RIMRAF_SYNC:y;const n=_prepareRemoveCallback(a,e,r);const o=_prepareRemoveCallback(s,e,r,n);if(!t.keep)C.unshift(n);return r?n:o}function _prepareRemoveCallback(e,t,r,i){let s=false;return function _cleanupCallback(a){if(!s){const n=i||_cleanupCallback;const o=C.indexOf(n);if(o>=0)C.splice(o,1);s=true;if(r||e===y||e===FN_RIMRAF_SYNC){return e(t)}else{return e(t,a||function(){})}}}}function _garbageCollector(){if(!I)return;while(C.length){try{C[0]()}catch(e){}}}function _randomChars(e){let t=[],r=null;try{r=n.randomBytes(e)}catch(t){r=n.pseudoRandomBytes(e)}for(var i=0;i<e;i++){t.push(c[r[i]%c.length])}return t.join("")}function _isBlank(e){return e===null||_isUndefined(e)||!e.trim()}function _isUndefined(e){return typeof e==="undefined"}function _parseArguments(e,t){if(typeof e==="function"){return[{},e]}if(_isUndefined(e)){return[{},t]}const r={};for(const t of Object.getOwnPropertyNames(e)){r[t]=e[t]}return[r,t]}function _generateTmpName(e){const t=e.tmpdir;if(!_isUndefined(e.name))return a.join(t,e.dir,e.name);if(!_isUndefined(e.template))return a.join(t,e.dir,e.template).replace(p,_randomChars(6));const r=[e.prefix?e.prefix:"tmp","-",process.pid,"-",_randomChars(12),e.postfix?"-"+e.postfix:""].join("");return a.join(t,e.dir,r)}function _assertAndSanitizeOptions(e){e.tmpdir=_getTmpDir(e);const t=e.tmpdir;if(!_isUndefined(e.name))_assertIsRelative(e.name,"name",t);if(!_isUndefined(e.dir))_assertIsRelative(e.dir,"dir",t);if(!_isUndefined(e.template)){_assertIsRelative(e.template,"template",t);if(!e.template.match(p))throw new Error(`Invalid template, found "${e.template}".`)}if(!_isUndefined(e.tries)&&isNaN(e.tries)||e.tries<0)throw new Error(`Invalid tries, found "${e.tries}".`);e.tries=_isUndefined(e.name)?e.tries||l:1;e.keep=!!e.keep;e.detachDescriptor=!!e.detachDescriptor;e.discardDescriptor=!!e.discardDescriptor;e.unsafeCleanup=!!e.unsafeCleanup;e.dir=_isUndefined(e.dir)?"":a.relative(t,_resolvePath(e.dir,t));e.template=_isUndefined(e.template)?unLine truncated
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=e=>e.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=e=>e.replace(/\r?\n|\r/g,"\r\n");const i=[];const s=new Uint8Array([13,10]);A=0;let a=false;for(const[t,n]of e){if(typeof n==="string"){const e=N.encode(r+`; name="${escape(normalizeLinefeeds(t))}"`+`\r\n\r\n${normalizeLinefeeds(n)}\r\n`);i.push(e);A+=e.byteLength}else{const e=N.encode(`${r}; name="${escape(normalizeLinefeeds(t))}"`+(n.name?`; filename="${escape(n.name)}"`:"")+"\r\n"+`Content-Type: ${n.type||"application/octet-stream"}\r\n\r\n`);i.push(e,n,s);if(typeof n.size==="number"){A+=e.byteLength+n.size+s.byteLength}else{a=true}}}const n=N.encode(`--${t}--`);i.push(n);A+=n.byteLength;if(a){A=null}l=e;p=async function*(){for(const e of i){if(e.stream){yield*e.stream()}else{yield e}}};d="multipart/form-data; boundary="+t}else if(n(e)){l=e;A=e.size;if(e.type){d=e.type}}else if(typeof e[Symbol.asyncIterator]==="function"){if(t){throw new TypeError("keepalive")}if(s.isDisturbed(e)||e.locked){throw new TypeError("Response body object should not be disturbed or locked")}i=e instanceof S?e:a(e)}if(typeof l==="string"||s.isBuffer(l)){A=Buffer.byteLength(l)}if(p!=null){let t;i=new S({async start(){t=p(e)[Symbol.asyncIterator]()},async pull(e){const{value:r,done:s}=await t.next();if(s){queueMicrotask((()=>{e.close()}))}else{if(!I(i)){e.enqueue(new Uint8Array(r))}}return e.desiredSize>0},async cancel(e){await t.return()},type:undefined})}const u={stream:i,source:l,length:A};return[u,d]}function safelyExtractBody(e,t=false){if(!S){S=r(5356).ReadableStream}if(e instanceof S){y(!s.isDisturbed(e),"The body has already been consumed.");y(!e.locked,"The stream is locked.")}return extractBody(e,t)}function cloneBody(e){const[t,r]=e.stream.tee();const i=g(r,{transfer:[r]});const[,s]=i.tee();e.stream=t;return{stream:s,length:e.length,source:e.source}}async function*consumeBody(e){if(e){if(B(e)){yield e}else{const t=e.stream;if(s.isDisturbed(t)){throw new TypeError("The body has already been consumed.")}if(t.locked){throw new TypeError("The stream is locked.")}t[C]=true;yield*t}}}function throwIfAborted(e){if(e.aborted){throw new m("The operation was aborted.","AbortError")}}function bodyMixinMethods(e){const t={blob(){return specConsumeBody(this,(e=>{let t=bodyMimeType(this);if(t==="failure"){t=""}else if(t){t=w(t)}return new h([e],{type:t})}),e)},arrayBuffer(){return specConsumeBody(this,(e=>new Uint8Array(e).buffer),e)},text(){return specConsumeBody(this,utf8DecodeBytes,e)},json(){return specConsumeBody(this,parseJSONFromBytes,e)},async formData(){u.brandCheck(this,e);throwIfAborted(this[d]);const t=this.headers.get("Content-Type");if(/multipart\/form-data/.test(t)){const e={};for(const[t,r]of this.headers)e[t.toLowerCase()]=r;const t=new A;let r;try{r=new i({headers:e,preservePath:true})}catch(e){throw new m(`${e}`,"AbortError")}r.on("field",((e,r)=>{t.append(e,r)}));r.on("file",((e,r,i,s,a)=>{const n=[];if(s==="base64"||s.toLowerCase()==="base64"){let s="";r.on("data",(e=>{s+=e.toString().replace(/[\r\n]/gm,"");const t=s.length-s.length%4;n.push(Buffer.from(s.slice(0,t),"base64"));s=s.slice(t)}));r.on("end",(()=>{n.push(Buffer.from(s,"base64"));t.append(e,new x(n,i,{type:a}))}))}else{r.on("data",(e=>{n.push(e)}));r.on("end",(()=>{t.append(e,new x(n,i,{type:a}))}))}}));const s=new Promise(((e,t)=>{r.on("finish",e);r.on("error",(e=>t(new TypeError(e))))}));if(this.body!==null)for await(const e of consumeBody(this[d].body))r.write(e);r.end();await s;return t}else if(/application\/x-www-form-urlencoded/.test(t)){let e;try{let t="";const r=new TextDecoder("utf-8",{ignoreBOM:true});for await(const e of consumeBody(this[d].body)){if(!B(e)){throw new TypeError("Expected Uint8Array chunk")}t+=r.decode(e,{stream:true})}t+=r.decode();e=new URLSearchParams(t)}catch(e){throw Object.assign(new TypeError,{cause:e})}const t=new A;for(const[r,i]of e){t.append(r,i)}return t}else{await Promise.resolve();throwIfAborted(this[d]);throw u.errors.exception({header:`${e.name}.formData`,message:"Could not parse content as FormData."})}}};return t}function mixinBody(e){Object.assign(e.prototype,bodyMixinMethods(e))}async function specConsumeBody(e,t,r){u.brandCheck(e,r);throwIfAborted(e[d]);if(bodyUnusable(e[d].body)){throw new TypeError("Body is unusable")}const i=p();const errorSteps=e=>i.reject(e);const successSteps=e=>{try{i.resolve(t(e))}catch(e){errorSteps(e)}};if(e[d].body==null){successSteps(new Uint8Array);return i.promise}await l(e[d].body,successSteps,errorSteps);return i.promise}function bodyUnusable(e){return e!=null&&(e.stream.locked||s.isDisturbed(e.stream))}function utf8DecodeBytes(e){if(e.length===0){return""}if(e[0]===239&&e[1]===187&&e[2]===191){e=e.subarray(3)}const t=R.decode(e);return t}function parseJSONFromBytes(e){return JSON.parse(utf8DecodeBytes(e))}function bodyMimeType(e){const{headersList:t}=e[d];const r=t.get("content-Line truncated
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */a[s-4]=this.maskKey[0];a[s-3]=this.maskKey[1];a[s-2]=this.maskKey[2];a[s-1]=this.maskKey[3];a[1]=r;if(r===126){a.writeUInt16BE(t,2)}else if(r===127){a[2]=a[3]=0;a.writeUIntBE(t,4,6)}a[1]|=128;for(let e=0;e<t;e++){a[s+e]=this.frameData[e]^this.maskKey[e%4]}return a}}e.exports={WebsocketFrameSend:WebsocketFrameSend}},1688:(e,t,r)=>{"use strict";const{Writable:i}=r(2781);const s=r(7643);const{parserStates:a,opcodes:n,states:o,emptyBuffer:c}=r(9188);const{kReadyState:p,kSentClose:l,kResponse:A,kReceivedClose:d}=r(7578);const{isValidStatusCode:u,failWebsocketConnection:m,websocketMessageReceived:g}=r(5515);const{WebsocketFrameSend:h}=r(5444);const E={};E.ping=s.channel("undici:websocket:ping");E.pong=s.channel("undici:websocket:pong");class ByteParser extends i{#n=[];#o=0;#c=a.INFO;#p={};#l=[];constructor(e){super();this.ws=e}_write(e,t,r){this.#n.push(e);this.#o+=e.length;this.run(r)}run(e){while(true){if(this.#c===a.INFO){if(this.#o<2){return e()}const t=this.consume(2);this.#p.fin=(t[0]&128)!==0;this.#p.opcode=t[0]&15;this.#p.originalOpcode??=this.#p.opcode;this.#p.fragmented=!this.#p.fin&&this.#p.opcode!==n.CONTINUATION;if(this.#p.fragmented&&this.#p.opcode!==n.BINARY&&this.#p.opcode!==n.TEXT){m(this.ws,"Invalid frame type was fragmented.");return}const r=t[1]&127;if(r<=125){this.#p.payloadLength=r;this.#c=a.READ_DATA}else if(r===126){this.#c=a.PAYLOADLENGTH_16}else if(r===127){this.#c=a.PAYLOADLENGTH_64}if(this.#p.fragmented&&r>125){m(this.ws,"Fragmented frame exceeded 125 bytes.");return}else if((this.#p.opcode===n.PING||this.#p.opcode===n.PONG||this.#p.opcode===n.CLOSE)&&r>125){m(this.ws,"Payload length for control frame exceeded 125 bytes.");return}else if(this.#p.opcode===n.CLOSE){if(r===1){m(this.ws,"Received close frame with a 1-byte body.");return}const e=this.consume(r);this.#p.closeInfo=this.parseCloseBody(false,e);if(!this.ws[l]){const e=Buffer.allocUnsafe(2);e.writeUInt16BE(this.#p.closeInfo.code,0);const t=new h(e);this.ws[A].socket.write(t.createFrame(n.CLOSE),(e=>{if(!e){this.ws[l]=true}}))}this.ws[p]=o.CLOSING;this.ws[d]=true;this.end();return}else if(this.#p.opcode===n.PING){const t=this.consume(r);if(!this.ws[d]){const e=new h(t);this.ws[A].socket.write(e.createFrame(n.PONG));if(E.ping.hasSubscribers){E.ping.publish({payload:t})}}this.#c=a.INFO;if(this.#o>0){continue}else{e();return}}else if(this.#p.opcode===n.PONG){const t=this.consume(r);if(E.pong.hasSubscribers){E.pong.publish({payload:t})}if(this.#o>0){continue}else{e();return}}}else if(this.#c===a.PAYLOADLENGTH_16){if(this.#o<2){return e()}const t=this.consume(2);this.#p.payloadLength=t.readUInt16BE(0);this.#c=a.READ_DATA}else if(this.#c===a.PAYLOADLENGTH_64){if(this.#o<8){return e()}const t=this.consume(8);const r=t.readUInt32BE(0);if(r>2**31-1){m(this.ws,"Received payload length > 2^31 bytes.");return}const i=t.readUInt32BE(4);this.#p.payloadLength=(r<<8)+i;this.#c=a.READ_DATA}else if(this.#c===a.READ_DATA){if(this.#o<this.#p.payloadLength){return e()}else if(this.#o>=this.#p.payloadLength){const e=this.consume(this.#p.payloadLength);this.#l.push(e);if(!this.#p.fragmented||this.#p.fin&&this.#p.opcode===n.CONTINUATION){const e=Buffer.concat(this.#l);g(this.ws,this.#p.originalOpcode,e);this.#p={};this.#l.length=0}this.#c=a.INFO}}if(this.#o>0){continue}else{e();break}}}consume(e){if(e>this.#o){return null}else if(e===0){return c}if(this.#n[0].length===e){this.#o-=this.#n[0].length;return this.#n.shift()}const t=Buffer.allocUnsafe(e);let r=0;while(r!==e){const i=this.#n[0];const{length:s}=i;if(s+r===e){t.set(this.#n.shift(),r);break}else if(s+r>e){t.set(i.subarray(0,e-r),r);this.#n[0]=i.subarray(e-r);break}else{t.set(this.#n.shift(),r);r+=i.length}}this.#o-=e;return t}parseCloseBody(e,t){let r;if(t.length>=2){r=t.readUInt16BE(0)}if(e){if(!u(r)){return null}return{code:r}}let i=t.subarray(2);if(i[0]===239&&i[1]===187&&i[2]===191){i=i.subarray(3)}if(r!==undefined&&!u(r)){return null}try{i=new TextDecoder("utf-8",{fatal:true}).decode(i)}catch{return null}return{code:r,reason:i}}get closingInfo(){return this.#p.closeInfo}}e.exports={ByteParser:ByteParser}},7578:e=>{"use strict";e.exports={kWebSocketURL:Symbol("url"),kReadyState:Symbol("ready state"),kController:Symbol("controller"),kResponse:Symbol("response"),kBinaryType:Symbol("binary type"),kSentClose:Symbol("sent close"),kReceivedClose:Symbol("received close"),kByteParser:Symbol("byte parser")}},5515:(e,t,r)=>{"use strict";const{kReadyState:i,kController:s,kResponse:a,kBinaryType:n,kWebSocketURL:o}=r(7578);const{states:c,opcodes:p}=r(9188);const{MessageEvent:l,ErrorEvent:A}=r(2611);function isEstablished(e){return e[i]===c.OPEN}function isClosing(e){return e[i]===c.CLOSING}function isClosed(e){return e[i]===c.CLOSED}function fireEvent(e,t,r=Event,i){const s=new r(e,i);t.dispatchEvent(s)}function websocketMessageReceived(e,t,r){if(e[i]!==c.OPEN){return}let s;if(t===p.TEXT){try{s=new TextDecoder("utf-8",{fatal:true}).decode(r)Line truncated
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */a[s-4]=this.maskKey[0];a[s-3]=this.maskKey[1];a[s-2]=this.maskKey[2];a[s-1]=this.maskKey[3];a[1]=r;if(r===126){a.writeUInt16BE(t,2)}else if(r===127){a[2]=a[3]=0;a.writeUIntBE(t,4,6)}a[1]|=128;for(let e=0;e<t;e++){a[s+e]=this.frameData[e]^this.maskKey[e%4]}return a}}e.exports={WebsocketFrameSend:WebsocketFrameSend}},1688:(e,t,r)=>{"use strict";const{Writable:i}=r(2781);const s=r(7643);const{parserStates:a,opcodes:n,states:o,emptyBuffer:c}=r(9188);const{kReadyState:p,kSentClose:l,kResponse:A,kReceivedClose:d}=r(7578);const{isValidStatusCode:u,failWebsocketConnection:m,websocketMessageReceived:g}=r(5515);const{WebsocketFrameSend:h}=r(5444);const E={};E.ping=s.channel("undici:websocket:ping");E.pong=s.channel("undici:websocket:pong");class ByteParser extends i{#n=[];#o=0;#c=a.INFO;#p={};#l=[];constructor(e){super();this.ws=e}_write(e,t,r){this.#n.push(e);this.#o+=e.length;this.run(r)}run(e){while(true){if(this.#c===a.INFO){if(this.#o<2){return e()}const t=this.consume(2);this.#p.fin=(t[0]&128)!==0;this.#p.opcode=t[0]&15;this.#p.originalOpcode??=this.#p.opcode;this.#p.fragmented=!this.#p.fin&&this.#p.opcode!==n.CONTINUATION;if(this.#p.fragmented&&this.#p.opcode!==n.BINARY&&this.#p.opcode!==n.TEXT){m(this.ws,"Invalid frame type was fragmented.");return}const r=t[1]&127;if(r<=125){this.#p.payloadLength=r;this.#c=a.READ_DATA}else if(r===126){this.#c=a.PAYLOADLENGTH_16}else if(r===127){this.#c=a.PAYLOADLENGTH_64}if(this.#p.fragmented&&r>125){m(this.ws,"Fragmented frame exceeded 125 bytes.");return}else if((this.#p.opcode===n.PING||this.#p.opcode===n.PONG||this.#p.opcode===n.CLOSE)&&r>125){m(this.ws,"Payload length for control frame exceeded 125 bytes.");return}else if(this.#p.opcode===n.CLOSE){if(r===1){m(this.ws,"Received close frame with a 1-byte body.");return}const e=this.consume(r);this.#p.closeInfo=this.parseCloseBody(false,e);if(!this.ws[l]){const e=Buffer.allocUnsafe(2);e.writeUInt16BE(this.#p.closeInfo.code,0);const t=new h(e);this.ws[A].socket.write(t.createFrame(n.CLOSE),(e=>{if(!e){this.ws[l]=true}}))}this.ws[p]=o.CLOSING;this.ws[d]=true;this.end();return}else if(this.#p.opcode===n.PING){const t=this.consume(r);if(!this.ws[d]){const e=new h(t);this.ws[A].socket.write(e.createFrame(n.PONG));if(E.ping.hasSubscribers){E.ping.publish({payload:t})}}this.#c=a.INFO;if(this.#o>0){continue}else{e();return}}else if(this.#p.opcode===n.PONG){const t=this.consume(r);if(E.pong.hasSubscribers){E.pong.publish({payload:t})}if(this.#o>0){continue}else{e();return}}}else if(this.#c===a.PAYLOADLENGTH_16){if(this.#o<2){return e()}const t=this.consume(2);this.#p.payloadLength=t.readUInt16BE(0);this.#c=a.READ_DATA}else if(this.#c===a.PAYLOADLENGTH_64){if(this.#o<8){return e()}const t=this.consume(8);const r=t.readUInt32BE(0);if(r>2**31-1){m(this.ws,"Received payload length > 2^31 bytes.");return}const i=t.readUInt32BE(4);this.#p.payloadLength=(r<<8)+i;this.#c=a.READ_DATA}else if(this.#c===a.READ_DATA){if(this.#o<this.#p.payloadLength){return e()}else if(this.#o>=this.#p.payloadLength){const e=this.consume(this.#p.payloadLength);this.#l.push(e);if(!this.#p.fragmented||this.#p.fin&&this.#p.opcode===n.CONTINUATION){const e=Buffer.concat(this.#l);g(this.ws,this.#p.originalOpcode,e);this.#p={};this.#l.length=0}this.#c=a.INFO}}if(this.#o>0){continue}else{e();break}}}consume(e){if(e>this.#o){return null}else if(e===0){return c}if(this.#n[0].length===e){this.#o-=this.#n[0].length;return this.#n.shift()}const t=Buffer.allocUnsafe(e);let r=0;while(r!==e){const i=this.#n[0];const{length:s}=i;if(s+r===e){t.set(this.#n.shift(),r);break}else if(s+r>e){t.set(i.subarray(0,e-r),r);this.#n[0]=i.subarray(e-r);break}else{t.set(this.#n.shift(),r);r+=i.length}}this.#o-=e;return t}parseCloseBody(e,t){let r;if(t.length>=2){r=t.readUInt16BE(0)}if(e){if(!u(r)){return null}return{code:r}}let i=t.subarray(2);if(i[0]===239&&i[1]===187&&i[2]===191){i=i.subarray(3)}if(r!==undefined&&!u(r)){return null}try{i=new TextDecoder("utf-8",{fatal:true}).decode(i)}catch{return null}return{code:r,reason:i}}get closingInfo(){return this.#p.closeInfo}}e.exports={ByteParser:ByteParser}},7578:e=>{"use strict";e.exports={kWebSocketURL:Symbol("url"),kReadyState:Symbol("ready state"),kController:Symbol("controller"),kResponse:Symbol("response"),kBinaryType:Symbol("binary type"),kSentClose:Symbol("sent close"),kReceivedClose:Symbol("received close"),kByteParser:Symbol("byte parser")}},5515:(e,t,r)=>{"use strict";const{kReadyState:i,kController:s,kResponse:a,kBinaryType:n,kWebSocketURL:o}=r(7578);const{states:c,opcodes:p}=r(9188);const{MessageEvent:l,ErrorEvent:A}=r(2611);function isEstablished(e){return e[i]===c.OPEN}function isClosing(e){return e[i]===c.CLOSING}function isClosed(e){return e[i]===c.CLOSED}function fireEvent(e,t,r=Event,i){const s=new r(e,i);t.dispatchEvent(s)}function websocketMessageReceived(e,t,r){if(e[i]!==c.OPEN){return}let s;if(t===p.TEXT){try{s=new TextDecoder("utf-8",{fatal:true}).decode(r)Line truncated
//# sourceMappingURL=index.js.map
Generated Vendored
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.js","names":["__createBinding","this","Object","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","get","defineProperty","__setModuleDefault","v","value","__importStar","mod","result","prototype","hasOwnProperty","call","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","e","rejected","done","then","apply","exports","saveCache","restoreCache","isFeatureAvailable","ReserveCacheError","ValidationError","core","__webpack_require__","path","utils","cacheHttpClient","tar_1","Error","constructor","message","super","name","setPrototypeOf","checkPaths","paths","length","checkKey","key","regex","test","process","env","primaryKey","restoreKeys","options","enableCrossOsArchive","keys","debug","JSON","stringify","compressionMethod","getCompressionMethod","archivePath","cacheEntry","getCacheEntry","archiveLocation","lookupOnly","info","cacheKey","join","createTempDirectory","getCacheFileName","downloadCache","isDebug","listTar","archiveFileSize","getArchiveFileSizeInBytes","Math","round","extractTar","error","typedError","warning","unlinkFile","_a","_b","_c","_d","_e","cacheId","cachePaths","resolvePaths","archiveFolder","createTar","fileSizeLimit","isGhes","reserveCacheResponse","reserveCache","cacheSize","statusCode","getCacheVersion","http_client_1","auth_1","crypto","fs","url_1","downloadUtils_1","options_1","requestUtils_1","versionSalt","getCacheApiUrl","resource","baseUrl","url","createAcceptHeader","type","apiVersion","getRequestOptions","requestOptions","headers","Accept","createHttpClient","token","bearerCredentialHandler","BearerCredentialHandler","HttpClient","components","slice","push","platform","createHash","update","digest","httpClient","version","encodeURIComponent","response","retryTypedResponse","getJson","printCachesListForDiagnostics","isSuccessStatusCode","cacheResult","cacheDownloadUrl","setSecret","cacheListResult","totalCount","artifactCaches","cacheVersion","scope","creationTime","archiveUrl","URL","downloadOptions","getDownloadOptions","hostname","endsWith","useAzureSdk","downloadCacheStorageSDK","concurrentBlobDownloads","downloadCacheHttpClientConcurrent","downloadCacheHttpClient","reserveCacheRequest","postJson","getContentRange","start","end","uploadChunk","resourceUrl","openStream","additionalHeaders","uploadChunkResponse","retryHttpClientResponse","sendStream","uploadFile","fileSize","toString","fd","openSync","uploadOptions","getUploadOptions","concurrency","assertDefined","uploadConcurrency","maxChunkSize","uploadChunkSize","parallelUploads","Array","offset","all","map","chunkSize","min","createReadStream","autoClose","on","closeSync","commitCache","filesize","commitCacheRequest","size","commitCacheResponse","__asyncValues","Symbol","asyncIterator","TypeError","i","__values","iterator","verb","n","settle","d","getGnuTarPathOnWindows","exec","glob","io","semver","util","uuid_1","constants_1","IS_WINDOWS","tempDirectory","baseLocation","dest","v4","mkdirP","filePath","statSync","patterns","e_1","workspace","cwd","globber","implicitDescendants","_f","globGenerator","_g","file","relativeFile","relative","replace","RegExp","sep","e_1_1","return","promisify","unlink","getVersion","app","additionalArgs","versionOutput","ignoreReturnCode","silent","listeners","stdout","data","stderr","err","trim","clean","CompressionMethod","Gzip","ZstdWithoutLong","CacheFilename","Zstd","existsSync","GnuTarPathOnWindows","toLowerCase","includes","which","ghUrl","trimEnd","toUpperCase","isGitHubHost","isGheHost","ManifestFilename","TarFilename","SystemTarPathOnWindows","SocketTimeout","DefaultRetryDelay","DefaultRetryAttempts","ArchiveToolType","DownloadProgress","storage_blob_1","buffer","stream","abort_controller_1","pipeResponseToStream","output","pipeline","contentLength","segmentIndex","segmentSize","segmentOffset","receivedBytes","displayedComplete","startTime","Date","now","nextSegment","setReceivedBytes","getTransferredBytes","isDone","display","transferredBytes","percentage","toFixed","elapsedTime","downloadSpeed","onProgress","progress","loadedBytes","startDisplayTimer","delayInMs","displayCallback","timeoutHandle","setTimeout","stopDisplayTimer","clearTimeout","writeStream","createWriteStream","downloadResponse","socket","destroy","contentLengthHeader","expectedLength","parseInt","actualLength","archiveDescriptor","promises","open","socketTimeout","timeoutInMs","keepAlive","res","request","lengthHeader","Number","isNaN","downloads","blockSize","count","promiseGetter","downloadSegmentRetry","reverse","actives","bytesDownloaded","progressFn","activeDownloads","nextDownload","waitAndWrite","segment","race","values","write","pop","downloadConcurrency","dispose","close","retries","failures","timeout","promiseWithTimeout","downloadSegment","partRes","Range","readBodyBuffer","client","BlockBlobClient","retryOptions","tryTimeoutInMs","properties"Line truncated
{"version":3,"file":"index.js","names":["__createBinding","this","Object","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","get","defineProperty","__setModuleDefault","v","value","__importStar","mod","result","prototype","hasOwnProperty","call","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","e","rejected","done","then","apply","exports","saveCache","restoreCache","isFeatureAvailable","ReserveCacheError","ValidationError","core","__webpack_require__","path","utils","cacheHttpClient","tar_1","Error","constructor","message","super","name","setPrototypeOf","checkPaths","paths","length","checkKey","key","regex","test","process","env","primaryKey","restoreKeys","options","enableCrossOsArchive","keys","debug","JSON","stringify","compressionMethod","getCompressionMethod","archivePath","cacheEntry","getCacheEntry","archiveLocation","lookupOnly","info","cacheKey","join","createTempDirectory","getCacheFileName","downloadCache","isDebug","listTar","archiveFileSize","getArchiveFileSizeInBytes","Math","round","extractTar","error","typedError","warning","unlinkFile","_a","_b","_c","_d","_e","cacheId","cachePaths","resolvePaths","archiveFolder","createTar","fileSizeLimit","isGhes","reserveCacheResponse","reserveCache","cacheSize","statusCode","getCacheVersion","http_client_1","auth_1","crypto","fs","url_1","downloadUtils_1","options_1","requestUtils_1","versionSalt","getCacheApiUrl","resource","baseUrl","url","createAcceptHeader","type","apiVersion","getRequestOptions","requestOptions","headers","Accept","createHttpClient","token","bearerCredentialHandler","BearerCredentialHandler","HttpClient","components","slice","push","platform","createHash","update","digest","httpClient","version","encodeURIComponent","response","retryTypedResponse","getJson","printCachesListForDiagnostics","isSuccessStatusCode","cacheResult","cacheDownloadUrl","setSecret","cacheListResult","totalCount","artifactCaches","cacheVersion","scope","creationTime","archiveUrl","URL","downloadOptions","getDownloadOptions","hostname","endsWith","useAzureSdk","downloadCacheStorageSDK","concurrentBlobDownloads","downloadCacheHttpClientConcurrent","downloadCacheHttpClient","reserveCacheRequest","postJson","getContentRange","start","end","uploadChunk","resourceUrl","openStream","additionalHeaders","uploadChunkResponse","retryHttpClientResponse","sendStream","uploadFile","fileSize","toString","fd","openSync","uploadOptions","getUploadOptions","concurrency","assertDefined","uploadConcurrency","maxChunkSize","uploadChunkSize","parallelUploads","Array","offset","all","map","chunkSize","min","createReadStream","autoClose","on","closeSync","commitCache","filesize","commitCacheRequest","size","commitCacheResponse","__asyncValues","Symbol","asyncIterator","TypeError","i","__values","iterator","verb","n","settle","d","getGnuTarPathOnWindows","exec","glob","io","semver","util","uuid_1","constants_1","IS_WINDOWS","tempDirectory","baseLocation","dest","v4","mkdirP","filePath","statSync","patterns","e_1","workspace","cwd","globber","implicitDescendants","_f","globGenerator","_g","file","relativeFile","relative","replace","RegExp","sep","e_1_1","return","promisify","unlink","getVersion","app","additionalArgs","versionOutput","ignoreReturnCode","silent","listeners","stdout","data","stderr","err","trim","clean","CompressionMethod","Gzip","ZstdWithoutLong","CacheFilename","Zstd","existsSync","GnuTarPathOnWindows","toLowerCase","includes","which","ghUrl","trimEnd","toUpperCase","isGitHubHost","isGheHost","ManifestFilename","TarFilename","SystemTarPathOnWindows","SocketTimeout","DefaultRetryDelay","DefaultRetryAttempts","ArchiveToolType","DownloadProgress","storage_blob_1","buffer","stream","abort_controller_1","pipeResponseToStream","output","pipeline","contentLength","segmentIndex","segmentSize","segmentOffset","receivedBytes","displayedComplete","startTime","Date","now","nextSegment","setReceivedBytes","getTransferredBytes","isDone","display","transferredBytes","percentage","toFixed","elapsedTime","downloadSpeed","onProgress","progress","loadedBytes","startDisplayTimer","delayInMs","displayCallback","timeoutHandle","setTimeout","stopDisplayTimer","clearTimeout","writeStream","createWriteStream","downloadResponse","socket","destroy","contentLengthHeader","expectedLength","parseInt","actualLength","archiveDescriptor","promises","open","socketTimeout","timeoutInMs","keepAlive","res","request","lengthHeader","Number","isNaN","downloads","blockSize","count","promiseGetter","downloadSegmentRetry","reverse","actives","bytesDownloaded","progressFn","activeDownloads","nextDownload","waitAndWrite","segment","race","values","write","pop","downloadConcurrency","dispose","close","retries","failures","timeout","promiseWithTimeout","downloadSegment","partRes","Range","readBodyBuffer","client","BlockBlobClient","retryOptions","tryTimeoutInMs","properties"Line truncated
+22 -4
View File
@@ -20,15 +20,33 @@ actionsToolkit.run(
});
await core.group(`Pulling binfmt Docker image`, async () => {
await Exec.exec('docker', ['pull', input.image]);
await Exec.getExecOutput('docker', ['pull', input.image], {
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
});
await core.group(`Image info`, async () => {
await Exec.exec('docker', ['image', 'inspect', input.image]);
await Exec.getExecOutput('docker', ['image', 'inspect', input.image], {
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
});
await core.group(`Installing QEMU static binaries`, async () => {
await Exec.exec('docker', ['run', '--rm', '--privileged', input.image, '--install', input.platforms]);
await Exec.getExecOutput('docker', ['run', '--rm', '--privileged', input.image, '--install', input.platforms], {
ignoreReturnCode: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
});
});
await core.group(`Extracting available platforms`, async () => {
@@ -37,7 +55,7 @@ actionsToolkit.run(
silent: true
}).then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.trim());
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
}
const platforms: Platforms = JSON.parse(res.stdout.trim());
core.info(`${platforms.supported.join(',')}`);