fix: replace unmaintained crates yaml-rust, dirs-next (#5887)

This commit is contained in:
David Knaack
2024-03-29 12:14:57 +01:00
committed by GitHub
parent e4d0c2db5a
commit 796a411602
11 changed files with 131 additions and 30 deletions
+1 -2
View File
@@ -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| {
+1 -1
View File
@@ -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")
})
+1 -1
View File
@@ -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())
}
+2 -2
View File
@@ -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())
@@ -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",
+1 -1
View File
@@ -1,4 +1,4 @@
use yaml_rust::YamlLoader;
use yaml_rust2::YamlLoader;
use std::borrow::Cow;
use std::env;
+1 -1
View File
@@ -1,4 +1,4 @@
use yaml_rust::YamlLoader;
use yaml_rust2::YamlLoader;
use super::{Context, Module, ModuleConfig};
+4 -4
View File
@@ -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)
@@ -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)
@@ -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)
@@ -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)
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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] = &[