Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): migrate dirs_next to dirs #9929

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changes/dirs-next-dirs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"tauri": patch:breaking
"tauri-build": patch:breaking
"tauri-bundler": patch:breaking
"tauri-cli": patch:breaking
"@tauri-apps/cli": patch:breaking
amrbashir marked this conversation as resolved.
Show resolved Hide resolved
---

Switch from `dirs_next` to `dirs` as `dirs_next` is now unmaintained while `dirs` is
34 changes: 20 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion core/tauri-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ json-patch = "1.2"
walkdir = "2"
tauri-winres = "0.1"
semver = "1"
dirs-next = "2"
dirs = "5"
glob = "0.3"
toml = "0.8"
schemars = { version = "0.8.18", features = [ "preserve_order" ] }
Expand Down
2 changes: 1 addition & 1 deletion core/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fn copy_frameworks(dest_dir: &Path, frameworks: &[String]) -> Result<()> {
framework
));
}
if let Some(home_dir) = dirs_next::home_dir() {
if let Some(home_dir) = dirs::home_dir() {
if copy_framework_from(&home_dir.join("Library/Frameworks/"), framework, dest_dir)? {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion core/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ getrandom = "0.2"
serde_repr = "0.1"
state = "0.6"
http = "1.1"
dirs-next = "2.0"
dirs = "5"
percent-encoding = "2.3"
reqwest = { version = "0.12", default-features = false, features = [ "json", "stream" ] }
bytes = { version = "1", features = [ "serde" ] }
Expand Down
44 changes: 22 additions & 22 deletions core/tauri/src/path/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Music`.
/// - **Windows:** Resolves to `{FOLDERID_Music}`.
pub fn audio_dir(&self) -> Result<PathBuf> {
dirs_next::audio_dir().ok_or(Error::UnknownPath)
dirs::audio_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's cache directory.
Expand All @@ -29,7 +29,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Library/Caches`.
/// - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
pub fn cache_dir(&self) -> Result<PathBuf> {
dirs_next::cache_dir().ok_or(Error::UnknownPath)
dirs::cache_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's config directory.
Expand All @@ -40,7 +40,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Library/Application Support`.
/// - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
pub fn config_dir(&self) -> Result<PathBuf> {
dirs_next::config_dir().ok_or(Error::UnknownPath)
dirs::config_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's data directory.
Expand All @@ -51,7 +51,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Library/Application Support`.
/// - **Windows:** Resolves to `{FOLDERID_RoamingAppData}`.
pub fn data_dir(&self) -> Result<PathBuf> {
dirs_next::data_dir().ok_or(Error::UnknownPath)
dirs::data_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's local data directory.
Expand All @@ -62,7 +62,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Library/Application Support`.
/// - **Windows:** Resolves to `{FOLDERID_LocalAppData}`.
pub fn local_data_dir(&self) -> Result<PathBuf> {
dirs_next::data_local_dir().ok_or(Error::UnknownPath)
dirs::data_local_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's desktop directory.
Expand All @@ -73,7 +73,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Desktop`.
/// - **Windows:** Resolves to `{FOLDERID_Desktop}`.
pub fn desktop_dir(&self) -> Result<PathBuf> {
dirs_next::desktop_dir().ok_or(Error::UnknownPath)
dirs::desktop_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's document directory.
Expand All @@ -84,7 +84,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Documents`.
/// - **Windows:** Resolves to `{FOLDERID_Documents}`.
pub fn document_dir(&self) -> Result<PathBuf> {
dirs_next::document_dir().ok_or(Error::UnknownPath)
dirs::document_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's download directory.
Expand All @@ -95,7 +95,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Downloads`.
/// - **Windows:** Resolves to `{FOLDERID_Downloads}`.
pub fn download_dir(&self) -> Result<PathBuf> {
dirs_next::download_dir().ok_or(Error::UnknownPath)
dirs::download_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's executable directory.
Expand All @@ -106,7 +106,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Not supported.
/// - **Windows:** Not supported.
pub fn executable_dir(&self) -> Result<PathBuf> {
dirs_next::executable_dir().ok_or(Error::UnknownPath)
dirs::executable_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's font directory.
Expand All @@ -117,7 +117,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Library/Fonts`.
/// - **Windows:** Not supported.
pub fn font_dir(&self) -> Result<PathBuf> {
dirs_next::font_dir().ok_or(Error::UnknownPath)
dirs::font_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's home directory.
Expand All @@ -128,7 +128,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME`.
/// - **Windows:** Resolves to `{FOLDERID_Profile}`.
pub fn home_dir(&self) -> Result<PathBuf> {
dirs_next::home_dir().ok_or(Error::UnknownPath)
dirs::home_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's picture directory.
Expand All @@ -139,7 +139,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Pictures`.
/// - **Windows:** Resolves to `{FOLDERID_Pictures}`.
pub fn picture_dir(&self) -> Result<PathBuf> {
dirs_next::picture_dir().ok_or(Error::UnknownPath)
dirs::picture_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's public directory.
Expand All @@ -150,7 +150,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Public`.
/// - **Windows:** Resolves to `{FOLDERID_Public}`.
pub fn public_dir(&self) -> Result<PathBuf> {
dirs_next::public_dir().ok_or(Error::UnknownPath)
dirs::public_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's runtime directory.
Expand All @@ -161,7 +161,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Not supported.
/// - **Windows:** Not supported.
pub fn runtime_dir(&self) -> Result<PathBuf> {
dirs_next::runtime_dir().ok_or(Error::UnknownPath)
dirs::runtime_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's template directory.
Expand All @@ -172,7 +172,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Not supported.
/// - **Windows:** Resolves to `{FOLDERID_Templates}`.
pub fn template_dir(&self) -> Result<PathBuf> {
dirs_next::template_dir().ok_or(Error::UnknownPath)
dirs::template_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the user's video dir
Expand All @@ -183,7 +183,7 @@ impl<R: Runtime> PathResolver<R> {
/// - **macOS:** Resolves to `$HOME/Movies`.
/// - **Windows:** Resolves to `{FOLDERID_Videos}`.
pub fn video_dir(&self) -> Result<PathBuf> {
dirs_next::video_dir().ok_or(Error::UnknownPath)
dirs::video_dir().ok_or(Error::UnknownPath)
}

/// Returns the path to the resource directory of this app.
Expand All @@ -196,7 +196,7 @@ impl<R: Runtime> PathResolver<R> {
///
/// Resolves to [`config_dir`](self.config_dir)`/${bundle_identifier}`.
pub fn app_config_dir(&self) -> Result<PathBuf> {
dirs_next::config_dir()
dirs::config_dir()
.ok_or(Error::UnknownPath)
.map(|dir| dir.join(&self.0.config().identifier))
}
Expand All @@ -205,7 +205,7 @@ impl<R: Runtime> PathResolver<R> {
///
/// Resolves to [`data_dir`](self.data_dir)`/${bundle_identifier}`.
pub fn app_data_dir(&self) -> Result<PathBuf> {
dirs_next::data_dir()
dirs::data_dir()
.ok_or(Error::UnknownPath)
.map(|dir| dir.join(&self.0.config().identifier))
}
Expand All @@ -214,7 +214,7 @@ impl<R: Runtime> PathResolver<R> {
///
/// Resolves to [`local_data_dir`](self.local_data_dir)`/${bundle_identifier}`.
pub fn app_local_data_dir(&self) -> Result<PathBuf> {
dirs_next::data_local_dir()
dirs::data_local_dir()
.ok_or(Error::UnknownPath)
.map(|dir| dir.join(&self.0.config().identifier))
}
Expand All @@ -223,7 +223,7 @@ impl<R: Runtime> PathResolver<R> {
///
/// Resolves to [`cache_dir`](self.cache_dir)`/${bundle_identifier}`.
pub fn app_cache_dir(&self) -> Result<PathBuf> {
dirs_next::cache_dir()
dirs::cache_dir()
.ok_or(Error::UnknownPath)
.map(|dir| dir.join(&self.0.config().identifier))
}
Expand All @@ -237,12 +237,12 @@ impl<R: Runtime> PathResolver<R> {
/// - **Windows:** Resolves to [`data_local_dir`](self.data_local_dir)`/${bundle_identifier}/logs`.
pub fn app_log_dir(&self) -> Result<PathBuf> {
#[cfg(target_os = "macos")]
let path = dirs_next::home_dir()
let path = dirs::home_dir()
.ok_or(Error::UnknownPath)
.map(|dir| dir.join("Library/Logs").join(&self.0.config().identifier));

#[cfg(not(target_os = "macos"))]
let path = dirs_next::data_local_dir()
let path = dirs::data_local_dir()
.ok_or(Error::UnknownPath)
.map(|dir| dir.join(&self.0.config().identifier).join("logs"));

Expand Down
2 changes: 1 addition & 1 deletion core/tauri/src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'de> Deserialize<'de> for SafePathBuf {
/// The base directory is the optional root of a file system operation.
/// If informed by the API call, all paths will be relative to the path of the given directory.
///
/// For more information, check the [`dirs_next` documentation](https://docs.rs/dirs_next/).
/// For more information, check the [`dirs` documentation](https://docs.rs/dirs/).
#[derive(Serialize_repr, Deserialize_repr, Clone, Copy, Debug)]
#[repr(u16)]
#[non_exhaustive]
Expand Down
2 changes: 1 addition & 1 deletion tooling/bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ walkdir = "2"
handlebars = "5.1"
tempfile = "3.10.1"
log = { version = "0.4.21", features = [ "kv" ] }
dirs-next = "2.0"
dirs = "5"
os_pipe = "1"
ureq = { version = "2.9.6", default-features = false, features = [ "socks-proxy" ] }
native-tls = { version = "0.2", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion tooling/bundler/src/bundle/linux/appimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
sh_map.insert("app_name", settings.product_name());
sh_map.insert("app_name_uppercase", &upcase_app_name);
sh_map.insert("appimage_filename", &appimage_filename);
let tauri_tools_path = dirs_next::cache_dir().map_or_else(
let tauri_tools_path = dirs::cache_dir().map_or_else(
|| output_path.to_path_buf(),
|mut p| {
p.push("tauri");
Expand Down
2 changes: 1 addition & 1 deletion tooling/bundler/src/bundle/macos/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ fn copy_frameworks_to_bundle(
framework
)));
}
if let Some(home_dir) = dirs_next::home_dir() {
if let Some(home_dir) = dirs::home_dir() {
if copy_framework_from(&dest_dir, framework, &home_dir.join("Library/Frameworks/"))? {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion tooling/bundler/src/bundle/macos/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ pub fn notarize_auth() -> Result<NotarizeAuth, NotarizeAuthError> {
let mut key_path = None;

let mut search_paths = vec!["./private_keys".into()];
if let Some(home_dir) = dirs_next::home_dir() {
if let Some(home_dir) = dirs::home_dir() {
search_paths.push(home_dir.join("private_keys"));
search_paths.push(home_dir.join(".private_keys"));
search_paths.push(home_dir.join(".appstoreconnect").join("private_keys"));
Expand Down
2 changes: 1 addition & 1 deletion tooling/bundler/src/bundle/windows/msi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const WIX_REQUIRED_FILES: &[&str] = &[
/// Runs all of the commands to build the MSI installer.
/// Returns a vector of PathBuf that shows where the MSI was created.
pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<PathBuf>> {
let mut wix_path = dirs_next::cache_dir().unwrap();
let mut wix_path = dirs::cache_dir().unwrap();
wix_path.push("tauri/WixTools");

if !wix_path.exists() {
Expand Down
4 changes: 2 additions & 2 deletions tooling/bundler/src/bundle/windows/nsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const NSIS_REQUIRED_FILES_HASH: &[(&str, &str, &str, HashAlgorithm)] = &[(
/// Runs all of the commands to build the NSIS installer.
/// Returns a vector of PathBuf that shows where the NSIS installer was created.
pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<PathBuf>> {
let tauri_tools_path = dirs_next::cache_dir().unwrap().join("tauri");
let tauri_tools_path = dirs::cache_dir().unwrap().join("tauri");
let nsis_toolset_path = tauri_tools_path.join("NSIS");

if !nsis_toolset_path.exists() {
Expand Down Expand Up @@ -176,7 +176,7 @@ fn build_nsis_app_installer(

#[cfg(not(target_os = "windows"))]
{
let mut dir = dirs_next::cache_dir().unwrap();
let mut dir = dirs::cache_dir().unwrap();
dir.extend(["tauri", "NSIS", "Plugins", "x86-unicode"]);
data.insert("additional_plugins_path", to_json(dir));
}
Expand Down
Loading