diff --git a/dist/index.mjs b/dist/index.mjs index e768615..a40e1e5 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -14,4 +14,4 @@ ${A.format(Q)} If you have not already done so, you can try authenticating calls to the GitHub API by setting the \`GITHUB_TOKEN\` environment variable. `)}throw Q}},Yc=async(A)=>{let Q=A.version;try{if(A.version==="latest"){const I=(await A.octokit.paginate("GET /repos/{owner}/{repo}/releases",{owner:"biomejs",repo:"biome"})).filter((C)=>{return C.tag_name.startsWith("cli/")&&!C.draft&&!C.prerelease}).map((C)=>{return CF.coerce(C.tag_name)});Q=CF.rsort(I)[0].version}return(await A.octokit.repos.getReleaseByTag({owner:"biomejs",repo:"biome",tag:`cli/v${Q}`})).data.id}catch(B){if(B instanceof iD){if(B.status===404)throw new Error(`Version ${A.version} of the Biome CLI does not exist.`);throw B}throw B}},Jc=async(A,Q)=>{const B=await Q.octokit.paginate("GET /repos/{owner}/{repo}/releases/{release_id}/assets",{owner:"biomejs",repo:"biome",release_id:A}),I=new Map([["linux",`linux-${Q.architecture}`],["darwin",`darwin-${Q.architecture}`],["win32",`win32-${Q.architecture}.exe`]]),E=B.find((C)=>C.name.endsWith(I.get(Q.platform)));if(!E)throw new Error(`Could not find an Biome CLI release for ${Q.platform} (${Q.architecture}) for the given version (${Q.version}).`);return E.browser_download_url},Nc=async(A,Q)=>{const B=gc(R5(A),`${Q.platform==="win32"?"biome.exe":"biome"}`);Cc(A,B),Ec(B,"755"),EF.addPath(R5(A))};var ng=eB(LI(),1),PB=eB(cU(),1);import{existsSync as er} from"node:fs";import{readFile as pF} from"node:fs/promises";import{join as ig} from"node:path";var wr=cG(),Lr=vg(),Vr=$G(),Q2=ug(),Wr=Tg(),TI=BA(),Mr=zI(),Zr=_A(),Xr=SI(),Kr=$I(),TBA=mF(),zr=tG(),Hr=eG(),Sr=A2(),dF=Zz(),Xz=Sg();var $r=wr.Composer,Tr=Lr.Document,qr=Vr.Schema,jr=Q2.YAMLError,Or=Q2.YAMLParseError,Pr=Q2.YAMLWarning,xr=Wr.Alias,yr=TI.isAlias,_r=TI.isCollection,hr=TI.isDocument,kr=TI.isMap,fr=TI.isNode,br=TI.isPair,vr=TI.isScalar,ur=TI.isSeq,mr=Mr.Pair,cr=Zr.Scalar,dr=Xr.YAMLMap,lr=Kr.YAMLSeq;var pr=zr.Lexer,ir=Hr.LineCounter,nr=Sr.Parser,lF=dF.parse,ar=dF.parseAllDocuments,sr=dF.parseDocument,rr=dF.stringify,or=Xz.visit,tr=Xz.visitAsync;var B2=eB(LI(),1),I2=(A)=>{return B2.getInput(A)===""?void 0:B2.getInput(A)};var Kz=async(A)=>{let Q=I2("working-dir");if(!Q)Q=process.cwd(),ng.info("No working directory specified. Using the current working directory.");if(Q&&!er(ig(Q)))Q=process.cwd(),ng.warning("The specified working directory does not exist. Using the current working directory instead.");return I2("version")??await Ao(Q)??await Qo(Q)??await Bo(Q)??await Io(Q,A)??"latest"},Ao=async(A)=>{try{return JSON.parse(await pF(ig(A,"package-lock.json"),"utf-8")).packages?.["node_modules/@biomejs/biome"]?.version}catch{return}},Qo=async(A)=>{try{const Q=lF(await pF(ig(A,"pnpm-lock.yaml"),"utf8"));return Q.importers["."]?.devDependencies["@biomejs/biome"]?.version??Q.importers["."]?.dependencies["@biomejs/biome"]?.version??Q.devDependencies?.["@biomejs/biome"]?.version??Q.dependencies?.["@biomejs/biome"]?.version}catch{return}},Bo=async(A)=>{try{const Q=lF(await pF(ig(A,"yarn.lock"),"utf8")).object,B=Object.keys(Q).filter((I)=>I.startsWith("@biomejs/biome@"))[0];return Q[B]?.version}catch{return}},Io=async(A,Q)=>{try{const B=JSON.parse(await pF(ig(A,"package.json"),"utf8")),I=B.devDependencies?.["@biomejs/biome"]??B.dependencies?.["@biomejs/biome"];if(!I)return;if(PB.valid(I))return I;if(PB.validRange(I)){ng.warning(`Please consider pinning the version of @biomejs/biome in your package.json file. - See https://biomejs.dev/internals/versioning/ for more information.`,{title:"Biome version range detected"});const E=await Eo(Q);if(!E)return;return PB.maxSatisfying(E,I,{includePrerelease:!1})?.version??void 0}}catch{return}},Eo=async(A)=>{try{const B=(await A.paginate("GET /repos/{owner}/{repo}/releases",{owner:"biomejs",repo:"biome"})).filter((I)=>I.tag_name.startsWith("cli/")).map((I)=>PB.coerce(I.tag_name));return PB.rsort(B)}catch{return}};(async()=>{const A=new zz.Octokit({auth:(await g2()()).token});await V5({version:await Kz(A),platform:process.platform,architecture:process.arch,octokit:A})})(); + See https://biomejs.dev/internals/versioning/ for more information.`,{title:"Biome version range detected"});const E=await Eo(Q);if(!E)return;return PB.maxSatisfying(E,I)?.version??void 0}}catch{return}},Eo=async(A)=>{try{const B=(await A.paginate("GET /repos/{owner}/{repo}/releases",{owner:"biomejs",repo:"biome"})).filter((I)=>I.tag_name.startsWith("cli/")&&!I.draft&&!I.prerelease).map((I)=>PB.coerce(I.tag_name));return PB.rsort(B)}catch{return}};(async()=>{const A=new zz.Octokit({auth:(await g2()()).token});await V5({version:await Kz(A),platform:process.platform,architecture:process.arch,octokit:A})})();