From bfda2e32c36d2b8a3b77f613fce3587a8c9b2024 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 3 May 2024 14:53:37 +0100 Subject: [PATCH 1/3] chore(deps): upgrade oxc_resolver --- Cargo.lock | 59 ++++++------- Cargo.toml | 4 +- crates/biome_fs/src/fs/os.rs | 2 +- xtask/contributors/Cargo.toml | 15 ---- xtask/contributors/src/main.rs | 146 --------------------------------- 5 files changed, 29 insertions(+), 197 deletions(-) delete mode 100644 xtask/contributors/Cargo.toml delete mode 100644 xtask/contributors/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 19151a806ff9..e60300a431a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1217,6 +1217,12 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +[[package]] +name = "clean-path" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaa6b4b263a5d737e9bf6b7c09b72c41a5480aec4d7219af827f6564e950b6a5" + [[package]] name = "codspeed" version = "2.6.0" @@ -1883,15 +1889,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" -[[package]] -name = "html-escape" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476" -dependencies = [ - "utf8-width", -] - [[package]] name = "httparse" version = "1.8.0" @@ -2382,13 +2379,12 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "oxc_resolver" -version = "1.5.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47777510a49fc554e7fb33101b67b6dc0bca28ea6d6fa852c113241e433a9e89" +checksum = "ab805c61c1758a7bf350c52ab8962307d1c0fe9677ffa0ac5007789c2e98858f" dependencies = [ "dashmap", "dunce", - "indexmap 2.2.6", "json-strip-comments", "once_cell", "rustc-hash", @@ -2396,6 +2392,7 @@ dependencies = [ "serde_json", "thiserror", "tracing", + "typescript_tsconfig_json", ] [[package]] @@ -3173,18 +3170,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", @@ -3534,6 +3531,19 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "typescript_tsconfig_json" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7cc416eaf05297012ead9d192226fe9a92e9a20f64f8780efb9085aaae9b590" +dependencies = [ + "clean-path", + "indexmap 2.2.6", + "rustc-hash", + "serde", + "serde_json", +] + [[package]] name = "unicase" version = "2.6.0" @@ -3634,12 +3644,6 @@ dependencies = [ "serde", ] -[[package]] -name = "utf8-width" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" - [[package]] name = "valuable" version = "0.1.0" @@ -4091,17 +4095,6 @@ dependencies = [ "xtask", ] -[[package]] -name = "xtask_contributors" -version = "0.0.0" -dependencies = [ - "html-escape", - "pico-args", - "serde", - "ureq", - "xtask", -] - [[package]] name = "xtask_coverage" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index d9c19be3cfd4..39305a8fab4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] # Use the newer version of the cargo resolver # https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions -members = ["crates/*", "xtask/bench", "xtask/codegen", "xtask/coverage", "xtask/libs_bench", "xtask/contributors"] +members = ["crates/*", "xtask/bench", "xtask/codegen", "xtask/coverage", "xtask/libs_bench"] resolver = "2" [workspace.lints.rust] @@ -162,7 +162,7 @@ ignore = "0.4.21" indexmap = { version = "2.2.6", features = ["serde"] } insta = "1.38.0" lazy_static = "1.4.0" -oxc_resolver = "1.4.0" +oxc_resolver = "1.7.0" proc-macro2 = "1.0.81" quickcheck = "1.0.3" quickcheck_macros = "1.0.0" diff --git a/crates/biome_fs/src/fs/os.rs b/crates/biome_fs/src/fs/os.rs index 4ea395464788..4b763904574f 100644 --- a/crates/biome_fs/src/fs/os.rs +++ b/crates/biome_fs/src/fs/os.rs @@ -46,7 +46,7 @@ impl Default for OsFileSystem { working_directory: env::current_dir().ok(), configuration_resolver: AssertUnwindSafe(Resolver::new(ResolveOptions { condition_names: vec!["node".to_string(), "import".to_string()], - extensions: vec!["*.json".to_string(), "*.jsonc".to_string()], + extensions: vec![".json".to_string(), ".jsonc".to_string()], ..ResolveOptions::default() })), } diff --git a/xtask/contributors/Cargo.toml b/xtask/contributors/Cargo.toml deleted file mode 100644 index b55591bdcf54..000000000000 --- a/xtask/contributors/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -edition = "2021" -name = "xtask_contributors" -publish = false -version = "0.0.0" - -[dependencies] -html-escape = "0.2.13" -pico-args = "0.5.0" -serde = { workspace = true, features = ["derive"] } -ureq = { version = "2.9.7", features = ["json"] } -xtask = { path = '../', version = "0.0" } - -[lints] -workspace = true diff --git a/xtask/contributors/src/main.rs b/xtask/contributors/src/main.rs deleted file mode 100644 index 1f34cf5d9a01..000000000000 --- a/xtask/contributors/src/main.rs +++ /dev/null @@ -1,146 +0,0 @@ -use pico_args::Arguments; -use serde::{Deserialize, Serialize}; -use std::fmt::Write; -use std::path::PathBuf; -use xtask::glue::fs2; -use xtask::*; - -/// A token is needed to run this script. To create a token, go to -/// and give it read access to the repository. -/// -/// Only users that have read rights can run this script -fn main() -> Result<()> { - let root = project_root().join("website/src/components"); - let mut args = Arguments::from_env(); - let token: String = args.value_from_str("--token").unwrap(); - let contributors = get_contributors(token.as_str()); - write_contributors_in_credits(root.clone(), contributors.as_slice())?; - write_contributors_in_community(root.clone(), contributors.as_slice())?; - - Ok(()) -} -const IMPORT_IMAGE: &str = "import { Image } from \"astro:assets\";"; - -fn write_contributors_in_community(root: PathBuf, contributors: &[Contributor]) -> Result<()> { - let mut content = String::new(); - - content.push_str(format!("---\n// {}\n{}\n---\n", PREAMBLE, IMPORT_IMAGE).as_str()); - - let contributors_per_row = [5, 4, 6, 5, 3, 5, 4]; - - let mut current_index = 0; - for items_per_row in contributors_per_row { - let current_contributors = &contributors[current_index..current_index + items_per_row]; - writeln!(content, "
")?; - for contributor in current_contributors { - let person = format!("User {}", contributor.login); - - writeln!( - content, - "\"{}\"", - contributor.avatar_url, person - )?; - } - current_index += items_per_row; - - writeln!(content, "
")?; - } - - fs2::write(root.join("Community.astro"), content)?; - Ok(()) -} - -fn write_contributors_in_credits(root: PathBuf, contributors: &[Contributor]) -> Result<()> { - let mut content = String::new(); - - content.push_str(format!("---\n// {}\n{}\n---\n", PREAMBLE, IMPORT_IMAGE).as_str()); - - content.push('\n'); - content.push_str("

Code contributors

"); - content.push('\n'); - content.push_str("\n"); - fs2::write(root.join("Contributors.astro"), content)?; - Ok(()) -} - -#[derive(Debug, Deserialize, Serialize, Ord, PartialOrd, Eq, PartialEq)] -struct Contributor { - avatar_url: String, - login: String, - id: u64, - contributions: u64, -} - -fn get_contributors(token: &str) -> Vec { - let mut contributors = Vec::new(); - contributors_request( - "https://api.github.com/repos/biomejs/biome/contributors", - token, - &mut contributors, - ); - contributors.sort_by(|a, b| b.contributions.cmp(&a.contributions)); - contributors.retain(|c| !c.login.ends_with("[bot]")); - contributors -} - -fn contributors_request(url: &str, token: &str, contributors: &mut Vec) { - let request = ureq::get(url) - .set("User-Agent", "@biomejs") - .set("Authorization", &format!("token {token}")); - - match request.call() { - Ok(response) => { - if let Some(link) = response.header("link") { - if link.contains("rel=\"next\"") { - let start_index = link - .find("rel=\"prev\", ") - .map_or(0, |index| index + "rel=\"prev\", ".len()); - // SAFETY: checked before - let end_index = link.find("; rel=\"next\"").unwrap(); - let url = &link[start_index..end_index]; - let url = url.replace(['<', '>'], ""); - - contributors_request(&url, token, contributors); - } - } - let result: Result, std::io::Error> = response.into_json(); - if let Ok(new_contributors) = result { - contributors.extend(new_contributors); - } - } - Err(err) => { - eprintln!("{:?}", err); - } - } -} From 15ce5e1c5283d5a126781d1df696179939d9e51b Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 3 May 2024 15:13:09 +0100 Subject: [PATCH 2/3] fix --- crates/biome_fs/src/fs/os.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/biome_fs/src/fs/os.rs b/crates/biome_fs/src/fs/os.rs index 4b763904574f..84830d75173b 100644 --- a/crates/biome_fs/src/fs/os.rs +++ b/crates/biome_fs/src/fs/os.rs @@ -33,7 +33,7 @@ impl OsFileSystem { working_directory: Some(working_directory), configuration_resolver: AssertUnwindSafe(Resolver::new(ResolveOptions { condition_names: vec!["node".to_string(), "import".to_string()], - extensions: vec!["*.json".to_string(), "*.jsonc".to_string()], + extensions: vec![".json".to_string(), ".jsonc".to_string()], ..ResolveOptions::default() })), } From 5a7aaa7338092adc61666779db5053370676e13a Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Fri, 3 May 2024 16:29:24 +0100 Subject: [PATCH 3/3] fix test --- crates/biome_configuration/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/biome_configuration/src/lib.rs b/crates/biome_configuration/src/lib.rs index 5215568138e7..1093bc0660a7 100644 --- a/crates/biome_configuration/src/lib.rs +++ b/crates/biome_configuration/src/lib.rs @@ -296,7 +296,7 @@ mod test { Test {}, ResolveOptions { condition_names: vec!["node".to_string(), "import".to_string()], - extensions: vec!["*.json".to_string()], + extensions: vec![".json".to_string()], ..ResolveOptions::default() }, );