From 92836c0e9cb49a17141b6e6bc0711e54bf13a7a3 Mon Sep 17 00:00:00 2001 From: Trevor Hilton Date: Sun, 3 Nov 2024 12:25:25 -0800 Subject: [PATCH] chore: clean up deps and remove once_cell (#105) --- serde_json_path/CHANGELOG.md | 1 + serde_json_path/Cargo.toml | 18 ++++++------ .../src/parser/selector/function/registry.rs | 28 +++++++++---------- serde_json_path_core/CHANGELOG.md | 2 ++ serde_json_path_core/Cargo.toml | 11 ++++---- serde_json_path_core/src/spec/functions.rs | 6 ++-- serde_json_path_macros/CHANGELOG.md | 8 ++++-- serde_json_path_macros/Cargo.toml | 3 +- .../src/internal/Cargo.toml | 6 ++-- .../src/internal/common/define.rs | 2 +- serde_json_path_macros/src/lib.rs | 3 -- 11 files changed, 46 insertions(+), 42 deletions(-) diff --git a/serde_json_path/CHANGELOG.md b/serde_json_path/CHANGELOG.md index 888f539..48c49df 100644 --- a/serde_json_path/CHANGELOG.md +++ b/serde_json_path/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#93]: https://github.com/hiltontj/serde_json_path/pull/93 [#98]: https://github.com/hiltontj/serde_json_path/pull/98 [i-json-range]: https://www.rfc-editor.org/rfc/rfc9535.html#section-2.1-4.1 +[#105]: https://github.com/hiltontj/serde_json_path/pull/105 # 0.6.7 (3 March 2024) diff --git a/serde_json_path/Cargo.toml b/serde_json_path/Cargo.toml index efc966e..71ddc85 100644 --- a/serde_json_path/Cargo.toml +++ b/serde_json_path/Cargo.toml @@ -17,17 +17,19 @@ trace = ["dep:tracing", "serde_json_path_core/trace"] functions = ["serde_json_path_core/functions"] [dependencies] -inventory = { version = "0.3.4" } +# crates.io crates: +inventory = { version = "0.3.15" } nom = "7.1.3" -once_cell = { version = "1.17.1" } -regex = { version="1.7.1", optional = true } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +regex = { version="1.11.1", optional = true } +serde = { version = "1.0.214", features = ["derive"] } +serde_json = "1.0.1" +thiserror = "1.0.67" +tracing = { version = "0.1.40", optional = true } + +# local crates: serde_json_path_core = { path = "../serde_json_path_core", version = "0.1.6" } serde_json_path_macros = { path = "../serde_json_path_macros", version = "0.1.4" } -thiserror = "1.0" -tracing = { version = "0.1", optional = true } [dev-dependencies] test-log = { version = "0.2.11", default-features = false, features=["trace"] } -tracing-subscriber = { version = "0.3", default-features = false, features=["env-filter", "fmt"] } +tracing-subscriber = { version = "0.3.18", default-features = false, features=["env-filter", "fmt"] } diff --git a/serde_json_path/src/parser/selector/function/registry.rs b/serde_json_path/src/parser/selector/function/registry.rs index a5644b1..8174ca3 100644 --- a/serde_json_path/src/parser/selector/function/registry.rs +++ b/serde_json_path/src/parser/selector/function/registry.rs @@ -1,6 +1,5 @@ -use std::collections::HashMap; +use std::{collections::HashMap, sync::LazyLock}; -use once_cell::sync::Lazy; use serde_json::Value; use serde_json_path_core::spec::functions::{Function, LogicalType, NodesType, ValueType}; @@ -15,18 +14,19 @@ use serde_json_path_core::spec::functions::{Function, LogicalType, NodesType, Va /// the return type for each function registered here. When adding new functions to /// the register, i.e., when new functions are standardized, the function there needs /// to be updated too. -pub(crate) static REGISTRY: Lazy> = Lazy::new(|| { - let mut m = HashMap::new(); - m.insert("length", &LENGTH_FUNC); - m.insert("count", &COUNT_FUNC); - #[cfg(feature = "regex")] - { - m.insert("match", &MATCH_FUNC); - m.insert("search", &SEARCH_FUNC); - } - m.insert("value", &VALUE_FUNC); - m -}); +pub(crate) static REGISTRY: LazyLock> = + LazyLock::new(|| { + let mut m = HashMap::new(); + m.insert("length", &LENGTH_FUNC); + m.insert("count", &COUNT_FUNC); + #[cfg(feature = "regex")] + { + m.insert("match", &MATCH_FUNC); + m.insert("search", &SEARCH_FUNC); + } + m.insert("value", &VALUE_FUNC); + m + }); fn value_length(value: &Value) -> Option { match value { diff --git a/serde_json_path_core/CHANGELOG.md b/serde_json_path_core/CHANGELOG.md index 1d48ea4..da86695 100644 --- a/serde_json_path_core/CHANGELOG.md +++ b/serde_json_path_core/CHANGELOG.md @@ -8,9 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased - **breaking**: ensure integers used as indices are within the [valid range for I-JSON][i-json-range] ([#98]) +- **internal**: remove use of `once_cell` and use specific versions for crate dependencies ([#105]) [#98]: https://github.com/hiltontj/serde_json_path/pull/98 [i-json-range]: https://www.rfc-editor.org/rfc/rfc9535.html#section-2.1-4.1 +[#105]: https://github.com/hiltontj/serde_json_path/pull/105 # 0.1.6 (3 March 2024) diff --git a/serde_json_path_core/Cargo.toml b/serde_json_path_core/Cargo.toml index 4fc904e..037857d 100644 --- a/serde_json_path_core/Cargo.toml +++ b/serde_json_path_core/Cargo.toml @@ -17,12 +17,11 @@ trace = ["dep:tracing"] functions = [] [dependencies] -inventory = { version = "0.3.4" } -once_cell = "1" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -thiserror = "1.0" -tracing = { version = "0.1", optional = true } +inventory = { version = "0.3.15" } +serde = { version = "1.0.214", features = ["derive"] } +serde_json = "1.0.1" +thiserror = "1.0.67" +tracing = { version = "0.1.40", optional = true } [dev-dependencies] serde_json_path = { path = "../serde_json_path" } diff --git a/serde_json_path_core/src/spec/functions.rs b/serde_json_path_core/src/spec/functions.rs index 8bcbdf2..d288ef4 100644 --- a/serde_json_path_core/src/spec/functions.rs +++ b/serde_json_path_core/src/spec/functions.rs @@ -137,9 +137,9 @@ use std::{ collections::VecDeque, ops::{Deref, DerefMut}, + sync::LazyLock, }; -use once_cell::sync::Lazy; use serde_json::Value; use crate::{node::NodeList, spec::query::Queryable}; @@ -151,11 +151,11 @@ use super::{ #[doc(hidden)] pub type Validator = - Lazy Result<(), FunctionValidationError> + Send + Sync>>; + LazyLock Result<(), FunctionValidationError> + Send + Sync>>; #[doc(hidden)] pub type Evaluator = - Lazy Fn(VecDeque>) -> JsonPathValue<'a> + Sync + Send>>; + LazyLock Fn(VecDeque>) -> JsonPathValue<'a> + Sync + Send>>; #[doc(hidden)] #[allow(missing_debug_implementations)] diff --git a/serde_json_path_macros/CHANGELOG.md b/serde_json_path_macros/CHANGELOG.md index 9733b94..72e0b8b 100644 --- a/serde_json_path_macros/CHANGELOG.md +++ b/serde_json_path_macros/CHANGELOG.md @@ -7,13 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased +- **internal**: remove use of `once_cell` and use specific versions for crate dependencies ([#105]) + +[#105]: https://github.com/hiltontj/serde_json_path/pull/105 + # 0.1.4 (3 March 2024) -- **testing**: support tests for non-determinism in compliance test suite ([#85]) - **fixed**: bug preventing registered functions from being used as arguments to other functions ([#84]) +- **testing**: support tests for non-determinism in compliance test suite ([#85]) -[#85]: https://github.com/hiltontj/serde_json_path/pull/85 [#84]: https://github.com/hiltontj/serde_json_path/pull/84 +[#85]: https://github.com/hiltontj/serde_json_path/pull/85 # 0.1.3 (23 February 2024) diff --git a/serde_json_path_macros/Cargo.toml b/serde_json_path_macros/Cargo.toml index db29a74..29afdbc 100644 --- a/serde_json_path_macros/Cargo.toml +++ b/serde_json_path_macros/Cargo.toml @@ -12,10 +12,9 @@ keywords = ["json", "jsonpath", "json_path", "serde", "serde_json"] [lib] [dependencies] +inventory = "0.3.15" serde_json_path_macros_internal = { path = "src/internal", version = "0.1.1" } serde_json_path_core = { path = "../serde_json_path_core", version = "0.1.6" } -inventory = "0.3" -once_cell = "1" [dev-dependencies] serde_json = "1" diff --git a/serde_json_path_macros/src/internal/Cargo.toml b/serde_json_path_macros/src/internal/Cargo.toml index 8e4bb5d..842bbc4 100644 --- a/serde_json_path_macros/src/internal/Cargo.toml +++ b/serde_json_path_macros/src/internal/Cargo.toml @@ -14,6 +14,6 @@ proc-macro = true path = "mod.rs" [dependencies] -proc-macro2 = "1.0" -quote = "1.0" -syn = { version = "2.0", features = ["full"] } +proc-macro2 = "1.0.89" +quote = "1.0.37" +syn = { version = "2.0.87", features = ["full"] } diff --git a/serde_json_path_macros/src/internal/common/define.rs b/serde_json_path_macros/src/internal/common/define.rs index 8a6c966..9902b8b 100644 --- a/serde_json_path_macros/src/internal/common/define.rs +++ b/serde_json_path_macros/src/internal/common/define.rs @@ -45,7 +45,7 @@ pub(crate) fn expand(input: ItemFn, name_str: Option) -> Result