setup-php/dist/index.js

3 lines
510 KiB
JavaScript
Raw Permalink Normal View History

2024-11-18 21:02:14 +07:00
(()=>{var A={6472:function(A,e,t){"use strict";var r=this&&this.__createBinding||(Object.create?function(A,e,t,r){if(r===undefined)r=t;var s=Object.getOwnPropertyDescriptor(e,t);if(!s||("get"in s?!e.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return e[t]}}}Object.defineProperty(A,r,s)}:function(A,e,t,r){if(r===undefined)r=t;A[r]=e[t]});var s=this&&this.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:true,value:e})}:function(A,e){A["default"]=e});var n=this&&this.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)if(t!=="default"&&Object.prototype.hasOwnProperty.call(A,t))r(e,A,t);s(e,A);return e};Object.defineProperty(e,"__esModule",{value:true});e.addINIValuesUnix=addINIValuesUnix;e.addINIValuesWindows=addINIValuesWindows;e.addINIValues=addINIValues;const o=n(t(9277));async function addINIValuesUnix(A){const e=await o.CSVArray(A);let t="";await o.asyncForEach(e,(async function(A){t+="\n"+await o.addLog("$tick",A,"Added to php.ini","linux")}));return'echo "'+e.join("\n")+'" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1'+t}async function addINIValuesWindows(A){const e=await o.CSVArray(A);let t="\n";await o.asyncForEach(e,(async function(A){t+=await o.addLog("$tick",A,"Added to php.ini","win32")+"\n"}));return'Add-Content "$php_dir\\php.ini" "'+e.join("\n")+'"'+t}async function addINIValues(A,e,t=false){let r="\n";switch(t){case true:r+=await o.stepLog("Add php.ini values",e)+await o.suppressOutput(e)+"\n";break;case false:default:r+=await o.stepLog("Add php.ini values",e)+"\n";break}switch(e){case"win32":return r+await addINIValuesWindows(A);case"darwin":case"linux":return r+await addINIValuesUnix(A);default:return await o.log("Platform "+e+" is not supported",e,"error")}}},9524:function(A,e,t){"use strict";var r=this&&this.__createBinding||(Object.create?function(A,e,t,r){if(r===undefined)r=t;var s=Object.getOwnPropertyDescriptor(e,t);if(!s||("get"in s?!e.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return e[t]}}}Object.defineProperty(A,r,s)}:function(A,e,t,r){if(r===undefined)r=t;A[r]=e[t]});var s=this&&this.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:true,value:e})}:function(A,e){A["default"]=e});var n=this&&this.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)if(t!=="default"&&Object.prototype.hasOwnProperty.call(A,t))r(e,A,t);s(e,A);return e};Object.defineProperty(e,"__esModule",{value:true});e.checkXdebugError=checkXdebugError;e.addCoverageXdebug=addCoverageXdebug;e.addCoveragePCOV=addCoveragePCOV;e.disableCoverage=disableCoverage;e.addCoverage=addCoverage;const o=n(t(9277));const i=n(t(3252));const a=n(t(6472));async function checkXdebugError(A,e){if(/^5\.[3-6]$|^7\.[0-1]$/.test(e)&&A=="xdebug3"||/^8\.[0-9]$/.test(e)&&A=="xdebug2"){return A+" is not supported on PHP "+e}return""}async function addCoverageXdebug(A,e,t,r){let s="\n";const n=await checkXdebugError(A,e);if(!n){s+=await i.addExtension(":pcov:false",e,t,true)+r;A=A=="xdebug3"?"xdebug":A;s+=await i.addExtension(A,e,t,true)+r;s+=await o.setVariable("xdebug_version","php -r \"echo phpversion('xdebug');\"",t);s+=await o.getCommand(t,"extension_log")+'xdebug "Xdebug $xdebug_version enabled as coverage driver"'}else{s+=await o.addLog("$cross",A,n,t)}return s}async function addCoveragePCOV(A,e,t){let r="\n";switch(true){default:r+=await i.addExtension(":xdebug:false",A,e,true)+t;r+=await i.addExtension("pcov",A,e,true)+t;r+=await a.addINIValues("pcov.enabled=1",e,true)+"\n";r+=await o.setVariable("pcov_version","php -r \"echo phpversion('pcov');\"",e);r+=await o.getCommand(e,"extension_log")+'pcov "PCOV $pcov_version enabled as coverage driver"';break;case/5\.[3-6]|7\.0/.test(A):r+=await o.addLog("$cross","pcov","PHP 7.1 or newer is required",e);break}return r}async function disableCoverage(A,e,t){let r="\n";r+=await i.addExtension(":pcov:false",A,e,true)+t;r+=await i.addExtension(":xdebug:false",A,e,true)+t;r+=aw
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=A=>A.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=A=>A.replace(/\r?\n|\r/g,"\r\n");const r=[];const s=new Uint8Array([13,10]);E=0;let n=false;for(const[e,o]of A){if(typeof o==="string"){const A=b.encode(t+`; name="${escape(normalizeLinefeeds(e))}"`+`\r\n\r\n${normalizeLinefeeds(o)}\r\n`);r.push(A);E+=A.byteLength}else{const A=b.encode(`${t}; name="${escape(normalizeLinefeeds(e))}"`+(o.name?`; filename="${escape(o.name)}"`:"")+"\r\n"+`Content-Type: ${o.type||"application/octet-stream"}\r\n\r\n`);r.push(A,o,s);if(typeof o.size==="number"){E+=A.byteLength+o.size+s.byteLength}else{n=true}}}const o=b.encode(`--${e}--`);r.push(o);E+=o.byteLength;if(n){E=null}g=A;c=async function*(){for(const A of r){if(A.stream){yield*A.stream()}else{yield A}}};Q="multipart/form-data; boundary="+e}else if(o(A)){g=A;E=A.size;if(A.type){Q=A.type}}else if(typeof A[Symbol.asyncIterator]==="function"){if(e){throw new TypeError("keepalive")}if(s.isDisturbed(A)||A.locked){throw new TypeError("Response body object should not be disturbed or locked")}r=A instanceof m?A:n(A)}if(typeof g==="string"||s.isBuffer(g)){E=Buffer.byteLength(g)}if(c!=null){let e;r=new m({async start(){e=c(A)[Symbol.asyncIterator]()},async pull(A){const{value:t,done:s}=await e.next();if(s){queueMicrotask((()=>{A.close()}))}else{if(!f(r)){A.enqueue(new Uint8Array(t))}}return A.desiredSize>0},async cancel(A){await e.return()},type:undefined})}const C={stream:r,source:g,length:E};return[C,Q]}function safelyExtractBody(A,e=false){if(!m){m=t(3774).ReadableStream}if(A instanceof m){d(!s.isDisturbed(A),"The body has already been consumed.");d(!A.locked,"The stream is locked.")}return extractBody(A,e)}function cloneBody(A){const[e,t]=A.stream.tee();const r=l(t,{transfer:[t]});const[,s]=r.tee();A.stream=e;return{stream:s,length:A.length,source:A.source}}async function*consumeBody(A){if(A){if(p(A)){yield A}else{const e=A.stream;if(s.isDisturbed(e)){throw new TypeError("The body has already been consumed.")}if(e.locked){throw new TypeError("The stream is locked.")}e[u]=true;yield*e}}}function throwIfAborted(A){if(A.aborted){throw new B("The operation was aborted.","AbortError")}}function bodyMixinMethods(A){const e={blob(){return specConsumeBody(this,(A=>{let e=bodyMimeType(this);if(e==="failure"){e=""}else if(e){e=D(e)}return new I([A],{type:e})}),A)},arrayBuffer(){return specConsumeBody(this,(A=>new Uint8Array(A).buffer),A)},text(){return specConsumeBody(this,utf8DecodeBytes,A)},json(){return specConsumeBody(this,parseJSONFromBytes,A)},async formData(){C.brandCheck(this,A);throwIfAborted(this[Q]);const e=this.headers.get("Content-Type");if(/multipart\/form-data/.test(e)){const A={};for(const[e,t]of this.headers)A[e.toLowerCase()]=t;const e=new E;let t;try{t=new r({headers:A,preservePath:true})}catch(A){throw new B(`${A}`,"AbortError")}t.on("field",((A,t)=>{e.append(A,t)}));t.on("file",((A,t,r,s,n)=>{const o=[];if(s==="base64"||s.toLowerCase()==="base64"){let s="";t.on("data",(A=>{s+=A.toString().replace(/[\r\n]/gm,"");const e=s.length-s.length%4;o.push(Buffer.from(s.slice(0,e),"base64"));s=s.slice(e)}));t.on("end",(()=>{o.push(Buffer.from(s,"base64"));e.append(A,new k(o,r,{type:n}))}))}else{t.on("data",(A=>{o.push(A)}));t.on("end",(()=>{e.append(A,new k(o,r,{type:n}))}))}}));const s=new Promise(((A,e)=>{t.on("finish",A);t.on("error",(A=>e(new TypeError(A))))}));if(this.body!==null)for await(const A of consumeBody(this[Q].body))t.write(A);t.end();await s;return e}else if(/application\/x-www-form-urlencoded/.test(e)){let A;try{let e="";const t=new TextDecoder("utf-8",{ignoreBOM:true});for await(const A of consumeBody(this[Q].body)){if(!p(A)){throw new TypeError("Expected Uint8Array chunk")}e+=t.decode(A,{stream:true})}e+=t.decode();A=new URLSearchParams(e)}catch(A){throw Object.assign(new TypeError,{cause:A})}const e=new E;for(const[t,r]of A){e.append(t,r)}return e}else{await Promise.resolve();throwIfAborted(this[Q]);throw C.errors.exception({he
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */n[s-4]=this.maskKey[0];n[s-3]=this.maskKey[1];n[s-2]=this.maskKey[2];n[s-1]=this.maskKey[3];n[1]=t;if(t===126){n.writeUInt16BE(e,2)}else if(t===127){n[2]=n[3]=0;n.writeUIntBE(e,4,6)}n[1]|=128;for(let A=0;A<e;A++){n[s+A]=this.frameData[A]^this.maskKey[A%4]}return n}}A.exports={WebsocketFrameSend:WebsocketFrameSend}},3171:(A,e,t)=>{"use strict";const{Writable:r}=t(2203);const s=t(1637);const{parserStates:n,opcodes:o,states:i,emptyBuffer:a}=t(5913);const{kReadyState:c,kSentClose:g,kResponse:E,kReceivedClose:Q}=t(2933);const{isValidStatusCode:C,failWebsocketConnection:B,websocketMessageReceived:l}=t(3574);const{WebsocketFrameSend:I}=t(1237);const h={};h.ping=s.channel("undici:websocket:ping");h.pong=s.channel("undici:websocket:pong");class ByteParser extends r{#o=[];#i=0;#a=n.INFO;#c={};#g=[];constructor(A){super();this.ws=A}_write(A,e,t){this.#o.push(A);this.#i+=A.length;this.run(t)}run(A){while(true){if(this.#a===n.INFO){if(this.#i<2){return A()}const e=this.consume(2);this.#c.fin=(e[0]&128)!==0;this.#c.opcode=e[0]&15;this.#c.originalOpcode??=this.#c.opcode;this.#c.fragmented=!this.#c.fin&&this.#c.opcode!==o.CONTINUATION;if(this.#c.fragmented&&this.#c.opcode!==o.BINARY&&this.#c.opcode!==o.TEXT){B(this.ws,"Invalid frame type was fragmented.");return}const t=e[1]&127;if(t<=125){this.#c.payloadLength=t;this.#a=n.READ_DATA}else if(t===126){this.#a=n.PAYLOADLENGTH_16}else if(t===127){this.#a=n.PAYLOADLENGTH_64}if(this.#c.fragmented&&t>125){B(this.ws,"Fragmented frame exceeded 125 bytes.");return}else if((this.#c.opcode===o.PING||this.#c.opcode===o.PONG||this.#c.opcode===o.CLOSE)&&t>125){B(this.ws,"Payload length for control frame exceeded 125 bytes.");return}else if(this.#c.opcode===o.CLOSE){if(t===1){B(this.ws,"Received close frame with a 1-byte body.");return}const A=this.consume(t);this.#c.closeInfo=this.parseCloseBody(false,A);if(!this.ws[g]){const A=Buffer.allocUnsafe(2);A.writeUInt16BE(this.#c.closeInfo.code,0);const e=new I(A);this.ws[E].socket.write(e.createFrame(o.CLOSE),(A=>{if(!A){this.ws[g]=true}}))}this.ws[c]=i.CLOSING;this.ws[Q]=true;this.end();return}else if(this.#c.opcode===o.PING){const e=this.consume(t);if(!this.ws[Q]){const A=new I(e);this.ws[E].socket.write(A.createFrame(o.PONG));if(h.ping.hasSubscribers){h.ping.publish({payload:e})}}this.#a=n.INFO;if(this.#i>0){continue}else{A();return}}else if(this.#c.opcode===o.PONG){const e=this.consume(t);if(h.pong.hasSubscribers){h.pong.publish({payload:e})}if(this.#i>0){continue}else{A();return}}}else if(this.#a===n.PAYLOADLENGTH_16){if(this.#i<2){return A()}const e=this.consume(2);this.#c.payloadLength=e.readUInt16BE(0);this.#a=n.READ_DATA}else if(this.#a===n.PAYLOADLENGTH_64){if(this.#i<8){return A()}const e=this.consume(8);const t=e.readUInt32BE(0);if(t>2**31-1){B(this.ws,"Received payload length > 2^31 bytes.");return}const r=e.readUInt32BE(4);this.#c.payloadLength=(t<<8)+r;this.#a=n.READ_DATA}else if(this.#a===n.READ_DATA){if(this.#i<this.#c.payloadLength){return A()}else if(this.#i>=this.#c.payloadLength){const A=this.consume(this.#c.payloadLength);this.#g.push(A);if(!this.#c.fragmented||this.#c.fin&&this.#c.opcode===o.CONTINUATION){const A=Buffer.concat(this.#g);l(this.ws,this.#c.originalOpcode,A);this.#c={};this.#g.length=0}this.#a=n.INFO}}if(this.#i>0){continue}else{A();break}}}consume(A){if(A>this.#i){return null}else if(A===0){return a}if(this.#o[0].length===A){this.#i-=this.#o[0].length;return this.#o.shift()}const e=Buffer.allocUnsafe(A);let t=0;while(t!==A){const r=this.#o[0];const{length:s}=r;if(s+t===A){e.set(this.#o.shift(),t);break}else if(s+t>A){e.set(r.subarray(0,A-t),t);this.#o[0]=r.subarray(A-t);break}else{e.set(this.#o.shift(),t);t+=r.length}}this.#i-=A;return e}parseCloseBody(A,e){let t;if(e.length>=2){t=e.readUInt16BE(0)}if(A){if(!C(t)){return null}return{code:t}}let r=e.subarray(2);if(r[0]===239&&r[1]===187&&r[2]===191){r=r.subarray(3)}if(t!==undefined&&!C(t)){return null}try{r=new TextDecoder("utf-8",{fatal:true}).decode(r)}catch{return null}return{code:t,reason:r}}get closingIn