1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

chore: upgrade dprint-core to 0.54.1 (#14146)

This commit is contained in:
David Sherret 2022-03-29 13:33:00 -04:00 committed by GitHub
parent d983b577bc
commit 03c71a8b4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 77 additions and 71 deletions

View file

@ -45,9 +45,9 @@
"tools/wpt/manifest.json"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.65.1.wasm",
"https://plugins.dprint.dev/json-0.14.1.wasm",
"https://plugins.dprint.dev/markdown-0.12.2.wasm",
"https://plugins.dprint.dev/typescript-0.66.0.wasm",
"https://plugins.dprint.dev/json-0.15.0.wasm",
"https://plugins.dprint.dev/markdown-0.13.0.wasm",
"https://plugins.dprint.dev/toml-0.5.4.wasm",
"https://plugins.dprint.dev/exec-0.2.1.exe-plugin@0a89a91810a212d9413e26d8946d41fbab3e2b5400362d764a1523839c4d78ea"
]

29
Cargo.lock generated
View file

@ -115,9 +115,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.55"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
[[package]]
name = "arrayvec"
@ -1264,21 +1264,22 @@ dependencies = [
[[package]]
name = "dprint-core"
version = "0.50.0"
version = "0.54.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a596556533e5739e71dfe105c8b4496c3eccaf5aa96d14b19db2fdf4157085a"
checksum = "4ac67835685dd407cfb415eec8a114bafa6ab6de9bad29ba93d29f874f40bc1a"
dependencies = [
"anyhow",
"bumpalo",
"indexmap",
"rustc-hash",
"serde",
]
[[package]]
name = "dprint-plugin-json"
version = "0.14.1"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d7673b479d64372e60e344722789ed9c61ea1023e9a8a13c7da8e7d63b0f7dc"
checksum = "1a83f35e23681206c2a69a65946e66e5bb692543c6e0377c32208452a8995fe2"
dependencies = [
"anyhow",
"dprint-core",
@ -1289,9 +1290,9 @@ dependencies = [
[[package]]
name = "dprint-plugin-markdown"
version = "0.12.2"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00a8c4e905bf5c95dbcc6eab7d81a1d884f7fbd0e7f2fd99af0154692fabc8a8"
checksum = "254ee918c51c21fa6ca20fe9556f3177b0b5be141df64952c6e353d17dbb5923"
dependencies = [
"anyhow",
"dprint-core",
@ -1302,9 +1303,9 @@ dependencies = [
[[package]]
name = "dprint-plugin-typescript"
version = "0.65.1"
version = "0.66.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e482c9fe4929ec672d2bdaf0b6dcfee88684ec23858f0c54f225b565f08882ac"
checksum = "e464d85d3db3ba0c53b1bf207f13d32aba614ff5c032497f240938738568bc20"
dependencies = [
"anyhow",
"deno_ast",
@ -3641,9 +3642,9 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.133"
version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
dependencies = [
"serde_derive",
]
@ -3659,9 +3660,9 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.133"
version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
dependencies = [
"proc-macro2 1.0.36",
"quote 1.0.14",

View file

@ -37,7 +37,7 @@ deno_webgpu = { version = "0.45.0", path = "../ext/webgpu" }
deno_websocket = { version = "0.49.0", path = "../ext/websocket" }
deno_webstorage = { version = "0.39.0", path = "../ext/webstorage" }
regex = "=1.5.5"
serde = { version = "=1.0.133", features = ["derive"] }
serde = { version = "=1.0.136", features = ["derive"] }
zstd = '=0.9.2'
[target.'cfg(windows)'.build-dependencies]
@ -62,9 +62,9 @@ clap_complete = "=3.1.1"
clap_complete_fig = "=3.1.4"
data-url = "=0.1.1"
dissimilar = "=1.0.2"
dprint-plugin-json = "=0.14.1"
dprint-plugin-markdown = "=0.12.2"
dprint-plugin-typescript = "=0.65.1"
dprint-plugin-json = "=0.15.0"
dprint-plugin-markdown = "=0.13.0"
dprint-plugin-typescript = "=0.66.0"
encoding_rs = "=0.8.29"
env_logger = "=0.8.4"
eszip = "=0.18.0"
@ -87,7 +87,7 @@ ring = "=0.16.20"
rustyline = { version = "=9.1.2", default-features = false }
rustyline-derive = "=0.6.0"
semver-parser = "=0.10.2"
serde = { version = "=1.0.133", features = ["derive"] }
serde = { version = "=1.0.136", features = ["derive"] }
shell-escape = "=0.1.5"
sourcemap = "=6.0.1"
tempfile = "=3.2.0"

View file

@ -45,7 +45,10 @@ impl Lockfile {
let j = json!(&self.map);
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()
.write(true)
.create(true)

View file

@ -1063,11 +1063,13 @@ impl Inner {
};
match format_result {
Ok(new_text) => Some(text::get_edits(
document.content().as_str(),
&new_text,
document.line_index().as_ref(),
)),
Ok(new_text) => new_text.map(|new_text| {
text::get_edits(
document.content().as_str(),
&new_text,
document.line_index().as_ref(),
)
}),
Err(err) => {
// TODO(lucacasonato): handle error properly
warn!("Format error: {}", err);

View file

@ -126,8 +126,10 @@ impl CoverageCollector {
let mut out = BufWriter::new(File::create(filepath)?);
let coverage = serde_json::to_string(&script_coverage)?;
let formated_coverage =
format_json(&coverage, &Default::default()).unwrap_or(coverage);
let formated_coverage = format_json(&coverage, &Default::default())
.ok()
.flatten()
.unwrap_or(coverage);
out.write_all(formated_coverage.as_bytes())?;
out.flush()?;

View file

@ -14,9 +14,11 @@ use crate::config_file::ProseWrap;
use crate::diff::diff;
use crate::file_watcher;
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::{collect_files, get_extension};
use crate::text_encoding;
use deno_ast::ParsedSource;
use deno_core::anyhow::bail;
@ -24,9 +26,9 @@ use deno_core::anyhow::Context;
use deno_core::error::generic_error;
use deno_core::error::AnyError;
use deno_core::futures;
use deno_core::parking_lot::Mutex;
use log::debug;
use log::info;
use std::borrow::Cow;
use std::fs;
use std::io::stdin;
use std::io::stdout;
@ -34,8 +36,9 @@ use std::io::Read;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::Arc;
/// Format JavaScript/TypeScript files.
pub async fn format(
@ -167,7 +170,7 @@ pub async fn format(
fn format_markdown(
file_text: &str,
fmt_options: &FmtOptionsConfig,
) -> Result<String, AnyError> {
) -> Result<Option<String>, AnyError> {
let markdown_config = get_resolved_markdown_config(fmt_options);
dprint_plugin_markdown::format_text(
file_text,
@ -196,7 +199,7 @@ fn format_markdown(
if matches!(extension, "json" | "jsonc") {
let mut json_config = get_resolved_json_config(fmt_options);
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 {
let fake_filename =
PathBuf::from(format!("deno_fmt_stdin.{}", extension));
@ -208,10 +211,9 @@ fn format_markdown(
text,
&codeblock_config,
)
.map(Cow::Owned)
}
} else {
Ok(Cow::Borrowed(text))
Ok(None)
}
},
)
@ -223,7 +225,7 @@ fn format_markdown(
pub fn format_json(
file_text: &str,
fmt_options: &FmtOptionsConfig,
) -> Result<String, AnyError> {
) -> Result<Option<String>, AnyError> {
let config = get_resolved_json_config(fmt_options);
dprint_plugin_json::format_text(file_text, &config)
}
@ -233,7 +235,7 @@ pub fn format_file(
file_path: &Path,
file_text: &str,
fmt_options: FmtOptionsConfig,
) -> Result<String, AnyError> {
) -> Result<Option<String>, AnyError> {
let ext = get_extension(file_path).unwrap_or_default();
if matches!(
ext.as_str(),
@ -251,7 +253,7 @@ pub fn format_file(
pub fn format_parsed_source(
parsed_source: &ParsedSource,
fmt_options: FmtOptionsConfig,
) -> Result<String, AnyError> {
) -> Result<Option<String>, AnyError> {
dprint_plugin_typescript::format_parsed_source(
parsed_source,
&get_resolved_typescript_config(&fmt_options),
@ -276,18 +278,17 @@ async fn check_source_files(
let file_text = read_file_contents(&file_path)?.text;
match format_file(&file_path, &file_text, fmt_options.clone()) {
Ok(formatted_text) => {
if formatted_text != file_text {
not_formatted_files_count.fetch_add(1, Ordering::Relaxed);
let _g = output_lock.lock().unwrap();
let diff = diff(&file_text, &formatted_text);
info!("");
info!("{} {}:", colors::bold("from"), file_path.display());
info!("{}", diff);
}
Ok(Some(formatted_text)) => {
not_formatted_files_count.fetch_add(1, Ordering::Relaxed);
let _g = output_lock.lock();
let diff = diff(&file_text, &formatted_text);
info!("");
info!("{} {}:", colors::bold("from"), file_path.display());
info!("{}", diff);
}
Ok(None) => {}
Err(e) => {
let _g = output_lock.lock().unwrap();
let _g = output_lock.lock();
eprintln!("Error checking: {}", file_path.to_string_lossy());
eprintln!(" {}", e);
}
@ -330,22 +331,21 @@ async fn format_source_files(
let file_contents = read_file_contents(&file_path)?;
match format_file(&file_path, &file_contents.text, fmt_options.clone()) {
Ok(formatted_text) => {
if formatted_text != file_contents.text {
write_file_contents(
&file_path,
FileContents {
had_bom: file_contents.had_bom,
text: formatted_text,
},
)?;
formatted_files_count.fetch_add(1, Ordering::Relaxed);
let _g = output_lock.lock().unwrap();
info!("{}", file_path.to_string_lossy());
}
Ok(Some(formatted_text)) => {
write_file_contents(
&file_path,
FileContents {
had_bom: file_contents.had_bom,
text: formatted_text,
},
)?;
formatted_files_count.fetch_add(1, Ordering::Relaxed);
let _g = output_lock.lock();
info!("{}", file_path.to_string_lossy());
}
Ok(None) => {}
Err(e) => {
let _g = output_lock.lock().unwrap();
let _g = output_lock.lock();
eprintln!("Error formatting: {}", file_path.to_string_lossy());
eprintln!(" {}", e);
}
@ -388,11 +388,11 @@ pub fn format_stdin(
let formatted_text = format_file(&file_path, &source, fmt_options)?;
if fmt_flags.check {
if formatted_text != source {
if formatted_text.is_some() {
println!("Not formatted stdin");
}
} else {
stdout().write_all(formatted_text.as_bytes())?;
stdout().write_all(formatted_text.unwrap_or(source).as_bytes())?;
}
Ok(())
}

View file

@ -369,9 +369,7 @@ async fn get_tls_config(
),
)
.with_single_cert(certs, PrivateKey(key))
.map_err(|e| {
anyhow!("Error setting cert: {:?}", e);
})
.map_err(|e| anyhow!("Error setting cert: {:?}", e))
.unwrap();
match http_versions {