Skip to content

Commit

Permalink
fix: dprint 0.46 release for cargo install without --locked flag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed May 26, 2024
1 parent a811f53 commit 6b54df5
Show file tree
Hide file tree
Showing 8 changed files with 572 additions and 448 deletions.
923 changes: 522 additions & 401 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/core/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ mod test {
config.insert("oldProp".to_string(), ConfigKeyValue::from_str("value"));
handle_renamed_config_property(&mut config, "oldProp", "newProp", &mut diagnostics);
assert_eq!(config.len(), 1);
assert_eq!(config.remove("newProp").unwrap(), ConfigKeyValue::from_str("value"));
assert_eq!(config.shift_remove("newProp").unwrap(), ConfigKeyValue::from_str("value"));
assert_eq!(diagnostics.len(), 1);
assert_eq!(diagnostics[0].message, "The configuration key was renamed to 'newProp'");
assert_eq!(diagnostics[0].property_name, "oldProp");
Expand All @@ -509,7 +509,7 @@ mod test {
config.insert("newProp".to_string(), ConfigKeyValue::from_str("value"));
handle_renamed_config_property(&mut config, "oldProp", "newProp", &mut diagnostics);
assert_eq!(config.len(), 1);
assert_eq!(config.remove("newProp").unwrap(), ConfigKeyValue::from_str("value"));
assert_eq!(config.shift_remove("newProp").unwrap(), ConfigKeyValue::from_str("value"));
assert_eq!(diagnostics.len(), 1);
assert_eq!(diagnostics[0].message, "The configuration key was renamed to 'newProp'");
assert_eq!(diagnostics[0].property_name, "oldProp");
Expand Down
73 changes: 38 additions & 35 deletions crates/dprint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,47 @@ repository = "https://github.com/dprint/dprint"
description = "Binary for dprint code formatter—a pluggable and configurable code formatting platform."

[dependencies]
anyhow = "1.0.76"
clap = "4.4.11"
clap_complete = "4.4.4"
console_static_text = "0.8.2"
crossterm = "0.27.0" # manually retest everything when bumping this crate
dirs = "5.0.1"
dissimilar = "=1.0.7"
dprint-core = { path = "../core", version = "0.66.0", features = ["process", "wasm"] }
dunce = "1.0.4"
fs3 = "0.5.0"
ignore = "0.4.21"
indexmap = { version = "2.1.0", features = ["serde"] }
jsonc-parser = { version = "0.23.0", features = ["preserve_order"] }
once_cell = "1.19.0"
parking_lot = "0.12.1"
percent-encoding = "2.3.1"
rand = "0.8.5"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
sha2 = "0.10.8"
similar = { version = "2.3.0", features = ["inline"] }
# all these deps are pinned because `cargo install dprint` doesn't lock deps
# without the `--locked` flag so this helps reduce the chance of a dep being
# released that breaks compiling dprint
anyhow = "=1.0.86"
clap = "=4.5.4"
clap_complete = "=4.5.2"
console_static_text = "=0.8.2"
crossterm = "=0.27.0" # manually retest everything when bumping this crate
dirs = "=5.0.1"
dissimilar = "=1.0.9"
dprint-core = { path = "../core", version = "=0.66.2", features = ["process", "wasm"] }
dunce = "=1.0.4"
fs3 = "=0.5.0"
ignore = "=0.4.22"
indexmap = { version = "=2.2.6", features = ["serde"] }
jsonc-parser = { version = "=0.23.0", features = ["preserve_order"] }
once_cell = "=1.19.0"
parking_lot = "=0.12.3"
percent-encoding = "=2.3.1"
rand = "=0.8.5"
serde = { version = "=1.0.203", features = ["derive"] }
serde_json = { version = "=1.0.117", features = ["preserve_order"] }
sha2 = "=0.10.8"
similar = { version = "=2.5.0", features = ["inline"] }
# disable the multi-threading feature of this crate
sysinfo = { version = "0.30.1", default-features = false }
sysinfo = { version = "=0.30.12", default-features = false }
text-size = "=1.1.1"
thiserror = "1"
tokio = { version = "1", features = ["rt", "time", "macros", "rt-multi-thread", "io-std"] }
tokio-util = { version = "0.7.10" }
tower-lsp = "0.20.0"
twox-hash = "1.6.3"
url = "2.5.0"
zip = "0.6.6"
thiserror = "=1.0.61"
tokio = { version = "=1.37.0", features = ["rt", "time", "macros", "rt-multi-thread", "io-std"] }
tokio-util = { version = "=0.7.11" }
tower-lsp = "=0.20.0"
twox-hash = "=1.6.3"
url = "=2.5.0"
zip = "=2.1.0"

# keep these in sync
rustls = "0.21.8"
rustls-native-certs = "0.6.2"
rustls-pemfile = "1.0.3"
ureq = { version = "2.9.1", features = ["socks-proxy"] }
webpki-roots = "0.25.2"
rustls = "=0.21.8"
rustls-native-certs = "=0.6.2"
rustls-pemfile = "=1.0.3"
ureq = { version = "=2.9.1", features = ["socks-proxy"] }
webpki-roots = "=0.25.2"

# pin these to prevent them changing with `cargo install` because
# patch version increases of rkyv may cause panics when deserializing
Expand All @@ -58,7 +61,7 @@ wasmer = "=4.2.5"
wasmer-compiler = "=4.2.5"

[target.'cfg(windows)'.dependencies]
winreg = "0.52.0"
winreg = "=0.52.0"

[dev-dependencies]
# stay on this version because it's good enough and makes the output the same on all platforms
Expand Down
2 changes: 1 addition & 1 deletion crates/dprint/src/configuration/get_global_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn get_global_config(mut config_map: ConfigMap) -> GlobalConfigurationResult
let mut diagnostics = Vec::new();

// ignore this property
config_map.remove("$schema");
config_map.shift_remove("$schema");

// now get and resolve the global config
let mut global_config = get_global_config_from_config_map(&mut diagnostics, config_map);
Expand Down
2 changes: 1 addition & 1 deletion crates/dprint/src/configuration/get_plugin_config_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn get_plugin_config_map(plugin: &PluginWrapper, config_map: &mut ConfigMap)
fn get_plugin_config_map_inner(plugin: &PluginWrapper, config_map: &mut ConfigMap) -> Result<RawPluginConfig> {
let config_key = &plugin.info().config_key;

if let Some(plugin_config) = config_map.remove(config_key) {
if let Some(plugin_config) = config_map.shift_remove(config_key) {
if let ConfigMapValue::PluginConfig(plugin_config) = plugin_config {
Ok(plugin_config)
} else {
Expand Down
12 changes: 6 additions & 6 deletions crates/dprint/src/configuration/resolve_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub async fn resolve_config_from_path<TEnvironment: Environment>(
// control over what files get formatted.
if !resolved_config_path.resolved_path.is_local() {
// Careful! Don't be fancy and ensure this is removed.
let removed_includes = config_map.remove("includes"); // NEVER REMOVE THIS STATEMENT
let removed_includes = config_map.shift_remove("includes"); // NEVER REMOVE THIS STATEMENT
if removed_includes.is_some() && resolved_config_path.resolved_path.is_first_download {
log_warn!(environment, &get_warn_includes_message());
}
Expand All @@ -128,7 +128,7 @@ pub async fn resolve_config_from_path<TEnvironment: Environment>(
let excludes = take_array_from_config_map(&mut config_map, "excludes")?;

let incremental = take_bool_from_config_map(&mut config_map, "incremental")?;
config_map.remove("projectType"); // this was an old config property that's no longer used
config_map.shift_remove("projectType"); // this was an old config property that's no longer used
let extends = take_extends(&mut config_map)?;
let resolved_config = ResolvedConfig {
resolved_path: resolved_config_path.resolved_path.clone(),
Expand Down Expand Up @@ -184,7 +184,7 @@ async fn handle_config_file<TEnvironment: Environment>(
// we don't want it specifying something like system or some configuration
// files that it could change. Basically, the end user should have 100%
// control over what files get formatted.
let removed_includes = new_config_map.remove("includes"); // NEVER REMOVE THIS STATEMENT
let removed_includes = new_config_map.shift_remove("includes"); // NEVER REMOVE THIS STATEMENT
if removed_includes.is_some() && resolved_path.is_first_download {
log_warn!(environment, &get_warn_includes_message());
}
Expand Down Expand Up @@ -257,7 +257,7 @@ async fn handle_config_file<TEnvironment: Environment>(
}

fn take_extends(config_map: &mut ConfigMap) -> Result<Vec<String>> {
match config_map.remove("extends") {
match config_map.shift_remove("extends") {
Some(ConfigMapValue::KeyValue(ConfigKeyValue::String(url_or_file_path))) => Ok(vec![url_or_file_path]),
Some(ConfigMapValue::Vec(url_or_file_paths)) => Ok(url_or_file_paths),
Some(_) => bail!("Extends in configuration must be a string or an array of strings."),
Expand Down Expand Up @@ -293,15 +293,15 @@ fn take_plugins_array_from_config_map(
}

fn take_array_from_config_map(config_map: &mut ConfigMap, property_name: &str) -> Result<Option<Vec<String>>> {
match config_map.remove(property_name) {
match config_map.shift_remove(property_name) {
Some(ConfigMapValue::Vec(elements)) => Ok(Some(elements)),
Some(_) => bail!("Expected array in '{}' property.", property_name),
None => Ok(None),
}
}

fn take_bool_from_config_map(config_map: &mut ConfigMap, property_name: &str) -> Result<Option<bool>> {
if let Some(value) = config_map.remove(property_name) {
if let Some(value) = config_map.shift_remove(property_name) {
match value {
ConfigMapValue::KeyValue(ConfigKeyValue::Bool(value)) => Ok(Some(value)),
_ => bail!("Expected boolean in '{}' property.", property_name),
Expand Down
2 changes: 1 addition & 1 deletion crates/dprint/src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub static PROCESS_PLUGIN_ZIP_BYTES: Lazy<Vec<u8>> = Lazy::new(|| {
let buf: Vec<u8> = Vec::new();
let w = std::io::Cursor::new(buf);
let mut zip = zip::ZipWriter::new(w);
let options = zip::write::FileOptions::default().compression_method(zip::CompressionMethod::Stored);
let options = zip::write::SimpleFileOptions::default().compression_method(zip::CompressionMethod::Stored);
zip
.start_file(
if cfg!(target_os = "windows") {
Expand Down
2 changes: 1 addition & 1 deletion crates/test-process-plugin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl AsyncPluginHandler for TestProcessPluginHandler {
async fn resolve_config(&self, config: ConfigKeyMap, global_config: GlobalConfiguration) -> PluginResolveConfigurationResult<Configuration> {
// todo: way to do something like get_value in dprint-core, but with vectors
fn get_string_vec(config: &mut ConfigKeyMap, key: &str, diagnostics: &mut Vec<ConfigurationDiagnostic>) -> Option<Vec<String>> {
match config.remove(key) {
match config.shift_remove(key) {
Some(value) => match value {
ConfigKeyValue::Array(values) => {
let mut result = Vec::with_capacity(values.len());
Expand Down

0 comments on commit 6b54df5

Please sign in to comment.