mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
Switch from dirs_next 2.0 to dirs 5.0 (#13384)
<!-- if this PR closes one or more issues, you can automatically link the PR with them by using one of the [*linking keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword), e.g. - this PR should close #xxxx - fixes #xxxx you can also mention related issues, PRs or discussions! --> # Description <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> Replaces the `dirs_next` family of crates with `dirs`. `dirs_next` was born when the `dirs` crates were abandoned three years ago, but they're being maintained again and most projects depend on `dirs` nowadays. `dirs_next` has been abandoned since. This came up while working on https://github.com/nushell/nushell/pull/13382. # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> None. # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> Tests and formatter have been run. # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
This commit is contained in:
parent
1981c50c8f
commit
b66671d339
11 changed files with 37 additions and 31 deletions
30
Cargo.lock
generated
30
Cargo.lock
generated
|
@ -1219,24 +1219,24 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-next"
|
name = "dirs"
|
||||||
version = "2.0.0"
|
version = "5.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
|
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"dirs-sys",
|
||||||
"dirs-sys-next",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-sys-next"
|
name = "dirs-sys"
|
||||||
version = "0.1.2"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
|
"option-ext",
|
||||||
"redox_users",
|
"redox_users",
|
||||||
"winapi",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2873,7 +2873,7 @@ dependencies = [
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"dirs-next",
|
"dirs",
|
||||||
"log",
|
"log",
|
||||||
"miette",
|
"miette",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
@ -3047,7 +3047,7 @@ dependencies = [
|
||||||
"deunicode",
|
"deunicode",
|
||||||
"dialoguer",
|
"dialoguer",
|
||||||
"digest",
|
"digest",
|
||||||
"dirs-next",
|
"dirs",
|
||||||
"dtparse",
|
"dtparse",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
"fancy-regex",
|
"fancy-regex",
|
||||||
|
@ -3245,7 +3245,7 @@ dependencies = [
|
||||||
name = "nu-path"
|
name = "nu-path"
|
||||||
version = "0.95.1"
|
version = "0.95.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-next",
|
"dirs",
|
||||||
"omnipath",
|
"omnipath",
|
||||||
"pwd",
|
"pwd",
|
||||||
]
|
]
|
||||||
|
@ -3836,6 +3836,12 @@ dependencies = [
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "option-ext"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ordered-multimap"
|
name = "ordered-multimap"
|
||||||
version = "0.7.3"
|
version = "0.7.3"
|
||||||
|
|
|
@ -83,7 +83,7 @@ ctrlc = "3.4"
|
||||||
deunicode = "1.6.0"
|
deunicode = "1.6.0"
|
||||||
dialoguer = { default-features = false, version = "0.11" }
|
dialoguer = { default-features = false, version = "0.11" }
|
||||||
digest = { default-features = false, version = "0.10" }
|
digest = { default-features = false, version = "0.10" }
|
||||||
dirs-next = "2.0"
|
dirs = "5.0"
|
||||||
dtparse = "2.0"
|
dtparse = "2.0"
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
fancy-regex = "0.13"
|
fancy-regex = "0.13"
|
||||||
|
@ -201,7 +201,7 @@ reedline = { workspace = true, features = ["bashisms", "sqlite"] }
|
||||||
|
|
||||||
crossterm = { workspace = true }
|
crossterm = { workspace = true }
|
||||||
ctrlc = { workspace = true }
|
ctrlc = { workspace = true }
|
||||||
dirs-next = { workspace = true }
|
dirs = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
miette = { workspace = true, features = ["fancy-no-backtrace", "fancy"] }
|
miette = { workspace = true, features = ["fancy-no-backtrace", "fancy"] }
|
||||||
mimalloc = { version = "0.1.42", default-features = false, optional = true }
|
mimalloc = { version = "0.1.42", default-features = false, optional = true }
|
||||||
|
@ -229,7 +229,7 @@ nu-test-support = { path = "./crates/nu-test-support", version = "0.95.1" }
|
||||||
nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.95.1" }
|
nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.95.1" }
|
||||||
nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.95.1" }
|
nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.95.1" }
|
||||||
assert_cmd = "2.0"
|
assert_cmd = "2.0"
|
||||||
dirs-next = { workspace = true }
|
dirs = { workspace = true }
|
||||||
tango-bench = "0.5"
|
tango-bench = "0.5"
|
||||||
pretty_assertions = { workspace = true }
|
pretty_assertions = { workspace = true }
|
||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
|
|
|
@ -140,10 +140,10 @@ trash-support = ["trash"]
|
||||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.1" }
|
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.1" }
|
||||||
nu-test-support = { path = "../nu-test-support", version = "0.95.1" }
|
nu-test-support = { path = "../nu-test-support", version = "0.95.1" }
|
||||||
|
|
||||||
dirs-next = { workspace = true }
|
dirs = { workspace = true }
|
||||||
mockito = { workspace = true, default-features = false }
|
mockito = { workspace = true, default-features = false }
|
||||||
quickcheck = { workspace = true }
|
quickcheck = { workspace = true }
|
||||||
quickcheck_macros = { workspace = true }
|
quickcheck_macros = { workspace = true }
|
||||||
rstest = { workspace = true, default-features = false }
|
rstest = { workspace = true, default-features = false }
|
||||||
pretty_assertions = { workspace = true }
|
pretty_assertions = { workspace = true }
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
|
|
|
@ -606,7 +606,7 @@ mod test {
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
|
|
||||||
let actual = expand_glob("~/foo.txt", cwd, Span::unknown(), &Signals::empty()).unwrap();
|
let actual = expand_glob("~/foo.txt", cwd, Span::unknown(), &Signals::empty()).unwrap();
|
||||||
let home = dirs_next::home_dir().expect("failed to get home dir");
|
let home = dirs::home_dir().expect("failed to get home dir");
|
||||||
let expected: Vec<OsString> = vec![home.join("foo.txt").into()];
|
let expected: Vec<OsString> = vec![home.join("foo.txt").into()];
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
})
|
})
|
||||||
|
|
|
@ -151,7 +151,7 @@ fn filesystem_change_to_home_directory() {
|
||||||
"
|
"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(Some(PathBuf::from(actual.out)), dirs_next::home_dir());
|
assert_eq!(Some(PathBuf::from(actual.out)), dirs::home_dir());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -309,7 +309,7 @@ fn external_arg_expand_tilde() {
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
|
||||||
let home = dirs_next::home_dir().expect("failed to find home dir");
|
let home = dirs::home_dir().expect("failed to find home dir");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual.out,
|
actual.out,
|
||||||
|
|
|
@ -12,10 +12,10 @@ exclude = ["/fuzz"]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dirs-next = { workspace = true }
|
dirs = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
omnipath = { workspace = true }
|
omnipath = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "android")))'.dependencies]
|
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "android")))'.dependencies]
|
||||||
pwd = { workspace = true }
|
pwd = { workspace = true }
|
||||||
|
|
|
@ -3,14 +3,14 @@ use omnipath::WinPathExt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn home_dir() -> Option<PathBuf> {
|
pub fn home_dir() -> Option<PathBuf> {
|
||||||
dirs_next::home_dir()
|
dirs::home_dir()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the data directory for the current platform or XDG_DATA_HOME if specified.
|
/// Return the data directory for the current platform or XDG_DATA_HOME if specified.
|
||||||
pub fn data_dir() -> Option<PathBuf> {
|
pub fn data_dir() -> Option<PathBuf> {
|
||||||
match std::env::var("XDG_DATA_HOME").map(PathBuf::from) {
|
match std::env::var("XDG_DATA_HOME").map(PathBuf::from) {
|
||||||
Ok(xdg_data) if xdg_data.is_absolute() => Some(canonicalize(&xdg_data).unwrap_or(xdg_data)),
|
Ok(xdg_data) if xdg_data.is_absolute() => Some(canonicalize(&xdg_data).unwrap_or(xdg_data)),
|
||||||
_ => get_canonicalized_path(dirs_next::data_dir()),
|
_ => get_canonicalized_path(dirs::data_dir()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ pub fn cache_dir() -> Option<PathBuf> {
|
||||||
Ok(xdg_cache) if xdg_cache.is_absolute() => {
|
Ok(xdg_cache) if xdg_cache.is_absolute() => {
|
||||||
Some(canonicalize(&xdg_cache).unwrap_or(xdg_cache))
|
Some(canonicalize(&xdg_cache).unwrap_or(xdg_cache))
|
||||||
}
|
}
|
||||||
_ => get_canonicalized_path(dirs_next::cache_dir()),
|
_ => get_canonicalized_path(dirs::cache_dir()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ pub fn config_dir() -> Option<PathBuf> {
|
||||||
Ok(xdg_config) if xdg_config.is_absolute() => {
|
Ok(xdg_config) if xdg_config.is_absolute() => {
|
||||||
Some(canonicalize(&xdg_config).unwrap_or(xdg_config))
|
Some(canonicalize(&xdg_config).unwrap_or(xdg_config))
|
||||||
}
|
}
|
||||||
_ => get_canonicalized_path(dirs_next::config_dir()),
|
_ => get_canonicalized_path(dirs::config_dir()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ fn user_home_dir(username: &str) -> PathBuf {
|
||||||
fn user_home_dir(username: &str) -> PathBuf {
|
fn user_home_dir(username: &str) -> PathBuf {
|
||||||
use std::path::Component;
|
use std::path::Component;
|
||||||
|
|
||||||
match dirs_next::home_dir() {
|
match dirs::home_dir() {
|
||||||
None => {
|
None => {
|
||||||
// Termux always has the same home directory
|
// Termux always has the same home directory
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
|
@ -145,7 +145,7 @@ fn expand_tilde_with_another_user_home(path: &Path) -> PathBuf {
|
||||||
/// Expand tilde ("~") into a home directory if it is the first path component
|
/// Expand tilde ("~") into a home directory if it is the first path component
|
||||||
pub fn expand_tilde(path: impl AsRef<Path>) -> PathBuf {
|
pub fn expand_tilde(path: impl AsRef<Path>) -> PathBuf {
|
||||||
// TODO: Extend this to work with "~user" style of home paths
|
// TODO: Extend this to work with "~user" style of home paths
|
||||||
expand_tilde_with_home(path, dirs_next::home_dir())
|
expand_tilde_with_home(path, dirs::home_dir())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -100,7 +100,7 @@ fn main() -> Result<()> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else if let Some(old_config) =
|
} else if let Some(old_config) =
|
||||||
nu_path::get_canonicalized_path(dirs_next::config_dir()).map(|p| p.join("nushell"))
|
nu_path::get_canonicalized_path(dirs::config_dir()).map(|p| p.join("nushell"))
|
||||||
{
|
{
|
||||||
let xdg_config_empty = nushell_config_path
|
let xdg_config_empty = nushell_config_path
|
||||||
.read_dir()
|
.read_dir()
|
||||||
|
|
|
@ -235,7 +235,7 @@ fn test_xdg_config_empty() {
|
||||||
playground.with_env("XDG_CONFIG_HOME", "");
|
playground.with_env("XDG_CONFIG_HOME", "");
|
||||||
|
|
||||||
let actual = run(playground, "$nu.default-config-dir");
|
let actual = run(playground, "$nu.default-config-dir");
|
||||||
let expected = dirs_next::config_dir().unwrap().join("nushell");
|
let expected = dirs::config_dir().unwrap().join("nushell");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual,
|
actual,
|
||||||
adjust_canonicalization(expected.canonicalize().unwrap_or(expected))
|
adjust_canonicalization(expected.canonicalize().unwrap_or(expected))
|
||||||
|
@ -250,7 +250,7 @@ fn test_xdg_config_bad() {
|
||||||
playground.with_env("XDG_CONFIG_HOME", xdg_config_home);
|
playground.with_env("XDG_CONFIG_HOME", xdg_config_home);
|
||||||
|
|
||||||
let actual = run(playground, "$nu.default-config-dir");
|
let actual = run(playground, "$nu.default-config-dir");
|
||||||
let expected = dirs_next::config_dir().unwrap().join("nushell");
|
let expected = dirs::config_dir().unwrap().join("nushell");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual,
|
actual,
|
||||||
adjust_canonicalization(expected.canonicalize().unwrap_or(expected))
|
adjust_canonicalization(expected.canonicalize().unwrap_or(expected))
|
||||||
|
|
Loading…
Reference in a new issue