Skip to content

Commit

Permalink
fix: replace unmaintained crates yaml-rust, dirs-next (#5887)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkna authored Mar 29, 2024
1 parent e4d0c2d commit 796a411
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 30 deletions.
130 changes: 116 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ gix-faster = ["gix-features/zlib-stock", "gix/fast-sha1"]
chrono = { version = "0.4.37", default-features = false, features = ["clock", "std", "wasmbind"] }
clap = { version = "4.5.4", features = ["derive", "cargo", "unicode"] }
clap_complete = "4.5.1"
dirs-next = "2.0.0"
dirs = "5.0.1"
dunce = "1.0.4"
gethostname = "0.4.3"
# default feature restriction addresses https://github.com/starship/starship/issues/4251
Expand Down Expand Up @@ -87,7 +87,7 @@ unicode-width = "0.1.11"
urlencoding = "2.1.3"
versions = "6.2.0"
which = "6.0.1"
yaml-rust = "0.4.5"
yaml-rust2 = "0.7.0"

process_control = { version = "4.1.0", features = ["crossbeam-channel"] }

Expand Down
3 changes: 1 addition & 2 deletions src/bug_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ fn get_terminal_info() -> TerminalInfo {

fn get_config_path(shell: &str) -> Option<PathBuf> {
if shell == "nu" {
return dirs_next::config_dir()
.map(|config_dir| config_dir.join("nushell").join("config.nu"));
return dirs::config_dir().map(|config_dir| config_dir.join("nushell").join("config.nu"));
}

utils::home_dir().and_then(|home_dir| {
Expand Down
2 changes: 1 addition & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn get_log_dir() -> PathBuf {
.unwrap_or_else(|| {
utils::home_dir()
.map(|home| home.join(".cache"))
.or_else(dirs_next::cache_dir)
.or_else(dirs::cache_dir)
.unwrap_or_else(std::env::temp_dir)
.join("starship")
})
Expand Down
2 changes: 1 addition & 1 deletion src/modules/daml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn get_daml_sdk_version(context: &Context) -> Option<String> {

fn read_sdk_version_from_daml_yaml(context: &Context) -> Option<String> {
let file_contents = context.read_file_from_pwd(DAML_YAML)?;
let daml_yaml = yaml_rust::YamlLoader::load_from_str(&file_contents).ok()?;
let daml_yaml = yaml_rust2::YamlLoader::load_from_str(&file_contents).ok()?;
let sdk_version = daml_yaml.first()?[DAML_SDK_VERSION].as_str()?;
Some(sdk_version.to_string())
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/haskell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn get_snapshot(context: &Context) -> Option<String> {
return None;
}
let file_contents = context.read_file_from_pwd("stack.yaml")?;
let yaml = yaml_rust::YamlLoader::load_from_str(&file_contents).ok()?;
let yaml = yaml_rust2::YamlLoader::load_from_str(&file_contents).ok()?;
let version = yaml.first()?["resolver"]
.as_str()
.or_else(|| yaml.first()?["snapshot"].as_str())
Expand Down Expand Up @@ -105,7 +105,7 @@ mod tests {
fn folder_stack() -> io::Result<()> {
let cases = vec![
("resolver: lts-18.12\n", "lts-18.12"),
("snapshot:\tnightly-2011-11-11", "nightly-2011-11-11"),
("snapshot: nightly-2011-11-11", "nightly-2011-11-11"),
("snapshot: ghc-8.10.7", "ghc-8.10.7"),
(
"snapshot: https://github.com/whatever/xxx.yaml\n",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/kubernetes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yaml_rust::YamlLoader;
use yaml_rust2::YamlLoader;

use std::borrow::Cow;
use std::env;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/openstack.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yaml_rust::YamlLoader;
use yaml_rust2::YamlLoader;

use super::{Context, Module, ModuleConfig};

Expand Down
8 changes: 4 additions & 4 deletions src/modules/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn get_julia_project_version(context: &Context, config: &PackageConfig) -> Optio

fn get_helm_package_version(context: &Context, config: &PackageConfig) -> Option<String> {
let file_contents = context.read_file_from_pwd("Chart.yaml")?;
let yaml = yaml_rust::YamlLoader::load_from_str(&file_contents).ok()?;
let yaml = yaml_rust2::YamlLoader::load_from_str(&file_contents).ok()?;
let version = yaml.first()?["version"].as_str()?;

format_version(version, config.version_format)
Expand Down Expand Up @@ -286,7 +286,7 @@ fn get_nimble_version(context: &Context, config: &PackageConfig) -> Option<Strin
fn get_shard_version(context: &Context, config: &PackageConfig) -> Option<String> {
let file_contents = context.read_file_from_pwd("shard.yml")?;

let data = yaml_rust::YamlLoader::load_from_str(&file_contents).ok()?;
let data = yaml_rust2::YamlLoader::load_from_str(&file_contents).ok()?;
let raw_version = data.first()?["version"].as_str()?;

format_version(raw_version, config.version_format)
Expand All @@ -295,7 +295,7 @@ fn get_shard_version(context: &Context, config: &PackageConfig) -> Option<String
fn get_daml_project_version(context: &Context, config: &PackageConfig) -> Option<String> {
let file_contents = context.read_file_from_pwd("daml.yaml")?;

let daml_yaml = yaml_rust::YamlLoader::load_from_str(&file_contents).ok()?;
let daml_yaml = yaml_rust2::YamlLoader::load_from_str(&file_contents).ok()?;
let raw_version = daml_yaml.first()?["version"].as_str()?;

format_version(raw_version, config.version_format)
Expand All @@ -304,7 +304,7 @@ fn get_daml_project_version(context: &Context, config: &PackageConfig) -> Option
fn get_dart_pub_version(context: &Context, config: &PackageConfig) -> Option<String> {
let file_contents = context.read_file_from_pwd("pubspec.yaml")?;

let data = yaml_rust::YamlLoader::load_from_str(&file_contents).ok()?;
let data = yaml_rust2::YamlLoader::load_from_str(&file_contents).ok()?;
let raw_version = data.first()?["version"].as_str()?;

format_version(raw_version, config.version_format)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/pulumi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::fs::File;
use std::io::{BufReader, Read};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use yaml_rust::{Yaml, YamlLoader};
use yaml_rust2::{Yaml, YamlLoader};

use super::{Context, Module, ModuleConfig};
use crate::configs::pulumi::PulumiConfig;
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ fn render_time_component((component, suffix): (&u128, &&str)) -> String {
}

pub fn home_dir() -> Option<PathBuf> {
dirs_next::home_dir()
dirs::home_dir()
}

const HEXTABLE: &[char] = &[
Expand Down

0 comments on commit 796a411

Please sign in to comment.