mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-18 04:28:28 +02:00
[autofix.ci] apply automated fixes
This commit is contained in:
parent
5b3afef087
commit
f5a2b423cd
1 changed files with 1 additions and 1 deletions
2
dist/setup/index.js
generated
vendored
2
dist/setup/index.js
generated
vendored
|
@ -66,7 +66,7 @@ Other caches with similar key:`);for(let p of n?.artifactCaches||[])fa.debug(`Ca
|
||||||
`:a+=" "+i.join(", ")+(i.length>0?" ":""),a+"]"}o(xF,"stringifyInlineArray");function bF(t){t=Lu(t);var e=[];return Object.keys(t).forEach(a=>{e.push(qu(a)+" = "+T_(t[a],!1))}),"{ "+e.join(", ")+(e.length>0?" ":"")+"}"}o(bF,"stringifyInlineTable");function wF(t,e,a,i){var r=oa(i);if(r==="array")return NF(t,e,a,i);if(r==="table")return _F(t,e,a,i);throw fn(r)}o(wF,"stringifyComplex");function NF(t,e,a,i){i=Lu(i),R_(i);var r=oa(i[0]);if(r!=="table")throw fn(r);var n=t+qu(a),s="";return i.forEach(p=>{s.length>0&&(s+=`
|
`:a+=" "+i.join(", ")+(i.length>0?" ":""),a+"]"}o(xF,"stringifyInlineArray");function bF(t){t=Lu(t);var e=[];return Object.keys(t).forEach(a=>{e.push(qu(a)+" = "+T_(t[a],!1))}),"{ "+e.join(", ")+(e.length>0?" ":"")+"}"}o(bF,"stringifyInlineTable");function wF(t,e,a,i){var r=oa(i);if(r==="array")return NF(t,e,a,i);if(r==="table")return _F(t,e,a,i);throw fn(r)}o(wF,"stringifyComplex");function NF(t,e,a,i){i=Lu(i),R_(i);var r=oa(i[0]);if(r!=="table")throw fn(r);var n=t+qu(a),s="";return i.forEach(p=>{s.length>0&&(s+=`
|
||||||
`),s+=e+"[["+n+`]]
|
`),s+=e+"[["+n+`]]
|
||||||
`,s+=u6(n+".",e,p)}),s}o(NF,"stringifyArrayOfTables");function _F(t,e,a,i){var r=t+qu(a),n="";return __(i).length>0&&(n+=e+"["+r+`]
|
`,s+=u6(n+".",e,p)}),s}o(NF,"stringifyArrayOfTables");function _F(t,e,a,i){var r=t+qu(a),n="";return __(i).length>0&&(n+=e+"["+r+`]
|
||||||
`),n+u6(r+".",e,i)}o(_F,"stringifyComplexTable")});var I_=E(h6=>{"use strict";h6.parse=N_();h6.stringify=P_()});var V_=require("node:os"),Lt=ya(rt());var L_=require("node:crypto"),q_=require("node:os"),eo=require("node:path"),bi=require("node:fs"),hn=ya(rt()),ku=ya(AN()),Hp=ya(e_()),v6=ya(_n());var Ys=require("node:fs"),g6=ya(rt()),zu=ya(I_());function D_(t,e){if(!e.length)return;let a=0;if(e.forEach(n=>{try{new URL(n.url)}catch{throw new Error(`Invalid registry URL: ${n.url}`)}n.scope||a++}),a>1)throw new Error("You can't have more than one global registry.");(0,g6.info)(`Writing bunfig.toml to '${t}'.`);let i={};if((0,Ys.existsSync)(t))try{let n=(0,Ys.readFileSync)(t,{encoding:"utf-8"});i=(0,zu.parse)(n)}catch(n){(0,g6.info)(`Error reading existing bunfig: ${n.message}`),i={}}i.install=i?.install||{},i.install.scopes=i?.install.scopes||{};let r=e.find(n=>!n.scope);r&&(i.install.registry={url:r.url,...r.token?{token:r.token}:{}});for(let n of e)if(n.scope){let s=n.scope.startsWith("@")?n.scope.toLowerCase():`@${n.scope.toLowerCase()}`;i.install.scopes[s]={url:n.url,...n.token?{token:n.token}:{}}}Object.keys(i.install.scopes).length===0&&delete i.install.scopes,(0,Ys.writeFileSync)(t,(0,zu.stringify)(i),{encoding:"utf8"})}o(D_,"writeBunfig");var z_=ya(rt());var Js=ya(rt()),A_=require("node:console"),Zs=require("node:fs"),ju=require("node:path");function y6(t,e,a=1e4){return t().catch(i=>{if(e<=0)throw i;return new Promise(r=>setTimeout(r,a)).then(()=>y6(t,e-1,a))})}o(y6,"retry");function B_(t,e){return t.endsWith(e)?t:((0,Zs.renameSync)(t,t+e),t+e)}o(B_,"addExtension");var SF={"package.json":t=>JSON.parse(t).packageManager?.split("bun@")?.[1],".tool-versions":t=>t.match(/^bun\s*(?<version>.*?)$/m)?.groups?.version,".bumrc":t=>t,".bun-version":t=>t};function M_(t){let e=process.env.GITHUB_WORKSPACE;if(!e||!t)return;(0,Js.debug)(`Reading version from ${t}`);let a=(0,ju.resolve)(e,t),i=(0,ju.basename)(t);if(!(0,Zs.existsSync)(a)){(0,Js.warning)(`File ${a} not found`);return}let r=SF[i]??(()=>{}),n;try{if(n=r((0,Zs.readFileSync)(a,"utf8"))?.trim(),!n){(0,Js.warning)(`Failed to read version from ${t}`);return}}catch(s){let{message:p}=s;(0,Js.warning)(`Failed to read ${t}: ${p}`)}finally{if(n)return(0,A_.info)(`Obtained version ${n} from ${t}`),n}}o(M_,"readVersionFromFile");var j_=require("node:process");var k_=o(async t=>{let e=(0,eo.join)((0,j_.cwd)(),"bunfig.toml");D_(e,t.registries);let a=TF(t),i=EF(t),r=(0,eo.join)((0,q_.homedir)(),".bun","bin");try{(0,bi.mkdirSync)(r,{recursive:!0})}catch(u){if(u.code!=="EEXIST")throw u}(0,hn.addPath)(r);let n=o(u=>process.platform==="win32"?`${u}.exe`:u,"exe"),s=(0,eo.join)(r,n("bun"));try{(0,bi.symlinkSync)(s,(0,eo.join)(r,n("bunx")))}catch(u){if(u.code!=="EEXIST")throw u}let p,l=!1;if(i){let u=(0,L_.createHash)("sha1").update(a).digest("base64");await(0,ku.restoreCache)([s],u)&&(p=await H_(s),p?(l=!0,(0,hn.info)(`Using a cached version of Bun: ${p}`)):(0,hn.warning)(`Found a cached version of Bun: ${p} (but it appears to be corrupted?)`))}if(l||((0,hn.info)(`Downloading a new version of Bun: ${a}`),p=await y6(async()=>await CF(a,s),3)),!p)throw new Error("Downloaded a new version of Bun, but failed to check its version? Try again.");let[d]=p.split("+");return(0,z_.saveState)("cache",JSON.stringify({cacheEnabled:i,cacheHit:l,bunPath:s,url:a})),{version:d,revision:p,bunPath:s,url:a,cacheHit:l}},"default");async function CF(t,e){let a=B_(await(0,Hp.downloadTool)(t),".zip"),i=await(0,Hp.extractZip)(a),r=await x6(i);try{(0,bi.renameSync)(r,e)}catch{(0,bi.copyFileSync)(r,e)}return await H_(e)}o(CF,"downloadBun");function EF(t){let{customUrl:e,version:a,noCache:i}=t;return i||e||!a||/latest|canary|action/i.test(a)?!1:(0,ku.isFeatureAvailable)()}o(EF,"isCacheEnabled");function TF(t){let{customUrl:e}=t;if(e)return e;let{version:a,os:i,arch:r,avx2:n,profile:s}=t,p=encodeURIComponent(a??"latest"),l=encodeURIComponent(i??process.platform),d=encodeURIComponent(r??process.arch),c=encodeURIComponent(n??!0),u=encodeURIComponent(s??!1),{href:m}=new URL(`${p}/${l}/${d}?avx2=${c}&profile=${u}`,"https://bun.sh/download/");return m}o(TF,"getDownloadUrl");async function x6(t){for(let e of(0,bi.readdirSync)(t,{withFileTypes:!0})){let{name:a}=e,i=(0,eo.join)(t,a);if(e.isFile()){if(a==="bun"||a==="bun.exe")return i;if(/^bun.*\.zip/.test(a)){let r=await(0,Hp.extractZip)(i);return x6(r)}}if(/^bun/.test(a)&&e.isDirectory())return x6(i)}throw new Error("Could not find executable: bun")}o(x6,"extractBun");async function H_(t){let e=await(0,v6.getExecOutput)(t,["--revision"],{ignoreReturnCode:!0});if(e.exitCode===0&&/^\d+\.\d+\.\d+/.test(e.stdout))return e.stdout.trim();let a=await(0,v6.getExecOutput)(t,["--version"],{ignoreReturnCode:!0});if(a.exitCode===0&&/^\d+\.\d+\.\d+/.test(a.stdout))return a.stdout.trim()}o(H_,"getRevision");function U_(t){return t?.trim()?t.split(`
|
`),n+u6(r+".",e,i)}o(_F,"stringifyComplexTable")});var I_=E(h6=>{"use strict";h6.parse=N_();h6.stringify=P_()});var V_=require("node:os"),Lt=ya(rt());var L_=require("node:crypto"),q_=require("node:os"),eo=require("node:path"),bi=require("node:fs"),hn=ya(rt()),ku=ya(AN()),Hp=ya(e_()),v6=ya(_n());var Ys=require("node:fs"),g6=ya(rt()),zu=ya(I_());function D_(t,e){if(!e.length)return;let a=0;if(e.forEach(n=>{try{new URL(n.url)}catch{throw new Error(`Invalid registry URL: ${n.url}`)}n.scope||a++}),a>1)throw new Error("You can't have more than one global registry.");(0,g6.info)(`Writing bunfig.toml to '${t}'.`);let i={};if((0,Ys.existsSync)(t))try{let n=(0,Ys.readFileSync)(t,{encoding:"utf-8"});i=(0,zu.parse)(n)}catch(n){(0,g6.info)(`Error reading existing bunfig: ${n.message}`),i={}}i.install=i?.install||{},i.install.scopes=i?.install.scopes||{};let r=e.find(n=>!n.scope);r&&(i.install.registry={url:r.url,...r.token?{token:r.token}:{}});for(let n of e)if(n.scope){let s=n.scope.startsWith("@")?n.scope.toLowerCase():`@${n.scope.toLowerCase()}`;i.install.scopes[s]={url:n.url,...n.token?{token:n.token}:{}}}Object.keys(i.install.scopes).length===0&&delete i.install.scopes,(0,Ys.writeFileSync)(t,(0,zu.stringify)(i),{encoding:"utf8"})}o(D_,"writeBunfig");var z_=ya(rt());var Js=ya(rt()),A_=require("node:console"),Zs=require("node:fs"),ju=require("node:path");function y6(t,e,a=1e4){return t().catch(i=>{if(e<=0)throw i;return new Promise(r=>setTimeout(r,a)).then(()=>y6(t,e-1,a))})}o(y6,"retry");function B_(t,e){return t.endsWith(e)?t:((0,Zs.renameSync)(t,t+e),t+e)}o(B_,"addExtension");var SF={"package.json":t=>JSON.parse(t).packageManager?.split("bun@")?.[1],".tool-versions":t=>t.match(/^bun\s*(?<version>.*?)$/m)?.groups?.version,".bumrc":t=>t,".bun-version":t=>t};function M_(t){let e=process.env.GITHUB_WORKSPACE;if(!e||!t)return;(0,Js.debug)(`Reading version from ${t}`);let a=(0,ju.resolve)(e,t),i=(0,ju.basename)(t);if(!(0,Zs.existsSync)(a)){(0,Js.warning)(`File ${a} not found`);return}let r=SF[i]??(()=>{}),n;try{if(n=r((0,Zs.readFileSync)(a,"utf8"))?.trim(),!n){(0,Js.warning)(`Failed to read version from ${t}`);return}}catch(s){let{message:p}=s;(0,Js.warning)(`Failed to read ${t}: ${p}`)}finally{if(n)return(0,A_.info)(`Obtained version ${n} from ${t}`),n}}o(M_,"readVersionFromFile");var j_=require("node:process");var k_=o(async t=>{let e=(0,eo.join)((0,j_.cwd)(),"bunfig.toml");D_(e,t.registries);let a=TF(t),i=EF(t),r=(0,eo.join)((0,q_.homedir)(),".bun","bin");try{(0,bi.mkdirSync)(r,{recursive:!0})}catch(u){if(u.code!=="EEXIST")throw u}(0,hn.addPath)(r);let n=o(u=>process.platform==="win32"?`${u}.exe`:u,"exe"),s=(0,eo.join)(r,n("bun"));try{(0,bi.symlinkSync)(s,(0,eo.join)(r,n("bunx")))}catch(u){if(u.code!=="EEXIST")throw u}let p,l=!1;if(i){let u=(0,L_.createHash)("sha1").update(a).digest("base64");await(0,ku.restoreCache)([s],u)&&(p=await H_(s),p?(l=!0,(0,hn.info)(`Using a cached version of Bun: ${p}`)):(0,hn.warning)(`Found a cached version of Bun: ${p} (but it appears to be corrupted?)`))}if(l||((0,hn.info)(`Downloading a new version of Bun: ${a}`),p=await y6(async()=>await CF(a,s),3)),!p)throw new Error("Downloaded a new version of Bun, but failed to check its version? Try again.");let[d]=p.split("+");return(0,z_.saveState)("cache",JSON.stringify({cacheEnabled:i,cacheHit:l,bunPath:s,url:a})),{version:d,revision:p,bunPath:s,url:a,cacheHit:l}},"default");async function CF(t,e){let a=B_(await(0,Hp.downloadTool)(t),".zip"),i=await(0,Hp.extractZip)(a),r=await x6(i);try{(0,bi.renameSync)(r,e)}catch{(0,bi.copyFileSync)(r,e)}return await H_(e)}o(CF,"downloadBun");function EF(t){let{customUrl:e,version:a,noCache:i}=t;return i||e||!a||/latest|canary|action/i.test(a)?!1:(0,ku.isFeatureAvailable)()}o(EF,"isCacheEnabled");function TF(t){let{customUrl:e}=t;if(e)return e;let{version:a,os:i,arch:r,avx2:n,profile:s}=t,p=encodeURIComponent(a??"latest"),l=encodeURIComponent(i??process.platform),d=encodeURIComponent((i??process.platform)==="win32"&&(r??process.arch)==="arm64"?"x64":r??process.arch),c=encodeURIComponent(n??!0),u=encodeURIComponent(s??!1),{href:m}=new URL(`${p}/${l}/${d}?avx2=${c}&profile=${u}`,"https://bun.sh/download/");return m}o(TF,"getDownloadUrl");async function x6(t){for(let e of(0,bi.readdirSync)(t,{withFileTypes:!0})){let{name:a}=e,i=(0,eo.join)(t,a);if(e.isFile()){if(a==="bun"||a==="bun.exe")return i;if(/^bun.*\.zip/.test(a)){let r=await(0,Hp.extractZip)(i);return x6(r)}}if(/^bun/.test(a)&&e.isDirectory())return x6(i)}throw new Error("Could not find executable: bun")}o(x6,"extractBun");async function H_(t){let e=await(0,v6.getExecOutput)(t,["--revision"],{ignoreReturnCode:!0});if(e.exitCode===0&&/^\d+\.\d+\.\d+/.test(e.stdout))return e.stdout.trim();let a=await(0,v6.getExecOutput)(t,["--version"],{ignoreReturnCode:!0});if(a.exitCode===0&&/^\d+\.\d+\.\d+/.test(a.stdout))return a.stdout.trim()}o(H_,"getRevision");function U_(t){return t?.trim()?t.split(`
|
||||||
`).map(e=>e.trim()).filter(Boolean).map(OF).filter(Boolean):[]}o(U_,"parseRegistries");function OF(t){let e=t.match(/^(@[a-z0-9-_.]+|[a-z0-9-_.]+(?=:[a-z]+:\/\/)):(.+)$/i);if(e){let a=e[1],i=e[2].trim(),[r,n]=i.split("|",2).map(s=>s?.trim());try{return new URL(r),{url:r,scope:a,...n&&{token:n}}}catch{throw new Error(`Invalid URL in registry configuration: ${r}`)}}else{let[a,i]=t.split("|",2).map(r=>r?.trim());try{return new URL(a),{url:a,scope:"",...i&&{token:i}}}catch{throw new Error(`Invalid URL in registry configuration: ${a}`)}}}o(OF,"parseLine");process.env.RUNNER_TEMP||(process.env.RUNNER_TEMP=(0,V_.tmpdir)());var $_=U_((0,Lt.getInput)("registries")),F_=(0,Lt.getInput)("registry-url"),RF=(0,Lt.getInput)("scope");F_&&$_.push({url:F_,scope:RF,token:"$BUN_AUTH_TOKEN"});k_({version:(0,Lt.getInput)("bun-version")||M_((0,Lt.getInput)("bun-version-file"))||void 0,customUrl:(0,Lt.getInput)("bun-download-url")||void 0,registries:$_,noCache:(0,Lt.getBooleanInput)("no-cache")||!1}).then(({version:t,revision:e,bunPath:a,url:i,cacheHit:r})=>{(0,Lt.setOutput)("bun-version",t),(0,Lt.setOutput)("bun-revision",e),(0,Lt.setOutput)("bun-path",a),(0,Lt.setOutput)("bun-download-url",i),(0,Lt.setOutput)("cache-hit",r),process.exit(0)}).catch(t=>{(0,Lt.setFailed)(t),process.exit(1)});
|
`).map(e=>e.trim()).filter(Boolean).map(OF).filter(Boolean):[]}o(U_,"parseRegistries");function OF(t){let e=t.match(/^(@[a-z0-9-_.]+|[a-z0-9-_.]+(?=:[a-z]+:\/\/)):(.+)$/i);if(e){let a=e[1],i=e[2].trim(),[r,n]=i.split("|",2).map(s=>s?.trim());try{return new URL(r),{url:r,scope:a,...n&&{token:n}}}catch{throw new Error(`Invalid URL in registry configuration: ${r}`)}}else{let[a,i]=t.split("|",2).map(r=>r?.trim());try{return new URL(a),{url:a,scope:"",...i&&{token:i}}}catch{throw new Error(`Invalid URL in registry configuration: ${a}`)}}}o(OF,"parseLine");process.env.RUNNER_TEMP||(process.env.RUNNER_TEMP=(0,V_.tmpdir)());var $_=U_((0,Lt.getInput)("registries")),F_=(0,Lt.getInput)("registry-url"),RF=(0,Lt.getInput)("scope");F_&&$_.push({url:F_,scope:RF,token:"$BUN_AUTH_TOKEN"});k_({version:(0,Lt.getInput)("bun-version")||M_((0,Lt.getInput)("bun-version-file"))||void 0,customUrl:(0,Lt.getInput)("bun-download-url")||void 0,registries:$_,noCache:(0,Lt.getBooleanInput)("no-cache")||!1}).then(({version:t,revision:e,bunPath:a,url:i,cacheHit:r})=>{(0,Lt.setOutput)("bun-version",t),(0,Lt.setOutput)("bun-revision",e),(0,Lt.setOutput)("bun-path",a),(0,Lt.setOutput)("bun-download-url",i),(0,Lt.setOutput)("cache-hit",r),process.exit(0)}).catch(t=>{(0,Lt.setFailed)(t),process.exit(1)});
|
||||||
/*! Bundled license information:
|
/*! Bundled license information:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue