mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore(cli): Upgrade jsonc_parser to 0.17 (#9977)
Use new parse_to_serde_value as it's faster and less code here.
This commit is contained in:
parent
1312a57984
commit
eed4e29337
4 changed files with 21 additions and 45 deletions
|
@ -35,8 +35,8 @@
|
||||||
"tools/wpt/manifest.json"
|
"tools/wpt/manifest.json"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"https://plugins.dprint.dev/typescript-0.41.0.wasm",
|
"https://plugins.dprint.dev/typescript-0.43.0.wasm",
|
||||||
"https://plugins.dprint.dev/json-0.9.0.wasm",
|
"https://plugins.dprint.dev/json-0.10.0.wasm",
|
||||||
"https://plugins.dprint.dev/markdown-0.6.0.wasm"
|
"https://plugins.dprint.dev/markdown-0.6.2.wasm"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -265,9 +265,9 @@ checksum = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.6.0"
|
version = "3.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9"
|
checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
|
@ -778,9 +778,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dprint-core"
|
name = "dprint-core"
|
||||||
version = "0.35.2"
|
version = "0.35.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a0edf9f35fbd32eb53b7e047cb1da4208c70e9c3643a733478fd7c99d98009b3"
|
checksum = "93bd44f40b1881477837edc7112695d4b174f058c36c1cbc4c50f8d0482e2ac8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"fnv",
|
"fnv",
|
||||||
|
@ -789,9 +789,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dprint-plugin-json"
|
name = "dprint-plugin-json"
|
||||||
version = "0.9.0"
|
version = "0.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "92e1e2cc629e68adce3eed0ce1bfb6c75aa6e53c0f0dda04d230fdf73d275f76"
|
checksum = "192d9caba72e0955a19026d139a4e412f9be3b0ba0712f1f584f2cf6e391f472"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dprint-core",
|
"dprint-core",
|
||||||
"jsonc-parser",
|
"jsonc-parser",
|
||||||
|
@ -800,9 +800,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dprint-plugin-markdown"
|
name = "dprint-plugin-markdown"
|
||||||
version = "0.6.0"
|
version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5600cc5d99205c6adfd79c825e4d6ac86581e9215c9b2d69a0448b0c2f2861a1"
|
checksum = "adc6e49d7c853ab62958e744f12498368d71c25c398c523364ac1810845089df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dprint-core",
|
"dprint-core",
|
||||||
"pulldown-cmark",
|
"pulldown-cmark",
|
||||||
|
@ -1672,9 +1672,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonc-parser"
|
name = "jsonc-parser"
|
||||||
version = "0.15.1"
|
version = "0.17.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da59eeab742770775c0f85b0b7b847f247b540a5389b806301d71c697d62bd8b"
|
checksum = "0cb8a8eb6349c33f5ff1c6f12d09936f048c039411c9a08cd54a378fbf1905e2"
|
||||||
|
dependencies = [
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kernel32-sys"
|
name = "kernel32-sys"
|
||||||
|
|
|
@ -44,15 +44,15 @@ base64 = "0.13.0"
|
||||||
byteorder = "1.4.2"
|
byteorder = "1.4.2"
|
||||||
clap = "2.33.3"
|
clap = "2.33.3"
|
||||||
dissimilar = "1.0.2"
|
dissimilar = "1.0.2"
|
||||||
dprint-plugin-json = "0.9.0"
|
dprint-plugin-json = "0.10.1"
|
||||||
dprint-plugin-markdown = "0.6.0"
|
dprint-plugin-markdown = "0.6.2"
|
||||||
dprint-plugin-typescript = "0.41.0"
|
dprint-plugin-typescript = "0.41.0"
|
||||||
encoding_rs = "0.8.28"
|
encoding_rs = "0.8.28"
|
||||||
env_logger = "0.8.2"
|
env_logger = "0.8.2"
|
||||||
filetime = "0.2.14"
|
filetime = "0.2.14"
|
||||||
http = "0.2.3"
|
http = "0.2.3"
|
||||||
indexmap = { version = "1.6.1", features = ["serde"] }
|
indexmap = { version = "1.6.1", features = ["serde"] }
|
||||||
jsonc-parser = "0.15.1"
|
jsonc-parser = { version = "0.17.0", features = ["serde"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
libc = "0.2.86"
|
libc = "0.2.86"
|
||||||
log = { version = "0.4.14", features = ["serde"] }
|
log = { version = "0.4.14", features = ["serde"] }
|
||||||
|
|
|
@ -8,13 +8,11 @@ use deno_core::serde::Serializer;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_core::serde_json::json;
|
use deno_core::serde_json::json;
|
||||||
use deno_core::serde_json::Value;
|
use deno_core::serde_json::Value;
|
||||||
use jsonc_parser::JsonValue;
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
/// The transpile options that are significant out of a user provided tsconfig
|
/// The transpile options that are significant out of a user provided tsconfig
|
||||||
/// file, that we want to deserialize out of the final config for a transpile.
|
/// file, that we want to deserialize out of the final config for a transpile.
|
||||||
|
@ -148,31 +146,6 @@ pub fn json_merge(a: &mut Value, b: &Value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a jsonc libraries `JsonValue` to a serde `Value`.
|
|
||||||
fn jsonc_to_serde(j: JsonValue) -> Value {
|
|
||||||
match j {
|
|
||||||
JsonValue::Array(arr) => {
|
|
||||||
let vec = arr.into_iter().map(jsonc_to_serde).collect();
|
|
||||||
Value::Array(vec)
|
|
||||||
}
|
|
||||||
JsonValue::Boolean(bool) => Value::Bool(bool),
|
|
||||||
JsonValue::Null => Value::Null,
|
|
||||||
JsonValue::Number(num) => {
|
|
||||||
let number =
|
|
||||||
serde_json::Number::from_str(&num).expect("could not parse number");
|
|
||||||
Value::Number(number)
|
|
||||||
}
|
|
||||||
JsonValue::Object(obj) => {
|
|
||||||
let mut map = serde_json::map::Map::new();
|
|
||||||
for (key, json_value) in obj.into_iter() {
|
|
||||||
map.insert(key, jsonc_to_serde(json_value));
|
|
||||||
}
|
|
||||||
Value::Object(map)
|
|
||||||
}
|
|
||||||
JsonValue::String(str) => Value::String(str),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
struct TsConfigJson {
|
struct TsConfigJson {
|
||||||
|
@ -220,8 +193,8 @@ pub fn parse_config(
|
||||||
path: &Path,
|
path: &Path,
|
||||||
) -> Result<(Value, Option<IgnoredCompilerOptions>), AnyError> {
|
) -> Result<(Value, Option<IgnoredCompilerOptions>), AnyError> {
|
||||||
assert!(!config_text.is_empty());
|
assert!(!config_text.is_empty());
|
||||||
let jsonc = jsonc_parser::parse_to_value(config_text)?.unwrap();
|
let jsonc = jsonc_parser::parse_to_serde_value(config_text)?.unwrap();
|
||||||
let config: TsConfigJson = serde_json::from_value(jsonc_to_serde(jsonc))?;
|
let config: TsConfigJson = serde_json::from_value(jsonc)?;
|
||||||
|
|
||||||
if let Some(compiler_options) = config.compiler_options {
|
if let Some(compiler_options) = config.compiler_options {
|
||||||
parse_compiler_options(&compiler_options, Some(path.to_owned()), false)
|
parse_compiler_options(&compiler_options, Some(path.to_owned()), false)
|
||||||
|
|
Loading…
Reference in a new issue