@@ -19,7 +19,6 @@ if (cargoTomlVersion.tag === latestTag.tag) {
1919$ . log ( "Found new version." ) ;
2020$ . logStep ( "Updating rust-toolchain.toml..." ) ;
2121await updateRustToolchain ( latestTag . tag ) ;
22-
2322$ . logStep ( "Updating Cargo.toml..." ) ;
2423const isPatchBump = cargoTomlVersion . version . major === latestTag . version . major
2524 && cargoTomlVersion . version . minor === latestTag . version . minor ;
@@ -82,29 +81,10 @@ function tagToVersion(tag: string) {
8281 return semver . parse ( tag . replace ( / ^ @ b i o m e j s \/ b i o m e @ / , "" ) ) ;
8382}
8483
85- async function getGitTags ( ) : Promise < string [ ] > {
86- const client = new Octokit ( ) ;
87- const tags = await client . paginate ( "GET /repos/{owner}/{repo}/tags" , {
88- owner : "biomejs" ,
89- repo : "biome" ,
90- per_page : 100 ,
91- } ) ;
92- return tags . map ( tag => tag . name ) ;
93- }
94-
9584async function updateRustToolchain ( tag : string ) {
96- // biome's tag (e.g. "@biomejs/biome@2.3.10") contains "/" and "@",
97- // both of which need percent-encoding in the raw.githubusercontent.com URL.
98- const encodedTag = encodeURIComponent ( tag ) ;
99- // .noThrow() so we can branch on 404 instead of throwing.
100- const response = await $ . request (
101- `https://raw.githubusercontent.com/biomejs/biome/${ encodedTag } /rust-toolchain.toml` ,
102- ) . noThrow ( ) ;
103- if ( response . status === 404 ) {
104- $ . log ( `biome ${ tag } does not include a rust-toolchain.toml; leaving local one alone.` ) ;
105- return ;
106- }
107- const content = await response . text ( ) ;
85+ const content = await $ . request (
86+ `https://raw.githubusercontent.com/biomejs/biome/${ tag } /rust-toolchain.toml` ,
87+ ) . text ( ) ;
10888 const match = content . match ( / c h a n n e l \s * = \s * " ( [ ^ " ] + ) " / ) ;
10989 if ( match == null ) {
11090 throw new Error ( "Could not find channel in biome's rust-toolchain.toml." ) ;
@@ -116,16 +96,21 @@ async function updateRustToolchain(tag: string) {
11696 if ( localMatch == null ) {
11797 throw new Error ( "Could not find channel in local rust-toolchain.toml." ) ;
11898 }
119- // rust-toolchain.toml channels may be just "1.84" (no patch); pad to
120- // MAJOR.MINOR.PATCH so @std /semver can parse it.
121- const normalize = ( v : string ) => / ^ \d + \. \d + $ / . test ( v ) ? `${ v } .0` : v ;
122- // only bump up; never downgrade. compare as semver so 1.95.0 > 1.91.0.
123- const local = semver . parse ( normalize ( localMatch [ 1 ] ) ) ;
124- const upstream = semver . parse ( normalize ( biomeRustVersion ) ) ;
125- if ( semver . greaterThan ( upstream , local ) ) {
99+ if ( localMatch [ 1 ] !== biomeRustVersion ) {
126100 $ . log ( `Updating Rust toolchain: ${ localMatch [ 1 ] } -> ${ biomeRustVersion } ` ) ;
127101 toolchainPath . writeTextSync ( localContent . replace ( localMatch [ 0 ] , `channel = "${ biomeRustVersion } "` ) ) ;
128102 } else {
129- $ . log ( `Rust toolchain at ${ localMatch [ 1 ] } already satisfies biome ${ tag } (needs >= ${ biomeRustVersion } ) .` ) ;
103+ $ . log ( `Rust toolchain already at ${ biomeRustVersion } .` ) ;
130104 }
131105}
106+
107+ async function getGitTags ( ) : Promise < string [ ] > {
108+ const client = new Octokit ( ) ;
109+ const tags = await client . paginate ( "GET /repos/{owner}/{repo}/tags" , {
110+ owner : "biomejs" ,
111+ repo : "biome" ,
112+ per_page : 100 ,
113+ } ) ;
114+ return tags . map ( tag => tag . name ) ;
115+ }
116+
0 commit comments