setup-cpp/dist/modern/setup-cpp.mjs

82 lines
318 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
import up from"process";import it,{homedir as lp,tmpdir as Ue}from"os";import ue,{join as J,resolve as Ia,delimiter as mn,basename as er,extname as In,normalize as Lm,sep as fp,dirname as be,relative as Dm,parse as dp}from"path";import je,{promises as Pn,existsSync as Qt,mkdir as pp,stat as km,statSync as Fm,mkdirSync as hp}from"fs";import*as uc from"https";import Pa from"https";import mp from"crypto";import*as Vn from"http";import yp from"http";import"net";import qm from"tls";import Tn from"events";import xn from"util";import Um from"string_decoder";import Fr from"child_process";import qr from"assert";import jm from"timers";import{Buffer as Mm}from"node:buffer";import dr from"node:path";import ga,{ChildProcess as Gm}from"node:child_process";import Tt from"node:process";import{fileURLToPath as vp}from"node:url";import wp,{constants as gp}from"node:os";import Vm,{createWriteStream as Bm,createReadStream as Hm,readFileSync as zm,promises as Wm}from"node:fs";import Xm from"buffer";import Ur from"stream";import{debuglog as Km}from"node:util";import _p,{readFile as pr,appendFile as Ym,writeFile as yn,chmod as Ep,readdir as Sp}from"fs/promises";import Jm,{fileURLToPath as Lt}from"url";import Qm from"constants";import{error as Zm,info as _a}from"console";function Bn(e){return e==null?[]:Array.isArray(e)?e:[e]}function ey(e,t,r,n){var i,o=e[t],s=~n.string.indexOf(t)?r==null||r===!0?"":String(r):typeof r=="boolean"?r:~n.boolean.indexOf(t)?r==="false"?!1:r==="true"||(e._.push((i=+r,i*0===0?i:r)),!!r):(i=+r,i*0===0?i:r);e[t]=o==null?s:Array.isArray(o)?o.concat(s):[o,s]}function ty(e,t){e=e||[],t=t||{};var r,n,i,o,s,l={_:[]},u=0,a=0,c=0,m=e.length;const p=t.alias!==void 0,w=t.unknown!==void 0,E=t.default!==void 0;if(t.alias=t.alias||{},t.string=Bn(t.string),t.boolean=Bn(t.boolean),p)for(r in t.alias)for(n=t.alias[r]=Bn(t.alias[r]),u=0;u<n.length;u++)(t.alias[n[u]]=n.concat(r)).splice(u,1);for(u=t.boolean.length;u-- >0;)for(n=t.alias[t.boolean[u]]||[],a=n.length;a-- >0;)t.boolean.push(n[a]);for(u=t.string.length;u-- >0;)for(n=t.alias[t.string[u]]||[],a=n.length;a-- >0;)t.string.push(n[a]);if(E){for(r in t.default)if(o=typeof t.default[r],n=t.alias[r]=t.alias[r]||[],t[o]!==void 0)for(t[o].push(r),u=0;u<n.length;u++)t[o].push(n[u])}const d=w?Object.keys(t.alias):[];for(u=0;u<m;u++){if(i=e[u],i==="--"){l._=l._.concat(e.slice(++u));break}for(a=0;a<i.length&&i.charCodeAt(a)===45;a++);if(a===0)l._.push(i);else if(i.substring(a,a+3)==="no-"){if(o=i.substring(a+3),w&&!~d.indexOf(o))return t.unknown(i);l[o]=!1}else{for(c=a+1;c<i.length&&i.charCodeAt(c)!==61;c++);for(o=i.substring(a,c),s=i.substring(++c)||u+1===m||(""+e[u+1]).charCodeAt(0)===45||e[++u],n=a===2?[o]:o,c=0;c<n.length;c++){if(o=n[c],w&&!~d.indexOf(o))return t.unknown("-".repeat(a)+o);ey(l,o,c+1<n.length||s,t)}}}if(E)for(r in t.default)l[r]===void 0&&(l[r]=t.default[r]);if(p)for(r in l)for(n=t.alias[r]||[];n.length>0;)l[n.shift()]=l[r];return l}var at=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ry(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var Hr={exports:{}},Hn,lc;function An(){if(lc)return Hn;lc=1;const e="2.0.0",t=256,r=Number.MAX_SAFE_INTEGER||9007199254740991,n=16,i=t-6;return Hn={MAX_LENGTH:t,MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:i,MAX_SAFE_INTEGER:r,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},Hn}var zn,fc;function Cn(){return fc||(fc=1,zn=typeof process=="object"&&
2025-07-10 22:11:16 +08:00
`),M=Math.max.apply(Math,A.map(function(F){return F.length})),K=["┌".concat("─".repeat(M+2),"┐")],Q=0,x=A;Q<x.length;Q++){var T=x[Q];K.push("│ ".concat(T.padEnd(M)," │"))}return K.push("└".concat("─".repeat(M+2),"┘")),K.join(`
`)},$=function(I){return s(void 0,void 0,void 0,function(){var A,M;return l(this,function(K){switch(K.label){case 0:if(!I.alwaysRun&&(!process.stdout.isTTY||E&&!I.shouldNotifyInNpmScript))return I.debug&&console.error("Opting out of running simpleUpdateNotifier()"),[2];K.label=1;case 1:return K.trys.push([1,3,,4]),[4,b(I)];case 2:return A=K.sent(),A&&console.error(g("New version of ".concat(I.pkg.name,` available!
Current Version: `).concat(I.pkg.version,`
2025-11-10 16:13:02 +08:00
Latest Version: `).concat(A))),[3,4];case 3:return M=K.sent(),I.debug&&M instanceof Error&&console.error("Unexpected error in simpleUpdateNotifier():",M),[3,4];case 4:return[2]}})})};return Di=$,Di}var Oy=$y();const Iy=$e(Oy),Py="setup-cpp",Ty="1.7.2",La={name:Py,version:Ty};var dt={},Je={},Gt={},ru;function Da(){if(ru)return Gt;ru=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.toCommandProperties=Gt.toCommandValue=void 0;function e(r){return r==null?"":typeof r=="string"||r instanceof String?r:JSON.stringify(r)}Gt.toCommandValue=e;function t(r){return Object.keys(r).length?{title:r.title,file:r.file,line:r.startLine,endLine:r.endLine,col:r.startColumn,endColumn:r.endColumn}:{}}return Gt.toCommandProperties=t,Gt}var nu;function xy(){if(nu)return Je;nu=1;var e=Je&&Je.__createBinding||(Object.create?function(m,p,w,E){E===void 0&&(E=w);var d=Object.getOwnPropertyDescriptor(p,w);(!d||("get"in d?!p.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return p[w]}}),Object.defineProperty(m,E,d)}:function(m,p,w,E){E===void 0&&(E=w),m[E]=p[w]}),t=Je&&Je.__setModuleDefault||(Object.create?function(m,p){Object.defineProperty(m,"default",{enumerable:!0,value:p})}:function(m,p){m.default=p}),r=Je&&Je.__importStar||function(m){if(m&&m.__esModule)return m;var p={};if(m!=null)for(var w in m)w!=="default"&&Object.prototype.hasOwnProperty.call(m,w)&&e(p,m,w);return t(p,m),p};Object.defineProperty(Je,"__esModule",{value:!0}),Je.issue=Je.issueCommand=void 0;const n=r(it),i=Da();function o(m,p,w){const E=new u(m,p,w);process.stdout.write(E.toString()+n.EOL)}Je.issueCommand=o;function s(m,p=""){o(m,{},p)}Je.issue=s;const l="::";class u{constructor(p,w,E){p||(p="missing.command"),this.command=p,this.properties=w,this.message=E}toString(){let p=l+this.command;if(this.properties&&Object.keys(this.properties).length>0){p+=" ";let w=!0;for(const E in this.properties)if(this.properties.hasOwnProperty(E)){const d=this.properties[E];d&&(w?w=!1:p+=",",p+=`${E}=${c(d)}`)}}return p+=`${l}${a(this.message)}`,p}}function a(m){return(0,i.toCommandValue)(m).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function c(m){return(0,i.toCommandValue)(m).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}return Je}var Qe={},iu;function Ay(){if(iu)return Qe;iu=1;var e=Qe&&Qe.__createBinding||(Object.create?function(a,c,m,p){p===void 0&&(p=m);var w=Object.getOwnPropertyDescriptor(c,m);(!w||("get"in w?!c.__esModule:w.writable||w.configurable))&&(w={enumerable:!0,get:function(){return c[m]}}),Object.defineProperty(a,p,w)}:function(a,c,m,p){p===void 0&&(p=m),a[p]=c[m]}),t=Qe&&Qe.__setModuleDefault||(Object.create?function(a,c){Object.defineProperty(a,"default",{enumerable:!0,value:c})}:function(a,c){a.default=c}),r=Qe&&Qe.__importStar||function(a){if(a&&a.__esModule)return a;var c={};if(a!=null)for(var m in a)m!=="default"&&Object.prototype.hasOwnProperty.call(a,m)&&e(c,a,m);return t(c,a),c};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.prepareKeyValueMessage=Qe.issueFileCommand=void 0;const n=r(mp),i=r(je),o=r(it),s=Da();function l(a,c){const m=process.env[`GITHUB_${a}`];if(!m)throw new Error(`Unable to find environment variable for file command ${a}`);if(!i.existsSync(m))throw new Error(`Missing file at path: ${m}`);i.appendFileSync(m,`${(0,s.toCommandValue)(c)}${o.EOL}`,{encoding:"utf8"})}Qe.issueFileCommand=l;function u(a,c){const m=`ghadelimiter_${n.randomUUID()}`,p=(0,s.toCommandValue)(c);if(a.includes(m))throw new Error(`Unexpected input: name should not contain the delimiter "${m}"`);if(p.includes(m))throw new Error(`Unexpected input: value should not contain the delimiter "${m}"`);return`${a}<<${m}${o.EOL}${p}${o.EOL}${m}`}return Qe.prepareKeyValueMessage=u,Qe}var Vt={};function Ea(e){const t=e.protocol==="https:";if(Cy(e))return;const r=t?process.env.https_proxy||process.env.HTTPS_PROXY:process.env.http_proxy||process.env.HTTP_PROXY;if(r)try{return new su(r)}catch{if(!r.startsWith("http://")&&!r.startsWith("https://"))return new su(`http://${r}`)}else return
2025-07-10 22:11:16 +08:00
`,I.message,I.stack);var A=new Error("tunneling socket could not be established, cause="+I.message);A.code="ECONNRESET",d.request.emit("error",A),h.removeSocket(y)}},a.prototype.removeSocket=function(d){var f=this.sockets.indexOf(d);if(f!==-1){this.sockets.splice(f,1);var h=this.requests.shift();h&&this.createSocket(h,function(y){h.request.onSocket(y)})}};function c(E,d){var f=this;a.prototype.createSocket.call(f,E,function(h){var y=E.request.getHeader("host"),v=p({},f.options,{socket:h,servername:y?y.replace(/:.*$/,""):E.host}),S=e.connect(0,v);f.sockets[f.sockets.indexOf(h)]=S,d(S)})}function m(E,d,f){return typeof E=="string"?{host:E,port:d,localAddress:f}:E}function p(E){for(var d=1,f=arguments.length;d<f;++d){var h=arguments[d];if(typeof h=="object")for(var y=Object.keys(h),v=0,S=y.length;v<S;++v){var _=y[v];h[_]!==void 0&&(E[_]=h[_])}}return E}var w;return process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG)?w=function(){var E=Array.prototype.slice.call(arguments);typeof E[0]=="string"?E[0]="TUNNEL: "+E[0]:E.unshift("TUNNEL:"),console.error.apply(console,E)}:w=function(){},Bt.debug=w,Bt}var ki,au;function Dy(){return au||(au=1,ki=Ly()),ki}var zr=Dy(),tt;(function(e){e[e.OK=200]="OK",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.ResourceMoved=302]="ResourceMoved",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.SwitchProxy=306]="SwitchProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"})(tt||(tt={}));var qe;(function(e){e.Accept="accept",e.ContentType="content-type"})(qe||(qe={}));var Ot;(function(e){e.ApplicationJson="application/json"})(Ot||(Ot={}));function ky(e){const t=Ea(new URL(e));return t?t.href:""}const Fy=[tt.MovedPermanently,tt.ResourceMoved,tt.SeeOther,tt.TemporaryRedirect,tt.PermanentRedirect],qy=[tt.BadGateway,tt.ServiceUnavailable,tt.GatewayTimeout],Uy=["OPTIONS","GET","DELETE","HEAD"],jy=10,My=5;class kn extends Error{constructor(t,r){super(t),this.name="HttpClientError",this.statusCode=r,Object.setPrototypeOf(this,kn.prototype)}statusCode;result}class xp{constructor(t){this.message=t}message;async readBody(){return new Promise(async t=>{let r=Buffer.alloc(0);this.message.on("data",n=>{r=Buffer.concat([r,n])}),this.message.on("end",()=>{t(r.toString())})})}async readBodyBuffer(){return new Promise(async t=>{const r=[];this.message.on("data",n=>{r.push(n)}),this.message.on("end",()=>{t(Buffer.concat(r))})})}}function Gy(e){return new URL(e).protocol==="https:"}class Vy{userAgent;handlers;requestOptions;_ignoreSslError=!1;_socketTimeout;_allowRedirects=!0;_allowRedirectDowngrade=!1;_maxRedirects=50;_allowRetries=!1;_maxRetries=1;_agent;_proxyAgent;_proxyAgentDispatcher;_keepAlive=!1;_disposed=!1;constructor(t,r,n){this.userAgent=t,this.handlers=r||[],this.requestOptions=n,n&&(n.ignoreSslError!=null&&(this._ignoreSslError=n.ignoreSslError),this._socketTimeout=n.socketTimeout,n.allowRedirects!=null&&(this._allowRedirects=n.allowRedirects),n.allowRedirectDowngrade!=null&&(this._allowRedirectDowngrade=n.allowRedirectDowngrade),n.maxRedirects!=null&&(this._maxRedirects=Math.max(n.maxRedirects,0)),n.keepAlive!=null&&(this._keepAlive=n.keepAlive),n.allowRetries!=null&&(this._allowRetries=n.allowRetries),n.maxRetries!=null&&(this._maxRetries=n.maxRetries))}async options(t,r){return this.request(
2025-07-10 22:11:16 +08:00
Error Code : ${m.statusCode}
Error Message: ${m.message}`)})).result)===null||l===void 0?void 0:l.value;if(!c)throw new Error("Response json body do not have ID Token field");return c})}static getIDToken(s){return e(this,void 0,void 0,function*(){try{let l=i.getIDTokenUrl();if(s){const a=encodeURIComponent(s);l=`${l}&audience=${a}`}(0,n.debug)(`ID token url is ${l}`);const u=yield i.getCall(l);return(0,n.setSecret)(u),u}catch(l){throw new Error(`Error message: ${l.message}`)}})}}return Vt.OidcClient=i,Vt}var Ir={},lu;function fu(){return lu||(lu=1,function(e){var t=Ir&&Ir.__awaiter||function(a,c,m,p){function w(E){return E instanceof m?E:new m(function(d){d(E)})}return new(m||(m=Promise))(function(E,d){function f(v){try{y(p.next(v))}catch(S){d(S)}}function h(v){try{y(p.throw(v))}catch(S){d(S)}}function y(v){v.done?E(v.value):w(v.value).then(f,h)}y((p=p.apply(a,c||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.summary=e.markdownSummary=e.SUMMARY_DOCS_URL=e.SUMMARY_ENV_VAR=void 0;const r=it,n=je,{access:i,appendFile:o,writeFile:s}=n.promises;e.SUMMARY_ENV_VAR="GITHUB_STEP_SUMMARY",e.SUMMARY_DOCS_URL="https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";class l{constructor(){this._buffer=""}filePath(){return t(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;const c=process.env[e.SUMMARY_ENV_VAR];if(!c)throw new Error(`Unable to find environment variable for $${e.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);try{yield i(c,n.constants.R_OK|n.constants.W_OK)}catch{throw new Error(`Unable to access summary file: '${c}'. Check if the file has correct read/write permissions.`)}return this._filePath=c,this._filePath})}wrap(c,m,p={}){const w=Object.entries(p).map(([E,d])=>` ${E}="${d}"`).join("");return m?`<${c}${w}>${m}</${c}>`:`<${c}${w}>`}write(c){return t(this,void 0,void 0,function*(){const m=!!c?.overwrite,p=yield this.filePath();return yield(m?s:o)(p,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return t(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer="",this}addRaw(c,m=!1){return this._buffer+=c,m?this.addEOL():this}addEOL(){return this.addRaw(r.EOL)}addCodeBlock(c,m){const p=Object.assign({},m&&{lang:m}),w=this.wrap("pre",this.wrap("code",c),p);return this.addRaw(w).addEOL()}addList(c,m=!1){const p=m?"ol":"ul",w=c.map(d=>this.wrap("li",d)).join(""),E=this.wrap(p,w);return this.addRaw(E).addEOL()}addTable(c){const m=c.map(w=>{const E=w.map(d=>{if(typeof d=="string")return this.wrap("td",d);const{header:f,data:h,colspan:y,rowspan:v}=d,S=f?"th":"td",_=Object.assign(Object.assign({},y&&{colspan:y}),v&&{rowspan:v});return this.wrap(S,h,_)}).join("");return this.wrap("tr",E)}).join(""),p=this.wrap("table",m);return this.addRaw(p).addEOL()}addDetails(c,m){const p=this.wrap("details",this.wrap("summary",c)+m);return this.addRaw(p).addEOL()}addImage(c,m,p){const{width:w,height:E}=p||{},d=Object.assign(Object.assign({},w&&{width:w}),E&&{height:E}),f=this.wrap("img",null,Object.assign({src:c,alt:m},d));return this.addRaw(f).addEOL()}addHeading(c,m){const p=`h${m}`,w=["h1","h2","h3","h4","h5","h6"].includes(p)?p:"h1",E=this.wrap(w,c);return this.addRaw(E).addEOL()}addSeparator(){const c=this.wrap("hr",null);return this.addRaw(c).addEOL()}addBreak(){const c=this.wrap("br",null);return this.addRaw(c).addEOL()}addQuote(c,m){const p=Object.assign({},m&&{cite:m}),w=this.wrap("blockquote",c,p);return this.addRaw(w).addEOL()}addLink(c,m){const p=this.wrap("a",c,{href:m});return this.addRaw(p).addEOL()}}const u=new l;e.markdownSummary=u,e.summary=u}(Ir)),Ir}var Ve={},du;function Wy(){if(du)return Ve;du=1;var e=Ve&&Ve.__createBinding||(Object.create?function(l,u,a,c){c===void 0&&(c=a);var m=Object.getOwnPropertyDescriptor(u,a);(!m||("get"in m?!u.__esModule:m.writable||m.configurable))&&(m={enumerable:!0,get:function(){return u[a]}}),Object.defineProperty(l,c,m)}:function(l,u,a,c
2025-07-10 22:11:16 +08:00
`);return{name:w,version:E}});e.platform=s.default.platform(),e.arch=s.default.arch(),e.isWindows=e.platform==="win32",e.isMacOS=e.platform==="darwin",e.isLinux=e.platform==="linux";function m(){return i(this,void 0,void 0,function*(){return Object.assign(Object.assign({},yield e.isWindows?u():e.isMacOS?a():c()),{platform:e.platform,arch:e.arch,isWindows:e.isWindows,isMacOS:e.isMacOS,isLinux:e.isLinux})})}e.getDetails=m}(Ze)),Ze}var wu;function wr(){return wu||(wu=1,function(e){var t=dt&&dt.__createBinding||(Object.create?function(C,H,W,re){re===void 0&&(re=W);var ce=Object.getOwnPropertyDescriptor(H,W);(!ce||("get"in ce?!H.__esModule:ce.writable||ce.configurable))&&(ce={enumerable:!0,get:function(){return H[W]}}),Object.defineProperty(C,re,ce)}:function(C,H,W,re){re===void 0&&(re=W),C[re]=H[W]}),r=dt&&dt.__setModuleDefault||(Object.create?function(C,H){Object.defineProperty(C,"default",{enumerable:!0,value:H})}:function(C,H){C.default=H}),n=dt&&dt.__importStar||function(C){if(C&&C.__esModule)return C;var H={};if(C!=null)for(var W in C)W!=="default"&&Object.prototype.hasOwnProperty.call(C,W)&&t(H,C,W);return r(H,C),H},i=dt&&dt.__awaiter||function(C,H,W,re){function ce(X){return X instanceof W?X:new W(function(ie){ie(X)})}return new(W||(W=Promise))(function(X,ie){function se(L){try{D(re.next(L))}catch(N){ie(N)}}function we(L){try{D(re.throw(L))}catch(N){ie(N)}}function D(L){L.done?X(L.value):ce(L.value).then(se,we)}D((re=re.apply(C,H||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.platform=e.toPlatformPath=e.toWin32Path=e.toPosixPath=e.markdownSummary=e.summary=e.getIDToken=e.getState=e.saveState=e.group=e.endGroup=e.startGroup=e.info=e.notice=e.warning=e.error=e.debug=e.isDebug=e.setFailed=e.setCommandEcho=e.setOutput=e.getBooleanInput=e.getMultilineInput=e.getInput=e.addPath=e.setSecret=e.exportVariable=e.ExitCode=void 0;const o=xy(),s=Ay(),l=Da(),u=n(it),a=n(ue),c=zy();var m;(function(C){C[C.Success=0]="Success",C[C.Failure=1]="Failure"})(m||(e.ExitCode=m={}));function p(C,H){const W=(0,l.toCommandValue)(H);if(process.env[C]=W,process.env.GITHUB_ENV||"")return(0,s.issueFileCommand)("ENV",(0,s.prepareKeyValueMessage)(C,H));(0,o.issueCommand)("set-env",{name:C},W)}e.exportVariable=p;function w(C){(0,o.issueCommand)("add-mask",{},C)}e.setSecret=w;function E(C){process.env.GITHUB_PATH||""?(0,s.issueFileCommand)("PATH",C):(0,o.issueCommand)("add-path",{},C),process.env.PATH=`${C}${a.delimiter}${process.env.PATH}`}e.addPath=E;function d(C,H){const W=process.env[`INPUT_${C.replace(/ /g,"_").toUpperCase()}`]||"";if(H&&H.required&&!W)throw new Error(`Input required and not supplied: ${C}`);return H&&H.trimWhitespace===!1?W:W.trim()}e.getInput=d;function f(C,H){const W=d(C,H).split(`
`).filter(re=>re!=="");return H&&H.trimWhitespace===!1?W:W.map(re=>re.trim())}e.getMultilineInput=f;function h(C,H){const W=["true","True","TRUE"],re=["false","False","FALSE"],ce=d(C,H);if(W.includes(ce))return!0;if(re.includes(ce))return!1;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${C}
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}e.getBooleanInput=h;function y(C,H){if(process.env.GITHUB_OUTPUT||"")return(0,s.issueFileCommand)("OUTPUT",(0,s.prepareKeyValueMessage)(C,H));process.stdout.write(u.EOL),(0,o.issueCommand)("set-output",{name:C},(0,l.toCommandValue)(H))}e.setOutput=y;function v(C){(0,o.issue)("echo",C?"on":"off")}e.setCommandEcho=v;function S(C){process.exitCode=m.Failure,g(C)}e.setFailed=S;function _(){return process.env.RUNNER_DEBUG==="1"}e.isDebug=_;function b(C){(0,o.issueCommand)("debug",{},C)}e.debug=b;function g(C,H={}){(0,o.issueCommand)("error",(0,l.toCommandProperties)(H),C instanceof Error?C.toString():C)}e.error=g;function $(C,H={}){(0,o.issueCommand)("warning",(0,l.toCommandProperties)(H),C instanceof Error?C.toString():C)}e.warning=$;function I(C,H={}){(0,o.issueCommand)("notice",(0,l.toCommandProperties)(H),C instanceof Error?C.toString():C)}e.notice=I;function A(C){process.stdout.write(C+u.EOL)}e.info=A;function M(C){(0,o.issue)("group",C)}e.startGroup=M;function K(){(0,o.issue)("endgroup")}e.endGroup=K;function Q(C,H){return i(this,void 0,void 0,function*(){M(C);let W;try{W=yield H()}finally{K()}return W})}e.group=Q;function x(C,H){if(process.env.GITHUB_STATE||"")return(0,s.issueFileCommand)("STATE",(0,s.prepareKeyValueMessage)(C,H));(0,o.issueCommand)("save-state",{name:C},(0,l.toCommandValue)(H))}e.saveState=x;function T(C){return process.env[`STATE_${C}`]||""}e.getState=T;function F(C){return i(this,void 0,void 0,function*(){return yield c.OidcClient.getIDToken(C)})}e.getIDToken=F;var U=fu();Object.defineProperty(e,"summary",{enumerable:!0,get:function(){return U.summary}});var k=fu();Object.defineProperty(e,"markdownSummary",{enumerable:!0,get:function(){return k.markdownSummary}});var G=Wy();Object.defineProperty(e,"toPosixPath",{enumerable:!0,get:function(){return G.toPosixPath}}),Object.defineProperty(e,"toWin32Path",{enumerable:!0,get:function(){return G.toWin32Path}}),Object.defineProperty(e,"toPlatformPath",{enumerable:!0,get:function(){return G.toPlatformPath}}),e.platform=n(Ky())}(dt)),dt}var Ee=wr();function Lp(e){const t=Ee.getInput(e.toLowerCase());if(t!=="false"&&t!=="")return t}var Fi={};const Yy=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_A
2025-07-10 22:11:16 +08:00
`:10,r=typeof e=="string"?"\r":13;return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===r&&(e=e.slice(0,-1)),e}function Dp(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}const mv=({cwd:e=Tt.cwd(),path:t=Tt.env[Dp()],preferLocal:r=!0,execPath:n=Tt.execPath,addExecPath:i=!0}={})=>{const o=e instanceof URL?vp(e):e,s=dr.resolve(o),l=[];return r&&yv(l,s),i&&vv(l,n,s),[...l,t].join(dr.delimiter)},yv=(e,t)=>{let r;for(;r!==t;)e.push(dr.join(t,"node_modules/.bin")),r=t,t=dr.resolve(t,"..")},vv=(e,t,r)=>{const n=t instanceof URL?vp(t):t;e.push(dr.resolve(r,n,".."))},wv=({env:e=Tt.env,...t}={})=>{e={...e};const r=Dp({env:e});return t.path=e[r],e[r]=mv(t),e},gv=(e,t,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const i=Object.getOwnPropertyDescriptor(e,r),o=Object.getOwnPropertyDescriptor(t,r);!_v(i,o)&&n||Object.defineProperty(e,r,o)},_v=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},Ev=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},Sv=(e,t)=>`/* Wrapped ${e}*/
${t}`,bv=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Rv=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),$v=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,i=Sv.bind(null,n,t.toString());Object.defineProperty(i,"name",Rv),Object.defineProperty(e,"toString",{...bv,value:i})};function Ov(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const i of Reflect.ownKeys(t))gv(e,t,i,r);return Ev(e,t),$v(e,t,n),e}const wn=new WeakMap,kp=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const i=e.displayName||e.name||"<anonymous>",o=function(...s){if(wn.set(o,++n),n===1)r=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${i}\` can only be called once`);return r};return Ov(o,e),wn.set(o,n),o};kp.callCount=e=>{if(!wn.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return wn.get(e)};const Iv=()=>{const e=qp-Fp+1;return Array.from({length:e},Pv)},Pv=(e,t)=>({name:`SIGRT${t+1}`,number:Fp+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Fp=34,qp=64,Tv=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standar
${n.message}`:f,v=[y,t,e].filter(Boolean).join(`
`);return h?(n.originalMessage=n.message,n.message=v):n=new Error(v),n.shortMessage=y,n.command=s,n.escapedCommand=l,n.exitCode=o,n.signal=i,n.signalDescription=w,n.stdout=e,n.stderr=t,n.cwd=p,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!u,n.isCanceled=a,n.killed=c&&!u,n},on=["stdin","stdout","stderr"],qv=e=>on.some(t=>e[t]!==void 0),Uv=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return on.map(n=>e[n]);if(qv(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${on.map(n=>`\`${n}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const r=Math.max(t.length,on.length);return Array.from({length:r},(n,i)=>t[i])};var zt={exports:{}},Xi={exports:{}},Nu;function jv(){return Nu||(Nu=1,function(e){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}(Xi)),Xi.exports}var Lu;function Mv(){if(Lu)return zt.exports;Lu=1;var e=at.process;const t=function(f){return f&&typeof f=="object"&&typeof f.removeListener=="function"&&typeof f.emit=="function"&&typeof f.reallyExit=="function"&&typeof f.listeners=="function"&&typeof f.kill=="function"&&typeof f.pid=="number"&&typeof f.on=="function"};if(!t(e))zt.exports=function(){return function(){}};else{var r=qr,n=jv(),i=/^win/i.test(e.platform),o=Tn;typeof o!="function"&&(o=o.EventEmitter);var s;e.__signal_exit_emitter__?s=e.__signal_exit_emitter__:(s=e.__signal_exit_emitter__=new o,s.count=0,s.emitted={}),s.infinite||(s.setMaxListeners(1/0),s.infinite=!0),zt.exports=function(f,h){if(!t(at.process))return function(){};r.equal(typeof f,"function","a callback must be provided for exit handler"),c===!1&&m();var y="exit";h&&h.alwaysLast&&(y="afterexit");var v=function(){s.removeListener(y,f),s.listeners("exit").length===0&&s.listeners("afterexit").length===0&&l()};return s.on(y,f),v};var l=function(){!c||!t(at.process)||(c=!1,n.forEach(function(h){try{e.removeListener(h,a[h])}catch{}}),e.emit=E,e.reallyExit=p,s.count-=1)};zt.exports.unload=l;var u=function(h,y,v){s.emitted[h]||(s.emitted[h]=!0,s.emit(h,y,v))},a={};n.forEach(function(f){a[f]=function(){if(t(at.process)){var y=e.listeners(f);y.length===s.count&&(l(),u("exit",null,f),u("afterexit",null,f),i&&f==="SIGHUP"&&(f="SIGINT"),e.kill(e.pid,f))}}}),zt.exports.signals=function(){return n};var c=!1,m=function(){c||!t(at.process)||(c=!0,s.count+=1,n=n.filter(function(h){try{return e.on(h,a[h]),!0}catch{return!1}}),e.emit=d,e.reallyExit=w)};zt.exports.load=m;var p=e.reallyExit,w=function(h){t(at.process)&&(e.exitCode=h||0,u("exit",e.exitCode,null),u("afterexit",e.exitCode,null),p.call(e,e.exitCode))},E=e.emit,d=function(h,y){if(h==="exit"&&t(at.process)){y!==void 0&&(e.exitCode=y);var v=E.apply(this,arguments);return u("exit",e.exitCode,null),u("afterexit",e.exitCode,null),v}else return E.apply(this,arguments)}}return zt.exports}var Gv=Mv();const Vv=$e(Gv),Bv=1e3*5,Hv=(e,t="SIGTERM",r={})=>{const n=e(t);return zv(e,t,r,n),n},zv=(e,t,r,n)=>{if(!Wv(t,r,n))return;const i=Kv(r),o=setTimeout(()=>{e("SIGKILL")},i);o.unref&&o.unref()},Wv=(e,{forceKillAfterTimeout:t},r)=>Xv(e)&&t!==!1&&r,Xv=e=>e===wp.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Kv=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Bv;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Yv=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Jv=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Qv=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let i;const o=new Promise((l,u)=>{i=setTimeout(()=>{Jv(e,r,u)},t)}),s=n.finally(()=>{clearTimeout(i)});return Promise.race([o,s])},Zv=({timeout:e})=>
2025-07-10 22:11:16 +08:00
`)},Rw=1e3*1e3*100,$w=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:i})=>{const o=t?{...Tt.env,...e}:e;return r?wv({env:o,cwd:n,execPath:i}):o},zp=(e,t,r={})=>{const n=pv._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:Rw,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||Tt.cwd(),execPath:Tt.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Sw,...r},r.env=$w(r),r.stdio=Uv(r),Tt.platform==="win32"&&dr.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},Dr=(e,t,r)=>typeof t!="string"&&!Mm.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?hv(t):t;function le(e,t,r){const n=zp(e,t,r),i=Gp(e,t),o=Vp(e,t);Hp(o,n.options),Zv(n.options);let s;try{s=ga.spawn(n.file,n.args,n.options)}catch(w){const E=new ga.ChildProcess,d=Promise.reject(gn({error:w,stdout:"",stderr:"",all:"",command:i,escapedCommand:o,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return ju(E,d),E}const l=vw(s),u=Qv(s,n.options,l),a=ew(s,n.options,u),c={isCanceled:!1};s.kill=Hv.bind(null,s.kill.bind(s)),s.cancel=Yv.bind(null,s,c);const p=kp(async()=>{const[{error:w,exitCode:E,signal:d,timedOut:f},h,y,v]=await hw(s,n.options,a),S=Dr(n.options,h),_=Dr(n.options,y),b=Dr(n.options,v);if(w||E!==0||d!==null){const g=gn({error:w,exitCode:E,signal:d,stdout:S,stderr:_,all:b,command:i,escapedCommand:o,parsed:n,timedOut:f,isCanceled:c.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:s.killed});if(!n.options.reject)return g;throw g}return{command:i,escapedCommand:o,exitCode:0,stdout:S,stderr:_,all:b,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return dw(s,n.options),s.all=pw(s,n.options),rw(s),ju(s,p),s}function ze(e,t,r){const n=zp(e,t,r),i=Gp(e,t),o=Vp(e,t);Hp(o,n.options);const s=lw(n.options);let l;try{l=ga.spawnSync(n.file,n.args,{...n.options,input:s})}catch(c){throw gn({error:c,stdout:"",stderr:"",all:"",command:i,escapedCommand:o,parsed:n,timedOut:!1,isCanceled:!1,killed:!1})}const u=Dr(n.options,l.stdout,l.error),a=Dr(n.options,l.stderr,l.error);if(l.error||l.status!==0||l.signal!==null){const c=gn({stdout:u,stderr:a,error:l.error,signal:l.signal,exitCode:l.status,command:i,escapedCommand:o,parsed:n,timedOut:l.error&&l.error.code==="ETIMEDOUT",isCanceled:!1,killed:l.signal!==null});if(!n.options.reject)return c;throw c}return{command:i,escapedCommand:o,exitCode:0,stdout:u,stderr:a,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}}function Ow(e,t){const[r,...n]=Bp(e);return le(r,n,t)}function Iw(e,t){const[r,...n]=Bp(e);return ze(r,n,t)}var mt={},Wt={},Mu;function Pw(){if(Mu)return Wt;Mu=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.sync=Wt.isexe=void 0;const e=je,t=_p,r=async(s,l={})=>{const{ignoreErrors:u=!1}=l;try{return i(await(0,t.stat)(s),l)}catch(a){const c=a;if(u||c.code==="EACCES")return!1;throw c}};Wt.isexe=r;const n=(s,l={})=>{const{ignoreErrors:u=!1}=l;try{return i((0,e.statSync)(s),l)}catch(a){const c=a;if(u||c.code==="EACCES")return!1;throw c}};Wt.sync=n;const i=(s,l)=>s.isFile()&&o(s,l),o=(s,l)=>{const u=l.uid??process.getuid?.(),a=l.groups??process.getgroups?.()??[],c=l.gid??process.getgid?.()??a[0];if(u===void 0||c===void 0)throw new Error("cannot get uid or gid");const m=new Set([c,...a]),p=s.mode,w=s.uid,E=s.gid,d=parseInt("100",8),f=parseInt("010",8),h=parseInt("001",8),y=d|f;return!!(p&h||p&f&&m.has(E)||p&d&&w===u||p&y&&u===0)};return Wt}var Xt={},Gu;function Tw(){if(Gu)return Xt;Gu=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.sync=Xt.isexe=void 0;const e=je,t=_p,r=async(s,l={})=>{const{ignoreErrors:u=!1}=l;try{return o(await(0,t.stat)(s),s,l)}catch(a){const c=a;if(u||c.code==="EACCES")return!1;throw c}};Xt.isexe=r;const n=(s,l={})=>{const{ignoreErrors:u=!1}=l;try{return o((0,e.statSync)(s),s,l)}catch(a){const c=a;if(u||c.code==="EACCES")return!1;throw c}};Xt.sync=n;const i=(s,l)=>{const{pathExt:u=process.env.PATHEXT||""}=l,a=u.split(";");if(a.indexOf("")!==-1)return!0;for(let c=0;c<a.length;c++){const m=a[c].toLowerCase(),p=s.substring(s.length-m.length).toLowerCase();if(m&&p===m)return!0}return!1},o=
Consider to rely on 'then' or 'done' mode instead.`);b&&(delete c[w],m[w]=_,a.emit("setasync",w,b))},y=function(){f=!0,c[w]&&(delete c[w],delete p[w],a.delete(w))},v=u;if(v||(v="then"),v==="then"){var S=function(){o(y)};d=d.then(function(_){o(h.bind(this,_))},S),typeof d.finally=="function"&&d.finally(S)}else if(v==="done"){if(typeof d.done!="function")throw new Error("Memoizee error: Retrieved promise does not implement 'done' in 'done' mode");d.done(h,y)}else if(v==="done:finally"){if(typeof d.done!="function")throw new Error("Memoizee error: Retrieved promise does not implement 'done' in 'done:finally' mode");if(typeof d.finally!="function")throw new Error("Memoizee error: Retrieved promise does not implement 'finally' in 'done:finally' mode");d.done(h),d.finally(y)}}),a.on("get",function(w,E,d){var f;if(c[w]){++c[w];return}f=p[w];var h=function(){a.emit("getasync",w,E,d)};i(f)?typeof f.done=="function"?f.done(h):f.then(function(){o(h)}):h()}),a.on("delete",function(w){if(delete p[w],c[w]){delete c[w];return}if(hasOwnProperty.call(m,w)){var E=m[w];delete m[w],a.emit("deleteasync",w,[E])}}),a.on("clear",function(){var w=m;m=s(null),c=s(null),p=s(null),a.emit("clearasync",e(w,function(E){return[E]}))})},uf}var wf={},gf;function Mg(){if(gf)return wf;gf=1;var e=jt(),t=qn(),r=ir(),n=Function.prototype.apply;return r.dispose=function(i,o,s){var l;if(e(i),s.async&&r.async||s.promise&&r.promise){o.on("deleteasync",l=function(u,a){n.call(i,null,a)}),o.on("clearasync",function(u){t(u,function(a,c){l(c,a)})});return}o.on("delete",l=function(u,a){i(a)}),o.on("clear",function(u){t(u,function(a,c){l(c,a)})})},wf}var _f={},_o,Ef;function Gg(){return Ef||(Ef=1,_o=2147483647),_o}var Eo,Sf;function Vg(){if(Sf)return Eo;Sf=1;var e=nr(),t=Gg();return Eo=function(r){if(r=e(r),r>t)throw new TypeError(r+" exceeds maximum possible timeout");return r},Eo}var bf;function Bg(){if(bf)return _f;bf=1;var e=Ua(),t=qn(),r=Ma(),n=oh(),i=Vg(),o=ir(),s=Function.prototype,l=Math.max,u=Math.min,a=Object.create;return o.maxAge=function(c,m,p){var w,E,d,f;c=i(c),c&&(w=a(null),E=p.async&&o.async||p.promise&&o.promise?"async":"",m.on("set"+E,function(h){w[h]=setTimeout(function(){m.delete(h)},c),typeof w[h].unref=="function"&&w[h].unref(),f&&(f[h]&&f[h]!=="nextTick"&&clearTimeout(f[h]),f[h]=setTimeout(function(){delete f[h]},d),typeof f[h].unref=="function"&&f[h].unref())}),m.on("delete"+E,function(h){clearTimeout(w[h]),delete w[h],f&&(f[h]!=="nextTick"&&clearTimeout(f[h]),delete f[h])}),p.preFetch&&(p.preFetch===!0||isNaN(p.preFetch)?d=.333:d=l(u(Number(p.preFetch),1),0),d&&(f={},d=(1-d)*c,m.on("get"+E,function(h,y,v){f[h]||(f[h]="nextTick",r(function(){var S;f[h]==="nextTick"&&(delete f[h],m.delete(h),p.async&&(y=e(y),y.push(s)),S=m.memoized.apply(v,y),p.promise&&n(S)&&(typeof S.done=="function"?S.done(s,s):S.then(s,s)))}))}))),m.on("clear"+E,function(){t(w,function(h){clearTimeout(h)}),w={},f&&(t(f,function(h){h!=="nextTick"&&clearTimeout(h)}),f={})}))},_f}var Rf={},So,$f;function Hg(){if($f)return So;$f=1;var e=nr(),t=Object.create,r=Object.prototype.hasOwnProperty;return So=function(n){var i=0,o=1,s=t(null),l=t(null),u=0,a;return n=e(n),{hit:function(c){var m=l[c],p=++u;if(s[p]=c,l[c]=p,!m)return++i,i<=n?void 0:(c=s[o],a(c),c);if(delete s[m],o===m)for(;!r.call(s,++o););},delete:a=function(c){var m=l[c];if(m&&(delete s[m],delete l[c],--i,o===m)){if(!i){u=0,o=1;return}for(;!r.call(s,++o););}},clear:function(){i=0,o=1,s=t(null),l=t(null),u=0}}},So}var Of;function zg(){if(Of)return Rf;Of=1;var e=nr(),t=Hg(),r=ir();return r.max=function(n,i,o){var s,l,u;n=e(n),n&&(l=t(n),s=o.async&&r.async||o.promise&&r.promise?"async":"",i.on("set"+s,u=function(a){a=l.hit(a),a!==void 0&&i.delete(a)}),i.on("get"+s,u),i.on("delete"+s,l.delete),i.on("clear"+s,l.clear))},Rf}var If={},Pf;function Wg(){if(Pf)return If;Pf=1;var e=sr(),t=ir(),r=Object.create,n=Object.defineProperties;return t.refCounter=function(i,o,s){var l,u;l=r(null),u=s.async&&t.async||s.promise&&t.promise?"async":"",o.on("set"+u,function(a,c){l[a]=c||1}),o.on("get"+u,function(a){++l[a]}),o.on("delete"+u,funct
# ${i}
if [[ "$SOURCE_${i.toUpperCase()}RC" != 0 && -f "${n}" ]]; then source "${n}"; fi
`;try{await Promise.all([r_(e),xf(o,t),xf(o,r)])}catch(s){ve(`Failed to add ${o} to .profile or .bashrc. You should add it manually: ${s}`)}}const Va=Fe(t_,{promise:!0});async function r_(e){const t=e.guard===void 0?`
# Automatically Generated by envosman
`:`
# Automatically Generated by envosman ${e.guard}
export SOURCE_${e.guard.toUpperCase()}RC=0
2025-07-10 22:11:16 +08:00
`;await ye(e.rcPath)&&((await Ga(e.rcPath,"utf8")).includes(t)||(await ah(e.rcPath,`
${t}
2025-07-10 22:11:16 +08:00
`),z(`Added ${t} to ${e.rcPath}`)))}async function xf(e,t){await ye(t)&&((await Ga(t,"utf-8")).includes(e)||(await ah(t,e),z(`${e} was added to ${t}`)))}async function n_(e){if(await ye(e.rcPath)){const t=(await Ga(e.rcPath,"utf-8")).split(`
`),r=[...new Set(t.reverse())].reverse();await Zg(e.rcPath,r.join(`
`)),await Er(e.rcPath)}}var Ro,Af;function i_(){if(Af)return Ro;Af=1;const e=it,t=e.platform()!=="win32",r=e.release(),n=/(\d+\.\d+)\.(\d+)/,i=(o="",s="")=>/1\d+\.\d+/.test(o)&&Number(s)>=17134.1184;return Ro=function(o){return t?o.replace(/(\s+)/g,"\\$1"):i(...n.exec(r).splice(1))?o:o.replace(/(\s+)/g,"%20")},Ro}var s_=i_();const o_=$e(s_);var an={exports:{}},$o,Cf;function a_(){if(Cf)return $o;Cf=1;var e=/[|\\{}()[\]^$+*?.]/g;return $o=function(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(e,"\\$&")},$o}var c_=an.exports,Nf;function u_(){return Nf||(Nf=1,function(){var e,t;e=a_(),t=function(r){return r.split("").reverse().join("")},an.exports=function(r,n,i){var o;return n==null&&(n="'"),i==null&&(i="\\"),typeof r!="string"?r:(o=new RegExp("(["+e(n)+"])(?!"+e(i)+")","g"),t(t(r).replace(o,"$1"+i)))}}.call(c_)),an.exports}var l_=u_();const f_=$e(l_);function d_(e,t=!1){const r=t?o_(e):e;return f_(r,'"',"\\")}const{GITHUB_ACTIONS:p_}=xt,{appendFile:Lf}=Pn;async function Ie(e,t,r={}){const n={escapeSpace:!1,overwrite:!0,rcPath:ch,...r},i=d_(t??"",n.escapeSpace);try{if(p_)try{if(!n.overwrite&&process.env[e]!==void 0){z(`Environment variable ${e} is already defined. Skipping.`);return}Ee.exportVariable(e,i)}catch(o){Ae(o),await Df(e,i,n)}else await Df(e,i,n)}catch(o){Ae(`${o}
Failed to export environment variable ${e}=${i}. You should add it manually.`)}}async function Df(e,t,r){const n=t??"";switch(process.platform){case"win32":{if(!r.overwrite&&process.env[e]!==void 0){z(`Environment variable ${e} is already defined. Skipping.`);return}await Wp(`[Environment]::SetEnvironmentVariable('${e}', '${n}', "User")`),z(`${e}='${n}' was set in the environment.`);return}case"linux":case"darwin":{await Va(r),r.overwrite?(await Lf(r.rcPath,`
export ${e}="${n}"
2025-07-10 22:11:16 +08:00
`),z(`${e}="${n}" was added to "${r.rcPath}`)):(await Lf(r.rcPath,`
if [ -z "\${${e}}" ]; then export ${e}="${n}"; fi
2025-07-10 22:11:16 +08:00
`),z(`if not defined ${e} then ${e}="${n}" was added to "${r.rcPath}`)),process.env[e]=n;return}}process.env[e]=n}const{GITHUB_ACTIONS:h_}=xt,{appendFile:m_}=Pn;async function Re(e,t={}){const r={rcPath:ch,...t};if(!v_(e)){process.env.PATH=`${e}${mn}${process.env.PATH}`;try{if(h_)try{Ee.addPath(e)}catch(n){Ae(n),await kf(e,r)}else await kf(e,r)}catch(n){Ae(`${n}
Failed to add ${e} to the percistent PATH. You should add it manually.`)}}}async function kf(e,t){switch(process.platform){case"win32":{await Wp(`$USER_PATH=([Environment]::GetEnvironmentVariable("PATH", "User")); [Environment]::SetEnvironmentVariable("PATH", "${e};$USER_PATH", "User")`),z(`"${e}" was added to the PATH.`);return}case"linux":case"darwin":{await Va(t),await m_(t.rcPath,`
export PATH="${e}:$PATH"
2025-07-10 22:11:16 +08:00
`),z(`"${e}" was added to "${t.rcPath}"`);return}default:return}}const y_=[/\/usr\/bin\/?/,/\/usr\/local\/bin\/?/];function v_(e){return y_.some(t=>t.test(e))?(process.env.PATH?.split(mn)??[]).includes(e):!1}function Ba(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var cn={exports:{}},w_=cn.exports,Ff;function uh(){return Ff||(Ff=1,function(e){(function(){var t={},r={create:n,addLocale:i,pluralize:o};e.exports=r;function n(a){return l(a),{pluralize:function(c,m){return o(a,c,m)}}}function i(a,c){t[a]=c}function o(a,c,m){if(l(a),typeof m!="object")throw new Error("List of variants should be specified as an object");var p=t[a](c);return typeof m[p]<"u"?m[p]:null}function s(a){return typeof t[a]<"u"}function l(a){s(a)||u(a)}function u(a){try{Ba(__dirname+"/../locales/"+a+".js")}catch{throw Error("Failed to load the following locale: "+a)}}}).call(w_)}(cn)),cn.exports}var Oo,qf;function lh(){return qf||(qf=1,Oo=uh()),Oo}var g_=lh();const __=$e(g_);var Io={},Uf;function E_(){return Uf||(Uf=1,function(){var e=this,t;typeof Ba=="function"?t=uh():t=e.numerous,t.addLocale("en",function(n){var i=Math.floor(Math.abs(n)),o=n.toString().replace(/^[^.]*\.?/,"").length;return typeof n=="string"&&(n=parseInt(n,10)),i===1&&o===0?"one":"other"})}.call(Io)),Io}var S_=E_();const b_=$e(S_);var Po={exports:{}},jf;function R_(){return jf||(jf=1,function(e,t){e.exports=!!(typeof process<"u"&&process.versions&&process.versions.node)}(Po)),Po.exports}var To,Mf;function $_(){if(Mf)return To;Mf=1;const e=lh(),t=R_(),r=[["years",12*4*7*24*60*60*1e3],["months",4*7*24*60*60*1e3],["weeks",7*24*60*60*1e3],["days",24*60*60*1e3],["hours",60*60*1e3],["minutes",60*1e3],["seconds",1e3]],n={locale:"en",span:2,delimiter:", ",unitType:"long",unitTypeLookupOrder:["long","short","narrow"],autoloadLocales:!0},i={};To={create:s,addLocale:o,defaultConfig:n};function o(d){Array.isArray(d)||(d=[d]);for(const f of d){const{id:h,data:y}=f;i[h]=y}}function s(d){return d=Object.assign({},n,d||{}),{format:function(f,h,y){return y=Object.assign({},d,y||{}),l(f,h,y)}}}function l(d,f,h){if(u(h.locale,{autoload:h.autoloadLocales}),!d)throw new Error("Missing first date argument");if(!f)throw new Error("Missing second date argument");const y=m(d,f),v=[];for(const S of y){const[_,b]=S;if(b>0&&v.push(p(_,b,h)),v.length>=h.span)break}return v.join(h.delimiter)}function u(d,f){const{autoload:h}=f;if(!a(d))if(t&&h)c(d);else throw new Error(`Missing locale: ${d}, you must load it manually before using it`)}function a(d){return!!i[d]}function c(d){try{o(Ba(`../locales/${d}.js`))}catch(f){throw Error(`Failed to load locale: ${d} from ../locales/${d}.js. If using a bundled time-delta, set 'autoloadLocales: false' in the config: ${f}`)}}function m(d,f){let h=f-d;const y=[];return r.some(function(v){const S=v[0],_=v[1],b=Math.floor(h/_);if(h-=b*_,y.push([S,b]),h<=0)return!0}),y}function p(d,f,h){const y=w(h);return e.pluralize(h.locale,f,y[d]).replace("{0}",f)}function w(d){const f=i[d.locale];let h=d.unitTypeLookupOrder.slice();h.unshift(d.unitType),h=E(h);let y=null;if(h.some(function(v){if(typeof f[v]<"u")return y=f[v],!0}),y===null)throw new Error("Can not find any unit type data for locale: "+d.locale);return y}function E(d){return Array.from(new Set(d))}return To}var xo,Gf;function O_(){return Gf||(Gf=1,xo=$_()),xo}var I_=O_();const Vf=$e(I_);var Ao,Bf;function P_(){return Bf||(Bf=1,Ao={id:"en",data:{long:{years:{one:"{0} year",other:"{0} years"},months:{one:"{0} month",other:"{0} months"},weeks:{one:"{0} week",other:"{0} weeks"},days:{one:"{0} day",other:"{0} days"},hours:{one:"{0} hour",other:"{0} hours"},minutes:{one:"{0} minute",other:"{0} minutes"},seconds:{one:"{0} second",other:"{0} seconds"}},narrow:{years:{one:"{0}y",other:"{0}y"},months:{one:"{0}m",other:"{0}m"},weeks:{one:"{0}w",other:"{0}w"},days:{one:"{0}d",other:"{0}d"},hours:{one:"{0}h",other:"{0}h"},minutes:{one:"{0}m",other:"{0}m"},seconds:{one:"{0}s",
`),await En.clear(),await En(),z(`Successfully added repository: ${e}`),!0}catch(t){throw new Error(`Failed to add repository ${e}: ${t}`)}}async function bh(){const e=(await z_()).split(".").slice(0,2).join(".");return H_(`https://dl-cdn.alpinelinux.org/alpine/v${e}/community/`)}async function z_(){const e="/etc/alpine-release";if(!await ye(e))throw new Error(`Alpine release file not found at ${e}`);return pr(e,"utf8")}async function W_(e){try{const{exitCode:t}=await wt("apk",["info","-e",e.name],{reject:!1,stdio:["ignore","pipe","ignore"]});if(t!==0)return!1;if(e.version===void 0||e.version==="")return!0;const{stdout:r}=await wt("apk",["info","-v",e.name],{stdio:["ignore","pipe","ignore"]});return r.trim().split("-").slice(-1)[0]===e.version}catch{return!1}}async function Rh(e){return(await Promise.all(e.map(async r=>await W_(r)?void 0:r))).filter(r=>r!==void 0).map($h)}function $h(e){return e.version!==void 0&&e.version!==""?`${e.name}=${e.version}`:e.name}async function X_(){const e=await Rh([{name:"bash"}]);e.length!==0&&he("apk",["add",...e],{...st})}const K_=Fe(X_,{promise:!0});async function De(e,t=!1){if(!await Oe())throw new Error("apk is not available on this system");try{await K_(),t&&await En.clear(),await En();const r=await Rh(e);return r.length===0?(z("All packages are already installed"),{binDir:"/usr/bin"}):(z(`Installing ${r.join(" ")}`),await wt("apk",["add",...r]),z(`Successfully installed ${r.join(" ")}`),{binDir:"/usr/bin"})}catch(r){throw ve(`Failed to install ${e.map(n=>$h(n)).join(" ")}: ${r}`),r}}const{GITHUB_ACTIONS:Y_}=xt,{appendFile:J_}=Pn;async function Q_(e,t,r=40){await wt("update-alternatives",["--install",`/usr/bin/${e}`,e,t,r.toString()])}async function vt(e,t,r,n=40){Y_?await Q_(e,t,n):(await Va(r),await J_(r.rcPath,`
if [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${e} ${e} ${t} ${n}; fi
2025-07-10 22:11:16 +08:00
`))}var No={},Wf;function Z_(){return Wf||(Wf=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DownloaderHelper=e.DH_STATES=void 0;var t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(y){return typeof y}:function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y},r=function(){function y(v,S){for(var _,b=0;b<S.length;b++)_=S[b],_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(v,_.key,_)}return function(v,S,_){return S&&y(v.prototype,S),_&&y(v,_),v}}(),n=je,i=w(n),o=Jm,s=ue,l=w(s),u=yp,a=w(u),c=Pa,m=w(c),p=Tn;function w(y){if(y&&y.__esModule)return y;var v={};if(y!=null)for(var S in y)Object.prototype.hasOwnProperty.call(y,S)&&(v[S]=y[S]);return v.default=y,v}function E(y,v){if(!(y instanceof v))throw new TypeError("Cannot call a class as a function")}function d(y,v){if(!y)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:y}function f(y,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);y.prototype=Object.create(v&&v.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(y,v):y.__proto__=v)}var h=e.DH_STATES={IDLE:"IDLE",SKIPPED:"SKIPPED",STARTED:"STARTED",DOWNLOADING:"DOWNLOADING",RETRY:"RETRY",PAUSED:"PAUSED",RESUMED:"RESUMED",STOPPED:"STOPPED",FINISHED:"FINISHED",FAILED:"FAILED"};e.DownloaderHelper=function(y){function v(S,_){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{};E(this,v);var g=d(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,{captureRejections:!0}));return g.__validate(S,_)?(g.url=g.requestURL=S.trim(),g.state=h.IDLE,g.__defaultOpts={body:null,retry:!1,method:"GET",headers:{},fileName:"",timeout:-1,metadata:null,override:!1,forceResume:!1,removeOnStop:!0,removeOnFail:!0,progressThrottle:1e3,httpRequestOptions:{},httpsRequestOptions:{},resumeOnIncomplete:!0,resumeIfFileExists:!1,resumeOnIncompleteMaxRetry:5},g.__opts=Object.assign({},g.__defaultOpts),g.__pipes=[],g.__total=0,g.__downloaded=0,g.__progress=0,g.__retryCount=0,g.__retryTimeout=null,g.__resumeRetryCount=0,g.__states=h,g.__promise=null,g.__request=null,g.__response=null,g.__isAborted=!1,g.__isResumed=!1,g.__isResumable=!1,g.__isRedirected=!1,g.__destFolder=_,g.__statsEstimate={time:0,bytes:0,prevBytes:0,throttleTime:0},g.__fileName="",g.__filePath="",g.updateOptions(b),g):d(g)}return f(v,y),r(v,[{key:"start",value:function(){var _=this,b=function(){return new Promise(function(g,$){_.__promise={resolve:g,reject:$},_.__start()})};return this.__opts.resumeIfFileExists&&this.state!==this.__states.RESUMED?this.getTotalSize().then(function(g){var $=g.name,I=g.total,A=_.__opts.override;if(_.__opts.override=!0,_.__filePath=_.__getFilePath($),_.__opts.override=A,_.__filePath&&i.existsSync(_.__filePath)){var M=_.__getFilesizeInBytes(_.__filePath);return M===I?b():_.resumeFromFile(_.__filePath,{total:I,fileName:$})}return b()}):b()}},{key:"pause",value:function(){var _=this;return this.state===this.__states.STOPPED?Promise.resolve(!0):(this.__response&&(this.__response.unpipe(),this.__pipes.forEach(function(b){return b.stream.unpipe()})),this.__fileStream&&this.__fileStream.removeAllListeners(),this.__requestAbort(),this.__closeFileStream().then(function(){return _.__setState(_.__states.PAUSED),_.emit("pause"),!0}))}},{key:"resume",value:function(){return this.__promise?this.state===this.__states.STOPPED?Promise.resolve(!1):(this.__setState(this.__states.RESUMED),this.__isResumable&&(this.__isResumed=!0,this.__reqOptions.headers.range="bytes="+this.__downloaded+"-"),this.emit("resume",this.__isResumed),this.__start()):this.start()}},{key:"stop",value:function(){var _=this;if(this.state===this.__states.STOPPED)return Promise.resolve(!0);var b=function(){return new Promise(function(g,$){i.access(_.__filePath,function(I){return I?(_.__emitStop(),g(!0)):void i.unlink(_
`).some(n=>n.startsWith("Status: install ok installed"))}catch{return!1}}async function iE(e){try{const{stdout:t}=await le("dpkg",["-l",e],{env:lt("apt-get"),stdio:"pipe"});return typeof t!="string"?!1:t.split(`
`).some(n=>n.startsWith("ii"))}catch{return!1}}let xh=!1;function sE(e=Gr()){he(e,["update","-o",Rr],{...st,env:lt(e)}),xh=!0}const hr=Fe(sE);var It;(function(e){e[e.NameDashVersion=0]="NameDashVersion",e[e.NameEqualsVersion=1]="NameEqualsVersion",e[e.Name=2]="Name",e[e.None=3]="None"})(It||(It={}));async function Ah(e,t=Gr()){return(await Promise.all(e.map(r=>ba(r,t)))).filter(r=>r!==void 0)}async function ba(e,t=Gr()){const r=await aE(t,e);return await Ha(r)?void 0:r}async function Ch(e,t,r,n){const i=r!==void 0&&r!=="",o=!i||n;if(i){if(await oE(e,t,r))return It.NameDashVersion;if(await Kf(e,`${t}=${r}`))return It.NameEqualsVersion}const s=()=>{i&&n&&z(`Could not find package ${t} ${r}. Falling back to latest version.`)};return o&&await Kf(e,t)?(s(),It.Name):xh?o?(s(),It.Name):It.None:(hr(e),Ch(e,t,r,n))}async function oE(e,t,r){try{const{stdout:n}=await le("apt-cache",["search","--names-only",`^${_n(t)}-${_n(r)}$`],{env:lt(e),stdio:"pipe"});if(n.trim()!=="")return!0}catch{}return!1}async function Kf(e,t){try{const{stdout:r}=await le("apt-cache",["show",t],{env:lt(e),stdio:"pipe",verbose:!0});if(r.trim()!=="")return!0}catch{}return!1}async function aE(e,t){const{name:r,version:n,fallBackToLatest:i=!1}=t;switch(await Ch(e,r,n,i)){case It.NameDashVersion:return`${r}-${n}`;case It.NameEqualsVersion:return`${r}=${n}`;case It.Name:return r;default:throw new Error(`Could not find package '${r}' ${n??"with unspecified version"}`)}}async function cE(e){hr(e);const t=await Ah([{name:"ca-certificates"},{name:"gnupg"},{name:"apt-utils"}],e);t.length!==0&&he(e,["install","-y","--fix-broken","-o",Rr,...t],{...st,env:lt(e)})}const Nh=Fe(cE,{promise:!0});function uE(e="apt-get"){try{const{stdout:t}=he("add-apt-repository",["--help"],{...st,env:lt(e),stdio:"pipe"});return t.includes("--no-update")}catch{return!1}}const Lh=Fe(uE);async function lE(e,t=Gr()){await Nh(t),await Dh();try{he("add-apt-repository",["-y",Lh(t)?"--no-update":void 0,e].filter(r=>r!==void 0),{...st,env:lt(t)})}catch{he("add-apt-repository",["-y",e],{...st,env:lt(t)})}hr.clear(),hr(t)}async function Dh(){if(await Ha("software-properties-common"))return;const e="apt-get";he(e,["install","-y","--fix-broken","-o",Rr,"software-properties-common"],{...st,env:lt(e)})}const fE=["E: Could not get lock","dpkg: error processing archive","dpkg: error: dpkg status database is locked by another process"];async function de(e,t=!1){try{const r=Gr();for(const{name:i,version:o}of e)z(`Installing ${i} ${o??""} via ${r}`);t&&hr.clear(),hr(r),await dE(r,e);const n=await Ah(e,r);if(n.length===0)return z("All packages are already installed"),{binDir:"/usr/bin/"};await Nh(r);try{await pE(e),he(r,["install","--fix-broken","-y",...n],{...st,env:lt(r)})}catch(i){if(hE(i))fE.some(o=>typeof i.stderr=="string"&&i.stderr.includes(o))&&(ve(`Failed to install packages ${n}. Retrying...`),he(r,["install","--fix-broken","-y","-o",Rr,...n],{...st,env:lt(r)}));else throw i}return{binDir:"/usr/bin/"}}catch(r){const n=r instanceof Error?`${r.message}
${r.stack}`:String(r);throw new Error(`Failed to install apt packages: ${n}`)}}async function dE(e,t){const r=[...new Set(t.flatMap(n=>n.repository??[]))];await Promise.all(r.map(n=>lE(n,e)))}async function pE(e){await Promise.all(e.map(async t=>{t.key!==void 0&&await tE(t.key)}))}function hE(e){return typeof e.stderr=="string"}let ur;async function Yf(){if(!me())return;if(typeof ur=="string")return{binDir:ur};const e=fe.sync("apt-fast",{nothrow:!0});return e!==null?(ur=be(e),{binDir:ur}):(ur="/usr/bin",await mE(),{binDir:ur})}async function mE(){const e=de([{name:"bash"},{name:"wget"}]),t=new br.DownloaderHelper("https://raw.githubusercontent.com/ilikenwf/apt-fast/c2cd0a0420d3f2d647dc82cf749bfd58c4697dac/quick-install.sh",Ue(),{fileName:"install-apt-fast.sh"});t.on("error",u=>{throw new Error(`Failed to download install-apt-fast.sh: ${u}`)}),await t.start();const r=J(Ue(),"install-apt-fast.sh");let n=await pr(r,"utf8");n=n.replace(/sudo/g,"").replace("https://raw.githubusercontent.com/ilikenwf/apt-fast/master","https://raw.githubusercontent.com/Rongronggg9/apt-fast/ac82051792f764220e5e303d4560de0f1952826b"),await yn(r,n),await e;try{he("bash",[r])}catch(u){Ae(`Failed to install apt-fast via installer: ${u}`)}const i="/etc/apt-fast.conf";let o=await pr(i,"utf8");const s=["_APTMGR","DOWNLOADBEFORE"];for(const u of s)o=o.replace(new RegExp(`^#\\s*${u}`,"m"),u);const l=J(Ue(),"apt-fast.conf");await yn(l,o),he("mv",[l,i])}let kt;async function yE({version:e}={}){if(!me())return;if(typeof kt=="string")return{binDir:kt};const t=fe.sync("nala",{nothrow:!0});if(t!==null)return kt=be(t),{binDir:kt};await de([{name:"python3-apt"}]),kt="/usr/bin";try{const r=await ba({name:"nala",version:e});if(r!==void 0)return await de([{name:r}]),{binDir:kt}}catch(r){z(`Failed to install nala: ${r}`)}try{const r=await ba({name:"nala-legacy"});if(r!==void 0)return await de([{name:r}],!0),{binDir:kt}}catch(r){z(`Failed to install nala-legacy: ${r}`)}return await vE(),{binDir:kt}}async function vE(){const e=new br.DownloaderHelper("https://gitlab.com/volian/volian-archive/-/raw/1939afc3f80638dca2bbedde74bbd86731703cc8/install-nala.sh",Ue(),{fileName:"install-nala.sh"});e.on("error",n=>{throw new Error(`Failed to download install-nala.sh: ${n}`)}),await e.start();const t=J(Ue(),"install-nala.sh"),r=await pr(t,"utf8");await yn(t,r.replace(/sudo/g,"")),await de([{name:"wget"}]);try{he("bash",[t])}catch(n){Ae(`Failed to install nala via installer: ${n}`),he("apt",["install","-y","-t","nala","nala"])}}let Yt;async function za(e={}){if(!["darwin","linux"].includes(process.platform)||process.platform==="linux"&&process.arch!=="x64"){ve(`Brew is not supported on ${process.platform} ${process.arch}`);return}if(typeof Yt=="string")return{binDir:Yt};const t=await fe("brew",{nothrow:!0});if(t!==null)return Yt=be(t),{binDir:Yt};await de([{name:"ca-certificates"}]);const r=new br.DownloaderHelper("https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh",Ue(),{fileName:"install-brew.sh"});return r.on("error",n=>{throw new Error(`Failed to download the brew installer script: ${n}`)}),await r.start(),ze("/bin/bash",[r.getDownloadPath()],{stdio:"inherit",env:{NONINTERACTIVE:"1"}}),Yt=Wa(),await Re(Yt,e.rcOptions),{binDir:Yt}}function Wa(){return J(Xa(),"bin")}function kh(){return J(Wa(),"brew")}function Xa(){if(process.platform==="darwin")return process.arch==="arm64"?"/opt/homebrew":"/usr/local";if(process.platform==="linux")return"/home/linuxbrew/.linuxbrew";throw new Error("Unsupported platform for brew")}function Fh(e,t){return t!==void 0&&t!==""?`${e}@${t}`:e}async function wE(e,t){const r=Fh(e,t),n=await Jf(r);if(n!==void 0)return n;const i=await Jf(e);return i!==void 0?i:gE(e,r)}async function Jf(e){try{const t=kh();return(await le(t,["--prefix",e],{stdio:"pipe"})).stdout}catch{return}}function gE(e,t){const r=Xa(),n=J(r,"opt",t);if(Qt(n))return n;const i=J(r,"opt",e);if(Qt(i))return i;const o=J(r,"Cellar",t);if(Qt(o))return o;const s=J(r,"Cellar",e);if(Qt(s))return s;const l=J(r,"lib",t);if(Qt(l))return l;const u=J(r,"lib",e);if(Qt(u))return u}le
GFS4: `),console.error(f)}),!e[o]){var c=at[o]||[];u(e,c),e.close=function(f){function h(y,v){return f.call(e,y,function(S){S||E(),typeof v=="function"&&v.apply(this,arguments)})}return Object.defineProperty(h,s,{value:f}),h}(e.close),e.closeSync=function(f){function h(y){f.apply(e,arguments),E()}return Object.defineProperty(h,s,{value:f}),h}(e.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){a(e[o]),qr.equal(e[o].length,0)})}at[o]||u(at,e[o]),tn=m(n(e)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!e.__patched&&(tn=m(e),e.__patched=!0);function m(f){t(f),f.gracefulify=m,f.createReadStream=H,f.createWriteStream=W;var h=f.readFile;f.readFile=y;function y(X,ie,se){return typeof ie=="function"&&(se=ie,ie=null),we(X,ie,se);function we(D,L,N,j){return h(D,L,function(B){B&&(B.code==="EMFILE"||B.code==="ENFILE")?p([we,[D,L,N],B,j||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var v=f.writeFile;f.writeFile=S;function S(X,ie,se,we){return typeof se=="function"&&(we=se,se=null),D(X,ie,se,we);function D(L,N,j,B,ee){return v(L,N,j,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?p([D,[L,N,j,B],Y,ee||Date.now(),Date.now()]):typeof B=="function"&&B.apply(this,arguments)})}}var _=f.appendFile;_&&(f.appendFile=b);function b(X,ie,se,we){return typeof se=="function"&&(we=se,se=null),D(X,ie,se,we);function D(L,N,j,B,ee){return _(L,N,j,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?p([D,[L,N,j,B],Y,ee||Date.now(),Date.now()]):typeof B=="function"&&B.apply(this,arguments)})}}var g=f.copyFile;g&&(f.copyFile=$);function $(X,ie,se,we){return typeof se=="function"&&(we=se,se=0),D(X,ie,se,we);function D(L,N,j,B,ee){return g(L,N,j,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?p([D,[L,N,j,B],Y,ee||Date.now(),Date.now()]):typeof B=="function"&&B.apply(this,arguments)})}}var I=f.readdir;f.readdir=M;var A=/^v[0-5]\./;function M(X,ie,se){typeof ie=="function"&&(se=ie,ie=null);var we=A.test(process.version)?function(N,j,B,ee){return I(N,D(N,j,B,ee))}:function(N,j,B,ee){return I(N,j,D(N,j,B,ee))};return we(X,ie,se);function D(L,N,j,B){return function(ee,Y){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?p([we,[L,N,j],ee,B||Date.now(),Date.now()]):(Y&&Y.sort&&Y.sort(),typeof j=="function"&&j.call(this,ee,Y))}}}if(process.version.substr(0,4)==="v0.8"){var K=r(f);U=K.ReadStream,G=K.WriteStream}var Q=f.ReadStream;Q&&(U.prototype=Object.create(Q.prototype),U.prototype.open=k);var x=f.WriteStream;x&&(G.prototype=Object.create(x.prototype),G.prototype.open=C),Object.defineProperty(f,"ReadStream",{get:function(){return U},set:function(X){U=X},enumerable:!0,configurable:!0}),Object.defineProperty(f,"WriteStream",{get:function(){return G},set:function(X){G=X},enumerable:!0,configurable:!0});var T=U;Object.defineProperty(f,"FileReadStream",{get:function(){return T},set:function(X){T=X},enumerable:!0,configurable:!0});var F=G;Object.defineProperty(f,"FileWriteStream",{get:function(){return F},set:function(X){F=X},enumerable:!0,configurable:!0});function U(X,ie){return this instanceof U?(Q.apply(this,arguments),this):U.apply(Object.create(U.prototype),arguments)}function k(){var X=this;ce(X.path,X.flags,X.mode,function(ie,se){ie?(X.autoClose&&X.destroy(),X.emit("error",ie)):(X.fd=se,X.emit("open",se),X.read())})}function G(X,ie){return this instanceof G?(x.apply(this,arguments),this):G.apply(Object.create(G.prototype),arguments)}function C(){var X=this;ce(X.path,X.flags,X.mode,function(ie,se){ie?(X.destroy(),X.emit("error",ie)):(X.fd=se,X.emit("open",se))})}function H(X,ie){return new f.ReadStream(X,ie)}function W(X,ie){return new f.WriteStream(X,ie)}var re=f.open;f.open=ce;function ce(X,ie,se,we){return typeof se=="function"&&(we=se,se=null),D(X,ie,se,we);function D(L,N,j,B,ee){return re(L,N,j,function(Y,ke){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?p([D,[L,N,j,B],Y,ee||Date.now(),Date.now()]):typeof B=="function"&&B.apply(this,arguments)})}}return f}function p(f){a("ENQUEUE",f[0].name,f[1]),e[o].push(f),d()}var w;function E(){for(var f=Date.now(),h=0;h<e[o].length;++h)e[o][h].length>2&&
2025-07-10 22:11:16 +08:00
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");const{srcStat:y,destStat:v}=await o.checkPaths(d,f,"copy",h);if(await o.checkParentPaths(d,y,f,"copy"),!await l(d,f,h))return;const _=t.dirname(f);await n(_)||await r(_),await u(v,d,f,h)}async function l(d,f,h){return h.filter?h.filter(d,f):!0}async function u(d,f,h,y){const S=await(y.dereference?e.stat:e.lstat)(f);if(S.isDirectory())return w(S,d,f,h,y);if(S.isFile()||S.isCharacterDevice()||S.isBlockDevice())return a(S,d,f,h,y);if(S.isSymbolicLink())return E(d,f,h,y);throw S.isSocket()?new Error(`Cannot copy a socket file: ${f}`):S.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${f}`):new Error(`Unknown file: ${f}`)}async function a(d,f,h,y,v){if(!f)return c(d,h,y,v);if(v.overwrite)return await e.unlink(y),c(d,h,y,v);if(v.errorOnExist)throw new Error(`'${y}' already exists`)}async function c(d,f,h,y){if(await e.copyFile(f,h),y.preserveTimestamps){m(d.mode)&&await p(h,d.mode);const v=await e.stat(f);await i(h,v.atime,v.mtime)}return e.chmod(h,d.mode)}function m(d){return(d&128)===0}function p(d,f){return e.chmod(d,f|128)}async function w(d,f,h,y,v){f||await e.mkdir(y);const S=[];for await(const _ of await e.opendir(h)){const b=t.join(h,_.name),g=t.join(y,_.name);S.push(l(b,g,v).then($=>{if($)return o.checkPaths(b,g,"copy",v).then(({destStat:I})=>u(I,b,g,v))}))}await Promise.all(S),f||await e.chmod(y,d.mode)}async function E(d,f,h,y){let v=await e.readlink(f);if(y.dereference&&(v=t.resolve(process.cwd(),v)),!d)return e.symlink(v,h);let S=null;try{S=await e.readlink(h)}catch(_){if(_.code==="EINVAL"||_.code==="UNKNOWN")return e.symlink(v,h);throw _}if(y.dereference&&(S=t.resolve(process.cwd(),S)),o.isSrcSubdir(v,S))throw new Error(`Cannot copy '${v}' to a subdirectory of itself, '${S}'.`);if(o.isSrcSubdir(S,v))throw new Error(`Cannot overwrite '${S}' with '${v}'.`);return await e.unlink(h),e.symlink(v,h)}return Ho=s,Ho}var zo,hd;function UE(){if(hd)return zo;hd=1;const e=Vr(),t=ue,r=Ct().mkdirsSync,n=Vh().utimesMillisSync,i=$r();function o(_,b,g){typeof g=="function"&&(g={filter:g}),g=g||{},g.clobber="clobber"in g?!!g.clobber:!0,g.overwrite="overwrite"in g?!!g.overwrite:g.clobber,g.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
2025-07-10 22:11:16 +08:00
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");const{srcStat:$,destStat:I}=i.checkPathsSync(_,b,"copy",g);if(i.checkParentPathsSync(_,$,b,"copy"),g.filter&&!g.filter(_,b))return;const A=t.dirname(b);return e.existsSync(A)||r(A),s(I,_,b,g)}function s(_,b,g,$){const A=($.dereference?e.statSync:e.lstatSync)(b);if(A.isDirectory())return d(A,_,b,g,$);if(A.isFile()||A.isCharacterDevice()||A.isBlockDevice())return l(A,_,b,g,$);if(A.isSymbolicLink())return v(_,b,g,$);throw A.isSocket()?new Error(`Cannot copy a socket file: ${b}`):A.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${b}`):new Error(`Unknown file: ${b}`)}function l(_,b,g,$,I){return b?u(_,g,$,I):a(_,g,$,I)}function u(_,b,g,$){if($.overwrite)return e.unlinkSync(g),a(_,b,g,$);if($.errorOnExist)throw new Error(`'${g}' already exists`)}function a(_,b,g,$){return e.copyFileSync(b,g),$.preserveTimestamps&&c(_.mode,b,g),w(g,_.mode)}function c(_,b,g){return m(_)&&p(g,_),E(b,g)}function m(_){return(_&128)===0}function p(_,b){return w(_,b|128)}function w(_,b){return e.chmodSync(_,b)}function E(_,b){const g=e.statSync(_);return n(b,g.atime,g.mtime)}function d(_,b,g,$,I){return b?h(g,$,I):f(_.mode,g,$,I)}function f(_,b,g,$){return e.mkdirSync(g),h(b,g,$),w(g,_)}function h(_,b,g){const $=e.opendirSync(_);try{let I;for(;(I=$.readSync())!==null;)y(I.name,_,b,g)}finally{$.closeSync()}}function y(_,b,g,$){const I=t.join(b,_),A=t.join(g,_);if($.filter&&!$.filter(I,A))return;const{destStat:M}=i.checkPathsSync(I,A,"copy",$);return s(M,I,A,$)}function v(_,b,g,$){let I=e.readlinkSync(b);if($.dereference&&(I=t.resolve(process.cwd(),I)),_){let A;try{A=e.readlinkSync(g)}catch(M){if(M.code==="EINVAL"||M.code==="UNKNOWN")return e.symlinkSync(I,g);throw M}if($.dereference&&(A=t.resolve(process.cwd(),A)),i.isSrcSubdir(I,A))throw new Error(`Cannot copy '${I}' to a subdirectory of itself, '${A}'.`);if(i.isSrcSubdir(A,I))throw new Error(`Cannot overwrite '${A}' with '${I}'.`);return S(I,g)}else return e.symlinkSync(I,g)}function S(_,b){return e.unlinkSync(b),e.symlinkSync(_,b)}return zo=o,zo}var Wo,md;function Qa(){if(md)return Wo;md=1;const e=Me().fromPromise;return Wo={copy:e(qE()),copySync:UE()},Wo}var Xo,yd;function Mn(){if(yd)return Xo;yd=1;const e=Vr(),t=Me().fromCallback;function r(i,o){e.rm(i,{recursive:!0,force:!0},o)}function n(i){e.rmSync(i,{recursive:!0,force:!0})}return Xo={remove:t(r),removeSync:n},Xo}var Ko,vd;function jE(){if(vd)return Ko;vd=1;const e=Me().fromPromise,t=Xe(),r=ue,n=Ct(),i=Mn(),o=e(async function(u){let a;try{a=await t.readdir(u)}catch{return n.mkdirs(u)}return Promise.all(a.map(c=>i.remove(r.join(u,c))))});function s(l){let u;try{u=t.readdirSync(l)}catch{return n.mkdirsSync(l)}u.forEach(a=>{a=r.join(l,a),i.removeSync(a)})}return Ko={emptyDirSync:s,emptydirSync:s,emptyDir:o,emptydir:o},Ko}var Yo,wd;function ME(){if(wd)return Yo;wd=1;const e=Me().fromPromise,t=ue,r=Xe(),n=Ct();async function i(s){let l;try{l=await r.stat(s)}catch{}if(l&&l.isFile())return;const u=t.dirname(s);let a=null;try{a=await r.stat(u)}catch(c){if(c.code==="ENOENT"){await n.mkdirs(u),await r.writeFile(s,"");return}else throw c}a.isDirectory()?await r.writeFile(s,""):await r.readdir(u)}function o(s){let l;try{l=r.statSync(s)}catch{}if(l&&l.isFile())return;const u=t.dirname(s);try{r.statSync(u).isDirectory()||r.readdirSync(u)}catch(a){if(a&&a.code==="ENOENT")n.mkdirsSync(u);else throw a}r.writeFileSync(s,"")}return Yo={createFile:e(i),createFileSync:o},Yo}var Jo,gd;function GE(){if(gd)return Jo;gd=1;const e=Me().fromPromise,t=ue,r=Xe(),n=Ct(),{pathExists:i}=or(),{areIdentical:o}=$r();async function s(u,a){let c;try{c=await r.lstat(a)}catch{}let m;try{m=await r.lstat(u)}catch(E){throw E.message=E.message.replace("lstat","ensureLink"),E}if(c&&o(m,c))return;const p=t.dirname(a);await i(p)||await n.mkdirs(p),await r.link(u,a)}function l(u,a){let c;try{c=r.lstatSync(a)}catch{}try{const w=r.lstatSync(u);if(c&&o(w,c))return}catch(w){throw w.message=w.message.replace("lstat","ensureLink"),w}const m=t.dirname(a);return r.existsSync(m)||n.mkdirsSync(m),r.linkSync
`,finalEOL:i=!0,replacer:o=null,spaces:s}={}){const l=i?n:"";return JSON.stringify(r,o,s).replace(/\n/g,n)+l}function t(r){return Buffer.isBuffer(r)&&(r=r.toString("utf8")),r.replace(/^\uFEFF/,"")}return ra={stringify:e,stripBom:t},ra}var na,$d;function WE(){if($d)return na;$d=1;let e;try{e=Vr()}catch{e=je}const t=Me(),{stringify:r,stripBom:n}=Za();async function i(m,p={}){typeof p=="string"&&(p={encoding:p});const w=p.fs||e,E="throws"in p?p.throws:!0;let d=await t.fromCallback(w.readFile)(m,p);d=n(d);let f;try{f=JSON.parse(d,p?p.reviver:null)}catch(h){if(E)throw h.message=`${m}: ${h.message}`,h;return null}return f}const o=t.fromPromise(i);function s(m,p={}){typeof p=="string"&&(p={encoding:p});const w=p.fs||e,E="throws"in p?p.throws:!0;try{let d=w.readFileSync(m,p);return d=n(d),JSON.parse(d,p.reviver)}catch(d){if(E)throw d.message=`${m}: ${d.message}`,d;return null}}async function l(m,p,w={}){const E=w.fs||e,d=r(p,w);await t.fromCallback(E.writeFile)(m,d,w)}const u=t.fromPromise(l);function a(m,p,w={}){const E=w.fs||e,d=r(p,w);return E.writeFileSync(m,d,w)}return na={readFile:o,readFileSync:s,writeFile:u,writeFileSync:a},na}var ia,Od;function XE(){if(Od)return ia;Od=1;const e=WE();return ia={readJson:e.readFile,readJsonSync:e.readFileSync,writeJson:e.writeFile,writeJsonSync:e.writeFileSync},ia}var sa,Id;function ec(){if(Id)return sa;Id=1;const e=Me().fromPromise,t=Xe(),r=ue,n=Ct(),i=or().pathExists;async function o(l,u,a="utf-8"){const c=r.dirname(l);return await i(c)||await n.mkdirs(c),t.writeFile(l,u,a)}function s(l,...u){const a=r.dirname(l);t.existsSync(a)||n.mkdirsSync(a),t.writeFileSync(l,...u)}return sa={outputFile:e(o),outputFileSync:s},sa}var oa,Pd;function KE(){if(Pd)return oa;Pd=1;const{stringify:e}=Za(),{outputFile:t}=ec();async function r(n,i,o={}){const s=e(i,o);await t(n,s,o)}return oa=r,oa}var aa,Td;function YE(){if(Td)return aa;Td=1;const{stringify:e}=Za(),{outputFileSync:t}=ec();function r(n,i,o){const s=e(i,o);t(n,s,o)}return aa=r,aa}var ca,xd;function JE(){if(xd)return ca;xd=1;const e=Me().fromPromise,t=XE();return t.outputJson=e(KE()),t.outputJsonSync=YE(),t.outputJSON=t.outputJson,t.outputJSONSync=t.outputJsonSync,t.writeJSON=t.writeJson,t.writeJSONSync=t.writeJsonSync,t.readJSON=t.readJson,t.readJSONSync=t.readJsonSync,ca=t,ca}var ua,Ad;function QE(){if(Ad)return ua;Ad=1;const e=Xe(),t=ue,{copy:r}=Qa(),{remove:n}=Mn(),{mkdirp:i}=Ct(),{pathExists:o}=or(),s=$r();async function l(c,m,p={}){const w=p.overwrite||p.clobber||!1,{srcStat:E,isChangingCase:d=!1}=await s.checkPaths(c,m,"move",p);await s.checkParentPaths(c,E,m,"move");const f=t.dirname(m);return t.parse(f).root!==f&&await i(f),u(c,m,w,d)}async function u(c,m,p,w){if(!w){if(p)await n(m);else if(await o(m))throw new Error("dest already exists.")}try{await e.rename(c,m)}catch(E){if(E.code!=="EXDEV")throw E;await a(c,m,p)}}async function a(c,m,p){return await r(c,m,{overwrite:p,errorOnExist:!0,preserveTimestamps:!0}),n(c)}return ua=l,ua}var la,Cd;function ZE(){if(Cd)return la;Cd=1;const e=Vr(),t=ue,r=Qa().copySync,n=Mn().removeSync,i=Ct().mkdirpSync,o=$r();function s(m,p,w){w=w||{};const E=w.overwrite||w.clobber||!1,{srcStat:d,isChangingCase:f=!1}=o.checkPathsSync(m,p,"move",w);return o.checkParentPathsSync(m,d,p,"move"),l(p)||i(t.dirname(p)),u(m,p,E,f)}function l(m){const p=t.dirname(m);return t.parse(p).root===p}function u(m,p,w,E){if(E)return a(m,p,w);if(w)return n(p),a(m,p,w);if(e.existsSync(p))throw new Error("dest already exists.");return a(m,p,w)}function a(m,p,w){try{e.renameSync(m,p)}catch(E){if(E.code!=="EXDEV")throw E;return c(m,p,w)}}function c(m,p,w){return r(m,p,{overwrite:w,errorOnExist:!0,preserveTimestamps:!0}),n(m)}return la=s,la}var fa,Nd;function eS(){if(Nd)return fa;Nd=1;const e=Me().fromPromise;return fa={move:e(QE()),moveSync:ZE()},fa}var da,Ld;function tS(){return Ld||(Ld=1,da={...Xe(),...Qa(),...jE(),...zE(),...JE(),...Ct(),...eS(),...ec(),...or(),...Mn()}),da}var Pt=tS();let Ft;async function Bh(e){if(process.platform!=="win32")return;if(typeof Ft=="string")return{binDir:Ft};const t=fe.sync("choco",{nothrow:!0});if(t!
`);for(const y of h){const v=y.split("=");if(v.length===2&&(v[0].trim()==="VERSION_ID"||v[0].trim()==="DISTRIB_RELEASE")){d=v[1].trim().replace(/^"/,"").replace(/"$/,"");break}}}}return d}t._getOsVersion=p;function w(){const E="/etc/lsb-release",d="/etc/os-release";let f="";return c.existsSync(E)?f=c.readFileSync(E).toString():c.existsSync(d)&&(f=c.readFileSync(d).toString()),f}t._readLinuxVersionFile=w}(Ar,Ar.exports)),Ar.exports}var et={},qd;function nS(){if(qd)return et;qd=1;var e=et&&et.__createBinding||(Object.create?function(s,l,u,a){a===void 0&&(a=u);var c=Object.getOwnPropertyDescriptor(l,u);(!c||("get"in c?!l.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:function(){return l[u]}}),Object.defineProperty(s,a,c)}:function(s,l,u,a){a===void 0&&(a=u),s[a]=l[u]}),t=et&&et.__setModuleDefault||(Object.create?function(s,l){Object.defineProperty(s,"default",{enumerable:!0,value:l})}:function(s,l){s.default=l}),r=et&&et.__importStar||function(s){if(s&&s.__esModule)return s;var l={};if(s!=null)for(var u in s)u!=="default"&&Object.prototype.hasOwnProperty.call(s,u)&&e(l,s,u);return t(l,s),l},n=et&&et.__awaiter||function(s,l,u,a){function c(m){return m instanceof u?m:new u(function(p){p(m)})}return new(u||(u=Promise))(function(m,p){function w(f){try{d(a.next(f))}catch(h){p(h)}}function E(f){try{d(a.throw(f))}catch(h){p(h)}}function d(f){f.done?m(f.value):c(f.value).then(w,E)}d((a=a.apply(s,l||[])).next())})};Object.defineProperty(et,"__esModule",{value:!0}),et.RetryHelper=void 0;const i=r(wr());class o{constructor(l,u,a){if(l<1)throw new Error("max attempts should be greater than or equal to 1");if(this.maxAttempts=l,this.minSeconds=Math.floor(u),this.maxSeconds=Math.floor(a),this.minSeconds>this.maxSeconds)throw new Error("min seconds should be less than or equal to max seconds")}execute(l,u){return n(this,void 0,void 0,function*(){let a=1;for(;a<this.maxAttempts;){try{return yield l()}catch(m){if(u&&!u(m))throw m;i.info(m.message)}const c=this.getSleepAmount();i.info(`Waiting ${c} seconds before trying again`),yield this.sleep(c),a++}return yield l()})}getSleepAmount(){return Math.floor(Math.random()*(this.maxSeconds-this.minSeconds+1))+this.minSeconds}sleep(l){return n(this,void 0,void 0,function*(){return new Promise(u=>setTimeout(u,l*1e3))})}}return et.RetryHelper=o,et}var Ud;function iS(){if(Ud)return ae;Ud=1;var e=ae&&ae.__createBinding||(Object.create?function(D,L,N,j){j===void 0&&(j=N);var B=Object.getOwnPropertyDescriptor(L,N);(!B||("get"in B?!L.__esModule:B.writable||B.configurable))&&(B={enumerable:!0,get:function(){return L[N]}}),Object.defineProperty(D,j,B)}:function(D,L,N,j){j===void 0&&(j=N),D[j]=L[N]}),t=ae&&ae.__setModuleDefault||(Object.create?function(D,L){Object.defineProperty(D,"default",{enumerable:!0,value:L})}:function(D,L){D.default=L}),r=ae&&ae.__importStar||function(D){if(D&&D.__esModule)return D;var L={};if(D!=null)for(var N in D)N!=="default"&&Object.prototype.hasOwnProperty.call(D,N)&&e(L,D,N);return t(L,D),L},n=ae&&ae.__awaiter||function(D,L,N,j){function B(ee){return ee instanceof N?ee:new N(function(Y){Y(ee)})}return new(N||(N=Promise))(function(ee,Y){function ke(xe){try{Ke(j.next(xe))}catch(Nt){Y(Nt)}}function Te(xe){try{Ke(j.throw(xe))}catch(Nt){Y(Nt)}}function Ke(xe){xe.done?ee(xe.value):B(xe.value).then(ke,Te)}Ke((j=j.apply(D,L||[])).next())})};Object.defineProperty(ae,"__esModule",{value:!0}),ae.evaluateVersions=ae.isExplicitVersion=ae.findFromManifest=ae.getManifestFromRepo=ae.findAllVersions=ae.find=ae.cacheFile=ae.cacheDir=ae.extractZip=ae.extractXar=ae.extractTar=ae.extract7z=ae.downloadTool=ae.HTTPError=void 0;const i=r(wr()),o=r(Np()),s=r(mp),l=r(je),u=r(rS()),a=r(it),c=r(ue),m=r(Ap),p=r(Hh()),w=r(Ur),E=r(xn),d=qr,f=ka(),h=nS();class y extends Error{constructor(L){super(`Unexpected HTTP response: ${L}`),this.httpStatusCode=L,Object.setPrototypeOf(this,new.target.prototype)}}ae.HTTPError=y;const v=process.platform==="win32",S=process.platform==="darwin",_="actions/tool-cache";function b(D,L,N,j){return n(this,void 0,void 0,function*(){L=L||c.join(ie(),s.randomUUID()
2025-07-10 22:11:16 +08:00
`)){const p=m.match(o);if(p!==null){if(p[1]!=="Ubuntu")return[];c=!0}const w=m.match(s);w&&(u=w);const E=m.match(l);if(E&&(a=E),c&&u&&a)break}if(!c)return[];for(const m of[u,a])if(m){const p=[m[1],m[2]];return m[3]&&p.push(m[3]),p.map(w=>parseInt(w,10))}return[]}return Tr.getUbuntuVersion=n,Tr}var nm=GS();async function VS(){try{if(me()){try{fe.sync("lsb_release",{nothrow:!0})===null&&await de([{name:"lsb-release"}])}catch{return Kd()}const e=await nm.getUbuntuVersion();return e.length===0?Kd():e}else return null}catch(e){return ve(e.toString()),null}}const Ut=Fe(VS,{promise:!0});function Kd(){if(!("version"in it&&typeof it.version=="function"))return null;const t=it.version().match(/(\d+)\.(\d+)\.(\d+)/);if(t===null)return null;const r=Number.parseInt(t[1],10),n=Number.parseInt(t[2],10),i=Number.parseInt(t[3],10);return[r,n,i]}function BS(e){return[...new Set(e)]}function Yd(e,t='"'){return e.includes(" ")?`${t}${e}${t}`:e}async function ar(e,t,r={}){return On(await KS(r.pythonVersion),e,t,r)}async function On(e,t,r,n={}){const{usePipx:i=!0,user:o=!0,upgrade:s=!1,isLibrary:l=!1}=n,u=i&&!l&&await dn(e),a=!u&&await om(e),c=u?"pipx":"pip",m=YS(t);if(!s&&(u?await QS(e,m):await JS(e,m)))return{binDir:u?await Jd():await Qd(e,m)};if(!a&&await ZS(e,m))try{Ee.info(`Installing ${t} ${r??""} via ${c}`);const w=r!==void 0&&r!==""?`${t}==${r}`:t,E=s?u?["upgrade"]:["install","--upgrade"]:["install"],d=!u&&o?["--user"]:[],f=process.env;u&&o&&(f.PIPX_HOME=await WS(),f.PIPX_BIN_DIR=await im()),ze(e,["-m",c,...E,...d,w],{stdio:"inherit",env:f})}catch(w){const E=w instanceof Error?`${w.message}
${w.stack}`:String(w);if(Ee.info(`Failed to install ${t} via ${c}: ${E}`),await kr(t)===null)throw new Error(`Failed to install ${t} via ${c}: ${w}.`)}else if(await kr(t)===null)throw new Error(`Failed to install ${t} as it was not found via ${c} or the system package manager`);return{binDir:u?await Jd():await Qd(e,m)}}function Jd(){return im()}async function Qd(e,t){const r=await rb(e),n=await eb(r,t);return await Re(n,ne),n}async function HS(){return await fe("pipx",{nothrow:!0})!==null}async function dn(e){return(await le(e,["-m","pipx","--help"],{stdio:"ignore",reject:!1})).exitCode===0}async function zS(){let e=process.env.PIPX_HOME;if(e!==void 0)return e;const t=rt("~/.local/pipx");if(await ye(t))return t;switch(process.platform){case"win32":{e=rt("~/AppData/Local/pipx");break}case"darwin":{e=rt("~/Library/Application Support/pipx");break}default:{e=rt("~/.local/share/pipx");break}}return await Cr(e),await Cr(J(e,"trash")),await Cr(J(e,"shared")),await Cr(J(e,"venv")),e}const WS=Fe(zS,{promise:!0});async function XS(){if(process.env.PIPX_BIN_DIR!==void 0)return process.env.PIPX_BIN_DIR;const e=rt("~/.local/bin");return await Re(e,ne),await Cr(e),e}const im=Fe(XS,{promise:!0});let sn;async function KS(e){if(sn!==void 0)return sn;const t=e??nt("python",void 0,await Ut());return sn=(await rm({version:t,setupDir:"",arch:process.arch})).bin,sn}function YS(e){return e.replace(/\[.*]/g,"").trim()}async function JS(e,t){try{return(await le(e,["-m","pip","-qq","show",t],{stdio:"ignore",reject:!1})).exitCode===0}catch{return!1}}async function QS(e,t){try{const r=await le(e,["-m","pipx","list","--json"],{stdio:"ignore",reject:!1});if(r.exitCode!==0||typeof r.stdout!="string")return!1;const n=JSON.parse(r.stdout);if(t in n.venvs)return!0;for(const i of Object.values(n.venvs))if(i.metadata.main_package.package_or_url===t||i.metadata.main_package.package===t)return!0}catch{}return!1}async function ZS(e,t){return(await le(e,["-m","pip","-qq","index","versions",t],{stdio:"ignore",reject:!1})).exitCode===0}async function eb(e,t){const n=(await Promise.all(e.map(o=>ye(J(o,ge(t)))))).findIndex(o=>o);if(n!==-1)return e[n];const i=fe.sync(ge(t),{nothrow:!0});return i!==null?be(i):e[e.length-1]}async function kr(e,t){if(process.platform==="linux"){Ee.info(`Installing ${e} via the system package manager`);const r=e==="pipx"?Pe():!0;if(Pe())return _e(r?`python-${e}`:e);if(Ne())return Ce([{name:r?`python3-${e}`:e}]);if(me())return de([{name:r?`python3-${e}`:e}]);if(await Oe())return De([{name:r?`py3-${e}`:e}])}else if(process.platform==="darwin")return["venv"].includes(e)?null:Ge(e);return null}async function tb(e){const t=[];process.platform==="linux"?t.push("/home/runner/.local/bin/"):process.platform==="darwin"&&t.push("/usr/local/bin/");const r=await sm(e);return t.push(J(r,"Scripts"),J(r,"Scripts","bin"),J(r,"bin")),BS(t)}const rb=Fe(tb,{promise:!0});async function nb(e){return(await Ka.getExecOutput(`${e} -c "import sys;print(sys.base_exec_prefix);"`)).stdout.trim()}const sm=Fe(nb,{promise:!0});async function ib(e){try{const t=await sm(e),r=await Mh(e);if(r===void 0)return ve(`Failed to get the version of ${e}`),!1;const n=J(t,"lib",`python${r.major}.${r.minor}`,"EXTERNALLY-MANAGED");return ye(n)}catch(t){return ve(`Failed to check if ${e} is externally managed: ${t}`),!1}}const om=Fe(ib,{promise:!0});function sb({version:e}={}){return me()&&(e===void 0||e==="")?de([{name:"gcovr",version:e}]):ar("gcovr",e)}function ob(){return Ie("GCOV","llvm-cov gcov",ne)}function Zd(e){const t=jn(e),r=t!==null?Eh(t):e,n=r!==""?`gcov-${r}`:"gcov";return Ie("GCOV",n,ne)}const ct=["x64","amd64","x86_64","win64","64","amd64_x86","amd64_arm64"],fr=["x86","i386","ia32","win32","32","x32"],ut=["aarch64","arm64","woa64","arm"],ab=["armv7","armv7a"],cb=["powerpc64le","ppc64le"],ub=["sparc64"],lb=["sparcv9"];function am(e){return ut.includes(e)?"arm64":ct.includes(e)?"amd64":e}async function fb({version:e}={}){switch(process.platform){case"win32":return Le("bazelisk",e);case"darwin":return Ge("bazelisk",e);case"linux":{if(Pe())throw new Error("installing ba
apt-get update -o ${Rr}`)}async function Zb(e){let t=e.replace(/apt-get install -y/g,`apt-get install -o Dpkg::Options::="--force-overwrite" -o ${Rr} -y --fix-broken`);const r=["libc++-$LLVM_VERSION-dev","libc++abi-$LLVM_VERSION-dev","libunwind-$LLVM_VERSION-dev"];return await Promise.all(r.map(async n=>{const i=n.replace("$LLVM_VERSION","*");await iE(i)&&(_a(`Removing conflicting package ${i}`),t=t.replace(n,""))})),t}function e0(e){return Oh()?e.replace(/apt-get/g,"nala"):e}function t0(e,t,r){return e===1?t.replace(/ -y \$PKG/g,` -y clang-format-${r}`):t}const ep=typeof __dirname=="string"?__dirname:ue.dirname(Lt(import.meta.url));async function r0(e,t,r){const n=await n0(t,r,e);z(`Downloading LLVM from ${n}`);const i=Kh(n);return{url:n,extractedFolderName:"",binRelativeDir:"bin",binFileName:ge("clang"),extractFunction:i===ln.Tar||i===ln.TarGz||i===ln.TarXz?(o,s)=>process.platform==="win32"?yr(o,s,!0):rc(o,s,1):Yh(i)}}async function n0(e,t,r){const{keywords:n,optionalKeywords:i}=await i0(e,t),o=await Sn(J(ep,"github_llvm_llvm-project.json")),s=bn(o,{version:r,keywords:n,optionalKeywords:i,filterMapTag(a){return a.replace(/^llvmorg-/,"")}});if(s!==void 0)return`https://github.com/llvm/llvm-project/releases/download/${s.tag}/${s.name}`;const l=await Sn(J(ep,"llvm_org_releases.json")),u=bn(l,{version:r,keywords:n,optionalKeywords:i});if(u!==void 0)return`https://releases.llvm.org/${u.tag}/${u.name}`;throw new Error(`No asset found for version ${r} matching ${n} and ${i}`)}async function i0(e,t){const r=[],n=[];switch(e){case"win32":{n.push(".tar.xz",".tar.xz");const i=[];ct.includes(t)?(i.push("win64"),n.push(["x86_64","X64"])):fr.includes(t)?i.push("win32"):ut.includes(t)?i.push("woa64"):(z(`Using arch ${t} for LLVM`),i.push(t)),i.push("windows","Windows"),r.push(i);break}case"linux":{const i=["linux","Linux"];if(me()){n.push("ubuntu");const o=await Ut();if(o!==null){n.push(`${o[0]}`);const s=o[1]<10?`0${o[1]}`:`${o[1]}`;n.push(`${o[0]}.${s}`),n.push(`${o[0]}.${s}.${o[2]}`)}}else Ne()&&n.push("rhel");ct.includes(t)?r.push(["x86_64","X64"]):fr.includes(t)?r.push("x86"):ut.includes(t)?r.push("aarch64"):ab.includes(t)?r.push("armv7a"):cb.includes(t)?r.push("powerpc64le"):ub.includes(t)?r.push("sparc64"):(z(`Using arch ${t} for LLVM`),r.push(t)),r.push(i);break}case"darwin":{r.push(["apple","macos","macOS"]),ct.includes(t)?n.push(["x86_64","X64"]):ut.includes(t)?n.push(["arm64","ARM64"]):(z(`Using arch ${t} for LLVM`),r.push(t));break}case"freebsd":{r.push("freebsd"),ct.includes(t)?r.push("amd64"):fr.includes(t)?r.push("i386"):(z(`Using arch ${t} for LLVM`),r.push(t));break}case"solaris":{r.push("solaris"),ct.includes(t)?r.push("amd64"):lb.includes(t)?r.push("sparcv9"):(z(`Using arch ${t} for LLVM`),r.push(t));break}default:z(`Using ${e} ${t} for LLVM`),r.push(e,t);break}return{keywords:r,optionalKeywords:n}}async function s0({version:e,setupDir:t,arch:r}){const n=await gt("llvm",e,r0,t,r);return await a0(Or(e),r),n}async function o0(e,t){if(me())for(const r of["libtinfo5","libtinfo6"])try{await de([{name:r}])}catch{try{if(r==="libtinfo5"){z(`Failed to install ${r}
Manually installing the package`);const i=`libtinfo5_6.3-2ubuntu0.1_${am(t)}.deb`,o=`https://launchpad.net/ubuntu/+archive/primary/+files/${i}`,s=new br.DownloaderHelper(o,Ue(),{fileName:i});s.on("error",async l=>{z(`Failed to download ${o}: ${l}`),await s.stop()}),await s.start(),he("dpkg",["-i",J(Ue(),i)])}}catch{z(`Failed to install ${r}. Ignoring`)}}else Pe()?await _e("ncurses5-compat-libs",void 0,"yay"):Ne()&&await Ce([{name:"ncurses-compat-libs"}])}const a0=Fe(o0,{promise:!0});async function c0({version:e}){if(process.platform!=="darwin")return Promise.resolve(void 0);try{return await u0({version:e})}catch(t){z(`Failed to install llvm via brew: ${t}`);return}}async function u0({version:e}){const t=Or(e),r=await Ge("llvm",`${t}`,{"force-bottle":!0});return await Re(r.binDir,ne),r}const{GITHUB_ACTIONS:l0}=xt,f0=typeof __dirname=="string"?__dirname:ue.dirname(Lt(import.meta.url));async function hn({version:e,setupDir:t,arch:r}){const n=await ac(e,t,r);return await p0(r),await m0(),n.installDir!==void 0&&await h0(n.installDir,e),n}async function ac(e,t,r,n=oc.All){const i=await Xb(e,n);if(i!==void 0)return i;const o=await Hb(e);if(o!==void 0)return o;const s=await c0({version:e});return s!==void 0?s:s0({version:e,setupDir:t,arch:r})}async function d0(e){process.platform==="linux"&&await Rn({version:nt("gcc",void 0,await Ut()),setupDir:"",arch:e,priority:40})}const p0=Fe(d0,{promise:!0});async function h0(e,t){const r=process.env.LD_LIBRARY_PATH??"",n=process.env.DYLD_LIBRARY_PATH??"",i=Or(t),o=[Ie("CC",ge(`${e}/bin/clang`),ne),Ie("CXX",ge(`${e}/bin/clang++`),ne),Ie("LLVM_PATH",e,ne),Ie("LLVM_LD_LIBRARY_PATH",`${r}${mn}${e}/lib`,ne),Ie("LLVM_DYLD_LIBRARY_PATH",`${n}${mn}${e}/lib`,ne),Ie("LLVM_LDFLAGS",`-L${Yd(`${e}/lib`)}`,ne),Ie("LLVM_CPPFLAGS",`-I${Yd(`${e}/include`)}`,ne),await ye(`${e}/lib/clang/${t}/include`)?Ie("LLVM_CPATH",`${e}/lib/clang/${t}/include`,ne):await ye(`${e}/lib/clang/${i}/include`)?Ie("LLVM_CPATH",`${e}/lib/clang/${i}/include`,ne):Promise.resolve(),Ie("LLVM_LIBRARY_PATH",`${e}/lib`,ne),qh()];me()&&o.push(vt("cc",`${e}/bin/clang`,ne,60),vt("cxx",`${e}/bin/clang++`,ne,60),vt("clang",`${e}/bin/clang`,ne),vt("clang++",`${e}/bin/clang++`,ne),vt("lld",`${e}/bin/lld`,ne),vt("ld.lld",`${e}/bin/ld.lld`,ne),vt("llvm-ar",`${e}/bin/llvm-ar`,ne)),await Promise.all(o)}async function m0(){if(!l0)return;const e=J(f0,"llvm_matcher.json");if(!await ye(e))return ve("the llvm_matcher.json file does not exist in the same folder as setup-cpp.js");z(`::add-matcher::${e}`)}function tp({version:e,setupDir:t,arch:r}){return ac(e,t,r,oc.ClangFormat)}function rp({version:e,setupDir:t,arch:r}){return ac(e,t,r)}async function y0({version:e}={}){switch(process.platform){case"win32":return Le("make",e);case"darwin":{await Ge("make",e);const t=J(Xa(),"opt/make/libexec/gnubin");return await Re(t,ne),{binDir:t}}case"linux":{if(Pe())return _e("make",e);if(Ne())return Ce([{name:"make",version:e}]);if(me())return de([{name:"make",version:e}]);if(await Oe())return De([{name:"make",version:e}]);throw new Error("Unsupported linux distribution")}default:throw new Error("Unsupported platform")}}function v0({version:e}={}){return ar("meson",e)}var Jt={},np;function w0(){if(np)return Jt;np=1;const e=wr(),t=Fr,r=je,n=ue,i=up,o=i.env["ProgramFiles(x86)"],s=[i.env["ProgramFiles(x86)"],i.env.ProgramFiles],l=["Enterprise","Professional","Community","BuildTools"],u=["2022","2019","2017"],a={2022:"17.0",2019:"16.0",2017:"15.0",2015:"14.0",2013:"12.0"};function c(y){return Object.values(a).includes(y)?y:y in a?a[y]:y}Jt.vsversion_to_versionnumber=c;function m(y){if(Object.keys(a).includes(y))return y;for(const[v,S]of Object.entries(a))if(S===y)return v;return y}Jt.vsversion_to_year=m;const p=`${o}\\Microsoft Visual Studio\\Installer`;function w(y,v){try{return t.execSync(`vswhere -products * ${v} -prerelease -property installationPath`).toString().trim()+"\\"+y}catch(S){e.warning(`vswhere failed: ${S}`)}return null}Jt.findWithVswhere=w;function E(y){const v=c(y);let S;if(v){const g=v.split(".")[0]+".9";S=`-version "${v},${g}"`}else S="-latest";let _=
`),x=K[1].split(`\r
`),T=K[2].split(`\r
`),F=x.filter(k=>!!(k.match(/^\[ERROR.*\]/)&&!k.match(/Error in script usage. The correct usage is:$/)));if(F.length>0)throw new Error(`invalid parameters\r
`+F.join(`\r
2025-07-10 22:11:16 +08:00
`));let U={};for(let k of Q){const[G,C]=k.split("=");U[G]=C}e.startGroup("Environment variables");for(let k of T){if(!k.includes("="))continue;let[G,C]=k.split("="),H=U[G];C!==H&&(e.info(`Setting ${G}`),d(G)&&(C=f(C)),e.exportVariable(G,C))}e.endGroup(),e.info("Configured Developer Command Prompt")}return Jt.setupMSVCDevCmd=h,Jt}var Oa=w0();function g0(e){switch(e){case"x32":case"32":case"ia32":return"x86";case"64":return"x64";default:return e}}async function cc({vsversion:e,VCTargetsPath:t,arch:r,toolset:n,sdk:i,uwp:o,spectre:s}){t!==void 0&&await ye(t)&&(z(`Adding ${t} to PATH`),await Ie("VCTargetsPath",t,ne)),await Oa.setupMSVCDevCmd(g0(r),i,n,o,s,e)}const{GITHUB_ACTIONS:_0}=xt,E0=typeof __dirname=="string"?__dirname:ue.dirname(Lt(import.meta.url));async function Lr({version:e,setupDir:t,arch:r,sdk:n,uwp:i,spectre:o}){if(process.platform!=="win32")return;const s=Oa.vsversion_to_versionnumber(e);z(`Checking if MSVC ${s} is already installed`);let l=!1;try{const c=Oa.findVcvarsall(s);l=!0,z(`Found the pre-installed version of MSVC at ${c}`)}catch{}let u,a;if(!l)try{s==="14.0"?(u="14.0",await Le("visualcpp-build-tools","14.0.25420.1",["--ignore-dependencies"]),a="C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140"):s==="15.0"?(u="14.16",await Le("visualstudio2017buildtools","15.9.41.0",[]),a="C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16"):s==="16.0"?(u="14.29",await Le("visualstudio2019buildtools","16.11.7.0",[]),a="C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133"):s==="17.0"?(u=void 0,await Le("visualstudio2022buildtools","117.0.5.0",[]),a=void 0):Ae(`The given MSVC versions ${e} is not supported yet.`)}catch(c){Ae(c)}await cc({VCTargetsPath:a,arch:r,toolset:u,sdk:n,uwp:i,spectre:o}),_0&&await S0()}async function S0(){const e=J(E0,"msvc_matcher.json");if(!await ye(e))return ve("the msvc_matcher.json file does not exist in the same folder as setup-cpp.js");z(`::add-matcher::${e}`)}async function ip({version:e}={}){return process.platform!=="win32"?void 0:(await Le("opencppcoverage",e),{binDir:await b0()})}async function b0(){const e="C:/Program Files/OpenCppCoverage";return await Re(e,ne),e}function R0(e,t,r){return{url:$0(t,r,e),binRelativeDir:"",binFileName:ge("pwsh"),extractedFolderName:""}}function $0(e,t,r){switch(e){case"win32":{const n=["ia32","x86","i386","x32"].includes(t)?"win-x86":"win-x64";return`https://github.com/PowerShell/PowerShell/releases/download/v${r}/PowerShell-${r}-${n}.zip`}case"darwin":{const n=["arm","arm64"].includes(t)?"osx-arm64":"osx-x64";return`https://github.com/PowerShell/PowerShell/releases/download/v${r}/powershell-${r}-${n}.tar.gz`}case"linux":{const i={arm64:"linux-arm64",arm:"linux-arm64",arm32:"linux-arm32",aarch64:"linux-arm64",x64:"linux-x64"}[t]??"linux-x64";return`https://github.com/PowerShell/PowerShell/releases/download/v${r}/powershell-${r}-${i}.tar.gz`}default:throw new Error(`Unsupported platform '${e}'`)}}async function sp({version:e,setupDir:t,arch:r}){try{return await Oe()?op({version:e}):await gt("pwsh",e,R0,t,r)}catch(n){return Ae(`Failed to setup pwsh via download: ${n}. Trying package managers...`),op({version:e})}}async function op({version:e}={}){switch(process.platform){case"win32":{await Le("powershell-core",e);const t="C:/Program Files/PowerShell/7";return await Re(t,ne),{binDir:t}}case"darwin":return Ge("powershell",e,{cask:!0,overwrite:!1});case"linux":{if(Pe())return _e("powershell-bin",e,"yay");if(Ne())return await Ce([{name:"curl"}]),he("/bin/bash",["-c","curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo"]),Ce([{name:"powershell",version:e}]);if(me()){await de([{name:"curl"}]);const t=await Ut(),r=`${t[0]}.0${t[1]}`;return he("curl",["-LJO",`https://packages.microsoft.com/config/ubuntu/${r}/packages-microsoft-prod.deb`]),he("dpkg",["-i","packages-microsoft-prod.deb"]),de([{name:"powershell",version:e}],!0)}else if(await Oe())return De([{name:"powershell",version:void 0}]);throw new Error("Unsupported linux distribution")}d
- The installation directory is ${t.installDir}`),t.binDir!==""&&(r+=`
2025-07-10 22:11:16 +08:00
- The binary directory is ${t.binDir}`)),r}const D0=/[.-]((?:\d{4}|\d+(?:\.\d+)*(?:-[\w.-]+)?(?:\+[\w.-]+)?)$)/;function k0(e){try{const t=e.match(D0);if(t===null)return{compiler:e,version:void 0};const r=t[1],n=e.slice(0,t.index).replace(/[.-]$/,"");return!r.match(/^\d{4}$/)&&jn(r)===null&&z(`Non-semver version format: ${r}`),{compiler:n,version:r}}catch(t){return Ae(`Failed to parse the compiler info ${e}: ${t}`),{compiler:e,version:void 0}}}async function F0(e,t,r,n,i,o,s){let l;try{if(Ee.startGroup(`Installing ${e} ${t??""}`),e in fm)l=await hn({version:nt("llvm",t,r),setupDir:J(n,"llvm"),arch:i}),await ob();else if(e in dm){const u=nt("gcc",t,r);l=await Rn({version:u,setupDir:J(n,"gcc"),arch:i}),await Zd(u)}else if(e in pm){const u=nt("mingw",t,r);l=await nc({version:u,setupDir:J(n,"gcc"),arch:i}),await Zd(u)}else e in hm?l=await Lr({version:nt("msvc",t,r),setupDir:J(n,"msvc"),arch:i}):e in mm?await Nr():(l=null,s.push(`Unsupported compiler ${e}`))}catch(u){Ae(u),u instanceof Error&&Ae(u.stack??""),s.push(`Failed to install the ${e} compiler ${t}`)}l!==null&&o.push(_m(e,l)),Ee.endGroup()}async function q0(e,t="npm"){try{return await fe("setup-cpp",{nothrow:!0})!==null?`setup-cpp@${e} already installed`:(z(`Installing setup-cpp@${e} via ${t}...`),await le(t,["install","-g",`setup-cpp@${e}`],{stdio:"inherit",timeout:1e3*60*1}),`setup-cpp@${e} installed successfully`)}catch(r){return new Error(`Failed to install the setup-cpp@${e} CLI: ${r}. Ignoring...`)}}async function U0(e={}){const t=e.architecture??process.arch,r=process.env.SETUP_CPP_DIR??rt("~"),n=[],i=[],o=Vf.create({autoloadLocales:!0});Vf.addLocale(x_),__.addLocale(b_);let s,l;const u=await Ut(),a=e.compiler!==void 0?k0(e.compiler):void 0;if(!xS(e,[...ym,"compiler"],a))return{successMessages:[],errorMessages:["The same version must be used for llvm, clang-format and clang-tidy"]};Pe()&&typeof e.cppcheck=="string"&&typeof e.gcovr=="string"&&(z("installing python-pygments to avoid conflicts with cppcheck and gcovr on Arch linux"),await _e("python-pygments"));const c=wm.filter(E=>{const d=e[E];return d!==void 0&&d!=="false"}),m=e["setup-cpp"]===void 0||e["setup-cpp"]?q0(La.version,e["node-package-manager"]):Promise.resolve(void 0);let p=!1;for(const E of c){const d=e[E],f=e.timeout!==void 0?Number.parseFloat(e.timeout)*60*1e3:void 0;if(s=Date.now(),await N0(E,d,u,t,r,n,i,f),l=Date.now(),z(`took ${o.format(s,l)||"0 seconds"}`),i.length!==0&&vn.isCI){p=!0;break}}if(!p&&a!==void 0){const E=Date.now();await F0(a.compiler,a.version,u,r,t,n,i);const d=Date.now();z(`took ${o.format(E,d)||"0 seconds"}`)}const w=await m;return typeof w=="string"&&n.push(w),await n_(ne),{successMessages:n,errorMessages:i}}async function j0(e){const t=vn.GITHUB_ACTIONS?Promise.resolve():M0(),r=G0(e);if(r.help)return V0(),0;if(r.version)return z(`${La.version}`),0;const{successMessages:n,errorMessages:i}=await U0(r);for(const o of n)Qy(o);for(const o of i)Ae(o);if((n.length!==0||i.length!==0)&&(z("setup-cpp finished"),!vn.GITHUB_ACTIONS))switch(process.platform){case"win32":{ve("Run `RefreshEnv.cmd` or restart your shell to update the environment.");break}case"linux":case"darwin":{ve("Run `source ~/.cpprc` or restart your shell to update the environment.");break}}return await t,i.length===0?0:1}async function M0(){try{await Iy({pkg:La})}catch(e){ve(`Failed to check for updates: ${e instanceof Error?e.message+e.stack:e}`)}}function G0(e){const t=Object.fromEntries(cp.map(r=>[r,Lp(r)]));return ty(e,{string:[...cp,"timeout","node-package-manager"],default:t,alias:{h:"help",v:"version"},boolean:["help","version","setup-cpp"]})}function V0(){z(`
setup-cpp [options]
setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
Install all the tools required for building and testing C++/C projects.
--architecture the cpu architecture to install the tools for. By default it uses the current CPU architecture.
--timeout the timeout for the installation of each tool in minutes. By default it is 10 minutes.
--compiler the <compiler> to install.
You can specify the version instead of specifying just the name e.g: --compiler 'llvm-13.0.0'
--tool_name pass "true" or pass the <version> you would like to install for this tool. e.g. --conan true or --conan "1.42.1"
--nodePackageManager the node package manager to use (npm/yarn/pnpm) when installing setup-cpp globally
--help show this help message
--version show the version of setup-cpp
All the available tools:
2025-07-10 22:11:16 +08:00
`),console.table({"compiler and analyzer":{tools:"--llvm, --gcc, --msvc, --apple-clang, --vcvarsall"},"build system":{tools:"--cmake, --ninja, --meson, --make, --task, --bazel"},"package manager":{tools:"--vcpkg, --conan, --choco, --brew, --apt-fast, --nala, --git, --setup-cpp"},"analyzer/linter":{tools:"--clang-tidy, --clang-format, --cppcheck, --cpplint, --flawfinder, --lizard, --infer, , --cmakelang, --cmake-lint, --cmake-format"},cache:{tools:"--ccache, --sccache"},documentation:{tools:"--doxygen, --graphviz"},coverage:{tools:"--gcovr, --opencppcoverage, --kcov"},other:{tools:"--python, --powershell, --sevenzip, --tar"}},["tools"])}process.env.SETUP_CPP_SKIP_MAIN!=="true"&&j0(process.argv).then(e=>{process.exitCode=e}).catch(e=>{Ae("main() panicked!"),Ae(e),process.exitCode=1});export{Vy as H,Ee as a,xt as b,at as c,Ka as e,$e as g,z as i,ye as p,G0 as parseArgs,Ry as r,tc as t,ve as w};
2025-04-07 21:21:56 +08:00
//# sourceMappingURL=setup-cpp.mjs.map