mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore: upgrade dprint-core to 0.54.1 (#14146)
This commit is contained in:
parent
d983b577bc
commit
03c71a8b4a
8 changed files with 77 additions and 71 deletions
|
@ -45,9 +45,9 @@
|
||||||
"tools/wpt/manifest.json"
|
"tools/wpt/manifest.json"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"https://plugins.dprint.dev/typescript-0.65.1.wasm",
|
"https://plugins.dprint.dev/typescript-0.66.0.wasm",
|
||||||
"https://plugins.dprint.dev/json-0.14.1.wasm",
|
"https://plugins.dprint.dev/json-0.15.0.wasm",
|
||||||
"https://plugins.dprint.dev/markdown-0.12.2.wasm",
|
"https://plugins.dprint.dev/markdown-0.13.0.wasm",
|
||||||
"https://plugins.dprint.dev/toml-0.5.4.wasm",
|
"https://plugins.dprint.dev/toml-0.5.4.wasm",
|
||||||
"https://plugins.dprint.dev/exec-0.2.1.exe-plugin@0a89a91810a212d9413e26d8946d41fbab3e2b5400362d764a1523839c4d78ea"
|
"https://plugins.dprint.dev/exec-0.2.1.exe-plugin@0a89a91810a212d9413e26d8946d41fbab3e2b5400362d764a1523839c4d78ea"
|
||||||
]
|
]
|
||||||
|
|
29
Cargo.lock
generated
29
Cargo.lock
generated
|
@ -115,9 +115,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.55"
|
version = "1.0.56"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
|
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
|
@ -1264,21 +1264,22 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dprint-core"
|
name = "dprint-core"
|
||||||
version = "0.50.0"
|
version = "0.54.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a596556533e5739e71dfe105c8b4496c3eccaf5aa96d14b19db2fdf4157085a"
|
checksum = "4ac67835685dd407cfb415eec8a114bafa6ab6de9bad29ba93d29f874f40bc1a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
|
"indexmap",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dprint-plugin-json"
|
name = "dprint-plugin-json"
|
||||||
version = "0.14.1"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5d7673b479d64372e60e344722789ed9c61ea1023e9a8a13c7da8e7d63b0f7dc"
|
checksum = "1a83f35e23681206c2a69a65946e66e5bb692543c6e0377c32208452a8995fe2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dprint-core",
|
"dprint-core",
|
||||||
|
@ -1289,9 +1290,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dprint-plugin-markdown"
|
name = "dprint-plugin-markdown"
|
||||||
version = "0.12.2"
|
version = "0.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "00a8c4e905bf5c95dbcc6eab7d81a1d884f7fbd0e7f2fd99af0154692fabc8a8"
|
checksum = "254ee918c51c21fa6ca20fe9556f3177b0b5be141df64952c6e353d17dbb5923"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dprint-core",
|
"dprint-core",
|
||||||
|
@ -1302,9 +1303,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dprint-plugin-typescript"
|
name = "dprint-plugin-typescript"
|
||||||
version = "0.65.1"
|
version = "0.66.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e482c9fe4929ec672d2bdaf0b6dcfee88684ec23858f0c54f225b565f08882ac"
|
checksum = "e464d85d3db3ba0c53b1bf207f13d32aba614ff5c032497f240938738568bc20"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"deno_ast",
|
"deno_ast",
|
||||||
|
@ -3641,9 +3642,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.133"
|
version = "1.0.136"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"
|
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
@ -3659,9 +3660,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.133"
|
version = "1.0.136"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"
|
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.36",
|
"proc-macro2 1.0.36",
|
||||||
"quote 1.0.14",
|
"quote 1.0.14",
|
||||||
|
|
|
@ -37,7 +37,7 @@ deno_webgpu = { version = "0.45.0", path = "../ext/webgpu" }
|
||||||
deno_websocket = { version = "0.49.0", path = "../ext/websocket" }
|
deno_websocket = { version = "0.49.0", path = "../ext/websocket" }
|
||||||
deno_webstorage = { version = "0.39.0", path = "../ext/webstorage" }
|
deno_webstorage = { version = "0.39.0", path = "../ext/webstorage" }
|
||||||
regex = "=1.5.5"
|
regex = "=1.5.5"
|
||||||
serde = { version = "=1.0.133", features = ["derive"] }
|
serde = { version = "=1.0.136", features = ["derive"] }
|
||||||
zstd = '=0.9.2'
|
zstd = '=0.9.2'
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
|
@ -62,9 +62,9 @@ clap_complete = "=3.1.1"
|
||||||
clap_complete_fig = "=3.1.4"
|
clap_complete_fig = "=3.1.4"
|
||||||
data-url = "=0.1.1"
|
data-url = "=0.1.1"
|
||||||
dissimilar = "=1.0.2"
|
dissimilar = "=1.0.2"
|
||||||
dprint-plugin-json = "=0.14.1"
|
dprint-plugin-json = "=0.15.0"
|
||||||
dprint-plugin-markdown = "=0.12.2"
|
dprint-plugin-markdown = "=0.13.0"
|
||||||
dprint-plugin-typescript = "=0.65.1"
|
dprint-plugin-typescript = "=0.66.0"
|
||||||
encoding_rs = "=0.8.29"
|
encoding_rs = "=0.8.29"
|
||||||
env_logger = "=0.8.4"
|
env_logger = "=0.8.4"
|
||||||
eszip = "=0.18.0"
|
eszip = "=0.18.0"
|
||||||
|
@ -87,7 +87,7 @@ ring = "=0.16.20"
|
||||||
rustyline = { version = "=9.1.2", default-features = false }
|
rustyline = { version = "=9.1.2", default-features = false }
|
||||||
rustyline-derive = "=0.6.0"
|
rustyline-derive = "=0.6.0"
|
||||||
semver-parser = "=0.10.2"
|
semver-parser = "=0.10.2"
|
||||||
serde = { version = "=1.0.133", features = ["derive"] }
|
serde = { version = "=1.0.136", features = ["derive"] }
|
||||||
shell-escape = "=0.1.5"
|
shell-escape = "=0.1.5"
|
||||||
sourcemap = "=6.0.1"
|
sourcemap = "=6.0.1"
|
||||||
tempfile = "=3.2.0"
|
tempfile = "=3.2.0"
|
||||||
|
|
|
@ -45,7 +45,10 @@ impl Lockfile {
|
||||||
let j = json!(&self.map);
|
let j = json!(&self.map);
|
||||||
let s = serde_json::to_string_pretty(&j).unwrap();
|
let s = serde_json::to_string_pretty(&j).unwrap();
|
||||||
|
|
||||||
let format_s = format_json(&s, &Default::default()).unwrap_or(s);
|
let format_s = format_json(&s, &Default::default())
|
||||||
|
.ok()
|
||||||
|
.flatten()
|
||||||
|
.unwrap_or(s);
|
||||||
let mut f = std::fs::OpenOptions::new()
|
let mut f = std::fs::OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
|
|
|
@ -1063,11 +1063,13 @@ impl Inner {
|
||||||
};
|
};
|
||||||
|
|
||||||
match format_result {
|
match format_result {
|
||||||
Ok(new_text) => Some(text::get_edits(
|
Ok(new_text) => new_text.map(|new_text| {
|
||||||
document.content().as_str(),
|
text::get_edits(
|
||||||
&new_text,
|
document.content().as_str(),
|
||||||
document.line_index().as_ref(),
|
&new_text,
|
||||||
)),
|
document.line_index().as_ref(),
|
||||||
|
)
|
||||||
|
}),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// TODO(lucacasonato): handle error properly
|
// TODO(lucacasonato): handle error properly
|
||||||
warn!("Format error: {}", err);
|
warn!("Format error: {}", err);
|
||||||
|
|
|
@ -126,8 +126,10 @@ impl CoverageCollector {
|
||||||
|
|
||||||
let mut out = BufWriter::new(File::create(filepath)?);
|
let mut out = BufWriter::new(File::create(filepath)?);
|
||||||
let coverage = serde_json::to_string(&script_coverage)?;
|
let coverage = serde_json::to_string(&script_coverage)?;
|
||||||
let formated_coverage =
|
let formated_coverage = format_json(&coverage, &Default::default())
|
||||||
format_json(&coverage, &Default::default()).unwrap_or(coverage);
|
.ok()
|
||||||
|
.flatten()
|
||||||
|
.unwrap_or(coverage);
|
||||||
|
|
||||||
out.write_all(formated_coverage.as_bytes())?;
|
out.write_all(formated_coverage.as_bytes())?;
|
||||||
out.flush()?;
|
out.flush()?;
|
||||||
|
|
|
@ -14,9 +14,11 @@ use crate::config_file::ProseWrap;
|
||||||
use crate::diff::diff;
|
use crate::diff::diff;
|
||||||
use crate::file_watcher;
|
use crate::file_watcher;
|
||||||
use crate::file_watcher::ResolutionResult;
|
use crate::file_watcher::ResolutionResult;
|
||||||
use crate::flags::{Flags, FmtFlags};
|
use crate::flags::Flags;
|
||||||
|
use crate::flags::FmtFlags;
|
||||||
|
use crate::fs_util::collect_files;
|
||||||
|
use crate::fs_util::get_extension;
|
||||||
use crate::fs_util::specifier_to_file_path;
|
use crate::fs_util::specifier_to_file_path;
|
||||||
use crate::fs_util::{collect_files, get_extension};
|
|
||||||
use crate::text_encoding;
|
use crate::text_encoding;
|
||||||
use deno_ast::ParsedSource;
|
use deno_ast::ParsedSource;
|
||||||
use deno_core::anyhow::bail;
|
use deno_core::anyhow::bail;
|
||||||
|
@ -24,9 +26,9 @@ use deno_core::anyhow::Context;
|
||||||
use deno_core::error::generic_error;
|
use deno_core::error::generic_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::futures;
|
use deno_core::futures;
|
||||||
|
use deno_core::parking_lot::Mutex;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use log::info;
|
use log::info;
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::stdin;
|
use std::io::stdin;
|
||||||
use std::io::stdout;
|
use std::io::stdout;
|
||||||
|
@ -34,8 +36,9 @@ use std::io::Read;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::AtomicUsize;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::atomic::Ordering;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Format JavaScript/TypeScript files.
|
/// Format JavaScript/TypeScript files.
|
||||||
pub async fn format(
|
pub async fn format(
|
||||||
|
@ -167,7 +170,7 @@ pub async fn format(
|
||||||
fn format_markdown(
|
fn format_markdown(
|
||||||
file_text: &str,
|
file_text: &str,
|
||||||
fmt_options: &FmtOptionsConfig,
|
fmt_options: &FmtOptionsConfig,
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
let markdown_config = get_resolved_markdown_config(fmt_options);
|
let markdown_config = get_resolved_markdown_config(fmt_options);
|
||||||
dprint_plugin_markdown::format_text(
|
dprint_plugin_markdown::format_text(
|
||||||
file_text,
|
file_text,
|
||||||
|
@ -196,7 +199,7 @@ fn format_markdown(
|
||||||
if matches!(extension, "json" | "jsonc") {
|
if matches!(extension, "json" | "jsonc") {
|
||||||
let mut json_config = get_resolved_json_config(fmt_options);
|
let mut json_config = get_resolved_json_config(fmt_options);
|
||||||
json_config.line_width = line_width;
|
json_config.line_width = line_width;
|
||||||
dprint_plugin_json::format_text(text, &json_config).map(Cow::Owned)
|
dprint_plugin_json::format_text(text, &json_config)
|
||||||
} else {
|
} else {
|
||||||
let fake_filename =
|
let fake_filename =
|
||||||
PathBuf::from(format!("deno_fmt_stdin.{}", extension));
|
PathBuf::from(format!("deno_fmt_stdin.{}", extension));
|
||||||
|
@ -208,10 +211,9 @@ fn format_markdown(
|
||||||
text,
|
text,
|
||||||
&codeblock_config,
|
&codeblock_config,
|
||||||
)
|
)
|
||||||
.map(Cow::Owned)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(Cow::Borrowed(text))
|
Ok(None)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -223,7 +225,7 @@ fn format_markdown(
|
||||||
pub fn format_json(
|
pub fn format_json(
|
||||||
file_text: &str,
|
file_text: &str,
|
||||||
fmt_options: &FmtOptionsConfig,
|
fmt_options: &FmtOptionsConfig,
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
let config = get_resolved_json_config(fmt_options);
|
let config = get_resolved_json_config(fmt_options);
|
||||||
dprint_plugin_json::format_text(file_text, &config)
|
dprint_plugin_json::format_text(file_text, &config)
|
||||||
}
|
}
|
||||||
|
@ -233,7 +235,7 @@ pub fn format_file(
|
||||||
file_path: &Path,
|
file_path: &Path,
|
||||||
file_text: &str,
|
file_text: &str,
|
||||||
fmt_options: FmtOptionsConfig,
|
fmt_options: FmtOptionsConfig,
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
let ext = get_extension(file_path).unwrap_or_default();
|
let ext = get_extension(file_path).unwrap_or_default();
|
||||||
if matches!(
|
if matches!(
|
||||||
ext.as_str(),
|
ext.as_str(),
|
||||||
|
@ -251,7 +253,7 @@ pub fn format_file(
|
||||||
pub fn format_parsed_source(
|
pub fn format_parsed_source(
|
||||||
parsed_source: &ParsedSource,
|
parsed_source: &ParsedSource,
|
||||||
fmt_options: FmtOptionsConfig,
|
fmt_options: FmtOptionsConfig,
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<Option<String>, AnyError> {
|
||||||
dprint_plugin_typescript::format_parsed_source(
|
dprint_plugin_typescript::format_parsed_source(
|
||||||
parsed_source,
|
parsed_source,
|
||||||
&get_resolved_typescript_config(&fmt_options),
|
&get_resolved_typescript_config(&fmt_options),
|
||||||
|
@ -276,18 +278,17 @@ async fn check_source_files(
|
||||||
let file_text = read_file_contents(&file_path)?.text;
|
let file_text = read_file_contents(&file_path)?.text;
|
||||||
|
|
||||||
match format_file(&file_path, &file_text, fmt_options.clone()) {
|
match format_file(&file_path, &file_text, fmt_options.clone()) {
|
||||||
Ok(formatted_text) => {
|
Ok(Some(formatted_text)) => {
|
||||||
if formatted_text != file_text {
|
not_formatted_files_count.fetch_add(1, Ordering::Relaxed);
|
||||||
not_formatted_files_count.fetch_add(1, Ordering::Relaxed);
|
let _g = output_lock.lock();
|
||||||
let _g = output_lock.lock().unwrap();
|
let diff = diff(&file_text, &formatted_text);
|
||||||
let diff = diff(&file_text, &formatted_text);
|
info!("");
|
||||||
info!("");
|
info!("{} {}:", colors::bold("from"), file_path.display());
|
||||||
info!("{} {}:", colors::bold("from"), file_path.display());
|
info!("{}", diff);
|
||||||
info!("{}", diff);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Ok(None) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _g = output_lock.lock().unwrap();
|
let _g = output_lock.lock();
|
||||||
eprintln!("Error checking: {}", file_path.to_string_lossy());
|
eprintln!("Error checking: {}", file_path.to_string_lossy());
|
||||||
eprintln!(" {}", e);
|
eprintln!(" {}", e);
|
||||||
}
|
}
|
||||||
|
@ -330,22 +331,21 @@ async fn format_source_files(
|
||||||
let file_contents = read_file_contents(&file_path)?;
|
let file_contents = read_file_contents(&file_path)?;
|
||||||
|
|
||||||
match format_file(&file_path, &file_contents.text, fmt_options.clone()) {
|
match format_file(&file_path, &file_contents.text, fmt_options.clone()) {
|
||||||
Ok(formatted_text) => {
|
Ok(Some(formatted_text)) => {
|
||||||
if formatted_text != file_contents.text {
|
write_file_contents(
|
||||||
write_file_contents(
|
&file_path,
|
||||||
&file_path,
|
FileContents {
|
||||||
FileContents {
|
had_bom: file_contents.had_bom,
|
||||||
had_bom: file_contents.had_bom,
|
text: formatted_text,
|
||||||
text: formatted_text,
|
},
|
||||||
},
|
)?;
|
||||||
)?;
|
formatted_files_count.fetch_add(1, Ordering::Relaxed);
|
||||||
formatted_files_count.fetch_add(1, Ordering::Relaxed);
|
let _g = output_lock.lock();
|
||||||
let _g = output_lock.lock().unwrap();
|
info!("{}", file_path.to_string_lossy());
|
||||||
info!("{}", file_path.to_string_lossy());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Ok(None) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _g = output_lock.lock().unwrap();
|
let _g = output_lock.lock();
|
||||||
eprintln!("Error formatting: {}", file_path.to_string_lossy());
|
eprintln!("Error formatting: {}", file_path.to_string_lossy());
|
||||||
eprintln!(" {}", e);
|
eprintln!(" {}", e);
|
||||||
}
|
}
|
||||||
|
@ -388,11 +388,11 @@ pub fn format_stdin(
|
||||||
|
|
||||||
let formatted_text = format_file(&file_path, &source, fmt_options)?;
|
let formatted_text = format_file(&file_path, &source, fmt_options)?;
|
||||||
if fmt_flags.check {
|
if fmt_flags.check {
|
||||||
if formatted_text != source {
|
if formatted_text.is_some() {
|
||||||
println!("Not formatted stdin");
|
println!("Not formatted stdin");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stdout().write_all(formatted_text.as_bytes())?;
|
stdout().write_all(formatted_text.unwrap_or(source).as_bytes())?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,9 +369,7 @@ async fn get_tls_config(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.with_single_cert(certs, PrivateKey(key))
|
.with_single_cert(certs, PrivateKey(key))
|
||||||
.map_err(|e| {
|
.map_err(|e| anyhow!("Error setting cert: {:?}", e))
|
||||||
anyhow!("Error setting cert: {:?}", e);
|
|
||||||
})
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
match http_versions {
|
match http_versions {
|
||||||
|
|
Loading…
Reference in a new issue