ocamba-publish/dist/index.js

12 lines
572 KiB
JavaScript
Raw Permalink Normal View History

2024-03-13 15:50:19 +00:00
import A from"os";import e from"fs";import t from"path";import i from"http";import n from"https";import s from"net";import o from"tls";import a from"events";import r from"assert";import c from"util";import l from"stream";import g from"buffer";import E from"querystring";import p from"stream/web";import Q from"node:stream";import u from"node:util";import B from"node:events";import C from"worker_threads";import h from"perf_hooks";import I from"util/types";import d from"async_hooks";import m from"console";import f from"url";import b from"zlib";import y from"string_decoder";import w from"diagnostics_channel";var D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}function x(A){if(A.__esModule)return A;var e=A.default;if("function"==typeof e){var t=function A(){return this instanceof A?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(A).forEach((function(e){var i=Object.getOwnPropertyDescriptor(A,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return A[e]}})})),t}var R={},k={},F={};Object.defineProperty(F,"__esModule",{value:!0}),F.toCommandProperties=F.toCommandValue=void 0,F.toCommandValue=function(A){return null==A?"":"string"==typeof A||A instanceof String?A:JSON.stringify(A)},F.toCommandProperties=function(A){return Object.keys(A).length?{title:A.title,file:A.file,line:A.startLine,endLine:A.endLine,col:A.startColumn,endColumn:A.endColumn}:{}};var N=D&&D.__createBinding||(Object.create?function(A,e,t,i){void 0===i&&(i=t),Object.defineProperty(A,i,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,i){void 0===i&&(i=t),A[i]=e[t]}),S=D&&D.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),U=D&&D.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(null!=A)for(var t in A)"default"!==t&&Object.hasOwnProperty.call(A,t)&&N(e,A,t);return S(e,A),e};Object.defineProperty(k,"__esModule",{value:!0}),k.issue=k.issueCommand=void 0;const L=U(A),M=F;function Y(A,e,t){const i=new T(A,e,t);process.stdout.write(i.toString()+L.EOL)}k.issueCommand=Y,k.issue=function(A,e=""){Y(A,{},e)};class T{constructor(A,e,t){A||(A="missing.command"),this.command=A,this.properties=e,this.message=t}toString(){let A="::"+this.command;if(this.properties&&Object.keys(this.properties).length>0){A+=" ";let t=!0;for(const i in this.properties)if(this.properties.hasOwnProperty(i)){const n=this.properties[i];n&&(t?t=!1:A+=",",A+=`${i}=${e=n,M.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}`)}}var e;return A+=`::${function(A){return M.toCommandValue(A).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}(this.message)}`,A}}var J,G={},H=new Uint8Array(16);function V(){if(!J&&!(J="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return J(H)}var O=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function q(A){return"string"==typeof A&&O.test(A)}for(var W,P,_=[],j=0;j<256;++j)_.push((j+256).toString(16).substr(1));function z(A){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=(_[A[e+0]]+_[A[e+1]]+_[A[e+2]]+_[A[e+3]]+"-"+_[A[e+4]]+_[A[e+5]]+"-"+_[A[e+6]]+_[A[e+7]]+"-"+_[A[e+8]]+_[A[e+9]]+"-"+_[A[e+10]]+_[A[e+11]]+_[A[e+12]]+_[A[e+13]]+_[A[e+14]]+_[A[e+15]]).toLowerCase();if(!q(t))throw TypeError("Stringified UUID is invalid");return t}var Z=0,X=0;function K(A){if(!q(A))throw TypeError("Invalid U
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */,i=A=>A.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),n=A=>A.replace(/\r?\n|\r/g,"\r\n"),s=[],o=new Uint8Array([13,10]);l=0;let a=!1;for(const[e,r]of A)if("string"==typeof r){const A=R.encode(t+`; name="${i(n(e))}"`+`\r\n\r\n${n(r)}\r\n`);s.push(A),l+=A.byteLength}else{const A=R.encode(`${t}; name="${i(n(e))}"`+(r.name?`; filename="${i(r.name)}"`:"")+"\r\n"+`Content-Type: ${r.type||"application/octet-stream"}\r\n\r\n`);s.push(A,r,o),"number"==typeof r.size?l+=A.byteLength+r.size+o.byteLength:a=!0}const E=R.encode(`--${e}--`);s.push(E),l+=E.byteLength,a&&(l=null),c=A,r=async function*(){for(const A of s)A.stream?yield*A.stream():yield A},g="multipart/form-data; boundary="+e}else if(i(A))c=A,l=A.size,A.type&&(g=A.type);else if("function"==typeof A[Symbol.asyncIterator]){if(o)throw new TypeError("keepalive");if(e.isDisturbed(A)||A.locked)throw new TypeError("Response body object should not be disturbed or locked");a=A instanceof v?A:t(A)}if(("string"==typeof c||e.isBuffer(c))&&(l=Buffer.byteLength(c)),null!=r){let e;a=new v({async start(){e=r(A)[Symbol.asyncIterator]()},async pull(A){const{value:t,done:i}=await e.next();return i?queueMicrotask((()=>{A.close()})):m(a)||A.enqueue(new Uint8Array(t)),A.desiredSize>0},async cancel(A){await e.return()},type:void 0})}return[{stream:a,source:c,length:l},g]}async function*N(A){if(A)if(f(A))yield A;else{const t=A.stream;if(e.isDisturbed(t))throw new TypeError("The body has already been consumed.");if(t.locked)throw new TypeError("The stream is locked.");t[h]=!0,yield*t}}function S(A){if(A.aborted)throw new Q("The operation was aborted.","AbortError")}function U(e){const t={blob(){return L(this,(A=>{let e=function(A){const{headersList:e}=A[l],t=e.get("content-type");if(null===t)return"failure";return w(t)}(this);return"failure"===e?e="":e&&(e=D(e)),new B([A],{type:e})}),e)},arrayBuffer(){return L(this,(A=>new Uint8Array(A).buffer),e)},text(){return L(this,M,e)},json(){return L(this,Y,e)},async formData(){E.brandCheck(this,e),S(this[l]);const t=this.headers.get("Content-Type");if(/multipart\/form-data/.test(t)){const e={};for(const[A,t]of this.headers)e[A.toLowerCase()]=t;const t=new c;let i;try{i=new A({headers:e,preservePath:!0})}catch(A){throw new Q(`${A}`,"AbortError")}i.on("field",((A,e)=>{t.append(A,e)})),i.on("file",((A,e,i,n,s)=>{const o=[];if("base64"===n||"base64"===n.toLowerCase()){let n="";e.on("data",(A=>{n+=A.toString().replace(/[\r\n]/gm,"");const e=n.length-n.length%4;o.push(Buffer.from(n.slice(0,e),"base64")),n=n.slice(e)})),e.on("end",(()=>{o.push(Buffer.from(n,"base64")),t.append(A,new x(o,i,{type:s}))}))}else e.on("data",(A=>{o.push(A)})),e.on("end",(()=>{t.append(A,new x(o,i,{type:s}))}))}));const n=new Promise(((A,e)=>{i.on("finish",A),i.on("error",(A=>e(new TypeError(A))))}));if(null!==this.body)for await(const A of N(this[l].body))i.write(A);return i.end(),await n,t}if(/application\/x-www-form-urlencoded/.test(t)){let A;try{let e="";const t=new TextDecoder("utf-8",{ignoreBOM:!0});for await(const A of N(this[l].body)){if(!f(A))throw new TypeError("Expected Uint8Array chunk");e+=t.decode(A,{stream:!0})}e+=t.decode(),A=new URLSearchParams(e)}catch(A){throw Object.assign(new TypeError,{cause:A})}const e=new c;for(const[t,i]of A)e.append(t,i);return e}throw await Promise.resolve(),S(this[l]),E.errors.exception({header:`${e.name}.formData`,message:"Could not parse content as FormData."})}};return t}async function L(A,t,i){if(E.brandCheck(A,i),S(A[l]),function(A){return null!=A&&(A.stream.locked||e.isDisturbed(A.stream))}(A[l].body))throw new TypeError("Body is unusable");const n=o(),s=A=>n.reject(A),r=A=>{try{n.resolve(t(A))}catch(A){s(A)}};return null==A[l].body?(r(new Uint8Array),n.promise):(await a(A[l].body,r,s),n.promise)}function M(A){if(0===A.length)return"";239===A[0]&&187===A[1]&&191===A[2]&&(A=A.subarray(3));return k.decode(A)}function Y(A){return JSON.parse(M(A))}return nt={extractBody:F,safelyExtractBody:function(A,t=!1){return v||(v=p.ReadableStream
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */
s[n-4]=this.maskKey[0],s[n-3]=this.maskKey[1],s[n-2]=this.maskKey[2],s[n-1]=this.maskKey[3],s[1]=i,126===i?s.writeUInt16BE(t,2):127===i&&(s[2]=s[3]=0,s.writeUIntBE(t,4,6)),s[1]|=128;for(let A=0;A<t;A++)s[n+A]=this.frameData[A]^this.maskKey[A%4];return s}}},vE}const zE=Js,ZE=Vt,XE=OA,KE=Jo,$E=ra,Ap=Ya,ep=Ee,{InvalidArgumentError:tp}=XE,ip=Ta,np=Ei,sp=Il,op=sg,ap=Sl,rp=dc,cp=yg,lp=Fg,{getGlobalDispatcher:gp,setGlobalDispatcher:Ep}=SE,pp=class{constructor(A){this.handler=A}onConnect(...A){return this.handler.onConnect(...A)}onError(...A){return this.handler.onError(...A)}onUpgrade(...A){return this.handler.onUpgrade(...A)}onHeaders(...A){return this.handler.onHeaders(...A)}onData(...A){return this.handler.onData(...A)}onComplete(...A){return this.handler.onComplete(...A)}onBodySent(...A){return this.handler.onBodySent(...A)}},Qp=yi,up=ki;let Bp;try{require("crypto"),Bp=!0}catch{Bp=!1}function Cp(A){return(e,t,i)=>{if("function"==typeof t&&(i=t,t=null),!e||"string"!=typeof e&&"object"!=typeof e&&!(e instanceof URL))throw new tp("invalid url");if(null!=t&&"object"!=typeof t)throw new tp("invalid opts");if(t&&null!=t.path){if("string"!=typeof t.path)throw new tp("invalid opts.path");let A=t.path;t.path.startsWith("/")||(A=`/${A}`),e=new URL(ep.parseOrigin(e).origin+A)}else t||(t="object"==typeof e?e:{}),e=ep.parseURL(e);const{agent:n,dispatcher:s=gp()}=t;if(n)throw new tp("unsupported opts.agent. Did you mean opts.client?");return A.call(s,{...t,origin:e.origin,path:e.search?`${e.pathname}${e.search}`:e.pathname,method:t.method||(t.body?"PUT":"GET")},i)}}if(Object.assign(ZE.prototype,ip),TA.Dispatcher=ZE,TA.Client=zE,TA.Pool=KE,TA.BalancedPool=$E,TA.Agent=Ap,TA.ProxyAgent=cp,TA.RetryHandler=lp,TA.DecoratorHandler=pp,TA.RedirectHandler=Qp,TA.createRedirectInterceptor=up,TA.buildConnector=np,TA.errors=XE,TA.setGlobalDispatcher=Ep,TA.getGlobalDispatcher=gp,ep.nodeMajor>16||16===ep.nodeMajor&&ep.nodeMinor>=8){let A=null;TA.fetch=async function(e){A||(A=YE().fetch);try{return await A(...arguments)}catch(A){throw"object"==typeof A&&Error.captureStackTrace(A,this),A}},TA.Headers=UE().Headers,TA.Response=LE().Response,TA.Request=ME().Request,TA.FormData=bt().FormData,TA.File=ft().File,TA.FileReader=function(){if(AE)return $g;AE=1;const{staticPropertyDescriptors:A,readOperation:e,fireAProgressEvent:t}=JE(),{kState:i,kError:n,kResult:s,kEvents:o,kAborted:a}=TE(),{webidl:r}=dt(),{kEnumerableProperty:c}=Ee;class l extends EventTarget{constructor(){super(),this[i]="empty",this[s]=null,this[n]=null,this[o]={loadend:null,error:null,abort:null,load:null,progress:null,loadstart:null}}readAsArrayBuffer(A){r.brandCheck(this,l),r.argumentLengthCheck(arguments,1,{header:"FileReader.readAsArrayBuffer"}),A=r.converters.Blob(A,{strict:!1}),e(this,A,"ArrayBuffer")}readAsBinaryString(A){r.brandCheck(this,l),r.argumentLengthCheck(arguments,1,{header:"FileReader.readAsBinaryString"}),A=r.converters.Blob(A,{strict:!1}),e(this,A,"BinaryString")}readAsText(A,t=void 0){r.brandCheck(this,l),r.argumentLengthCheck(arguments,1,{header:"FileReader.readAsText"}),A=r.converters.Blob(A,{strict:!1}),void 0!==t&&(t=r.converters.DOMString(t)),e(this,A,"Text",t)}readAsDataURL(A){r.brandCheck(this,l),r.argumentLengthCheck(arguments,1,{header:"FileReader.readAsDataURL"}),A=r.converters.Blob(A,{strict:!1}),e(this,A,"DataURL")}abort(){"empty"!==this[i]&&"done"!==this[i]?("loading"===this[i]&&(this[i]="done",this[s]=null),this[a]=!0,t("abort",this),"loading"!==this[i]&&t("loadend",this)):this[s]=null}get readyState(){switch(r.brandCheck(this,l),this[i]){case"empty":return this.EMPTY;case"loading":return this.LOADING;case"done":return this.DONE}}get result(){return r.brandCheck(this,l),this[s]}get error(){return r.brandCheck(this,l),this[n]}get onloadend(){return r.brandCheck(this,l),this[o].loadend}set onloadend(A){r.brandCheck(this,l),this[o].loadend&&this.removeEventListener("loadend",this[o].loadend),"function"==typeof A?(this[o].loadend=A,this.addEventListener("loadend",A)):this[o].loadend=null}get onerror(){return r.brandCheck(this,l),this[o].error}set onerror(A){r.bra
/*!
* mime-types
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
!function(A){var e,i,n,s=nQ,o=t.extname,a=/^\s*([^;\s]*)(?:;|\s|$)/,r=/^text\//i;function c(A){if(!A||"string"!=typeof A)return!1;var e=a.exec(A),t=e&&s[e[1].toLowerCase()];return t&&t.charset?t.charset:!(!e||!r.test(e[1]))&&"UTF-8"}A.charset=c,A.charsets={lookup:c},A.contentType=function(e){if(!e||"string"!=typeof e)return!1;var t=-1===e.indexOf("/")?A.lookup(e):e;if(!t)return!1;if(-1===t.indexOf("charset")){var i=A.charset(t);i&&(t+="; charset="+i.toLowerCase())}return t},A.extension=function(e){if(!e||"string"!=typeof e)return!1;var t=a.exec(e),i=t&&A.extensions[t[1].toLowerCase()];if(!i||!i.length)return!1;return i[0]},A.extensions=Object.create(null),A.lookup=function(e){if(!e||"string"!=typeof e)return!1;var t=o("x."+e).toLowerCase().substr(1);if(!t)return!1;return A.types[t]||!1},A.types=Object.create(null),e=A.extensions,i=A.types,n=["nginx","apache",void 0,"iana"],Object.keys(s).forEach((function(A){var t=s[A],o=t.extensions;if(o&&o.length){e[A]=o;for(var a=0;a<o.length;a++){var r=o[a];if(i[r]){var c=n.indexOf(s[i[r]].source),l=n.indexOf(t.source);if("application/octet-stream"!==i[r]&&(c>l||c===l&&"application/"===i[r].substr(0,12)))continue}i[r]=A}}}))}(iQ);var sQ=function(A){var e="function"==typeof setImmediate?setImmediate:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:null;e?e(A):setTimeout(A,0)},oQ=function(A){var e=!1;return sQ((function(){e=!0})),function(t,i){e?A(t,i):sQ((function(){A(t,i)}))}};var aQ=function(A){Object.keys(A.jobs).forEach(rQ.bind(A)),A.jobs={}};function rQ(A){"function"==typeof this.jobs[A]&&this.jobs[A]()}var cQ=oQ,lQ=aQ,gQ=function(A,e,t,i){var n=t.keyedList?t.keyedList[t.index]:t.index;t.jobs[n]=function(A,e,t,i){var n;n=2==A.length?A(t,cQ(i)):A(t,e,cQ(i));return n}(e,n,A[n],(function(A,e){n in t.jobs&&(delete t.jobs[n],A?lQ(t):t.results[n]=e,i(A,t.results))}))};var EQ=function(A,e){var t=!Array.isArray(A),i={index:0,keyedList:t||e?Object.keys(A):null,jobs:{},results:t?{}:[],size:t?Object.keys(A).length:A.length};e&&i.keyedList.sort(t?e:function(t,i){return e(A[t],A[i])});return i};var pQ=aQ,QQ=oQ,uQ=function(A){if(!Object.keys(this.jobs).length)return;this.index=this.size,pQ(this),QQ(A)(null,this.results)};var BQ=gQ,CQ=EQ,hQ=uQ,IQ=function(A,e,t){var i=CQ(A);for(;i.index<(i.keyedList||A).length;)BQ(A,e,i,(function(A,e){A?t(A,e):0!==Object.keys(i.jobs).length||t(null,i.results)})),i.index++;return hQ.bind(i,t)};var dQ={exports:{}},mQ=gQ,fQ=EQ,bQ=uQ;function yQ(A,e){return A<e?-1:A>e?1:0}dQ.exports=function(A,e,t,i){var n=fQ(A,t);return mQ(A,e,n,(function t(s,o){s?i(s,o):(n.index++,n.index<(n.keyedList||A).length?mQ(A,e,n,t):i(null,n.results))})),bQ.bind(n,i)},dQ.exports.ascending=yQ,dQ.exports.descending=function(A,e){return-1*yQ(A,e)};var wQ=dQ.exports,DQ=wQ;var vQ={parallel:IQ,serial:function(A,e,t){return DQ(A,e,null,t)},serialOrdered:wQ},xQ=eQ,RQ=c,kQ=t,FQ=i,NQ=n,SQ=f.parse,UQ=e,LQ=l.Stream,MQ=iQ,YQ=vQ,TQ=function(A,e){return Object.keys(e).forEach((function(t){A[t]=A[t]||e[t]})),A},JQ=GQ;function GQ(A){if(!(this instanceof GQ))return new GQ(A);for(var e in this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],xQ.call(this),A=A||{})this[e]=A[e]}RQ.inherits(GQ,xQ),GQ.LINE_BREAK="\r\n",GQ.DEFAULT_CONTENT_TYPE="application/octet-stream",GQ.prototype.append=function(A,e,t){"string"==typeof(t=t||{})&&(t={filename:t});var i=xQ.prototype.append.bind(this);if("number"==typeof e&&(e=""+e),RQ.isArray(e))this._error(new Error("Arrays are not supported."));else{var n=this._multiPartHeader(A,e,t),s=this._multiPartFooter();i(n),i(e),i(s),this._trackLength(n,e,t)}},GQ.prototype._trackLength=function(A,e,t){var i=0;null!=t.knownLength?i+=+t.knownLength:Buffer.isBuffer(e)?i=e.length:"string"==typeof e&&(i=Buffer.byteLength(e)),this._valueLength+=i,this._overheadLength+=Buffer.byteLength(A)+GQ.LINE_BREAK.length,e&&(e.path||e.readable&&e.hasOwnProperty("httpVersion")||e instanceof LQ)&&(t.knownLength||this._valuesToMeasure.push(e))},GQ.prototype._lengthRetriever=function(A,e){A.hasOwnProperty("fd")?null!=A.end&&A.end!=1/0&&null!=A.start?e(null,A.end+