mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-10-15 20:06:58 +00:00
Update to Node 24
Update fetch.ts to use native fetch() API Use immutable sort in tools.ts
This commit is contained in:
6 files changed
+44
-57
No files matched your search
@@ -19,7 +19,9 @@ it('checking fetch', async () => {
|
||||
Location: host_url + '/pong'
|
||||
})
|
||||
.get('/pong')
|
||||
.reply(200, 'pong');
|
||||
.reply(200, 'pong')
|
||||
.get('/error')
|
||||
.replyWithError('Network failure');
|
||||
|
||||
let response: Record<string, string> = await fetch.fetch(manifest_url);
|
||||
expect(response.error).toBe(undefined);
|
||||
@@ -36,4 +38,8 @@ it('checking fetch', async () => {
|
||||
response = await fetch.fetch(manifest_url, 'invalid_token');
|
||||
expect(response.error).not.toBe(undefined);
|
||||
expect(response.data).toBe(undefined);
|
||||
|
||||
response = await fetch.fetch(host_url + '/error');
|
||||
expect(response.error).toContain('Fetch error:');
|
||||
expect(response.data).toBe(undefined);
|
||||
});
|
||||
+1
-1
@@ -34,5 +34,5 @@ outputs:
|
||||
php-version:
|
||||
description: 'PHP version in semver format'
|
||||
runs:
|
||||
using: 'node20'
|
||||
using: 'node24'
|
||||
main: 'dist/index.js'
|
||||
Vendored
+2
-2
@@ -1,3 +1,3 @@
|
||||
(()=>{var e={6472:function(e,A,t){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,A,t,r){if(r===undefined)r=t;var s=Object.getOwnPropertyDescriptor(A,t);if(!s||("get"in s?!A.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return A[t]}}}Object.defineProperty(e,r,s)}:function(e,A,t,r){if(r===undefined)r=t;e[r]=A[t]});var s=this&&this.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:true,value:A})}:function(e,A){e["default"]=A});var n=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var A=[];for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))A[A.length]=t;return A};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t=ownKeys(e),n=0;n<t.length;n++)if(t[n]!=="default")r(A,e,t[n]);s(A,e);return A}}();Object.defineProperty(A,"__esModule",{value:true});A.addINIValuesUnix=addINIValuesUnix;A.addINIValuesWindows=addINIValuesWindows;A.addINIValues=addINIValues;const o=n(t(9277));async function addINIValuesUnix(e){const A=await o.CSVArray(e);let t="";await o.asyncForEach(A,(async function(e){t+="\n"+await o.addLog("$tick",e,"Added to php.ini","linux")}));return'echo "'+A.join("\n")+'" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1'+t}async function addINIValuesWindows(e){const A=await o.CSVArray(e);let t="\n";await o.asyncForEach(A,(async function(e){t+=await o.addLog("$tick",e,"Added to php.ini","win32")+"\n"}));return'Add-Content "$php_dir\\php.ini" "'+A.join("\n")+'"'+t}async function addINIValues(e,A,t=false){let r="\n";switch(t){case true:r+=await o.stepLog("Add php.ini values",A)+await o.suppressOutput(A)+"\n";break;case false:default:r+=await o.stepLog("Add php.ini values",A)+"\n";break}switch(A){case"win32":return r+await addINIValuesWindows(e);case"darwin":case"linux":return r+await addINIValuesUnix(e);default:return await o.log("Platform "+A+" is not supported",A,"error")}}},9524:function(e,A,t){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,A,t,r){if(r===undefined)r=t;var s=Object.getOwnPropertyDescriptor(A,t);if(!s||("get"in s?!A.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return A[t]}}}Object.defineProperty(e,r,s)}:function(e,A,t,r){if(r===undefined)r=t;e[r]=A[t]});var s=this&&this.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:true,value:A})}:function(e,A){e["default"]=A});var n=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var A=[];for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))A[A.length]=t;return A};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t=ownKeys(e),n=0;n<t.length;n++)if(t[n]!=="default")r(A,e,t[n]);s(A,e);return A}}();Object.defineProperty(A,"__esModule",{value:true});A.checkXdebugError=checkXdebugError;A.addCoverageXdebug=addCoverageXdebug;A.addCoveragePCOV=addCoveragePCOV;A.disableCoverage=disableCoverage;A.addCoverage=addCoverage;const o=n(t(9277));const i=n(t(3252));const a=n(t(6472));async function checkXdebugError(e,A){if(/^5\.[3-6]$|^7\.[0-1]$/.test(A)&&e=="xdebug3"||/^8\.[0-9]$/.test(A)&&e=="xdebug2"){return e+" is not supported on PHP "+A}return""}async function addCoverageXdebug(e,A,t,r){let s="\n";const n=await checkXdebugError(e,A);if(!n){s+=await i.addExtension(":pcov:false",A,t,true)+r;e=e=="xdebug3"?"xdebug":e;s+=await i.addExtension(e,A,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",e,n,t)}return s}async function addCoveragePCOV(e,A,t){let r="\n";switch(true){default:r+=await i.addExtension(":xdebug:false",e,A,true)+t;r+=await i.addExtension("pcov",e,A,true)+t;r+=await a.addINIValues("pcov.enabled=1",A,true)+"\n";r+=await o.setVariable("pcov_version","php -r \"echo phpversion('pcov');\"",A);r+=await o.getCommand(A,"extension_log")+'pcov "PCOV $pcov_version enabled as coverage driver"';break;case/5\.[3-6]|7\.0/.test(e):r+=await o.addLog("$cross","pcov","PHP 7.1 or newer is required",A);break}return r}async function disableCoverage(e,A,t){let r="\n";r+=await i.addExtension(":pcov:false",e,A,true)+t;r+=await i.addExtension(":xdebug:false",e,A,true)+t;r+=await o.addLog("$tick","none","Disabled Xdebug and PCOV",A);return r}async function addCoverage(e,A,t){e=e.toLowerCase();const r="\n"+await o.stepLog("Setup Coverage",t);const s=await o.suppressOutput(t)+"\n";switch(e){case"pcov":return r+await addCoveragePCOV(A,t,s);case"xdebug":case"xdebug2":case"xdebug3":return r+await addCoverageXdebug(e,A,t,s);case"none":return r+await disableCoverage(A,t,s);default:return""}}},3252:function(e,A,t){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,A,t,r)Line truncated
|
||||
(()=>{var e={6472:function(e,A,t){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,A,t,r){if(r===undefined)r=t;var s=Object.getOwnPropertyDescriptor(A,t);if(!s||("get"in s?!A.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return A[t]}}}Object.defineProperty(e,r,s)}:function(e,A,t,r){if(r===undefined)r=t;e[r]=A[t]});var s=this&&this.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:true,value:A})}:function(e,A){e["default"]=A});var n=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var A=[];for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))A[A.length]=t;return A};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t=ownKeys(e),n=0;n<t.length;n++)if(t[n]!=="default")r(A,e,t[n]);s(A,e);return A}}();Object.defineProperty(A,"__esModule",{value:true});A.addINIValuesUnix=addINIValuesUnix;A.addINIValuesWindows=addINIValuesWindows;A.addINIValues=addINIValues;const o=n(t(9277));async function addINIValuesUnix(e){const A=await o.CSVArray(e);let t="";await o.asyncForEach(A,(async function(e){t+="\n"+await o.addLog("$tick",e,"Added to php.ini","linux")}));return'echo "'+A.join("\n")+'" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1'+t}async function addINIValuesWindows(e){const A=await o.CSVArray(e);let t="\n";await o.asyncForEach(A,(async function(e){t+=await o.addLog("$tick",e,"Added to php.ini","win32")+"\n"}));return'Add-Content "$php_dir\\php.ini" "'+A.join("\n")+'"'+t}async function addINIValues(e,A,t=false){let r="\n";switch(t){case true:r+=await o.stepLog("Add php.ini values",A)+await o.suppressOutput(A)+"\n";break;case false:default:r+=await o.stepLog("Add php.ini values",A)+"\n";break}switch(A){case"win32":return r+await addINIValuesWindows(e);case"darwin":case"linux":return r+await addINIValuesUnix(e);default:return await o.log("Platform "+A+" is not supported",A,"error")}}},9524:function(e,A,t){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,A,t,r){if(r===undefined)r=t;var s=Object.getOwnPropertyDescriptor(A,t);if(!s||("get"in s?!A.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return A[t]}}}Object.defineProperty(e,r,s)}:function(e,A,t,r){if(r===undefined)r=t;e[r]=A[t]});var s=this&&this.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:true,value:A})}:function(e,A){e["default"]=A});var n=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var A=[];for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))A[A.length]=t;return A};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t=ownKeys(e),n=0;n<t.length;n++)if(t[n]!=="default")r(A,e,t[n]);s(A,e);return A}}();Object.defineProperty(A,"__esModule",{value:true});A.checkXdebugError=checkXdebugError;A.addCoverageXdebug=addCoverageXdebug;A.addCoveragePCOV=addCoveragePCOV;A.disableCoverage=disableCoverage;A.addCoverage=addCoverage;const o=n(t(9277));const i=n(t(3252));const a=n(t(6472));async function checkXdebugError(e,A){if(/^5\.[3-6]$|^7\.[0-1]$/.test(A)&&e=="xdebug3"||/^8\.[0-9]$/.test(A)&&e=="xdebug2"){return e+" is not supported on PHP "+A}return""}async function addCoverageXdebug(e,A,t,r){let s="\n";const n=await checkXdebugError(e,A);if(!n){s+=await i.addExtension(":pcov:false",A,t,true)+r;e=e=="xdebug3"?"xdebug":e;s+=await i.addExtension(e,A,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",e,n,t)}return s}async function addCoveragePCOV(e,A,t){let r="\n";switch(true){default:r+=await i.addExtension(":xdebug:false",e,A,true)+t;r+=await i.addExtension("pcov",e,A,true)+t;r+=await a.addINIValues("pcov.enabled=1",A,true)+"\n";r+=await o.setVariable("pcov_version","php -r \"echo phpversion('pcov');\"",A);r+=await o.getCommand(A,"extension_log")+'pcov "PCOV $pcov_version enabled as coverage driver"';break;case/5\.[3-6]|7\.0/.test(e):r+=await o.addLog("$cross","pcov","PHP 7.1 or newer is required",A);break}return r}async function disableCoverage(e,A,t){let r="\n";r+=await i.addExtension(":pcov:false",e,A,true)+t;r+=await i.addExtension(":xdebug:false",e,A,true)+t;r+=await o.addLog("$tick","none","Disabled Xdebug and PCOV",A);return r}async function addCoverage(e,A,t){e=e.toLowerCase();const r="\n"+await o.stepLog("Setup Coverage",t);const s=await o.suppressOutput(t)+"\n";switch(e){case"pcov":return r+await addCoveragePCOV(A,t,s);case"xdebug":case"xdebug2":case"xdebug3":return r+await addCoverageXdebug(e,A,t,s);case"none":return r+await disableCoverage(A,t,s);default:return""}}},3252:function(e,A,t){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,A,t,r)Line 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 r=[];const s=new Uint8Array([13,10]);l=0;let n=false;for(const[A,o]of e){if(typeof o==="string"){const e=y.encode(t+`; name="${escape(normalizeLinefeeds(A))}"`+`\r\n\r\n${normalizeLinefeeds(o)}\r\n`);r.push(e);l+=e.byteLength}else{const e=y.encode(`${t}; name="${escape(normalizeLinefeeds(A))}"`+(o.name?`; filename="${escape(o.name)}"`:"")+"\r\n"+`Content-Type: ${o.type||"application/octet-stream"}\r\n\r\n`);r.push(e,o,s);if(typeof o.size==="number"){l+=e.byteLength+o.size+s.byteLength}else{n=true}}}const o=y.encode(`--${A}--\r\n`);r.push(o);l+=o.byteLength;if(n){l=null}c=e;a=async function*(){for(const e of r){if(e.stream){yield*e.stream()}else{yield e}}};g=`multipart/form-data; boundary=${A}`}else if(n(e)){c=e;l=e.size;if(e.type){g=e.type}}else if(typeof e[Symbol.asyncIterator]==="function"){if(A){throw new TypeError("keepalive")}if(r.isDisturbed(e)||e.locked){throw new TypeError("Response body object should not be disturbed or locked")}t=e instanceof ReadableStream?e:s(e)}if(typeof c==="string"||r.isBuffer(c)){l=Buffer.byteLength(c)}if(a!=null){let A;t=new ReadableStream({async start(){A=a(e)[Symbol.asyncIterator]()},async pull(e){const{value:r,done:s}=await A.next();if(s){queueMicrotask((()=>{e.close();e.byobRequest?.respond(0)}))}else{if(!C(t)){const A=new Uint8Array(r);if(A.byteLength){e.enqueue(A)}}}return e.desiredSize>0},async cancel(e){await A.return()},type:"bytes"})}const u={stream:t,source:c,length:l};return[u,g]}function safelyExtractBody(e,A=false){if(e instanceof ReadableStream){B(!r.isDisturbed(e),"The body has already been consumed.");B(!e.locked,"The stream is locked.")}return extractBody(e,A)}function cloneBody(e,A){const[t,r]=A.stream.tee();A.stream=t;return{stream:r,length:A.length,source:A.source}}function throwIfAborted(e){if(e.aborted){throw new DOMException("The operation was aborted.","AbortError")}}function bodyMixinMethods(e){const A={blob(){return consumeBody(this,(e=>{let A=bodyMimeType(this);if(A===null){A=""}else if(A){A=f(A)}return new h([e],{type:A})}),e)},arrayBuffer(){return consumeBody(this,(e=>new Uint8Array(e).buffer),e)},text(){return consumeBody(this,g,e)},json(){return consumeBody(this,parseJSONFromBytes,e)},formData(){return consumeBody(this,(e=>{const A=bodyMimeType(this);if(A!==null){switch(A.essence){case"multipart/form-data":{const t=p(e,A);if(t==="failure"){throw new TypeError("Failed to parse body as FormData.")}const r=new u;r[Q]=t;return r}case"application/x-www-form-urlencoded":{const A=new URLSearchParams(e.toString());const t=new u;for(const[e,r]of A){t.append(e,r)}return t}}}throw new TypeError('Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".')}),e)},bytes(){return consumeBody(this,(e=>new Uint8Array(e)),e)}};return A}function mixinBody(e){Object.assign(e.prototype,bodyMixinMethods(e))}async function consumeBody(e,A,t){E.brandCheck(e,t);if(bodyUnusable(e)){throw new TypeError("Body is unusable: Body has already been read")}throwIfAborted(e[Q]);const r=a();const errorSteps=e=>r.reject(e);const successSteps=e=>{try{r.resolve(A(e))}catch(e){errorSteps(e)}};if(e[Q].body==null){successSteps(Buffer.allocUnsafe(0));return r.promise}await c(e[Q].body,successSteps,errorSteps);return r.promise}function bodyUnusable(e){const A=e[Q].body;return A!=null&&(A.stream.locked||r.isDisturbed(A.stream))}function parseJSONFromBytes(e){return JSON.parse(g(e))}function bodyMimeType(e){const A=e[Q].headersList;const t=l(A);if(t==="failure"){return null}return t}e.exports={extractBody:extractBody,safelyExtractBody:safelyExtractBody,cloneBody:cloneBody,mixinBody:mixinBody,streamRegistry:D,hasFinalizationRegistry:m,bodyUnusable:bodyUnusable}},4495:e=>{"use strict";const A=["GET","HEAD","POST"];const t=new Set(A);const r=[101,204,205,304];const s=[301,302,303,307,308];const n=new Set(s);const o=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"];const i=new Set(o);const a=["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"];const c=new Set(a);const l=["follow","manual","error"];const g=["GET","HEAD","OPTIONS","TRACE"];const u=new Set(g);const Q=["navigate","same-origin","no-cors","cors"];const E=["omit","same-origin","include"];const h=["default","no-store","reload","no-caLine truncated
|
||||
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */i[o-4]=t[0];i[o-3]=t[1];i[o-2]=t[2];i[o-1]=t[3];i[1]=n;if(n===126){i.writeUInt16BE(s,2)}else if(n===127){i[2]=i[3]=0;i.writeUIntBE(s,4,6)}i[1]|=128;for(let e=0;e<s;++e){i[o+e]=A[e]^t[e&3]}return i}}e.exports={WebsocketFrameSend:WebsocketFrameSend}},9469:(e,A,t)=>{"use strict";const{createInflateRaw:r,Z_DEFAULT_WINDOWBITS:s}=t(8522);const{isValidClientWindowBits:n}=t(8625);const o=Buffer.from([0,0,255,255]);const i=Symbol("kBuffer");const a=Symbol("kLength");class PerMessageDeflate{#z;#Q={};constructor(e){this.#Q.serverNoContextTakeover=e.has("server_no_context_takeover");this.#Q.serverMaxWindowBits=e.get("server_max_window_bits")}decompress(e,A,t){if(!this.#z){let e=s;if(this.#Q.serverMaxWindowBits){if(!n(this.#Q.serverMaxWindowBits)){t(new Error("Invalid server_max_window_bits"));return}e=Number.parseInt(this.#Q.serverMaxWindowBits)}this.#z=r({windowBits:e});this.#z[i]=[];this.#z[a]=0;this.#z.on("data",(e=>{this.#z[i].push(e);this.#z[a]+=e.length}));this.#z.on("error",(e=>{this.#z=null;t(e)}))}this.#z.write(e);if(A){this.#z.write(o)}this.#z.flush((()=>{const e=Buffer.concat(this.#z[i],this.#z[a]);this.#z[i].length=0;this.#z[a]=0;t(null,e)}))}}e.exports={PerMessageDeflate:PerMessageDeflate}},1652:(e,A,t)=>{"use strict";const{Writable:r}=t(7075);const s=t(4589);const{parserStates:n,opcodes:o,states:i,emptyBuffer:a,sentCloseFrameState:c}=t(736);const{kReadyState:l,kSentClose:g,kResponse:u,kReceivedClose:Q}=t(1216);const{channels:E}=t(2414);const{isValidStatusCode:h,isValidOpcode:B,failWebsocketConnection:C,websocketMessageReceived:I,utf8Decode:d,isControlFrame:f,isTextBinaryFrame:p,isContinuationFrame:w}=t(8625);const{WebsocketFrameSend:y}=t(3264);const{closeWebSocketConnection:m}=t(6897);const{PerMessageDeflate:D}=t(9469);class ByteParser extends r{#K=[];#X=0;#$=false;#f=n.INFO;#ee={};#Ae=[];#te;constructor(e,A){super();this.ws=e;this.#te=A==null?new Map:A;if(this.#te.has("permessage-deflate")){this.#te.set("permessage-deflate",new D(A))}}_write(e,A,t){this.#K.push(e);this.#X+=e.length;this.#$=true;this.run(t)}run(e){while(this.#$){if(this.#f===n.INFO){if(this.#X<2){return e()}const A=this.consume(2);const t=(A[0]&128)!==0;const r=A[0]&15;const s=(A[1]&128)===128;const i=!t&&r!==o.CONTINUATION;const a=A[1]&127;const c=A[0]&64;const l=A[0]&32;const g=A[0]&16;if(!B(r)){C(this.ws,"Invalid opcode received");return e()}if(s){C(this.ws,"Frame cannot be masked");return e()}if(c!==0&&!this.#te.has("permessage-deflate")){C(this.ws,"Expected RSV1 to be clear.");return}if(l!==0||g!==0){C(this.ws,"RSV1, RSV2, RSV3 must be clear");return}if(i&&!p(r)){C(this.ws,"Invalid frame type was fragmented.");return}if(p(r)&&this.#Ae.length>0){C(this.ws,"Expected continuation frame");return}if(this.#ee.fragmented&&i){C(this.ws,"Fragmented frame exceeded 125 bytes.");return}if((a>125||i)&&f(r)){C(this.ws,"Control frame either too large or fragmented");return}if(w(r)&&this.#Ae.length===0&&!this.#ee.compressed){C(this.ws,"Unexpected continuation frame");return}if(a<=125){this.#ee.payloadLength=a;this.#f=n.READ_DATA}else if(a===126){this.#f=n.PAYLOADLENGTH_16}else if(a===127){this.#f=n.PAYLOADLENGTH_64}if(p(r)){this.#ee.binaryType=r;this.#ee.compressed=c!==0}this.#ee.opcode=r;this.#ee.masked=s;this.#ee.fin=t;this.#ee.fragmented=i}else if(this.#f===n.PAYLOADLENGTH_16){if(this.#X<2){return e()}const A=this.consume(2);this.#ee.payloadLength=A.readUInt16BE(0);this.#f=n.READ_DATA}else if(this.#f===n.PAYLOADLENGTH_64){if(this.#X<8){return e()}const A=this.consume(8);const t=A.readUInt32BE(0);if(t>2**31-1){C(this.ws,"Received payload length > 2^31 bytes.");return}const r=A.readUInt32BE(4);this.#ee.payloadLength=(t<<8)+r;this.#f=n.READ_DATA}else if(this.#f===n.READ_DATA){if(this.#X<this.#ee.payloadLength){return e()}const A=this.consume(this.#ee.payloadLength);if(f(this.#ee.opcode)){this.#$=this.parseControlFrame(A);this.#f=n.INFO}else{if(!this.#ee.compressed){this.#Ae.push(A);if(!this.#ee.fragmented&&this.#ee.fin){const e=Buffer.concat(this.#Ae);I(this.ws,this.#ee.binaryType,e);this.#Ae.length=0}this.#f=n.INFO}else{this.#te.get("permessage-deflate").decompress(A,this.#ee.fin,((A,t)=>{if(A){m(this.ws,1007,A.message,A.message.length);return}this.#Ae.push(t);if(!this.#ee.fin){this.#f=n.INFO;this.#$=true;this.run(e);return}I(this.ws,this.#ee.binaryType,Buffer.concat(this.#Ae));this.#$=true;this.#f=n.INFO;this.#Ae.length=0;this.run(e)}));this.#$=false;break}}}}}consume(e){if(e>this.#X){throw new Error("Called consume() before buffers satiated.")}else if(e===0){return a}if(this.#K[0].length===e){this.#X-=this.#K[0].length;return this.#K.shift()}const A=Buffer.allocUnsafe(e);let t=0;while(t!==e){const r=this.#K[0];const{length:s}=r;if(s+t===e){A.set(this.#K.shift(),t);break}else if(s+t>e){A.set(r.subarray(0,e-t),t);this.#K[0]=r.subarray(e-t);break}else{A.set(this.#K.shift(),t);t+=r.length}}this.#X-=e;return A}parseCloseBody(e){s(e.length!==1);let A;if(e.length>=2){A=e.readUInt16BE(0)}if(Line truncated
|
||||
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */i[o-4]=t[0];i[o-3]=t[1];i[o-2]=t[2];i[o-1]=t[3];i[1]=n;if(n===126){i.writeUInt16BE(s,2)}else if(n===127){i[2]=i[3]=0;i.writeUIntBE(s,4,6)}i[1]|=128;for(let e=0;e<s;++e){i[o+e]=A[e]^t[e&3]}return i}}e.exports={WebsocketFrameSend:WebsocketFrameSend}},9469:(e,A,t)=>{"use strict";const{createInflateRaw:r,Z_DEFAULT_WINDOWBITS:s}=t(8522);const{isValidClientWindowBits:n}=t(8625);const o=Buffer.from([0,0,255,255]);const i=Symbol("kBuffer");const a=Symbol("kLength");class PerMessageDeflate{#z;#Q={};constructor(e){this.#Q.serverNoContextTakeover=e.has("server_no_context_takeover");this.#Q.serverMaxWindowBits=e.get("server_max_window_bits")}decompress(e,A,t){if(!this.#z){let e=s;if(this.#Q.serverMaxWindowBits){if(!n(this.#Q.serverMaxWindowBits)){t(new Error("Invalid server_max_window_bits"));return}e=Number.parseInt(this.#Q.serverMaxWindowBits)}this.#z=r({windowBits:e});this.#z[i]=[];this.#z[a]=0;this.#z.on("data",(e=>{this.#z[i].push(e);this.#z[a]+=e.length}));this.#z.on("error",(e=>{this.#z=null;t(e)}))}this.#z.write(e);if(A){this.#z.write(o)}this.#z.flush((()=>{const e=Buffer.concat(this.#z[i],this.#z[a]);this.#z[i].length=0;this.#z[a]=0;t(null,e)}))}}e.exports={PerMessageDeflate:PerMessageDeflate}},1652:(e,A,t)=>{"use strict";const{Writable:r}=t(7075);const s=t(4589);const{parserStates:n,opcodes:o,states:i,emptyBuffer:a,sentCloseFrameState:c}=t(736);const{kReadyState:l,kSentClose:g,kResponse:u,kReceivedClose:Q}=t(1216);const{channels:E}=t(2414);const{isValidStatusCode:h,isValidOpcode:B,failWebsocketConnection:C,websocketMessageReceived:I,utf8Decode:d,isControlFrame:f,isTextBinaryFrame:p,isContinuationFrame:w}=t(8625);const{WebsocketFrameSend:y}=t(3264);const{closeWebSocketConnection:m}=t(6897);const{PerMessageDeflate:D}=t(9469);class ByteParser extends r{#K=[];#X=0;#$=false;#f=n.INFO;#ee={};#Ae=[];#te;constructor(e,A){super();this.ws=e;this.#te=A==null?new Map:A;if(this.#te.has("permessage-deflate")){this.#te.set("permessage-deflate",new D(A))}}_write(e,A,t){this.#K.push(e);this.#X+=e.length;this.#$=true;this.run(t)}run(e){while(this.#$){if(this.#f===n.INFO){if(this.#X<2){return e()}const A=this.consume(2);const t=(A[0]&128)!==0;const r=A[0]&15;const s=(A[1]&128)===128;const i=!t&&r!==o.CONTINUATION;const a=A[1]&127;const c=A[0]&64;const l=A[0]&32;const g=A[0]&16;if(!B(r)){C(this.ws,"Invalid opcode received");return e()}if(s){C(this.ws,"Frame cannot be masked");return e()}if(c!==0&&!this.#te.has("permessage-deflate")){C(this.ws,"Expected RSV1 to be clear.");return}if(l!==0||g!==0){C(this.ws,"RSV1, RSV2, RSV3 must be clear");return}if(i&&!p(r)){C(this.ws,"Invalid frame type was fragmented.");return}if(p(r)&&this.#Ae.length>0){C(this.ws,"Expected continuation frame");return}if(this.#ee.fragmented&&i){C(this.ws,"Fragmented frame exceeded 125 bytes.");return}if((a>125||i)&&f(r)){C(this.ws,"Control frame either too large or fragmented");return}if(w(r)&&this.#Ae.length===0&&!this.#ee.compressed){C(this.ws,"Unexpected continuation frame");return}if(a<=125){this.#ee.payloadLength=a;this.#f=n.READ_DATA}else if(a===126){this.#f=n.PAYLOADLENGTH_16}else if(a===127){this.#f=n.PAYLOADLENGTH_64}if(p(r)){this.#ee.binaryType=r;this.#ee.compressed=c!==0}this.#ee.opcode=r;this.#ee.masked=s;this.#ee.fin=t;this.#ee.fragmented=i}else if(this.#f===n.PAYLOADLENGTH_16){if(this.#X<2){return e()}const A=this.consume(2);this.#ee.payloadLength=A.readUInt16BE(0);this.#f=n.READ_DATA}else if(this.#f===n.PAYLOADLENGTH_64){if(this.#X<8){return e()}const A=this.consume(8);const t=A.readUInt32BE(0);if(t>2**31-1){C(this.ws,"Received payload length > 2^31 bytes.");return}const r=A.readUInt32BE(4);this.#ee.payloadLength=(t<<8)+r;this.#f=n.READ_DATA}else if(this.#f===n.READ_DATA){if(this.#X<this.#ee.payloadLength){return e()}const A=this.consume(this.#ee.payloadLength);if(f(this.#ee.opcode)){this.#$=this.parseControlFrame(A);this.#f=n.INFO}else{if(!this.#ee.compressed){this.#Ae.push(A);if(!this.#ee.fragmented&&this.#ee.fin){const e=Buffer.concat(this.#Ae);I(this.ws,this.#ee.binaryType,e);this.#Ae.length=0}this.#f=n.INFO}else{this.#te.get("permessage-deflate").decompress(A,this.#ee.fin,((A,t)=>{if(A){m(this.ws,1007,A.message,A.message.length);return}this.#Ae.push(t);if(!this.#ee.fin){this.#f=n.INFO;this.#$=true;this.run(e);return}I(this.ws,this.#ee.binaryType,Buffer.concat(this.#Ae));this.#$=true;this.#f=n.INFO;this.#Ae.length=0;this.run(e)}));this.#$=false;break}}}}}consume(e){if(e>this.#X){throw new Error("Called consume() before buffers satiated.")}else if(e===0){return a}if(this.#K[0].length===e){this.#X-=this.#K[0].length;return this.#K.shift()}const A=Buffer.allocUnsafe(e);let t=0;while(t!==e){const r=this.#K[0];const{length:s}=r;if(s+t===e){A.set(this.#K.shift(),t);break}else if(s+t>e){A.set(r.subarray(0,e-t),t);this.#K[0]=r.subarray(e-t);break}else{A.set(this.#K.shift(),t);t+=r.length}}this.#X-=e;return A}parseCloseBody(e){s(e.length!==1);let A;if(e.length>=2){A=e.readUInt16BE(0)}if(Line truncated
|
||||
+27
-43
@@ -1,9 +1,5 @@
|
||||
import {IncomingMessage, OutgoingHttpHeaders} from 'http';
|
||||
import * as https from 'https';
|
||||
import * as url from 'url';
|
||||
|
||||
/**
|
||||
* Function to fetch a URL
|
||||
* Function to fetch a URL using native fetch API (Node 24+)
|
||||
*
|
||||
* @param input_url
|
||||
* @param auth_token
|
||||
@@ -14,43 +10,31 @@ export async function fetch(
|
||||
auth_token?: string,
|
||||
redirect_count = 5
|
||||
): Promise<Record<string, string>> {
|
||||
const fetch_promise: Promise<Record<string, string>> = new Promise(
|
||||
resolve => {
|
||||
const url_object: url.UrlObject = new url.URL(input_url);
|
||||
const headers: OutgoingHttpHeaders = {
|
||||
'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php`
|
||||
};
|
||||
if (auth_token) {
|
||||
headers.authorization = 'Bearer ' + auth_token;
|
||||
}
|
||||
const options: https.RequestOptions = {
|
||||
hostname: url_object.hostname,
|
||||
path: url_object.pathname,
|
||||
headers: headers,
|
||||
agent: new https.Agent({keepAlive: false})
|
||||
};
|
||||
const req = https.get(options, (res: IncomingMessage) => {
|
||||
if (res.statusCode === 200) {
|
||||
let body = '';
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', chunk => (body += chunk));
|
||||
res.on('end', () => resolve({data: `${body}`}));
|
||||
} else if (
|
||||
[301, 302, 303, 307, 308].includes(res.statusCode as number)
|
||||
) {
|
||||
if (redirect_count > 0 && res.headers.location) {
|
||||
fetch(res.headers.location, auth_token, redirect_count--).then(
|
||||
resolve
|
||||
);
|
||||
} else {
|
||||
resolve({error: `${res.statusCode}: Redirect error`});
|
||||
}
|
||||
} else {
|
||||
resolve({error: `${res.statusCode}: ${res.statusMessage}`});
|
||||
}
|
||||
});
|
||||
req.end();
|
||||
const headers: Record<string, string> = {
|
||||
'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php`
|
||||
};
|
||||
if (auth_token) {
|
||||
headers['Authorization'] = 'Bearer ' + auth_token;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await globalThis.fetch(input_url, {
|
||||
headers,
|
||||
redirect: redirect_count > 0 ? 'follow' : 'manual'
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.text();
|
||||
return {data};
|
||||
} else if (
|
||||
[301, 302, 303, 307, 308].includes(response.status) &&
|
||||
redirect_count <= 0
|
||||
) {
|
||||
return {error: `${response.status}: Redirect error`};
|
||||
} else {
|
||||
return {error: `${response.status}: ${response.statusText}`};
|
||||
}
|
||||
);
|
||||
return await fetch_promise;
|
||||
} catch (error) {
|
||||
return {error: `Fetch error: ${(error as Error).message}`};
|
||||
}
|
||||
}
|
||||
+5
-8
@@ -46,14 +46,14 @@ export async function getSemverVersion(data: RS): Promise<string> {
|
||||
fixedToOriginal.set(f, t);
|
||||
return f;
|
||||
});
|
||||
fixed.sort((a, b) => {
|
||||
const sorted = fixed.toSorted((a, b) => {
|
||||
try {
|
||||
return cv.compareVersions(b, a);
|
||||
} catch {
|
||||
return b.localeCompare(a, 'en', {numeric: true, sensitivity: 'base'});
|
||||
}
|
||||
});
|
||||
return fixedToOriginal.get(fixed[0]) ?? fixed[0];
|
||||
return fixedToOriginal.get(sorted[0]) ?? sorted[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,13 +74,10 @@ export async function getLatestVersion(data: RS): Promise<string> {
|
||||
...resp['data'].matchAll(/releases\/tag\/([a-zA-Z]*)?(\d+.\d+.\d+)"/g)
|
||||
].map(match => match[2]);
|
||||
|
||||
return (
|
||||
releases
|
||||
.sort((a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {numeric: true})
|
||||
)
|
||||
.pop() || 'latest'
|
||||
const sorted = releases.toSorted((a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {numeric: true})
|
||||
);
|
||||
return sorted.at(-1) || 'latest';
|
||||
}
|
||||
return 'latest';
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
"declaration": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": [
|
||||
"ES2021"
|
||||
"ES2024"
|
||||
],
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
@@ -13,7 +13,7 @@
|
||||
"rootDir": "./src",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"target": "ES2021"
|
||||
"target": "ES2024"
|
||||
},
|
||||
"exclude": ["__tests__", "lib", "node_modules"]
|
||||
}
|
||||
Reference in new issue
Block a user